From b8d85c6939eaa3fca676af832b5d64320b2296ca Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 30 Nov 2022 12:51:59 -0800 Subject: [PATCH] Update for SDL3 coding style (#6717) I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594 (cherry picked from commit 5750bcb174300011b91d1de20edb288fcca70f8c) --- .clang-format | 11 +- build-scripts/clang-format-src.sh | 32 + src/SDL.c | 57 +- src/SDL_assert.c | 106 +- src/SDL_dataqueue.c | 64 +- src/SDL_dataqueue.h | 1 - src/SDL_error.c | 16 +- src/SDL_guid.c | 8 +- src/SDL_hints.c | 24 +- src/SDL_internal.h | 33 +- src/SDL_list.c | 16 +- src/SDL_list.h | 1 - src/SDL_log.c | 145 +- src/atomic/SDL_atomic.c | 57 +- src/atomic/SDL_spinlock.c | 46 +- src/audio/SDL_audio.c | 415 +- src/audio/SDL_audio_c.h | 8 +- src/audio/SDL_audio_channel_converters.h | 579 +- src/audio/SDL_audio_resampler_filter.h | 7 +- src/audio/SDL_audiocvt.c | 560 +- src/audio/SDL_audiodev.c | 22 +- src/audio/SDL_audiodev_c.h | 6 +- src/audio/SDL_audiotypecvt.c | 880 +-- src/audio/SDL_mixer.c | 406 +- src/audio/SDL_sysaudio.h | 41 +- src/audio/SDL_wave.c | 259 +- src/audio/SDL_wave.h | 46 +- src/audio/aaudio/SDL_aaudio.c | 87 +- src/audio/aaudio/SDL_aaudio.h | 5 +- src/audio/aaudio/SDL_aaudiofuncs.h | 111 +- src/audio/alsa/SDL_alsa_audio.c | 354 +- src/audio/alsa/SDL_alsa_audio.h | 2 +- src/audio/android/SDL_androidaudio.c | 40 +- src/audio/android/SDL_androidaudio.h | 2 +- src/audio/coreaudio/SDL_coreaudio.h | 2 +- src/audio/coreaudio/SDL_coreaudio.m | 269 +- src/audio/directsound/SDL_directsound.c | 136 +- src/audio/directsound/SDL_directsound.h | 2 +- src/audio/disk/SDL_diskaudio.c | 62 +- src/audio/disk/SDL_diskaudio.h | 2 +- src/audio/dsp/SDL_dspaudio.c | 51 +- src/audio/dsp/SDL_dspaudio.h | 4 +- src/audio/dummy/SDL_dummyaudio.c | 16 +- src/audio/dummy/SDL_dummyaudio.h | 2 +- src/audio/emscripten/SDL_emscriptenaudio.c | 49 +- src/audio/emscripten/SDL_emscriptenaudio.h | 2 +- src/audio/haiku/SDL_haikuaudio.cc | 21 +- src/audio/haiku/SDL_haikuaudio.h | 2 +- src/audio/jack/SDL_jackaudio.c | 146 +- src/audio/n3ds/SDL_n3dsaudio.c | 60 +- src/audio/netbsd/SDL_netbsdaudio.c | 49 +- src/audio/netbsd/SDL_netbsdaudio.h | 4 +- src/audio/openslES/SDL_openslES.c | 112 +- src/audio/openslES/SDL_openslES.h | 10 +- src/audio/pipewire/SDL_pipewire.c | 287 +- src/audio/pipewire/SDL_pipewire.h | 8 +- src/audio/ps2/SDL_ps2audio.c | 40 +- src/audio/ps2/SDL_ps2audio.h | 18 +- src/audio/psp/SDL_pspaudio.c | 16 +- src/audio/psp/SDL_pspaudio.h | 13 +- src/audio/pulseaudio/SDL_pulseaudio.c | 284 +- src/audio/pulseaudio/SDL_pulseaudio.h | 2 +- src/audio/sndio/SDL_sndioaudio.c | 83 +- src/audio/sndio/SDL_sndioaudio.h | 2 +- src/audio/vita/SDL_vitaaudio.c | 25 +- src/audio/vita/SDL_vitaaudio.h | 13 +- src/audio/wasapi/SDL_wasapi.c | 160 +- src/audio/wasapi/SDL_wasapi_win32.c | 43 +- src/audio/wasapi/SDL_wasapi_winrt.cpp | 123 +- src/core/android/SDL_android.c | 607 +- src/core/android/SDL_android.h | 14 +- .../freebsd/SDL_evdev_kbd_default_keyaccmap.h | 2 + src/core/freebsd/SDL_evdev_kbd_freebsd.c | 77 +- src/core/gdk/SDL_gdk.cpp | 23 +- src/core/linux/SDL_dbus.c | 91 +- src/core/linux/SDL_dbus.h | 14 +- src/core/linux/SDL_evdev.c | 133 +- src/core/linux/SDL_evdev_capabilities.c | 10 +- src/core/linux/SDL_evdev_capabilities.h | 22 +- src/core/linux/SDL_evdev_kbd.c | 92 +- src/core/linux/SDL_evdev_kbd_default_keymap.h | 6 +- src/core/linux/SDL_fcitx.c | 76 +- src/core/linux/SDL_ibus.c | 194 +- src/core/linux/SDL_ibus.h | 4 +- src/core/linux/SDL_ime.c | 18 +- src/core/linux/SDL_sandbox.c | 4 +- src/core/linux/SDL_threadprio.c | 41 +- src/core/linux/SDL_udev.c | 76 +- src/core/linux/SDL_udev.h | 13 +- src/core/openbsd/SDL_wscons.h | 2 - src/core/openbsd/SDL_wscons_kbd.c | 833 +-- src/core/openbsd/SDL_wscons_mouse.c | 106 +- src/core/unix/SDL_poll.c | 9 +- src/core/windows/SDL_directx.h | 33 +- src/core/windows/SDL_hid.c | 10 +- src/core/windows/SDL_hid.h | 237 +- src/core/windows/SDL_immdevice.c | 79 +- src/core/windows/SDL_windows.c | 113 +- src/core/windows/SDL_windows.h | 32 +- src/core/windows/SDL_xinput.c | 21 +- src/core/windows/SDL_xinput.h | 67 +- src/core/winrt/SDL_winrtapp_common.cpp | 7 +- src/core/winrt/SDL_winrtapp_direct3d.cpp | 288 +- src/core/winrt/SDL_winrtapp_direct3d.h | 75 +- src/core/winrt/SDL_winrtapp_xaml.cpp | 41 +- src/core/winrt/SDL_winrtapp_xaml.h | 2 +- src/cpuinfo/SDL_cpuinfo.c | 469 +- src/dynapi/SDL_dynapi.c | 296 +- src/dynapi/SDL_dynapi.h | 16 +- src/events/SDL_clipboardevents.c | 4 +- src/events/SDL_displayevents.c | 4 +- src/events/SDL_dropevents.c | 16 +- src/events/SDL_events.c | 623 +- src/events/SDL_events_c.h | 2 +- src/events/SDL_gesture.c | 219 +- src/events/SDL_gesture_c.h | 2 +- src/events/SDL_keyboard.c | 117 +- src/events/SDL_keyboard_c.h | 6 +- src/events/SDL_mouse.c | 128 +- src/events/SDL_mouse_c.h | 35 +- src/events/SDL_quit.c | 69 +- src/events/SDL_touch.c | 68 +- src/events/SDL_touch_c.h | 7 +- src/events/SDL_windowevents.c | 26 +- src/events/SDL_windowevents_c.h | 2 +- src/events/blank_cursor.h | 8 +- src/events/scancodes_ascii.h | 256 +- src/file/SDL_rwops.c | 188 +- src/file/cocoa/SDL_rwopsbundlesupport.h | 2 +- src/file/cocoa/SDL_rwopsbundlesupport.m | 51 +- src/filesystem/android/SDL_sysfilesystem.c | 2 +- src/filesystem/cocoa/SDL_sysfilesystem.m | 175 +- src/filesystem/emscripten/SDL_sysfilesystem.c | 6 +- src/filesystem/ps2/SDL_sysfilesystem.c | 109 +- src/filesystem/psp/SDL_sysfilesystem.c | 4 +- src/filesystem/riscos/SDL_sysfilesystem.c | 13 +- src/filesystem/unix/SDL_sysfilesystem.c | 48 +- src/filesystem/vita/SDL_sysfilesystem.c | 4 +- src/filesystem/windows/SDL_sysfilesystem.c | 15 +- src/filesystem/winrt/SDL_sysfilesystem.cpp | 90 +- src/haptic/SDL_haptic.c | 146 +- src/haptic/SDL_syshaptic.h | 64 +- src/haptic/android/SDL_syshaptic.c | 128 +- src/haptic/darwin/SDL_syshaptic.c | 289 +- src/haptic/darwin/SDL_syshaptic_c.h | 5 +- src/haptic/dummy/SDL_syshaptic.c | 90 +- src/haptic/linux/SDL_syshaptic.c | 261 +- src/haptic/windows/SDL_dinputhaptic.c | 309 +- src/haptic/windows/SDL_dinputhaptic_c.h | 30 +- src/haptic/windows/SDL_windowshaptic.c | 86 +- src/haptic/windows/SDL_windowshaptic_c.h | 16 +- src/haptic/windows/SDL_xinputhaptic.c | 141 +- src/haptic/windows/SDL_xinputhaptic_c.h | 30 +- src/hidapi/SDL_hidapi.c | 460 +- src/joystick/SDL_gamecontroller.c | 397 +- src/joystick/SDL_gamecontrollerdb.h | 6 +- src/joystick/SDL_joystick.c | 452 +- src/joystick/SDL_sysjoystick.h | 69 +- src/joystick/android/SDL_sysjoystick.c | 345 +- src/joystick/android/SDL_sysjoystick_c.h | 4 +- src/joystick/bsd/SDL_bsdjoystick.c | 279 +- src/joystick/darwin/SDL_iokitjoystick.c | 356 +- src/joystick/darwin/SDL_iokitjoystick_c.h | 34 +- src/joystick/dummy/SDL_sysjoystick.c | 64 +- src/joystick/emscripten/SDL_sysjoystick.c | 103 +- src/joystick/emscripten/SDL_sysjoystick_c.h | 25 +- src/joystick/hidapi/SDL_hidapi_combined.c | 55 +- src/joystick/hidapi/SDL_hidapi_gamecube.c | 153 +- src/joystick/hidapi/SDL_hidapi_luna.c | 79 +- src/joystick/hidapi/SDL_hidapi_nintendo.h | 34 +- src/joystick/hidapi/SDL_hidapi_ps3.c | 131 +- src/joystick/hidapi/SDL_hidapi_ps4.c | 130 +- src/joystick/hidapi/SDL_hidapi_ps5.c | 319 +- src/joystick/hidapi/SDL_hidapi_rumble.c | 11 +- src/joystick/hidapi/SDL_hidapi_shield.c | 212 +- src/joystick/hidapi/SDL_hidapi_stadia.c | 67 +- src/joystick/hidapi/SDL_hidapi_steam.c | 706 +-- src/joystick/hidapi/SDL_hidapi_switch.c | 350 +- src/joystick/hidapi/SDL_hidapi_wii.c | 554 +- src/joystick/hidapi/SDL_hidapi_xbox360.c | 74 +- src/joystick/hidapi/SDL_hidapi_xbox360w.c | 76 +- src/joystick/hidapi/SDL_hidapi_xboxone.c | 203 +- src/joystick/hidapi/SDL_hidapijoystick.c | 166 +- src/joystick/hidapi/SDL_hidapijoystick_c.h | 9 +- src/joystick/iphoneos/SDL_mfijoystick.m | 318 +- src/joystick/iphoneos/SDL_mfijoystick_c.h | 1 - src/joystick/linux/SDL_sysjoystick.c | 332 +- src/joystick/linux/SDL_sysjoystick_c.h | 6 +- src/joystick/n3ds/SDL_sysjoystick.c | 62 +- src/joystick/ps2/SDL_sysjoystick.c | 65 +- src/joystick/psp/SDL_sysjoystick.c | 46 +- src/joystick/steam/SDL_steamcontroller.c | 1 - src/joystick/usb_ids.h | 188 +- src/joystick/virtual/SDL_virtualjoystick.c | 118 +- src/joystick/virtual/SDL_virtualjoystick_c.h | 10 +- src/joystick/vita/SDL_sysjoystick.c | 91 +- src/joystick/windows/SDL_dinputjoystick.c | 193 +- src/joystick/windows/SDL_dinputjoystick_c.h | 10 +- src/joystick/windows/SDL_rawinputjoystick.c | 324 +- src/joystick/windows/SDL_rawinputjoystick_c.h | 1 - .../windows/SDL_windows_gaming_input.c | 119 +- src/joystick/windows/SDL_windowsjoystick.c | 169 +- src/joystick/windows/SDL_windowsjoystick_c.h | 6 +- src/joystick/windows/SDL_xinputjoystick.c | 81 +- src/joystick/windows/SDL_xinputjoystick_c.h | 10 +- src/loadso/dlopen/SDL_sysloadso.c | 7 +- src/loadso/dummy/SDL_sysloadso.c | 3 +- src/loadso/windows/SDL_sysloadso.c | 11 +- src/locale/SDL_locale.c | 32 +- src/locale/android/SDL_syslocale.c | 4 +- src/locale/dummy/SDL_syslocale.c | 4 +- src/locale/emscripten/SDL_syslocale.c | 6 +- src/locale/macosx/SDL_syslocale.m | 84 +- src/locale/n3ds/SDL_syslocale.c | 3 +- src/locale/unix/SDL_syslocale.c | 16 +- src/locale/vita/SDL_syslocale.c | 4 +- src/locale/windows/SDL_syslocale.c | 41 +- src/locale/winrt/SDL_syslocale.c | 16 +- src/main/dummy/SDL_dummy_main.c | 6 +- src/main/gdk/SDL_gdk_main.c | 2 +- src/main/haiku/SDL_BApp.h | 196 +- src/main/haiku/SDL_BeApp.cc | 3 +- src/main/n3ds/SDL_n3ds_main.c | 3 +- src/main/ngage/SDL_ngage_main.cpp | 22 +- src/main/ps2/SDL_ps2_main.c | 20 +- src/main/psp/SDL_psp_main.c | 6 +- src/main/uikit/SDL_uikit_main.c | 3 +- src/main/windows/SDL_windows_main.c | 23 +- src/main/winrt/SDL_winrt_main_NonXAML.cpp | 2 +- src/misc/SDL_url.c | 3 +- src/misc/android/SDL_sysurl.c | 4 +- src/misc/dummy/SDL_sysurl.c | 4 +- src/misc/emscripten/SDL_sysurl.c | 7 +- src/misc/ios/SDL_sysurl.m | 16 +- src/misc/macosx/SDL_sysurl.m | 16 +- src/misc/riscos/SDL_sysurl.c | 4 +- src/misc/unix/SDL_sysurl.c | 24 +- src/misc/vita/SDL_sysurl.c | 4 +- src/misc/windows/SDL_sysurl.c | 11 +- src/misc/winrt/SDL_sysurl.cpp | 6 +- src/power/SDL_power.c | 28 +- src/power/android/SDL_syspower.c | 2 +- src/power/haiku/SDL_syspower.c | 32 +- src/power/linux/SDL_syspower.c | 195 +- src/power/macosx/SDL_syspower.c | 38 +- src/power/n3ds/SDL_syspower.c | 2 +- src/power/psp/SDL_syspower.c | 14 +- src/power/uikit/SDL_syspower.h | 2 +- src/power/uikit/SDL_syspower.m | 14 +- src/power/vita/SDL_syspower.c | 14 +- src/power/windows/SDL_syspower.c | 18 +- src/render/SDL_d3dmath.c | 1 - src/render/SDL_d3dmath.h | 7 +- src/render/SDL_render.c | 938 ++- src/render/SDL_sysrender.h | 143 +- src/render/SDL_yuv_sw.c | 229 +- src/render/SDL_yuv_sw_c.h | 20 +- src/render/direct3d/SDL_render_d3d.c | 485 +- src/render/direct3d/SDL_shaders_d3d.c | 1 - src/render/direct3d/SDL_shaders_d3d.h | 3 +- src/render/direct3d11/SDL_render_d3d11.c | 991 ++- src/render/direct3d11/SDL_render_winrt.cpp | 6 +- src/render/direct3d11/SDL_render_winrt.h | 2 +- src/render/direct3d11/SDL_shaders_d3d11.c | 35 +- src/render/direct3d11/SDL_shaders_d3d11.h | 3 +- src/render/direct3d12/SDL_render_d3d12.c | 1273 ++-- src/render/direct3d12/SDL_shaders_d3d12.c | 110 +- src/render/direct3d12/SDL_shaders_d3d12.h | 8 +- src/render/metal/SDL_render_metal.m | 1779 +++--- src/render/opengl/SDL_glfuncs.h | 284 +- src/render/opengl/SDL_render_gl.c | 793 ++- src/render/opengl/SDL_shaders_gl.c | 66 +- src/render/opengl/SDL_shaders_gl.h | 5 +- src/render/opengles/SDL_glesfuncs.h | 4 +- src/render/opengles/SDL_render_gles.c | 488 +- src/render/opengles2/SDL_gles2funcs.h | 4 +- src/render/opengles2/SDL_render_gles2.c | 802 ++- src/render/opengles2/SDL_shaders_gles2.c | 4 +- src/render/ps2/SDL_render_ps2.c | 391 +- src/render/psp/SDL_render_psp.c | 795 ++- src/render/software/SDL_blendfillrect.c | 43 +- src/render/software/SDL_blendfillrect.h | 5 +- src/render/software/SDL_blendline.c | 81 +- src/render/software/SDL_blendline.h | 5 +- src/render/software/SDL_blendpoint.c | 41 +- src/render/software/SDL_blendpoint.h | 5 +- src/render/software/SDL_draw.h | 700 +- src/render/software/SDL_drawline.c | 49 +- src/render/software/SDL_drawline.h | 5 +- src/render/software/SDL_drawpoint.c | 9 +- src/render/software/SDL_drawpoint.h | 5 +- src/render/software/SDL_render_sw.c | 547 +- src/render/software/SDL_render_sw_c.h | 2 +- src/render/software/SDL_rotate.c | 189 +- src/render/software/SDL_rotate.h | 6 +- src/render/software/SDL_triangle.c | 187 +- src/render/software/SDL_triangle.h | 14 +- src/render/vitagxm/SDL_render_vita_gxm.c | 594 +- .../vitagxm/SDL_render_vita_gxm_memory.c | 25 +- .../vitagxm/SDL_render_vita_gxm_memory.h | 4 +- .../vitagxm/SDL_render_vita_gxm_shaders.h | 16 +- .../vitagxm/SDL_render_vita_gxm_tools.c | 322 +- .../vitagxm/SDL_render_vita_gxm_tools.h | 3 +- .../vitagxm/SDL_render_vita_gxm_types.h | 58 +- src/sensor/SDL_sensor.c | 62 +- src/sensor/SDL_syssensor.h | 24 +- src/sensor/android/SDL_androidsensor.c | 48 +- src/sensor/android/SDL_androidsensor.h | 1 - src/sensor/coremotion/SDL_coremotionsensor.h | 1 - src/sensor/coremotion/SDL_coremotionsensor.m | 97 +- src/sensor/dummy/SDL_dummysensor.c | 38 +- src/sensor/n3ds/SDL_n3dssensor.c | 47 +- src/sensor/vita/SDL_vitasensor.c | 85 +- src/sensor/windows/SDL_windowssensor.c | 60 +- src/stdlib/SDL_crc16.c | 4 +- src/stdlib/SDL_crc32.c | 4 +- src/stdlib/SDL_getenv.c | 46 +- src/stdlib/SDL_iconv.c | 818 ++- src/stdlib/SDL_mslibc.c | 60 +- src/stdlib/SDL_stdlib.c | 113 +- src/stdlib/SDL_string.c | 328 +- src/stdlib/SDL_vacopy.h | 6 +- src/test/SDL_test_assert.c | 2 +- src/test/SDL_test_common.c | 377 +- src/test/SDL_test_compare.c | 125 +- src/test/SDL_test_crc32.c | 167 +- src/test/SDL_test_font.c | 4163 ++++++------ src/test/SDL_test_fuzzer.c | 222 +- src/test/SDL_test_harness.c | 173 +- src/test/SDL_test_imageBlit.c | 3102 ++++----- src/test/SDL_test_imageBlitBlend.c | 5623 +++++++++-------- src/test/SDL_test_imageFace.c | 408 +- src/test/SDL_test_imagePrimitives.c | 956 +-- src/test/SDL_test_imagePrimitivesBlend.c | 1311 ++-- src/test/SDL_test_log.c | 2 +- src/test/SDL_test_md5.c | 418 +- src/test/SDL_test_memory.c | 22 +- src/test/SDL_test_random.c | 90 +- src/thread/SDL_systhread.h | 10 +- src/thread/SDL_thread.c | 85 +- src/thread/SDL_thread_c.h | 16 +- src/thread/generic/SDL_syscond.c | 17 +- src/thread/generic/SDL_syscond_c.h | 14 +- src/thread/generic/SDL_sysmutex.c | 15 +- src/thread/generic/SDL_syssem.c | 39 +- src/thread/generic/SDL_systhread.c | 22 +- src/thread/generic/SDL_systls.c | 4 +- src/thread/n3ds/SDL_syscond.c | 19 +- src/thread/n3ds/SDL_sysmutex.c | 14 +- src/thread/n3ds/SDL_syssem.c | 17 +- src/thread/n3ds/SDL_systhread.c | 24 +- src/thread/ngage/SDL_sysmutex.cpp | 17 +- src/thread/ngage/SDL_syssem.cpp | 39 +- src/thread/ngage/SDL_systhread.cpp | 32 +- src/thread/ps2/SDL_syssem.c | 14 +- src/thread/ps2/SDL_systhread.c | 30 +- src/thread/psp/SDL_syscond.c | 17 +- src/thread/psp/SDL_sysmutex.c | 36 +- src/thread/psp/SDL_syssem.c | 26 +- src/thread/psp/SDL_systhread.c | 12 +- src/thread/pthread/SDL_syscond.c | 19 +- src/thread/pthread/SDL_sysmutex.c | 14 +- src/thread/pthread/SDL_syssem.c | 27 +- src/thread/pthread/SDL_systhread.c | 70 +- src/thread/pthread/SDL_systls.c | 4 +- src/thread/stdcpp/SDL_syscond.cpp | 40 +- src/thread/stdcpp/SDL_sysmutex.cpp | 28 +- src/thread/stdcpp/SDL_systhread.cpp | 47 +- src/thread/stdcpp/SDL_systhread_c.h | 2 +- src/thread/vita/SDL_syscond.c | 17 +- src/thread/vita/SDL_sysmutex.c | 36 +- src/thread/vita/SDL_syssem.c | 10 +- src/thread/vita/SDL_systhread.c | 55 +- src/thread/windows/SDL_syscond_cv.c | 89 +- src/thread/windows/SDL_sysmutex.c | 74 +- src/thread/windows/SDL_sysmutex_c.h | 17 +- src/thread/windows/SDL_syssem.c | 106 +- src/thread/windows/SDL_systhread.c | 93 +- src/thread/windows/SDL_systls.c | 5 +- src/timer/SDL_timer.c | 39 +- src/timer/SDL_timer_c.h | 2 +- src/timer/dummy/SDL_systimer.c | 9 +- src/timer/haiku/SDL_systimer.c | 11 +- src/timer/n3ds/SDL_systimer.c | 9 +- src/timer/ngage/SDL_systimer.cpp | 19 +- src/timer/ps2/SDL_systimer.c | 12 +- src/timer/psp/SDL_systimer.c | 6 +- src/timer/unix/SDL_systimer.c | 13 +- src/timer/vita/SDL_systimer.c | 8 +- src/timer/windows/SDL_systimer.c | 33 +- src/video/SDL_RLEaccel.c | 1104 ++-- src/video/SDL_RLEaccel_c.h | 4 +- src/video/SDL_blit.c | 35 +- src/video/SDL_blit.h | 864 +-- src/video/SDL_blit_0.c | 79 +- src/video/SDL_blit_1.c | 94 +- src/video/SDL_blit_A.c | 349 +- src/video/SDL_blit_N.c | 837 ++- src/video/SDL_blit_copy.c | 68 +- src/video/SDL_blit_copy.h | 2 +- src/video/SDL_blit_slow.c | 18 +- src/video/SDL_blit_slow.h | 2 +- src/video/SDL_bmp.c | 164 +- src/video/SDL_clipboard.c | 7 +- src/video/SDL_egl.c | 324 +- src/video/SDL_egl_c.h | 116 +- src/video/SDL_fillrect.c | 163 +- src/video/SDL_pixels.c | 208 +- src/video/SDL_pixels_c.h | 12 +- src/video/SDL_rect.c | 39 +- src/video/SDL_rect_c.h | 2 +- src/video/SDL_rect_impl.h | 54 +- src/video/SDL_shape.c | 203 +- src/video/SDL_shape_internals.h | 28 +- src/video/SDL_stretch.c | 397 +- src/video/SDL_surface.c | 177 +- src/video/SDL_sysvideo.h | 163 +- src/video/SDL_video.c | 765 +-- src/video/SDL_vulkan_internal.h | 5 +- src/video/SDL_vulkan_utils.c | 196 +- src/video/SDL_yuv.c | 767 ++- src/video/SDL_yuv_c.h | 1 - src/video/android/SDL_androidclipboard.c | 3 +- src/video/android/SDL_androidevents.c | 44 +- src/video/android/SDL_androidgl.c | 20 +- src/video/android/SDL_androidgl.h | 7 +- src/video/android/SDL_androidkeyboard.c | 578 +- src/video/android/SDL_androidkeyboard.h | 2 +- src/video/android/SDL_androidmessagebox.c | 3 +- src/video/android/SDL_androidmouse.c | 108 +- src/video/android/SDL_androidtouch.c | 30 +- src/video/android/SDL_androidvideo.c | 92 +- src/video/android/SDL_androidvideo.h | 6 +- src/video/android/SDL_androidvulkan.c | 29 +- src/video/android/SDL_androidvulkan.h | 12 +- src/video/android/SDL_androidwindow.c | 25 +- src/video/android/SDL_androidwindow.h | 4 +- src/video/cocoa/SDL_cocoaclipboard.h | 2 +- src/video/cocoa/SDL_cocoaclipboard.m | 97 +- src/video/cocoa/SDL_cocoaevents.h | 2 +- src/video/cocoa/SDL_cocoaevents.m | 269 +- src/video/cocoa/SDL_cocoakeyboard.h | 4 +- src/video/cocoa/SDL_cocoakeyboard.m | 193 +- src/video/cocoa/SDL_cocoamessagebox.m | 59 +- src/video/cocoa/SDL_cocoametalview.h | 12 +- src/video/cocoa/SDL_cocoametalview.m | 119 +- src/video/cocoa/SDL_cocoamodes.h | 10 +- src/video/cocoa/SDL_cocoamodes.m | 387 +- src/video/cocoa/SDL_cocoamouse.h | 7 +- src/video/cocoa/SDL_cocoamouse.m | 334 +- src/video/cocoa/SDL_cocoaopengl.h | 25 +- src/video/cocoa/SDL_cocoaopengl.m | 510 +- src/video/cocoa/SDL_cocoaopengles.m | 51 +- src/video/cocoa/SDL_cocoashape.h | 10 +- src/video/cocoa/SDL_cocoashape.m | 153 +- src/video/cocoa/SDL_cocoavideo.h | 18 +- src/video/cocoa/SDL_cocoavideo.m | 244 +- src/video/cocoa/SDL_cocoavulkan.h | 12 +- src/video/cocoa/SDL_cocoavulkan.m | 31 +- src/video/cocoa/SDL_cocoawindow.h | 131 +- src/video/cocoa/SDL_cocoawindow.m | 1373 ++-- src/video/dummy/SDL_nullevents.c | 3 +- src/video/dummy/SDL_nullframebuffer.c | 13 +- src/video/dummy/SDL_nullframebuffer_c.h | 6 +- src/video/dummy/SDL_nullvideo.c | 46 +- src/video/emscripten/SDL_emscriptenevents.c | 875 ++- src/video/emscripten/SDL_emscriptenevents.h | 2 - .../emscripten/SDL_emscriptenframebuffer.c | 14 +- .../emscripten/SDL_emscriptenframebuffer.h | 6 +- src/video/emscripten/SDL_emscriptenmouse.c | 140 +- src/video/emscripten/SDL_emscriptenmouse.h | 1 - src/video/emscripten/SDL_emscriptenopengles.c | 4 +- src/video/emscripten/SDL_emscriptenvideo.c | 78 +- src/video/haiku/SDL_BApp.h | 196 +- src/video/haiku/SDL_BWin.h | 395 +- src/video/haiku/SDL_bframebuffer.h | 12 +- src/video/haiku/SDL_bmodes.h | 4 +- src/video/haiku/SDL_bopengl.h | 19 +- src/video/haiku/SDL_bvideo.cc | 18 +- src/video/haiku/SDL_bvideo.h | 1 - src/video/haiku/SDL_bwindow.h | 4 - src/video/kmsdrm/SDL_kmsdrmdyn.c | 44 +- src/video/kmsdrm/SDL_kmsdrmdyn.h | 6 +- src/video/kmsdrm/SDL_kmsdrmevents.c | 2 - src/video/kmsdrm/SDL_kmsdrmmouse.c | 132 +- src/video/kmsdrm/SDL_kmsdrmmouse.h | 6 +- src/video/kmsdrm/SDL_kmsdrmopengles.c | 32 +- src/video/kmsdrm/SDL_kmsdrmopengles.h | 6 +- src/video/kmsdrm/SDL_kmsdrmvideo.c | 278 +- src/video/kmsdrm/SDL_kmsdrmvideo.h | 24 +- src/video/kmsdrm/SDL_kmsdrmvulkan.c | 86 +- src/video/kmsdrm/SDL_kmsdrmvulkan.h | 12 +- src/video/n3ds/SDL_n3dsevents.c | 3 +- src/video/n3ds/SDL_n3dsframebuffer.c | 23 +- src/video/n3ds/SDL_n3dsswkb.c | 15 +- src/video/n3ds/SDL_n3dstouch.c | 9 +- src/video/n3ds/SDL_n3dsvideo.c | 32 +- src/video/ngage/SDL_ngageevents.cpp | 223 +- src/video/ngage/SDL_ngageframebuffer.cpp | 240 +- src/video/ngage/SDL_ngageframebuffer_c.h | 10 +- src/video/ngage/SDL_ngagevideo.cpp | 51 +- src/video/ngage/SDL_ngagevideo.h | 38 +- src/video/ngage/SDL_ngagewindow.cpp | 32 +- src/video/ngage/SDL_ngagewindow.h | 11 +- src/video/offscreen/SDL_offscreenevents.c | 3 +- .../offscreen/SDL_offscreenframebuffer.c | 13 +- .../offscreen/SDL_offscreenframebuffer_c.h | 6 +- src/video/offscreen/SDL_offscreenopengles.c | 17 +- src/video/offscreen/SDL_offscreenopengles.h | 1 - src/video/offscreen/SDL_offscreenvideo.c | 19 +- src/video/offscreen/SDL_offscreenwindow.c | 8 +- src/video/offscreen/SDL_offscreenwindow.h | 7 +- src/video/ps2/SDL_ps2video.c | 13 +- src/video/psp/SDL_pspevents.c | 61 +- src/video/psp/SDL_pspevents_c.h | 1 - src/video/psp/SDL_pspgl.c | 148 +- src/video/psp/SDL_pspgl_c.h | 22 +- src/video/psp/SDL_pspmouse.c | 4 +- src/video/psp/SDL_pspvideo.c | 92 +- src/video/psp/SDL_pspvideo.h | 49 +- src/video/raspberry/SDL_rpievents.c | 2 - src/video/raspberry/SDL_rpimouse.c | 143 +- src/video/raspberry/SDL_rpimouse.h | 10 +- src/video/raspberry/SDL_rpiopengles.c | 18 +- src/video/raspberry/SDL_rpiopengles.h | 8 +- src/video/raspberry/SDL_rpivideo.c | 155 +- src/video/raspberry/SDL_rpivideo.h | 47 +- src/video/riscos/SDL_riscosdefs.h | 6 +- src/video/riscos/SDL_riscosevents.c | 24 +- src/video/riscos/SDL_riscosframebuffer.c | 20 +- src/video/riscos/SDL_riscosframebuffer_c.h | 6 +- src/video/riscos/SDL_riscosmessagebox.c | 7 +- src/video/riscos/SDL_riscosmodes.c | 66 +- src/video/riscos/SDL_riscosmodes.h | 6 +- src/video/riscos/SDL_riscosmouse.c | 13 +- src/video/riscos/SDL_riscosvideo.c | 16 +- src/video/riscos/SDL_riscoswindow.c | 10 +- src/video/uikit/SDL_uikitappdelegate.h | 4 +- src/video/uikit/SDL_uikitappdelegate.m | 48 +- src/video/uikit/SDL_uikitclipboard.m | 23 +- src/video/uikit/SDL_uikitevents.m | 85 +- src/video/uikit/SDL_uikitmessagebox.m | 54 +- src/video/uikit/SDL_uikitmetalview.h | 11 +- src/video/uikit/SDL_uikitmetalview.m | 108 +- src/video/uikit/SDL_uikitmodes.h | 16 +- src/video/uikit/SDL_uikitmodes.m | 290 +- src/video/uikit/SDL_uikitopengles.h | 10 +- src/video/uikit/SDL_uikitopengles.m | 39 +- src/video/uikit/SDL_uikitopenglview.h | 12 +- src/video/uikit/SDL_uikitopenglview.m | 13 +- src/video/uikit/SDL_uikitvideo.h | 2 +- src/video/uikit/SDL_uikitvideo.m | 43 +- src/video/uikit/SDL_uikitview.h | 2 +- src/video/uikit/SDL_uikitview.m | 63 +- src/video/uikit/SDL_uikitviewcontroller.h | 16 +- src/video/uikit/SDL_uikitviewcontroller.m | 88 +- src/video/uikit/SDL_uikitvulkan.h | 12 +- src/video/uikit/SDL_uikitvulkan.m | 54 +- src/video/uikit/SDL_uikitwindow.h | 8 +- src/video/uikit/SDL_uikitwindow.m | 102 +- src/video/vita/SDL_vitaframebuffer.c | 35 +- src/video/vita/SDL_vitaframebuffer.h | 6 +- src/video/vita/SDL_vitagl_pvr.c | 45 +- src/video/vita/SDL_vitagl_pvr_c.h | 3 +- src/video/vita/SDL_vitagles.c | 66 +- src/video/vita/SDL_vitagles_c.h | 22 +- src/video/vita/SDL_vitagles_pvr.c | 52 +- src/video/vita/SDL_vitagles_pvr_c.h | 7 +- src/video/vita/SDL_vitakeyboard.c | 12 +- src/video/vita/SDL_vitamessagebox.c | 2 +- src/video/vita/SDL_vitamouse.c | 8 +- src/video/vita/SDL_vitatouch.c | 75 +- src/video/vita/SDL_vitavideo.c | 219 +- src/video/vita/SDL_vitavideo.h | 51 +- src/video/vivante/SDL_vivanteopengles.c | 10 +- src/video/vivante/SDL_vivanteopengles.h | 8 +- src/video/vivante/SDL_vivanteplatform.c | 9 +- src/video/vivante/SDL_vivantevideo.c | 63 +- src/video/vivante/SDL_vivantevideo.h | 36 +- src/video/vivante/SDL_vivantevulkan.c | 26 +- src/video/vivante/SDL_vivantevulkan.h | 15 +- src/video/wayland/SDL_waylandclipboard.c | 14 +- src/video/wayland/SDL_waylanddatamanager.c | 156 +- src/video/wayland/SDL_waylanddatamanager.h | 38 +- src/video/wayland/SDL_waylanddyn.c | 55 +- src/video/wayland/SDL_waylanddyn.h | 127 +- src/video/wayland/SDL_waylandevents.c | 865 ++- src/video/wayland/SDL_waylandevents_c.h | 36 +- src/video/wayland/SDL_waylandkeyboard.c | 15 +- src/video/wayland/SDL_waylandmessagebox.c | 19 +- src/video/wayland/SDL_waylandmouse.c | 146 +- src/video/wayland/SDL_waylandmouse.h | 2 +- src/video/wayland/SDL_waylandopengles.c | 45 +- src/video/wayland/SDL_waylandopengles.h | 6 +- src/video/wayland/SDL_waylandtouch.c | 132 +- src/video/wayland/SDL_waylandtouch.h | 215 +- src/video/wayland/SDL_waylandvideo.c | 257 +- src/video/wayland/SDL_waylandvideo.h | 12 +- src/video/wayland/SDL_waylandvulkan.c | 35 +- src/video/wayland/SDL_waylandvulkan.h | 12 +- src/video/wayland/SDL_waylandwindow.c | 450 +- src/video/wayland/SDL_waylandwindow.h | 53 +- src/video/windows/SDL_msctf.h | 10 +- src/video/windows/SDL_vkeys.h | 98 +- src/video/windows/SDL_windowsclipboard.c | 25 +- src/video/windows/SDL_windowsclipboard.h | 2 +- src/video/windows/SDL_windowsevents.c | 1264 ++-- src/video/windows/SDL_windowsevents.h | 2 +- src/video/windows/SDL_windowsframebuffer.c | 18 +- src/video/windows/SDL_windowsframebuffer.h | 6 +- src/video/windows/SDL_windowskeyboard.c | 441 +- src/video/windows/SDL_windowsmessagebox.c | 168 +- src/video/windows/SDL_windowsmodes.c | 157 +- src/video/windows/SDL_windowsmodes.h | 10 +- src/video/windows/SDL_windowsmouse.c | 142 +- src/video/windows/SDL_windowsopengl.c | 171 +- src/video/windows/SDL_windowsopengl.h | 138 +- src/video/windows/SDL_windowsopengles.c | 26 +- src/video/windows/SDL_windowsopengles.h | 6 +- src/video/windows/SDL_windowsshape.c | 43 +- src/video/windows/SDL_windowsshape.h | 7 +- src/video/windows/SDL_windowsvideo.c | 139 +- src/video/windows/SDL_windowsvideo.h | 226 +- src/video/windows/SDL_windowsvulkan.c | 19 +- src/video/windows/SDL_windowswindow.c | 255 +- src/video/windows/SDL_windowswindow.h | 8 +- src/video/windows/wmmsg.h | 2 +- src/video/winrt/SDL_winrtevents.cpp | 87 +- src/video/winrt/SDL_winrtevents_c.h | 30 +- src/video/winrt/SDL_winrtgamebar.cpp | 64 +- src/video/winrt/SDL_winrtkeyboard.cpp | 485 +- src/video/winrt/SDL_winrtmessagebox.cpp | 18 +- src/video/winrt/SDL_winrtmouse.cpp | 100 +- src/video/winrt/SDL_winrtopengles.cpp | 71 +- src/video/winrt/SDL_winrtopengles.h | 17 +- src/video/winrt/SDL_winrtpointerinput.cpp | 215 +- src/video/winrt/SDL_winrtvideo.cpp | 203 +- src/video/winrt/SDL_winrtvideo_cpp.h | 27 +- src/video/x11/SDL_x11clipboard.c | 140 +- src/video/x11/SDL_x11clipboard.h | 7 +- src/video/x11/SDL_x11dyn.c | 45 +- src/video/x11/SDL_x11dyn.h | 19 +- src/video/x11/SDL_x11events.c | 1434 +++-- src/video/x11/SDL_x11events.h | 2 +- src/video/x11/SDL_x11framebuffer.c | 52 +- src/video/x11/SDL_x11framebuffer.h | 13 +- src/video/x11/SDL_x11keyboard.c | 113 +- src/video/x11/SDL_x11messagebox.c | 473 +- src/video/x11/SDL_x11modes.c | 187 +- src/video/x11/SDL_x11modes.h | 20 +- src/video/x11/SDL_x11mouse.c | 161 +- src/video/x11/SDL_x11opengl.c | 268 +- src/video/x11/SDL_x11opengl.h | 41 +- src/video/x11/SDL_x11opengles.c | 28 +- src/video/x11/SDL_x11opengles.h | 8 +- src/video/x11/SDL_x11shape.c | 39 +- src/video/x11/SDL_x11shape.h | 11 +- src/video/x11/SDL_x11touch.c | 10 +- src/video/x11/SDL_x11video.c | 51 +- src/video/x11/SDL_x11video.h | 4 +- src/video/x11/SDL_x11vulkan.c | 20 +- src/video/x11/SDL_x11window.c | 446 +- src/video/x11/SDL_x11window.h | 16 +- src/video/x11/SDL_x11xfixes.c | 67 +- src/video/x11/SDL_x11xfixes.h | 6 +- src/video/x11/SDL_x11xinput2.c | 286 +- src/video/x11/SDL_x11xinput2.h | 2 +- src/video/x11/edid.h | 194 +- test/checkkeys.c | 36 +- test/checkkeysthreads.c | 51 +- test/controllermap.c | 107 +- test/loopwave.c | 17 +- test/loopwavequeue.c | 28 +- test/testatomic.c | 185 +- test/testaudiocapture.c | 16 +- test/testaudiohotplug.c | 31 +- test/testaudioinfo.c | 4 +- test/testautomation.c | 15 +- test/testautomation_audio.c | 1268 ++-- test/testautomation_clipboard.c | 71 +- test/testautomation_events.c | 202 +- test/testautomation_guid.c | 45 +- test/testautomation_hints.c | 309 +- test/testautomation_joystick.c | 7 +- test/testautomation_keyboard.c | 899 ++- test/testautomation_main.c | 70 +- test/testautomation_math.c | 230 +- test/testautomation_mouse.c | 505 +- test/testautomation_pixels.c | 449 +- test/testautomation_platform.c | 660 +- test/testautomation_rect.c | 691 +- test/testautomation_render.c | 1575 +++-- test/testautomation_rwops.c | 783 ++- test/testautomation_sdltest.c | 2023 +++--- test/testautomation_stdlib.c | 827 ++- test/testautomation_suites.h | 2 +- test/testautomation_surface.c | 449 +- test/testautomation_syswm.c | 28 +- test/testautomation_timer.c | 211 +- test/testautomation_video.c | 2738 ++++---- test/testbounds.c | 2 +- test/testcustomcursor.c | 213 +- test/testdisplayinfo.c | 5 +- test/testdraw2.c | 50 +- test/testdrawchessboard.c | 51 +- test/testdropfile.c | 9 +- test/testerror.c | 7 +- test/testevdev.c | 47 +- test/testfile.c | 57 +- test/testfilesystem.c | 15 +- test/testgamecontroller.c | 154 +- test/testgeometry.c | 19 +- test/testgesture.c | 150 +- test/testgl2.c | 88 +- test/testgles.c | 118 +- test/testgles2.c | 290 +- test/testgles2_sdf.c | 207 +- test/testhaptic.c | 47 +- test/testhittesting.c | 63 +- test/testhotplug.c | 124 +- test/testiconv.c | 9 +- test/testime.c | 196 +- test/testintersections.c | 34 +- test/testjoystick.c | 28 +- test/testkeys.c | 5 +- test/testloadso.c | 13 +- test/testlocale.c | 2 +- test/testlock.c | 16 +- test/testmessage.c | 75 +- test/testmouse.c | 103 +- test/testmultiaudio.c | 41 +- test/testnative.c | 16 +- test/testnative.h | 4 +- test/testnativew32.c | 4 +- test/testnativex11.c | 4 +- test/testoffscreen.c | 30 +- test/testoverlay2.c | 39 +- test/testplatform.c | 320 +- test/testpower.c | 8 +- test/testqsort.c | 17 +- test/testrelative.c | 21 +- test/testrendercopyex.c | 17 +- test/testrendertarget.c | 11 +- test/testresample.c | 33 +- test/testrumble.c | 22 +- test/testscale.c | 18 +- test/testsem.c | 38 +- test/testsensor.c | 6 +- test/testshader.c | 255 +- test/testshape.c | 61 +- test/testsprite2.c | 69 +- test/testspriteminimal.c | 15 +- test/teststreaming.c | 19 +- test/testsurround.c | 17 +- test/testthread.c | 28 +- test/testtimer.c | 21 +- test/testutils.c | 8 +- test/testver.c | 11 +- test/testviewport.c | 44 +- test/testvulkan.c | 107 +- test/testwm2.c | 208 +- test/testyuv.c | 46 +- test/testyuv_cvt.c | 57 +- test/torturethread.c | 17 +- 764 files changed, 50598 insertions(+), 54407 deletions(-) create mode 100755 build-scripts/clang-format-src.sh diff --git a/.clang-format b/.clang-format index f4d9bcfd0..459a886af 100644 --- a/.clang-format +++ b/.clang-format @@ -16,8 +16,8 @@ AllowShortFunctionsOnASingleLine: All AllowShortIfStatementsOnASingleLine: Never AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: All -AlwaysBreakAfterReturnType: AllDefinitions +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: MultiLine @@ -35,7 +35,7 @@ BraceWrapping: AfterUnion: true AfterExternBlock: false BeforeElse: false - BeforeWhile: true + BeforeWhile: false IndentBraces: false SplitEmptyFunction: true SplitEmptyRecord: true @@ -48,7 +48,7 @@ IncludeBlocks: Preserve # clang-format version 4.0 through 12.0: #SortIncludes: false # clang-format version 13.0+: -#SortIncludes: Never +SortIncludes: Never # No length limit, in case it breaks macros, you can # disable it with /* clang-format off/on */ comments @@ -62,7 +62,8 @@ IndentGotoLabels: true IndentPPDirectives: None IndentExternBlock: NoIndent -SpaceAfterCStyleCast: true +PointerAlignment: Right +SpaceAfterCStyleCast: false SpacesInCStyleCastParentheses: false SpacesInConditionalStatement: false SpacesInContainerLiterals: true diff --git a/build-scripts/clang-format-src.sh b/build-scripts/clang-format-src.sh new file mode 100755 index 000000000..c4af9a591 --- /dev/null +++ b/build-scripts/clang-format-src.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +cd "$(dirname $0)/../src" + +echo "Running clang-format in $(pwd)" + +find . -regex '.*\.[chm]p*' -exec clang-format -i {} \; + +# Revert third-party code +git checkout \ + events/imKStoUCS.* \ + hidapi \ + joystick/controller_type.c \ + joystick/controller_type.h \ + joystick/hidapi/steam/controller_constants.h \ + joystick/hidapi/steam/controller_structs.h \ + libm \ + stdlib/SDL_malloc.c \ + stdlib/SDL_qsort.c \ + stdlib/SDL_strtokr.c \ + video/arm \ + video/khronos \ + video/x11/edid-parse.c \ + video/yuv2rgb +clang-format -i hidapi/SDL_hidapi.c + +# Revert generated code +git checkout dynapi/SDL_dynapi_overrides.h +git checkout dynapi/SDL_dynapi_procs.h +git checkout render/metal/SDL_shaders_metal_*.h + +echo "clang-format complete!" diff --git a/src/SDL.c b/src/SDL.c index 463cb2b9e..6d879f28a 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -55,7 +55,7 @@ /* Initialization/Cleanup routines */ #if !SDL_TIMERS_DISABLED -# include "timer/SDL_timer_c.h" +#include "timer/SDL_timer_c.h" #endif #if SDL_VIDEO_DRIVER_WINDOWS extern int SDL_HelperWindowCreate(void); @@ -98,8 +98,8 @@ SDL_NORETURN void SDL_ExitProcess(int exitcode) ExitProcess here that will never be reached but make MingW happy. */ ExitProcess(exitcode); #elif defined(__EMSCRIPTEN__) - emscripten_cancel_main_loop(); /* this should "kill" the app. */ - emscripten_force_exit(exitcode); /* this should "kill" the app. */ + emscripten_cancel_main_loop(); /* this should "kill" the app. */ + emscripten_force_exit(exitcode); /* this should "kill" the app. */ exit(exitcode); #elif defined(__HAIKU__) /* Haiku has _Exit, but it's not marked noreturn. */ _exit(exitcode); @@ -110,7 +110,6 @@ SDL_NORETURN void SDL_ExitProcess(int exitcode) #endif } - /* The initialized subsystems */ #ifdef SDL_MAIN_NEEDED static SDL_bool SDL_MainIsReady = SDL_FALSE; @@ -118,11 +117,10 @@ static SDL_bool SDL_MainIsReady = SDL_FALSE; static SDL_bool SDL_MainIsReady = SDL_TRUE; #endif static SDL_bool SDL_bInMainQuit = SDL_FALSE; -static Uint8 SDL_SubsystemRefCount[ 32 ]; +static Uint8 SDL_SubsystemRefCount[32]; /* Private helper to increment a subsystem's ref counter. */ -static void -SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem) +static void SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem) { const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255)); @@ -132,8 +130,7 @@ SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem) } /* Private helper to decrement a subsystem's ref counter. */ -static void -SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem) +static void SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem) { const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] > 0)) { @@ -142,8 +139,7 @@ SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem) } /* Private helper to check if a system needs init. */ -static SDL_bool -SDL_PrivateShouldInitSubsystem(Uint32 subsystem) +static SDL_bool SDL_PrivateShouldInitSubsystem(Uint32 subsystem) { const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255)); @@ -151,8 +147,8 @@ SDL_PrivateShouldInitSubsystem(Uint32 subsystem) } /* Private helper to check if a system needs to be quit. */ -static SDL_bool -SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) { +static SDL_bool SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) +{ const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) { return SDL_FALSE; @@ -164,14 +160,12 @@ SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) { return (((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 1)) || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE; } -void -SDL_SetMainReady(void) +void SDL_SetMainReady(void) { SDL_MainIsReady = SDL_TRUE; } -int -SDL_InitSubSystem(Uint32 flags) +int SDL_InitSubSystem(Uint32 flags) { Uint32 flags_initialized = 0; @@ -193,7 +187,7 @@ SDL_InitSubSystem(Uint32 flags) flags |= SDL_INIT_JOYSTICK; } - if ((flags & (SDL_INIT_VIDEO|SDL_INIT_JOYSTICK|SDL_INIT_AUDIO))) { + if ((flags & (SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO))) { /* video or joystick or audio implies events */ flags |= SDL_INIT_EVENTS; } @@ -203,7 +197,7 @@ SDL_InitSubSystem(Uint32 flags) #endif #if SDL_VIDEO_DRIVER_WINDOWS - if ((flags & (SDL_INIT_HAPTIC|SDL_INIT_JOYSTICK))) { + if ((flags & (SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK))) { if (SDL_HelperWindowCreate() < 0) { goto quit_and_error; } @@ -282,9 +276,9 @@ SDL_InitSubSystem(Uint32 flags) if ((flags & SDL_INIT_JOYSTICK)) { #if !SDL_JOYSTICK_DISABLED if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) { - if (SDL_JoystickInit() < 0) { - goto quit_and_error; - } + if (SDL_JoystickInit() < 0) { + goto quit_and_error; + } } SDL_PrivateSubsystemRefCountIncr(SDL_INIT_JOYSTICK); flags_initialized |= SDL_INIT_JOYSTICK; @@ -341,7 +335,7 @@ SDL_InitSubSystem(Uint32 flags) #endif } - (void) flags_initialized; /* make static analysis happy, since this only gets used in error cases. */ + (void)flags_initialized; /* make static analysis happy, since this only gets used in error cases. */ return 0; @@ -350,14 +344,12 @@ quit_and_error: return -1; } -int -SDL_Init(Uint32 flags) +int SDL_Init(Uint32 flags) { return SDL_InitSubSystem(flags); } -void -SDL_QuitSubSystem(Uint32 flags) +void SDL_QuitSubSystem(Uint32 flags) { #if defined(__OS2__) #if SDL_THREAD_OS2 @@ -481,8 +473,7 @@ SDL_WasInit(Uint32 flags) return initialized; } -void -SDL_Quit(void) +void SDL_Quit(void) { SDL_bInMainQuit = SDL_TRUE; @@ -508,7 +499,7 @@ SDL_Quit(void) /* Now that every subsystem has been quit, we reset the subsystem refcount * and the list of initialized subsystems. */ - SDL_memset( SDL_SubsystemRefCount, 0x0, sizeof(SDL_SubsystemRefCount) ); + SDL_memset(SDL_SubsystemRefCount, 0x0, sizeof(SDL_SubsystemRefCount)); SDL_TLSCleanup(); @@ -516,13 +507,13 @@ SDL_Quit(void) } /* Get the library version number */ -void -SDL_GetVersion(SDL_version * ver) +void SDL_GetVersion(SDL_version *ver) { static SDL_bool check_hint = SDL_TRUE; static SDL_bool legacy_version = SDL_FALSE; - if (ver == NULL) { return; + if (ver == NULL) { + return; } SDL_VERSION(ver); diff --git a/src/SDL_assert.c b/src/SDL_assert.c index e60f7a9b3..c4ca82407 100644 --- a/src/SDL_assert.c +++ b/src/SDL_assert.c @@ -48,8 +48,7 @@ /* The size of the stack buffer to use for rendering assert messages. */ #define SDL_MAX_ASSERT_MESSAGE_STACK 256 -static SDL_assert_state SDLCALL -SDL_PromptAssertion(const SDL_assert_data *data, void *userdata); +static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data, void *userdata); /* * We keep all triggered assertions in a singly-linked list so we can @@ -65,12 +64,10 @@ static SDL_AssertionHandler assertion_handler = SDL_PromptAssertion; static void *assertion_userdata = NULL; #ifdef __GNUC__ -static void -debug_print(const char *fmt, ...) __attribute__((format (printf, 1, 2))); +static void debug_print(const char *fmt, ...) __attribute__((format(printf, 1, 2))); #endif -static void -debug_print(const char *fmt, ...) +static void debug_print(const char *fmt, ...) { va_list ap; va_start(ap, fmt); @@ -78,31 +75,30 @@ debug_print(const char *fmt, ...) va_end(ap); } - static void SDL_AddAssertionToReport(SDL_assert_data *data) { /* (data) is always a static struct defined with the assert macros, so we don't have to worry about copying or allocating them. */ data->trigger_count++; - if (data->trigger_count == 1) { /* not yet added? */ + if (data->trigger_count == 1) { /* not yet added? */ data->next = triggered_assertions; triggered_assertions = data; } } #if defined(__WIN32__) || defined(__GDK__) - #define ENDLINE "\r\n" +#define ENDLINE "\r\n" #else - #define ENDLINE "\n" +#define ENDLINE "\n" #endif -static int SDL_RenderAssertMessage(char *buf, size_t buf_len, const SDL_assert_data *data) { +static int SDL_RenderAssertMessage(char *buf, size_t buf_len, const SDL_assert_data *data) +{ return SDL_snprintf(buf, buf_len, - "Assertion failure at %s (%s:%d), triggered %u %s:" ENDLINE " '%s'", - data->function, data->filename, data->linenum, - data->trigger_count, (data->trigger_count == 1) ? "time" : "times", - data->condition - ); + "Assertion failure at %s (%s:%d), triggered %u %s:" ENDLINE " '%s'", + data->function, data->filename, data->linenum, + data->trigger_count, (data->trigger_count == 1) ? "time" : "times", + data->condition); } static void SDL_GenerateAssertionReport(void) @@ -132,7 +128,6 @@ static void SDL_GenerateAssertionReport(void) } } - /* This is not declared in any header, although it is shared between some parts of SDL, because we don't want anything calling it without an extremely good reason. */ @@ -142,9 +137,8 @@ extern void SDL_ExitProcess(int exitcode); #endif extern SDL_NORETURN void SDL_ExitProcess(int exitcode); - #if defined(__WATCOMC__) -static void SDL_AbortAssertion (void); +static void SDL_AbortAssertion(void); #pragma aux SDL_AbortAssertion aborts; #endif static SDL_NORETURN void SDL_AbortAssertion(void) @@ -153,21 +147,20 @@ static SDL_NORETURN void SDL_AbortAssertion(void) SDL_ExitProcess(42); } -static SDL_assert_state SDLCALL -SDL_PromptAssertion(const SDL_assert_data *data, void *userdata) +static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data, void *userdata) { const char *envr; SDL_assert_state state = SDL_ASSERTION_ABORT; SDL_Window *window; SDL_MessageBoxData messagebox; SDL_MessageBoxButtonData buttons[] = { - { 0, SDL_ASSERTION_RETRY, "Retry" }, - { 0, SDL_ASSERTION_BREAK, "Break" }, - { 0, SDL_ASSERTION_ABORT, "Abort" }, - { SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, - SDL_ASSERTION_IGNORE, "Ignore" }, - { SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, - SDL_ASSERTION_ALWAYS_IGNORE, "Always Ignore" } + { 0, SDL_ASSERTION_RETRY, "Retry" }, + { 0, SDL_ASSERTION_BREAK, "Break" }, + { 0, SDL_ASSERTION_ABORT, "Abort" }, + { SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, + SDL_ASSERTION_IGNORE, "Ignore" }, + { SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, + SDL_ASSERTION_ALWAYS_IGNORE, "Always Ignore" } }; int selected; @@ -176,7 +169,7 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata) size_t buf_len = sizeof(stack_buf); int len; - (void) userdata; /* unused in default handler. */ + (void)userdata; /* unused in default handler. */ /* Assume the output will fit... */ len = SDL_RenderAssertMessage(message, buf_len, data); @@ -221,7 +214,7 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata) } else if (SDL_strcmp(envr, "always_ignore") == 0) { return SDL_ASSERTION_ALWAYS_IGNORE; } else { - return SDL_ASSERTION_ABORT; /* oh well. */ + return SDL_ASSERTION_ABORT; /* oh well. */ } } @@ -255,8 +248,9 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata) } else { #if defined(__EMSCRIPTEN__) /* This is nasty, but we can't block on a custom UI. */ - for ( ; ; ) { + for (;;) { SDL_bool okay = SDL_TRUE; + /* *INDENT-OFF* */ /* clang-format off */ char *buf = (char *) EM_ASM_INT({ var str = UTF8ToString($0) + '\n\n' + @@ -267,12 +261,14 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata) } return allocate(intArrayFromString(reply), 'i8', ALLOC_NORMAL); }, message); + /* *INDENT-ON* */ /* clang-format on */ if (SDL_strcmp(buf, "a") == 0) { state = SDL_ASSERTION_ABORT; - /* (currently) no break functionality on Emscripten +#if 0 /* (currently) no break functionality on Emscripten */ } else if (SDL_strcmp(buf, "b") == 0) { - state = SDL_ASSERTION_BREAK; */ + state = SDL_ASSERTION_BREAK; +#endif } else if (SDL_strcmp(buf, "r") == 0) { state = SDL_ASSERTION_RETRY; } else if (SDL_strcmp(buf, "i") == 0) { @@ -290,11 +286,11 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata) } #elif defined(HAVE_STDIO_H) /* this is a little hacky. */ - for ( ; ; ) { + for (;;) { char buf[32]; fprintf(stderr, "Abort/Break/Retry/Ignore/AlwaysIgnore? [abriA] : "); fflush(stderr); - if (fgets(buf, sizeof (buf), stdin) == NULL) { + if (fgets(buf, sizeof(buf), stdin) == NULL) { break; } @@ -330,7 +326,6 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata) return state; } - SDL_assert_state SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file, int line) @@ -345,13 +340,13 @@ SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file, assertion_mutex = SDL_CreateMutex(); if (assertion_mutex == NULL) { SDL_AtomicUnlock(&spinlock); - return SDL_ASSERTION_IGNORE; /* oh well, I guess. */ + return SDL_ASSERTION_IGNORE; /* oh well, I guess. */ } } SDL_AtomicUnlock(&spinlock); if (SDL_LockMutex(assertion_mutex) < 0) { - return SDL_ASSERTION_IGNORE; /* oh well, I guess. */ + return SDL_ASSERTION_IGNORE; /* oh well, I guess. */ } #endif @@ -365,13 +360,14 @@ SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file, SDL_AddAssertionToReport(data); assertion_running++; - if (assertion_running > 1) { /* assert during assert! Abort. */ + if (assertion_running > 1) { /* assert during assert! Abort. */ if (assertion_running == 2) { SDL_AbortAssertion(); - } else if (assertion_running == 3) { /* Abort asserted! */ + } else if (assertion_running == 3) { /* Abort asserted! */ SDL_ExitProcess(42); } else { - while (1) { /* do nothing but spin; what else can you do?! */ } + while (1) { /* do nothing but spin; what else can you do?! */ + } } } @@ -379,21 +375,20 @@ SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file, state = assertion_handler(data, assertion_userdata); } - switch (state) - { - case SDL_ASSERTION_ALWAYS_IGNORE: - state = SDL_ASSERTION_IGNORE; - data->always_ignore = 1; - break; + switch (state) { + case SDL_ASSERTION_ALWAYS_IGNORE: + state = SDL_ASSERTION_IGNORE; + data->always_ignore = 1; + break; - case SDL_ASSERTION_IGNORE: - case SDL_ASSERTION_RETRY: - case SDL_ASSERTION_BREAK: - break; /* macro handles these. */ + case SDL_ASSERTION_IGNORE: + case SDL_ASSERTION_RETRY: + case SDL_ASSERTION_BREAK: + break; /* macro handles these. */ - case SDL_ASSERTION_ABORT: - SDL_AbortAssertion(); - /*break; ...shouldn't return, but oh well. */ + case SDL_ASSERTION_ABORT: + SDL_AbortAssertion(); + /*break; ...shouldn't return, but oh well. */ } assertion_running--; @@ -405,7 +400,6 @@ SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file, return state; } - void SDL_AssertionsQuit(void) { #if SDL_ASSERT_LEVEL > 0 @@ -440,7 +434,7 @@ void SDL_ResetAssertionReport(void) SDL_assert_data *next = NULL; SDL_assert_data *item; for (item = triggered_assertions; item != NULL; item = next) { - next = (SDL_assert_data *) item->next; + next = (SDL_assert_data *)item->next; item->always_ignore = SDL_FALSE; item->trigger_count = 0; item->next = NULL; diff --git a/src/SDL_dataqueue.c b/src/SDL_dataqueue.c index 6a44621eb..20ee6462e 100644 --- a/src/SDL_dataqueue.c +++ b/src/SDL_dataqueue.c @@ -25,10 +25,10 @@ typedef struct SDL_DataQueuePacket { - size_t datalen; /* bytes currently in use in this packet. */ - size_t startpos; /* bytes currently consumed in this packet. */ - struct SDL_DataQueuePacket *next; /* next item in linked list. */ - Uint8 data[SDL_VARIABLE_LENGTH_ARRAY]; /* packet data */ + size_t datalen; /* bytes currently in use in this packet. */ + size_t startpos; /* bytes currently consumed in this packet. */ + struct SDL_DataQueuePacket *next; /* next item in linked list. */ + Uint8 data[SDL_VARIABLE_LENGTH_ARRAY]; /* packet data */ } SDL_DataQueuePacket; struct SDL_DataQueue @@ -36,12 +36,11 @@ struct SDL_DataQueue SDL_DataQueuePacket *head; /* device fed from here. */ SDL_DataQueuePacket *tail; /* queue fills to here. */ SDL_DataQueuePacket *pool; /* these are unused packets. */ - size_t packet_size; /* size of new packets */ - size_t queued_bytes; /* number of bytes of data in the queue. */ + size_t packet_size; /* size of new packets */ + size_t queued_bytes; /* number of bytes of data in the queue. */ }; -static void -SDL_FreeDataQueueList(SDL_DataQueuePacket *packet) +static void SDL_FreeDataQueueList(SDL_DataQueuePacket *packet) { while (packet) { SDL_DataQueuePacket *next = packet->next; @@ -50,13 +49,12 @@ SDL_FreeDataQueueList(SDL_DataQueuePacket *packet) } } - /* this all expects that you managed thread safety elsewhere. */ SDL_DataQueue * SDL_NewDataQueue(const size_t _packetlen, const size_t initialslack) { - SDL_DataQueue *queue = (SDL_DataQueue *) SDL_malloc(sizeof (SDL_DataQueue)); + SDL_DataQueue *queue = (SDL_DataQueue *)SDL_malloc(sizeof(SDL_DataQueue)); if (queue == NULL) { SDL_OutOfMemory(); @@ -70,7 +68,7 @@ SDL_NewDataQueue(const size_t _packetlen, const size_t initialslack) queue->packet_size = packetlen; for (i = 0; i < wantpackets; i++) { - SDL_DataQueuePacket *packet = (SDL_DataQueuePacket *) SDL_malloc(sizeof (SDL_DataQueuePacket) + packetlen); + SDL_DataQueuePacket *packet = (SDL_DataQueuePacket *)SDL_malloc(sizeof(SDL_DataQueuePacket) + packetlen); if (packet) { /* don't care if this fails, we'll deal later. */ packet->datalen = 0; packet->startpos = 0; @@ -83,8 +81,7 @@ SDL_NewDataQueue(const size_t _packetlen, const size_t initialslack) return queue; } -void -SDL_FreeDataQueue(SDL_DataQueue *queue) +void SDL_FreeDataQueue(SDL_DataQueue *queue) { if (queue) { SDL_FreeDataQueueList(queue->head); @@ -93,11 +90,10 @@ SDL_FreeDataQueue(SDL_DataQueue *queue) } } -void -SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack) +void SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack) { const size_t packet_size = queue ? queue->packet_size : 1; - const size_t slackpackets = (slack + (packet_size-1)) / packet_size; + const size_t slackpackets = (slack + (packet_size - 1)) / packet_size; SDL_DataQueuePacket *packet; SDL_DataQueuePacket *prev = NULL; size_t i; @@ -133,11 +129,10 @@ SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack) queue->pool = NULL; } - SDL_FreeDataQueueList(packet); /* free extra packets */ + SDL_FreeDataQueueList(packet); /* free extra packets */ } -static SDL_DataQueuePacket * -AllocateDataQueuePacket(SDL_DataQueue *queue) +static SDL_DataQueuePacket *AllocateDataQueuePacket(SDL_DataQueue *queue) { SDL_DataQueuePacket *packet; @@ -149,7 +144,7 @@ AllocateDataQueuePacket(SDL_DataQueue *queue) queue->pool = packet->next; } else { /* Have to allocate a new one! */ - packet = (SDL_DataQueuePacket *) SDL_malloc(sizeof (SDL_DataQueuePacket) + queue->packet_size); + packet = (SDL_DataQueuePacket *)SDL_malloc(sizeof(SDL_DataQueuePacket) + queue->packet_size); if (packet == NULL) { return NULL; } @@ -158,7 +153,7 @@ AllocateDataQueuePacket(SDL_DataQueue *queue) packet->datalen = 0; packet->startpos = 0; packet->next = NULL; - + SDL_assert((queue->head != NULL) == (queue->queued_bytes != 0)); if (queue->tail == NULL) { queue->head = packet; @@ -169,12 +164,10 @@ AllocateDataQueuePacket(SDL_DataQueue *queue) return packet; } - -int -SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _len) +int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _len) { size_t len = _len; - const Uint8 *data = (const Uint8 *) _data; + const Uint8 *data = (const Uint8 *)_data; const size_t packet_size = queue ? queue->packet_size : 0; SDL_DataQueuePacket *orighead; SDL_DataQueuePacket *origtail; @@ -198,9 +191,9 @@ SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _len) if (packet == NULL) { /* uhoh, reset so we've queued nothing new, free what we can. */ if (origtail == NULL) { - packet = queue->head; /* whole queue. */ + packet = queue->head; /* whole queue. */ } else { - packet = origtail->next; /* what we added to existing queue. */ + packet = origtail->next; /* what we added to existing queue. */ origtail->next = NULL; origtail->datalen = origlen; } @@ -208,7 +201,7 @@ SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _len) queue->tail = origtail; queue->pool = NULL; - SDL_FreeDataQueueList(packet); /* give back what we can. */ + SDL_FreeDataQueueList(packet); /* give back what we can. */ return SDL_OutOfMemory(); } } @@ -228,7 +221,7 @@ size_t SDL_PeekIntoDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len) { size_t len = _len; - Uint8 *buf = (Uint8 *) _buf; + Uint8 *buf = (Uint8 *)_buf; Uint8 *ptr = buf; SDL_DataQueuePacket *packet; @@ -246,14 +239,14 @@ SDL_PeekIntoDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len) len -= cpy; } - return (size_t) (ptr - buf); + return (size_t)(ptr - buf); } size_t SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len) { size_t len = _len; - Uint8 *buf = (Uint8 *) _buf; + Uint8 *buf = (Uint8 *)_buf; Uint8 *ptr = buf; SDL_DataQueuePacket *packet; @@ -272,7 +265,7 @@ SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len) queue->queued_bytes -= cpy; len -= cpy; - if (packet->startpos == packet->datalen) { /* packet is done, put it in the pool. */ + if (packet->startpos == packet->datalen) { /* packet is done, put it in the pool. */ queue->head = packet->next; SDL_assert((packet->next != NULL) || (packet == queue->tail)); packet->next = queue->pool; @@ -283,10 +276,10 @@ SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len) SDL_assert((queue->head != NULL) == (queue->queued_bytes != 0)); if (queue->head == NULL) { - queue->tail = NULL; /* in case we drained the queue entirely. */ + queue->tail = NULL; /* in case we drained the queue entirely. */ } - return (size_t) (ptr - buf); + return (size_t)(ptr - buf); } size_t @@ -314,7 +307,7 @@ SDL_ReserveSpaceInDataQueue(SDL_DataQueue *queue, const size_t len) packet = queue->head; if (packet) { const size_t avail = queue->packet_size - packet->datalen; - if (len <= avail) { /* we can use the space at end of this packet. */ + if (len <= avail) { /* we can use the space at end of this packet. */ void *retval = packet->data + packet->datalen; packet->datalen += len; queue->queued_bytes += len; @@ -335,4 +328,3 @@ SDL_ReserveSpaceInDataQueue(SDL_DataQueue *queue, const size_t len) } /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/SDL_dataqueue.h b/src/SDL_dataqueue.h index 46b8ebd70..e5c8c966d 100644 --- a/src/SDL_dataqueue.h +++ b/src/SDL_dataqueue.h @@ -52,4 +52,3 @@ void *SDL_ReserveSpaceInDataQueue(SDL_DataQueue *queue, const size_t len); #endif /* SDL_dataqueue_h_ */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/SDL_error.c b/src/SDL_error.c index 1ca460a69..be3160c5d 100644 --- a/src/SDL_error.c +++ b/src/SDL_error.c @@ -25,8 +25,7 @@ #include "SDL_error.h" #include "SDL_error_c.h" -int -SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) +int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { /* Ignore call if invalid format pointer was passed */ if (fmt != NULL) { @@ -34,7 +33,7 @@ SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) int result; SDL_error *error = SDL_GetErrBuf(); - error->error = 1; /* mark error as valid */ + error->error = 1; /* mark error as valid */ va_start(ap, fmt); result = SDL_vsnprintf(error->str, error->len, fmt, ap); @@ -52,7 +51,6 @@ SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) } } - if (SDL_LogGetPriority(SDL_LOG_CATEGORY_ERROR) <= SDL_LOG_PRIORITY_DEBUG) { /* If we are in debug mode, print out the error message */ SDL_LogDebug(SDL_LOG_CATEGORY_ERROR, "%s", error->str); @@ -70,15 +68,13 @@ SDL_GetError(void) return error->error ? error->str : ""; } -void -SDL_ClearError(void) +void SDL_ClearError(void) { SDL_GetErrBuf()->error = 0; } /* Very common errors go here */ -int -SDL_Error(SDL_errorcode code) +int SDL_Error(SDL_errorcode code) { switch (code) { case SDL_ENOMEM: @@ -97,8 +93,7 @@ SDL_Error(SDL_errorcode code) } #ifdef TEST_ERROR -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { char buffer[BUFSIZ + 1]; @@ -113,7 +108,6 @@ main(int argc, char *argv[]) } #endif - char * SDL_GetErrorMsg(char *errstr, int maxlen) { diff --git a/src/SDL_guid.c b/src/SDL_guid.c index f75ab0a89..11fe0b08c 100644 --- a/src/SDL_guid.c +++ b/src/SDL_guid.c @@ -33,7 +33,7 @@ void SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID) return; } - for (i = 0; i < sizeof(guid.data) && i < (cbGUID-1)/2; i++) { + for (i = 0; i < sizeof(guid.data) && i < (cbGUID - 1) / 2; i++) { /* each input byte writes 2 ascii chars, and might write a null byte. */ /* If we don't have room for next input byte, stop */ unsigned char c = guid.data[i]; @@ -72,7 +72,7 @@ static unsigned char nibble(unsigned char c) SDL_GUID SDL_GUIDFromString(const char *pchGUID) { SDL_GUID guid; - int maxoutputbytes= sizeof(guid); + int maxoutputbytes = sizeof(guid); size_t len = SDL_strlen(pchGUID); Uint8 *p; size_t i; @@ -83,8 +83,8 @@ SDL_GUID SDL_GUIDFromString(const char *pchGUID) SDL_memset(&guid, 0x00, sizeof(guid)); p = (Uint8 *)&guid; - for (i = 0; (i < len) && ((p - (Uint8 *)&guid) < maxoutputbytes); i+=2, p++) { - *p = (nibble((unsigned char)pchGUID[i]) << 4) | nibble((unsigned char)pchGUID[i+1]); + for (i = 0; (i < len) && ((p - (Uint8 *)&guid) < maxoutputbytes); i += 2, p++) { + *p = (nibble((unsigned char)pchGUID[i]) << 4) | nibble((unsigned char)pchGUID[i + 1]); } return guid; diff --git a/src/SDL_hints.c b/src/SDL_hints.c index 5e310ca01..f6edec4a8 100644 --- a/src/SDL_hints.c +++ b/src/SDL_hints.c @@ -24,17 +24,18 @@ #include "SDL_error.h" #include "SDL_hints_c.h" - /* Assuming there aren't many hints set and they aren't being queried in critical performance paths, we'll just use linked lists here. */ -typedef struct SDL_HintWatch { +typedef struct SDL_HintWatch +{ SDL_HintCallback callback; void *userdata; struct SDL_HintWatch *next; } SDL_HintWatch; -typedef struct SDL_Hint { +typedef struct SDL_Hint +{ char *name; char *value; SDL_HintPriority priority; @@ -68,7 +69,7 @@ SDL_SetHintWithPriority(const char *name, const char *value, } if (hint->value != value && (value == NULL || !hint->value || SDL_strcmp(hint->value, value) != 0)) { - for (entry = hint->callbacks; entry; ) { + for (entry = hint->callbacks; entry;) { /* Save the next entry in case this one is deleted */ SDL_HintWatch *next = entry->next; entry->callback(entry->userdata, name, hint->value, value); @@ -113,7 +114,7 @@ SDL_ResetHint(const char *name) if ((env == NULL && hint->value != NULL) || (env != NULL && hint->value == NULL) || (env != NULL && SDL_strcmp(env, hint->value) != 0)) { - for (entry = hint->callbacks; entry; ) { + for (entry = hint->callbacks; entry;) { /* Save the next entry in case this one is deleted */ SDL_HintWatch *next = entry->next; entry->callback(entry->userdata, name, hint->value, env); @@ -129,8 +130,7 @@ SDL_ResetHint(const char *name) return SDL_FALSE; } -void -SDL_ResetHints(void) +void SDL_ResetHints(void) { const char *env; SDL_Hint *hint; @@ -141,7 +141,7 @@ SDL_ResetHints(void) if ((env == NULL && hint->value != NULL) || (env != NULL && hint->value == NULL) || (env != NULL && SDL_strcmp(env, hint->value) != 0)) { - for (entry = hint->callbacks; entry; ) { + for (entry = hint->callbacks; entry;) { /* Save the next entry in case this one is deleted */ SDL_HintWatch *next = entry->next; entry->callback(entry->userdata, hint->name, hint->value, env); @@ -197,8 +197,7 @@ SDL_GetHintBoolean(const char *name, SDL_bool default_value) return SDL_GetStringBoolean(hint, default_value); } -void -SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata) +void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata) { SDL_Hint *hint; SDL_HintWatch *entry; @@ -259,8 +258,7 @@ SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata) callback(userdata, name, value, value); } -void -SDL_DelHintCallback(const char *name, SDL_HintCallback callback, void *userdata) +void SDL_DelHintCallback(const char *name, SDL_HintCallback callback, void *userdata) { SDL_Hint *hint; SDL_HintWatch *entry, *prev; @@ -296,7 +294,7 @@ void SDL_ClearHints(void) SDL_free(hint->name); SDL_free(hint->value); - for (entry = hint->callbacks; entry; ) { + for (entry = hint->callbacks; entry;) { SDL_HintWatch *freeable = entry; entry = entry->next; SDL_free(freeable); diff --git a/src/SDL_internal.h b/src/SDL_internal.h index 43e407f87..411287313 100644 --- a/src/SDL_internal.h +++ b/src/SDL_internal.h @@ -35,9 +35,14 @@ #define SDL_VARIABLE_LENGTH_ARRAY #endif -#define SDL_MAX_SMALL_ALLOC_STACKSIZE 128 -#define SDL_small_alloc(type, count, pisstack) ( (*(pisstack) = ((sizeof(type)*(count)) < SDL_MAX_SMALL_ALLOC_STACKSIZE)), (*(pisstack) ? SDL_stack_alloc(type, count) : (type*)SDL_malloc(sizeof(type)*(count))) ) -#define SDL_small_free(ptr, isstack) if ((isstack)) { SDL_stack_free(ptr); } else { SDL_free(ptr); } +#define SDL_MAX_SMALL_ALLOC_STACKSIZE 128 +#define SDL_small_alloc(type, count, pisstack) ((*(pisstack) = ((sizeof(type) * (count)) < SDL_MAX_SMALL_ALLOC_STACKSIZE)), (*(pisstack) ? SDL_stack_alloc(type, count) : (type *)SDL_malloc(sizeof(type) * (count)))) +#define SDL_small_free(ptr, isstack) \ + if ((isstack)) { \ + SDL_stack_free(ptr); \ + } else { \ + SDL_free(ptr); \ + } #include "dynapi/SDL_dynapi.h" @@ -52,57 +57,57 @@ /* If you run into a warning that O_CLOEXEC is redefined, update the SDL configuration header for your platform to add HAVE_O_CLOEXEC */ #ifndef HAVE_O_CLOEXEC -#define O_CLOEXEC 0 +#define O_CLOEXEC 0 #endif /* A few #defines to reduce SDL2 footprint. Only effective when library is statically linked. You have to manually edit this file. */ #ifndef SDL_LEAN_AND_MEAN -#define SDL_LEAN_AND_MEAN 0 +#define SDL_LEAN_AND_MEAN 0 #endif /* Optimized functions from 'SDL_blit_0.c' - blit with source BitsPerPixel < 8, palette */ #ifndef SDL_HAVE_BLIT_0 -#define SDL_HAVE_BLIT_0 !SDL_LEAN_AND_MEAN +#define SDL_HAVE_BLIT_0 !SDL_LEAN_AND_MEAN #endif /* Optimized functions from 'SDL_blit_1.c' - blit with source BytesPerPixel == 1, palette */ #ifndef SDL_HAVE_BLIT_1 -#define SDL_HAVE_BLIT_1 !SDL_LEAN_AND_MEAN +#define SDL_HAVE_BLIT_1 !SDL_LEAN_AND_MEAN #endif /* Optimized functions from 'SDL_blit_A.c' - blit with 'SDL_BLENDMODE_BLEND' blending mode */ #ifndef SDL_HAVE_BLIT_A -#define SDL_HAVE_BLIT_A !SDL_LEAN_AND_MEAN +#define SDL_HAVE_BLIT_A !SDL_LEAN_AND_MEAN #endif /* Optimized functions from 'SDL_blit_N.c' - blit with COLORKEY mode, or nothing */ #ifndef SDL_HAVE_BLIT_N -#define SDL_HAVE_BLIT_N !SDL_LEAN_AND_MEAN +#define SDL_HAVE_BLIT_N !SDL_LEAN_AND_MEAN #endif /* Optimized functions from 'SDL_blit_N.c' - RGB565 conversion with Lookup tables */ #ifndef SDL_HAVE_BLIT_N_RGB565 -#define SDL_HAVE_BLIT_N_RGB565 !SDL_LEAN_AND_MEAN +#define SDL_HAVE_BLIT_N_RGB565 !SDL_LEAN_AND_MEAN #endif /* Optimized functions from 'SDL_blit_AUTO.c' - blit with modulate color, modulate alpha, any blending mode - scaling or not */ #ifndef SDL_HAVE_BLIT_AUTO -#define SDL_HAVE_BLIT_AUTO !SDL_LEAN_AND_MEAN +#define SDL_HAVE_BLIT_AUTO !SDL_LEAN_AND_MEAN #endif /* Run-Length-Encoding - SDL_SetColorKey() called with SDL_RLEACCEL flag */ #ifndef SDL_HAVE_RLE -#define SDL_HAVE_RLE !SDL_LEAN_AND_MEAN +#define SDL_HAVE_RLE !SDL_LEAN_AND_MEAN #endif /* Software SDL_Renderer @@ -110,14 +115,14 @@ - *not* general blitting functions - {blend,draw}{fillrect,line,point} internal functions */ #ifndef SDL_VIDEO_RENDER_SW -#define SDL_VIDEO_RENDER_SW !SDL_LEAN_AND_MEAN +#define SDL_VIDEO_RENDER_SW !SDL_LEAN_AND_MEAN #endif /* YUV formats - handling of YUV surfaces - blitting and conversion functions */ #ifndef SDL_HAVE_YUV -#define SDL_HAVE_YUV !SDL_LEAN_AND_MEAN +#define SDL_HAVE_YUV !SDL_LEAN_AND_MEAN #endif #include "SDL_assert.h" diff --git a/src/SDL_list.c b/src/SDL_list.c index af9f8bf81..43c055332 100644 --- a/src/SDL_list.c +++ b/src/SDL_list.c @@ -24,10 +24,9 @@ #include "./SDL_list.h" /* Push */ -int -SDL_ListAdd(SDL_ListNode **head, void *ent) +int SDL_ListAdd(SDL_ListNode **head, void *ent) { - SDL_ListNode *node = SDL_malloc(sizeof (*node)); + SDL_ListNode *node = SDL_malloc(sizeof(*node)); if (node == NULL) { return SDL_OutOfMemory(); @@ -40,8 +39,7 @@ SDL_ListAdd(SDL_ListNode **head, void *ent) } /* Pop from end as a FIFO (if add with SDL_ListAdd) */ -void -SDL_ListPop(SDL_ListNode **head, void **ent) +void SDL_ListPop(SDL_ListNode **head, void **ent) { SDL_ListNode **ptr = head; @@ -55,15 +53,14 @@ SDL_ListPop(SDL_ListNode **head, void **ent) } if (ent) { - *ent = (*ptr)->entry; + *ent = (*ptr)->entry; } SDL_free(*ptr); *ptr = NULL; } -void -SDL_ListRemove(SDL_ListNode **head, void *ent) +void SDL_ListRemove(SDL_ListNode **head, void *ent) { SDL_ListNode **ptr = head; @@ -78,8 +75,7 @@ SDL_ListRemove(SDL_ListNode **head, void *ent) } } -void -SDL_ListClear(SDL_ListNode **head) +void SDL_ListClear(SDL_ListNode **head) { SDL_ListNode *l = *head; *head = NULL; diff --git a/src/SDL_list.h b/src/SDL_list.h index a7ead1dcd..458234ae7 100644 --- a/src/SDL_list.h +++ b/src/SDL_list.h @@ -28,7 +28,6 @@ typedef struct SDL_ListNode struct SDL_ListNode *next; } SDL_ListNode; - int SDL_ListAdd(SDL_ListNode **head, void *ent); void SDL_ListPop(SDL_ListNode **head, void **ent); void SDL_ListRemove(SDL_ListNode **head, void *ent); diff --git a/src/SDL_log.c b/src/SDL_log.c index 63743da7f..59f763820 100644 --- a/src/SDL_log.c +++ b/src/SDL_log.c @@ -41,14 +41,13 @@ #include "stdlib/SDL_vacopy.h" - /* The size of the stack buffer to use for rendering log messages. */ #define SDL_MAX_LOG_MESSAGE_STACK 256 -#define DEFAULT_PRIORITY SDL_LOG_PRIORITY_CRITICAL -#define DEFAULT_ASSERT_PRIORITY SDL_LOG_PRIORITY_WARN -#define DEFAULT_APPLICATION_PRIORITY SDL_LOG_PRIORITY_INFO -#define DEFAULT_TEST_PRIORITY SDL_LOG_PRIORITY_VERBOSE +#define DEFAULT_PRIORITY SDL_LOG_PRIORITY_CRITICAL +#define DEFAULT_ASSERT_PRIORITY SDL_LOG_PRIORITY_WARN +#define DEFAULT_APPLICATION_PRIORITY SDL_LOG_PRIORITY_INFO +#define DEFAULT_TEST_PRIORITY SDL_LOG_PRIORITY_VERBOSE typedef struct SDL_LogLevel { @@ -105,8 +104,7 @@ static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = { }; #endif /* __ANDROID__ */ -void -SDL_LogInit(void) +void SDL_LogInit(void) { if (log_function_mutex == NULL) { /* if this fails we'll try to continue without it. */ @@ -114,8 +112,7 @@ SDL_LogInit(void) } } -void -SDL_LogQuit(void) +void SDL_LogQuit(void) { SDL_LogResetPriorities(); if (log_function_mutex) { @@ -124,8 +121,7 @@ SDL_LogQuit(void) } } -void -SDL_LogSetAllPriority(SDL_LogPriority priority) +void SDL_LogSetAllPriority(SDL_LogPriority priority) { SDL_LogLevel *entry; @@ -137,8 +133,7 @@ SDL_LogSetAllPriority(SDL_LogPriority priority) SDL_application_priority = priority; } -void -SDL_LogSetPriority(int category, SDL_LogPriority priority) +void SDL_LogSetPriority(int category, SDL_LogPriority priority) { SDL_LogLevel *entry; @@ -181,8 +176,7 @@ SDL_LogGetPriority(int category) } } -void -SDL_LogResetPriorities(void) +void SDL_LogResetPriorities(void) { SDL_LogLevel *entry; @@ -198,8 +192,7 @@ SDL_LogResetPriorities(void) SDL_test_priority = DEFAULT_TEST_PRIORITY; } -void -SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) +void SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { va_list ap; @@ -208,8 +201,7 @@ SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) va_end(ap); } -void -SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) +void SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { va_list ap; @@ -218,8 +210,7 @@ SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) va_end(ap); } -void -SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) +void SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { va_list ap; @@ -228,8 +219,7 @@ SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) va_end(ap); } -void -SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) +void SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { va_list ap; @@ -238,8 +228,7 @@ SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) va_end(ap); } -void -SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) +void SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { va_list ap; @@ -248,8 +237,7 @@ SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) va_end(ap); } -void -SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) +void SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { va_list ap; @@ -258,8 +246,7 @@ SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) va_end(ap); } -void -SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) +void SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { va_list ap; @@ -268,8 +255,7 @@ SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) va_end(ap); } -void -SDL_LogMessage(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) +void SDL_LogMessage(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { va_list ap; @@ -279,8 +265,7 @@ SDL_LogMessage(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING } #ifdef __ANDROID__ -static const char * -GetCategoryPrefix(int category) +static const char *GetCategoryPrefix(int category) { if (category < SDL_LOG_CATEGORY_RESERVED1) { return SDL_category_prefixes[category]; @@ -292,8 +277,7 @@ GetCategoryPrefix(int category) } #endif /* __ANDROID__ */ -void -SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap) +void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap) { char *message = NULL; char stack_buf[SDL_MAX_LOG_MESSAGE_STACK]; @@ -345,9 +329,9 @@ SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list } /* Chop off final endline. */ - if ((len > 0) && (message[len-1] == '\n')) { + if ((len > 0) && (message[len - 1] == '\n')) { message[--len] = '\0'; - if ((len > 0) && (message[len-1] == '\r')) { /* catch "\r\n", too. */ + if ((len > 0) && (message[len - 1] == '\r')) { /* catch "\r\n", too. */ message[--len] = '\0'; } } @@ -376,9 +360,8 @@ static int consoleAttached = 0; static HANDLE stderrHandle = NULL; #endif -static void SDLCALL -SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, - const char *message) +static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, + const char *message) { #if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) /* Way too many allocations here, urgh */ @@ -399,34 +382,34 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, if (consoleAttached == 0) { attachResult = AttachConsole(ATTACH_PARENT_PROCESS); if (!attachResult) { - attachError = GetLastError(); - if (attachError == ERROR_INVALID_HANDLE) { - /* This is expected when running from Visual Studio */ - /*OutputDebugString(TEXT("Parent process has no console\r\n"));*/ - consoleAttached = -1; - } else if (attachError == ERROR_GEN_FAILURE) { - OutputDebugString(TEXT("Could not attach to console of parent process\r\n")); - consoleAttached = -1; - } else if (attachError == ERROR_ACCESS_DENIED) { - /* Already attached */ - consoleAttached = 1; - } else { - OutputDebugString(TEXT("Error attaching console\r\n")); - consoleAttached = -1; - } - } else { - /* Newly attached */ + attachError = GetLastError(); + if (attachError == ERROR_INVALID_HANDLE) { + /* This is expected when running from Visual Studio */ + /*OutputDebugString(TEXT("Parent process has no console\r\n"));*/ + consoleAttached = -1; + } else if (attachError == ERROR_GEN_FAILURE) { + OutputDebugString(TEXT("Could not attach to console of parent process\r\n")); + consoleAttached = -1; + } else if (attachError == ERROR_ACCESS_DENIED) { + /* Already attached */ consoleAttached = 1; + } else { + OutputDebugString(TEXT("Error attaching console\r\n")); + consoleAttached = -1; } + } else { + /* Newly attached */ + consoleAttached = 1; + } - if (consoleAttached == 1) { - stderrHandle = GetStdHandle(STD_ERROR_HANDLE); + if (consoleAttached == 1) { + stderrHandle = GetStdHandle(STD_ERROR_HANDLE); - if (GetConsoleMode(stderrHandle, &consoleMode) == 0) { - /* WriteConsole fails if the output is redirected to a file. Must use WriteFile instead. */ - consoleAttached = 2; - } + if (GetConsoleMode(stderrHandle, &consoleMode) == 0) { + /* WriteConsole fails if the output is redirected to a file. Must use WriteFile instead. */ + consoleAttached = 2; } + } } #endif /* !defined(HAVE_STDIO_H) && !defined(__WINRT__) && !defined(__GDK__) */ @@ -434,22 +417,22 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, output = SDL_small_alloc(char, length, &isstack); SDL_snprintf(output, length, "%s: %s\r\n", SDL_priority_prefixes[priority], message); tstr = WIN_UTF8ToString(output); - + /* Output to debugger */ OutputDebugString(tstr); - + #if !defined(HAVE_STDIO_H) && !defined(__WINRT__) && !defined(__GDK__) /* Screen output to stderr, if console was attached. */ if (consoleAttached == 1) { - if (!WriteConsole(stderrHandle, tstr, (DWORD) SDL_tcslen(tstr), &charsWritten, NULL)) { - OutputDebugString(TEXT("Error calling WriteConsole\r\n")); - if (GetLastError() == ERROR_NOT_ENOUGH_MEMORY) { - OutputDebugString(TEXT("Insufficient heap memory to write message\r\n")); - } + if (!WriteConsole(stderrHandle, tstr, (DWORD)SDL_tcslen(tstr), &charsWritten, NULL)) { + OutputDebugString(TEXT("Error calling WriteConsole\r\n")); + if (GetLastError() == ERROR_NOT_ENOUGH_MEMORY) { + OutputDebugString(TEXT("Insufficient heap memory to write message\r\n")); } + } } else if (consoleAttached == 2) { - if (!WriteFile(stderrHandle, output, (DWORD) SDL_strlen(output), &charsWritten, NULL)) { + if (!WriteFile(stderrHandle, output, (DWORD)SDL_strlen(output), &charsWritten, NULL)) { OutputDebugString(TEXT("Error calling WriteFile\r\n")); } } @@ -467,7 +450,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, } #elif defined(__APPLE__) && (defined(SDL_VIDEO_DRIVER_COCOA) || defined(SDL_VIDEO_DRIVER_UIKIT)) /* Technically we don't need Cocoa/UIKit, but that's where this function is defined for now. - */ + */ extern void SDL_NSLog(const char *prefix, const char *text); { SDL_NSLog(SDL_priority_prefixes[priority], message); @@ -475,17 +458,17 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, } #elif defined(__PSP__) || defined(__PS2__) { - FILE* pFile; - pFile = fopen ("SDL_Log.txt", "a"); + FILE *pFile; + pFile = fopen("SDL_Log.txt", "a"); fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message); - fclose (pFile); + fclose(pFile); } #elif defined(__VITA__) { - FILE* pFile; - pFile = fopen ("ux0:/data/SDL_Log.txt", "a"); + FILE *pFile; + pFile = fopen("ux0:/data/SDL_Log.txt", "a"); fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message); - fclose (pFile); + fclose(pFile); } #elif defined(__3DS__) { @@ -504,8 +487,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, #endif } -void -SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata) +void SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata) { if (callback) { *callback = SDL_log_function; @@ -515,8 +497,7 @@ SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata) } } -void -SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata) +void SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata) { SDL_log_function = callback; SDL_log_userdata = userdata; diff --git a/src/atomic/SDL_atomic.c b/src/atomic/SDL_atomic.c index deea13d95..72f3402bf 100644 --- a/src/atomic/SDL_atomic.c +++ b/src/atomic/SDL_atomic.c @@ -37,19 +37,20 @@ /* The __atomic_load_n() intrinsic showed up in different times for different compilers. */ #if defined(__clang__) -# if __has_builtin(__atomic_load_n) || defined(HAVE_GCC_ATOMICS) - /* !!! FIXME: this advertises as available in the NDK but uses an external symbol we don't have. - It might be in a later NDK or we might need an extra library? --ryan. */ -# if !defined(__ANDROID__) -# define HAVE_ATOMIC_LOAD_N 1 -# endif -# endif +#if __has_builtin(__atomic_load_n) || defined(HAVE_GCC_ATOMICS) +/* !!! FIXME: this advertises as available in the NDK but uses an external symbol we don't have. + It might be in a later NDK or we might need an extra library? --ryan. */ +#if !defined(__ANDROID__) +#define HAVE_ATOMIC_LOAD_N 1 +#endif +#endif #elif defined(__GNUC__) -# if (__GNUC__ >= 5) -# define HAVE_ATOMIC_LOAD_N 1 -# endif +#if (__GNUC__ >= 5) +#define HAVE_ATOMIC_LOAD_N 1 +#endif #endif +/* *INDENT-OFF* */ /* clang-format off */ #if defined(__WATCOMC__) && defined(__386__) SDL_COMPILE_TIME_ASSERT(intsize, 4==sizeof(int)); #define HAVE_WATCOM_ATOMICS @@ -74,7 +75,9 @@ extern __inline int _SDL_xadd_watcom(volatile int *a, int v); parm [ecx] [eax] \ value [eax] \ modify exact [eax]; + #endif /* __WATCOMC__ && __386__ */ +/* *INDENT-ON* */ /* clang-format on */ /* If any of the operations are not provided then we must emulate some @@ -106,16 +109,14 @@ extern __inline int _SDL_xadd_watcom(volatile int *a, int v); #if EMULATE_CAS static SDL_SpinLock locks[32]; -static SDL_INLINE void -enterLock(void *a) +static SDL_INLINE void enterLock(void *a) { uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f); SDL_AtomicLock(&locks[index]); } -static SDL_INLINE void -leaveLock(void *a) +static SDL_INLINE void leaveLock(void *a) { uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f); @@ -123,7 +124,6 @@ leaveLock(void *a) } #endif - SDL_bool SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval) { @@ -150,7 +150,7 @@ SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval) return retval; #else - #error Please define your platform. +#error Please define your platform. #endif } @@ -181,12 +181,11 @@ SDL_AtomicCASPtr(void **a, void *oldval, void *newval) return retval; #else - #error Please define your platform. +#error Please define your platform. #endif } -int -SDL_AtomicSet(SDL_atomic_t *a, int v) +int SDL_AtomicSet(SDL_atomic_t *a, int v) { #ifdef HAVE_MSC_ATOMICS SDL_COMPILE_TIME_ASSERT(atomic_set, sizeof(long) == sizeof(a->value)); @@ -206,7 +205,7 @@ SDL_AtomicSet(SDL_atomic_t *a, int v) #endif } -void* +void * SDL_AtomicSetPtr(void **a, void *v) { #if defined(HAVE_MSC_ATOMICS) @@ -226,8 +225,7 @@ SDL_AtomicSetPtr(void **a, void *v) #endif } -int -SDL_AtomicAdd(SDL_atomic_t *a, int v) +int SDL_AtomicAdd(SDL_atomic_t *a, int v) { #ifdef HAVE_MSC_ATOMICS SDL_COMPILE_TIME_ASSERT(atomic_add, sizeof(long) == sizeof(a->value)); @@ -237,9 +235,9 @@ SDL_AtomicAdd(SDL_atomic_t *a, int v) #elif defined(HAVE_GCC_ATOMICS) return __sync_fetch_and_add(&a->value, v); #elif defined(__SOLARIS__) - int pv = a->value; - membar_consumer(); - atomic_add_int((volatile uint_t*)&a->value, v); + int pv = a->value; + membar_consumer(); + atomic_add_int((volatile uint_t *)&a->value, v); return pv; #else int value; @@ -250,8 +248,7 @@ SDL_AtomicAdd(SDL_atomic_t *a, int v) #endif } -int -SDL_AtomicGet(SDL_atomic_t *a) +int SDL_AtomicGet(SDL_atomic_t *a) { #ifdef HAVE_ATOMIC_LOAD_N return __atomic_load_n(&a->value, __ATOMIC_SEQ_CST); @@ -299,14 +296,12 @@ SDL_AtomicGetPtr(void **a) #error This file should be built in arm mode so the mcr instruction is available for memory barriers #endif -void -SDL_MemoryBarrierReleaseFunction(void) +void SDL_MemoryBarrierReleaseFunction(void) { SDL_MemoryBarrierRelease(); } -void -SDL_MemoryBarrierAcquireFunction(void) +void SDL_MemoryBarrierAcquireFunction(void) { SDL_MemoryBarrierAcquire(); } diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c index 58f5cf6c5..0f0cd94d1 100644 --- a/src/atomic/SDL_spinlock.c +++ b/src/atomic/SDL_spinlock.c @@ -48,6 +48,7 @@ #include #endif +/* *INDENT-OFF* */ /* clang-format off */ #if defined(__WATCOMC__) && defined(__386__) SDL_COMPILE_TIME_ASSERT(locksize, 4==sizeof(SDL_SpinLock)); extern __inline int _SDL_xchg_watcom(volatile int *a, int v); @@ -57,6 +58,7 @@ extern __inline int _SDL_xchg_watcom(volatile int *a, int v); value [eax] \ modify exact [eax]; #endif /* __WATCOMC__ && __386__ */ +/* *INDENT-ON* */ /* clang-format on */ /* This function is where all the magic happens... */ SDL_bool @@ -93,39 +95,47 @@ SDL_AtomicTryLock(SDL_SpinLock *lock) #elif defined(__WATCOMC__) && defined(__386__) return _SDL_xchg_watcom(lock, 1) == 0; -#elif defined(__GNUC__) && defined(__arm__) && \ - (defined(__ARM_ARCH_3__) || defined(__ARM_ARCH_3M__) || \ - defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) || \ - defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5TE__) || \ - defined(__ARM_ARCH_5TEJ__)) +#elif defined(__GNUC__) && defined(__arm__) && \ + (defined(__ARM_ARCH_3__) || defined(__ARM_ARCH_3M__) || \ + defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) || \ + defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5TE__) || \ + defined(__ARM_ARCH_5TEJ__)) int result; #if defined(__RISCOS__) if (__cpucap_have_rex()) { - __asm__ __volatile__ ( + __asm__ __volatile__( "ldrex %0, [%2]\nteq %0, #0\nstrexeq %0, %1, [%2]" - : "=&r" (result) : "r" (1), "r" (lock) : "cc", "memory"); + : "=&r"(result) + : "r"(1), "r"(lock) + : "cc", "memory"); return result == 0; } #endif - __asm__ __volatile__ ( + __asm__ __volatile__( "swp %0, %1, [%2]\n" - : "=&r,&r" (result) : "r,0" (1), "r,r" (lock) : "memory"); + : "=&r,&r"(result) + : "r,0"(1), "r,r"(lock) + : "memory"); return result == 0; #elif defined(__GNUC__) && defined(__arm__) int result; - __asm__ __volatile__ ( + __asm__ __volatile__( "ldrex %0, [%2]\nteq %0, #0\nstrexeq %0, %1, [%2]" - : "=&r" (result) : "r" (1), "r" (lock) : "cc", "memory"); + : "=&r"(result) + : "r"(1), "r"(lock) + : "cc", "memory"); return result == 0; #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) int result; __asm__ __volatile__( "lock ; xchgl %0, (%1)\n" - : "=r" (result) : "r" (lock), "0" (1) : "cc", "memory"); + : "=r"(result) + : "r"(lock), "0"(1) + : "cc", "memory"); return result == 0; #elif defined(__MACOSX__) || defined(__IPHONEOS__) @@ -150,7 +160,9 @@ SDL_AtomicTryLock(SDL_SpinLock *lock) res = SDL_TRUE; } // enable interuption - if (oldintr) { EIntr(); } + if (oldintr) { + EIntr(); + } return res; #else #error Please implement for your platform. @@ -158,8 +170,7 @@ SDL_AtomicTryLock(SDL_SpinLock *lock) #endif } -void -SDL_AtomicLock(SDL_SpinLock *lock) +void SDL_AtomicLock(SDL_SpinLock *lock) { int iterations = 0; /* FIXME: Should we have an eventual timeout? */ @@ -174,8 +185,7 @@ SDL_AtomicLock(SDL_SpinLock *lock) } } -void -SDL_AtomicUnlock(SDL_SpinLock *lock) +void SDL_AtomicUnlock(SDL_SpinLock *lock) { #if HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET __sync_lock_release(lock); @@ -188,7 +198,7 @@ SDL_AtomicUnlock(SDL_SpinLock *lock) *lock = 0; #elif defined(__WATCOMC__) && defined(__386__) - SDL_CompilerBarrier (); + SDL_CompilerBarrier(); *lock = 0; #elif defined(__SOLARIS__) diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 91d01339a..52ed79271 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -132,22 +132,20 @@ static const AudioBootStrap *const bootstrap[] = { NULL }; - #ifdef HAVE_LIBSAMPLERATE_H #ifdef SDL_LIBSAMPLERATE_DYNAMIC static void *SRC_lib = NULL; #endif SDL_bool SRC_available = SDL_FALSE; int SRC_converter = 0; -SRC_STATE* (*SRC_src_new)(int converter_type, int channels, int *error) = NULL; +SRC_STATE *(*SRC_src_new)(int converter_type, int channels, int *error) = NULL; int (*SRC_src_process)(SRC_STATE *state, SRC_DATA *data) = NULL; int (*SRC_src_reset)(SRC_STATE *state) = NULL; -SRC_STATE* (*SRC_src_delete)(SRC_STATE *state) = NULL; -const char* (*SRC_src_strerror)(int error) = NULL; +SRC_STATE *(*SRC_src_delete)(SRC_STATE *state) = NULL; +const char *(*SRC_src_strerror)(int error) = NULL; int (*SRC_src_simple)(SRC_DATA *data, int converter_type, int channels) = NULL; -static SDL_bool -LoadLibSampleRate(void) +static SDL_bool LoadLibSampleRate(void) { const char *hint = SDL_GetHint(SDL_HINT_AUDIO_RESAMPLING_MODE); @@ -155,7 +153,7 @@ LoadLibSampleRate(void) SRC_converter = 0; if (!hint || *hint == '0' || SDL_strcasecmp(hint, "default") == 0) { - return SDL_FALSE; /* don't load anything. */ + return SDL_FALSE; /* don't load anything. */ } else if (*hint == '1' || SDL_strcasecmp(hint, "fast") == 0) { SRC_converter = SRC_SINC_FASTEST; } else if (*hint == '2' || SDL_strcasecmp(hint, "medium") == 0) { @@ -163,7 +161,7 @@ LoadLibSampleRate(void) } else if (*hint == '3' || SDL_strcasecmp(hint, "best") == 0) { SRC_converter = SRC_SINC_BEST_QUALITY; } else { - return SDL_FALSE; /* treat it like "default", don't load anything. */ + return SDL_FALSE; /* treat it like "default", don't load anything. */ } #ifdef SDL_LIBSAMPLERATE_DYNAMIC @@ -174,12 +172,14 @@ LoadLibSampleRate(void) return SDL_FALSE; } + /* *INDENT-OFF* */ /* clang-format off */ SRC_src_new = (SRC_STATE* (*)(int converter_type, int channels, int *error))SDL_LoadFunction(SRC_lib, "src_new"); SRC_src_process = (int (*)(SRC_STATE *state, SRC_DATA *data))SDL_LoadFunction(SRC_lib, "src_process"); SRC_src_reset = (int(*)(SRC_STATE *state))SDL_LoadFunction(SRC_lib, "src_reset"); SRC_src_delete = (SRC_STATE* (*)(SRC_STATE *state))SDL_LoadFunction(SRC_lib, "src_delete"); SRC_src_strerror = (const char* (*)(int error))SDL_LoadFunction(SRC_lib, "src_strerror"); SRC_src_simple = (int(*)(SRC_DATA *data, int converter_type, int channels))SDL_LoadFunction(SRC_lib, "src_simple"); +/* *INDENT-ON* */ /* clang-format on */ if (!SRC_src_new || !SRC_src_process || !SRC_src_reset || !SRC_src_delete || !SRC_src_strerror || !SRC_src_simple) { SDL_UnloadObject(SRC_lib); @@ -199,8 +199,7 @@ LoadLibSampleRate(void) return SDL_TRUE; } -static void -UnloadLibSampleRate(void) +static void UnloadLibSampleRate(void) { #ifdef SDL_LIBSAMPLERATE_DYNAMIC if (SRC_lib != NULL) { @@ -218,8 +217,7 @@ UnloadLibSampleRate(void) } #endif -static SDL_AudioDevice * -get_audio_device(SDL_AudioDeviceID id) +static SDL_AudioDevice *get_audio_device(SDL_AudioDeviceID id) { id--; if ((id >= SDL_arraysize(open_devices)) || (open_devices[id] == NULL)) { @@ -230,82 +228,67 @@ get_audio_device(SDL_AudioDeviceID id) return open_devices[id]; } - /* stubs for audio drivers that don't need a specific entry point... */ -static void -SDL_AudioDetectDevices_Default(void) +static void SDL_AudioDetectDevices_Default(void) { /* you have to write your own implementation if these assertions fail. */ SDL_assert(current_audio.impl.OnlyHasDefaultOutputDevice); SDL_assert(current_audio.impl.OnlyHasDefaultCaptureDevice || !current_audio.impl.HasCaptureSupport); - SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, NULL, (void *) ((size_t) 0x1)); + SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, NULL, (void *)((size_t)0x1)); if (current_audio.impl.HasCaptureSupport) { - SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, NULL, (void *) ((size_t) 0x2)); + SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, NULL, (void *)((size_t)0x2)); } } -static void -SDL_AudioThreadInit_Default(_THIS) -{ /* no-op. */ +static void SDL_AudioThreadInit_Default(_THIS) +{ /* no-op. */ } -static void -SDL_AudioThreadDeinit_Default(_THIS) -{ /* no-op. */ +static void SDL_AudioThreadDeinit_Default(_THIS) +{ /* no-op. */ } -static void -SDL_AudioWaitDevice_Default(_THIS) -{ /* no-op. */ +static void SDL_AudioWaitDevice_Default(_THIS) +{ /* no-op. */ } -static void -SDL_AudioPlayDevice_Default(_THIS) -{ /* no-op. */ +static void SDL_AudioPlayDevice_Default(_THIS) +{ /* no-op. */ } -static Uint8 * -SDL_AudioGetDeviceBuf_Default(_THIS) +static Uint8 *SDL_AudioGetDeviceBuf_Default(_THIS) { return NULL; } -static int -SDL_AudioCaptureFromDevice_Default(_THIS, void *buffer, int buflen) +static int SDL_AudioCaptureFromDevice_Default(_THIS, void *buffer, int buflen) { - return -1; /* just fail immediately. */ + return -1; /* just fail immediately. */ } -static void -SDL_AudioFlushCapture_Default(_THIS) -{ /* no-op. */ +static void SDL_AudioFlushCapture_Default(_THIS) +{ /* no-op. */ } -static void -SDL_AudioCloseDevice_Default(_THIS) -{ /* no-op. */ +static void SDL_AudioCloseDevice_Default(_THIS) +{ /* no-op. */ } -static void -SDL_AudioDeinitialize_Default(void) -{ /* no-op. */ +static void SDL_AudioDeinitialize_Default(void) +{ /* no-op. */ } -static void -SDL_AudioFreeDeviceHandle_Default(void *handle) -{ /* no-op. */ +static void SDL_AudioFreeDeviceHandle_Default(void *handle) +{ /* no-op. */ } - -static int -SDL_AudioOpenDevice_Default(_THIS, const char *devname) +static int SDL_AudioOpenDevice_Default(_THIS, const char *devname) { return SDL_Unsupported(); } -static SDL_INLINE SDL_bool -is_in_audio_device_thread(SDL_AudioDevice * device) +static SDL_INLINE SDL_bool is_in_audio_device_thread(SDL_AudioDevice *device) { /* The device thread locks the same mutex, but not through the public API. This check is in case the application, in the audio callback, @@ -318,35 +301,31 @@ is_in_audio_device_thread(SDL_AudioDevice * device) return SDL_FALSE; } -static void -SDL_AudioLockDevice_Default(SDL_AudioDevice * device) +static void SDL_AudioLockDevice_Default(SDL_AudioDevice *device) { if (!is_in_audio_device_thread(device)) { SDL_LockMutex(device->mixer_lock); } } -static void -SDL_AudioUnlockDevice_Default(SDL_AudioDevice * device) +static void SDL_AudioUnlockDevice_Default(SDL_AudioDevice *device) { if (!is_in_audio_device_thread(device)) { SDL_UnlockMutex(device->mixer_lock); } } -static void -finish_audio_entry_points_init(void) +static void finish_audio_entry_points_init(void) { /* * Fill in stub functions for unused driver entry points. This lets us * blindly call them without having to check for validity first. */ - -#define FILL_STUB(x) \ - if (current_audio.impl.x == NULL) { \ - current_audio.impl.x = SDL_Audio##x##_Default; \ - } +#define FILL_STUB(x) \ + if (current_audio.impl.x == NULL) { \ + current_audio.impl.x = SDL_Audio##x##_Default; \ + } FILL_STUB(DetectDevices); FILL_STUB(OpenDevice); FILL_STUB(ThreadInit); @@ -364,21 +343,19 @@ finish_audio_entry_points_init(void) #undef FILL_STUB } - /* device hotplug support... */ -static int -add_audio_device(const char *name, SDL_AudioSpec *spec, void *handle, SDL_AudioDeviceItem **devices, int *devCount) +static int add_audio_device(const char *name, SDL_AudioSpec *spec, void *handle, SDL_AudioDeviceItem **devices, int *devCount) { int retval = -1; SDL_AudioDeviceItem *item; const SDL_AudioDeviceItem *i; int dupenum = 0; - SDL_assert(handle != NULL); /* we reserve NULL, audio backends can't use it. */ + SDL_assert(handle != NULL); /* we reserve NULL, audio backends can't use it. */ SDL_assert(name != NULL); - item = (SDL_AudioDeviceItem *) SDL_malloc(sizeof (SDL_AudioDeviceItem)); + item = (SDL_AudioDeviceItem *)SDL_malloc(sizeof(SDL_AudioDeviceItem)); if (!item) { return SDL_OutOfMemory(); } @@ -403,13 +380,13 @@ add_audio_device(const char *name, SDL_AudioSpec *spec, void *handle, SDL_AudioD for (i = *devices; i != NULL; i = i->next) { if (SDL_strcmp(name, i->original_name) == 0) { dupenum = i->dupenum + 1; - break; /* stop at the highest-numbered dupe. */ + break; /* stop at the highest-numbered dupe. */ } } if (dupenum) { const size_t len = SDL_strlen(name) + 16; - char *replacement = (char *) SDL_malloc(len); + char *replacement = (char *)SDL_malloc(len); if (!replacement) { SDL_UnlockMutex(current_audio.detectionLock); SDL_free(item->original_name); @@ -424,28 +401,25 @@ add_audio_device(const char *name, SDL_AudioSpec *spec, void *handle, SDL_AudioD item->next = *devices; *devices = item; - retval = (*devCount)++; /* !!! FIXME: this should be an atomic increment */ + retval = (*devCount)++; /* !!! FIXME: this should be an atomic increment */ SDL_UnlockMutex(current_audio.detectionLock); return retval; } -static SDL_INLINE int -add_capture_device(const char *name, SDL_AudioSpec *spec, void *handle) +static SDL_INLINE int add_capture_device(const char *name, SDL_AudioSpec *spec, void *handle) { SDL_assert(current_audio.impl.HasCaptureSupport); return add_audio_device(name, spec, handle, ¤t_audio.inputDevices, ¤t_audio.inputDeviceCount); } -static SDL_INLINE int -add_output_device(const char *name, SDL_AudioSpec *spec, void *handle) +static SDL_INLINE int add_output_device(const char *name, SDL_AudioSpec *spec, void *handle) { return add_audio_device(name, spec, handle, ¤t_audio.outputDevices, ¤t_audio.outputDeviceCount); } -static void -free_device_list(SDL_AudioDeviceItem **devices, int *devCount) +static void free_device_list(SDL_AudioDeviceItem **devices, int *devCount) { SDL_AudioDeviceItem *item, *next; for (item = *devices; item != NULL; item = next) { @@ -464,10 +438,8 @@ free_device_list(SDL_AudioDeviceItem **devices, int *devCount) *devCount = 0; } - /* The audio backends call this when a new device is plugged in. */ -void -SDL_AddAudioDevice(const SDL_bool iscapture, const char *name, SDL_AudioSpec *spec, void *handle) +void SDL_AddAudioDevice(const SDL_bool iscapture, const char *name, SDL_AudioSpec *spec, void *handle) { const int device_index = iscapture ? add_capture_device(name, spec, handle) : add_output_device(name, spec, handle); if (device_index != -1) { @@ -489,11 +461,11 @@ void SDL_OpenedAudioDeviceDisconnected(SDL_AudioDevice *device) SDL_assert(get_audio_device(device->id) == device); if (!SDL_AtomicGet(&device->enabled)) { - return; /* don't report disconnects more than once. */ + return; /* don't report disconnects more than once. */ } if (SDL_AtomicGet(&device->shutdown)) { - return; /* don't report disconnect if we're trying to close device. */ + return; /* don't report disconnect if we're trying to close device. */ } /* Ends the audio callback and mark the device as STOPPED, but the @@ -513,8 +485,7 @@ void SDL_OpenedAudioDeviceDisconnected(SDL_AudioDevice *device) } } -static void -mark_device_removed(void *handle, SDL_AudioDeviceItem *devices, SDL_bool *removedFlag) +static void mark_device_removed(void *handle, SDL_AudioDeviceItem *devices, SDL_bool *removedFlag) { SDL_AudioDeviceItem *item; SDL_assert(handle != NULL); @@ -528,8 +499,7 @@ mark_device_removed(void *handle, SDL_AudioDeviceItem *devices, SDL_bool *remove } /* The audio backends call this when a device is removed from the system. */ -void -SDL_RemoveAudioDevice(const SDL_bool iscapture, void *handle) +void SDL_RemoveAudioDevice(const SDL_bool iscapture, void *handle) { int device_index; SDL_AudioDevice *device = NULL; @@ -572,40 +542,36 @@ SDL_RemoveAudioDevice(const SDL_bool iscapture, void *handle) current_audio.impl.FreeDeviceHandle(handle); } - - /* buffer queueing support... */ -static void SDLCALL -SDL_BufferQueueDrainCallback(void *userdata, Uint8 *stream, int len) +static void SDLCALL SDL_BufferQueueDrainCallback(void *userdata, Uint8 *stream, int len) { /* this function always holds the mixer lock before being called. */ - SDL_AudioDevice *device = (SDL_AudioDevice *) userdata; + SDL_AudioDevice *device = (SDL_AudioDevice *)userdata; size_t dequeued; - SDL_assert(device != NULL); /* this shouldn't ever happen, right?! */ - SDL_assert(!device->iscapture); /* this shouldn't ever happen, right?! */ - SDL_assert(len >= 0); /* this shouldn't ever happen, right?! */ + SDL_assert(device != NULL); /* this shouldn't ever happen, right?! */ + SDL_assert(!device->iscapture); /* this shouldn't ever happen, right?! */ + SDL_assert(len >= 0); /* this shouldn't ever happen, right?! */ dequeued = SDL_ReadFromDataQueue(device->buffer_queue, stream, len); stream += dequeued; - len -= (int) dequeued; + len -= (int)dequeued; - if (len > 0) { /* fill any remaining space in the stream with silence. */ + if (len > 0) { /* fill any remaining space in the stream with silence. */ SDL_assert(SDL_CountDataQueue(device->buffer_queue) == 0); SDL_memset(stream, device->callbackspec.silence, len); } } -static void SDLCALL -SDL_BufferQueueFillCallback(void *userdata, Uint8 *stream, int len) +static void SDLCALL SDL_BufferQueueFillCallback(void *userdata, Uint8 *stream, int len) { /* this function always holds the mixer lock before being called. */ - SDL_AudioDevice *device = (SDL_AudioDevice *) userdata; + SDL_AudioDevice *device = (SDL_AudioDevice *)userdata; - SDL_assert(device != NULL); /* this shouldn't ever happen, right?! */ - SDL_assert(device->iscapture); /* this shouldn't ever happen, right?! */ - SDL_assert(len >= 0); /* this shouldn't ever happen, right?! */ + SDL_assert(device != NULL); /* this shouldn't ever happen, right?! */ + SDL_assert(device->iscapture); /* this shouldn't ever happen, right?! */ + SDL_assert(len >= 0); /* this shouldn't ever happen, right?! */ /* note that if this needs to allocate more space and run out of memory, we have no choice but to quietly drop the data and hope it works out @@ -613,14 +579,13 @@ SDL_BufferQueueFillCallback(void *userdata, Uint8 *stream, int len) SDL_WriteToDataQueue(device->buffer_queue, stream, len); } -int -SDL_QueueAudio(SDL_AudioDeviceID devid, const void *data, Uint32 len) +int SDL_QueueAudio(SDL_AudioDeviceID devid, const void *data, Uint32 len) { SDL_AudioDevice *device = get_audio_device(devid); int rc = 0; if (!device) { - return -1; /* get_audio_device() will have set the error state */ + return -1; /* get_audio_device() will have set the error state */ } else if (device->iscapture) { return SDL_SetError("This is a capture device, queueing not allowed"); } else if (device->callbackspec.callback != SDL_BufferQueueDrainCallback) { @@ -642,15 +607,15 @@ SDL_DequeueAudio(SDL_AudioDeviceID devid, void *data, Uint32 len) SDL_AudioDevice *device = get_audio_device(devid); Uint32 rc; - if ( (len == 0) || /* nothing to do? */ - (!device) || /* called with bogus device id */ - (!device->iscapture) || /* playback devices can't dequeue */ - (device->callbackspec.callback != SDL_BufferQueueFillCallback) ) { /* not set for queueing */ - return 0; /* just report zero bytes dequeued. */ + if ((len == 0) || /* nothing to do? */ + (!device) || /* called with bogus device id */ + (!device->iscapture) || /* playback devices can't dequeue */ + (device->callbackspec.callback != SDL_BufferQueueFillCallback)) { /* not set for queueing */ + return 0; /* just report zero bytes dequeued. */ } current_audio.impl.LockDevice(device); - rc = (Uint32) SDL_ReadFromDataQueue(device->buffer_queue, data, len); + rc = (Uint32)SDL_ReadFromDataQueue(device->buffer_queue, data, len); current_audio.impl.UnlockDevice(device); return rc; } @@ -667,23 +632,21 @@ SDL_GetQueuedAudioSize(SDL_AudioDeviceID devid) /* Nothing to do unless we're set up for queueing. */ if (device->callbackspec.callback == SDL_BufferQueueDrainCallback || - device->callbackspec.callback == SDL_BufferQueueFillCallback) - { + device->callbackspec.callback == SDL_BufferQueueFillCallback) { current_audio.impl.LockDevice(device); - retval = (Uint32) SDL_CountDataQueue(device->buffer_queue); + retval = (Uint32)SDL_CountDataQueue(device->buffer_queue); current_audio.impl.UnlockDevice(device); } return retval; } -void -SDL_ClearQueuedAudio(SDL_AudioDeviceID devid) +void SDL_ClearQueuedAudio(SDL_AudioDeviceID devid) { SDL_AudioDevice *device = get_audio_device(devid); if (!device) { - return; /* nothing to do. */ + return; /* nothing to do. */ } /* Blank out the device and release the mutex. Free it afterwards. */ @@ -695,12 +658,10 @@ SDL_ClearQueuedAudio(SDL_AudioDeviceID devid) current_audio.impl.UnlockDevice(device); } - /* The general mixing thread function */ -static int SDLCALL -SDL_RunAudio(void *devicep) +static int SDLCALL SDL_RunAudio(void *devicep) { - SDL_AudioDevice *device = (SDL_AudioDevice *) devicep; + SDL_AudioDevice *device = (SDL_AudioDevice *)devicep; void *udata = device->callbackspec.userdata; SDL_AudioCallback callback = device->callbackspec.callback; int data_len = 0; @@ -759,15 +720,15 @@ SDL_RunAudio(void *devicep) /* if this fails...oh well. We'll play silence here. */ SDL_AudioStreamPut(device->stream, data, data_len); - while (SDL_AudioStreamAvailable(device->stream) >= ((int) device->spec.size)) { + while (SDL_AudioStreamAvailable(device->stream) >= ((int)device->spec.size)) { int got; data = SDL_AtomicGet(&device->enabled) ? current_audio.impl.GetDeviceBuf(device) : NULL; got = SDL_AudioStreamGet(device->stream, data ? data : device->work_buffer, device->spec.size); SDL_assert((got <= 0) || (got == device->spec.size)); - if (data == NULL) { /* device is having issues... */ + if (data == NULL) { /* device is having issues... */ const Uint32 delay = ((device->spec.samples * 1000) / device->spec.freq); - SDL_Delay(delay); /* wait for as long as this buffer would have played. Maybe device recovers later? */ + SDL_Delay(delay); /* wait for as long as this buffer would have played. Maybe device recovers later? */ } else { if (got != device->spec.size) { SDL_memset(data, device->spec.silence, device->spec.size); @@ -780,7 +741,7 @@ SDL_RunAudio(void *devicep) /* nothing to do; pause like we queued a buffer to play. */ const Uint32 delay = ((device->spec.samples * 1000) / device->spec.freq); SDL_Delay(delay); - } else { /* writing directly to the device. */ + } else { /* writing directly to the device. */ /* queue this buffer and wait for it to finish playing. */ current_audio.impl.PlayDevice(device); current_audio.impl.WaitDevice(device); @@ -797,11 +758,10 @@ SDL_RunAudio(void *devicep) /* !!! FIXME: this needs to deal with device spec changes. */ /* The general capture thread function */ -static int SDLCALL -SDL_CaptureAudio(void *devicep) +static int SDLCALL SDL_CaptureAudio(void *devicep) { - SDL_AudioDevice *device = (SDL_AudioDevice *) devicep; - const int silence = (int) device->spec.silence; + SDL_AudioDevice *device = (SDL_AudioDevice *)devicep; + const int silence = (int)device->spec.silence; const Uint32 delay = ((device->spec.samples * 1000) / device->spec.freq); const int data_len = device->spec.size; Uint8 *data; @@ -831,11 +791,11 @@ SDL_CaptureAudio(void *devicep) Uint8 *ptr; if (SDL_AtomicGet(&device->paused)) { - SDL_Delay(delay); /* just so we don't cook the CPU. */ + SDL_Delay(delay); /* just so we don't cook the CPU. */ if (device->stream) { SDL_AudioStreamClear(device->stream); } - current_audio.impl.FlushCapture(device); /* dump anything pending. */ + current_audio.impl.FlushCapture(device); /* dump anything pending. */ continue; } @@ -853,15 +813,15 @@ SDL_CaptureAudio(void *devicep) But we don't process it further or call the app's callback. */ if (!SDL_AtomicGet(&device->enabled)) { - SDL_Delay(delay); /* try to keep callback firing at normal pace. */ + SDL_Delay(delay); /* try to keep callback firing at normal pace. */ } else { while (still_need > 0) { const int rc = current_audio.impl.CaptureFromDevice(device, ptr, still_need); - SDL_assert(rc <= still_need); /* device should not overflow buffer. :) */ + SDL_assert(rc <= still_need); /* device should not overflow buffer. :) */ if (rc > 0) { still_need -= rc; ptr += rc; - } else { /* uhoh, device failed for some reason! */ + } else { /* uhoh, device failed for some reason! */ SDL_OpenedAudioDeviceDisconnected(device); break; } @@ -877,7 +837,7 @@ SDL_CaptureAudio(void *devicep) /* if this fails...oh well. */ SDL_AudioStreamPut(device->stream, data, data_len); - while (SDL_AudioStreamAvailable(device->stream) >= ((int) device->callbackspec.size)) { + while (SDL_AudioStreamAvailable(device->stream) >= ((int)device->callbackspec.size)) { const int got = SDL_AudioStreamGet(device->stream, device->work_buffer, device->callbackspec.size); SDL_assert((got < 0) || (got == device->callbackspec.size)); if (got != device->callbackspec.size) { @@ -891,7 +851,7 @@ SDL_CaptureAudio(void *devicep) } SDL_UnlockMutex(device->mixer_lock); } - } else { /* feeding user callback directly without streaming. */ + } else { /* feeding user callback directly without streaming. */ /* !!! FIXME: this should be LockDevice. */ SDL_LockMutex(device->mixer_lock); if (!SDL_AtomicGet(&device->paused)) { @@ -908,11 +868,11 @@ SDL_CaptureAudio(void *devicep) return 0; } - -static SDL_AudioFormat -SDL_ParseAudioFormat(const char *string) +static SDL_AudioFormat SDL_ParseAudioFormat(const char *string) { -#define CHECK_FMT_STRING(x) if (SDL_strcmp(string, #x) == 0) return AUDIO_##x +#define CHECK_FMT_STRING(x) \ + if (SDL_strcmp(string, #x) == 0) \ + return AUDIO_##x CHECK_FMT_STRING(U8); CHECK_FMT_STRING(S8); CHECK_FMT_STRING(U16LSB); @@ -935,8 +895,7 @@ SDL_ParseAudioFormat(const char *string) return 0; } -int -SDL_GetNumAudioDrivers(void) +int SDL_GetNumAudioDrivers(void) { return SDL_arraysize(bootstrap) - 1; } @@ -950,14 +909,13 @@ SDL_GetAudioDriver(int index) return NULL; } -int -SDL_AudioInit(const char *driver_name) +int SDL_AudioInit(const char *driver_name) { int i; SDL_bool initialized = SDL_FALSE, tried_to_init = SDL_FALSE; if (SDL_GetCurrentAudioDriver()) { - SDL_AudioQuit(); /* shutdown driver if already running. */ + SDL_AudioQuit(); /* shutdown driver if already running. */ } SDL_zeroa(open_devices); @@ -1030,7 +988,7 @@ SDL_AudioInit(const char *driver_name) } SDL_zero(current_audio); - return -1; /* No driver was available, so fail. */ + return -1; /* No driver was available, so fail. */ } current_audio.detectionLock = SDL_CreateMutex(); @@ -1057,8 +1015,7 @@ SDL_GetCurrentAudioDriver() } /* Clean out devices that we've removed but had to keep around for stability. */ -static void -clean_out_device_list(SDL_AudioDeviceItem **devices, int *devCount, SDL_bool *removedFlag) +static void clean_out_device_list(SDL_AudioDeviceItem **devices, int *devCount, SDL_bool *removedFlag) { SDL_AudioDeviceItem *item = *devices; SDL_AudioDeviceItem *prev = NULL; @@ -1089,9 +1046,7 @@ clean_out_device_list(SDL_AudioDeviceItem **devices, int *devCount, SDL_bool *re *removedFlag = SDL_FALSE; } - -int -SDL_GetNumAudioDevices(int iscapture) +int SDL_GetNumAudioDevices(int iscapture) { int retval = 0; @@ -1114,7 +1069,6 @@ SDL_GetNumAudioDevices(int iscapture) return retval; } - const char * SDL_GetAudioDeviceName(int index, int iscapture) { @@ -1145,9 +1099,7 @@ SDL_GetAudioDeviceName(int index, int iscapture) return retval; } - -int -SDL_GetAudioDeviceSpec(int index, int iscapture, SDL_AudioSpec *spec) +int SDL_GetAudioDeviceSpec(int index, int iscapture, SDL_AudioSpec *spec) { SDL_AudioDeviceItem *item; int i, retval; @@ -1178,9 +1130,7 @@ SDL_GetAudioDeviceSpec(int index, int iscapture, SDL_AudioSpec *spec) return retval; } - -int -SDL_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) +int SDL_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) { if (spec == NULL) { return SDL_InvalidParamError("spec"); @@ -1196,9 +1146,7 @@ SDL_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) return current_audio.impl.GetDefaultAudioInfo(name, spec, iscapture); } - -static void -close_audio_device(SDL_AudioDevice * device) +static void close_audio_device(SDL_AudioDevice *device) { if (!device) { return; @@ -1239,34 +1187,32 @@ close_audio_device(SDL_AudioDevice * device) SDL_free(device); } - /* * Sanity check desired AudioSpec for SDL_OpenAudio() in (orig). * Fills in a sanitized copy in (prepared). * Returns non-zero if okay, zero on fatal parameters in (orig). */ -static int -prepare_audiospec(const SDL_AudioSpec * orig, SDL_AudioSpec * prepared) +static int prepare_audiospec(const SDL_AudioSpec *orig, SDL_AudioSpec *prepared) { SDL_copyp(prepared, orig); if (orig->freq == 0) { const char *env = SDL_getenv("SDL_AUDIO_FREQUENCY"); if ((!env) || ((prepared->freq = SDL_atoi(env)) == 0)) { - prepared->freq = 22050; /* a reasonable default */ + prepared->freq = 22050; /* a reasonable default */ } } if (orig->format == 0) { const char *env = SDL_getenv("SDL_AUDIO_FORMAT"); if ((!env) || ((prepared->format = SDL_ParseAudioFormat(env)) == 0)) { - prepared->format = AUDIO_S16; /* a reasonable default */ + prepared->format = AUDIO_S16; /* a reasonable default */ } } if (orig->channels == 0) { const char *env = SDL_getenv("SDL_AUDIO_CHANNELS"); - if ((!env) || ((prepared->channels = (Uint8) SDL_atoi(env)) == 0)) { + if ((!env) || ((prepared->channels = (Uint8)SDL_atoi(env)) == 0)) { prepared->channels = 2; /* a reasonable default */ } } else if (orig->channels > 8) { @@ -1276,7 +1222,7 @@ prepare_audiospec(const SDL_AudioSpec * orig, SDL_AudioSpec * prepared) if (orig->samples == 0) { const char *env = SDL_getenv("SDL_AUDIO_SAMPLES"); - if ((!env) || ((prepared->samples = (Uint16) SDL_atoi(env)) == 0)) { + if ((!env) || ((prepared->samples = (Uint16)SDL_atoi(env)) == 0)) { /* Pick a default of ~46 ms at desired frequency */ /* !!! FIXME: remove this when the non-Po2 resampling is in. */ const int samples = (prepared->freq / 1000) * 46; @@ -1294,10 +1240,9 @@ prepare_audiospec(const SDL_AudioSpec * orig, SDL_AudioSpec * prepared) return 1; } -static SDL_AudioDeviceID -open_audio_device(const char *devname, int iscapture, - const SDL_AudioSpec * desired, SDL_AudioSpec * obtained, - int allowed_changes, int min_id) +static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture, + const SDL_AudioSpec *desired, SDL_AudioSpec *obtained, + int allowed_changes, int min_id) { const SDL_bool is_internal_thread = (desired->callback == NULL); SDL_AudioDeviceID id = 0; @@ -1409,7 +1354,7 @@ open_audio_device(const char *devname, int iscapture, } } - device = (SDL_AudioDevice *) SDL_calloc(1, sizeof (SDL_AudioDevice)); + device = (SDL_AudioDevice *)SDL_calloc(1, sizeof(SDL_AudioDevice)); if (device == NULL) { SDL_OutOfMemory(); SDL_UnlockMutex(current_audio.detectionLock); @@ -1420,7 +1365,7 @@ open_audio_device(const char *devname, int iscapture, device->iscapture = iscapture ? SDL_TRUE : SDL_FALSE; device->handle = handle; - SDL_AtomicSet(&device->shutdown, 0); /* just in case. */ + SDL_AtomicSet(&device->shutdown, 0); /* just in case. */ SDL_AtomicSet(&device->paused, 1); SDL_AtomicSet(&device->enabled, 1); @@ -1483,19 +1428,19 @@ open_audio_device(const char *devname, int iscapture, } } - SDL_CalculateAudioSpec(obtained); /* recalc after possible changes. */ + SDL_CalculateAudioSpec(obtained); /* recalc after possible changes. */ device->callbackspec = *obtained; if (build_stream) { if (iscapture) { device->stream = SDL_NewAudioStream(device->spec.format, - device->spec.channels, device->spec.freq, - obtained->format, obtained->channels, obtained->freq); + device->spec.channels, device->spec.freq, + obtained->format, obtained->channels, obtained->freq); } else { device->stream = SDL_NewAudioStream(obtained->format, obtained->channels, - obtained->freq, device->spec.format, - device->spec.channels, device->spec.freq); + obtained->freq, device->spec.format, + device->spec.channels, device->spec.freq); } if (!device->stream) { @@ -1505,7 +1450,7 @@ open_audio_device(const char *devname, int iscapture, } } - if (device->spec.callback == NULL) { /* use buffer queueing? */ + if (device->spec.callback == NULL) { /* use buffer queueing? */ /* pool a few packets to start. Enough for two callbacks. */ device->buffer_queue = SDL_NewDataQueue(SDL_AUDIOBUFFERQUEUE_PACKETLEN, obtained->size * 2); if (!device->buffer_queue) { @@ -1525,7 +1470,7 @@ open_audio_device(const char *devname, int iscapture, } SDL_assert(device->work_buffer_len > 0); - device->work_buffer = (Uint8 *) SDL_malloc(device->work_buffer_len); + device->work_buffer = (Uint8 *)SDL_malloc(device->work_buffer_len); if (device->work_buffer == NULL) { close_audio_device(device); SDL_UnlockMutex(current_audio.detectionLock); @@ -1533,7 +1478,7 @@ open_audio_device(const char *devname, int iscapture, return 0; } - open_devices[id] = device; /* add it to our list of open devices. */ + open_devices[id] = device; /* add it to our list of open devices. */ /* Start the audio thread if necessary */ if (!current_audio.impl.ProvidesOwnCallbackThread) { @@ -1543,7 +1488,7 @@ open_audio_device(const char *devname, int iscapture, const size_t stacksize = is_internal_thread ? 64 * 1024 : 0; char threadname[64]; - SDL_snprintf(threadname, sizeof (threadname), "SDLAudio%c%d", (iscapture) ? 'C' : 'P', (int) device->id); + SDL_snprintf(threadname, sizeof(threadname), "SDLAudio%c%d", (iscapture) ? 'C' : 'P', (int)device->id); device->thread = SDL_CreateThreadInternal(iscapture ? SDL_CaptureAudio : SDL_RunAudio, threadname, stacksize, device); if (device->thread == NULL) { @@ -1558,9 +1503,7 @@ open_audio_device(const char *devname, int iscapture, return device->id; } - -int -SDL_OpenAudio(SDL_AudioSpec * desired, SDL_AudioSpec * obtained) +int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained) { SDL_AudioDeviceID id = 0; @@ -1596,7 +1539,7 @@ SDL_OpenAudio(SDL_AudioSpec * desired, SDL_AudioSpec * obtained) SDL_AudioDeviceID SDL_OpenAudioDevice(const char *device, int iscapture, - const SDL_AudioSpec * desired, SDL_AudioSpec * obtained, + const SDL_AudioSpec *desired, SDL_AudioSpec *obtained, int allowed_changes) { return open_audio_device(device, iscapture, desired, obtained, @@ -1618,15 +1561,13 @@ SDL_GetAudioDeviceStatus(SDL_AudioDeviceID devid) return status; } - SDL_AudioStatus SDL_GetAudioStatus(void) { return SDL_GetAudioDeviceStatus(1); } -void -SDL_PauseAudioDevice(SDL_AudioDeviceID devid, int pause_on) +void SDL_PauseAudioDevice(SDL_AudioDeviceID devid, int pause_on) { SDL_AudioDevice *device = get_audio_device(devid); if (device) { @@ -1636,15 +1577,12 @@ SDL_PauseAudioDevice(SDL_AudioDeviceID devid, int pause_on) } } -void -SDL_PauseAudio(int pause_on) +void SDL_PauseAudio(int pause_on) { SDL_PauseAudioDevice(1, pause_on); } - -void -SDL_LockAudioDevice(SDL_AudioDeviceID devid) +void SDL_LockAudioDevice(SDL_AudioDeviceID devid) { /* Obtain a lock on the mixing buffers */ SDL_AudioDevice *device = get_audio_device(devid); @@ -1653,14 +1591,12 @@ SDL_LockAudioDevice(SDL_AudioDeviceID devid) } } -void -SDL_LockAudio(void) +void SDL_LockAudio(void) { SDL_LockAudioDevice(1); } -void -SDL_UnlockAudioDevice(SDL_AudioDeviceID devid) +void SDL_UnlockAudioDevice(SDL_AudioDeviceID devid) { /* Obtain a lock on the mixing buffers */ SDL_AudioDevice *device = get_audio_device(devid); @@ -1669,30 +1605,26 @@ SDL_UnlockAudioDevice(SDL_AudioDeviceID devid) } } -void -SDL_UnlockAudio(void) +void SDL_UnlockAudio(void) { SDL_UnlockAudioDevice(1); } -void -SDL_CloseAudioDevice(SDL_AudioDeviceID devid) +void SDL_CloseAudioDevice(SDL_AudioDeviceID devid) { close_audio_device(get_audio_device(devid)); } -void -SDL_CloseAudio(void) +void SDL_CloseAudio(void) { SDL_CloseAudioDevice(1); } -void -SDL_AudioQuit(void) +void SDL_AudioQuit(void) { SDL_AudioDeviceID i; - if (!current_audio.name) { /* not initialized?! */ + if (!current_audio.name) { /* not initialized?! */ return; } @@ -1720,26 +1652,26 @@ SDL_AudioQuit(void) static int format_idx; static int format_idx_sub; static SDL_AudioFormat format_list[NUM_FORMATS][NUM_FORMATS] = { - {AUDIO_U8, AUDIO_S8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, - AUDIO_U16MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB}, - {AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, - AUDIO_U16MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB}, - {AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S32LSB, - AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8}, - {AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S32MSB, - AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_U8, AUDIO_S8}, - {AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S32LSB, - AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8}, - {AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_S32MSB, - AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_U8, AUDIO_S8}, - {AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_S16LSB, - AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, AUDIO_S8}, - {AUDIO_S32MSB, AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_S16MSB, - AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8}, - {AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S16LSB, - AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, AUDIO_S8}, - {AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_S32MSB, AUDIO_S32LSB, AUDIO_S16MSB, - AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8}, + { AUDIO_U8, AUDIO_S8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, + AUDIO_U16MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB }, + { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, + AUDIO_U16MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB }, + { AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S32LSB, + AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8 }, + { AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S32MSB, + AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_U8, AUDIO_S8 }, + { AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S32LSB, + AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8 }, + { AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_S32MSB, + AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_U8, AUDIO_S8 }, + { AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_S16LSB, + AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, AUDIO_S8 }, + { AUDIO_S32MSB, AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_S16MSB, + AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8 }, + { AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S16LSB, + AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, AUDIO_S8 }, + { AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_S32MSB, AUDIO_S32LSB, AUDIO_S16MSB, + AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8 }, }; SDL_AudioFormat @@ -1763,26 +1695,25 @@ SDL_NextAudioFormat(void) return format_list[format_idx][format_idx_sub++]; } -Uint8 -SDL_SilenceValueForFormat(const SDL_AudioFormat format) +Uint8 SDL_SilenceValueForFormat(const SDL_AudioFormat format) { switch (format) { - /* !!! FIXME: 0x80 isn't perfect for U16, but we can't fit 0x8000 in a - !!! FIXME: byte for SDL_memset() use. This is actually 0.1953 percent - !!! FIXME: off from silence. Maybe just don't use U16. */ - case AUDIO_U16LSB: - case AUDIO_U16MSB: - case AUDIO_U8: - return 0x80; + /* !!! FIXME: 0x80 isn't perfect for U16, but we can't fit 0x8000 in a + !!! FIXME: byte for SDL_memset() use. This is actually 0.1953 percent + !!! FIXME: off from silence. Maybe just don't use U16. */ + case AUDIO_U16LSB: + case AUDIO_U16MSB: + case AUDIO_U8: + return 0x80; - default: break; - } + default: + break; + } return 0x00; } -void -SDL_CalculateAudioSpec(SDL_AudioSpec * spec) +void SDL_CalculateAudioSpec(SDL_AudioSpec *spec) { spec->silence = SDL_SilenceValueForFormat(spec->format); spec->size = SDL_AUDIO_BITSIZE(spec->format) / 8; @@ -1790,13 +1721,11 @@ SDL_CalculateAudioSpec(SDL_AudioSpec * spec) spec->size *= spec->samples; } - /* * Moved here from SDL_mixer.c, since it relies on internals of an opened * audio device (and is deprecated, by the way!). */ -void -SDL_MixAudio(Uint8 * dst, const Uint8 * src, Uint32 len, int volume) +void SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume) { /* Mix the user-level audio format */ SDL_AudioDevice *device = get_audio_device(1); diff --git a/src/audio/SDL_audio_c.h b/src/audio/SDL_audio_c.h index a976dfd09..c21674ac3 100644 --- a/src/audio/SDL_audio_c.h +++ b/src/audio/SDL_audio_c.h @@ -40,11 +40,11 @@ #include "samplerate.h" extern SDL_bool SRC_available; extern int SRC_converter; -extern SRC_STATE* (*SRC_src_new)(int converter_type, int channels, int *error); +extern SRC_STATE *(*SRC_src_new)(int converter_type, int channels, int *error); extern int (*SRC_src_process)(SRC_STATE *state, SRC_DATA *data); extern int (*SRC_src_reset)(SRC_STATE *state); -extern SRC_STATE* (*SRC_src_delete)(SRC_STATE *state); -extern const char* (*SRC_src_strerror)(int error); +extern SRC_STATE *(*SRC_src_delete)(SRC_STATE *state); +extern const char *(*SRC_src_strerror)(int error); extern int (*SRC_src_simple)(SRC_DATA *data, int converter_type, int channels); #endif @@ -54,7 +54,7 @@ extern SDL_AudioFormat SDL_NextAudioFormat(void); /* Function to calculate the size and silence for a SDL_AudioSpec */ extern Uint8 SDL_SilenceValueForFormat(const SDL_AudioFormat format); -extern void SDL_CalculateAudioSpec(SDL_AudioSpec * spec); +extern void SDL_CalculateAudioSpec(SDL_AudioSpec *spec); /* Choose the audio filter functions below */ extern void SDL_ChooseAudioConverters(void); diff --git a/src/audio/SDL_audio_channel_converters.h b/src/audio/SDL_audio_channel_converters.h index fea9ad1e1..8b35f3696 100644 --- a/src/audio/SDL_audio_channel_converters.h +++ b/src/audio/SDL_audio_channel_converters.h @@ -21,18 +21,17 @@ /* DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_channel_conversion.c */ -static void SDLCALL -SDL_ConvertMonoToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertMonoToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 2))) - 2; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 2))) - 2; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; int i; LOG_DEBUG_CONVERT("mono", "stereo"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 1); i; i--, src -= 1, dst -= 2) { + for (i = cvt->len_cvt / (sizeof(float) * 1); i; i--, src -= 1, dst -= 2) { const float srcFC = src[0]; dst[1] /* FR */ = srcFC; dst[0] /* FL */ = srcFC; @@ -40,22 +39,21 @@ SDL_ConvertMonoToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = cvt->len_cvt * 2; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertMonoTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertMonoTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 3))) - 3; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 3))) - 3; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; int i; LOG_DEBUG_CONVERT("mono", "2.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 1); i; i--, src -= 1, dst -= 3) { + for (i = cvt->len_cvt / (sizeof(float) * 1); i; i--, src -= 1, dst -= 3) { const float srcFC = src[0]; dst[2] /* LFE */ = 0.0f; dst[1] /* FR */ = srcFC; @@ -64,22 +62,21 @@ SDL_ConvertMonoTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = cvt->len_cvt * 3; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertMonoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertMonoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 4))) - 4; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 4))) - 4; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; int i; LOG_DEBUG_CONVERT("mono", "quad"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 1); i; i--, src -= 1, dst -= 4) { + for (i = cvt->len_cvt / (sizeof(float) * 1); i; i--, src -= 1, dst -= 4) { const float srcFC = src[0]; dst[3] /* BR */ = 0.0f; dst[2] /* BL */ = 0.0f; @@ -89,22 +86,21 @@ SDL_ConvertMonoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = cvt->len_cvt * 4; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertMonoTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertMonoTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 5))) - 5; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 5))) - 5; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; int i; LOG_DEBUG_CONVERT("mono", "4.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 1); i; i--, src -= 1, dst -= 5) { + for (i = cvt->len_cvt / (sizeof(float) * 1); i; i--, src -= 1, dst -= 5) { const float srcFC = src[0]; dst[4] /* BR */ = 0.0f; dst[3] /* BL */ = 0.0f; @@ -115,22 +111,21 @@ SDL_ConvertMonoTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = cvt->len_cvt * 5; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertMonoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertMonoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 6))) - 6; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 6))) - 6; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; int i; LOG_DEBUG_CONVERT("mono", "5.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 1); i; i--, src -= 1, dst -= 6) { + for (i = cvt->len_cvt / (sizeof(float) * 1); i; i--, src -= 1, dst -= 6) { const float srcFC = src[0]; dst[5] /* BR */ = 0.0f; dst[4] /* BL */ = 0.0f; @@ -142,22 +137,21 @@ SDL_ConvertMonoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = cvt->len_cvt * 6; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertMonoTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertMonoTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 7))) - 7; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 7))) - 7; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; int i; LOG_DEBUG_CONVERT("mono", "6.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 1); i; i--, src -= 1, dst -= 7) { + for (i = cvt->len_cvt / (sizeof(float) * 1); i; i--, src -= 1, dst -= 7) { const float srcFC = src[0]; dst[6] /* SR */ = 0.0f; dst[5] /* SL */ = 0.0f; @@ -170,22 +164,21 @@ SDL_ConvertMonoTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = cvt->len_cvt * 7; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertMonoTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertMonoTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 8))) - 8; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 8))) - 8; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; int i; LOG_DEBUG_CONVERT("mono", "7.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 1); i; i--, src -= 1, dst -= 8) { + for (i = cvt->len_cvt / (sizeof(float) * 1); i; i--, src -= 1, dst -= 8) { const float srcFC = src[0]; dst[7] /* SR */ = 0.0f; dst[6] /* SL */ = 0.0f; @@ -199,42 +192,40 @@ SDL_ConvertMonoTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = cvt->len_cvt * 8; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertStereoToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertStereoToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("stereo", "mono"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 2); i; i--, src += 2, dst += 1) { + for (i = cvt->len_cvt / (sizeof(float) * 2); i; i--, src += 2, dst += 1) { dst[0] /* FC */ = (src[0] * 0.500000000f) + (src[1] * 0.500000000f); } cvt->len_cvt = cvt->len_cvt / 2; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertStereoTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertStereoTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 2) * 3))) - 3; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 2; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 2) * 3))) - 3; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 2; int i; LOG_DEBUG_CONVERT("stereo", "2.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 2); i; i--, src -= 2, dst -= 3) { + for (i = cvt->len_cvt / (sizeof(float) * 2); i; i--, src -= 2, dst -= 3) { dst[2] /* LFE */ = 0.0f; dst[1] /* FR */ = src[1]; dst[0] /* FL */ = src[0]; @@ -242,22 +233,21 @@ SDL_ConvertStereoTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 2) * 3; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertStereoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertStereoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 2) * 4))) - 4; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 2; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 2) * 4))) - 4; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 2; int i; LOG_DEBUG_CONVERT("stereo", "quad"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 2); i; i--, src -= 2, dst -= 4) { + for (i = cvt->len_cvt / (sizeof(float) * 2); i; i--, src -= 2, dst -= 4) { dst[3] /* BR */ = 0.0f; dst[2] /* BL */ = 0.0f; dst[1] /* FR */ = src[1]; @@ -266,22 +256,21 @@ SDL_ConvertStereoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 2) * 4; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertStereoTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertStereoTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 2) * 5))) - 5; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 2; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 2) * 5))) - 5; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 2; int i; LOG_DEBUG_CONVERT("stereo", "4.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 2); i; i--, src -= 2, dst -= 5) { + for (i = cvt->len_cvt / (sizeof(float) * 2); i; i--, src -= 2, dst -= 5) { dst[4] /* BR */ = 0.0f; dst[3] /* BL */ = 0.0f; dst[2] /* LFE */ = 0.0f; @@ -291,22 +280,21 @@ SDL_ConvertStereoTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 2) * 5; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertStereoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertStereoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 2) * 6))) - 6; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 2; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 2) * 6))) - 6; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 2; int i; LOG_DEBUG_CONVERT("stereo", "5.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 2); i; i--, src -= 2, dst -= 6) { + for (i = cvt->len_cvt / (sizeof(float) * 2); i; i--, src -= 2, dst -= 6) { dst[5] /* BR */ = 0.0f; dst[4] /* BL */ = 0.0f; dst[3] /* LFE */ = 0.0f; @@ -317,22 +305,21 @@ SDL_ConvertStereoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 2) * 6; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertStereoTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertStereoTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 2) * 7))) - 7; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 2; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 2) * 7))) - 7; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 2; int i; LOG_DEBUG_CONVERT("stereo", "6.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 2); i; i--, src -= 2, dst -= 7) { + for (i = cvt->len_cvt / (sizeof(float) * 2); i; i--, src -= 2, dst -= 7) { dst[6] /* SR */ = 0.0f; dst[5] /* SL */ = 0.0f; dst[4] /* BC */ = 0.0f; @@ -344,22 +331,21 @@ SDL_ConvertStereoTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 2) * 7; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertStereoTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertStereoTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 2) * 8))) - 8; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 2; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 2) * 8))) - 8; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 2; int i; LOG_DEBUG_CONVERT("stereo", "7.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 2); i; i--, src -= 2, dst -= 8) { + for (i = cvt->len_cvt / (sizeof(float) * 2); i; i--, src -= 2, dst -= 8) { dst[7] /* SR */ = 0.0f; dst[6] /* SL */ = 0.0f; dst[5] /* BR */ = 0.0f; @@ -372,41 +358,39 @@ SDL_ConvertStereoTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 2) * 8; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert21ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert21ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("2.1", "mono"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 3); i; i--, src += 3, dst += 1) { + for (i = cvt->len_cvt / (sizeof(float) * 3); i; i--, src += 3, dst += 1) { dst[0] /* FC */ = (src[0] * 0.333333343f) + (src[1] * 0.333333343f) + (src[2] * 0.333333343f); } cvt->len_cvt = cvt->len_cvt / 3; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert21ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert21ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("2.1", "stereo"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 3); i; i--, src += 3, dst += 2) { + for (i = cvt->len_cvt / (sizeof(float) * 3); i; i--, src += 3, dst += 2) { const float srcLFE = src[2]; dst[0] /* FL */ = (src[0] * 0.800000012f) + (srcLFE * 0.200000003f); dst[1] /* FR */ = (src[1] * 0.800000012f) + (srcLFE * 0.200000003f); @@ -414,22 +398,21 @@ SDL_Convert21ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 3) * 2; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert21ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert21ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 3) * 4))) - 4; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 3; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 3) * 4))) - 4; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 3; int i; LOG_DEBUG_CONVERT("2.1", "quad"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 3); i; i--, src -= 3, dst -= 4) { + for (i = cvt->len_cvt / (sizeof(float) * 3); i; i--, src -= 3, dst -= 4) { const float srcLFE = src[2]; dst[3] /* BR */ = (srcLFE * 0.111111112f); dst[2] /* BL */ = (srcLFE * 0.111111112f); @@ -439,22 +422,21 @@ SDL_Convert21ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 3) * 4; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert21To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert21To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 3) * 5))) - 5; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 3; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 3) * 5))) - 5; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 3; int i; LOG_DEBUG_CONVERT("2.1", "4.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 3); i; i--, src -= 3, dst -= 5) { + for (i = cvt->len_cvt / (sizeof(float) * 3); i; i--, src -= 3, dst -= 5) { dst[4] /* BR */ = 0.0f; dst[3] /* BL */ = 0.0f; dst[2] /* LFE */ = src[2]; @@ -464,22 +446,21 @@ SDL_Convert21To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 3) * 5; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert21To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert21To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 3) * 6))) - 6; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 3; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 3) * 6))) - 6; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 3; int i; LOG_DEBUG_CONVERT("2.1", "5.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 3); i; i--, src -= 3, dst -= 6) { + for (i = cvt->len_cvt / (sizeof(float) * 3); i; i--, src -= 3, dst -= 6) { dst[5] /* BR */ = 0.0f; dst[4] /* BL */ = 0.0f; dst[3] /* LFE */ = src[2]; @@ -490,22 +471,21 @@ SDL_Convert21To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 3) * 6; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert21To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert21To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 3) * 7))) - 7; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 3; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 3) * 7))) - 7; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 3; int i; LOG_DEBUG_CONVERT("2.1", "6.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 3); i; i--, src -= 3, dst -= 7) { + for (i = cvt->len_cvt / (sizeof(float) * 3); i; i--, src -= 3, dst -= 7) { dst[6] /* SR */ = 0.0f; dst[5] /* SL */ = 0.0f; dst[4] /* BC */ = 0.0f; @@ -517,22 +497,21 @@ SDL_Convert21To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 3) * 7; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert21To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert21To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 3) * 8))) - 8; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 3; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 3) * 8))) - 8; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 3; int i; LOG_DEBUG_CONVERT("2.1", "7.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 3); i; i--, src -= 3, dst -= 8) { + for (i = cvt->len_cvt / (sizeof(float) * 3); i; i--, src -= 3, dst -= 8) { dst[7] /* SR */ = 0.0f; dst[6] /* SL */ = 0.0f; dst[5] /* BR */ = 0.0f; @@ -545,41 +524,39 @@ SDL_Convert21To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 3) * 8; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertQuadToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertQuadToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("quad", "mono"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 4); i; i--, src += 4, dst += 1) { + for (i = cvt->len_cvt / (sizeof(float) * 4); i; i--, src += 4, dst += 1) { dst[0] /* FC */ = (src[0] * 0.250000000f) + (src[1] * 0.250000000f) + (src[2] * 0.250000000f) + (src[3] * 0.250000000f); } cvt->len_cvt = cvt->len_cvt / 4; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertQuadToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertQuadToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("quad", "stereo"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 4); i; i--, src += 4, dst += 2) { + for (i = cvt->len_cvt / (sizeof(float) * 4); i; i--, src += 4, dst += 2) { const float srcBL = src[2]; const float srcBR = src[3]; dst[0] /* FL */ = (src[0] * 0.421000004f) + (srcBL * 0.358999997f) + (srcBR * 0.219999999f); @@ -588,21 +565,20 @@ SDL_ConvertQuadToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 4) * 2; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertQuadTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertQuadTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("quad", "2.1"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 4); i; i--, src += 4, dst += 3) { + for (i = cvt->len_cvt / (sizeof(float) * 4); i; i--, src += 4, dst += 3) { const float srcBL = src[2]; const float srcBR = src[3]; dst[0] /* FL */ = (src[0] * 0.421000004f) + (srcBL * 0.358999997f) + (srcBR * 0.219999999f); @@ -612,22 +588,21 @@ SDL_ConvertQuadTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 4) * 3; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertQuadTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertQuadTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 4) * 5))) - 5; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 4; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 4) * 5))) - 5; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 4; int i; LOG_DEBUG_CONVERT("quad", "4.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 4); i; i--, src -= 4, dst -= 5) { + for (i = cvt->len_cvt / (sizeof(float) * 4); i; i--, src -= 4, dst -= 5) { dst[4] /* BR */ = src[3]; dst[3] /* BL */ = src[2]; dst[2] /* LFE */ = 0.0f; @@ -637,22 +612,21 @@ SDL_ConvertQuadTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 4) * 5; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertQuadTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertQuadTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 4) * 6))) - 6; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 4; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 4) * 6))) - 6; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 4; int i; LOG_DEBUG_CONVERT("quad", "5.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 4); i; i--, src -= 4, dst -= 6) { + for (i = cvt->len_cvt / (sizeof(float) * 4); i; i--, src -= 4, dst -= 6) { dst[5] /* BR */ = src[3]; dst[4] /* BL */ = src[2]; dst[3] /* LFE */ = 0.0f; @@ -663,22 +637,21 @@ SDL_ConvertQuadTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 4) * 6; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertQuadTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertQuadTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 4) * 7))) - 7; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 4; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 4) * 7))) - 7; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 4; int i; LOG_DEBUG_CONVERT("quad", "6.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 4); i; i--, src -= 4, dst -= 7) { + for (i = cvt->len_cvt / (sizeof(float) * 4); i; i--, src -= 4, dst -= 7) { const float srcBL = src[2]; const float srcBR = src[3]; dst[6] /* SR */ = (srcBR * 0.796000004f); @@ -692,22 +665,21 @@ SDL_ConvertQuadTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 4) * 7; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_ConvertQuadTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertQuadTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 4) * 8))) - 8; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 4; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 4) * 8))) - 8; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 4; int i; LOG_DEBUG_CONVERT("quad", "7.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 4); i; i--, src -= 4, dst -= 8) { + for (i = cvt->len_cvt / (sizeof(float) * 4); i; i--, src -= 4, dst -= 8) { dst[7] /* SR */ = 0.0f; dst[6] /* SL */ = 0.0f; dst[5] /* BR */ = src[3]; @@ -720,41 +692,39 @@ SDL_ConvertQuadTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 4) * 8; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert41ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert41ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("4.1", "mono"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 5); i; i--, src += 5, dst += 1) { + for (i = cvt->len_cvt / (sizeof(float) * 5); i; i--, src += 5, dst += 1) { dst[0] /* FC */ = (src[0] * 0.200000003f) + (src[1] * 0.200000003f) + (src[2] * 0.200000003f) + (src[3] * 0.200000003f) + (src[4] * 0.200000003f); } cvt->len_cvt = cvt->len_cvt / 5; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert41ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert41ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("4.1", "stereo"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 5); i; i--, src += 5, dst += 2) { + for (i = cvt->len_cvt / (sizeof(float) * 5); i; i--, src += 5, dst += 2) { const float srcLFE = src[2]; const float srcBL = src[3]; const float srcBR = src[4]; @@ -764,21 +734,20 @@ SDL_Convert41ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 5) * 2; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert41To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert41To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("4.1", "2.1"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 5); i; i--, src += 5, dst += 3) { + for (i = cvt->len_cvt / (sizeof(float) * 5); i; i--, src += 5, dst += 3) { const float srcBL = src[3]; const float srcBR = src[4]; dst[0] /* FL */ = (src[0] * 0.421000004f) + (srcBL * 0.358999997f) + (srcBR * 0.219999999f); @@ -788,21 +757,20 @@ SDL_Convert41To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 5) * 3; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert41ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert41ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("4.1", "quad"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 5); i; i--, src += 5, dst += 4) { + for (i = cvt->len_cvt / (sizeof(float) * 5); i; i--, src += 5, dst += 4) { const float srcLFE = src[2]; dst[0] /* FL */ = (src[0] * 0.941176474f) + (srcLFE * 0.058823530f); dst[1] /* FR */ = (src[1] * 0.941176474f) + (srcLFE * 0.058823530f); @@ -812,22 +780,21 @@ SDL_Convert41ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 5) * 4; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert41To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert41To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 5) * 6))) - 6; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 5; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 5) * 6))) - 6; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 5; int i; LOG_DEBUG_CONVERT("4.1", "5.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 5); i; i--, src -= 5, dst -= 6) { + for (i = cvt->len_cvt / (sizeof(float) * 5); i; i--, src -= 5, dst -= 6) { dst[5] /* BR */ = src[4]; dst[4] /* BL */ = src[3]; dst[3] /* LFE */ = src[2]; @@ -838,22 +805,21 @@ SDL_Convert41To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 5) * 6; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert41To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert41To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 5) * 7))) - 7; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 5; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 5) * 7))) - 7; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 5; int i; LOG_DEBUG_CONVERT("4.1", "6.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 5); i; i--, src -= 5, dst -= 7) { + for (i = cvt->len_cvt / (sizeof(float) * 5); i; i--, src -= 5, dst -= 7) { const float srcBL = src[3]; const float srcBR = src[4]; dst[6] /* SR */ = (srcBR * 0.796000004f); @@ -867,22 +833,21 @@ SDL_Convert41To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 5) * 7; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert41To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert41To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 5) * 8))) - 8; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 5; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 5) * 8))) - 8; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 5; int i; LOG_DEBUG_CONVERT("4.1", "7.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 5); i; i--, src -= 5, dst -= 8) { + for (i = cvt->len_cvt / (sizeof(float) * 5); i; i--, src -= 5, dst -= 8) { dst[7] /* SR */ = 0.0f; dst[6] /* SL */ = 0.0f; dst[5] /* BR */ = src[4]; @@ -895,41 +860,39 @@ SDL_Convert41To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 5) * 8; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert51ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert51ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("5.1", "mono"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 6); i; i--, src += 6, dst += 1) { + for (i = cvt->len_cvt / (sizeof(float) * 6); i; i--, src += 6, dst += 1) { dst[0] /* FC */ = (src[0] * 0.166666672f) + (src[1] * 0.166666672f) + (src[2] * 0.166666672f) + (src[3] * 0.166666672f) + (src[4] * 0.166666672f) + (src[5] * 0.166666672f); } cvt->len_cvt = cvt->len_cvt / 6; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert51ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert51ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("5.1", "stereo"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 6); i; i--, src += 6, dst += 2) { + for (i = cvt->len_cvt / (sizeof(float) * 6); i; i--, src += 6, dst += 2) { const float srcFC = src[2]; const float srcLFE = src[3]; const float srcBL = src[4]; @@ -940,21 +903,20 @@ SDL_Convert51ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 6) * 2; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert51To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert51To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("5.1", "2.1"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 6); i; i--, src += 6, dst += 3) { + for (i = cvt->len_cvt / (sizeof(float) * 6); i; i--, src += 6, dst += 3) { const float srcFC = src[2]; const float srcBL = src[4]; const float srcBR = src[5]; @@ -965,21 +927,20 @@ SDL_Convert51To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 6) * 3; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert51ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert51ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("5.1", "quad"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 6); i; i--, src += 6, dst += 4) { + for (i = cvt->len_cvt / (sizeof(float) * 6); i; i--, src += 6, dst += 4) { const float srcFC = src[2]; const float srcLFE = src[3]; dst[0] /* FL */ = (src[0] * 0.558095276f) + (srcFC * 0.394285709f) + (srcLFE * 0.047619049f); @@ -990,21 +951,20 @@ SDL_Convert51ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 6) * 4; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert51To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert51To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("5.1", "4.1"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 6); i; i--, src += 6, dst += 5) { + for (i = cvt->len_cvt / (sizeof(float) * 6); i; i--, src += 6, dst += 5) { const float srcFC = src[2]; dst[0] /* FL */ = (src[0] * 0.586000025f) + (srcFC * 0.414000005f); dst[1] /* FR */ = (src[1] * 0.586000025f) + (srcFC * 0.414000005f); @@ -1015,22 +975,21 @@ SDL_Convert51To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 6) * 5; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert51To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert51To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 6) * 7))) - 7; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 6; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 6) * 7))) - 7; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 6; int i; LOG_DEBUG_CONVERT("5.1", "6.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 6); i; i--, src -= 6, dst -= 7) { + for (i = cvt->len_cvt / (sizeof(float) * 6); i; i--, src -= 6, dst -= 7) { const float srcBL = src[4]; const float srcBR = src[5]; dst[6] /* SR */ = (srcBR * 0.796000004f); @@ -1044,22 +1003,21 @@ SDL_Convert51To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 6) * 7; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert51To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert51To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 6) * 8))) - 8; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 6; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 6) * 8))) - 8; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 6; int i; LOG_DEBUG_CONVERT("5.1", "7.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 6); i; i--, src -= 6, dst -= 8) { + for (i = cvt->len_cvt / (sizeof(float) * 6); i; i--, src -= 6, dst -= 8) { dst[7] /* SR */ = 0.0f; dst[6] /* SL */ = 0.0f; dst[5] /* BR */ = src[5]; @@ -1072,41 +1030,39 @@ SDL_Convert51To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 6) * 8; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert61ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert61ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("6.1", "mono"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 7); i; i--, src += 7, dst += 1) { + for (i = cvt->len_cvt / (sizeof(float) * 7); i; i--, src += 7, dst += 1) { dst[0] /* FC */ = (src[0] * 0.143142849f) + (src[1] * 0.143142849f) + (src[2] * 0.143142849f) + (src[3] * 0.142857149f) + (src[4] * 0.143142849f) + (src[5] * 0.143142849f) + (src[6] * 0.143142849f); } cvt->len_cvt = cvt->len_cvt / 7; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert61ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert61ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("6.1", "stereo"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 7); i; i--, src += 7, dst += 2) { + for (i = cvt->len_cvt / (sizeof(float) * 7); i; i--, src += 7, dst += 2) { const float srcFC = src[2]; const float srcLFE = src[3]; const float srcBC = src[4]; @@ -1118,21 +1074,20 @@ SDL_Convert61ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 7) * 2; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert61To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert61To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("6.1", "2.1"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 7); i; i--, src += 7, dst += 3) { + for (i = cvt->len_cvt / (sizeof(float) * 7); i; i--, src += 7, dst += 3) { const float srcFC = src[2]; const float srcBC = src[4]; const float srcSL = src[5]; @@ -1144,21 +1099,20 @@ SDL_Convert61To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 7) * 3; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert61ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert61ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("6.1", "quad"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 7); i; i--, src += 7, dst += 4) { + for (i = cvt->len_cvt / (sizeof(float) * 7); i; i--, src += 7, dst += 4) { const float srcFC = src[2]; const float srcLFE = src[3]; const float srcBC = src[4]; @@ -1172,21 +1126,20 @@ SDL_Convert61ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 7) * 4; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert61To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert61To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("6.1", "4.1"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 7); i; i--, src += 7, dst += 5) { + for (i = cvt->len_cvt / (sizeof(float) * 7); i; i--, src += 7, dst += 5) { const float srcFC = src[2]; const float srcBC = src[4]; const float srcSL = src[5]; @@ -1200,21 +1153,20 @@ SDL_Convert61To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 7) * 5; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert61To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert61To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("6.1", "5.1"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 7); i; i--, src += 7, dst += 6) { + for (i = cvt->len_cvt / (sizeof(float) * 7); i; i--, src += 7, dst += 6) { const float srcBC = src[4]; const float srcSL = src[5]; const float srcSR = src[6]; @@ -1228,22 +1180,21 @@ SDL_Convert61To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 7) * 6; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert61To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert61To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 7) * 8))) - 8; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 7; + float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 7) * 8))) - 8; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 7; int i; LOG_DEBUG_CONVERT("6.1", "7.1"); SDL_assert(format == AUDIO_F32SYS); /* convert backwards, since output is growing in-place. */ - for (i = cvt->len_cvt / (sizeof (float) * 7); i; i--, src -= 7, dst -= 8) { + for (i = cvt->len_cvt / (sizeof(float) * 7); i; i--, src -= 7, dst -= 8) { const float srcBC = src[4]; dst[7] /* SR */ = src[6]; dst[6] /* SL */ = src[5]; @@ -1257,41 +1208,39 @@ SDL_Convert61To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 7) * 8; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert71ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert71ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("7.1", "mono"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 8); i; i--, src += 8, dst += 1) { + for (i = cvt->len_cvt / (sizeof(float) * 8); i; i--, src += 8, dst += 1) { dst[0] /* FC */ = (src[0] * 0.125125006f) + (src[1] * 0.125125006f) + (src[2] * 0.125125006f) + (src[3] * 0.125000000f) + (src[4] * 0.125125006f) + (src[5] * 0.125125006f) + (src[6] * 0.125125006f) + (src[7] * 0.125125006f); } cvt->len_cvt = cvt->len_cvt / 8; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert71ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert71ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("7.1", "stereo"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 8); i; i--, src += 8, dst += 2) { + for (i = cvt->len_cvt / (sizeof(float) * 8); i; i--, src += 8, dst += 2) { const float srcFC = src[2]; const float srcLFE = src[3]; const float srcBL = src[4]; @@ -1304,21 +1253,20 @@ SDL_Convert71ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 8) * 2; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert71To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert71To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("7.1", "2.1"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 8); i; i--, src += 8, dst += 3) { + for (i = cvt->len_cvt / (sizeof(float) * 8); i; i--, src += 8, dst += 3) { const float srcFC = src[2]; const float srcBL = src[4]; const float srcBR = src[5]; @@ -1331,21 +1279,20 @@ SDL_Convert71To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 8) * 3; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert71ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert71ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("7.1", "quad"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 8); i; i--, src += 8, dst += 4) { + for (i = cvt->len_cvt / (sizeof(float) * 8); i; i--, src += 8, dst += 4) { const float srcFC = src[2]; const float srcLFE = src[3]; const float srcSL = src[6]; @@ -1358,21 +1305,20 @@ SDL_Convert71ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 8) * 4; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert71To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert71To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("7.1", "4.1"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 8); i; i--, src += 8, dst += 5) { + for (i = cvt->len_cvt / (sizeof(float) * 8); i; i--, src += 8, dst += 5) { const float srcFC = src[2]; const float srcSL = src[6]; const float srcSR = src[7]; @@ -1385,21 +1331,20 @@ SDL_Convert71To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 8) * 5; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert71To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert71To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("7.1", "5.1"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 8); i; i--, src += 8, dst += 6) { + for (i = cvt->len_cvt / (sizeof(float) * 8); i; i--, src += 8, dst += 6) { const float srcSL = src[6]; const float srcSR = src[7]; dst[0] /* FL */ = (src[0] * 0.518000007f) + (srcSL * 0.188999996f); @@ -1412,21 +1357,20 @@ SDL_Convert71To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 8) * 6; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static void SDLCALL -SDL_Convert71To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert71To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i; LOG_DEBUG_CONVERT("7.1", "6.1"); SDL_assert(format == AUDIO_F32SYS); - for (i = cvt->len_cvt / (sizeof (float) * 8); i; i--, src += 8, dst += 7) { + for (i = cvt->len_cvt / (sizeof(float) * 8); i; i--, src += 8, dst += 7) { const float srcBL = src[4]; const float srcBR = src[5]; dst[0] /* FL */ = (src[0] * 0.541000009f); @@ -1440,20 +1384,19 @@ SDL_Convert71To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) cvt->len_cvt = (cvt->len_cvt / 8) * 7; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } -static const SDL_AudioFilter channel_converters[8][8] = { /* [from][to] */ - { NULL, SDL_ConvertMonoToStereo, SDL_ConvertMonoTo21, SDL_ConvertMonoToQuad, SDL_ConvertMonoTo41, SDL_ConvertMonoTo51, SDL_ConvertMonoTo61, SDL_ConvertMonoTo71 }, - { SDL_ConvertStereoToMono, NULL, SDL_ConvertStereoTo21, SDL_ConvertStereoToQuad, SDL_ConvertStereoTo41, SDL_ConvertStereoTo51, SDL_ConvertStereoTo61, SDL_ConvertStereoTo71 }, - { SDL_Convert21ToMono, SDL_Convert21ToStereo, NULL, SDL_Convert21ToQuad, SDL_Convert21To41, SDL_Convert21To51, SDL_Convert21To61, SDL_Convert21To71 }, - { SDL_ConvertQuadToMono, SDL_ConvertQuadToStereo, SDL_ConvertQuadTo21, NULL, SDL_ConvertQuadTo41, SDL_ConvertQuadTo51, SDL_ConvertQuadTo61, SDL_ConvertQuadTo71 }, - { SDL_Convert41ToMono, SDL_Convert41ToStereo, SDL_Convert41To21, SDL_Convert41ToQuad, NULL, SDL_Convert41To51, SDL_Convert41To61, SDL_Convert41To71 }, - { SDL_Convert51ToMono, SDL_Convert51ToStereo, SDL_Convert51To21, SDL_Convert51ToQuad, SDL_Convert51To41, NULL, SDL_Convert51To61, SDL_Convert51To71 }, - { SDL_Convert61ToMono, SDL_Convert61ToStereo, SDL_Convert61To21, SDL_Convert61ToQuad, SDL_Convert61To41, SDL_Convert61To51, NULL, SDL_Convert61To71 }, - { SDL_Convert71ToMono, SDL_Convert71ToStereo, SDL_Convert71To21, SDL_Convert71ToQuad, SDL_Convert71To41, SDL_Convert71To51, SDL_Convert71To61, NULL } +static const SDL_AudioFilter channel_converters[8][8] = { /* [from][to] */ + { NULL, SDL_ConvertMonoToStereo, SDL_ConvertMonoTo21, SDL_ConvertMonoToQuad, SDL_ConvertMonoTo41, SDL_ConvertMonoTo51, SDL_ConvertMonoTo61, SDL_ConvertMonoTo71 }, + { SDL_ConvertStereoToMono, NULL, SDL_ConvertStereoTo21, SDL_ConvertStereoToQuad, SDL_ConvertStereoTo41, SDL_ConvertStereoTo51, SDL_ConvertStereoTo61, SDL_ConvertStereoTo71 }, + { SDL_Convert21ToMono, SDL_Convert21ToStereo, NULL, SDL_Convert21ToQuad, SDL_Convert21To41, SDL_Convert21To51, SDL_Convert21To61, SDL_Convert21To71 }, + { SDL_ConvertQuadToMono, SDL_ConvertQuadToStereo, SDL_ConvertQuadTo21, NULL, SDL_ConvertQuadTo41, SDL_ConvertQuadTo51, SDL_ConvertQuadTo61, SDL_ConvertQuadTo71 }, + { SDL_Convert41ToMono, SDL_Convert41ToStereo, SDL_Convert41To21, SDL_Convert41ToQuad, NULL, SDL_Convert41To51, SDL_Convert41To61, SDL_Convert41To71 }, + { SDL_Convert51ToMono, SDL_Convert51ToStereo, SDL_Convert51To21, SDL_Convert51ToQuad, SDL_Convert51To41, NULL, SDL_Convert51To61, SDL_Convert51To71 }, + { SDL_Convert61ToMono, SDL_Convert61ToStereo, SDL_Convert61To21, SDL_Convert61ToQuad, SDL_Convert61To41, SDL_Convert61To51, NULL, SDL_Convert61To71 }, + { SDL_Convert71ToMono, SDL_Convert71ToStereo, SDL_Convert71To21, SDL_Convert71ToQuad, SDL_Convert71To41, SDL_Convert71To51, SDL_Convert71To61, NULL } }; /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/audio/SDL_audio_resampler_filter.h b/src/audio/SDL_audio_resampler_filter.h index 9b4728c3b..44df79613 100644 --- a/src/audio/SDL_audio_resampler_filter.h +++ b/src/audio/SDL_audio_resampler_filter.h @@ -21,10 +21,10 @@ /* DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_resampler_filter.c */ -#define RESAMPLER_ZERO_CROSSINGS 5 -#define RESAMPLER_BITS_PER_SAMPLE 16 +#define RESAMPLER_ZERO_CROSSINGS 5 +#define RESAMPLER_BITS_PER_SAMPLE 16 #define RESAMPLER_SAMPLES_PER_ZERO_CROSSING (1 << ((RESAMPLER_BITS_PER_SAMPLE / 2) + 1)) -#define RESAMPLER_FILTER_SIZE ((RESAMPLER_SAMPLES_PER_ZERO_CROSSING * RESAMPLER_ZERO_CROSSINGS) + 1) +#define RESAMPLER_FILTER_SIZE ((RESAMPLER_SAMPLES_PER_ZERO_CROSSING * RESAMPLER_ZERO_CROSSINGS) + 1) static const float ResamplerFilter[RESAMPLER_FILTER_SIZE] = { 1.000000000f, 0.999993682f, 0.999974370f, 0.999941289f, 0.999894559f, @@ -1059,4 +1059,3 @@ static const float ResamplerFilterDifference[RESAMPLER_FILTER_SIZE] = { }; /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c index 398bdba1d..b0a8a7072 100644 --- a/src/audio/SDL_audiocvt.c +++ b/src/audio/SDL_audiocvt.c @@ -48,16 +48,16 @@ #define HAVE_AVX_INTRINSICS 1 #endif #if defined __clang__ -# if (!__has_attribute(target)) -# undef HAVE_AVX_INTRINSICS -# endif -# if (defined(_MSC_VER) || defined(__SCE__)) && !defined(__AVX__) -# undef HAVE_AVX_INTRINSICS -# endif +#if (!__has_attribute(target)) +#undef HAVE_AVX_INTRINSICS +#endif +#if (defined(_MSC_VER) || defined(__SCE__)) && !defined(__AVX__) +#undef HAVE_AVX_INTRINSICS +#endif #elif defined __GNUC__ -# if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 9) -# undef HAVE_AVX_INTRINSICS -# endif +#if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 9) +#undef HAVE_AVX_INTRINSICS +#endif #endif /* @@ -95,11 +95,10 @@ #if HAVE_SSE3_INTRINSICS /* Convert from stereo to mono. Average left and right. */ -static void SDLCALL -SDL_ConvertStereoToMono_SSE3(SDL_AudioCVT * cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertStereoToMono_SSE3(SDL_AudioCVT *cvt, SDL_AudioFormat format) { const __m128 divby2 = _mm_set1_ps(0.5f); - float *dst = (float *) cvt->buf; + float *dst = (float *)cvt->buf; const float *src = dst; int i = cvt->len_cvt / 8; @@ -109,32 +108,35 @@ SDL_ConvertStereoToMono_SSE3(SDL_AudioCVT * cvt, SDL_AudioFormat format) /* Do SSE blocks as long as we have 16 bytes available. Just use unaligned load/stores, if the memory at runtime is aligned it'll be just as fast on modern processors */ - while (i >= 4) { /* 4 * float32 */ - _mm_storeu_ps(dst, _mm_mul_ps(_mm_hadd_ps(_mm_loadu_ps(src), _mm_loadu_ps(src+4)), divby2)); - i -= 4; src += 8; dst += 4; + while (i >= 4) { /* 4 * float32 */ + _mm_storeu_ps(dst, _mm_mul_ps(_mm_hadd_ps(_mm_loadu_ps(src), _mm_loadu_ps(src + 4)), divby2)); + i -= 4; + src += 8; + dst += 4; } /* Finish off any leftovers with scalar operations. */ while (i) { *dst = (src[0] + src[1]) * 0.5f; - dst++; i--; src += 2; + dst++; + i--; + src += 2; } cvt->len_cvt /= 2; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } #endif #if HAVE_SSE_INTRINSICS /* Convert from mono to stereo. Duplicate to stereo left and right. */ -static void SDLCALL -SDL_ConvertMonoToStereo_SSE(SDL_AudioCVT * cvt, SDL_AudioFormat format) +static void SDLCALL SDL_ConvertMonoToStereo_SSE(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - float *dst = ((float *) (cvt->buf + (cvt->len_cvt * 2))) - 8; - const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 4; - int i = cvt->len_cvt / sizeof (float); + float *dst = ((float *)(cvt->buf + (cvt->len_cvt * 2))) - 8; + const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 4; + int i = cvt->len_cvt / sizeof(float); LOG_DEBUG_CONVERT("mono", "stereo (using SSE)"); SDL_assert(format == AUDIO_F32SYS); @@ -143,42 +145,43 @@ SDL_ConvertMonoToStereo_SSE(SDL_AudioCVT * cvt, SDL_AudioFormat format) Just use unaligned load/stores, if the memory at runtime is aligned it'll be just as fast on modern processors */ /* convert backwards, since output is growing in-place. */ - while (i >= 4) { /* 4 * float32 */ - const __m128 input = _mm_loadu_ps(src); /* A B C D */ - _mm_storeu_ps(dst, _mm_unpacklo_ps(input, input)); /* A A B B */ - _mm_storeu_ps(dst+4, _mm_unpackhi_ps(input, input)); /* C C D D */ - i -= 4; src -= 4; dst -= 8; + while (i >= 4) { /* 4 * float32 */ + const __m128 input = _mm_loadu_ps(src); /* A B C D */ + _mm_storeu_ps(dst, _mm_unpacklo_ps(input, input)); /* A A B B */ + _mm_storeu_ps(dst + 4, _mm_unpackhi_ps(input, input)); /* C C D D */ + i -= 4; + src -= 4; + dst -= 8; } /* Finish off any leftovers with scalar operations. */ - src += 3; dst += 6; /* adjust for smaller buffers. */ - while (i) { /* convert backwards, since output is growing in-place. */ + src += 3; + dst += 6; /* adjust for smaller buffers. */ + while (i) { /* convert backwards, since output is growing in-place. */ const float srcFC = src[0]; dst[1] /* FR */ = srcFC; dst[0] /* FL */ = srcFC; - i--; src--; dst -= 2; + i--; + src--; + dst -= 2; } cvt->len_cvt *= 2; if (cvt->filters[++cvt->filter_index]) { - cvt->filters[cvt->filter_index] (cvt, format); + cvt->filters[cvt->filter_index](cvt, format); } } #endif - /* Include the autogenerated channel converters... */ #include "SDL_audio_channel_converters.h" - - /* SDL's resampler uses a "bandlimited interpolation" algorithm: https://ccrma.stanford.edu/~jos/resample/ */ #include "SDL_audio_resampler_filter.h" -static int -ResamplerPadding(const int inrate, const int outrate) +static int ResamplerPadding(const int inrate, const int outrate) { if (inrate == outrate) { return 0; @@ -190,23 +193,22 @@ ResamplerPadding(const int inrate, const int outrate) } /* lpadding and rpadding are expected to be buffers of (ResamplePadding(inrate, outrate) * chans * sizeof (float)) bytes. */ -static int -SDL_ResampleAudio(const int chans, const int inrate, const int outrate, - const float *lpadding, const float *rpadding, - const float *inbuf, const int inbuflen, - float *outbuf, const int outbuflen) +static int SDL_ResampleAudio(const int chans, const int inrate, const int outrate, + const float *lpadding, const float *rpadding, + const float *inbuf, const int inbuflen, + float *outbuf, const int outbuflen) { /* Note that this used to be double, but it looks like we can get by with float in most cases at almost twice the speed on Intel processors, and orders of magnitude more on CPUs that need a software fallback for double calculations. */ typedef float ResampleFloatType; - const ResampleFloatType finrate = (ResampleFloatType) inrate; - const ResampleFloatType ratio = ((float) outrate) / ((float) inrate); + const ResampleFloatType finrate = (ResampleFloatType)inrate; + const ResampleFloatType ratio = ((float)outrate) / ((float)inrate); const int paddinglen = ResamplerPadding(inrate, outrate); - const int framelen = chans * (int)sizeof (float); + const int framelen = chans * (int)sizeof(float); const int inframes = inbuflen / framelen; - const int wantedoutframes = (int) ((inbuflen / framelen) * ratio); /* outbuflen isn't total to write, it's total available. */ + const int wantedoutframes = (int)((inbuflen / framelen) * ratio); /* outbuflen isn't total to write, it's total available. */ const int maxoutframes = outbuflen / framelen; const int outframes = SDL_min(wantedoutframes, maxoutframes); ResampleFloatType outtime = 0.0f; @@ -214,14 +216,14 @@ SDL_ResampleAudio(const int chans, const int inrate, const int outrate, int i, j, chan; for (i = 0; i < outframes; i++) { - const int srcindex = (int) (outtime * inrate); - const ResampleFloatType intime = ((ResampleFloatType) srcindex) / finrate; - const ResampleFloatType innexttime = ((ResampleFloatType) (srcindex + 1)) / finrate; + const int srcindex = (int)(outtime * inrate); + const ResampleFloatType intime = ((ResampleFloatType)srcindex) / finrate; + const ResampleFloatType innexttime = ((ResampleFloatType)(srcindex + 1)) / finrate; const ResampleFloatType indeltatime = innexttime - intime; const ResampleFloatType interpolation1 = (indeltatime == 0.0f) ? 1.0f : (1.0f - ((innexttime - outtime) / indeltatime)); - const int filterindex1 = (int) (interpolation1 * RESAMPLER_SAMPLES_PER_ZERO_CROSSING); + const int filterindex1 = (int)(interpolation1 * RESAMPLER_SAMPLES_PER_ZERO_CROSSING); const ResampleFloatType interpolation2 = 1.0f - interpolation1; - const int filterindex2 = (int) (interpolation2 * RESAMPLER_SAMPLES_PER_ZERO_CROSSING); + const int filterindex2 = (int)(interpolation2 * RESAMPLER_SAMPLES_PER_ZERO_CROSSING); for (chan = 0; chan < chans; chan++) { float outsample = 0.0f; @@ -246,14 +248,13 @@ SDL_ResampleAudio(const int chans, const int inrate, const int outrate, *(dst++) = outsample; } - outtime = ((ResampleFloatType) i) / ((ResampleFloatType) outrate); + outtime = ((ResampleFloatType)i) / ((ResampleFloatType)outrate); } return outframes * chans * sizeof(float); } -int -SDL_ConvertAudio(SDL_AudioCVT * cvt) +int SDL_ConvertAudio(SDL_AudioCVT *cvt) { /* !!! FIXME: (cvt) should be const; stack-copy it here. */ /* !!! FIXME: (actually, we can't...len_cvt needs to be updated. Grr.) */ @@ -271,35 +272,37 @@ SDL_ConvertAudio(SDL_AudioCVT * cvt) /* Set up the conversion and go! */ cvt->filter_index = 0; - cvt->filters[0] (cvt, cvt->src_format); + cvt->filters[0](cvt, cvt->src_format); return 0; } -static void SDLCALL -SDL_Convert_Byteswap(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_Byteswap(SDL_AudioCVT *cvt, SDL_AudioFormat format) { #if DEBUG_CONVERT SDL_Log("SDL_AUDIO_CONVERT: Converting byte order\n"); #endif switch (SDL_AUDIO_BITSIZE(format)) { - #define CASESWAP(b) \ - case b: { \ - Uint##b *ptr = (Uint##b *) cvt->buf; \ - int i; \ - for (i = cvt->len_cvt / sizeof (*ptr); i; --i, ++ptr) { \ - *ptr = SDL_Swap##b(*ptr); \ - } \ - break; \ - } +#define CASESWAP(b) \ + case b: \ + { \ + Uint##b *ptr = (Uint##b *)cvt->buf; \ + int i; \ + for (i = cvt->len_cvt / sizeof(*ptr); i; --i, ++ptr) { \ + *ptr = SDL_Swap##b(*ptr); \ + } \ + break; \ + } CASESWAP(16); CASESWAP(32); CASESWAP(64); - #undef CASESWAP +#undef CASESWAP - default: SDL_assert(!"unhandled byteswap datatype!"); break; + default: + SDL_assert(!"unhandled byteswap datatype!"); + break; } if (cvt->filters[++cvt->filter_index]) { @@ -313,8 +316,7 @@ SDL_Convert_Byteswap(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static int -SDL_AddAudioCVTFilter(SDL_AudioCVT *cvt, const SDL_AudioFilter filter) +static int SDL_AddAudioCVTFilter(SDL_AudioCVT *cvt, const SDL_AudioFilter filter) { if (cvt->filter_index >= SDL_AUDIOCVT_MAX_FILTERS) { return SDL_SetError("Too many filters needed for conversion, exceeded maximum of %d", SDL_AUDIOCVT_MAX_FILTERS); @@ -325,16 +327,15 @@ SDL_AddAudioCVTFilter(SDL_AudioCVT *cvt, const SDL_AudioFilter filter) return 0; } -static int -SDL_BuildAudioTypeCVTToFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat src_fmt) +static int SDL_BuildAudioTypeCVTToFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat src_fmt) { - int retval = 0; /* 0 == no conversion necessary. */ + int retval = 0; /* 0 == no conversion necessary. */ if ((SDL_AUDIO_ISBIGENDIAN(src_fmt) != 0) == (SDL_BYTEORDER == SDL_LIL_ENDIAN) && SDL_AUDIO_BITSIZE(src_fmt) > 8) { if (SDL_AddAudioCVTFilter(cvt, SDL_Convert_Byteswap) < 0) { return -1; } - retval = 1; /* added a converter. */ + retval = 1; /* added a converter. */ } if (!SDL_AUDIO_ISFLOAT(src_fmt)) { @@ -343,12 +344,24 @@ SDL_BuildAudioTypeCVTToFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat src_fmt) SDL_AudioFilter filter = NULL; switch (src_fmt & ~SDL_AUDIO_MASK_ENDIAN) { - case AUDIO_S8: filter = SDL_Convert_S8_to_F32; break; - case AUDIO_U8: filter = SDL_Convert_U8_to_F32; break; - case AUDIO_S16: filter = SDL_Convert_S16_to_F32; break; - case AUDIO_U16: filter = SDL_Convert_U16_to_F32; break; - case AUDIO_S32: filter = SDL_Convert_S32_to_F32; break; - default: SDL_assert(!"Unexpected audio format!"); break; + case AUDIO_S8: + filter = SDL_Convert_S8_to_F32; + break; + case AUDIO_U8: + filter = SDL_Convert_U8_to_F32; + break; + case AUDIO_S16: + filter = SDL_Convert_S16_to_F32; + break; + case AUDIO_U16: + filter = SDL_Convert_U16_to_F32; + break; + case AUDIO_S32: + filter = SDL_Convert_S32_to_F32; + break; + default: + SDL_assert(!"Unexpected audio format!"); + break; } if (!filter) { @@ -366,28 +379,39 @@ SDL_BuildAudioTypeCVTToFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat src_fmt) cvt->len_ratio /= (src_bitsize / dst_bitsize); } - retval = 1; /* added a converter. */ + retval = 1; /* added a converter. */ } return retval; } -static int -SDL_BuildAudioTypeCVTFromFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat dst_fmt) +static int SDL_BuildAudioTypeCVTFromFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat dst_fmt) { - int retval = 0; /* 0 == no conversion necessary. */ + int retval = 0; /* 0 == no conversion necessary. */ if (!SDL_AUDIO_ISFLOAT(dst_fmt)) { const Uint16 dst_bitsize = SDL_AUDIO_BITSIZE(dst_fmt); const Uint16 src_bitsize = 32; SDL_AudioFilter filter = NULL; switch (dst_fmt & ~SDL_AUDIO_MASK_ENDIAN) { - case AUDIO_S8: filter = SDL_Convert_F32_to_S8; break; - case AUDIO_U8: filter = SDL_Convert_F32_to_U8; break; - case AUDIO_S16: filter = SDL_Convert_F32_to_S16; break; - case AUDIO_U16: filter = SDL_Convert_F32_to_U16; break; - case AUDIO_S32: filter = SDL_Convert_F32_to_S32; break; - default: SDL_assert(!"Unexpected audio format!"); break; + case AUDIO_S8: + filter = SDL_Convert_F32_to_S8; + break; + case AUDIO_U8: + filter = SDL_Convert_F32_to_U8; + break; + case AUDIO_S16: + filter = SDL_Convert_F32_to_S16; + break; + case AUDIO_U16: + filter = SDL_Convert_F32_to_U16; + break; + case AUDIO_S32: + filter = SDL_Convert_F32_to_S32; + break; + default: + SDL_assert(!"Unexpected audio format!"); + break; } if (!filter) { @@ -405,14 +429,14 @@ SDL_BuildAudioTypeCVTFromFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat dst_fmt) const int div = (src_bitsize / dst_bitsize); cvt->len_ratio /= div; } - retval = 1; /* added a converter. */ + retval = 1; /* added a converter. */ } if ((SDL_AUDIO_ISBIGENDIAN(dst_fmt) != 0) == (SDL_BYTEORDER == SDL_LIL_ENDIAN) && SDL_AUDIO_BITSIZE(dst_fmt) > 8) { if (SDL_AddAudioCVTFilter(cvt, SDL_Convert_Byteswap) < 0) { return -1; } - retval = 1; /* added a converter. */ + retval = 1; /* added a converter. */ } return retval; @@ -420,12 +444,11 @@ SDL_BuildAudioTypeCVTFromFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat dst_fmt) #ifdef HAVE_LIBSAMPLERATE_H -static void -SDL_ResampleCVT_SRC(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format) +static void SDL_ResampleCVT_SRC(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format) { - const float *src = (const float *) cvt->buf; + const float *src = (const float *)cvt->buf; const int srclen = cvt->len_cvt; - float *dst = (float *) (cvt->buf + srclen); + float *dst = (float *)(cvt->buf + srclen); const int dstlen = (cvt->len * cvt->len_mult) - srclen; const int framelen = sizeof(float) * chans; int result = 0; @@ -442,12 +465,12 @@ SDL_ResampleCVT_SRC(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat fo data.src_ratio = cvt->rate_incr; result = SRC_src_simple(&data, SRC_converter, chans); /* Simple API converts the whole buffer at once. No need for initialization. */ - /* !!! FIXME: Handle library failures? */ - #ifdef DEBUG_CONVERT +/* !!! FIXME: Handle library failures? */ +#ifdef DEBUG_CONVERT if (result != 0) { SDL_Log("src_simple() failed: %s", SRC_src_strerror(result)); } - #endif +#endif cvt->len_cvt = data.output_frames_gen * framelen; @@ -460,20 +483,19 @@ SDL_ResampleCVT_SRC(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat fo #endif /* HAVE_LIBSAMPLERATE_H */ -static void -SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format) +static void SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format) { /* !!! FIXME in 2.1: there are ten slots in the filter list, and the theoretical maximum we use is six (seven with NULL terminator). !!! FIXME in 2.1: We need to store data for this resampler, because the cvt structure doesn't store the original sample rates, !!! FIXME in 2.1: so we steal the ninth and tenth slot. :( */ - const int inrate = (int) (size_t) cvt->filters[SDL_AUDIOCVT_MAX_FILTERS-1]; - const int outrate = (int) (size_t) cvt->filters[SDL_AUDIOCVT_MAX_FILTERS]; - const float *src = (const float *) cvt->buf; + const int inrate = (int)(size_t)cvt->filters[SDL_AUDIOCVT_MAX_FILTERS - 1]; + const int outrate = (int)(size_t)cvt->filters[SDL_AUDIOCVT_MAX_FILTERS]; + const float *src = (const float *)cvt->buf; const int srclen = cvt->len_cvt; /*float *dst = (float *) cvt->buf; const int dstlen = (cvt->len * cvt->len_mult);*/ /* !!! FIXME: remove this if we can get the resampler to work in-place again. */ - float *dst = (float *) (cvt->buf + srclen); + float *dst = (float *)(cvt->buf + srclen); const int dstlen = (cvt->len * cvt->len_mult) - srclen; const int requestedpadding = ResamplerPadding(inrate, outrate); int paddingsamples; @@ -487,7 +509,7 @@ SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format SDL_assert(format == AUDIO_F32SYS); /* we keep no streaming state here, so pad with silence on both ends. */ - padding = (float *) SDL_calloc(paddingsamples ? paddingsamples : 1, sizeof (float)); + padding = (float *)SDL_calloc(paddingsamples ? paddingsamples : 1, sizeof(float)); if (padding == NULL) { SDL_OutOfMemory(); return; @@ -497,7 +519,7 @@ SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format SDL_free(padding); - SDL_memmove(cvt->buf, dst, cvt->len_cvt); /* !!! FIXME: remove this if we can get the resampler to work in-place again. */ + SDL_memmove(cvt->buf, dst, cvt->len_cvt); /* !!! FIXME: remove this if we can get the resampler to work in-place again. */ if (cvt->filters[++cvt->filter_index]) { cvt->filters[cvt->filter_index](cvt, format); @@ -508,10 +530,11 @@ SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format !!! FIXME: store channel info, so we have to have function entry !!! FIXME: points for each supported channel count and multiple !!! FIXME: vs arbitrary. When we rev the ABI, clean this up. */ -#define RESAMPLER_FUNCS(chans) \ - static void SDLCALL \ - SDL_ResampleCVT_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) { \ - SDL_ResampleCVT(cvt, chans, format); \ +#define RESAMPLER_FUNCS(chans) \ + static void SDLCALL \ + SDL_ResampleCVT_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) \ + { \ + SDL_ResampleCVT(cvt, chans, format); \ } RESAMPLER_FUNCS(1) RESAMPLER_FUNCS(2) @@ -521,10 +544,11 @@ RESAMPLER_FUNCS(8) #undef RESAMPLER_FUNCS #ifdef HAVE_LIBSAMPLERATE_H -#define RESAMPLER_FUNCS(chans) \ - static void SDLCALL \ - SDL_ResampleCVT_SRC_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) { \ - SDL_ResampleCVT_SRC(cvt, chans, format); \ +#define RESAMPLER_FUNCS(chans) \ + static void SDLCALL \ + SDL_ResampleCVT_SRC_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) \ + { \ + SDL_ResampleCVT_SRC(cvt, chans, format); \ } RESAMPLER_FUNCS(1) RESAMPLER_FUNCS(2) @@ -534,42 +558,52 @@ RESAMPLER_FUNCS(8) #undef RESAMPLER_FUNCS #endif /* HAVE_LIBSAMPLERATE_H */ -static SDL_AudioFilter -ChooseCVTResampler(const int dst_channels) +static SDL_AudioFilter ChooseCVTResampler(const int dst_channels) { - #ifdef HAVE_LIBSAMPLERATE_H +#ifdef HAVE_LIBSAMPLERATE_H if (SRC_available) { switch (dst_channels) { - case 1: return SDL_ResampleCVT_SRC_c1; - case 2: return SDL_ResampleCVT_SRC_c2; - case 4: return SDL_ResampleCVT_SRC_c4; - case 6: return SDL_ResampleCVT_SRC_c6; - case 8: return SDL_ResampleCVT_SRC_c8; - default: break; + case 1: + return SDL_ResampleCVT_SRC_c1; + case 2: + return SDL_ResampleCVT_SRC_c2; + case 4: + return SDL_ResampleCVT_SRC_c4; + case 6: + return SDL_ResampleCVT_SRC_c6; + case 8: + return SDL_ResampleCVT_SRC_c8; + default: + break; } } - #endif /* HAVE_LIBSAMPLERATE_H */ +#endif /* HAVE_LIBSAMPLERATE_H */ switch (dst_channels) { - case 1: return SDL_ResampleCVT_c1; - case 2: return SDL_ResampleCVT_c2; - case 4: return SDL_ResampleCVT_c4; - case 6: return SDL_ResampleCVT_c6; - case 8: return SDL_ResampleCVT_c8; - default: break; + case 1: + return SDL_ResampleCVT_c1; + case 2: + return SDL_ResampleCVT_c2; + case 4: + return SDL_ResampleCVT_c4; + case 6: + return SDL_ResampleCVT_c6; + case 8: + return SDL_ResampleCVT_c8; + default: + break; } return NULL; } -static int -SDL_BuildAudioResampleCVT(SDL_AudioCVT * cvt, const int dst_channels, - const int src_rate, const int dst_rate) +static int SDL_BuildAudioResampleCVT(SDL_AudioCVT *cvt, const int dst_channels, + const int src_rate, const int dst_rate) { SDL_AudioFilter filter; if (src_rate == dst_rate) { - return 0; /* no conversion necessary. */ + return 0; /* no conversion necessary. */ } filter = ChooseCVTResampler(dst_channels); @@ -585,18 +619,18 @@ SDL_BuildAudioResampleCVT(SDL_AudioCVT * cvt, const int dst_channels, /* !!! FIXME in 2.1: there are ten slots in the filter list, and the theoretical maximum we use is six (seven with NULL terminator). !!! FIXME in 2.1: We need to store data for this resampler, because the cvt structure doesn't store the original sample rates, !!! FIXME in 2.1: so we steal the ninth and tenth slot. :( */ - if (cvt->filter_index >= (SDL_AUDIOCVT_MAX_FILTERS-2)) { + if (cvt->filter_index >= (SDL_AUDIOCVT_MAX_FILTERS - 2)) { return SDL_SetError("Too many filters needed for conversion, exceeded maximum of %d", SDL_AUDIOCVT_MAX_FILTERS - 2); } - cvt->filters[SDL_AUDIOCVT_MAX_FILTERS-1] = (SDL_AudioFilter) (uintptr_t) src_rate; - cvt->filters[SDL_AUDIOCVT_MAX_FILTERS] = (SDL_AudioFilter) (uintptr_t) dst_rate; + cvt->filters[SDL_AUDIOCVT_MAX_FILTERS - 1] = (SDL_AudioFilter)(uintptr_t)src_rate; + cvt->filters[SDL_AUDIOCVT_MAX_FILTERS] = (SDL_AudioFilter)(uintptr_t)dst_rate; if (src_rate < dst_rate) { - const double mult = ((double) dst_rate) / ((double) src_rate); - cvt->len_mult *= (int) SDL_ceil(mult); + const double mult = ((double)dst_rate) / ((double)src_rate); + cvt->len_mult *= (int)SDL_ceil(mult); cvt->len_ratio *= mult; } else { - cvt->len_ratio /= ((double) src_rate) / ((double) dst_rate); + cvt->len_ratio /= ((double)src_rate) / ((double)dst_rate); } /* !!! FIXME: remove this if we can get the resampler to work in-place again. */ @@ -604,48 +638,44 @@ SDL_BuildAudioResampleCVT(SDL_AudioCVT * cvt, const int dst_channels, we need it large enough to hold a separate scratch buffer. */ cvt->len_mult *= 2; - return 1; /* added a converter. */ + return 1; /* added a converter. */ } -static SDL_bool -SDL_SupportedAudioFormat(const SDL_AudioFormat fmt) +static SDL_bool SDL_SupportedAudioFormat(const SDL_AudioFormat fmt) { switch (fmt) { - case AUDIO_U8: - case AUDIO_S8: - case AUDIO_U16LSB: - case AUDIO_S16LSB: - case AUDIO_U16MSB: - case AUDIO_S16MSB: - case AUDIO_S32LSB: - case AUDIO_S32MSB: - case AUDIO_F32LSB: - case AUDIO_F32MSB: - return SDL_TRUE; /* supported. */ + case AUDIO_U8: + case AUDIO_S8: + case AUDIO_U16LSB: + case AUDIO_S16LSB: + case AUDIO_U16MSB: + case AUDIO_S16MSB: + case AUDIO_S32LSB: + case AUDIO_S32MSB: + case AUDIO_F32LSB: + case AUDIO_F32MSB: + return SDL_TRUE; /* supported. */ - default: - break; + default: + break; } - return SDL_FALSE; /* unsupported. */ + return SDL_FALSE; /* unsupported. */ } -static SDL_bool -SDL_SupportedChannelCount(const int channels) +static SDL_bool SDL_SupportedChannelCount(const int channels) { return ((channels >= 1) && (channels <= 8)) ? SDL_TRUE : SDL_FALSE; } - /* Creates a set of audio filters to convert from one format to another. Returns 0 if no conversion is needed, 1 if the audio filter is set up, or -1 if an error like invalid parameter, unsupported format, etc. occurred. */ -int -SDL_BuildAudioCVT(SDL_AudioCVT * cvt, - SDL_AudioFormat src_fmt, Uint8 src_channels, int src_rate, - SDL_AudioFormat dst_fmt, Uint8 dst_channels, int dst_rate) +int SDL_BuildAudioCVT(SDL_AudioCVT *cvt, + SDL_AudioFormat src_fmt, Uint8 src_channels, int src_rate, + SDL_AudioFormat dst_fmt, Uint8 dst_channels, int dst_rate) { SDL_AudioFilter channel_converter = NULL; @@ -684,7 +714,7 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt, #if DEBUG_CONVERT SDL_Log("SDL_AUDIO_CONVERT: Build format %04x->%04x, channels %u->%u, rate %d->%d\n", - src_fmt, dst_fmt, src_channels, dst_channels, src_rate, dst_rate); + src_fmt, dst_fmt, src_channels, dst_channels, src_rate, dst_rate); #endif /* Start off with no conversion necessary */ @@ -695,7 +725,7 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt, SDL_zeroa(cvt->filters); cvt->len_mult = 1; cvt->len_ratio = 1.0; - cvt->rate_incr = ((double) dst_rate) / ((double) src_rate); + cvt->rate_incr = ((double)dst_rate) / ((double)src_rate); /* Make sure we've chosen audio conversion functions (SIMD, scalar, etc.) */ SDL_ChooseAudioConverters(); @@ -735,17 +765,16 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt, /* Convert data types, if necessary. Updates (cvt). */ if (SDL_BuildAudioTypeCVTToFloat(cvt, src_fmt) < 0) { - return -1; /* shouldn't happen, but just in case... */ + return -1; /* shouldn't happen, but just in case... */ } - /* Channel conversion */ /* SDL_SupportedChannelCount should have caught these asserts, or we added a new format and forgot to update the table. */ SDL_assert(src_channels <= SDL_arraysize(channel_converters)); SDL_assert(dst_channels <= SDL_arraysize(channel_converters[0])); - channel_converter = channel_converters[src_channels-1][dst_channels-1]; + channel_converter = channel_converters[src_channels - 1][dst_channels - 1]; if ((channel_converter == NULL) != (src_channels == dst_channels)) { /* All combinations of supported channel counts should have been handled by now, but let's be defensive */ return SDL_SetError("Invalid channel combination"); @@ -753,16 +782,24 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt, /* swap in some SIMD versions for a few of these. */ if (channel_converter == SDL_ConvertStereoToMono) { SDL_AudioFilter filter = NULL; - #if HAVE_SSE3_INTRINSICS - if (!filter && SDL_HasSSE3()) { filter = SDL_ConvertStereoToMono_SSE3; } - #endif - if (filter) { channel_converter = filter; } +#if HAVE_SSE3_INTRINSICS + if (!filter && SDL_HasSSE3()) { + filter = SDL_ConvertStereoToMono_SSE3; + } +#endif + if (filter) { + channel_converter = filter; + } } else if (channel_converter == SDL_ConvertMonoToStereo) { SDL_AudioFilter filter = NULL; - #if HAVE_SSE_INTRINSICS - if (!filter && SDL_HasSSE()) { filter = SDL_ConvertMonoToStereo_SSE; } - #endif - if (filter) { channel_converter = filter; } +#if HAVE_SSE_INTRINSICS + if (!filter && SDL_HasSSE()) { + filter = SDL_ConvertMonoToStereo_SSE; + } +#endif + if (filter) { + channel_converter = filter; + } } if (SDL_AddAudioCVTFilter(cvt, channel_converter) < 0) { @@ -770,7 +807,7 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt, } if (src_channels < dst_channels) { - cvt->len_mult = ((cvt->len_mult * dst_channels) + (src_channels-1)) / src_channels; + cvt->len_mult = ((cvt->len_mult * dst_channels) + (src_channels - 1)) / src_channels; } cvt->len_ratio = (cvt->len_ratio * dst_channels) / src_channels; @@ -779,12 +816,12 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt, /* Do rate conversion, if necessary. Updates (cvt). */ if (SDL_BuildAudioResampleCVT(cvt, dst_channels, src_rate, dst_rate) < 0) { - return -1; /* shouldn't happen, but just in case... */ + return -1; /* shouldn't happen, but just in case... */ } /* Move to final data type. */ if (SDL_BuildAudioTypeCVTFromFloat(cvt, dst_fmt) < 0) { - return -1; /* shouldn't happen, but just in case... */ + return -1; /* shouldn't happen, but just in case... */ } cvt->needed = (cvt->filter_index != 0); @@ -804,7 +841,7 @@ struct _SDL_AudioStream Uint8 *staging_buffer; int staging_buffer_size; int staging_buffer_filled; - Uint8 *work_buffer_base; /* maybe unaligned pointer from SDL_realloc(). */ + Uint8 *work_buffer_base; /* maybe unaligned pointer from SDL_realloc(). */ int work_buffer_len; int src_sample_frame_size; SDL_AudioFormat src_format; @@ -825,8 +862,7 @@ struct _SDL_AudioStream SDL_CleanupAudioStreamResamplerFunc cleanup_resampler_func; }; -static Uint8 * -EnsureStreamBufferSize(SDL_AudioStream *stream, const int newlen) +static Uint8 *EnsureStreamBufferSize(SDL_AudioStream *stream, const int newlen) { Uint8 *ptr; size_t offset; @@ -834,7 +870,7 @@ EnsureStreamBufferSize(SDL_AudioStream *stream, const int newlen) if (stream->work_buffer_len >= newlen) { ptr = stream->work_buffer_base; } else { - ptr = (Uint8 *) SDL_realloc(stream->work_buffer_base, newlen + 32); + ptr = (Uint8 *)SDL_realloc(stream->work_buffer_base, newlen + 32); if (ptr == NULL) { SDL_OutOfMemory(); return NULL; @@ -844,22 +880,21 @@ EnsureStreamBufferSize(SDL_AudioStream *stream, const int newlen) stream->work_buffer_len = newlen; } - offset = ((size_t) ptr) & 15; + offset = ((size_t)ptr) & 15; return offset ? ptr + (16 - offset) : ptr; } #ifdef HAVE_LIBSAMPLERATE_H -static int -SDL_ResampleAudioStream_SRC(SDL_AudioStream *stream, const void *_inbuf, const int inbuflen, void *_outbuf, const int outbuflen) +static int SDL_ResampleAudioStream_SRC(SDL_AudioStream *stream, const void *_inbuf, const int inbuflen, void *_outbuf, const int outbuflen) { - const float *inbuf = (const float *) _inbuf; - float *outbuf = (float *) _outbuf; + const float *inbuf = (const float *)_inbuf; + float *outbuf = (float *)_outbuf; const int framelen = sizeof(float) * stream->pre_resample_channels; SRC_STATE *state = (SRC_STATE *)stream->resampler_state; SRC_DATA data; int result; - SDL_assert(inbuf != ((const float *) outbuf)); /* SDL_AudioStreamPut() shouldn't allow in-place resamples. */ + SDL_assert(inbuf != ((const float *)outbuf)); /* SDL_AudioStreamPut() shouldn't allow in-place resamples. */ data.data_in = (float *)inbuf; /* Older versions of libsamplerate had a non-const pointer, but didn't write to it */ data.input_frames = inbuflen / framelen; @@ -883,14 +918,12 @@ SDL_ResampleAudioStream_SRC(SDL_AudioStream *stream, const void *_inbuf, const i return data.output_frames_gen * (sizeof(float) * stream->pre_resample_channels); } -static void -SDL_ResetAudioStreamResampler_SRC(SDL_AudioStream *stream) +static void SDL_ResetAudioStreamResampler_SRC(SDL_AudioStream *stream) { SRC_src_reset((SRC_STATE *)stream->resampler_state); } -static void -SDL_CleanupAudioStreamResampler_SRC(SDL_AudioStream *stream) +static void SDL_CleanupAudioStreamResampler_SRC(SDL_AudioStream *stream) { SRC_STATE *state = (SRC_STATE *)stream->resampler_state; if (state) { @@ -903,8 +936,7 @@ SDL_CleanupAudioStreamResampler_SRC(SDL_AudioStream *stream) stream->cleanup_resampler_func = NULL; } -static SDL_bool -SetupLibSampleRateResampling(SDL_AudioStream *stream) +static SDL_bool SetupLibSampleRateResampling(SDL_AudioStream *stream) { int result = 0; SRC_STATE *state = NULL; @@ -930,42 +962,38 @@ SetupLibSampleRateResampling(SDL_AudioStream *stream) } #endif /* HAVE_LIBSAMPLERATE_H */ - -static int -SDL_ResampleAudioStream(SDL_AudioStream *stream, const void *_inbuf, const int inbuflen, void *_outbuf, const int outbuflen) +static int SDL_ResampleAudioStream(SDL_AudioStream *stream, const void *_inbuf, const int inbuflen, void *_outbuf, const int outbuflen) { - const Uint8 *inbufend = ((const Uint8 *) _inbuf) + inbuflen; - const float *inbuf = (const float *) _inbuf; - float *outbuf = (float *) _outbuf; - const int chans = (int) stream->pre_resample_channels; + const Uint8 *inbufend = ((const Uint8 *)_inbuf) + inbuflen; + const float *inbuf = (const float *)_inbuf; + float *outbuf = (float *)_outbuf; + const int chans = (int)stream->pre_resample_channels; const int inrate = stream->src_rate; const int outrate = stream->dst_rate; const int paddingsamples = stream->resampler_padding_samples; - const int paddingbytes = paddingsamples * sizeof (float); - float *lpadding = (float *) stream->resampler_state; - const float *rpadding = (const float *) inbufend; /* we set this up so there are valid padding samples at the end of the input buffer. */ + const int paddingbytes = paddingsamples * sizeof(float); + float *lpadding = (float *)stream->resampler_state; + const float *rpadding = (const float *)inbufend; /* we set this up so there are valid padding samples at the end of the input buffer. */ const int cpy = SDL_min(inbuflen, paddingbytes); int retval; - SDL_assert(inbuf != ((const float *) outbuf)); /* SDL_AudioStreamPut() shouldn't allow in-place resamples. */ + SDL_assert(inbuf != ((const float *)outbuf)); /* SDL_AudioStreamPut() shouldn't allow in-place resamples. */ retval = SDL_ResampleAudio(chans, inrate, outrate, lpadding, rpadding, inbuf, inbuflen, outbuf, outbuflen); /* update our left padding with end of current input, for next run. */ - SDL_memcpy((lpadding + paddingsamples) - (cpy / sizeof (float)), inbufend - cpy, cpy); + SDL_memcpy((lpadding + paddingsamples) - (cpy / sizeof(float)), inbufend - cpy, cpy); return retval; } -static void -SDL_ResetAudioStreamResampler(SDL_AudioStream *stream) +static void SDL_ResetAudioStreamResampler(SDL_AudioStream *stream) { /* set all the padding to silence. */ const int len = stream->resampler_padding_samples; - SDL_memset(stream->resampler_state, '\0', len * sizeof (float)); + SDL_memset(stream->resampler_state, '\0', len * sizeof(float)); } -static void -SDL_CleanupAudioStreamResampler(SDL_AudioStream *stream) +static void SDL_CleanupAudioStreamResampler(SDL_AudioStream *stream) { SDL_free(stream->resampler_state); } @@ -978,11 +1006,11 @@ SDL_NewAudioStream(const SDL_AudioFormat src_format, const Uint8 dst_channels, const int dst_rate) { - const int packetlen = 4096; /* !!! FIXME: good enough for now. */ + const int packetlen = 4096; /* !!! FIXME: good enough for now. */ Uint8 pre_resample_channels; SDL_AudioStream *retval; - retval = (SDL_AudioStream *) SDL_calloc(1, sizeof (SDL_AudioStream)); + retval = (SDL_AudioStream *)SDL_calloc(1, sizeof(SDL_AudioStream)); if (retval == NULL) { SDL_OutOfMemory(); return NULL; @@ -1005,9 +1033,9 @@ SDL_NewAudioStream(const SDL_AudioFormat src_format, retval->dst_rate = dst_rate; retval->pre_resample_channels = pre_resample_channels; retval->packetlen = packetlen; - retval->rate_incr = ((double) dst_rate) / ((double) src_rate); + retval->rate_incr = ((double)dst_rate) / ((double)src_rate); retval->resampler_padding_samples = ResamplerPadding(retval->src_rate, retval->dst_rate) * pre_resample_channels; - retval->resampler_padding = (float *) SDL_calloc(retval->resampler_padding_samples ? retval->resampler_padding_samples : 1, sizeof (float)); + retval->resampler_padding = (float *)SDL_calloc(retval->resampler_padding_samples ? retval->resampler_padding_samples : 1, sizeof(float)); if (retval->resampler_padding == NULL) { SDL_FreeAudioStream(retval); @@ -1017,7 +1045,7 @@ SDL_NewAudioStream(const SDL_AudioFormat src_format, retval->staging_buffer_size = ((retval->resampler_padding_samples / retval->pre_resample_channels) * retval->src_sample_frame_size); if (retval->staging_buffer_size > 0) { - retval->staging_buffer = (Uint8 *) SDL_malloc(retval->staging_buffer_size); + retval->staging_buffer = (Uint8 *)SDL_malloc(retval->staging_buffer_size); if (retval->staging_buffer == NULL) { SDL_FreeAudioStream(retval); SDL_OutOfMemory(); @@ -1030,14 +1058,14 @@ SDL_NewAudioStream(const SDL_AudioFormat src_format, retval->cvt_before_resampling.needed = SDL_FALSE; if (SDL_BuildAudioCVT(&retval->cvt_after_resampling, src_format, src_channels, dst_rate, dst_format, dst_channels, dst_rate) < 0) { SDL_FreeAudioStream(retval); - return NULL; /* SDL_BuildAudioCVT should have called SDL_SetError. */ + return NULL; /* SDL_BuildAudioCVT should have called SDL_SetError. */ } } else { /* Don't resample at first. Just get us to Float32 format. */ /* !!! FIXME: convert to int32 on devices without hardware float. */ if (SDL_BuildAudioCVT(&retval->cvt_before_resampling, src_format, src_channels, src_rate, AUDIO_F32SYS, pre_resample_channels, src_rate) < 0) { SDL_FreeAudioStream(retval); - return NULL; /* SDL_BuildAudioCVT should have called SDL_SetError. */ + return NULL; /* SDL_BuildAudioCVT should have called SDL_SetError. */ } #ifdef HAVE_LIBSAMPLERATE_H @@ -1045,7 +1073,7 @@ SDL_NewAudioStream(const SDL_AudioFormat src_format, #endif if (!retval->resampler_func) { - retval->resampler_state = SDL_calloc(retval->resampler_padding_samples, sizeof (float)); + retval->resampler_state = SDL_calloc(retval->resampler_padding_samples, sizeof(float)); if (!retval->resampler_state) { SDL_FreeAudioStream(retval); SDL_OutOfMemory(); @@ -1060,21 +1088,20 @@ SDL_NewAudioStream(const SDL_AudioFormat src_format, /* Convert us to the final format after resampling. */ if (SDL_BuildAudioCVT(&retval->cvt_after_resampling, AUDIO_F32SYS, pre_resample_channels, dst_rate, dst_format, dst_channels, dst_rate) < 0) { SDL_FreeAudioStream(retval); - return NULL; /* SDL_BuildAudioCVT should have called SDL_SetError. */ + return NULL; /* SDL_BuildAudioCVT should have called SDL_SetError. */ } } retval->queue = SDL_NewDataQueue(packetlen, packetlen * 2); if (!retval->queue) { SDL_FreeAudioStream(retval); - return NULL; /* SDL_NewDataQueue should have called SDL_SetError. */ + return NULL; /* SDL_NewDataQueue should have called SDL_SetError. */ } return retval; } -static int -SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, int *maxputbytes) +static int SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, int *maxputbytes) { int buflen = len; int workbuflen; @@ -1093,7 +1120,7 @@ SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, in !!! FIXME: a few samples at the end and convert them separately. */ /* no padding prepended on first run. */ - neededpaddingbytes = stream->resampler_padding_samples * sizeof (float); + neededpaddingbytes = stream->resampler_padding_samples * sizeof(float); paddingbytes = stream->first_run ? 0 : neededpaddingbytes; stream->first_run = SDL_FALSE; @@ -1105,12 +1132,12 @@ SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, in if (stream->dst_rate != stream->src_rate) { /* resamples can't happen in place, so make space for second buf. */ - const int framesize = stream->pre_resample_channels * sizeof (float); + const int framesize = stream->pre_resample_channels * sizeof(float); const int frames = workbuflen / framesize; - resamplebuflen = ((int) SDL_ceil(frames * stream->rate_incr)) * framesize; - #if DEBUG_AUDIOSTREAM + resamplebuflen = ((int)SDL_ceil(frames * stream->rate_incr)) * framesize; +#if DEBUG_AUDIOSTREAM SDL_Log("AUDIOSTREAM: will resample %d bytes to %d (ratio=%.6f)\n", workbuflen, resamplebuflen, stream->rate_incr); - #endif +#endif workbuflen += resamplebuflen; } @@ -1121,16 +1148,16 @@ SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, in workbuflen += neededpaddingbytes; - #if DEBUG_AUDIOSTREAM +#if DEBUG_AUDIOSTREAM SDL_Log("AUDIOSTREAM: Putting %d bytes of preconverted audio, need %d byte work buffer\n", buflen, workbuflen); - #endif +#endif workbuf = EnsureStreamBufferSize(stream, workbuflen); if (workbuf == NULL) { - return -1; /* probably out of memory. */ + return -1; /* probably out of memory. */ } - resamplebuf = workbuf; /* default if not resampling. */ + resamplebuf = workbuf; /* default if not resampling. */ SDL_memcpy(workbuf + paddingbytes, buf, buflen); @@ -1138,13 +1165,13 @@ SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, in stream->cvt_before_resampling.buf = workbuf + paddingbytes; stream->cvt_before_resampling.len = buflen; if (SDL_ConvertAudio(&stream->cvt_before_resampling) == -1) { - return -1; /* uhoh! */ + return -1; /* uhoh! */ } buflen = stream->cvt_before_resampling.len_cvt; - #if DEBUG_AUDIOSTREAM +#if DEBUG_AUDIOSTREAM SDL_Log("AUDIOSTREAM: After initial conversion we have %d bytes\n", buflen); - #endif +#endif } if (stream->dst_rate != stream->src_rate) { @@ -1161,7 +1188,7 @@ SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, in /* save off the data at the end for the next run. */ SDL_memcpy(stream->resampler_padding, workbuf + (buflen - neededpaddingbytes), neededpaddingbytes); - resamplebuf = workbuf + buflen; /* skip to second piece of workbuf. */ + resamplebuf = workbuf + buflen; /* skip to second piece of workbuf. */ SDL_assert(buflen >= neededpaddingbytes); if (buflen > neededpaddingbytes) { buflen = stream->resampler_func(stream, workbuf, buflen - neededpaddingbytes, resamplebuf, resamplebuflen); @@ -1169,27 +1196,27 @@ SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, in buflen = 0; } - #if DEBUG_AUDIOSTREAM +#if DEBUG_AUDIOSTREAM SDL_Log("AUDIOSTREAM: After resampling we have %d bytes\n", buflen); - #endif +#endif } if (stream->cvt_after_resampling.needed && (buflen > 0)) { stream->cvt_after_resampling.buf = resamplebuf; stream->cvt_after_resampling.len = buflen; if (SDL_ConvertAudio(&stream->cvt_after_resampling) == -1) { - return -1; /* uhoh! */ + return -1; /* uhoh! */ } buflen = stream->cvt_after_resampling.len_cvt; - #if DEBUG_AUDIOSTREAM +#if DEBUG_AUDIOSTREAM SDL_Log("AUDIOSTREAM: After final conversion we have %d bytes\n", buflen); - #endif +#endif } - #if DEBUG_AUDIOSTREAM +#if DEBUG_AUDIOSTREAM SDL_Log("AUDIOSTREAM: Final output is %d bytes\n", buflen); - #endif +#endif if (maxputbytes) { const int maxbytes = *maxputbytes; @@ -1203,8 +1230,7 @@ SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, in return buflen ? SDL_WriteToDataQueue(stream->queue, resamplebuf, buflen) : 0; } -int -SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len) +int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len) { /* !!! FIXME: several converters can take advantage of SIMD, but only !!! FIXME: if the data is aligned to 16 bytes. EnsureStreamBufferSize() @@ -1214,9 +1240,9 @@ SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len) !!! FIXME: isn't a multiple of 16. In these cases, we should chop off !!! FIXME: a few samples at the end and convert them separately. */ - #if DEBUG_AUDIOSTREAM +#if DEBUG_AUDIOSTREAM SDL_Log("AUDIOSTREAM: wants to put %d preconverted bytes\n", buflen); - #endif +#endif if (stream == NULL) { return SDL_InvalidParamError("stream"); @@ -1225,7 +1251,7 @@ SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len) return SDL_InvalidParamError("buf"); } if (len == 0) { - return 0; /* nothing to do. */ + return 0; /* nothing to do. */ } if ((len % stream->src_sample_frame_size) != 0) { return SDL_SetError("Can't add partial sample frames"); @@ -1234,9 +1260,9 @@ SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len) if (!stream->cvt_before_resampling.needed && (stream->dst_rate == stream->src_rate) && !stream->cvt_after_resampling.needed) { - #if DEBUG_AUDIOSTREAM +#if DEBUG_AUDIOSTREAM SDL_Log("AUDIOSTREAM: no conversion needed at all, queueing %d bytes.\n", len); - #endif +#endif return SDL_WriteToDataQueue(stream->queue, buf, len); } @@ -1277,9 +1303,9 @@ int SDL_AudioStreamFlush(SDL_AudioStream *stream) return SDL_InvalidParamError("stream"); } - #if DEBUG_AUDIOSTREAM +#if DEBUG_AUDIOSTREAM SDL_Log("AUDIOSTREAM: flushing! staging_buffer_filled=%d bytes\n", stream->staging_buffer_filled); - #endif +#endif /* shouldn't use a staging buffer if we're not resampling. */ SDL_assert((stream->dst_rate != stream->src_rate) || (stream->staging_buffer_filled == 0)); @@ -1295,13 +1321,13 @@ int SDL_AudioStreamFlush(SDL_AudioStream *stream) actual_input_frames += stream->resampler_padding_samples / stream->pre_resample_channels; } - if (actual_input_frames > 0) { /* don't bother if nothing to flush. */ + if (actual_input_frames > 0) { /* don't bother if nothing to flush. */ /* This is how many bytes we're expecting without silence appended. */ - int flush_remaining = ((int) SDL_ceil(actual_input_frames * stream->rate_incr)) * stream->dst_sample_frame_size; + int flush_remaining = ((int)SDL_ceil(actual_input_frames * stream->rate_incr)) * stream->dst_sample_frame_size; - #if DEBUG_AUDIOSTREAM +#if DEBUG_AUDIOSTREAM SDL_Log("AUDIOSTREAM: flushing with padding to get max %d bytes!\n", flush_remaining); - #endif +#endif SDL_memset(stream->staging_buffer + filled, '\0', stream->staging_buffer_size - filled); if (SDL_AudioStreamPutInternal(stream, stream->staging_buffer, stream->staging_buffer_size, &flush_remaining) < 0) { @@ -1325,12 +1351,11 @@ int SDL_AudioStreamFlush(SDL_AudioStream *stream) } /* get converted/resampled data from the stream */ -int -SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len) +int SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len) { - #if DEBUG_AUDIOSTREAM +#if DEBUG_AUDIOSTREAM SDL_Log("AUDIOSTREAM: want to get %d converted bytes\n", len); - #endif +#endif if (stream == NULL) { return SDL_InvalidParamError("stream"); @@ -1339,7 +1364,7 @@ SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len) return SDL_InvalidParamError("buf"); } if (len <= 0) { - return 0; /* nothing to do. */ + return 0; /* nothing to do. */ } if ((len % stream->dst_sample_frame_size) != 0) { return SDL_SetError("Can't request partial sample frames"); @@ -1349,14 +1374,12 @@ SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len) } /* number of converted/resampled bytes available */ -int -SDL_AudioStreamAvailable(SDL_AudioStream *stream) +int SDL_AudioStreamAvailable(SDL_AudioStream *stream) { return stream ? (int)SDL_CountDataQueue(stream->queue) : 0; } -void -SDL_AudioStreamClear(SDL_AudioStream *stream) +void SDL_AudioStreamClear(SDL_AudioStream *stream) { if (stream == NULL) { SDL_InvalidParamError("stream"); @@ -1371,8 +1394,7 @@ SDL_AudioStreamClear(SDL_AudioStream *stream) } /* dispose of a stream */ -void -SDL_FreeAudioStream(SDL_AudioStream *stream) +void SDL_FreeAudioStream(SDL_AudioStream *stream) { if (stream) { if (stream->cleanup_resampler_func) { diff --git a/src/audio/SDL_audiodev.c b/src/audio/SDL_audiodev.c index ee674d7df..d5c61d84d 100644 --- a/src/audio/SDL_audiodev.c +++ b/src/audio/SDL_audiodev.c @@ -34,9 +34,9 @@ #ifndef _PATH_DEV_DSP #if defined(__NETBSD__) || defined(__OPENBSD__) -#define _PATH_DEV_DSP "/dev/audio" +#define _PATH_DEV_DSP "/dev/audio" #else -#define _PATH_DEV_DSP "/dev/dsp" +#define _PATH_DEV_DSP "/dev/dsp" #endif #endif #ifndef _PATH_DEV_DSP24 @@ -46,8 +46,7 @@ #define _PATH_DEV_AUDIO "/dev/audio" #endif -static void -test_device(const int iscapture, const char *fname, int flags, int (*test) (int fd)) +static void test_device(const int iscapture, const char *fname, int flags, int (*test)(int fd)) { struct stat sb; if ((stat(fname, &sb) == 0) && (S_ISCHR(sb.st_mode))) { @@ -65,20 +64,18 @@ test_device(const int iscapture, const char *fname, int flags, int (*test) (int * information, making this information inaccessible at * enumeration time */ - SDL_AddAudioDevice(iscapture, fname, NULL, (void *) (uintptr_t) dummyhandle); + SDL_AddAudioDevice(iscapture, fname, NULL, (void *)(uintptr_t)dummyhandle); } } } } -static int -test_stub(int fd) +static int test_stub(int fd) { return 1; } -static void -SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int classic, int (*test)(int)) +static void SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int classic, int (*test)(int)) { const int flags = iscapture ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT; const char *audiodev; @@ -97,9 +94,7 @@ SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int classic, int (* struct stat sb; /* Added support for /dev/sound/\* in Linux 2.4 */ - if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) - && ((stat(_PATH_DEV_DSP24, &sb) == 0) - && S_ISCHR(sb.st_mode))) { + if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) && ((stat(_PATH_DEV_DSP24, &sb) == 0) && S_ISCHR(sb.st_mode))) { audiodev = _PATH_DEV_DSP24; } else { audiodev = _PATH_DEV_DSP; @@ -119,8 +114,7 @@ SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int classic, int (* } } -void -SDL_EnumUnixAudioDevices(const int classic, int (*test)(int)) +void SDL_EnumUnixAudioDevices(const int classic, int (*test)(int)) { SDL_EnumUnixAudioDevices_Internal(SDL_TRUE, classic, test); SDL_EnumUnixAudioDevices_Internal(SDL_FALSE, classic, test); diff --git a/src/audio/SDL_audiodev_c.h b/src/audio/SDL_audiodev_c.h index ff14ba5dc..ec0edaf0b 100644 --- a/src/audio/SDL_audiodev_c.h +++ b/src/audio/SDL_audiodev_c.h @@ -31,10 +31,10 @@ #ifdef USE_BLOCKING_WRITES #define OPEN_FLAGS_OUTPUT O_WRONLY -#define OPEN_FLAGS_INPUT O_RDONLY +#define OPEN_FLAGS_INPUT O_RDONLY #else -#define OPEN_FLAGS_OUTPUT (O_WRONLY|O_NONBLOCK) -#define OPEN_FLAGS_INPUT (O_RDONLY|O_NONBLOCK) +#define OPEN_FLAGS_OUTPUT (O_WRONLY | O_NONBLOCK) +#define OPEN_FLAGS_INPUT (O_RDONLY | O_NONBLOCK) #endif extern void SDL_EnumUnixAudioDevices(const int classic, int (*test)(int)); diff --git a/src/audio/SDL_audiotypecvt.c b/src/audio/SDL_audiotypecvt.c index e82bee05f..75eb5f45b 100644 --- a/src/audio/SDL_audiotypecvt.c +++ b/src/audio/SDL_audiotypecvt.c @@ -37,9 +37,9 @@ #elif __MACOSX__ && HAVE_SSE2_INTRINSICS #define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* Mac OS X/Intel guarantees SSE2. */ #elif defined(__ARM_ARCH) && (__ARM_ARCH >= 8) && HAVE_NEON_INTRINSICS -#define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* ARMv8+ promise NEON. */ +#define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* ARMv8+ promise NEON. */ #elif defined(__APPLE__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7) && HAVE_NEON_INTRINSICS -#define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* All Apple ARMv7 chips promise NEON support. */ +#define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* All Apple ARMv7 chips promise NEON support. */ #endif /* Set to zero if platform is guaranteed to use a SIMD codepath here. */ @@ -59,24 +59,21 @@ SDL_AudioFilter SDL_Convert_F32_to_S16 = NULL; SDL_AudioFilter SDL_Convert_F32_to_U16 = NULL; SDL_AudioFilter SDL_Convert_F32_to_S32 = NULL; - -#define DIVBY128 0.0078125f -#define DIVBY32768 0.000030517578125f +#define DIVBY128 0.0078125f +#define DIVBY32768 0.000030517578125f #define DIVBY8388607 0.00000011920930376163766f - #if NEED_SCALAR_CONVERTER_FALLBACKS -static void SDLCALL -SDL_Convert_S8_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_S8_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Sint8 *src = ((const Sint8 *) (cvt->buf + cvt->len_cvt)) - 1; - float *dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1; + const Sint8 *src = ((const Sint8 *)(cvt->buf + cvt->len_cvt)) - 1; + float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; int i; LOG_DEBUG_CONVERT("AUDIO_S8", "AUDIO_F32"); for (i = cvt->len_cvt; i; --i, --src, --dst) { - *dst = ((float) *src) * DIVBY128; + *dst = ((float)*src) * DIVBY128; } cvt->len_cvt *= 4; @@ -85,17 +82,16 @@ SDL_Convert_S8_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_U8_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_U8_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Uint8 *src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1; - float *dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1; + const Uint8 *src = ((const Uint8 *)(cvt->buf + cvt->len_cvt)) - 1; + float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; int i; LOG_DEBUG_CONVERT("AUDIO_U8", "AUDIO_F32"); for (i = cvt->len_cvt; i; --i, --src, --dst) { - *dst = (((float) *src) * DIVBY128) - 1.0f; + *dst = (((float)*src) * DIVBY128) - 1.0f; } cvt->len_cvt *= 4; @@ -104,17 +100,16 @@ SDL_Convert_U8_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_S16_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_S16_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Sint16 *src = ((const Sint16 *) (cvt->buf + cvt->len_cvt)) - 1; - float *dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1; + const Sint16 *src = ((const Sint16 *)(cvt->buf + cvt->len_cvt)) - 1; + float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; int i; LOG_DEBUG_CONVERT("AUDIO_S16", "AUDIO_F32"); - for (i = cvt->len_cvt / sizeof (Sint16); i; --i, --src, --dst) { - *dst = ((float) *src) * DIVBY32768; + for (i = cvt->len_cvt / sizeof(Sint16); i; --i, --src, --dst) { + *dst = ((float)*src) * DIVBY32768; } cvt->len_cvt *= 2; @@ -123,17 +118,16 @@ SDL_Convert_S16_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_U16_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_U16_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Uint16 *src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1; - float *dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1; + const Uint16 *src = ((const Uint16 *)(cvt->buf + cvt->len_cvt)) - 1; + float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; int i; LOG_DEBUG_CONVERT("AUDIO_U16", "AUDIO_F32"); - for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) { - *dst = (((float) *src) * DIVBY32768) - 1.0f; + for (i = cvt->len_cvt / sizeof(Uint16); i; --i, --src, --dst) { + *dst = (((float)*src) * DIVBY32768) - 1.0f; } cvt->len_cvt *= 2; @@ -142,17 +136,16 @@ SDL_Convert_U16_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_S32_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_S32_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Sint32 *src = (const Sint32 *) cvt->buf; - float *dst = (float *) cvt->buf; + const Sint32 *src = (const Sint32 *)cvt->buf; + float *dst = (float *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_S32", "AUDIO_F32"); - for (i = cvt->len_cvt / sizeof (Sint32); i; --i, ++src, ++dst) { - *dst = ((float) (*src>>8)) * DIVBY8388607; + for (i = cvt->len_cvt / sizeof(Sint32); i; --i, ++src, ++dst) { + *dst = ((float)(*src >> 8)) * DIVBY8388607; } if (cvt->filters[++cvt->filter_index]) { @@ -160,16 +153,15 @@ SDL_Convert_S32_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_F32_to_S8_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_F32_to_S8_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const float *src = (const float *) cvt->buf; - Sint8 *dst = (Sint8 *) cvt->buf; + const float *src = (const float *)cvt->buf; + Sint8 *dst = (Sint8 *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_S8"); - for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) { + for (i = cvt->len_cvt / sizeof(float); i; --i, ++src, ++dst) { const float sample = *src; if (sample >= 1.0f) { *dst = 127; @@ -186,16 +178,15 @@ SDL_Convert_F32_to_S8_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_F32_to_U8_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_F32_to_U8_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const float *src = (const float *) cvt->buf; - Uint8 *dst = (Uint8 *) cvt->buf; + const float *src = (const float *)cvt->buf; + Uint8 *dst = (Uint8 *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_U8"); - for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) { + for (i = cvt->len_cvt / sizeof(float); i; --i, ++src, ++dst) { const float sample = *src; if (sample >= 1.0f) { *dst = 255; @@ -212,16 +203,15 @@ SDL_Convert_F32_to_U8_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_F32_to_S16_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_F32_to_S16_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const float *src = (const float *) cvt->buf; - Sint16 *dst = (Sint16 *) cvt->buf; + const float *src = (const float *)cvt->buf; + Sint16 *dst = (Sint16 *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_S16"); - for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) { + for (i = cvt->len_cvt / sizeof(float); i; --i, ++src, ++dst) { const float sample = *src; if (sample >= 1.0f) { *dst = 32767; @@ -238,16 +228,15 @@ SDL_Convert_F32_to_S16_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_F32_to_U16_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_F32_to_U16_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const float *src = (const float *) cvt->buf; - Uint16 *dst = (Uint16 *) cvt->buf; + const float *src = (const float *)cvt->buf; + Uint16 *dst = (Uint16 *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_U16"); - for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) { + for (i = cvt->len_cvt / sizeof(float); i; --i, ++src, ++dst) { const float sample = *src; if (sample >= 1.0f) { *dst = 65535; @@ -264,21 +253,20 @@ SDL_Convert_F32_to_U16_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_F32_to_S32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_F32_to_S32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const float *src = (const float *) cvt->buf; - Sint32 *dst = (Sint32 *) cvt->buf; + const float *src = (const float *)cvt->buf; + Sint32 *dst = (Sint32 *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_S32"); - for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) { + for (i = cvt->len_cvt / sizeof(float); i; --i, ++src, ++dst) { const float sample = *src; if (sample >= 1.0f) { *dst = 2147483647; } else if (sample <= -1.0f) { - *dst = (Sint32) -2147483648LL; + *dst = (Sint32)-2147483648LL; } else { *dst = ((Sint32)(sample * 8388607.0f)) << 8; } @@ -290,33 +278,32 @@ SDL_Convert_F32_to_S32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) } #endif - #if HAVE_SSE2_INTRINSICS -static void SDLCALL -SDL_Convert_S8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_S8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Sint8 *src = ((const Sint8 *) (cvt->buf + cvt->len_cvt)) - 1; - float *dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1; + const Sint8 *src = ((const Sint8 *)(cvt->buf + cvt->len_cvt)) - 1; + float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; int i; LOG_DEBUG_CONVERT("AUDIO_S8", "AUDIO_F32 (using SSE2)"); /* Get dst aligned to 16 bytes (since buffer is growing, we don't have to worry about overreading from src) */ - for (i = cvt->len_cvt; i && (((size_t) (dst-15)) & 15); --i, --src, --dst) { - *dst = ((float) *src) * DIVBY128; + for (i = cvt->len_cvt; i && (((size_t)(dst - 15)) & 15); --i, --src, --dst) { + *dst = ((float)*src) * DIVBY128; } - src -= 15; dst -= 15; /* adjust to read SSE blocks from the start. */ - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); + src -= 15; + dst -= 15; /* adjust to read SSE blocks from the start. */ + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); /* Make sure src is aligned too. */ - if ((((size_t) src) & 15) == 0) { + if ((((size_t)src) & 15) == 0) { /* Aligned! Do SSE blocks as long as we have 16 bytes available. */ - const __m128i *mmsrc = (const __m128i *) src; + const __m128i *mmsrc = (const __m128i *)src; const __m128i zero = _mm_setzero_si128(); const __m128 divby128 = _mm_set1_ps(DIVBY128); - while (i >= 16) { /* 16 * 8-bit */ - const __m128i bytes = _mm_load_si128(mmsrc); /* get 16 sint8 into an XMM register. */ + while (i >= 16) { /* 16 * 8-bit */ + const __m128i bytes = _mm_load_si128(mmsrc); /* get 16 sint8 into an XMM register. */ /* treat as int16, shift left to clear every other sint16, then back right with sign-extend. Now sint16. */ const __m128i shorts1 = _mm_srai_epi16(_mm_slli_epi16(bytes, 8), 8); /* right-shift-sign-extend gets us sint16 with the other set of values. */ @@ -328,21 +315,26 @@ SDL_Convert_S8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) const __m128 floats4 = _mm_mul_ps(_mm_cvtepi32_ps(_mm_srai_epi32(_mm_slli_epi32(_mm_unpackhi_epi16(shorts2, zero), 16), 16)), divby128); /* Interleave back into correct order, store. */ _mm_store_ps(dst, _mm_unpacklo_ps(floats1, floats2)); - _mm_store_ps(dst+4, _mm_unpackhi_ps(floats1, floats2)); - _mm_store_ps(dst+8, _mm_unpacklo_ps(floats3, floats4)); - _mm_store_ps(dst+12, _mm_unpackhi_ps(floats3, floats4)); - i -= 16; mmsrc--; dst -= 16; + _mm_store_ps(dst + 4, _mm_unpackhi_ps(floats1, floats2)); + _mm_store_ps(dst + 8, _mm_unpacklo_ps(floats3, floats4)); + _mm_store_ps(dst + 12, _mm_unpackhi_ps(floats3, floats4)); + i -= 16; + mmsrc--; + dst -= 16; } - src = (const Sint8 *) mmsrc; + src = (const Sint8 *)mmsrc; } - src += 15; dst += 15; /* adjust for any scalar finishing. */ + src += 15; + dst += 15; /* adjust for any scalar finishing. */ /* Finish off any leftovers with scalar operations. */ while (i) { - *dst = ((float) *src) * DIVBY128; - i--; src--; dst--; + *dst = ((float)*src) * DIVBY128; + i--; + src--; + dst--; } cvt->len_cvt *= 4; @@ -351,32 +343,32 @@ SDL_Convert_S8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_U8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_U8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Uint8 *src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1; - float *dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1; + const Uint8 *src = ((const Uint8 *)(cvt->buf + cvt->len_cvt)) - 1; + float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; int i; LOG_DEBUG_CONVERT("AUDIO_U8", "AUDIO_F32 (using SSE2)"); /* Get dst aligned to 16 bytes (since buffer is growing, we don't have to worry about overreading from src) */ - for (i = cvt->len_cvt; i && (((size_t) (dst-15)) & 15); --i, --src, --dst) { - *dst = (((float) *src) * DIVBY128) - 1.0f; + for (i = cvt->len_cvt; i && (((size_t)(dst - 15)) & 15); --i, --src, --dst) { + *dst = (((float)*src) * DIVBY128) - 1.0f; } - src -= 15; dst -= 15; /* adjust to read SSE blocks from the start. */ - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); + src -= 15; + dst -= 15; /* adjust to read SSE blocks from the start. */ + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); /* Make sure src is aligned too. */ - if ((((size_t) src) & 15) == 0) { + if ((((size_t)src) & 15) == 0) { /* Aligned! Do SSE blocks as long as we have 16 bytes available. */ - const __m128i *mmsrc = (const __m128i *) src; + const __m128i *mmsrc = (const __m128i *)src; const __m128i zero = _mm_setzero_si128(); const __m128 divby128 = _mm_set1_ps(DIVBY128); const __m128 minus1 = _mm_set1_ps(-1.0f); - while (i >= 16) { /* 16 * 8-bit */ - const __m128i bytes = _mm_load_si128(mmsrc); /* get 16 uint8 into an XMM register. */ + while (i >= 16) { /* 16 * 8-bit */ + const __m128i bytes = _mm_load_si128(mmsrc); /* get 16 uint8 into an XMM register. */ /* treat as int16, shift left to clear every other sint16, then back right with zero-extend. Now uint16. */ const __m128i shorts1 = _mm_srli_epi16(_mm_slli_epi16(bytes, 8), 8); /* right-shift-zero-extend gets us uint16 with the other set of values. */ @@ -389,21 +381,26 @@ SDL_Convert_U8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) const __m128 floats4 = _mm_add_ps(_mm_mul_ps(_mm_cvtepi32_ps(_mm_unpackhi_epi16(shorts2, zero)), divby128), minus1); /* Interleave back into correct order, store. */ _mm_store_ps(dst, _mm_unpacklo_ps(floats1, floats2)); - _mm_store_ps(dst+4, _mm_unpackhi_ps(floats1, floats2)); - _mm_store_ps(dst+8, _mm_unpacklo_ps(floats3, floats4)); - _mm_store_ps(dst+12, _mm_unpackhi_ps(floats3, floats4)); - i -= 16; mmsrc--; dst -= 16; + _mm_store_ps(dst + 4, _mm_unpackhi_ps(floats1, floats2)); + _mm_store_ps(dst + 8, _mm_unpacklo_ps(floats3, floats4)); + _mm_store_ps(dst + 12, _mm_unpackhi_ps(floats3, floats4)); + i -= 16; + mmsrc--; + dst -= 16; } - src = (const Uint8 *) mmsrc; + src = (const Uint8 *)mmsrc; } - src += 15; dst += 15; /* adjust for any scalar finishing. */ + src += 15; + dst += 15; /* adjust for any scalar finishing. */ /* Finish off any leftovers with scalar operations. */ while (i) { - *dst = (((float) *src) * DIVBY128) - 1.0f; - i--; src--; dst--; + *dst = (((float)*src) * DIVBY128) - 1.0f; + i--; + src--; + dst--; } cvt->len_cvt *= 4; @@ -412,46 +409,51 @@ SDL_Convert_U8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_S16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_S16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Sint16 *src = ((const Sint16 *) (cvt->buf + cvt->len_cvt)) - 1; - float *dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1; + const Sint16 *src = ((const Sint16 *)(cvt->buf + cvt->len_cvt)) - 1; + float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; int i; LOG_DEBUG_CONVERT("AUDIO_S16", "AUDIO_F32 (using SSE2)"); /* Get dst aligned to 16 bytes (since buffer is growing, we don't have to worry about overreading from src) */ - for (i = cvt->len_cvt / sizeof (Sint16); i && (((size_t) (dst-7)) & 15); --i, --src, --dst) { - *dst = ((float) *src) * DIVBY32768; + for (i = cvt->len_cvt / sizeof(Sint16); i && (((size_t)(dst - 7)) & 15); --i, --src, --dst) { + *dst = ((float)*src) * DIVBY32768; } - src -= 7; dst -= 7; /* adjust to read SSE blocks from the start. */ - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); + src -= 7; + dst -= 7; /* adjust to read SSE blocks from the start. */ + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); /* Make sure src is aligned too. */ - if ((((size_t) src) & 15) == 0) { + if ((((size_t)src) & 15) == 0) { /* Aligned! Do SSE blocks as long as we have 16 bytes available. */ const __m128 divby32768 = _mm_set1_ps(DIVBY32768); - while (i >= 8) { /* 8 * 16-bit */ - const __m128i ints = _mm_load_si128((__m128i const *) src); /* get 8 sint16 into an XMM register. */ + while (i >= 8) { /* 8 * 16-bit */ + const __m128i ints = _mm_load_si128((__m128i const *)src); /* get 8 sint16 into an XMM register. */ /* treat as int32, shift left to clear every other sint16, then back right with sign-extend. Now sint32. */ const __m128i a = _mm_srai_epi32(_mm_slli_epi32(ints, 16), 16); /* right-shift-sign-extend gets us sint32 with the other set of values. */ const __m128i b = _mm_srai_epi32(ints, 16); /* Interleave these back into the right order, convert to float, multiply, store. */ _mm_store_ps(dst, _mm_mul_ps(_mm_cvtepi32_ps(_mm_unpacklo_epi32(a, b)), divby32768)); - _mm_store_ps(dst+4, _mm_mul_ps(_mm_cvtepi32_ps(_mm_unpackhi_epi32(a, b)), divby32768)); - i -= 8; src -= 8; dst -= 8; + _mm_store_ps(dst + 4, _mm_mul_ps(_mm_cvtepi32_ps(_mm_unpackhi_epi32(a, b)), divby32768)); + i -= 8; + src -= 8; + dst -= 8; } } - src += 7; dst += 7; /* adjust for any scalar finishing. */ + src += 7; + dst += 7; /* adjust for any scalar finishing. */ /* Finish off any leftovers with scalar operations. */ while (i) { - *dst = ((float) *src) * DIVBY32768; - i--; src--; dst--; + *dst = ((float)*src) * DIVBY32768; + i--; + src--; + dst--; } cvt->len_cvt *= 2; @@ -460,47 +462,52 @@ SDL_Convert_S16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_U16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_U16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Uint16 *src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1; - float *dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1; + const Uint16 *src = ((const Uint16 *)(cvt->buf + cvt->len_cvt)) - 1; + float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; int i; LOG_DEBUG_CONVERT("AUDIO_U16", "AUDIO_F32 (using SSE2)"); /* Get dst aligned to 16 bytes (since buffer is growing, we don't have to worry about overreading from src) */ - for (i = cvt->len_cvt / sizeof (Sint16); i && (((size_t) (dst-7)) & 15); --i, --src, --dst) { - *dst = (((float) *src) * DIVBY32768) - 1.0f; + for (i = cvt->len_cvt / sizeof(Sint16); i && (((size_t)(dst - 7)) & 15); --i, --src, --dst) { + *dst = (((float)*src) * DIVBY32768) - 1.0f; } - src -= 7; dst -= 7; /* adjust to read SSE blocks from the start. */ - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); + src -= 7; + dst -= 7; /* adjust to read SSE blocks from the start. */ + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); /* Make sure src is aligned too. */ - if ((((size_t) src) & 15) == 0) { + if ((((size_t)src) & 15) == 0) { /* Aligned! Do SSE blocks as long as we have 16 bytes available. */ const __m128 divby32768 = _mm_set1_ps(DIVBY32768); const __m128 minus1 = _mm_set1_ps(-1.0f); - while (i >= 8) { /* 8 * 16-bit */ - const __m128i ints = _mm_load_si128((__m128i const *) src); /* get 8 sint16 into an XMM register. */ + while (i >= 8) { /* 8 * 16-bit */ + const __m128i ints = _mm_load_si128((__m128i const *)src); /* get 8 sint16 into an XMM register. */ /* treat as int32, shift left to clear every other sint16, then back right with zero-extend. Now sint32. */ const __m128i a = _mm_srli_epi32(_mm_slli_epi32(ints, 16), 16); /* right-shift-sign-extend gets us sint32 with the other set of values. */ const __m128i b = _mm_srli_epi32(ints, 16); /* Interleave these back into the right order, convert to float, multiply, store. */ _mm_store_ps(dst, _mm_add_ps(_mm_mul_ps(_mm_cvtepi32_ps(_mm_unpacklo_epi32(a, b)), divby32768), minus1)); - _mm_store_ps(dst+4, _mm_add_ps(_mm_mul_ps(_mm_cvtepi32_ps(_mm_unpackhi_epi32(a, b)), divby32768), minus1)); - i -= 8; src -= 8; dst -= 8; + _mm_store_ps(dst + 4, _mm_add_ps(_mm_mul_ps(_mm_cvtepi32_ps(_mm_unpackhi_epi32(a, b)), divby32768), minus1)); + i -= 8; + src -= 8; + dst -= 8; } } - src += 7; dst += 7; /* adjust for any scalar finishing. */ + src += 7; + dst += 7; /* adjust for any scalar finishing. */ /* Finish off any leftovers with scalar operations. */ while (i) { - *dst = (((float) *src) * DIVBY32768) - 1.0f; - i--; src--; dst--; + *dst = (((float)*src) * DIVBY32768) - 1.0f; + i--; + src--; + dst--; } cvt->len_cvt *= 2; @@ -509,39 +516,42 @@ SDL_Convert_U16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_S32_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_S32_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Sint32 *src = (const Sint32 *) cvt->buf; - float *dst = (float *) cvt->buf; + const Sint32 *src = (const Sint32 *)cvt->buf; + float *dst = (float *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_S32", "AUDIO_F32 (using SSE2)"); /* Get dst aligned to 16 bytes */ - for (i = cvt->len_cvt / sizeof (Sint32); i && (((size_t) dst) & 15); --i, ++src, ++dst) { - *dst = ((float) (*src>>8)) * DIVBY8388607; + for (i = cvt->len_cvt / sizeof(Sint32); i && (((size_t)dst) & 15); --i, ++src, ++dst) { + *dst = ((float)(*src >> 8)) * DIVBY8388607; } - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); /* Make sure src is aligned too. */ - if ((((size_t) src) & 15) == 0) { + if ((((size_t)src) & 15) == 0) { /* Aligned! Do SSE blocks as long as we have 16 bytes available. */ const __m128 divby8388607 = _mm_set1_ps(DIVBY8388607); - const __m128i *mmsrc = (const __m128i *) src; - while (i >= 4) { /* 4 * sint32 */ + const __m128i *mmsrc = (const __m128i *)src; + while (i >= 4) { /* 4 * sint32 */ /* shift out lowest bits so int fits in a float32. Small precision loss, but much faster. */ _mm_store_ps(dst, _mm_mul_ps(_mm_cvtepi32_ps(_mm_srai_epi32(_mm_load_si128(mmsrc), 8)), divby8388607)); - i -= 4; mmsrc++; dst += 4; + i -= 4; + mmsrc++; + dst += 4; } - src = (const Sint32 *) mmsrc; + src = (const Sint32 *)mmsrc; } /* Finish off any leftovers with scalar operations. */ while (i) { - *dst = ((float) (*src>>8)) * DIVBY8388607; - i--; src++; dst++; + *dst = ((float)(*src >> 8)) * DIVBY8388607; + i--; + src++; + dst++; } if (cvt->filters[++cvt->filter_index]) { @@ -549,17 +559,16 @@ SDL_Convert_S32_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_F32_to_S8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_F32_to_S8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const float *src = (const float *) cvt->buf; - Sint8 *dst = (Sint8 *) cvt->buf; + const float *src = (const float *)cvt->buf; + Sint8 *dst = (Sint8 *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_S8 (using SSE2)"); /* Get dst aligned to 16 bytes */ - for (i = cvt->len_cvt / sizeof (float); i && (((size_t) dst) & 15); --i, ++src, ++dst) { + for (i = cvt->len_cvt / sizeof(float); i && (((size_t)dst) & 15); --i, ++src, ++dst) { const float sample = *src; if (sample >= 1.0f) { *dst = 127; @@ -570,24 +579,26 @@ SDL_Convert_F32_to_S8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); /* Make sure src is aligned too. */ - if ((((size_t) src) & 15) == 0) { + if ((((size_t)src) & 15) == 0) { /* Aligned! Do SSE blocks as long as we have 16 bytes available. */ const __m128 one = _mm_set1_ps(1.0f); const __m128 negone = _mm_set1_ps(-1.0f); const __m128 mulby127 = _mm_set1_ps(127.0f); - __m128i *mmdst = (__m128i *) dst; - while (i >= 16) { /* 16 * float32 */ - const __m128i ints1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const __m128i ints2 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src+4)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const __m128i ints3 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src+8)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const __m128i ints4 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src+12)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - _mm_store_si128(mmdst, _mm_packs_epi16(_mm_packs_epi32(ints1, ints2), _mm_packs_epi32(ints3, ints4))); /* pack down, store out. */ - i -= 16; src += 16; mmdst++; + __m128i *mmdst = (__m128i *)dst; + while (i >= 16) { /* 16 * float32 */ + const __m128i ints1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ + const __m128i ints2 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 4)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ + const __m128i ints3 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 8)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ + const __m128i ints4 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 12)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ + _mm_store_si128(mmdst, _mm_packs_epi16(_mm_packs_epi32(ints1, ints2), _mm_packs_epi32(ints3, ints4))); /* pack down, store out. */ + i -= 16; + src += 16; + mmdst++; } - dst = (Sint8 *) mmdst; + dst = (Sint8 *)mmdst; } /* Finish off any leftovers with scalar operations. */ @@ -600,7 +611,9 @@ SDL_Convert_F32_to_S8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) } else { *dst = (Sint8)(sample * 127.0f); } - i--; src++; dst++; + i--; + src++; + dst++; } cvt->len_cvt /= 4; @@ -609,17 +622,16 @@ SDL_Convert_F32_to_S8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_F32_to_U8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_F32_to_U8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const float *src = (const float *) cvt->buf; + const float *src = (const float *)cvt->buf; Uint8 *dst = cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_U8 (using SSE2)"); /* Get dst aligned to 16 bytes */ - for (i = cvt->len_cvt / sizeof (float); i && (((size_t) dst) & 15); --i, ++src, ++dst) { + for (i = cvt->len_cvt / sizeof(float); i && (((size_t)dst) & 15); --i, ++src, ++dst) { const float sample = *src; if (sample >= 1.0f) { *dst = 255; @@ -630,24 +642,26 @@ SDL_Convert_F32_to_U8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); /* Make sure src is aligned too. */ - if ((((size_t) src) & 15) == 0) { + if ((((size_t)src) & 15) == 0) { /* Aligned! Do SSE blocks as long as we have 16 bytes available. */ const __m128 one = _mm_set1_ps(1.0f); const __m128 negone = _mm_set1_ps(-1.0f); const __m128 mulby127 = _mm_set1_ps(127.0f); - __m128i *mmdst = (__m128i *) dst; - while (i >= 16) { /* 16 * float32 */ - const __m128i ints1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_add_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const __m128i ints2 = _mm_cvtps_epi32(_mm_mul_ps(_mm_add_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src+4)), one), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const __m128i ints3 = _mm_cvtps_epi32(_mm_mul_ps(_mm_add_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src+8)), one), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const __m128i ints4 = _mm_cvtps_epi32(_mm_mul_ps(_mm_add_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src+12)), one), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - _mm_store_si128(mmdst, _mm_packus_epi16(_mm_packs_epi32(ints1, ints2), _mm_packs_epi32(ints3, ints4))); /* pack down, store out. */ - i -= 16; src += 16; mmdst++; + __m128i *mmdst = (__m128i *)dst; + while (i >= 16) { /* 16 * float32 */ + const __m128i ints1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_add_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ + const __m128i ints2 = _mm_cvtps_epi32(_mm_mul_ps(_mm_add_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 4)), one), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ + const __m128i ints3 = _mm_cvtps_epi32(_mm_mul_ps(_mm_add_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 8)), one), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ + const __m128i ints4 = _mm_cvtps_epi32(_mm_mul_ps(_mm_add_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 12)), one), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ + _mm_store_si128(mmdst, _mm_packus_epi16(_mm_packs_epi32(ints1, ints2), _mm_packs_epi32(ints3, ints4))); /* pack down, store out. */ + i -= 16; + src += 16; + mmdst++; } - dst = (Uint8 *) mmdst; + dst = (Uint8 *)mmdst; } /* Finish off any leftovers with scalar operations. */ @@ -660,7 +674,9 @@ SDL_Convert_F32_to_U8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) } else { *dst = (Uint8)((sample + 1.0f) * 127.0f); } - i--; src++; dst++; + i--; + src++; + dst++; } cvt->len_cvt /= 4; @@ -669,17 +685,16 @@ SDL_Convert_F32_to_U8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_F32_to_S16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_F32_to_S16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const float *src = (const float *) cvt->buf; - Sint16 *dst = (Sint16 *) cvt->buf; + const float *src = (const float *)cvt->buf; + Sint16 *dst = (Sint16 *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_S16 (using SSE2)"); /* Get dst aligned to 16 bytes */ - for (i = cvt->len_cvt / sizeof (float); i && (((size_t) dst) & 15); --i, ++src, ++dst) { + for (i = cvt->len_cvt / sizeof(float); i && (((size_t)dst) & 15); --i, ++src, ++dst) { const float sample = *src; if (sample >= 1.0f) { *dst = 32767; @@ -690,22 +705,24 @@ SDL_Convert_F32_to_S16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); /* Make sure src is aligned too. */ - if ((((size_t) src) & 15) == 0) { + if ((((size_t)src) & 15) == 0) { /* Aligned! Do SSE blocks as long as we have 16 bytes available. */ const __m128 one = _mm_set1_ps(1.0f); const __m128 negone = _mm_set1_ps(-1.0f); const __m128 mulby32767 = _mm_set1_ps(32767.0f); - __m128i *mmdst = (__m128i *) dst; - while (i >= 8) { /* 8 * float32 */ - const __m128i ints1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ - const __m128i ints2 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src+4)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ - _mm_store_si128(mmdst, _mm_packs_epi32(ints1, ints2)); /* pack to sint16, store out. */ - i -= 8; src += 8; mmdst++; + __m128i *mmdst = (__m128i *)dst; + while (i >= 8) { /* 8 * float32 */ + const __m128i ints1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ + const __m128i ints2 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 4)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ + _mm_store_si128(mmdst, _mm_packs_epi32(ints1, ints2)); /* pack to sint16, store out. */ + i -= 8; + src += 8; + mmdst++; } - dst = (Sint16 *) mmdst; + dst = (Sint16 *)mmdst; } /* Finish off any leftovers with scalar operations. */ @@ -718,7 +735,9 @@ SDL_Convert_F32_to_S16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) } else { *dst = (Sint16)(sample * 32767.0f); } - i--; src++; dst++; + i--; + src++; + dst++; } cvt->len_cvt /= 2; @@ -727,17 +746,16 @@ SDL_Convert_F32_to_S16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_F32_to_U16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_F32_to_U16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const float *src = (const float *) cvt->buf; - Uint16 *dst = (Uint16 *) cvt->buf; + const float *src = (const float *)cvt->buf; + Uint16 *dst = (Uint16 *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_U16 (using SSE2)"); /* Get dst aligned to 16 bytes */ - for (i = cvt->len_cvt / sizeof (float); i && (((size_t) dst) & 15); --i, ++src, ++dst) { + for (i = cvt->len_cvt / sizeof(float); i && (((size_t)dst) & 15); --i, ++src, ++dst) { const float sample = *src; if (sample >= 1.0f) { *dst = 65535; @@ -748,10 +766,10 @@ SDL_Convert_F32_to_U16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); /* Make sure src is aligned too. */ - if ((((size_t) src) & 15) == 0) { + if ((((size_t)src) & 15) == 0) { /* Aligned! Do SSE blocks as long as we have 16 bytes available. */ /* This calculates differently than the scalar path because SSE2 can't pack int32 data down to unsigned int16. _mm_packs_epi32 does signed @@ -764,14 +782,16 @@ SDL_Convert_F32_to_U16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) const __m128i topbit = _mm_set1_epi16(-32768); const __m128 one = _mm_set1_ps(1.0f); const __m128 negone = _mm_set1_ps(-1.0f); - __m128i *mmdst = (__m128i *) dst; - while (i >= 8) { /* 8 * float32 */ - const __m128i ints1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ - const __m128i ints2 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src+4)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ - _mm_store_si128(mmdst, _mm_xor_si128(_mm_packs_epi32(ints1, ints2), topbit)); /* pack to sint16, xor top bit, store out. */ - i -= 8; src += 8; mmdst++; + __m128i *mmdst = (__m128i *)dst; + while (i >= 8) { /* 8 * float32 */ + const __m128i ints1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ + const __m128i ints2 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 4)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ + _mm_store_si128(mmdst, _mm_xor_si128(_mm_packs_epi32(ints1, ints2), topbit)); /* pack to sint16, xor top bit, store out. */ + i -= 8; + src += 8; + mmdst++; } - dst = (Uint16 *) mmdst; + dst = (Uint16 *)mmdst; } /* Finish off any leftovers with scalar operations. */ @@ -784,7 +804,9 @@ SDL_Convert_F32_to_U16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) } else { *dst = (Uint16)((sample + 1.0f) * 32767.0f); } - i--; src++; dst++; + i--; + src++; + dst++; } cvt->len_cvt /= 2; @@ -793,41 +815,42 @@ SDL_Convert_F32_to_U16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_F32_to_S32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_F32_to_S32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const float *src = (const float *) cvt->buf; - Sint32 *dst = (Sint32 *) cvt->buf; + const float *src = (const float *)cvt->buf; + Sint32 *dst = (Sint32 *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_S32 (using SSE2)"); /* Get dst aligned to 16 bytes */ - for (i = cvt->len_cvt / sizeof (float); i && (((size_t) dst) & 15); --i, ++src, ++dst) { + for (i = cvt->len_cvt / sizeof(float); i && (((size_t)dst) & 15); --i, ++src, ++dst) { const float sample = *src; if (sample >= 1.0f) { *dst = 2147483647; } else if (sample <= -1.0f) { - *dst = (Sint32) -2147483648LL; + *dst = (Sint32)-2147483648LL; } else { *dst = ((Sint32)(sample * 8388607.0f)) << 8; } } - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); - SDL_assert(!i || ((((size_t) src) & 15) == 0)); + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); + SDL_assert(!i || ((((size_t)src) & 15) == 0)); { /* Aligned! Do SSE blocks as long as we have 16 bytes available. */ const __m128 one = _mm_set1_ps(1.0f); const __m128 negone = _mm_set1_ps(-1.0f); const __m128 mulby8388607 = _mm_set1_ps(8388607.0f); - __m128i *mmdst = (__m128i *) dst; - while (i >= 4) { /* 4 * float32 */ - _mm_store_si128(mmdst, _mm_slli_epi32(_mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), mulby8388607)), 8)); /* load 4 floats, clamp, convert to sint32 */ - i -= 4; src += 4; mmdst++; + __m128i *mmdst = (__m128i *)dst; + while (i >= 4) { /* 4 * float32 */ + _mm_store_si128(mmdst, _mm_slli_epi32(_mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), mulby8388607)), 8)); /* load 4 floats, clamp, convert to sint32 */ + i -= 4; + src += 4; + mmdst++; } - dst = (Sint32 *) mmdst; + dst = (Sint32 *)mmdst; } /* Finish off any leftovers with scalar operations. */ @@ -836,11 +859,13 @@ SDL_Convert_F32_to_S32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) if (sample >= 1.0f) { *dst = 2147483647; } else if (sample <= -1.0f) { - *dst = (Sint32) -2147483648LL; + *dst = (Sint32)-2147483648LL; } else { *dst = ((Sint32)(sample * 8388607.0f)) << 8; } - i--; src++; dst++; + i--; + src++; + dst++; } if (cvt->filters[++cvt->filter_index]) { @@ -849,51 +874,55 @@ SDL_Convert_F32_to_S32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) } #endif - #if HAVE_NEON_INTRINSICS -static void SDLCALL -SDL_Convert_S8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_S8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Sint8 *src = ((const Sint8 *) (cvt->buf + cvt->len_cvt)) - 1; - float *dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1; + const Sint8 *src = ((const Sint8 *)(cvt->buf + cvt->len_cvt)) - 1; + float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; int i; LOG_DEBUG_CONVERT("AUDIO_S8", "AUDIO_F32 (using NEON)"); /* Get dst aligned to 16 bytes (since buffer is growing, we don't have to worry about overreading from src) */ - for (i = cvt->len_cvt; i && (((size_t) (dst-15)) & 15); --i, --src, --dst) { - *dst = ((float) *src) * DIVBY128; + for (i = cvt->len_cvt; i && (((size_t)(dst - 15)) & 15); --i, --src, --dst) { + *dst = ((float)*src) * DIVBY128; } - src -= 15; dst -= 15; /* adjust to read NEON blocks from the start. */ - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); + src -= 15; + dst -= 15; /* adjust to read NEON blocks from the start. */ + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); /* Make sure src is aligned too. */ - if ((((size_t) src) & 15) == 0) { + if ((((size_t)src) & 15) == 0) { /* Aligned! Do NEON blocks as long as we have 16 bytes available. */ - const int8_t *mmsrc = (const int8_t *) src; + const int8_t *mmsrc = (const int8_t *)src; const float32x4_t divby128 = vdupq_n_f32(DIVBY128); - while (i >= 16) { /* 16 * 8-bit */ - const int8x16_t bytes = vld1q_s8(mmsrc); /* get 16 sint8 into a NEON register. */ - const int16x8_t int16hi = vmovl_s8(vget_high_s8(bytes)); /* convert top 8 bytes to 8 int16 */ - const int16x8_t int16lo = vmovl_s8(vget_low_s8(bytes)); /* convert bottom 8 bytes to 8 int16 */ + while (i >= 16) { /* 16 * 8-bit */ + const int8x16_t bytes = vld1q_s8(mmsrc); /* get 16 sint8 into a NEON register. */ + const int16x8_t int16hi = vmovl_s8(vget_high_s8(bytes)); /* convert top 8 bytes to 8 int16 */ + const int16x8_t int16lo = vmovl_s8(vget_low_s8(bytes)); /* convert bottom 8 bytes to 8 int16 */ /* split int16 to two int32, then convert to float, then multiply to normalize, store. */ vst1q_f32(dst, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_low_s16(int16lo))), divby128)); - vst1q_f32(dst+4, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_high_s16(int16lo))), divby128)); - vst1q_f32(dst+8, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_low_s16(int16hi))), divby128)); - vst1q_f32(dst+12, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_high_s16(int16hi))), divby128)); - i -= 16; mmsrc -= 16; dst -= 16; + vst1q_f32(dst + 4, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_high_s16(int16lo))), divby128)); + vst1q_f32(dst + 8, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_low_s16(int16hi))), divby128)); + vst1q_f32(dst + 12, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_high_s16(int16hi))), divby128)); + i -= 16; + mmsrc -= 16; + dst -= 16; } - src = (const Sint8 *) mmsrc; + src = (const Sint8 *)mmsrc; } - src += 15; dst += 15; /* adjust for any scalar finishing. */ + src += 15; + dst += 15; /* adjust for any scalar finishing. */ /* Finish off any leftovers with scalar operations. */ while (i) { - *dst = ((float) *src) * DIVBY128; - i--; src--; dst--; + *dst = ((float)*src) * DIVBY128; + i--; + src--; + dst--; } cvt->len_cvt *= 4; @@ -902,50 +931,55 @@ SDL_Convert_S8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_U8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_U8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Uint8 *src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1; - float *dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1; + const Uint8 *src = ((const Uint8 *)(cvt->buf + cvt->len_cvt)) - 1; + float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; int i; LOG_DEBUG_CONVERT("AUDIO_U8", "AUDIO_F32 (using NEON)"); /* Get dst aligned to 16 bytes (since buffer is growing, we don't have to worry about overreading from src) */ - for (i = cvt->len_cvt; i && (((size_t) (dst-15)) & 15); --i, --src, --dst) { - *dst = (((float) *src) * DIVBY128) - 1.0f; + for (i = cvt->len_cvt; i && (((size_t)(dst - 15)) & 15); --i, --src, --dst) { + *dst = (((float)*src) * DIVBY128) - 1.0f; } - src -= 15; dst -= 15; /* adjust to read NEON blocks from the start. */ - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); + src -= 15; + dst -= 15; /* adjust to read NEON blocks from the start. */ + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); /* Make sure src is aligned too. */ - if ((((size_t) src) & 15) == 0) { + if ((((size_t)src) & 15) == 0) { /* Aligned! Do NEON blocks as long as we have 16 bytes available. */ - const uint8_t *mmsrc = (const uint8_t *) src; + const uint8_t *mmsrc = (const uint8_t *)src; const float32x4_t divby128 = vdupq_n_f32(DIVBY128); const float32x4_t negone = vdupq_n_f32(-1.0f); - while (i >= 16) { /* 16 * 8-bit */ - const uint8x16_t bytes = vld1q_u8(mmsrc); /* get 16 uint8 into a NEON register. */ - const uint16x8_t uint16hi = vmovl_u8(vget_high_u8(bytes)); /* convert top 8 bytes to 8 uint16 */ - const uint16x8_t uint16lo = vmovl_u8(vget_low_u8(bytes)); /* convert bottom 8 bytes to 8 uint16 */ + while (i >= 16) { /* 16 * 8-bit */ + const uint8x16_t bytes = vld1q_u8(mmsrc); /* get 16 uint8 into a NEON register. */ + const uint16x8_t uint16hi = vmovl_u8(vget_high_u8(bytes)); /* convert top 8 bytes to 8 uint16 */ + const uint16x8_t uint16lo = vmovl_u8(vget_low_u8(bytes)); /* convert bottom 8 bytes to 8 uint16 */ /* split uint16 to two uint32, then convert to float, then multiply to normalize, subtract to adjust for sign, store. */ vst1q_f32(dst, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_low_u16(uint16lo))), divby128)); - vst1q_f32(dst+4, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_high_u16(uint16lo))), divby128)); - vst1q_f32(dst+8, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_low_u16(uint16hi))), divby128)); - vst1q_f32(dst+12, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_high_u16(uint16hi))), divby128)); - i -= 16; mmsrc -= 16; dst -= 16; + vst1q_f32(dst + 4, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_high_u16(uint16lo))), divby128)); + vst1q_f32(dst + 8, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_low_u16(uint16hi))), divby128)); + vst1q_f32(dst + 12, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_high_u16(uint16hi))), divby128)); + i -= 16; + mmsrc -= 16; + dst -= 16; } - src = (const Uint8 *) mmsrc; + src = (const Uint8 *)mmsrc; } - src += 15; dst += 15; /* adjust for any scalar finishing. */ + src += 15; + dst += 15; /* adjust for any scalar finishing. */ /* Finish off any leftovers with scalar operations. */ while (i) { - *dst = (((float) *src) * DIVBY128) - 1.0f; - i--; src--; dst--; + *dst = (((float)*src) * DIVBY128) - 1.0f; + i--; + src--; + dst--; } cvt->len_cvt *= 4; @@ -954,42 +988,47 @@ SDL_Convert_U8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_S16_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_S16_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Sint16 *src = ((const Sint16 *) (cvt->buf + cvt->len_cvt)) - 1; - float *dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1; + const Sint16 *src = ((const Sint16 *)(cvt->buf + cvt->len_cvt)) - 1; + float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; int i; LOG_DEBUG_CONVERT("AUDIO_S16", "AUDIO_F32 (using NEON)"); /* Get dst aligned to 16 bytes (since buffer is growing, we don't have to worry about overreading from src) */ - for (i = cvt->len_cvt / sizeof (Sint16); i && (((size_t) (dst-7)) & 15); --i, --src, --dst) { - *dst = ((float) *src) * DIVBY32768; + for (i = cvt->len_cvt / sizeof(Sint16); i && (((size_t)(dst - 7)) & 15); --i, --src, --dst) { + *dst = ((float)*src) * DIVBY32768; } - src -= 7; dst -= 7; /* adjust to read NEON blocks from the start. */ - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); + src -= 7; + dst -= 7; /* adjust to read NEON blocks from the start. */ + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); /* Make sure src is aligned too. */ - if ((((size_t) src) & 15) == 0) { + if ((((size_t)src) & 15) == 0) { /* Aligned! Do NEON blocks as long as we have 16 bytes available. */ const float32x4_t divby32768 = vdupq_n_f32(DIVBY32768); - while (i >= 8) { /* 8 * 16-bit */ - const int16x8_t ints = vld1q_s16((int16_t const *) src); /* get 8 sint16 into a NEON register. */ + while (i >= 8) { /* 8 * 16-bit */ + const int16x8_t ints = vld1q_s16((int16_t const *)src); /* get 8 sint16 into a NEON register. */ /* split int16 to two int32, then convert to float, then multiply to normalize, store. */ vst1q_f32(dst, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_low_s16(ints))), divby32768)); - vst1q_f32(dst+4, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_high_s16(ints))), divby32768)); - i -= 8; src -= 8; dst -= 8; + vst1q_f32(dst + 4, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_high_s16(ints))), divby32768)); + i -= 8; + src -= 8; + dst -= 8; } } - src += 7; dst += 7; /* adjust for any scalar finishing. */ + src += 7; + dst += 7; /* adjust for any scalar finishing. */ /* Finish off any leftovers with scalar operations. */ while (i) { - *dst = ((float) *src) * DIVBY32768; - i--; src--; dst--; + *dst = ((float)*src) * DIVBY32768; + i--; + src--; + dst--; } cvt->len_cvt *= 2; @@ -998,43 +1037,48 @@ SDL_Convert_S16_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_U16_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_U16_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Uint16 *src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1; - float *dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1; + const Uint16 *src = ((const Uint16 *)(cvt->buf + cvt->len_cvt)) - 1; + float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; int i; LOG_DEBUG_CONVERT("AUDIO_U16", "AUDIO_F32 (using NEON)"); /* Get dst aligned to 16 bytes (since buffer is growing, we don't have to worry about overreading from src) */ - for (i = cvt->len_cvt / sizeof (Sint16); i && (((size_t) (dst-7)) & 15); --i, --src, --dst) { - *dst = (((float) *src) * DIVBY32768) - 1.0f; + for (i = cvt->len_cvt / sizeof(Sint16); i && (((size_t)(dst - 7)) & 15); --i, --src, --dst) { + *dst = (((float)*src) * DIVBY32768) - 1.0f; } - src -= 7; dst -= 7; /* adjust to read NEON blocks from the start. */ - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); + src -= 7; + dst -= 7; /* adjust to read NEON blocks from the start. */ + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); /* Make sure src is aligned too. */ - if ((((size_t) src) & 15) == 0) { + if ((((size_t)src) & 15) == 0) { /* Aligned! Do NEON blocks as long as we have 16 bytes available. */ const float32x4_t divby32768 = vdupq_n_f32(DIVBY32768); const float32x4_t negone = vdupq_n_f32(-1.0f); - while (i >= 8) { /* 8 * 16-bit */ - const uint16x8_t uints = vld1q_u16((uint16_t const *) src); /* get 8 uint16 into a NEON register. */ + while (i >= 8) { /* 8 * 16-bit */ + const uint16x8_t uints = vld1q_u16((uint16_t const *)src); /* get 8 uint16 into a NEON register. */ /* split uint16 to two int32, then convert to float, then multiply to normalize, subtract for sign, store. */ vst1q_f32(dst, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_low_u16(uints))), divby32768)); - vst1q_f32(dst+4, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_high_u16(uints))), divby32768)); - i -= 8; src -= 8; dst -= 8; + vst1q_f32(dst + 4, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_high_u16(uints))), divby32768)); + i -= 8; + src -= 8; + dst -= 8; } } - src += 7; dst += 7; /* adjust for any scalar finishing. */ + src += 7; + dst += 7; /* adjust for any scalar finishing. */ /* Finish off any leftovers with scalar operations. */ while (i) { - *dst = (((float) *src) * DIVBY32768) - 1.0f; - i--; src--; dst--; + *dst = (((float)*src) * DIVBY32768) - 1.0f; + i--; + src--; + dst--; } cvt->len_cvt *= 2; @@ -1043,39 +1087,42 @@ SDL_Convert_U16_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_S32_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_S32_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Sint32 *src = (const Sint32 *) cvt->buf; - float *dst = (float *) cvt->buf; + const Sint32 *src = (const Sint32 *)cvt->buf; + float *dst = (float *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_S32", "AUDIO_F32 (using NEON)"); /* Get dst aligned to 16 bytes */ - for (i = cvt->len_cvt / sizeof (Sint32); i && (((size_t) dst) & 15); --i, ++src, ++dst) { - *dst = ((float) (*src>>8)) * DIVBY8388607; + for (i = cvt->len_cvt / sizeof(Sint32); i && (((size_t)dst) & 15); --i, ++src, ++dst) { + *dst = ((float)(*src >> 8)) * DIVBY8388607; } - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); /* Make sure src is aligned too. */ - if ((((size_t) src) & 15) == 0) { + if ((((size_t)src) & 15) == 0) { /* Aligned! Do NEON blocks as long as we have 16 bytes available. */ const float32x4_t divby8388607 = vdupq_n_f32(DIVBY8388607); - const int32_t *mmsrc = (const int32_t *) src; - while (i >= 4) { /* 4 * sint32 */ + const int32_t *mmsrc = (const int32_t *)src; + while (i >= 4) { /* 4 * sint32 */ /* shift out lowest bits so int fits in a float32. Small precision loss, but much faster. */ vst1q_f32(dst, vmulq_f32(vcvtq_f32_s32(vshrq_n_s32(vld1q_s32(mmsrc), 8)), divby8388607)); - i -= 4; mmsrc += 4; dst += 4; + i -= 4; + mmsrc += 4; + dst += 4; } - src = (const Sint32 *) mmsrc; + src = (const Sint32 *)mmsrc; } /* Finish off any leftovers with scalar operations. */ while (i) { - *dst = ((float) (*src>>8)) * DIVBY8388607; - i--; src++; dst++; + *dst = ((float)(*src >> 8)) * DIVBY8388607; + i--; + src++; + dst++; } if (cvt->filters[++cvt->filter_index]) { @@ -1083,17 +1130,16 @@ SDL_Convert_S32_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_F32_to_S8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_F32_to_S8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const float *src = (const float *) cvt->buf; - Sint8 *dst = (Sint8 *) cvt->buf; + const float *src = (const float *)cvt->buf; + Sint8 *dst = (Sint8 *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_S8 (using NEON)"); /* Get dst aligned to 16 bytes */ - for (i = cvt->len_cvt / sizeof (float); i && (((size_t) dst) & 15); --i, ++src, ++dst) { + for (i = cvt->len_cvt / sizeof(float); i && (((size_t)dst) & 15); --i, ++src, ++dst) { const float sample = *src; if (sample >= 1.0f) { *dst = 127; @@ -1104,26 +1150,28 @@ SDL_Convert_F32_to_S8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); /* Make sure src is aligned too. */ - if ((((size_t) src) & 15) == 0) { + if ((((size_t)src) & 15) == 0) { /* Aligned! Do NEON blocks as long as we have 16 bytes available. */ const float32x4_t one = vdupq_n_f32(1.0f); const float32x4_t negone = vdupq_n_f32(-1.0f); const float32x4_t mulby127 = vdupq_n_f32(127.0f); - int8_t *mmdst = (int8_t *) dst; - while (i >= 16) { /* 16 * float32 */ - const int32x4_t ints1 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const int32x4_t ints2 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src+4)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const int32x4_t ints3 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src+8)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const int32x4_t ints4 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src+12)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const int8x8_t i8lo = vmovn_s16(vcombine_s16(vmovn_s32(ints1), vmovn_s32(ints2))); /* narrow to sint16, combine, narrow to sint8 */ - const int8x8_t i8hi = vmovn_s16(vcombine_s16(vmovn_s32(ints3), vmovn_s32(ints4))); /* narrow to sint16, combine, narrow to sint8 */ - vst1q_s8(mmdst, vcombine_s8(i8lo, i8hi)); /* combine to int8x16_t, store out */ - i -= 16; src += 16; mmdst += 16; + int8_t *mmdst = (int8_t *)dst; + while (i >= 16) { /* 16 * float32 */ + const int32x4_t ints1 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ + const int32x4_t ints2 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 4)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ + const int32x4_t ints3 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 8)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ + const int32x4_t ints4 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 12)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ + const int8x8_t i8lo = vmovn_s16(vcombine_s16(vmovn_s32(ints1), vmovn_s32(ints2))); /* narrow to sint16, combine, narrow to sint8 */ + const int8x8_t i8hi = vmovn_s16(vcombine_s16(vmovn_s32(ints3), vmovn_s32(ints4))); /* narrow to sint16, combine, narrow to sint8 */ + vst1q_s8(mmdst, vcombine_s8(i8lo, i8hi)); /* combine to int8x16_t, store out */ + i -= 16; + src += 16; + mmdst += 16; } - dst = (Sint8 *) mmdst; + dst = (Sint8 *)mmdst; } /* Finish off any leftovers with scalar operations. */ @@ -1136,7 +1184,9 @@ SDL_Convert_F32_to_S8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } else { *dst = (Sint8)(sample * 127.0f); } - i--; src++; dst++; + i--; + src++; + dst++; } cvt->len_cvt /= 4; @@ -1145,17 +1195,16 @@ SDL_Convert_F32_to_S8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_F32_to_U8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_F32_to_U8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const float *src = (const float *) cvt->buf; - Uint8 *dst = (Uint8 *) cvt->buf; + const float *src = (const float *)cvt->buf; + Uint8 *dst = (Uint8 *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_U8 (using NEON)"); /* Get dst aligned to 16 bytes */ - for (i = cvt->len_cvt / sizeof (float); i && (((size_t) dst) & 15); --i, ++src, ++dst) { + for (i = cvt->len_cvt / sizeof(float); i && (((size_t)dst) & 15); --i, ++src, ++dst) { const float sample = *src; if (sample >= 1.0f) { *dst = 255; @@ -1166,27 +1215,29 @@ SDL_Convert_F32_to_U8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); /* Make sure src is aligned too. */ - if ((((size_t) src) & 15) == 0) { + if ((((size_t)src) & 15) == 0) { /* Aligned! Do NEON blocks as long as we have 16 bytes available. */ const float32x4_t one = vdupq_n_f32(1.0f); const float32x4_t negone = vdupq_n_f32(-1.0f); const float32x4_t mulby127 = vdupq_n_f32(127.0f); - uint8_t *mmdst = (uint8_t *) dst; - while (i >= 16) { /* 16 * float32 */ - const uint32x4_t uints1 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), one), mulby127)); /* load 4 floats, clamp, convert to uint32 */ - const uint32x4_t uints2 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src+4)), one), one), mulby127)); /* load 4 floats, clamp, convert to uint32 */ - const uint32x4_t uints3 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src+8)), one), one), mulby127)); /* load 4 floats, clamp, convert to uint32 */ - const uint32x4_t uints4 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src+12)), one), one), mulby127)); /* load 4 floats, clamp, convert to uint32 */ - const uint8x8_t ui8lo = vmovn_u16(vcombine_u16(vmovn_u32(uints1), vmovn_u32(uints2))); /* narrow to uint16, combine, narrow to uint8 */ - const uint8x8_t ui8hi = vmovn_u16(vcombine_u16(vmovn_u32(uints3), vmovn_u32(uints4))); /* narrow to uint16, combine, narrow to uint8 */ - vst1q_u8(mmdst, vcombine_u8(ui8lo, ui8hi)); /* combine to uint8x16_t, store out */ - i -= 16; src += 16; mmdst += 16; + uint8_t *mmdst = (uint8_t *)dst; + while (i >= 16) { /* 16 * float32 */ + const uint32x4_t uints1 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), one), mulby127)); /* load 4 floats, clamp, convert to uint32 */ + const uint32x4_t uints2 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 4)), one), one), mulby127)); /* load 4 floats, clamp, convert to uint32 */ + const uint32x4_t uints3 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 8)), one), one), mulby127)); /* load 4 floats, clamp, convert to uint32 */ + const uint32x4_t uints4 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 12)), one), one), mulby127)); /* load 4 floats, clamp, convert to uint32 */ + const uint8x8_t ui8lo = vmovn_u16(vcombine_u16(vmovn_u32(uints1), vmovn_u32(uints2))); /* narrow to uint16, combine, narrow to uint8 */ + const uint8x8_t ui8hi = vmovn_u16(vcombine_u16(vmovn_u32(uints3), vmovn_u32(uints4))); /* narrow to uint16, combine, narrow to uint8 */ + vst1q_u8(mmdst, vcombine_u8(ui8lo, ui8hi)); /* combine to uint8x16_t, store out */ + i -= 16; + src += 16; + mmdst += 16; } - dst = (Uint8 *) mmdst; + dst = (Uint8 *)mmdst; } /* Finish off any leftovers with scalar operations. */ @@ -1199,7 +1250,9 @@ SDL_Convert_F32_to_U8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } else { *dst = (Uint8)((sample + 1.0f) * 127.0f); } - i--; src++; dst++; + i--; + src++; + dst++; } cvt->len_cvt /= 4; @@ -1208,17 +1261,16 @@ SDL_Convert_F32_to_U8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_F32_to_S16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_F32_to_S16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const float *src = (const float *) cvt->buf; - Sint16 *dst = (Sint16 *) cvt->buf; + const float *src = (const float *)cvt->buf; + Sint16 *dst = (Sint16 *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_S16 (using NEON)"); /* Get dst aligned to 16 bytes */ - for (i = cvt->len_cvt / sizeof (float); i && (((size_t) dst) & 15); --i, ++src, ++dst) { + for (i = cvt->len_cvt / sizeof(float); i && (((size_t)dst) & 15); --i, ++src, ++dst) { const float sample = *src; if (sample >= 1.0f) { *dst = 32767; @@ -1229,22 +1281,24 @@ SDL_Convert_F32_to_S16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); /* Make sure src is aligned too. */ - if ((((size_t) src) & 15) == 0) { + if ((((size_t)src) & 15) == 0) { /* Aligned! Do NEON blocks as long as we have 16 bytes available. */ const float32x4_t one = vdupq_n_f32(1.0f); const float32x4_t negone = vdupq_n_f32(-1.0f); const float32x4_t mulby32767 = vdupq_n_f32(32767.0f); - int16_t *mmdst = (int16_t *) dst; - while (i >= 8) { /* 8 * float32 */ - const int32x4_t ints1 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ - const int32x4_t ints2 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src+4)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ - vst1q_s16(mmdst, vcombine_s16(vmovn_s32(ints1), vmovn_s32(ints2))); /* narrow to sint16, combine, store out. */ - i -= 8; src += 8; mmdst += 8; + int16_t *mmdst = (int16_t *)dst; + while (i >= 8) { /* 8 * float32 */ + const int32x4_t ints1 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ + const int32x4_t ints2 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 4)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ + vst1q_s16(mmdst, vcombine_s16(vmovn_s32(ints1), vmovn_s32(ints2))); /* narrow to sint16, combine, store out. */ + i -= 8; + src += 8; + mmdst += 8; } - dst = (Sint16 *) mmdst; + dst = (Sint16 *)mmdst; } /* Finish off any leftovers with scalar operations. */ @@ -1257,7 +1311,9 @@ SDL_Convert_F32_to_S16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } else { *dst = (Sint16)(sample * 32767.0f); } - i--; src++; dst++; + i--; + src++; + dst++; } cvt->len_cvt /= 2; @@ -1266,17 +1322,16 @@ SDL_Convert_F32_to_S16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_F32_to_U16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_F32_to_U16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const float *src = (const float *) cvt->buf; - Uint16 *dst = (Uint16 *) cvt->buf; + const float *src = (const float *)cvt->buf; + Uint16 *dst = (Uint16 *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_U16 (using NEON)"); /* Get dst aligned to 16 bytes */ - for (i = cvt->len_cvt / sizeof (float); i && (((size_t) dst) & 15); --i, ++src, ++dst) { + for (i = cvt->len_cvt / sizeof(float); i && (((size_t)dst) & 15); --i, ++src, ++dst) { const float sample = *src; if (sample >= 1.0f) { *dst = 65535; @@ -1287,22 +1342,24 @@ SDL_Convert_F32_to_U16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); /* Make sure src is aligned too. */ - if ((((size_t) src) & 15) == 0) { + if ((((size_t)src) & 15) == 0) { /* Aligned! Do NEON blocks as long as we have 16 bytes available. */ const float32x4_t one = vdupq_n_f32(1.0f); const float32x4_t negone = vdupq_n_f32(-1.0f); const float32x4_t mulby32767 = vdupq_n_f32(32767.0f); - uint16_t *mmdst = (uint16_t *) dst; - while (i >= 8) { /* 8 * float32 */ - const uint32x4_t uints1 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), one), mulby32767)); /* load 4 floats, clamp, convert to uint32 */ - const uint32x4_t uints2 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src+4)), one), one), mulby32767)); /* load 4 floats, clamp, convert to uint32 */ - vst1q_u16(mmdst, vcombine_u16(vmovn_u32(uints1), vmovn_u32(uints2))); /* narrow to uint16, combine, store out. */ - i -= 8; src += 8; mmdst += 8; + uint16_t *mmdst = (uint16_t *)dst; + while (i >= 8) { /* 8 * float32 */ + const uint32x4_t uints1 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), one), mulby32767)); /* load 4 floats, clamp, convert to uint32 */ + const uint32x4_t uints2 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 4)), one), one), mulby32767)); /* load 4 floats, clamp, convert to uint32 */ + vst1q_u16(mmdst, vcombine_u16(vmovn_u32(uints1), vmovn_u32(uints2))); /* narrow to uint16, combine, store out. */ + i -= 8; + src += 8; + mmdst += 8; } - dst = (Uint16 *) mmdst; + dst = (Uint16 *)mmdst; } /* Finish off any leftovers with scalar operations. */ @@ -1315,7 +1372,9 @@ SDL_Convert_F32_to_U16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } else { *dst = (Uint16)((sample + 1.0f) * 32767.0f); } - i--; src++; dst++; + i--; + src++; + dst++; } cvt->len_cvt /= 2; @@ -1324,17 +1383,16 @@ SDL_Convert_F32_to_U16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } -static void SDLCALL -SDL_Convert_F32_to_S32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) +static void SDLCALL SDL_Convert_F32_to_S32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const float *src = (const float *) cvt->buf; - Sint32 *dst = (Sint32 *) cvt->buf; + const float *src = (const float *)cvt->buf; + Sint32 *dst = (Sint32 *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_S32 (using NEON)"); /* Get dst aligned to 16 bytes */ - for (i = cvt->len_cvt / sizeof (float); i && (((size_t) dst) & 15); --i, ++src, ++dst) { + for (i = cvt->len_cvt / sizeof(float); i && (((size_t)dst) & 15); --i, ++src, ++dst) { const float sample = *src; if (sample >= 1.0f) { *dst = 2147483647; @@ -1345,20 +1403,22 @@ SDL_Convert_F32_to_S32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } } - SDL_assert(!i || ((((size_t) dst) & 15) == 0)); - SDL_assert(!i || ((((size_t) src) & 15) == 0)); + SDL_assert(!i || ((((size_t)dst) & 15) == 0)); + SDL_assert(!i || ((((size_t)src) & 15) == 0)); { /* Aligned! Do NEON blocks as long as we have 16 bytes available. */ const float32x4_t one = vdupq_n_f32(1.0f); const float32x4_t negone = vdupq_n_f32(-1.0f); const float32x4_t mulby8388607 = vdupq_n_f32(8388607.0f); - int32_t *mmdst = (int32_t *) dst; - while (i >= 4) { /* 4 * float32 */ + int32_t *mmdst = (int32_t *)dst; + while (i >= 4) { /* 4 * float32 */ vst1q_s32(mmdst, vshlq_n_s32(vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), mulby8388607)), 8)); - i -= 4; src += 4; mmdst += 4; + i -= 4; + src += 4; + mmdst += 4; } - dst = (Sint32 *) mmdst; + dst = (Sint32 *)mmdst; } /* Finish off any leftovers with scalar operations. */ @@ -1371,7 +1431,9 @@ SDL_Convert_F32_to_S32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } else { *dst = ((Sint32)(sample * 8388607.0f)) << 8; } - i--; src++; dst++; + i--; + src++; + dst++; } if (cvt->filters[++cvt->filter_index]) { @@ -1380,8 +1442,6 @@ SDL_Convert_F32_to_S32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) } #endif - - void SDL_ChooseAudioConverters(void) { static SDL_bool converters_chosen = SDL_FALSE; @@ -1390,18 +1450,18 @@ void SDL_ChooseAudioConverters(void) return; } -#define SET_CONVERTER_FUNCS(fntype) \ - SDL_Convert_S8_to_F32 = SDL_Convert_S8_to_F32_##fntype; \ - SDL_Convert_U8_to_F32 = SDL_Convert_U8_to_F32_##fntype; \ - SDL_Convert_S16_to_F32 = SDL_Convert_S16_to_F32_##fntype; \ - SDL_Convert_U16_to_F32 = SDL_Convert_U16_to_F32_##fntype; \ - SDL_Convert_S32_to_F32 = SDL_Convert_S32_to_F32_##fntype; \ - SDL_Convert_F32_to_S8 = SDL_Convert_F32_to_S8_##fntype; \ - SDL_Convert_F32_to_U8 = SDL_Convert_F32_to_U8_##fntype; \ - SDL_Convert_F32_to_S16 = SDL_Convert_F32_to_S16_##fntype; \ - SDL_Convert_F32_to_U16 = SDL_Convert_F32_to_U16_##fntype; \ - SDL_Convert_F32_to_S32 = SDL_Convert_F32_to_S32_##fntype; \ - converters_chosen = SDL_TRUE +#define SET_CONVERTER_FUNCS(fntype) \ + SDL_Convert_S8_to_F32 = SDL_Convert_S8_to_F32_##fntype; \ + SDL_Convert_U8_to_F32 = SDL_Convert_U8_to_F32_##fntype; \ + SDL_Convert_S16_to_F32 = SDL_Convert_S16_to_F32_##fntype; \ + SDL_Convert_U16_to_F32 = SDL_Convert_U16_to_F32_##fntype; \ + SDL_Convert_S32_to_F32 = SDL_Convert_S32_to_F32_##fntype; \ + SDL_Convert_F32_to_S8 = SDL_Convert_F32_to_S8_##fntype; \ + SDL_Convert_F32_to_U8 = SDL_Convert_F32_to_U8_##fntype; \ + SDL_Convert_F32_to_S16 = SDL_Convert_F32_to_S16_##fntype; \ + SDL_Convert_F32_to_U16 = SDL_Convert_F32_to_U16_##fntype; \ + SDL_Convert_F32_to_S32 = SDL_Convert_F32_to_S32_##fntype; \ + converters_chosen = SDL_TRUE #if HAVE_SSE2_INTRINSICS if (SDL_HasSSE2()) { diff --git a/src/audio/SDL_mixer.c b/src/audio/SDL_mixer.c index 9c9e5df21..898e0e7e2 100644 --- a/src/audio/SDL_mixer.c +++ b/src/audio/SDL_mixer.c @@ -81,14 +81,12 @@ static const Uint8 mix8[] = { }; /* The volume ranges from 0 - 128 */ -#define ADJUST_VOLUME(s, v) (s = (s*v)/SDL_MIX_MAXVOLUME) -#define ADJUST_VOLUME_U8(s, v) (s = (((s-128)*v)/SDL_MIX_MAXVOLUME)+128) -#define ADJUST_VOLUME_U16(s, v) (s = (((s-32768)*v)/SDL_MIX_MAXVOLUME)+32768) +#define ADJUST_VOLUME(s, v) (s = (s * v) / SDL_MIX_MAXVOLUME) +#define ADJUST_VOLUME_U8(s, v) (s = (((s - 128) * v) / SDL_MIX_MAXVOLUME) + 128) +#define ADJUST_VOLUME_U16(s, v) (s = (((s - 32768) * v) / SDL_MIX_MAXVOLUME) + 32768) - -void -SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format, - Uint32 len, int volume) +void SDL_MixAudioFormat(Uint8 *dst, const Uint8 *src, SDL_AudioFormat format, + Uint32 len, int volume) { if (volume == 0) { return; @@ -97,258 +95,248 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format, switch (format) { case AUDIO_U8: - { - Uint8 src_sample; + { + Uint8 src_sample; - while (len--) { - src_sample = *src; - ADJUST_VOLUME_U8(src_sample, volume); - *dst = mix8[*dst + src_sample]; - ++dst; - ++src; - } + while (len--) { + src_sample = *src; + ADJUST_VOLUME_U8(src_sample, volume); + *dst = mix8[*dst + src_sample]; + ++dst; + ++src; } - break; + } break; case AUDIO_S8: - { - Sint8 *dst8, *src8; - Sint8 src_sample; - int dst_sample; - const int max_audioval = SDL_MAX_SINT8; - const int min_audioval = SDL_MIN_SINT8; + { + Sint8 *dst8, *src8; + Sint8 src_sample; + int dst_sample; + const int max_audioval = SDL_MAX_SINT8; + const int min_audioval = SDL_MIN_SINT8; - src8 = (Sint8 *) src; - dst8 = (Sint8 *) dst; - while (len--) { - src_sample = *src8; - ADJUST_VOLUME(src_sample, volume); - dst_sample = *dst8 + src_sample; - if (dst_sample > max_audioval) { - dst_sample = max_audioval; - } else if (dst_sample < min_audioval) { - dst_sample = min_audioval; - } - *dst8 = dst_sample; - ++dst8; - ++src8; + src8 = (Sint8 *)src; + dst8 = (Sint8 *)dst; + while (len--) { + src_sample = *src8; + ADJUST_VOLUME(src_sample, volume); + dst_sample = *dst8 + src_sample; + if (dst_sample > max_audioval) { + dst_sample = max_audioval; + } else if (dst_sample < min_audioval) { + dst_sample = min_audioval; } + *dst8 = dst_sample; + ++dst8; + ++src8; } - break; + } break; case AUDIO_S16LSB: - { - Sint16 src1, src2; - int dst_sample; - const int max_audioval = SDL_MAX_SINT16; - const int min_audioval = SDL_MIN_SINT16; + { + Sint16 src1, src2; + int dst_sample; + const int max_audioval = SDL_MAX_SINT16; + const int min_audioval = SDL_MIN_SINT16; - len /= 2; - while (len--) { - src1 = SDL_SwapLE16(*(Sint16 *)src); - ADJUST_VOLUME(src1, volume); - src2 = SDL_SwapLE16(*(Sint16 *)dst); - src += 2; - dst_sample = src1 + src2; - if (dst_sample > max_audioval) { - dst_sample = max_audioval; - } else if (dst_sample < min_audioval) { - dst_sample = min_audioval; - } - *(Sint16 *)dst = SDL_SwapLE16(dst_sample); - dst += 2; + len /= 2; + while (len--) { + src1 = SDL_SwapLE16(*(Sint16 *)src); + ADJUST_VOLUME(src1, volume); + src2 = SDL_SwapLE16(*(Sint16 *)dst); + src += 2; + dst_sample = src1 + src2; + if (dst_sample > max_audioval) { + dst_sample = max_audioval; + } else if (dst_sample < min_audioval) { + dst_sample = min_audioval; } + *(Sint16 *)dst = SDL_SwapLE16(dst_sample); + dst += 2; } - break; + } break; case AUDIO_S16MSB: - { - Sint16 src1, src2; - int dst_sample; - const int max_audioval = SDL_MAX_SINT16; - const int min_audioval = SDL_MIN_SINT16; + { + Sint16 src1, src2; + int dst_sample; + const int max_audioval = SDL_MAX_SINT16; + const int min_audioval = SDL_MIN_SINT16; - len /= 2; - while (len--) { - src1 = SDL_SwapBE16(*(Sint16 *)src); - ADJUST_VOLUME(src1, volume); - src2 = SDL_SwapBE16(*(Sint16 *)dst); - src += 2; - dst_sample = src1 + src2; - if (dst_sample > max_audioval) { - dst_sample = max_audioval; - } else if (dst_sample < min_audioval) { - dst_sample = min_audioval; - } - *(Sint16 *)dst = SDL_SwapBE16(dst_sample); - dst += 2; + len /= 2; + while (len--) { + src1 = SDL_SwapBE16(*(Sint16 *)src); + ADJUST_VOLUME(src1, volume); + src2 = SDL_SwapBE16(*(Sint16 *)dst); + src += 2; + dst_sample = src1 + src2; + if (dst_sample > max_audioval) { + dst_sample = max_audioval; + } else if (dst_sample < min_audioval) { + dst_sample = min_audioval; } + *(Sint16 *)dst = SDL_SwapBE16(dst_sample); + dst += 2; } - break; + } break; case AUDIO_U16LSB: - { - Uint16 src1, src2; - int dst_sample; - const int max_audioval = SDL_MAX_SINT16; - const int min_audioval = SDL_MIN_SINT16; + { + Uint16 src1, src2; + int dst_sample; + const int max_audioval = SDL_MAX_SINT16; + const int min_audioval = SDL_MIN_SINT16; - len /= 2; - while (len--) { - src1 = SDL_SwapLE16(*(Uint16 *)src); - ADJUST_VOLUME_U16(src1, volume); - src2 = SDL_SwapLE16(*(Uint16 *)dst); - src += 2; - dst_sample = src1 + src2 - 32768 * 2; - if (dst_sample > max_audioval) { - dst_sample = max_audioval; - } else if (dst_sample < min_audioval) { - dst_sample = min_audioval; - } - dst_sample += 32768; - *(Uint16 *)dst = SDL_SwapLE16(dst_sample); - dst += 2; + len /= 2; + while (len--) { + src1 = SDL_SwapLE16(*(Uint16 *)src); + ADJUST_VOLUME_U16(src1, volume); + src2 = SDL_SwapLE16(*(Uint16 *)dst); + src += 2; + dst_sample = src1 + src2 - 32768 * 2; + if (dst_sample > max_audioval) { + dst_sample = max_audioval; + } else if (dst_sample < min_audioval) { + dst_sample = min_audioval; } + dst_sample += 32768; + *(Uint16 *)dst = SDL_SwapLE16(dst_sample); + dst += 2; } - break; + } break; case AUDIO_U16MSB: - { - Uint16 src1, src2; - int dst_sample; - const int max_audioval = SDL_MAX_SINT16; - const int min_audioval = SDL_MIN_SINT16; + { + Uint16 src1, src2; + int dst_sample; + const int max_audioval = SDL_MAX_SINT16; + const int min_audioval = SDL_MIN_SINT16; - len /= 2; - while (len--) { - src1 = SDL_SwapBE16(*(Uint16 *)src); - ADJUST_VOLUME_U16(src1, volume); - src2 = SDL_SwapBE16(*(Uint16 *)dst); - src += 2; - dst_sample = src1 + src2 - 32768 * 2; - if (dst_sample > max_audioval) { - dst_sample = max_audioval; - } else if (dst_sample < min_audioval) { - dst_sample = min_audioval; - } - dst_sample += 32768; - *(Uint16 *)dst = SDL_SwapBE16(dst_sample); - dst += 2; + len /= 2; + while (len--) { + src1 = SDL_SwapBE16(*(Uint16 *)src); + ADJUST_VOLUME_U16(src1, volume); + src2 = SDL_SwapBE16(*(Uint16 *)dst); + src += 2; + dst_sample = src1 + src2 - 32768 * 2; + if (dst_sample > max_audioval) { + dst_sample = max_audioval; + } else if (dst_sample < min_audioval) { + dst_sample = min_audioval; } + dst_sample += 32768; + *(Uint16 *)dst = SDL_SwapBE16(dst_sample); + dst += 2; } - break; + } break; case AUDIO_S32LSB: - { - const Uint32 *src32 = (Uint32 *) src; - Uint32 *dst32 = (Uint32 *) dst; - Sint64 src1, src2; - Sint64 dst_sample; - const Sint64 max_audioval = SDL_MAX_SINT32; - const Sint64 min_audioval = SDL_MIN_SINT32; + { + const Uint32 *src32 = (Uint32 *)src; + Uint32 *dst32 = (Uint32 *)dst; + Sint64 src1, src2; + Sint64 dst_sample; + const Sint64 max_audioval = SDL_MAX_SINT32; + const Sint64 min_audioval = SDL_MIN_SINT32; - len /= 4; - while (len--) { - src1 = (Sint64) ((Sint32) SDL_SwapLE32(*src32)); - src32++; - ADJUST_VOLUME(src1, volume); - src2 = (Sint64) ((Sint32) SDL_SwapLE32(*dst32)); - dst_sample = src1 + src2; - if (dst_sample > max_audioval) { - dst_sample = max_audioval; - } else if (dst_sample < min_audioval) { - dst_sample = min_audioval; - } - *(dst32++) = SDL_SwapLE32((Uint32) ((Sint32) dst_sample)); + len /= 4; + while (len--) { + src1 = (Sint64)((Sint32)SDL_SwapLE32(*src32)); + src32++; + ADJUST_VOLUME(src1, volume); + src2 = (Sint64)((Sint32)SDL_SwapLE32(*dst32)); + dst_sample = src1 + src2; + if (dst_sample > max_audioval) { + dst_sample = max_audioval; + } else if (dst_sample < min_audioval) { + dst_sample = min_audioval; } + *(dst32++) = SDL_SwapLE32((Uint32)((Sint32)dst_sample)); } - break; + } break; case AUDIO_S32MSB: - { - const Uint32 *src32 = (Uint32 *) src; - Uint32 *dst32 = (Uint32 *) dst; - Sint64 src1, src2; - Sint64 dst_sample; - const Sint64 max_audioval = SDL_MAX_SINT32; - const Sint64 min_audioval = SDL_MIN_SINT32; + { + const Uint32 *src32 = (Uint32 *)src; + Uint32 *dst32 = (Uint32 *)dst; + Sint64 src1, src2; + Sint64 dst_sample; + const Sint64 max_audioval = SDL_MAX_SINT32; + const Sint64 min_audioval = SDL_MIN_SINT32; - len /= 4; - while (len--) { - src1 = (Sint64) ((Sint32) SDL_SwapBE32(*src32)); - src32++; - ADJUST_VOLUME(src1, volume); - src2 = (Sint64) ((Sint32) SDL_SwapBE32(*dst32)); - dst_sample = src1 + src2; - if (dst_sample > max_audioval) { - dst_sample = max_audioval; - } else if (dst_sample < min_audioval) { - dst_sample = min_audioval; - } - *(dst32++) = SDL_SwapBE32((Uint32) ((Sint32) dst_sample)); + len /= 4; + while (len--) { + src1 = (Sint64)((Sint32)SDL_SwapBE32(*src32)); + src32++; + ADJUST_VOLUME(src1, volume); + src2 = (Sint64)((Sint32)SDL_SwapBE32(*dst32)); + dst_sample = src1 + src2; + if (dst_sample > max_audioval) { + dst_sample = max_audioval; + } else if (dst_sample < min_audioval) { + dst_sample = min_audioval; } + *(dst32++) = SDL_SwapBE32((Uint32)((Sint32)dst_sample)); } - break; + } break; case AUDIO_F32LSB: - { - const float fmaxvolume = 1.0f / ((float) SDL_MIX_MAXVOLUME); - const float fvolume = (float) volume; - const float *src32 = (float *) src; - float *dst32 = (float *) dst; - float src1, src2; - double dst_sample; - /* !!! FIXME: are these right? */ - const double max_audioval = 3.402823466e+38F; - const double min_audioval = -3.402823466e+38F; + { + const float fmaxvolume = 1.0f / ((float)SDL_MIX_MAXVOLUME); + const float fvolume = (float)volume; + const float *src32 = (float *)src; + float *dst32 = (float *)dst; + float src1, src2; + double dst_sample; + /* !!! FIXME: are these right? */ + const double max_audioval = 3.402823466e+38F; + const double min_audioval = -3.402823466e+38F; - len /= 4; - while (len--) { - src1 = ((SDL_SwapFloatLE(*src32) * fvolume) * fmaxvolume); - src2 = SDL_SwapFloatLE(*dst32); - src32++; + len /= 4; + while (len--) { + src1 = ((SDL_SwapFloatLE(*src32) * fvolume) * fmaxvolume); + src2 = SDL_SwapFloatLE(*dst32); + src32++; - dst_sample = ((double) src1) + ((double) src2); - if (dst_sample > max_audioval) { - dst_sample = max_audioval; - } else if (dst_sample < min_audioval) { - dst_sample = min_audioval; - } - *(dst32++) = SDL_SwapFloatLE((float) dst_sample); + dst_sample = ((double)src1) + ((double)src2); + if (dst_sample > max_audioval) { + dst_sample = max_audioval; + } else if (dst_sample < min_audioval) { + dst_sample = min_audioval; } + *(dst32++) = SDL_SwapFloatLE((float)dst_sample); } - break; + } break; case AUDIO_F32MSB: - { - const float fmaxvolume = 1.0f / ((float) SDL_MIX_MAXVOLUME); - const float fvolume = (float) volume; - const float *src32 = (float *) src; - float *dst32 = (float *) dst; - float src1, src2; - double dst_sample; - /* !!! FIXME: are these right? */ - const double max_audioval = 3.402823466e+38F; - const double min_audioval = -3.402823466e+38F; + { + const float fmaxvolume = 1.0f / ((float)SDL_MIX_MAXVOLUME); + const float fvolume = (float)volume; + const float *src32 = (float *)src; + float *dst32 = (float *)dst; + float src1, src2; + double dst_sample; + /* !!! FIXME: are these right? */ + const double max_audioval = 3.402823466e+38F; + const double min_audioval = -3.402823466e+38F; - len /= 4; - while (len--) { - src1 = ((SDL_SwapFloatBE(*src32) * fvolume) * fmaxvolume); - src2 = SDL_SwapFloatBE(*dst32); - src32++; + len /= 4; + while (len--) { + src1 = ((SDL_SwapFloatBE(*src32) * fvolume) * fmaxvolume); + src2 = SDL_SwapFloatBE(*dst32); + src32++; - dst_sample = ((double) src1) + ((double) src2); - if (dst_sample > max_audioval) { - dst_sample = max_audioval; - } else if (dst_sample < min_audioval) { - dst_sample = min_audioval; - } - *(dst32++) = SDL_SwapFloatBE((float) dst_sample); + dst_sample = ((double)src1) + ((double)src2); + if (dst_sample > max_audioval) { + dst_sample = max_audioval; + } else if (dst_sample < min_audioval) { + dst_sample = min_audioval; } + *(dst32++) = SDL_SwapFloatBE((float)dst_sample); } - break; + } break; - default: /* If this happens... FIXME! */ + default: /* If this happens... FIXME! */ SDL_SetError("SDL_MixAudioFormat(): unknown audio format"); return; } diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index a911de041..708c0eea4 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -30,11 +30,11 @@ /* !!! FIXME: These are wordy and unlocalized... */ #define DEFAULT_OUTPUT_DEVNAME "System audio output device" -#define DEFAULT_INPUT_DEVNAME "System audio capture device" +#define DEFAULT_INPUT_DEVNAME "System audio capture device" /* The SDL audio driver */ typedef struct SDL_AudioDevice SDL_AudioDevice; -#define _THIS SDL_AudioDevice *_this +#define _THIS SDL_AudioDevice *_this /* Audio targets should call this as devices are added to the system (such as a USB headset being plugged in), and should also be called for @@ -64,21 +64,21 @@ extern void SDL_OpenedAudioDeviceDisconnected(SDL_AudioDevice *device); typedef struct SDL_AudioDriverImpl { - void (*DetectDevices) (void); - int (*OpenDevice) (_THIS, const char *devname); - void (*ThreadInit) (_THIS); /* Called by audio thread at start */ - void (*ThreadDeinit) (_THIS); /* Called by audio thread at end */ - void (*WaitDevice) (_THIS); - void (*PlayDevice) (_THIS); - Uint8 *(*GetDeviceBuf) (_THIS); - int (*CaptureFromDevice) (_THIS, void *buffer, int buflen); - void (*FlushCapture) (_THIS); - void (*CloseDevice) (_THIS); - void (*LockDevice) (_THIS); - void (*UnlockDevice) (_THIS); - void (*FreeDeviceHandle) (void *handle); /**< SDL is done with handle from SDL_AddAudioDevice() */ - void (*Deinitialize) (void); - int (*GetDefaultAudioInfo) (char **name, SDL_AudioSpec *spec, int iscapture); + void (*DetectDevices)(void); + int (*OpenDevice)(_THIS, const char *devname); + void (*ThreadInit)(_THIS); /* Called by audio thread at start */ + void (*ThreadDeinit)(_THIS); /* Called by audio thread at end */ + void (*WaitDevice)(_THIS); + void (*PlayDevice)(_THIS); + Uint8 *(*GetDeviceBuf)(_THIS); + int (*CaptureFromDevice)(_THIS, void *buffer, int buflen); + void (*FlushCapture)(_THIS); + void (*CloseDevice)(_THIS); + void (*LockDevice)(_THIS); + void (*UnlockDevice)(_THIS); + void (*FreeDeviceHandle)(void *handle); /**< SDL is done with handle from SDL_AddAudioDevice() */ + void (*Deinitialize)(void); + int (*GetDefaultAudioInfo)(char **name, SDL_AudioSpec *spec, int iscapture); /* !!! FIXME: add pause(), so we can optimize instead of mixing silence. */ @@ -91,7 +91,6 @@ typedef struct SDL_AudioDriverImpl SDL_bool SupportsNonPow2Samples; } SDL_AudioDriverImpl; - typedef struct SDL_AudioDeviceItem { void *handle; @@ -102,7 +101,6 @@ typedef struct SDL_AudioDeviceItem struct SDL_AudioDeviceItem *next; } SDL_AudioDeviceItem; - typedef struct SDL_AudioDriver { /* * * */ @@ -125,7 +123,6 @@ typedef struct SDL_AudioDriver SDL_AudioDeviceItem *inputDevices; } SDL_AudioDriver; - /* Define the SDL audio driver structure */ struct SDL_AudioDevice { @@ -176,8 +173,8 @@ typedef struct AudioBootStrap { const char *name; const char *desc; - SDL_bool (*init) (SDL_AudioDriverImpl * impl); - SDL_bool demand_only; /* 1==request explicitly, or it won't be available. */ + SDL_bool (*init)(SDL_AudioDriverImpl *impl); + SDL_bool demand_only; /* 1==request explicitly, or it won't be available. */ } AudioBootStrap; /* Not all of these are available in a given build. Use #ifdefs, etc. */ diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c index 9a0b9cc50..a9c0dc2a1 100644 --- a/src/audio/SDL_wave.c +++ b/src/audio/SDL_wave.c @@ -43,8 +43,7 @@ * Returns 0 on success, or -1 if the multiplication overflows, in which case f1 * does not get modified. */ -static int -SafeMult(size_t *f1, size_t f2) +static int SafeMult(size_t *f1, size_t f2) { if (*f1 > 0 && SIZE_MAX / *f1 <= f2) { return -1; @@ -66,21 +65,24 @@ typedef struct ADPCM_DecoderState void *cstate; /* Decoding state for each channel. */ /* ADPCM data. */ - struct { + struct + { Uint8 *data; size_t size; size_t pos; } input; /* Current ADPCM block in the ADPCM data above. */ - struct { + struct + { Uint8 *data; size_t size; size_t pos; } block; /* Decoded 16-bit PCM data. */ - struct { + struct + { Sint16 *data; size_t size; size_t pos; @@ -102,8 +104,7 @@ typedef struct MS_ADPCM_ChannelState } MS_ADPCM_ChannelState; #ifdef SDL_WAVE_DEBUG_LOG_FORMAT -static void -WaveDebugLogFormat(WaveFile *file) +static void WaveDebugLogFormat(WaveFile *file) { WaveFormat *format = &file->format; const char *fmtstr = "WAVE file: %s, %u Hz, %s, %u bits, %u %s/s"; @@ -137,55 +138,60 @@ WaveDebugLogFormat(WaveFile *file) break; } -#define SDL_WAVE_DEBUG_CHANNELCFG(STR, CODE) case CODE: wavechannel = STR; break; -#define SDL_WAVE_DEBUG_CHANNELSTR(STR, CODE) if (format->channelmask & CODE) { \ - SDL_strlcat(channelstr, channelstr[0] ? "-" STR : STR, sizeof(channelstr));} +#define SDL_WAVE_DEBUG_CHANNELCFG(STR, CODE) \ + case CODE: \ + wavechannel = STR; \ + break; +#define SDL_WAVE_DEBUG_CHANNELSTR(STR, CODE) \ + if (format->channelmask & CODE) { \ + SDL_strlcat(channelstr, channelstr[0] ? "-" STR : STR, sizeof(channelstr)); \ + } if (format->formattag == EXTENSIBLE_CODE && format->channelmask > 0) { switch (format->channelmask) { - SDL_WAVE_DEBUG_CHANNELCFG("1.0 Mono", 0x4) - SDL_WAVE_DEBUG_CHANNELCFG("1.1 Mono", 0xc) - SDL_WAVE_DEBUG_CHANNELCFG("2.0 Stereo", 0x3) - SDL_WAVE_DEBUG_CHANNELCFG("2.1 Stereo", 0xb) - SDL_WAVE_DEBUG_CHANNELCFG("3.0 Stereo", 0x7) - SDL_WAVE_DEBUG_CHANNELCFG("3.1 Stereo", 0xf) - SDL_WAVE_DEBUG_CHANNELCFG("3.0 Surround", 0x103) - SDL_WAVE_DEBUG_CHANNELCFG("3.1 Surround", 0x10b) - SDL_WAVE_DEBUG_CHANNELCFG("4.0 Quad", 0x33) - SDL_WAVE_DEBUG_CHANNELCFG("4.1 Quad", 0x3b) - SDL_WAVE_DEBUG_CHANNELCFG("4.0 Surround", 0x107) - SDL_WAVE_DEBUG_CHANNELCFG("4.1 Surround", 0x10f) - SDL_WAVE_DEBUG_CHANNELCFG("5.0", 0x37) - SDL_WAVE_DEBUG_CHANNELCFG("5.1", 0x3f) - SDL_WAVE_DEBUG_CHANNELCFG("5.0 Side", 0x607) - SDL_WAVE_DEBUG_CHANNELCFG("5.1 Side", 0x60f) - SDL_WAVE_DEBUG_CHANNELCFG("6.0", 0x137) - SDL_WAVE_DEBUG_CHANNELCFG("6.1", 0x13f) - SDL_WAVE_DEBUG_CHANNELCFG("6.0 Side", 0x707) - SDL_WAVE_DEBUG_CHANNELCFG("6.1 Side", 0x70f) - SDL_WAVE_DEBUG_CHANNELCFG("7.0", 0xf7) - SDL_WAVE_DEBUG_CHANNELCFG("7.1", 0xff) - SDL_WAVE_DEBUG_CHANNELCFG("7.0 Side", 0x6c7) - SDL_WAVE_DEBUG_CHANNELCFG("7.1 Side", 0x6cf) - SDL_WAVE_DEBUG_CHANNELCFG("7.0 Surround", 0x637) - SDL_WAVE_DEBUG_CHANNELCFG("7.1 Surround", 0x63f) - SDL_WAVE_DEBUG_CHANNELCFG("9.0 Surround", 0x5637) - SDL_WAVE_DEBUG_CHANNELCFG("9.1 Surround", 0x563f) - SDL_WAVE_DEBUG_CHANNELCFG("11.0 Surround", 0x56f7) - SDL_WAVE_DEBUG_CHANNELCFG("11.1 Surround", 0x56ff) + SDL_WAVE_DEBUG_CHANNELCFG("1.0 Mono", 0x4) + SDL_WAVE_DEBUG_CHANNELCFG("1.1 Mono", 0xc) + SDL_WAVE_DEBUG_CHANNELCFG("2.0 Stereo", 0x3) + SDL_WAVE_DEBUG_CHANNELCFG("2.1 Stereo", 0xb) + SDL_WAVE_DEBUG_CHANNELCFG("3.0 Stereo", 0x7) + SDL_WAVE_DEBUG_CHANNELCFG("3.1 Stereo", 0xf) + SDL_WAVE_DEBUG_CHANNELCFG("3.0 Surround", 0x103) + SDL_WAVE_DEBUG_CHANNELCFG("3.1 Surround", 0x10b) + SDL_WAVE_DEBUG_CHANNELCFG("4.0 Quad", 0x33) + SDL_WAVE_DEBUG_CHANNELCFG("4.1 Quad", 0x3b) + SDL_WAVE_DEBUG_CHANNELCFG("4.0 Surround", 0x107) + SDL_WAVE_DEBUG_CHANNELCFG("4.1 Surround", 0x10f) + SDL_WAVE_DEBUG_CHANNELCFG("5.0", 0x37) + SDL_WAVE_DEBUG_CHANNELCFG("5.1", 0x3f) + SDL_WAVE_DEBUG_CHANNELCFG("5.0 Side", 0x607) + SDL_WAVE_DEBUG_CHANNELCFG("5.1 Side", 0x60f) + SDL_WAVE_DEBUG_CHANNELCFG("6.0", 0x137) + SDL_WAVE_DEBUG_CHANNELCFG("6.1", 0x13f) + SDL_WAVE_DEBUG_CHANNELCFG("6.0 Side", 0x707) + SDL_WAVE_DEBUG_CHANNELCFG("6.1 Side", 0x70f) + SDL_WAVE_DEBUG_CHANNELCFG("7.0", 0xf7) + SDL_WAVE_DEBUG_CHANNELCFG("7.1", 0xff) + SDL_WAVE_DEBUG_CHANNELCFG("7.0 Side", 0x6c7) + SDL_WAVE_DEBUG_CHANNELCFG("7.1 Side", 0x6cf) + SDL_WAVE_DEBUG_CHANNELCFG("7.0 Surround", 0x637) + SDL_WAVE_DEBUG_CHANNELCFG("7.1 Surround", 0x63f) + SDL_WAVE_DEBUG_CHANNELCFG("9.0 Surround", 0x5637) + SDL_WAVE_DEBUG_CHANNELCFG("9.1 Surround", 0x563f) + SDL_WAVE_DEBUG_CHANNELCFG("11.0 Surround", 0x56f7) + SDL_WAVE_DEBUG_CHANNELCFG("11.1 Surround", 0x56ff) default: - SDL_WAVE_DEBUG_CHANNELSTR("FL", 0x1) - SDL_WAVE_DEBUG_CHANNELSTR("FR", 0x2) - SDL_WAVE_DEBUG_CHANNELSTR("FC", 0x4) - SDL_WAVE_DEBUG_CHANNELSTR("LF", 0x8) - SDL_WAVE_DEBUG_CHANNELSTR("BL", 0x10) - SDL_WAVE_DEBUG_CHANNELSTR("BR", 0x20) + SDL_WAVE_DEBUG_CHANNELSTR("FL", 0x1) + SDL_WAVE_DEBUG_CHANNELSTR("FR", 0x2) + SDL_WAVE_DEBUG_CHANNELSTR("FC", 0x4) + SDL_WAVE_DEBUG_CHANNELSTR("LF", 0x8) + SDL_WAVE_DEBUG_CHANNELSTR("BL", 0x10) + SDL_WAVE_DEBUG_CHANNELSTR("BR", 0x20) SDL_WAVE_DEBUG_CHANNELSTR("FLC", 0x40) SDL_WAVE_DEBUG_CHANNELSTR("FRC", 0x80) - SDL_WAVE_DEBUG_CHANNELSTR("BC", 0x100) - SDL_WAVE_DEBUG_CHANNELSTR("SL", 0x200) - SDL_WAVE_DEBUG_CHANNELSTR("SR", 0x400) - SDL_WAVE_DEBUG_CHANNELSTR("TC", 0x800) + SDL_WAVE_DEBUG_CHANNELSTR("BC", 0x100) + SDL_WAVE_DEBUG_CHANNELSTR("SL", 0x200) + SDL_WAVE_DEBUG_CHANNELSTR("SR", 0x400) + SDL_WAVE_DEBUG_CHANNELSTR("TC", 0x800) SDL_WAVE_DEBUG_CHANNELSTR("TFL", 0x1000) SDL_WAVE_DEBUG_CHANNELSTR("TFC", 0x2000) SDL_WAVE_DEBUG_CHANNELSTR("TFR", 0x4000) @@ -226,33 +232,32 @@ WaveDebugLogFormat(WaveFile *file) #endif #ifdef SDL_WAVE_DEBUG_DUMP_FORMAT -static void -WaveDebugDumpFormat(WaveFile *file, Uint32 rifflen, Uint32 fmtlen, Uint32 datalen) +static void WaveDebugDumpFormat(WaveFile *file, Uint32 rifflen, Uint32 fmtlen, Uint32 datalen) { WaveFormat *format = &file->format; const char *fmtstr1 = "WAVE chunk dump:\n" - "-------------------------------------------\n" - "RIFF %11u\n" - "-------------------------------------------\n" - " fmt %11u\n" - " wFormatTag 0x%04x\n" - " nChannels %11u\n" - " nSamplesPerSec %11u\n" - " nAvgBytesPerSec %11u\n" - " nBlockAlign %11u\n"; + "-------------------------------------------\n" + "RIFF %11u\n" + "-------------------------------------------\n" + " fmt %11u\n" + " wFormatTag 0x%04x\n" + " nChannels %11u\n" + " nSamplesPerSec %11u\n" + " nAvgBytesPerSec %11u\n" + " nBlockAlign %11u\n"; const char *fmtstr2 = " wBitsPerSample %11u\n"; const char *fmtstr3 = " cbSize %11u\n"; const char *fmtstr4a = " wValidBitsPerSample %11u\n"; const char *fmtstr4b = " wSamplesPerBlock %11u\n"; const char *fmtstr5 = " dwChannelMask 0x%08x\n" - " SubFormat\n" - " %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x\n"; + " SubFormat\n" + " %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x\n"; const char *fmtstr6 = "-------------------------------------------\n" - " fact\n" - " dwSampleLength %11u\n"; + " fact\n" + " dwSampleLength %11u\n"; const char *fmtstr7 = "-------------------------------------------\n" - " data %11u\n" - "-------------------------------------------\n"; + " data %11u\n" + "-------------------------------------------\n"; char *dumpstr; size_t dumppos = 0; const size_t bufsize = 1024; @@ -317,8 +322,7 @@ WaveDebugDumpFormat(WaveFile *file, Uint32 rifflen, Uint32 fmtlen, Uint32 datale } #endif -static Sint64 -WaveAdjustToFactValue(WaveFile *file, Sint64 sampleframes) +static Sint64 WaveAdjustToFactValue(WaveFile *file, Sint64 sampleframes) { if (file->fact.status == 2) { if (file->facthint == FactStrict && sampleframes < file->fact.samplelength) { @@ -331,8 +335,7 @@ WaveAdjustToFactValue(WaveFile *file, Sint64 sampleframes) return sampleframes; } -static int -MS_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength) +static int MS_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength) { WaveFormat *format = &file->format; const size_t blockheadersize = (size_t)file->format.channels * 7; @@ -371,8 +374,7 @@ MS_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength) return 0; } -static int -MS_ADPCM_Init(WaveFile *file, size_t datalength) +static int MS_ADPCM_Init(WaveFile *file, size_t datalength) { WaveFormat *format = &file->format; WaveChunk *chunk = &file->chunk; @@ -380,7 +382,7 @@ MS_ADPCM_Init(WaveFile *file, size_t datalength) const size_t blockdatasize = (size_t)format->blockalign - blockheadersize; const size_t blockframebitsize = (size_t)format->bitspersample * format->channels; const size_t blockdatasamples = (blockdatasize * 8) / blockframebitsize; - const Sint16 presetcoeffs[14] = {256, 0, 512, -256, 0, 0, 192, 64, 240, 0, 460, -208, 392, -232}; + const Sint16 presetcoeffs[14] = { 256, 0, 512, -256, 0, 0, 192, 64, 240, 0, 460, -208, 392, -232 }; size_t i, coeffcount; MS_ADPCM_CoeffData *coeffdata; @@ -490,8 +492,7 @@ MS_ADPCM_Init(WaveFile *file, size_t datalength) return 0; } -static Sint16 -MS_ADPCM_ProcessNibble(MS_ADPCM_ChannelState *cstate, Sint32 sample1, Sint32 sample2, Uint8 nybble) +static Sint16 MS_ADPCM_ProcessNibble(MS_ADPCM_ChannelState *cstate, Sint32 sample1, Sint32 sample2, Uint8 nybble) { const Sint32 max_audioval = 32767; const Sint32 min_audioval = -32768; @@ -527,8 +528,7 @@ MS_ADPCM_ProcessNibble(MS_ADPCM_ChannelState *cstate, Sint32 sample1, Sint32 sam return (Sint16)new_sample; } -static int -MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state) +static int MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state) { Uint8 coeffindex; const Uint32 channels = state->channels; @@ -588,8 +588,7 @@ MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state) * will always contain full sample frames (same sample count for each channel). * Incomplete sample frames are discarded. */ -static int -MS_ADPCM_DecodeBlockData(ADPCM_DecoderState *state) +static int MS_ADPCM_DecodeBlockData(ADPCM_DecoderState *state) { Uint16 nybble = 0; Sint16 sample1, sample2; @@ -636,8 +635,7 @@ MS_ADPCM_DecodeBlockData(ADPCM_DecoderState *state) return 0; } -static int -MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) +static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) { int result; size_t bytesleft, outputsize; @@ -736,8 +734,7 @@ MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) return 0; } -static int -IMA_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength) +static int IMA_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength) { WaveFormat *format = &file->format; const size_t blockheadersize = (size_t)format->channels * 4; @@ -790,8 +787,7 @@ IMA_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength) return 0; } -static int -IMA_ADPCM_Init(WaveFile *file, size_t datalength) +static int IMA_ADPCM_Init(WaveFile *file, size_t datalength) { WaveFormat *format = &file->format; WaveChunk *chunk = &file->chunk; @@ -856,8 +852,7 @@ IMA_ADPCM_Init(WaveFile *file, size_t datalength) return 0; } -static Sint16 -IMA_ADPCM_ProcessNibble(Sint8 *cindex, Sint16 lastsample, Uint8 nybble) +static Sint16 IMA_ADPCM_ProcessNibble(Sint8 *cindex, Sint16 lastsample, Uint8 nybble) { const Sint32 max_audioval = 32767; const Sint32 min_audioval = -32768; @@ -926,12 +921,11 @@ IMA_ADPCM_ProcessNibble(Sint8 *cindex, Sint16 lastsample, Uint8 nybble) return (Sint16)sample; } -static int -IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state) +static int IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state) { Sint16 step; Uint32 c; - Uint8 *cstate = (Uint8 *) state->cstate; + Uint8 *cstate = (Uint8 *)state->cstate; for (c = 0; c < state->channels; c++) { size_t o = state->block.pos + c * 4; @@ -949,7 +943,7 @@ IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state) /* Reserved byte in block header, should be 0. */ if (state->block.data[o + 3] != 0) { - /* Uh oh, corrupt data? Buggy code? */ ; + /* Uh oh, corrupt data? Buggy code? */; } } @@ -966,8 +960,7 @@ IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state) * contains full sample frames (same sample count for each channel). * Incomplete sample frames are discarded. */ -static int -IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state) +static int IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state) { size_t i; int retval = 0; @@ -1036,8 +1029,7 @@ IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state) return retval; } -static int -IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) +static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) { int result; size_t bytesleft, outputsize; @@ -1140,8 +1132,7 @@ IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) return 0; } -static int -LAW_Init(WaveFile *file, size_t datalength) +static int LAW_Init(WaveFile *file, size_t datalength) { WaveFormat *format = &file->format; @@ -1169,8 +1160,7 @@ LAW_Init(WaveFile *file, size_t datalength) return 0; } -static int -LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) +static int LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) { #ifdef SDL_WAVE_LAW_LUT const Sint16 alaw_lut[256] = { @@ -1312,8 +1302,7 @@ LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) return 0; } -static int -PCM_Init(WaveFile *file, size_t datalength) +static int PCM_Init(WaveFile *file, size_t datalength) { WaveFormat *format = &file->format; @@ -1356,8 +1345,7 @@ PCM_Init(WaveFile *file, size_t datalength) return 0; } -static int -PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) +static int PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) { WaveFormat *format = &file->format; WaveChunk *chunk = &file->chunk; @@ -1408,8 +1396,7 @@ PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) return 0; } -static int -PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) +static int PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) { WaveFormat *format = &file->format; WaveChunk *chunk = &file->chunk; @@ -1451,8 +1438,7 @@ PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) return 0; } -static WaveRiffSizeHint -WaveGetRiffSizeHint() +static WaveRiffSizeHint WaveGetRiffSizeHint() { const char *hint = SDL_GetHint(SDL_HINT_WAVE_RIFF_CHUNK_SIZE); @@ -1471,8 +1457,7 @@ WaveGetRiffSizeHint() return RiffSizeNoHint; } -static WaveTruncationHint -WaveGetTruncationHint() +static WaveTruncationHint WaveGetTruncationHint() { const char *hint = SDL_GetHint(SDL_HINT_WAVE_TRUNCATION); @@ -1491,8 +1476,7 @@ WaveGetTruncationHint() return TruncNoHint; } -static WaveFactChunkHint -WaveGetFactChunkHint() +static WaveFactChunkHint WaveGetFactChunkHint() { const char *hint = SDL_GetHint(SDL_HINT_WAVE_FACT_CHUNK); @@ -1511,8 +1495,7 @@ WaveGetFactChunkHint() return FactNoHint; } -static void -WaveFreeChunkData(WaveChunk *chunk) +static void WaveFreeChunkData(WaveChunk *chunk) { if (chunk->data != NULL) { SDL_free(chunk->data); @@ -1521,8 +1504,7 @@ WaveFreeChunkData(WaveChunk *chunk) chunk->size = 0; } -static int -WaveNextChunk(SDL_RWops *src, WaveChunk *chunk) +static int WaveNextChunk(SDL_RWops *src, WaveChunk *chunk) { Uint32 chunkheader[2]; Sint64 nextposition = chunk->position + chunk->length; @@ -1554,8 +1536,7 @@ WaveNextChunk(SDL_RWops *src, WaveChunk *chunk) return 0; } -static int -WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t length) +static int WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t length) { WaveFreeChunkData(chunk); @@ -1564,7 +1545,7 @@ WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t length) } if (length > 0) { - chunk->data = (Uint8 *) SDL_malloc(length); + chunk->data = (Uint8 *)SDL_malloc(length); if (chunk->data == NULL) { return SDL_OutOfMemory(); } @@ -1583,30 +1564,32 @@ WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t length) return 0; } -static int -WaveReadChunkData(SDL_RWops *src, WaveChunk *chunk) +static int WaveReadChunkData(SDL_RWops *src, WaveChunk *chunk) { return WaveReadPartialChunkData(src, chunk, chunk->length); } -typedef struct WaveExtensibleGUID { +typedef struct WaveExtensibleGUID +{ Uint16 encoding; Uint8 guid[16]; } WaveExtensibleGUID; /* Some of the GUIDs that are used by WAVEFORMATEXTENSIBLE. */ -#define WAVE_FORMATTAG_GUID(tag) {(tag) & 0xff, (tag) >> 8, 0, 0, 0, 0, 16, 0, 128, 0, 0, 170, 0, 56, 155, 113} +#define WAVE_FORMATTAG_GUID(tag) \ + { \ + (tag) & 0xff, (tag) >> 8, 0, 0, 0, 0, 16, 0, 128, 0, 0, 170, 0, 56, 155, 113 \ + } static WaveExtensibleGUID extensible_guids[] = { - {PCM_CODE, WAVE_FORMATTAG_GUID(PCM_CODE)}, - {MS_ADPCM_CODE, WAVE_FORMATTAG_GUID(MS_ADPCM_CODE)}, - {IEEE_FLOAT_CODE, WAVE_FORMATTAG_GUID(IEEE_FLOAT_CODE)}, - {ALAW_CODE, WAVE_FORMATTAG_GUID(ALAW_CODE)}, - {MULAW_CODE, WAVE_FORMATTAG_GUID(MULAW_CODE)}, - {IMA_ADPCM_CODE, WAVE_FORMATTAG_GUID(IMA_ADPCM_CODE)} + { PCM_CODE, WAVE_FORMATTAG_GUID(PCM_CODE) }, + { MS_ADPCM_CODE, WAVE_FORMATTAG_GUID(MS_ADPCM_CODE) }, + { IEEE_FLOAT_CODE, WAVE_FORMATTAG_GUID(IEEE_FLOAT_CODE) }, + { ALAW_CODE, WAVE_FORMATTAG_GUID(ALAW_CODE) }, + { MULAW_CODE, WAVE_FORMATTAG_GUID(MULAW_CODE) }, + { IMA_ADPCM_CODE, WAVE_FORMATTAG_GUID(IMA_ADPCM_CODE) } }; -static Uint16 -WaveGetFormatGUIDEncoding(WaveFormat *format) +static Uint16 WaveGetFormatGUIDEncoding(WaveFormat *format) { size_t i; for (i = 0; i < SDL_arraysize(extensible_guids); i++) { @@ -1617,8 +1600,7 @@ WaveGetFormatGUIDEncoding(WaveFormat *format) return UNKNOWN_CODE; } -static int -WaveReadFormat(WaveFile *file) +static int WaveReadFormat(WaveFile *file) { WaveChunk *chunk = &file->chunk; WaveFormat *format = &file->format; @@ -1679,8 +1661,7 @@ WaveReadFormat(WaveFile *file) return 0; } -static int -WaveCheckFormat(WaveFile *file, size_t datalength) +static int WaveCheckFormat(WaveFile *file, size_t datalength) { WaveFormat *format = &file->format; @@ -1787,8 +1768,7 @@ WaveCheckFormat(WaveFile *file, size_t datalength) return 0; } -static int -WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len) +static int WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len) { int result; Uint32 chunkcount = 0; @@ -2053,7 +2033,7 @@ WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 **audio_buf, SDL_zerop(spec); spec->freq = format->frequency; spec->channels = (Uint8)format->channels; - spec->samples = 4096; /* Good default buffer size */ + spec->samples = 4096; /* Good default buffer size */ switch (format->encoding) { case MS_ADPCM_CODE: @@ -2150,8 +2130,7 @@ SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_b /* Since the WAV memory is allocated in the shared library, it must also be freed here. (Necessary under Win32, VC++) */ -void -SDL_FreeWAV(Uint8 *audio_buf) +void SDL_FreeWAV(Uint8 *audio_buf) { SDL_free(audio_buf); } diff --git a/src/audio/SDL_wave.h b/src/audio/SDL_wave.h index c96f957de..13b475d31 100644 --- a/src/audio/SDL_wave.h +++ b/src/audio/SDL_wave.h @@ -26,14 +26,14 @@ /* Define values for Microsoft WAVE format */ /*******************************************/ /* FOURCC */ -#define RIFF 0x46464952 /* "RIFF" */ -#define WAVE 0x45564157 /* "WAVE" */ -#define FACT 0x74636166 /* "fact" */ -#define LIST 0x5453494c /* "LIST" */ -#define BEXT 0x74786562 /* "bext" */ -#define JUNK 0x4B4E554A /* "JUNK" */ -#define FMT 0x20746D66 /* "fmt " */ -#define DATA 0x61746164 /* "data" */ +#define RIFF 0x46464952 /* "RIFF" */ +#define WAVE 0x45564157 /* "WAVE" */ +#define FACT 0x74636166 /* "fact" */ +#define LIST 0x5453494c /* "LIST" */ +#define BEXT 0x74786562 /* "bext" */ +#define JUNK 0x4B4E554A /* "JUNK" */ +#define FMT 0x20746D66 /* "fmt " */ +#define DATA 0x61746164 /* "data" */ /* Format tags */ #define UNKNOWN_CODE 0x0000 #define PCM_CODE 0x0001 @@ -49,13 +49,13 @@ /* Stores the WAVE format information. */ typedef struct WaveFormat { - Uint16 formattag; /* Raw value of the first field in the fmt chunk data. */ - Uint16 encoding; /* Actual encoding, possibly from the extensible header. */ - Uint16 channels; /* Number of channels. */ - Uint32 frequency; /* Sampling rate in Hz. */ - Uint32 byterate; /* Average bytes per second. */ - Uint16 blockalign; /* Bytes per block. */ - Uint16 bitspersample; /* Currently supported are 8, 16, 24, 32, and 4 for ADPCM. */ + Uint16 formattag; /* Raw value of the first field in the fmt chunk data. */ + Uint16 encoding; /* Actual encoding, possibly from the extensible header. */ + Uint16 channels; /* Number of channels. */ + Uint32 frequency; /* Sampling rate in Hz. */ + Uint32 byterate; /* Average bytes per second. */ + Uint16 blockalign; /* Bytes per block. */ + Uint16 bitspersample; /* Currently supported are 8, 16, 24, 32, and 4 for ADPCM. */ /* Extra information size. Number of extra bytes starting at byte 18 in the * fmt chunk data. This is at least 22 for the extensible header. @@ -66,11 +66,12 @@ typedef struct WaveFormat Uint16 validsamplebits; Uint32 samplesperblock; /* For compressed formats. Can be zero. Actually 16 bits in the header. */ Uint32 channelmask; - Uint8 subformat[16]; /* A format GUID. */ + Uint8 subformat[16]; /* A format GUID. */ } WaveFormat; /* Stores information on the fact chunk. */ -typedef struct WaveFact { +typedef struct WaveFact +{ /* Represents the state of the fact chunk in the WAVE file. * Set to -1 if the fact chunk is invalid. * Set to 0 if the fact chunk is not present @@ -101,7 +102,8 @@ typedef struct WaveChunk } WaveChunk; /* Controls how the size of the RIFF chunk affects the loading of a WAVE file. */ -typedef enum WaveRiffSizeHint { +typedef enum WaveRiffSizeHint +{ RiffSizeNoHint, RiffSizeForce, RiffSizeIgnoreZero, @@ -110,7 +112,8 @@ typedef enum WaveRiffSizeHint { } WaveRiffSizeHint; /* Controls how a truncated WAVE file is handled. */ -typedef enum WaveTruncationHint { +typedef enum WaveTruncationHint +{ TruncNoHint, TruncVeryStrict, TruncStrict, @@ -119,7 +122,8 @@ typedef enum WaveTruncationHint { } WaveTruncationHint; /* Controls how the fact chunk affects the loading of a WAVE file. */ -typedef enum WaveFactChunkHint { +typedef enum WaveFactChunkHint +{ FactNoHint, FactTruncate, FactStrict, @@ -139,7 +143,7 @@ typedef struct WaveFile */ Sint64 sampleframes; - void *decoderdata; /* Some decoders require extra data for a state. */ + void *decoderdata; /* Some decoders require extra data for a state. */ WaveRiffSizeHint riffhint; WaveTruncationHint trunchint; diff --git a/src/audio/aaudio/SDL_aaudio.c b/src/audio/aaudio/SDL_aaudio.c index 2fac33614..92d22338d 100644 --- a/src/audio/aaudio/SDL_aaudio.c +++ b/src/audio/aaudio/SDL_aaudio.c @@ -30,17 +30,17 @@ /* Debug */ #if 0 -# define LOGI(...) SDL_Log(__VA_ARGS__); +#define LOGI(...) SDL_Log(__VA_ARGS__); #else -# define LOGI(...) +#define LOGI(...) #endif typedef struct AAUDIO_Data { AAudioStreamBuilder *builder; void *handle; -#define SDL_PROC(ret,func,params) ret (*func) params; -# include "SDL_aaudiofuncs.h" +#define SDL_PROC(ret, func, params) ret(*func) params; +#include "SDL_aaudiofuncs.h" #undef SDL_PROC } AAUDIO_Data; static AAUDIO_Data ctx; @@ -50,28 +50,27 @@ static SDL_AudioDevice *captureDevice = NULL; static int aaudio_LoadFunctions(AAUDIO_Data *data) { -#define SDL_PROC(ret,func,params) \ - do { \ - data->func = SDL_LoadFunction(data->handle, #func); \ - if (! data->func) { \ - return SDL_SetError("Couldn't load AAUDIO function %s: %s", #func, SDL_GetError()); \ - } \ +#define SDL_PROC(ret, func, params) \ + do { \ + data->func = SDL_LoadFunction(data->handle, #func); \ + if (!data->func) { \ + return SDL_SetError("Couldn't load AAUDIO function %s: %s", #func, SDL_GetError()); \ + } \ } while (0); #include "SDL_aaudiofuncs.h" #undef SDL_PROC return 0; } -void aaudio_errorCallback( AAudioStream *stream, void *userData, aaudio_result_t error ); -void aaudio_errorCallback( AAudioStream *stream, void *userData, aaudio_result_t error ) +void aaudio_errorCallback(AAudioStream *stream, void *userData, aaudio_result_t error); +void aaudio_errorCallback(AAudioStream *stream, void *userData, aaudio_result_t error) { - LOGI( "SDL aaudio_errorCallback: %d - %s", error, ctx.AAudio_convertResultToText( error ) ); + LOGI("SDL aaudio_errorCallback: %d - %s", error, ctx.AAudio_convertResultToText(error)); } #define LIB_AAUDIO_SO "libaaudio.so" -static int -aaudio_OpenDevice(_THIS, const char *devname) +static int aaudio_OpenDevice(_THIS, const char *devname) { struct SDL_PrivateAudioData *private; SDL_bool iscapture = this->iscapture; @@ -94,7 +93,7 @@ aaudio_OpenDevice(_THIS, const char *devname) audioDevice = this; } - this->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, (sizeof *this->hidden)); + this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, (sizeof *this->hidden)); if (this->hidden == NULL) { return SDL_OutOfMemory(); } @@ -116,11 +115,11 @@ aaudio_OpenDevice(_THIS, const char *devname) ctx.AAudioStreamBuilder_setFormat(ctx.builder, format); } - ctx.AAudioStreamBuilder_setErrorCallback( ctx.builder, aaudio_errorCallback, private ); + ctx.AAudioStreamBuilder_setErrorCallback(ctx.builder, aaudio_errorCallback, private); LOGI("AAudio Try to open %u hz %u bit chan %u %s samples %u", - this->spec.freq, SDL_AUDIO_BITSIZE(this->spec.format), - this->spec.channels, (this->spec.format & 0x1000) ? "BE" : "LE", this->spec.samples); + this->spec.freq, SDL_AUDIO_BITSIZE(this->spec.format), + this->spec.channels, (this->spec.format & 0x1000) ? "BE" : "LE", this->spec.samples); res = ctx.AAudioStreamBuilder_openStream(ctx.builder, &private->stream); if (res != AAUDIO_OK) { @@ -140,15 +139,15 @@ aaudio_OpenDevice(_THIS, const char *devname) } LOGI("AAudio Try to open %u hz %u bit chan %u %s samples %u", - this->spec.freq, SDL_AUDIO_BITSIZE(this->spec.format), - this->spec.channels, (this->spec.format & 0x1000) ? "BE" : "LE", this->spec.samples); + this->spec.freq, SDL_AUDIO_BITSIZE(this->spec.format), + this->spec.channels, (this->spec.format & 0x1000) ? "BE" : "LE", this->spec.samples); SDL_CalculateAudioSpec(&this->spec); /* Allocate mixing buffer */ if (!iscapture) { private->mixlen = this->spec.size; - private->mixbuf = (Uint8 *) SDL_malloc(private->mixlen); + private->mixbuf = (Uint8 *)SDL_malloc(private->mixlen); if (private->mixbuf == NULL) { return SDL_OutOfMemory(); } @@ -167,8 +166,7 @@ aaudio_OpenDevice(_THIS, const char *devname) return 0; } -static void -aaudio_CloseDevice(_THIS) +static void aaudio_CloseDevice(_THIS) { struct SDL_PrivateAudioData *private = this->hidden; aaudio_result_t res; @@ -202,20 +200,18 @@ aaudio_CloseDevice(_THIS) SDL_free(this->hidden); } -static Uint8 * -aaudio_GetDeviceBuf(_THIS) +static Uint8 *aaudio_GetDeviceBuf(_THIS) { struct SDL_PrivateAudioData *private = this->hidden; return private->mixbuf; } -static void -aaudio_PlayDevice(_THIS) +static void aaudio_PlayDevice(_THIS) { struct SDL_PrivateAudioData *private = this->hidden; aaudio_result_t res; int64_t timeoutNanoseconds = 1 * 1000 * 1000; /* 8 ms */ - res = ctx.AAudioStream_write(private->stream, private->mixbuf, private->mixlen / private->frame_size, timeoutNanoseconds); + res = ctx.AAudioStream_write(private->stream, private->mixbuf, private->mixlen / private->frame_size, timeoutNanoseconds); if (res < 0) { LOGI("%s : %s", __func__, ctx.AAudio_convertResultToText(res)); } else { @@ -235,13 +231,12 @@ aaudio_PlayDevice(_THIS) #endif } -static int -aaudio_CaptureFromDevice(_THIS, void *buffer, int buflen) +static int aaudio_CaptureFromDevice(_THIS, void *buffer, int buflen) { struct SDL_PrivateAudioData *private = this->hidden; aaudio_result_t res; int64_t timeoutNanoseconds = 8 * 1000 * 1000; /* 8 ms */ - res = ctx.AAudioStream_read(private->stream, buffer, buflen / private->frame_size, timeoutNanoseconds); + res = ctx.AAudioStream_read(private->stream, buffer, buflen / private->frame_size, timeoutNanoseconds); if (res < 0) { LOGI("%s : %s", __func__, ctx.AAudio_convertResultToText(res)); return -1; @@ -250,8 +245,7 @@ aaudio_CaptureFromDevice(_THIS, void *buffer, int buflen) return res * private->frame_size; } -static void -aaudio_Deinitialize(void) +static void aaudio_Deinitialize(void) { LOGI(__func__); if (ctx.handle) { @@ -269,8 +263,7 @@ aaudio_Deinitialize(void) LOGI("End AAUDIO %s", SDL_GetError()); } -static SDL_bool -aaudio_Init(SDL_AudioDriverImpl *impl) +static SDL_bool aaudio_Init(SDL_AudioDriverImpl *impl) { aaudio_result_t res; LOGI(__func__); @@ -345,7 +338,7 @@ void aaudio_PauseDevices(void) /* TODO: Handle multiple devices? */ struct SDL_PrivateAudioData *private; if (audioDevice != NULL && audioDevice->hidden != NULL) { - private = (struct SDL_PrivateAudioData *) audioDevice->hidden; + private = (struct SDL_PrivateAudioData *)audioDevice->hidden; if (private->stream) { aaudio_result_t res = ctx.AAudioStream_requestPause(private->stream); @@ -366,7 +359,7 @@ void aaudio_PauseDevices(void) } if (captureDevice != NULL && captureDevice->hidden != NULL) { - private = (struct SDL_PrivateAudioData *) captureDevice->hidden; + private = (struct SDL_PrivateAudioData *)captureDevice->hidden; if (private->stream) { /* Pause() isn't implemented for 'capture', use Stop() */ @@ -394,7 +387,7 @@ void aaudio_ResumeDevices(void) /* TODO: Handle multiple devices? */ struct SDL_PrivateAudioData *private; if (audioDevice != NULL && audioDevice->hidden != NULL) { - private = (struct SDL_PrivateAudioData *) audioDevice->hidden; + private = (struct SDL_PrivateAudioData *)audioDevice->hidden; if (private->resume) { SDL_AtomicSet(&audioDevice->paused, 0); @@ -412,7 +405,7 @@ void aaudio_ResumeDevices(void) } if (captureDevice != NULL && captureDevice->hidden != NULL) { - private = (struct SDL_PrivateAudioData *) captureDevice->hidden; + private = (struct SDL_PrivateAudioData *)captureDevice->hidden; if (private->resume) { SDL_AtomicSet(&captureDevice->paused, 0); @@ -435,24 +428,24 @@ void aaudio_ResumeDevices(void) None of the standard state queries indicate any problem in my testing. And the error callback doesn't actually get called. But, AAudioStream_getTimestamp() does return AAUDIO_ERROR_INVALID_STATE */ -SDL_bool aaudio_DetectBrokenPlayState( void ) +SDL_bool aaudio_DetectBrokenPlayState(void) { struct SDL_PrivateAudioData *private; int64_t framePosition, timeNanoseconds; aaudio_result_t res; - if (audioDevice == NULL || !audioDevice->hidden ) { + if (audioDevice == NULL || !audioDevice->hidden) { return SDL_FALSE; } private = audioDevice->hidden; - res = ctx.AAudioStream_getTimestamp( private->stream, CLOCK_MONOTONIC, &framePosition, &timeNanoseconds ); - if ( res == AAUDIO_ERROR_INVALID_STATE ) { - aaudio_stream_state_t currentState = ctx.AAudioStream_getState( private->stream ); + res = ctx.AAudioStream_getTimestamp(private->stream, CLOCK_MONOTONIC, &framePosition, &timeNanoseconds); + if (res == AAUDIO_ERROR_INVALID_STATE) { + aaudio_stream_state_t currentState = ctx.AAudioStream_getState(private->stream); /* AAudioStream_getTimestamp() will also return AAUDIO_ERROR_INVALID_STATE while the stream is still initially starting. But we only care if it silently went invalid while playing. */ - if ( currentState == AAUDIO_STREAM_STATE_STARTED ) { - LOGI( "SDL aaudio_DetectBrokenPlayState: detected invalid audio device state: AAudioStream_getTimestamp result=%d, framePosition=%lld, timeNanoseconds=%lld, getState=%d", (int)res, (long long)framePosition, (long long)timeNanoseconds, (int)currentState ); + if (currentState == AAUDIO_STREAM_STATE_STARTED) { + LOGI("SDL aaudio_DetectBrokenPlayState: detected invalid audio device state: AAudioStream_getTimestamp result=%d, framePosition=%lld, timeNanoseconds=%lld, getState=%d", (int)res, (long long)framePosition, (long long)timeNanoseconds, (int)currentState); return SDL_TRUE; } } diff --git a/src/audio/aaudio/SDL_aaudio.h b/src/audio/aaudio/SDL_aaudio.h index babb68392..2a1f65dfb 100644 --- a/src/audio/aaudio/SDL_aaudio.h +++ b/src/audio/aaudio/SDL_aaudio.h @@ -28,7 +28,7 @@ #include /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { @@ -42,12 +42,11 @@ struct SDL_PrivateAudioData /* Resume device if it was paused automatically */ int resume; }; - + void aaudio_ResumeDevices(void); void aaudio_PauseDevices(void); SDL_bool aaudio_DetectBrokenPlayState(void); - #endif /* _SDL_aaudio_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/aaudio/SDL_aaudiofuncs.h b/src/audio/aaudio/SDL_aaudiofuncs.h index 54ef65bbc..57f84d45a 100644 --- a/src/audio/aaudio/SDL_aaudiofuncs.h +++ b/src/audio/aaudio/SDL_aaudiofuncs.h @@ -19,62 +19,61 @@ 3. This notice may not be removed or altered from any source distribution. */ -#define SDL_PROC_UNUSED(ret,func,params) +#define SDL_PROC_UNUSED(ret, func, params) SDL_PROC(const char *, AAudio_convertResultToText, (aaudio_result_t returnCode)) SDL_PROC(const char *, AAudio_convertStreamStateToText, (aaudio_stream_state_t state)) -SDL_PROC(aaudio_result_t, AAudio_createStreamBuilder, (AAudioStreamBuilder** builder)) -SDL_PROC_UNUSED(void, AAudioStreamBuilder_setDeviceId, (AAudioStreamBuilder* builder, int32_t deviceId)) -SDL_PROC(void, AAudioStreamBuilder_setSampleRate, (AAudioStreamBuilder* builder, int32_t sampleRate)) -SDL_PROC(void, AAudioStreamBuilder_setChannelCount, (AAudioStreamBuilder* builder, int32_t channelCount)) -SDL_PROC_UNUSED(void, AAudioStreamBuilder_setSamplesPerFrame, (AAudioStreamBuilder* builder, int32_t samplesPerFrame)) -SDL_PROC(void, AAudioStreamBuilder_setFormat, (AAudioStreamBuilder* builder, aaudio_format_t format)) -SDL_PROC_UNUSED(void, AAudioStreamBuilder_setSharingMode, (AAudioStreamBuilder* builder, aaudio_sharing_mode_t sharingMode)) -SDL_PROC(void, AAudioStreamBuilder_setDirection, (AAudioStreamBuilder* builder, aaudio_direction_t direction)) -SDL_PROC_UNUSED(void, AAudioStreamBuilder_setBufferCapacityInFrames, (AAudioStreamBuilder* builder, int32_t numFrames)) -SDL_PROC_UNUSED(void, AAudioStreamBuilder_setPerformanceMode, (AAudioStreamBuilder* builder, aaudio_performance_mode_t mode)) -SDL_PROC_UNUSED(void, AAudioStreamBuilder_setUsage, (AAudioStreamBuilder* builder, aaudio_usage_t usage)) /* API 28 */ -SDL_PROC_UNUSED(void, AAudioStreamBuilder_setContentType, (AAudioStreamBuilder* builder, aaudio_content_type_t contentType)) /* API 28 */ -SDL_PROC_UNUSED(void, AAudioStreamBuilder_setInputPreset, (AAudioStreamBuilder* builder, aaudio_input_preset_t inputPreset)) /* API 28 */ -SDL_PROC_UNUSED(void, AAudioStreamBuilder_setAllowedCapturePolicy, (AAudioStreamBuilder* builder, aaudio_allowed_capture_policy_t capturePolicy)) /* API 29 */ -SDL_PROC_UNUSED(void, AAudioStreamBuilder_setSessionId, (AAudioStreamBuilder* builder, aaudio_session_id_t sessionId)) /* API 28 */ -SDL_PROC_UNUSED(void, AAudioStreamBuilder_setPrivacySensitive, (AAudioStreamBuilder* builder, bool privacySensitive)) /* API 30 */ -SDL_PROC_UNUSED(void, AAudioStreamBuilder_setDataCallback, (AAudioStreamBuilder* builder, AAudioStream_dataCallback callback, void *userData)) -SDL_PROC_UNUSED(void, AAudioStreamBuilder_setFramesPerDataCallback, (AAudioStreamBuilder* builder, int32_t numFrames)) -SDL_PROC(void, AAudioStreamBuilder_setErrorCallback, (AAudioStreamBuilder* builder, AAudioStream_errorCallback callback, void *userData)) -SDL_PROC(aaudio_result_t , AAudioStreamBuilder_openStream, (AAudioStreamBuilder* builder, AAudioStream** stream)) -SDL_PROC(aaudio_result_t , AAudioStreamBuilder_delete, (AAudioStreamBuilder* builder)) -SDL_PROC_UNUSED(aaudio_result_t , AAudioStream_release, (AAudioStream* stream)) /* API 30 */ -SDL_PROC(aaudio_result_t , AAudioStream_close, (AAudioStream* stream)) -SDL_PROC(aaudio_result_t , AAudioStream_requestStart, (AAudioStream* stream)) -SDL_PROC(aaudio_result_t , AAudioStream_requestPause, (AAudioStream* stream)) -SDL_PROC_UNUSED(aaudio_result_t , AAudioStream_requestFlush, (AAudioStream* stream)) -SDL_PROC(aaudio_result_t , AAudioStream_requestStop, (AAudioStream* stream)) -SDL_PROC(aaudio_stream_state_t, AAudioStream_getState, (AAudioStream* stream)) -SDL_PROC_UNUSED(aaudio_result_t, AAudioStream_waitForStateChange, (AAudioStream* stream, aaudio_stream_state_t inputState, aaudio_stream_state_t *nextState, int64_t timeoutNanoseconds)) -SDL_PROC(aaudio_result_t, AAudioStream_read, (AAudioStream* stream, void *buffer, int32_t numFrames, int64_t timeoutNanoseconds)) -SDL_PROC(aaudio_result_t, AAudioStream_write, (AAudioStream* stream, const void *buffer, int32_t numFrames, int64_t timeoutNanoseconds)) -SDL_PROC_UNUSED(aaudio_result_t, AAudioStream_setBufferSizeInFrames, (AAudioStream* stream, int32_t numFrames)) -SDL_PROC_UNUSED(int32_t, AAudioStream_getBufferSizeInFrames, (AAudioStream* stream)) -SDL_PROC_UNUSED(int32_t, AAudioStream_getFramesPerBurst, (AAudioStream* stream)) -SDL_PROC_UNUSED(int32_t, AAudioStream_getBufferCapacityInFrames, (AAudioStream* stream)) -SDL_PROC_UNUSED(int32_t, AAudioStream_getFramesPerDataCallback, (AAudioStream* stream)) -SDL_PROC(int32_t, AAudioStream_getXRunCount, (AAudioStream* stream)) -SDL_PROC(int32_t, AAudioStream_getSampleRate, (AAudioStream* stream)) -SDL_PROC(int32_t, AAudioStream_getChannelCount, (AAudioStream* stream)) -SDL_PROC_UNUSED(int32_t, AAudioStream_getSamplesPerFrame, (AAudioStream* stream)) -SDL_PROC_UNUSED(int32_t, AAudioStream_getDeviceId, (AAudioStream* stream)) -SDL_PROC(aaudio_format_t, AAudioStream_getFormat, (AAudioStream* stream)) -SDL_PROC_UNUSED(aaudio_sharing_mode_t, AAudioStream_getSharingMode, (AAudioStream* stream)) -SDL_PROC_UNUSED(aaudio_performance_mode_t, AAudioStream_getPerformanceMode, (AAudioStream* stream)) -SDL_PROC_UNUSED(aaudio_direction_t, AAudioStream_getDirection, (AAudioStream* stream)) -SDL_PROC_UNUSED(int64_t, AAudioStream_getFramesWritten, (AAudioStream* stream)) -SDL_PROC_UNUSED(int64_t, AAudioStream_getFramesRead, (AAudioStream* stream)) -SDL_PROC_UNUSED(aaudio_session_id_t, AAudioStream_getSessionId, (AAudioStream* stream)) /* API 28 */ -SDL_PROC(aaudio_result_t, AAudioStream_getTimestamp, (AAudioStream* stream, clockid_t clockid, int64_t *framePosition, int64_t *timeNanoseconds)) -SDL_PROC_UNUSED(aaudio_usage_t, AAudioStream_getUsage, (AAudioStream* stream)) /* API 28 */ -SDL_PROC_UNUSED(aaudio_content_type_t, AAudioStream_getContentType, (AAudioStream* stream)) /* API 28 */ -SDL_PROC_UNUSED(aaudio_input_preset_t, AAudioStream_getInputPreset, (AAudioStream* stream)) /* API 28 */ -SDL_PROC_UNUSED(aaudio_allowed_capture_policy_t, AAudioStream_getAllowedCapturePolicy, ( AAudioStream* stream)) /* API 29 */ -SDL_PROC_UNUSED(bool, AAudioStream_isPrivacySensitive, (AAudioStream* stream)) /* API 30 */ - +SDL_PROC(aaudio_result_t, AAudio_createStreamBuilder, (AAudioStreamBuilder * *builder)) +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setDeviceId, (AAudioStreamBuilder * builder, int32_t deviceId)) +SDL_PROC(void, AAudioStreamBuilder_setSampleRate, (AAudioStreamBuilder * builder, int32_t sampleRate)) +SDL_PROC(void, AAudioStreamBuilder_setChannelCount, (AAudioStreamBuilder * builder, int32_t channelCount)) +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setSamplesPerFrame, (AAudioStreamBuilder * builder, int32_t samplesPerFrame)) +SDL_PROC(void, AAudioStreamBuilder_setFormat, (AAudioStreamBuilder * builder, aaudio_format_t format)) +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setSharingMode, (AAudioStreamBuilder * builder, aaudio_sharing_mode_t sharingMode)) +SDL_PROC(void, AAudioStreamBuilder_setDirection, (AAudioStreamBuilder * builder, aaudio_direction_t direction)) +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setBufferCapacityInFrames, (AAudioStreamBuilder * builder, int32_t numFrames)) +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setPerformanceMode, (AAudioStreamBuilder * builder, aaudio_performance_mode_t mode)) +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setUsage, (AAudioStreamBuilder * builder, aaudio_usage_t usage)) /* API 28 */ +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setContentType, (AAudioStreamBuilder * builder, aaudio_content_type_t contentType)) /* API 28 */ +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setInputPreset, (AAudioStreamBuilder * builder, aaudio_input_preset_t inputPreset)) /* API 28 */ +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setAllowedCapturePolicy, (AAudioStreamBuilder * builder, aaudio_allowed_capture_policy_t capturePolicy)) /* API 29 */ +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setSessionId, (AAudioStreamBuilder * builder, aaudio_session_id_t sessionId)) /* API 28 */ +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setPrivacySensitive, (AAudioStreamBuilder * builder, bool privacySensitive)) /* API 30 */ +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setDataCallback, (AAudioStreamBuilder * builder, AAudioStream_dataCallback callback, void *userData)) +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setFramesPerDataCallback, (AAudioStreamBuilder * builder, int32_t numFrames)) +SDL_PROC(void, AAudioStreamBuilder_setErrorCallback, (AAudioStreamBuilder * builder, AAudioStream_errorCallback callback, void *userData)) +SDL_PROC(aaudio_result_t, AAudioStreamBuilder_openStream, (AAudioStreamBuilder * builder, AAudioStream **stream)) +SDL_PROC(aaudio_result_t, AAudioStreamBuilder_delete, (AAudioStreamBuilder * builder)) +SDL_PROC_UNUSED(aaudio_result_t, AAudioStream_release, (AAudioStream * stream)) /* API 30 */ +SDL_PROC(aaudio_result_t, AAudioStream_close, (AAudioStream * stream)) +SDL_PROC(aaudio_result_t, AAudioStream_requestStart, (AAudioStream * stream)) +SDL_PROC(aaudio_result_t, AAudioStream_requestPause, (AAudioStream * stream)) +SDL_PROC_UNUSED(aaudio_result_t, AAudioStream_requestFlush, (AAudioStream * stream)) +SDL_PROC(aaudio_result_t, AAudioStream_requestStop, (AAudioStream * stream)) +SDL_PROC(aaudio_stream_state_t, AAudioStream_getState, (AAudioStream * stream)) +SDL_PROC_UNUSED(aaudio_result_t, AAudioStream_waitForStateChange, (AAudioStream * stream, aaudio_stream_state_t inputState, aaudio_stream_state_t *nextState, int64_t timeoutNanoseconds)) +SDL_PROC(aaudio_result_t, AAudioStream_read, (AAudioStream * stream, void *buffer, int32_t numFrames, int64_t timeoutNanoseconds)) +SDL_PROC(aaudio_result_t, AAudioStream_write, (AAudioStream * stream, const void *buffer, int32_t numFrames, int64_t timeoutNanoseconds)) +SDL_PROC_UNUSED(aaudio_result_t, AAudioStream_setBufferSizeInFrames, (AAudioStream * stream, int32_t numFrames)) +SDL_PROC_UNUSED(int32_t, AAudioStream_getBufferSizeInFrames, (AAudioStream * stream)) +SDL_PROC_UNUSED(int32_t, AAudioStream_getFramesPerBurst, (AAudioStream * stream)) +SDL_PROC_UNUSED(int32_t, AAudioStream_getBufferCapacityInFrames, (AAudioStream * stream)) +SDL_PROC_UNUSED(int32_t, AAudioStream_getFramesPerDataCallback, (AAudioStream * stream)) +SDL_PROC(int32_t, AAudioStream_getXRunCount, (AAudioStream * stream)) +SDL_PROC(int32_t, AAudioStream_getSampleRate, (AAudioStream * stream)) +SDL_PROC(int32_t, AAudioStream_getChannelCount, (AAudioStream * stream)) +SDL_PROC_UNUSED(int32_t, AAudioStream_getSamplesPerFrame, (AAudioStream * stream)) +SDL_PROC_UNUSED(int32_t, AAudioStream_getDeviceId, (AAudioStream * stream)) +SDL_PROC(aaudio_format_t, AAudioStream_getFormat, (AAudioStream * stream)) +SDL_PROC_UNUSED(aaudio_sharing_mode_t, AAudioStream_getSharingMode, (AAudioStream * stream)) +SDL_PROC_UNUSED(aaudio_performance_mode_t, AAudioStream_getPerformanceMode, (AAudioStream * stream)) +SDL_PROC_UNUSED(aaudio_direction_t, AAudioStream_getDirection, (AAudioStream * stream)) +SDL_PROC_UNUSED(int64_t, AAudioStream_getFramesWritten, (AAudioStream * stream)) +SDL_PROC_UNUSED(int64_t, AAudioStream_getFramesRead, (AAudioStream * stream)) +SDL_PROC_UNUSED(aaudio_session_id_t, AAudioStream_getSessionId, (AAudioStream * stream)) /* API 28 */ +SDL_PROC(aaudio_result_t, AAudioStream_getTimestamp, (AAudioStream * stream, clockid_t clockid, int64_t *framePosition, int64_t *timeNanoseconds)) +SDL_PROC_UNUSED(aaudio_usage_t, AAudioStream_getUsage, (AAudioStream * stream)) /* API 28 */ +SDL_PROC_UNUSED(aaudio_content_type_t, AAudioStream_getContentType, (AAudioStream * stream)) /* API 28 */ +SDL_PROC_UNUSED(aaudio_input_preset_t, AAudioStream_getInputPreset, (AAudioStream * stream)) /* API 28 */ +SDL_PROC_UNUSED(aaudio_allowed_capture_policy_t, AAudioStream_getAllowedCapturePolicy, (AAudioStream * stream)) /* API 29 */ +SDL_PROC_UNUSED(bool, AAudioStream_isPrivacySensitive, (AAudioStream * stream)) /* API 30 */ diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 7e35efd70..0d3a57813 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -34,7 +34,7 @@ /* Allow access to a raw mixing buffer */ #include -#include /* For kill() */ +#include /* For kill() */ #include #include "SDL_timer.h" @@ -46,64 +46,46 @@ #include "SDL_loadso.h" #endif -static int (*ALSA_snd_pcm_open) - (snd_pcm_t **, const char *, snd_pcm_stream_t, int); -static int (*ALSA_snd_pcm_close) (snd_pcm_t * pcm); -static snd_pcm_sframes_t (*ALSA_snd_pcm_writei) - (snd_pcm_t *, const void *, snd_pcm_uframes_t); -static snd_pcm_sframes_t (*ALSA_snd_pcm_readi) - (snd_pcm_t *, void *, snd_pcm_uframes_t); -static int (*ALSA_snd_pcm_recover) (snd_pcm_t *, int, int); -static int (*ALSA_snd_pcm_prepare) (snd_pcm_t *); -static int (*ALSA_snd_pcm_drain) (snd_pcm_t *); -static const char *(*ALSA_snd_strerror) (int); -static size_t(*ALSA_snd_pcm_hw_params_sizeof) (void); -static size_t(*ALSA_snd_pcm_sw_params_sizeof) (void); -static void (*ALSA_snd_pcm_hw_params_copy) - (snd_pcm_hw_params_t *, const snd_pcm_hw_params_t *); -static int (*ALSA_snd_pcm_hw_params_any) (snd_pcm_t *, snd_pcm_hw_params_t *); -static int (*ALSA_snd_pcm_hw_params_set_access) - (snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_access_t); -static int (*ALSA_snd_pcm_hw_params_set_format) - (snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_format_t); -static int (*ALSA_snd_pcm_hw_params_set_channels) - (snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int); -static int (*ALSA_snd_pcm_hw_params_get_channels) - (const snd_pcm_hw_params_t *, unsigned int *); -static int (*ALSA_snd_pcm_hw_params_set_rate_near) - (snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *); -static int (*ALSA_snd_pcm_hw_params_set_period_size_near) - (snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *); -static int (*ALSA_snd_pcm_hw_params_get_period_size) - (const snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *); -static int (*ALSA_snd_pcm_hw_params_set_periods_min) - (snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *); -static int (*ALSA_snd_pcm_hw_params_set_periods_first) - (snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *); -static int (*ALSA_snd_pcm_hw_params_get_periods) - (const snd_pcm_hw_params_t *, unsigned int *, int *); -static int (*ALSA_snd_pcm_hw_params_set_buffer_size_near) - (snd_pcm_t *pcm, snd_pcm_hw_params_t *, snd_pcm_uframes_t *); -static int (*ALSA_snd_pcm_hw_params_get_buffer_size) - (const snd_pcm_hw_params_t *, snd_pcm_uframes_t *); -static int (*ALSA_snd_pcm_hw_params) (snd_pcm_t *, snd_pcm_hw_params_t *); -static int (*ALSA_snd_pcm_sw_params_current) (snd_pcm_t *, - snd_pcm_sw_params_t *); -static int (*ALSA_snd_pcm_sw_params_set_start_threshold) - (snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t); -static int (*ALSA_snd_pcm_sw_params) (snd_pcm_t *, snd_pcm_sw_params_t *); -static int (*ALSA_snd_pcm_nonblock) (snd_pcm_t *, int); +static int (*ALSA_snd_pcm_open)(snd_pcm_t **, const char *, snd_pcm_stream_t, int); +static int (*ALSA_snd_pcm_close)(snd_pcm_t *pcm); +static snd_pcm_sframes_t (*ALSA_snd_pcm_writei)(snd_pcm_t *, const void *, snd_pcm_uframes_t); +static snd_pcm_sframes_t (*ALSA_snd_pcm_readi)(snd_pcm_t *, void *, snd_pcm_uframes_t); +static int (*ALSA_snd_pcm_recover)(snd_pcm_t *, int, int); +static int (*ALSA_snd_pcm_prepare)(snd_pcm_t *); +static int (*ALSA_snd_pcm_drain)(snd_pcm_t *); +static const char *(*ALSA_snd_strerror)(int); +static size_t (*ALSA_snd_pcm_hw_params_sizeof)(void); +static size_t (*ALSA_snd_pcm_sw_params_sizeof)(void); +static void (*ALSA_snd_pcm_hw_params_copy)(snd_pcm_hw_params_t *, const snd_pcm_hw_params_t *); +static int (*ALSA_snd_pcm_hw_params_any)(snd_pcm_t *, snd_pcm_hw_params_t *); +static int (*ALSA_snd_pcm_hw_params_set_access)(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_access_t); +static int (*ALSA_snd_pcm_hw_params_set_format)(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_format_t); +static int (*ALSA_snd_pcm_hw_params_set_channels)(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int); +static int (*ALSA_snd_pcm_hw_params_get_channels)(const snd_pcm_hw_params_t *, unsigned int *); +static int (*ALSA_snd_pcm_hw_params_set_rate_near)(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *); +static int (*ALSA_snd_pcm_hw_params_set_period_size_near)(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *); +static int (*ALSA_snd_pcm_hw_params_get_period_size)(const snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *); +static int (*ALSA_snd_pcm_hw_params_set_periods_min)(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *); +static int (*ALSA_snd_pcm_hw_params_set_periods_first)(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *); +static int (*ALSA_snd_pcm_hw_params_get_periods)(const snd_pcm_hw_params_t *, unsigned int *, int *); +static int (*ALSA_snd_pcm_hw_params_set_buffer_size_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *, snd_pcm_uframes_t *); +static int (*ALSA_snd_pcm_hw_params_get_buffer_size)(const snd_pcm_hw_params_t *, snd_pcm_uframes_t *); +static int (*ALSA_snd_pcm_hw_params)(snd_pcm_t *, snd_pcm_hw_params_t *); +static int (*ALSA_snd_pcm_sw_params_current)(snd_pcm_t *, + snd_pcm_sw_params_t *); +static int (*ALSA_snd_pcm_sw_params_set_start_threshold)(snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t); +static int (*ALSA_snd_pcm_sw_params)(snd_pcm_t *, snd_pcm_sw_params_t *); +static int (*ALSA_snd_pcm_nonblock)(snd_pcm_t *, int); static int (*ALSA_snd_pcm_wait)(snd_pcm_t *, int); -static int (*ALSA_snd_pcm_sw_params_set_avail_min) - (snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t); +static int (*ALSA_snd_pcm_sw_params_set_avail_min)(snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t); static int (*ALSA_snd_pcm_reset)(snd_pcm_t *); -static int (*ALSA_snd_device_name_hint) (int, const char *, void ***); -static char* (*ALSA_snd_device_name_get_hint) (const void *, const char *); -static int (*ALSA_snd_device_name_free_hint) (void **); +static int (*ALSA_snd_device_name_hint)(int, const char *, void ***); +static char *(*ALSA_snd_device_name_get_hint)(const void *, const char *); +static int (*ALSA_snd_device_name_free_hint)(void **); static snd_pcm_sframes_t (*ALSA_snd_pcm_avail)(snd_pcm_t *); #ifdef SND_CHMAP_API_VERSION -static snd_pcm_chmap_t* (*ALSA_snd_pcm_get_chmap) (snd_pcm_t *); -static int (*ALSA_snd_pcm_chmap_print) (const snd_pcm_chmap_t *map, size_t maxlen, char *buf); +static snd_pcm_chmap_t *(*ALSA_snd_pcm_get_chmap)(snd_pcm_t *); +static int (*ALSA_snd_pcm_chmap_print)(const snd_pcm_chmap_t *map, size_t maxlen, char *buf); #endif #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC @@ -113,8 +95,7 @@ static int (*ALSA_snd_pcm_chmap_print) (const snd_pcm_chmap_t *map, size_t maxle static const char *alsa_library = SDL_AUDIO_DRIVER_ALSA_DYNAMIC; static void *alsa_handle = NULL; -static int -load_alsa_sym(const char *fn, void **addr) +static int load_alsa_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(alsa_handle, fn); if (*addr == NULL) { @@ -126,14 +107,14 @@ load_alsa_sym(const char *fn, void **addr) } /* cast funcs to char* first, to please GCC's strict aliasing rules. */ -#define SDL_ALSA_SYM(x) \ - if (!load_alsa_sym(#x, (void **) (char *) &ALSA_##x)) return -1 +#define SDL_ALSA_SYM(x) \ + if (!load_alsa_sym(#x, (void **)(char *)&ALSA_##x)) \ + return -1 #else #define SDL_ALSA_SYM(x) ALSA_##x = x #endif -static int -load_alsa_syms(void) +static int load_alsa_syms(void) { SDL_ALSA_SYM(snd_pcm_open); SDL_ALSA_SYM(snd_pcm_close); @@ -183,8 +164,7 @@ load_alsa_syms(void) #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC -static void -UnloadALSALibrary(void) +static void UnloadALSALibrary(void) { if (alsa_handle != NULL) { SDL_UnloadObject(alsa_handle); @@ -192,8 +172,7 @@ UnloadALSALibrary(void) } } -static int -LoadALSALibrary(void) +static int LoadALSALibrary(void) { int retval = 0; if (alsa_handle == NULL) { @@ -213,13 +192,11 @@ LoadALSALibrary(void) #else -static void -UnloadALSALibrary(void) +static void UnloadALSALibrary(void) { } -static int -LoadALSALibrary(void) +static int LoadALSALibrary(void) { load_alsa_syms(); return 0; @@ -227,8 +204,7 @@ LoadALSALibrary(void) #endif /* SDL_AUDIO_DRIVER_ALSA_DYNAMIC */ -static const char * -get_audio_device(void *handle, const int channels) +static const char *get_audio_device(void *handle, const int channels) { const char *device; @@ -237,7 +213,7 @@ get_audio_device(void *handle, const int channels) } /* !!! FIXME: we also check "SDL_AUDIO_DEVICE_NAME" at the higher level. */ - device = SDL_getenv("AUDIODEV"); /* Is there a standard variable name? */ + device = SDL_getenv("AUDIODEV"); /* Is there a standard variable name? */ if (device != NULL) { return device; } @@ -251,49 +227,50 @@ get_audio_device(void *handle, const int channels) return "default"; } - /* This function waits until it is possible to write a full sound buffer */ -static void -ALSA_WaitDevice(_THIS) +static void ALSA_WaitDevice(_THIS) { #if SDL_ALSA_NON_BLOCKING - const snd_pcm_sframes_t needed = (snd_pcm_sframes_t) this->spec.samples; + const snd_pcm_sframes_t needed = (snd_pcm_sframes_t)this->spec.samples; while (SDL_AtomicGet(&this->enabled)) { const snd_pcm_sframes_t rc = ALSA_snd_pcm_avail(this->hidden->pcm_handle); if ((rc < 0) && (rc != -EAGAIN)) { /* Hmm, not much we can do - abort */ fprintf(stderr, "ALSA snd_pcm_avail failed (unrecoverable): %s\n", - ALSA_snd_strerror(rc)); + ALSA_snd_strerror(rc)); SDL_OpenedAudioDeviceDisconnected(this); return; } else if (rc < needed) { const Uint32 delay = ((needed - (SDL_max(rc, 0))) * 1000) / this->spec.freq; SDL_Delay(SDL_max(delay, 10)); } else { - break; /* ready to go! */ + break; /* ready to go! */ } } #endif } - /* !!! FIXME: is there a channel swizzler in alsalib instead? */ /* * https://bugzilla.libsdl.org/show_bug.cgi?id=110 * "For Linux ALSA, this is FL-FR-RL-RR-C-LFE * and for Windows DirectX [and CoreAudio], this is FL-FR-C-LFE-RL-RR" */ -#define SWIZ6(T) \ -static void swizzle_alsa_channels_6_##T(void *buffer, const Uint32 bufferlen) { \ - T *ptr = (T *) buffer; \ - Uint32 i; \ - for (i = 0; i < bufferlen; i++, ptr += 6) { \ - T tmp; \ - tmp = ptr[2]; ptr[2] = ptr[4]; ptr[4] = tmp; \ - tmp = ptr[3]; ptr[3] = ptr[5]; ptr[5] = tmp; \ - } \ -} - +#define SWIZ6(T) \ + static void swizzle_alsa_channels_6_##T(void *buffer, const Uint32 bufferlen) \ + { \ + T *ptr = (T *)buffer; \ + Uint32 i; \ + for (i = 0; i < bufferlen; i++, ptr += 6) { \ + T tmp; \ + tmp = ptr[2]; \ + ptr[2] = ptr[4]; \ + ptr[4] = tmp; \ + tmp = ptr[3]; \ + ptr[3] = ptr[5]; \ + ptr[5] = tmp; \ + } \ + } /* !!! FIXME: is there a channel swizzler in alsalib instead? */ /* !!! FIXME: this screams for a SIMD shuffle operation. */ @@ -302,31 +279,32 @@ static void swizzle_alsa_channels_6_##T(void *buffer, const Uint32 bufferlen) { * For Linux ALSA, this appears to be FL-FR-RL-RR-C-LFE-SL-SR * and for Windows DirectX [and CoreAudio], this is FL-FR-C-LFE-SL-SR-RL-RR" */ -#define SWIZ8(T) \ -static void swizzle_alsa_channels_8_##T(void *buffer, const Uint32 bufferlen) { \ - T *ptr = (T *) buffer; \ - Uint32 i; \ - for (i = 0; i < bufferlen; i++, ptr += 6) { \ - const T center = ptr[2]; \ - const T subwoofer = ptr[3]; \ - const T side_left = ptr[4]; \ - const T side_right = ptr[5]; \ - const T rear_left = ptr[6]; \ - const T rear_right = ptr[7]; \ - ptr[2] = rear_left; \ - ptr[3] = rear_right; \ - ptr[4] = center; \ - ptr[5] = subwoofer; \ - ptr[6] = side_left; \ - ptr[7] = side_right; \ - } \ -} +#define SWIZ8(T) \ + static void swizzle_alsa_channels_8_##T(void *buffer, const Uint32 bufferlen) \ + { \ + T *ptr = (T *)buffer; \ + Uint32 i; \ + for (i = 0; i < bufferlen; i++, ptr += 6) { \ + const T center = ptr[2]; \ + const T subwoofer = ptr[3]; \ + const T side_left = ptr[4]; \ + const T side_right = ptr[5]; \ + const T rear_left = ptr[6]; \ + const T rear_right = ptr[7]; \ + ptr[2] = rear_left; \ + ptr[3] = rear_right; \ + ptr[4] = center; \ + ptr[5] = subwoofer; \ + ptr[6] = side_left; \ + ptr[7] = side_right; \ + } \ + } #define CHANNEL_SWIZZLE(x) \ - x(Uint64) \ - x(Uint32) \ - x(Uint16) \ - x(Uint8) + x(Uint64) \ + x(Uint32) \ + x(Uint16) \ + x(Uint8) CHANNEL_SWIZZLE(SWIZ6) CHANNEL_SWIZZLE(SWIZ8) @@ -335,53 +313,59 @@ CHANNEL_SWIZZLE(SWIZ8) #undef SWIZ6 #undef SWIZ8 - /* * Called right before feeding this->hidden->mixbuf to the hardware. Swizzle * channels from Windows/Mac order to the format alsalib will want. */ -static void -swizzle_alsa_channels(_THIS, void *buffer, Uint32 bufferlen) +static void swizzle_alsa_channels(_THIS, void *buffer, Uint32 bufferlen) { switch (this->spec.channels) { - #define CHANSWIZ(chans) \ - case chans: \ - switch ((this->spec.format & (0xFF))) { \ - case 8: swizzle_alsa_channels_##chans##_Uint8(buffer, bufferlen); break; \ - case 16: swizzle_alsa_channels_##chans##_Uint16(buffer, bufferlen); break; \ - case 32: swizzle_alsa_channels_##chans##_Uint32(buffer, bufferlen); break; \ - case 64: swizzle_alsa_channels_##chans##_Uint64(buffer, bufferlen); break; \ - default: SDL_assert(!"unhandled bitsize"); break; \ - } \ - return; +#define CHANSWIZ(chans) \ + case chans: \ + switch ((this->spec.format & (0xFF))) { \ + case 8: \ + swizzle_alsa_channels_##chans##_Uint8(buffer, bufferlen); \ + break; \ + case 16: \ + swizzle_alsa_channels_##chans##_Uint16(buffer, bufferlen); \ + break; \ + case 32: \ + swizzle_alsa_channels_##chans##_Uint32(buffer, bufferlen); \ + break; \ + case 64: \ + swizzle_alsa_channels_##chans##_Uint64(buffer, bufferlen); \ + break; \ + default: \ + SDL_assert(!"unhandled bitsize"); \ + break; \ + } \ + return; CHANSWIZ(6); CHANSWIZ(8); - #undef CHANSWIZ - default: break; +#undef CHANSWIZ + default: + break; } } #ifdef SND_CHMAP_API_VERSION /* Some devices have the right channel map, no swizzling necessary */ -static void -no_swizzle(_THIS, void *buffer, Uint32 bufferlen) +static void no_swizzle(_THIS, void *buffer, Uint32 bufferlen) { } #endif /* SND_CHMAP_API_VERSION */ - -static void -ALSA_PlayDevice(_THIS) +static void ALSA_PlayDevice(_THIS) { - const Uint8 *sample_buf = (const Uint8 *) this->hidden->mixbuf; + const Uint8 *sample_buf = (const Uint8 *)this->hidden->mixbuf; const int frame_size = ((SDL_AUDIO_BITSIZE(this->spec.format)) / 8) * - this->spec.channels; - snd_pcm_uframes_t frames_left = ((snd_pcm_uframes_t) this->spec.samples); + this->spec.channels; + snd_pcm_uframes_t frames_left = ((snd_pcm_uframes_t)this->spec.samples); this->hidden->swizzle_func(this, this->hidden->mixbuf, frames_left); - while ( frames_left > 0 && SDL_AtomicGet(&this->enabled) ) { + while (frames_left > 0 && SDL_AtomicGet(&this->enabled)) { int status = ALSA_snd_pcm_writei(this->hidden->pcm_handle, sample_buf, frames_left); @@ -413,29 +397,27 @@ ALSA_PlayDevice(_THIS) } } -static Uint8 * -ALSA_GetDeviceBuf(_THIS) +static Uint8 *ALSA_GetDeviceBuf(_THIS) { return this->hidden->mixbuf; } -static int -ALSA_CaptureFromDevice(_THIS, void *buffer, int buflen) +static int ALSA_CaptureFromDevice(_THIS, void *buffer, int buflen) { - Uint8 *sample_buf = (Uint8 *) buffer; + Uint8 *sample_buf = (Uint8 *)buffer; const int frame_size = ((SDL_AUDIO_BITSIZE(this->spec.format)) / 8) * - this->spec.channels; + this->spec.channels; const int total_frames = buflen / frame_size; snd_pcm_uframes_t frames_left = total_frames; snd_pcm_uframes_t wait_time = frame_size / 2; SDL_assert((buflen % frame_size) == 0); - while ( frames_left > 0 && SDL_AtomicGet(&this->enabled) ) { + while (frames_left > 0 && SDL_AtomicGet(&this->enabled)) { int status; status = ALSA_snd_pcm_readi(this->hidden->pcm_handle, - sample_buf, frames_left); + sample_buf, frames_left); if (status == -EAGAIN) { ALSA_snd_pcm_wait(this->hidden->pcm_handle, wait_time); @@ -462,14 +444,12 @@ ALSA_CaptureFromDevice(_THIS, void *buffer, int buflen) return (total_frames - frames_left) * frame_size; } -static void -ALSA_FlushCapture(_THIS) +static void ALSA_FlushCapture(_THIS) { ALSA_snd_pcm_reset(this->hidden->pcm_handle); } -static void -ALSA_CloseDevice(_THIS) +static void ALSA_CloseDevice(_THIS) { if (this->hidden->pcm_handle) { /* Wait for the submitted audio to drain @@ -484,8 +464,7 @@ ALSA_CloseDevice(_THIS) SDL_free(this->hidden); } -static int -ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params) +static int ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params) { int status; snd_pcm_hw_params_t *hwparams; @@ -499,49 +478,48 @@ ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params) /* Attempt to match the period size to the requested buffer size */ persize = this->spec.samples; status = ALSA_snd_pcm_hw_params_set_period_size_near( - this->hidden->pcm_handle, hwparams, &persize, NULL); - if ( status < 0 ) { + this->hidden->pcm_handle, hwparams, &persize, NULL); + if (status < 0) { return -1; } /* Need to at least double buffer */ periods = 2; status = ALSA_snd_pcm_hw_params_set_periods_min( - this->hidden->pcm_handle, hwparams, &periods, NULL); - if ( status < 0 ) { + this->hidden->pcm_handle, hwparams, &periods, NULL); + if (status < 0) { return -1; } status = ALSA_snd_pcm_hw_params_set_periods_first( - this->hidden->pcm_handle, hwparams, &periods, NULL); - if ( status < 0 ) { + this->hidden->pcm_handle, hwparams, &periods, NULL); + if (status < 0) { return -1; } /* "set" the hardware with the desired parameters */ status = ALSA_snd_pcm_hw_params(this->hidden->pcm_handle, hwparams); - if ( status < 0 ) { + if (status < 0) { return -1; } this->spec.samples = persize; /* This is useful for debugging */ - if ( SDL_getenv("SDL_AUDIO_ALSA_DEBUG") ) { + if (SDL_getenv("SDL_AUDIO_ALSA_DEBUG")) { snd_pcm_uframes_t bufsize; ALSA_snd_pcm_hw_params_get_buffer_size(hwparams, &bufsize); fprintf(stderr, - "ALSA: period size = %ld, periods = %u, buffer size = %lu\n", - persize, periods, bufsize); + "ALSA: period size = %ld, periods = %u, buffer size = %lu\n", + persize, periods, bufsize); } return 0; } -static int -ALSA_OpenDevice(_THIS, const char *devname) +static int ALSA_OpenDevice(_THIS, const char *devname) { int status = 0; SDL_bool iscapture = this->iscapture; @@ -568,9 +546,9 @@ ALSA_OpenDevice(_THIS, const char *devname) /* Open the audio device */ /* Name of device should depend on # channels in spec */ status = ALSA_snd_pcm_open(&pcm_handle, - get_audio_device(this->handle, this->spec.channels), - iscapture ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK, - SND_PCM_NONBLOCK); + get_audio_device(this->handle, this->spec.channels), + iscapture ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK, + SND_PCM_NONBLOCK); if (status < 0) { return SDL_SetError("ALSA: Couldn't open audio device: %s", ALSA_snd_strerror(status)); @@ -707,18 +685,18 @@ ALSA_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ if (!iscapture) { this->hidden->mixlen = this->spec.size; - this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); + this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen); if (this->hidden->mixbuf == NULL) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->hidden->mixlen); } - #if !SDL_ALSA_NON_BLOCKING +#if !SDL_ALSA_NON_BLOCKING if (!iscapture) { ALSA_snd_pcm_nonblock(pcm_handle, 0); } - #endif +#endif /* We're ready to rock and roll. :-) */ return 0; @@ -731,10 +709,9 @@ typedef struct ALSA_Device struct ALSA_Device *next; } ALSA_Device; -static void -add_device(const int iscapture, const char *name, void *hint, ALSA_Device **pSeen) +static void add_device(const int iscapture, const char *name, void *hint, ALSA_Device **pSeen) { - ALSA_Device *dev = SDL_malloc(sizeof (ALSA_Device)); + ALSA_Device *dev = SDL_malloc(sizeof(ALSA_Device)); char *desc; char *handle = NULL; char *ptr; @@ -754,7 +731,7 @@ add_device(const int iscapture, const char *name, void *hint, ALSA_Device **pSee return; } } else { - desc = (char *) name; + desc = (char *)name; } SDL_assert(name != NULL); @@ -791,11 +768,9 @@ add_device(const int iscapture, const char *name, void *hint, ALSA_Device **pSee *pSeen = dev; } - static ALSA_Device *hotplug_devices = NULL; -static void -ALSA_HotplugIteration(void) +static void ALSA_HotplugIteration(void) { void **hints = NULL; ALSA_Device *dev; @@ -810,7 +785,7 @@ ALSA_HotplugIteration(void) int bestmatch = 0xFFFF; size_t match_len = 0; int defaultdev = -1; - static const char * const prefixes[] = { + static const char *const prefixes[] = { "hw:", "sysdefault:", "default:", NULL }; @@ -853,7 +828,7 @@ ALSA_HotplugIteration(void) /* if we didn't find a device name prefix we like at all... */ if ((match == NULL) && (defaultdev != i)) { - continue; /* ...skip anything that isn't the default device. */ + continue; /* ...skip anything that isn't the default device. */ } name = ALSA_snd_device_name_get_hint(hints[i], "NAME"); @@ -879,7 +854,7 @@ ALSA_HotplugIteration(void) prev = NULL; for (dev = unseen; dev; dev = next) { next = dev->next; - if ( (SDL_strcmp(dev->name, name) == 0) && (((isinput) && dev->iscapture) || ((isoutput) && !dev->iscapture)) ) { + if ((SDL_strcmp(dev->name, name) == 0) && (((isinput) && dev->iscapture) || ((isoutput) && !dev->iscapture))) { if (prev) { prev->next = next; } else { @@ -911,7 +886,7 @@ ALSA_HotplugIteration(void) ALSA_snd_device_name_free_hint(hints); - hotplug_devices = seen; /* now we have a known-good list of attached devices. */ + hotplug_devices = seen; /* now we have a known-good list of attached devices. */ /* report anything still in unseen as removed. */ for (dev = unseen; dev; dev = next) { @@ -928,8 +903,7 @@ ALSA_HotplugIteration(void) static SDL_atomic_t ALSA_hotplug_shutdown; static SDL_Thread *ALSA_hotplug_thread; -static int SDLCALL -ALSA_HotplugThread(void *arg) +static int SDLCALL ALSA_HotplugThread(void *arg) { SDL_SetThreadPriority(SDL_THREAD_PRIORITY_LOW); @@ -940,17 +914,16 @@ ALSA_HotplugThread(void *arg) SDL_Delay(100); } - ALSA_HotplugIteration(); /* run the check. */ + ALSA_HotplugIteration(); /* run the check. */ } return 0; } #endif -static void -ALSA_DetectDevices(void) +static void ALSA_DetectDevices(void) { - ALSA_HotplugIteration(); /* run once now before a thread continues to check. */ + ALSA_HotplugIteration(); /* run once now before a thread continues to check. */ #if SDL_ALSA_HOTPLUG_THREAD SDL_AtomicSet(&ALSA_hotplug_shutdown, 0); @@ -959,8 +932,7 @@ ALSA_DetectDevices(void) #endif } -static void -ALSA_Deinitialize(void) +static void ALSA_Deinitialize(void) { ALSA_Device *dev; ALSA_Device *next; @@ -985,8 +957,7 @@ ALSA_Deinitialize(void) UnloadALSALibrary(); } -static SDL_bool -ALSA_Init(SDL_AudioDriverImpl * impl) +static SDL_bool ALSA_Init(SDL_AudioDriverImpl *impl) { if (LoadALSALibrary() < 0) { return SDL_FALSE; @@ -1006,10 +977,9 @@ ALSA_Init(SDL_AudioDriverImpl * impl) impl->HasCaptureSupport = SDL_TRUE; impl->SupportsNonPow2Samples = SDL_TRUE; - return SDL_TRUE; /* this audio target is available. */ + return SDL_TRUE; /* this audio target is available. */ } - AudioBootStrap ALSA_bootstrap = { "alsa", "ALSA PCM audio", ALSA_Init, SDL_FALSE }; diff --git a/src/audio/alsa/SDL_alsa_audio.h b/src/audio/alsa/SDL_alsa_audio.h index 5ec339d91..d1ba17663 100644 --- a/src/audio/alsa/SDL_alsa_audio.h +++ b/src/audio/alsa/SDL_alsa_audio.h @@ -28,7 +28,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { diff --git a/src/audio/android/SDL_androidaudio.c b/src/audio/android/SDL_androidaudio.c index 7db3cbc30..60779b049 100644 --- a/src/audio/android/SDL_androidaudio.c +++ b/src/audio/android/SDL_androidaudio.c @@ -32,11 +32,10 @@ #include -static SDL_AudioDevice* audioDevice = NULL; -static SDL_AudioDevice* captureDevice = NULL; +static SDL_AudioDevice *audioDevice = NULL; +static SDL_AudioDevice *captureDevice = NULL; -static int -ANDROIDAUDIO_OpenDevice(_THIS, const char *devname) +static int ANDROIDAUDIO_OpenDevice(_THIS, const char *devname) { SDL_AudioFormat test_format; SDL_bool iscapture = this->iscapture; @@ -50,7 +49,7 @@ ANDROIDAUDIO_OpenDevice(_THIS, const char *devname) audioDevice = this; } - this->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, (sizeof *this->hidden)); + this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, (sizeof *this->hidden)); if (this->hidden == NULL) { return SDL_OutOfMemory(); } @@ -78,32 +77,27 @@ ANDROIDAUDIO_OpenDevice(_THIS, const char *devname) return 0; } -static void -ANDROIDAUDIO_PlayDevice(_THIS) +static void ANDROIDAUDIO_PlayDevice(_THIS) { Android_JNI_WriteAudioBuffer(); } -static Uint8 * -ANDROIDAUDIO_GetDeviceBuf(_THIS) +static Uint8 *ANDROIDAUDIO_GetDeviceBuf(_THIS) { return Android_JNI_GetAudioBuffer(); } -static int -ANDROIDAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) +static int ANDROIDAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) { return Android_JNI_CaptureAudioBuffer(buffer, buflen); } -static void -ANDROIDAUDIO_FlushCapture(_THIS) +static void ANDROIDAUDIO_FlushCapture(_THIS) { Android_JNI_FlushCapturedAudio(); } -static void -ANDROIDAUDIO_CloseDevice(_THIS) +static void ANDROIDAUDIO_CloseDevice(_THIS) { /* At this point SDL_CloseAudioDevice via close_audio_device took care of terminating the audio thread so it's safe to terminate the Java side buffer and AudioTrack @@ -119,8 +113,7 @@ ANDROIDAUDIO_CloseDevice(_THIS) SDL_free(this->hidden); } -static SDL_bool -ANDROIDAUDIO_Init(SDL_AudioDriverImpl * impl) +static SDL_bool ANDROIDAUDIO_Init(SDL_AudioDriverImpl *impl) { /* Set the function pointers */ impl->OpenDevice = ANDROIDAUDIO_OpenDevice; @@ -135,7 +128,7 @@ ANDROIDAUDIO_Init(SDL_AudioDriverImpl * impl) impl->OnlyHasDefaultOutputDevice = SDL_TRUE; impl->OnlyHasDefaultCaptureDevice = SDL_TRUE; - return SDL_TRUE; /* this audio target is available. */ + return SDL_TRUE; /* this audio target is available. */ } AudioBootStrap ANDROIDAUDIO_bootstrap = { @@ -148,7 +141,7 @@ void ANDROIDAUDIO_PauseDevices(void) /* TODO: Handle multiple devices? */ struct SDL_PrivateAudioData *private; if (audioDevice != NULL && audioDevice->hidden != NULL) { - private = (struct SDL_PrivateAudioData *) audioDevice->hidden; + private = (struct SDL_PrivateAudioData *)audioDevice->hidden; if (SDL_AtomicGet(&audioDevice->paused)) { /* The device is already paused, leave it alone */ private->resume = SDL_FALSE; @@ -160,7 +153,7 @@ void ANDROIDAUDIO_PauseDevices(void) } if (captureDevice != NULL && captureDevice->hidden != NULL) { - private = (struct SDL_PrivateAudioData *) captureDevice->hidden; + private = (struct SDL_PrivateAudioData *)captureDevice->hidden; if (SDL_AtomicGet(&captureDevice->paused)) { /* The device is already paused, leave it alone */ private->resume = SDL_FALSE; @@ -178,7 +171,7 @@ void ANDROIDAUDIO_ResumeDevices(void) /* TODO: Handle multiple devices? */ struct SDL_PrivateAudioData *private; if (audioDevice != NULL && audioDevice->hidden != NULL) { - private = (struct SDL_PrivateAudioData *) audioDevice->hidden; + private = (struct SDL_PrivateAudioData *)audioDevice->hidden; if (private->resume) { SDL_AtomicSet(&audioDevice->paused, 0); private->resume = SDL_FALSE; @@ -187,7 +180,7 @@ void ANDROIDAUDIO_ResumeDevices(void) } if (captureDevice != NULL && captureDevice->hidden != NULL) { - private = (struct SDL_PrivateAudioData *) captureDevice->hidden; + private = (struct SDL_PrivateAudioData *)captureDevice->hidden; if (private->resume) { SDL_AtomicSet(&captureDevice->paused, 0); private->resume = SDL_FALSE; @@ -196,7 +189,7 @@ void ANDROIDAUDIO_ResumeDevices(void) } } -#else +#else void ANDROIDAUDIO_ResumeDevices(void) {} void ANDROIDAUDIO_PauseDevices(void) {} @@ -204,4 +197,3 @@ void ANDROIDAUDIO_PauseDevices(void) {} #endif /* SDL_AUDIO_DRIVER_ANDROID */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/audio/android/SDL_androidaudio.h b/src/audio/android/SDL_androidaudio.h index a04975864..791e91ac8 100644 --- a/src/audio/android/SDL_androidaudio.h +++ b/src/audio/android/SDL_androidaudio.h @@ -26,7 +26,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { diff --git a/src/audio/coreaudio/SDL_coreaudio.h b/src/audio/coreaudio/SDL_coreaudio.h index 9353046a4..cc6aaf85d 100644 --- a/src/audio/coreaudio/SDL_coreaudio.h +++ b/src/audio/coreaudio/SDL_coreaudio.h @@ -48,7 +48,7 @@ #endif /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { diff --git a/src/audio/coreaudio/SDL_coreaudio.m b/src/audio/coreaudio/SDL_coreaudio.m index d22335912..3ef0a7f79 100644 --- a/src/audio/coreaudio/SDL_coreaudio.m +++ b/src/audio/coreaudio/SDL_coreaudio.m @@ -34,21 +34,20 @@ #define DEBUG_COREAUDIO 0 #if DEBUG_COREAUDIO - #define CHECK_RESULT(msg) \ - if (result != noErr) { \ - printf("COREAUDIO: Got error %d from '%s'!\n", (int) result, msg); \ - SDL_SetError("CoreAudio error (%s): %d", msg, (int) result); \ - return 0; \ - } +#define CHECK_RESULT(msg) \ + if (result != noErr) { \ + printf("COREAUDIO: Got error %d from '%s'!\n", (int)result, msg); \ + SDL_SetError("CoreAudio error (%s): %d", msg, (int)result); \ + return 0; \ + } #else - #define CHECK_RESULT(msg) \ - if (result != noErr) { \ - SDL_SetError("CoreAudio error (%s): %d", msg, (int) result); \ - return 0; \ - } +#define CHECK_RESULT(msg) \ + if (result != noErr) { \ + SDL_SetError("CoreAudio error (%s): %d", msg, (int)result); \ + return 0; \ + } #endif - #if MACOSX_COREAUDIO static const AudioObjectPropertyAddress devlist_address = { kAudioHardwarePropertyDevices, @@ -68,10 +67,9 @@ typedef struct AudioDeviceList static AudioDeviceList *output_devs = NULL; static AudioDeviceList *capture_devs = NULL; -static SDL_bool -add_to_internal_dev_list(const int iscapture, AudioDeviceID devId) +static SDL_bool add_to_internal_dev_list(const int iscapture, AudioDeviceID devId) { - AudioDeviceList *item = (AudioDeviceList *) SDL_malloc(sizeof (AudioDeviceList)); + AudioDeviceList *item = (AudioDeviceList *)SDL_malloc(sizeof(AudioDeviceList)); if (item == NULL) { return SDL_FALSE; } @@ -87,16 +85,14 @@ add_to_internal_dev_list(const int iscapture, AudioDeviceID devId) return SDL_TRUE; } -static void -addToDevList(const char *name, SDL_AudioSpec *spec, const int iscapture, AudioDeviceID devId, void *data) +static void addToDevList(const char *name, SDL_AudioSpec *spec, const int iscapture, AudioDeviceID devId, void *data) { if (add_to_internal_dev_list(iscapture, devId)) { - SDL_AddAudioDevice(iscapture, name, spec, (void *) ((size_t) devId)); + SDL_AddAudioDevice(iscapture, name, spec, (void *)((size_t)devId)); } } -static void -build_device_list(int iscapture, addDevFn addfn, void *addfndata) +static void build_device_list(int iscapture, addDevFn addfn, void *addfndata) { OSStatus result = noErr; UInt32 size = 0; @@ -109,7 +105,7 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata) if (result != kAudioHardwareNoError) return; - devs = (AudioDeviceID *) alloca(size); + devs = (AudioDeviceID *)alloca(size); if (devs == NULL) return; @@ -118,7 +114,7 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata) if (result != kAudioHardwareNoError) return; - max = size / sizeof (AudioDeviceID); + max = size / sizeof(AudioDeviceID); for (i = 0; i < max; i++) { CFStringRef cfstr = NULL; char *ptr = NULL; @@ -148,7 +144,7 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata) if (result != noErr) continue; - buflist = (AudioBufferList *) SDL_malloc(size); + buflist = (AudioBufferList *)SDL_malloc(size); if (buflist == NULL) continue; @@ -168,13 +164,13 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata) if (spec.channels == 0) continue; - size = sizeof (sampleRate); + size = sizeof(sampleRate); result = AudioObjectGetPropertyData(dev, &freqaddr, 0, NULL, &size, &sampleRate); if (result == noErr) { - spec.freq = (int) sampleRate; + spec.freq = (int)sampleRate; } - size = sizeof (CFStringRef); + size = sizeof(CFStringRef); result = AudioObjectGetPropertyData(dev, &nameaddr, 0, NULL, &size, &cfstr); if (result != kAudioHardwareNoError) continue; @@ -182,10 +178,9 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata) len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(cfstr), kCFStringEncodingUTF8); - ptr = (char *) SDL_malloc(len + 1); + ptr = (char *)SDL_malloc(len + 1); usable = ((ptr != NULL) && - (CFStringGetCString - (cfstr, ptr, len + 1, kCFStringEncodingUTF8))); + (CFStringGetCString(cfstr, ptr, len + 1, kCFStringEncodingUTF8))); CFRelease(cfstr); @@ -204,16 +199,15 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata) #if DEBUG_COREAUDIO printf("COREAUDIO: Found %s device #%d: '%s' (devid %d)\n", ((iscapture) ? "capture" : "output"), - (int) i, ptr, (int) dev); + (int)i, ptr, (int)dev); #endif addfn(ptr, &spec, iscapture, dev, addfndata); } - SDL_free(ptr); /* addfn() would have copied the string. */ + SDL_free(ptr); /* addfn() would have copied the string. */ } } -static void -free_audio_device_list(AudioDeviceList **list) +static void free_audio_device_list(AudioDeviceList **list) { AudioDeviceList *item = *list; while (item) { @@ -224,17 +218,15 @@ free_audio_device_list(AudioDeviceList **list) *list = NULL; } -static void -COREAUDIO_DetectDevices(void) +static void COREAUDIO_DetectDevices(void) { build_device_list(SDL_TRUE, addToDevList, NULL); build_device_list(SDL_FALSE, addToDevList, NULL); } -static void -build_device_change_list(const char *name, SDL_AudioSpec *spec, const int iscapture, AudioDeviceID devId, void *data) +static void build_device_change_list(const char *name, SDL_AudioSpec *spec, const int iscapture, AudioDeviceID devId, void *data) { - AudioDeviceList **list = (AudioDeviceList **) data; + AudioDeviceList **list = (AudioDeviceList **)data; AudioDeviceList *item; for (item = *list; item != NULL; item = item->next) { if (item->devid == devId) { @@ -243,12 +235,11 @@ build_device_change_list(const char *name, SDL_AudioSpec *spec, const int iscapt } } - add_to_internal_dev_list(iscapture, devId); /* new device, add it. */ - SDL_AddAudioDevice(iscapture, name, spec, (void *) ((size_t) devId)); + add_to_internal_dev_list(iscapture, devId); /* new device, add it. */ + SDL_AddAudioDevice(iscapture, name, spec, (void *)((size_t)devId)); } -static void -reprocess_device_list(const int iscapture, AudioDeviceList **list) +static void reprocess_device_list(const int iscapture, AudioDeviceList **list) { AudioDeviceList *item; AudioDeviceList *prev = NULL; @@ -265,7 +256,7 @@ reprocess_device_list(const int iscapture, AudioDeviceList **list) if (item->alive) { prev = item; } else { - SDL_RemoveAudioDevice(iscapture, (void *) ((size_t) item->devid)); + SDL_RemoveAudioDevice(iscapture, (void *)((size_t)item->devid)); if (prev) { prev->next = item->next; } else { @@ -278,8 +269,7 @@ reprocess_device_list(const int iscapture, AudioDeviceList **list) } /* this is called when the system's list of available audio devices changes. */ -static OSStatus -device_list_changed(AudioObjectID systemObj, UInt32 num_addr, const AudioObjectPropertyAddress *addrs, void *data) +static OSStatus device_list_changed(AudioObjectID systemObj, UInt32 num_addr, const AudioObjectPropertyAddress *addrs, void *data) { reprocess_device_list(SDL_TRUE, &capture_devs); reprocess_device_list(SDL_FALSE, &output_devs); @@ -287,7 +277,6 @@ device_list_changed(AudioObjectID systemObj, UInt32 num_addr, const AudioObjectP } #endif - static int open_playback_devices; static int open_capture_devices; static int num_open_devices; @@ -339,16 +328,14 @@ static void interruption_begin(_THIS) static void interruption_end(_THIS) { - if (this != NULL && this->hidden != NULL && this->hidden->audioQueue != NULL - && this->hidden->interrupted - && AudioQueueStart(this->hidden->audioQueue, NULL) == AVAudioSessionErrorCodeNone) { + if (this != NULL && this->hidden != NULL && this->hidden->audioQueue != NULL && this->hidden->interrupted && AudioQueueStart(this->hidden->audioQueue, NULL) == AVAudioSessionErrorCodeNone) { this->hidden->interrupted = SDL_FALSE; } } @interface SDLInterruptionListener : NSObject -@property (nonatomic, assign) SDL_AudioDevice *device; +@property(nonatomic, assign) SDL_AudioDevice *device; @end @@ -356,7 +343,7 @@ static void interruption_end(_THIS) - (void)audioSessionInterruption:(NSNotification *)note { - @synchronized (self) { + @synchronized(self) { NSNumber *type = note.userInfo[AVAudioSessionInterruptionTypeKey]; if (type.unsignedIntegerValue == AVAudioSessionInterruptionTypeBegan) { interruption_begin(self.device); @@ -368,7 +355,7 @@ static void interruption_end(_THIS) - (void)applicationBecameActive:(NSNotification *)note { - @synchronized (self) { + @synchronized(self) { interruption_end(self.device); } } @@ -504,9 +491,9 @@ static BOOL update_audio_session(_THIS, SDL_bool open, SDL_bool allow_playandrec this->hidden->interruption_listener = CFBridgingRetain(listener); } else { SDLInterruptionListener *listener = nil; - listener = (SDLInterruptionListener *) CFBridgingRelease(this->hidden->interruption_listener); + listener = (SDLInterruptionListener *)CFBridgingRelease(this->hidden->interruption_listener); [center removeObserver:listener]; - @synchronized (listener) { + @synchronized(listener) { listener.device = NULL; } } @@ -516,25 +503,23 @@ static BOOL update_audio_session(_THIS, SDL_bool open, SDL_bool allow_playandrec } #endif - /* The AudioQueue callback */ -static void -outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer) +static void outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer) { - SDL_AudioDevice *this = (SDL_AudioDevice *) inUserData; + SDL_AudioDevice *this = (SDL_AudioDevice *)inUserData; /* This flag is set before this->mixer_lock is destroyed during shutdown, so check it before grabbing the mutex, and then check it again _after_ in case we blocked waiting on the lock. */ if (SDL_AtomicGet(&this->shutdown)) { - return; /* don't do anything, since we don't even want to enqueue this buffer again. */ + return; /* don't do anything, since we don't even want to enqueue this buffer again. */ } SDL_LockMutex(this->mixer_lock); if (SDL_AtomicGet(&this->shutdown)) { SDL_UnlockMutex(this->mixer_lock); - return; /* don't do anything, since we don't even want to enqueue this buffer again. */ + return; /* don't do anything, since we don't even want to enqueue this buffer again. */ } if (!SDL_AtomicGet(&this->enabled) || SDL_AtomicGet(&this->paused)) { @@ -542,7 +527,7 @@ outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffe SDL_memset(inBuffer->mAudioData, this->spec.silence, inBuffer->mAudioDataBytesCapacity); } else if (this->stream) { UInt32 remaining = inBuffer->mAudioDataBytesCapacity; - Uint8 *ptr = (Uint8 *) inBuffer->mAudioData; + Uint8 *ptr = (Uint8 *)inBuffer->mAudioData; while (remaining > 0) { if (SDL_AudioStreamAvailable(this->stream) == 0) { @@ -568,14 +553,14 @@ outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffe } } else { UInt32 remaining = inBuffer->mAudioDataBytesCapacity; - Uint8 *ptr = (Uint8 *) inBuffer->mAudioData; + Uint8 *ptr = (Uint8 *)inBuffer->mAudioData; while (remaining > 0) { UInt32 len; if (this->hidden->bufferOffset >= this->hidden->bufferSize) { /* Generate the data */ (*this->callbackspec.callback)(this->callbackspec.userdata, - this->hidden->buffer, this->hidden->bufferSize); + this->hidden->buffer, this->hidden->bufferSize); this->hidden->bufferOffset = 0; } @@ -583,8 +568,7 @@ outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffe if (len > remaining) { len = remaining; } - SDL_memcpy(ptr, (char *)this->hidden->buffer + - this->hidden->bufferOffset, len); + SDL_memcpy(ptr, (char *)this->hidden->buffer + this->hidden->bufferOffset, len); ptr = ptr + len; remaining -= len; this->hidden->bufferOffset += len; @@ -598,20 +582,19 @@ outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffe SDL_UnlockMutex(this->mixer_lock); } -static void -inputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer, - const AudioTimeStamp *inStartTime, UInt32 inNumberPacketDescriptions, - const AudioStreamPacketDescription *inPacketDescs) +static void inputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer, + const AudioTimeStamp *inStartTime, UInt32 inNumberPacketDescriptions, + const AudioStreamPacketDescription *inPacketDescs) { - SDL_AudioDevice *this = (SDL_AudioDevice *) inUserData; + SDL_AudioDevice *this = (SDL_AudioDevice *)inUserData; if (SDL_AtomicGet(&this->shutdown)) { - return; /* don't do anything. */ + return; /* don't do anything. */ } /* ignore unless we're active. */ if (!SDL_AtomicGet(&this->paused) && SDL_AtomicGet(&this->enabled)) { - const Uint8 *ptr = (const Uint8 *) inBuffer->mAudioData; + const Uint8 *ptr = (const Uint8 *)inBuffer->mAudioData; UInt32 remaining = inBuffer->mAudioDataByteSize; while (remaining > 0) { UInt32 len = this->hidden->bufferSize - this->hidden->bufferOffset; @@ -636,35 +619,32 @@ inputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer AudioQueueEnqueueBuffer(this->hidden->audioQueue, inBuffer, 0, NULL); } - #if MACOSX_COREAUDIO -static const AudioObjectPropertyAddress alive_address = -{ +static const AudioObjectPropertyAddress alive_address = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMain }; -static OSStatus -device_unplugged(AudioObjectID devid, UInt32 num_addr, const AudioObjectPropertyAddress *addrs, void *data) +static OSStatus device_unplugged(AudioObjectID devid, UInt32 num_addr, const AudioObjectPropertyAddress *addrs, void *data) { - SDL_AudioDevice *this = (SDL_AudioDevice *) data; + SDL_AudioDevice *this = (SDL_AudioDevice *)data; SDL_bool dead = SDL_FALSE; UInt32 isAlive = 1; - UInt32 size = sizeof (isAlive); + UInt32 size = sizeof(isAlive); OSStatus error; if (!SDL_AtomicGet(&this->enabled)) { - return 0; /* already known to be dead. */ + return 0; /* already known to be dead. */ } error = AudioObjectGetPropertyData(this->hidden->deviceID, &alive_address, 0, NULL, &size, &isAlive); if (error == kAudioHardwareBadDeviceError) { - dead = SDL_TRUE; /* device was unplugged. */ + dead = SDL_TRUE; /* device was unplugged. */ } else if ((error == kAudioHardwareNoError) && (!isAlive)) { - dead = SDL_TRUE; /* device died in some other way. */ + dead = SDL_TRUE; /* device died in some other way. */ } if (dead) { @@ -675,20 +655,18 @@ device_unplugged(AudioObjectID devid, UInt32 num_addr, const AudioObjectProperty } /* macOS calls this when the default device changed (if we have a default device open). */ -static OSStatus -default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses, void *inUserData) +static OSStatus default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses, void *inUserData) { - SDL_AudioDevice *this = (SDL_AudioDevice *) inUserData; - #if DEBUG_COREAUDIO + SDL_AudioDevice *this = (SDL_AudioDevice *)inUserData; +#if DEBUG_COREAUDIO printf("COREAUDIO: default device changed for SDL audio device %p!\n", this); - #endif - SDL_AtomicSet(&this->hidden->device_change_flag, 1); /* let the audioqueue thread pick up on this when safe to do so. */ +#endif + SDL_AtomicSet(&this->hidden->device_change_flag, 1); /* let the audioqueue thread pick up on this when safe to do so. */ return noErr; } #endif -static void -COREAUDIO_CloseDevice(_THIS) +static void COREAUDIO_CloseDevice(_THIS) { const SDL_bool iscapture = this->iscapture; int i; @@ -696,7 +674,7 @@ COREAUDIO_CloseDevice(_THIS) /* !!! FIXME: what does iOS do when a bluetooth audio device vanishes? Headphones unplugged? */ /* !!! FIXME: (we only do a "default" device on iOS right now...can we do more?) */ #if MACOSX_COREAUDIO - if (this->handle != NULL) { /* we don't register this listener for default devices. */ + if (this->handle != NULL) { /* we don't register this listener for default devices. */ AudioObjectRemovePropertyListener(this->hidden->deviceID, &alive_address, device_unplugged, this); } #endif @@ -710,7 +688,7 @@ COREAUDIO_CloseDevice(_THIS) } if (this->hidden->thread) { - SDL_assert(SDL_AtomicGet(&this->shutdown) != 0); /* should have been set by SDL_audio.c */ + SDL_assert(SDL_AtomicGet(&this->shutdown) != 0); /* should have been set by SDL_audio.c */ SDL_WaitThread(this->hidden->thread, NULL); } @@ -728,7 +706,7 @@ COREAUDIO_CloseDevice(_THIS) if (open_devices[i] == this) { --num_open_devices; if (i < num_open_devices) { - SDL_memmove(&open_devices[i], &open_devices[i+1], sizeof(open_devices[i])*(num_open_devices - i)); + SDL_memmove(&open_devices[i], &open_devices[i + 1], sizeof(open_devices[i]) * (num_open_devices - i)); } break; } @@ -750,12 +728,11 @@ COREAUDIO_CloseDevice(_THIS) } #if MACOSX_COREAUDIO -static int -prepare_device(_THIS) +static int prepare_device(_THIS) { void *handle = this->handle; SDL_bool iscapture = this->iscapture; - AudioDeviceID devid = (AudioDeviceID) ((size_t) handle); + AudioDeviceID devid = (AudioDeviceID)((size_t)handle); OSStatus result = noErr; UInt32 size = 0; UInt32 alive = 0; @@ -768,23 +745,20 @@ prepare_device(_THIS) }; if (handle == NULL) { - size = sizeof (AudioDeviceID); + size = sizeof(AudioDeviceID); addr.mSelector = - ((iscapture) ? kAudioHardwarePropertyDefaultInputDevice : - kAudioHardwarePropertyDefaultOutputDevice); + ((iscapture) ? kAudioHardwarePropertyDefaultInputDevice : kAudioHardwarePropertyDefaultOutputDevice); result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr, 0, NULL, &size, &devid); CHECK_RESULT("AudioHardwareGetProperty (default device)"); } addr.mSelector = kAudioDevicePropertyDeviceIsAlive; - addr.mScope = iscapture ? kAudioDevicePropertyScopeInput : - kAudioDevicePropertyScopeOutput; + addr.mScope = iscapture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput; - size = sizeof (alive); + size = sizeof(alive); result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &alive); - CHECK_RESULT - ("AudioDeviceGetProperty (kAudioDevicePropertyDeviceIsAlive)"); + CHECK_RESULT("AudioDeviceGetProperty (kAudioDevicePropertyDeviceIsAlive)"); if (!alive) { SDL_SetError("CoreAudio: requested device exists, but isn't alive."); @@ -792,7 +766,7 @@ prepare_device(_THIS) } addr.mSelector = kAudioDevicePropertyHogMode; - size = sizeof (pid); + size = sizeof(pid); result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &pid); /* some devices don't support this property, so errors are fine here. */ @@ -805,8 +779,7 @@ prepare_device(_THIS) return 1; } -static int -assign_device_to_audioqueue(_THIS) +static int assign_device_to_audioqueue(_THIS) { const AudioObjectPropertyAddress prop = { kAudioDevicePropertyDeviceUID, @@ -816,7 +789,7 @@ assign_device_to_audioqueue(_THIS) OSStatus result; CFStringRef devuid; - UInt32 devuidsize = sizeof (devuid); + UInt32 devuidsize = sizeof(devuid); result = AudioObjectGetPropertyData(this->hidden->deviceID, &prop, 0, NULL, &devuidsize, &devuid); CHECK_RESULT("AudioObjectGetPropertyData (kAudioDevicePropertyDeviceUID)"); result = AudioQueueSetProperty(this->hidden->audioQueue, kAudioQueueProperty_CurrentDevice, &devuid, devuidsize); @@ -826,8 +799,7 @@ assign_device_to_audioqueue(_THIS) } #endif -static int -prepare_audioqueue(_THIS) +static int prepare_audioqueue(_THIS) { const AudioStreamBasicDescription *strdesc = &this->hidden->strdesc; const int iscapture = this->iscapture; @@ -835,7 +807,8 @@ prepare_audioqueue(_THIS) int i, numAudioBuffers = 2; AudioChannelLayout layout; double MINIMUM_AUDIO_BUFFER_TIME_MS; - const double msecs = (this->spec.samples / ((double) this->spec.freq)) * 1000.0;; + const double msecs = (this->spec.samples / ((double)this->spec.freq)) * 1000.0; + ; SDL_assert(CFRunLoopGetCurrent() != NULL); @@ -847,7 +820,7 @@ prepare_audioqueue(_THIS) CHECK_RESULT("AudioQueueNewOutput"); } - #if MACOSX_COREAUDIO +#if MACOSX_COREAUDIO if (!assign_device_to_audioqueue(this)) { return 0; } @@ -861,7 +834,7 @@ prepare_audioqueue(_THIS) /* If this fails, oh well, we won't notice a device had an extraordinary event take place. */ AudioObjectAddPropertyListener(this->hidden->deviceID, &alive_address, device_unplugged, this); } - #endif +#endif /* Calculate the final parameters for this audio specification */ SDL_CalculateAudioSpec(&this->spec); @@ -918,12 +891,12 @@ prepare_audioqueue(_THIS) MINIMUM_AUDIO_BUFFER_TIME_MS = 40.0; } #endif - if (msecs < MINIMUM_AUDIO_BUFFER_TIME_MS) { /* use more buffers if we have a VERY small sample set. */ + if (msecs < MINIMUM_AUDIO_BUFFER_TIME_MS) { /* use more buffers if we have a VERY small sample set. */ numAudioBuffers = ((int)SDL_ceil(MINIMUM_AUDIO_BUFFER_TIME_MS / msecs) * 2); } this->hidden->numAudioBuffers = numAudioBuffers; - this->hidden->audioBuffer = SDL_calloc(1, sizeof (AudioQueueBufferRef) * numAudioBuffers); + this->hidden->audioBuffer = SDL_calloc(1, sizeof(AudioQueueBufferRef) * numAudioBuffers); if (this->hidden->audioBuffer == NULL) { SDL_OutOfMemory(); return 0; @@ -950,24 +923,23 @@ prepare_audioqueue(_THIS) return 1; } -static int -audioqueue_thread(void *arg) +static int audioqueue_thread(void *arg) { - SDL_AudioDevice *this = (SDL_AudioDevice *) arg; + SDL_AudioDevice *this = (SDL_AudioDevice *)arg; int rc; - #if MACOSX_COREAUDIO +#if MACOSX_COREAUDIO const AudioObjectPropertyAddress default_device_address = { this->iscapture ? kAudioHardwarePropertyDefaultInputDevice : kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMain }; - if (this->handle == NULL) { /* opened the default device? Register to know if the user picks a new default. */ + if (this->handle == NULL) { /* opened the default device? Register to know if the user picks a new default. */ /* we don't care if this fails; we just won't change to new default devices, but we still otherwise function in this case. */ AudioObjectAddPropertyListener(kAudioObjectSystemObject, &default_device_address, default_device_changed, this); } - #endif +#endif rc = prepare_audioqueue(this); if (!rc) { @@ -984,14 +956,14 @@ audioqueue_thread(void *arg) while (!SDL_AtomicGet(&this->shutdown)) { CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.10, 1); - #if MACOSX_COREAUDIO +#if MACOSX_COREAUDIO if ((this->handle == NULL) && SDL_AtomicGet(&this->hidden->device_change_flag)) { const AudioDeviceID prev_devid = this->hidden->deviceID; SDL_AtomicSet(&this->hidden->device_change_flag, 0); - #if DEBUG_COREAUDIO +#if DEBUG_COREAUDIO printf("COREAUDIO: audioqueue_thread is trying to switch to new default device!\n"); - #endif +#endif /* if any of this fails, there's not much to do but wait to see if the user gives up and quits (flagging the audioqueue for shutdown), or toggles to some other system @@ -1009,26 +981,25 @@ audioqueue_thread(void *arg) } } } - #endif +#endif } - if (!this->iscapture) { /* Drain off any pending playback. */ - const CFTimeInterval secs = (((this->spec.size / (SDL_AUDIO_BITSIZE(this->spec.format) / 8)) / this->spec.channels) / ((CFTimeInterval) this->spec.freq)) * 2.0; + if (!this->iscapture) { /* Drain off any pending playback. */ + const CFTimeInterval secs = (((this->spec.size / (SDL_AUDIO_BITSIZE(this->spec.format) / 8)) / this->spec.channels) / ((CFTimeInterval)this->spec.freq)) * 2.0; CFRunLoopRunInMode(kCFRunLoopDefaultMode, secs, 0); } - #if MACOSX_COREAUDIO +#if MACOSX_COREAUDIO if (this->handle == NULL) { /* we don't care if this fails; we just won't change to new default devices, but we still otherwise function in this case. */ AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &default_device_address, default_device_changed, this); } - #endif +#endif return 0; } -static int -COREAUDIO_OpenDevice(_THIS, const char *devname) +static int COREAUDIO_OpenDevice(_THIS, const char *devname) { AudioStreamBasicDescription *strdesc; SDL_AudioFormat test_format; @@ -1064,7 +1035,7 @@ COREAUDIO_OpenDevice(_THIS, const char *devname) /* Stop CoreAudio from doing expensive audio rate conversion */ @autoreleasepool { - AVAudioSession* session = [AVAudioSession sharedInstance]; + AVAudioSession *session = [AVAudioSession sharedInstance]; [session setPreferredSampleRate:this->spec.freq error:nil]; this->spec.freq = (int)session.sampleRate; #if TARGET_OS_TV @@ -1108,7 +1079,7 @@ COREAUDIO_OpenDevice(_THIS, const char *devname) break; } - if (!test_format) { /* shouldn't happen, but just in case... */ + if (!test_format) { /* shouldn't happen, but just in case... */ return SDL_SetError("%s: Unsupported audio format", "coreaudio"); } this->spec.format = test_format; @@ -1133,7 +1104,7 @@ COREAUDIO_OpenDevice(_THIS, const char *devname) /* This has to init in a new thread so it can get its own CFRunLoop. :/ */ this->hidden->ready_semaphore = SDL_CreateSemaphore(0); if (!this->hidden->ready_semaphore) { - return -1; /* oh well. */ + return -1; /* oh well. */ } this->hidden->thread = SDL_CreateThreadInternal(audioqueue_thread, "AudioQueue thread", 512 * 1024, this); @@ -1153,10 +1124,9 @@ COREAUDIO_OpenDevice(_THIS, const char *devname) } #if !MACOSX_COREAUDIO -static int -COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) +static int COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) { - AVAudioSession* session = [AVAudioSession sharedInstance]; + AVAudioSession *session = [AVAudioSession sharedInstance]; if (name != NULL) { *name = NULL; @@ -1166,9 +1136,8 @@ COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) spec->channels = [session outputNumberOfChannels]; return 0; } -#else /* MACOSX_COREAUDIO */ -static int -COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) +#else /* MACOSX_COREAUDIO */ +static int COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) { AudioDeviceID devid; AudioBufferList *buflist; @@ -1207,7 +1176,7 @@ COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) /* Get the Device ID */ cfstr = NULL; - size = sizeof (AudioDeviceID); + size = sizeof(AudioDeviceID); result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr, 0, NULL, &size, &devid); @@ -1217,7 +1186,7 @@ COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) if (name != NULL) { /* Use the Device ID to get the name */ - size = sizeof (CFStringRef); + size = sizeof(CFStringRef); result = AudioObjectGetPropertyData(devid, &nameaddr, 0, NULL, &size, &cfstr); if (result != noErr) { @@ -1225,8 +1194,8 @@ COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) } len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(cfstr), - kCFStringEncodingUTF8); - devname = (char *) SDL_malloc(len + 1); + kCFStringEncodingUTF8); + devname = (char *)SDL_malloc(len + 1); usable = ((devname != NULL) && (CFStringGetCString(cfstr, devname, len + 1, kCFStringEncodingUTF8))); CFRelease(cfstr); @@ -1258,13 +1227,13 @@ COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) return SDL_SetError("%s: Default Device Sample Rate not found", "coreaudio"); } - spec->freq = (int) sampleRate; + spec->freq = (int)sampleRate; result = AudioObjectGetPropertyDataSize(devid, &bufaddr, 0, NULL, &size); if (result != noErr) return SDL_SetError("%s: Default Device Data Size not found", "coreaudio"); - buflist = (AudioBufferList *) SDL_malloc(size); + buflist = (AudioBufferList *)SDL_malloc(size); if (buflist == NULL) return SDL_SetError("%s: Default Device Buffer List not found", "coreaudio"); @@ -1288,8 +1257,7 @@ COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) } #endif /* MACOSX_COREAUDIO */ -static void -COREAUDIO_Deinitialize(void) +static void COREAUDIO_Deinitialize(void) { #if MACOSX_COREAUDIO AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &devlist_address, device_list_changed, NULL); @@ -1298,8 +1266,7 @@ COREAUDIO_Deinitialize(void) #endif } -static SDL_bool -COREAUDIO_Init(SDL_AudioDriverImpl * impl) +static SDL_bool COREAUDIO_Init(SDL_AudioDriverImpl *impl) { /* Set the function pointers */ impl->OpenDevice = COREAUDIO_OpenDevice; @@ -1319,7 +1286,7 @@ COREAUDIO_Init(SDL_AudioDriverImpl * impl) impl->HasCaptureSupport = SDL_TRUE; impl->SupportsNonPow2Samples = SDL_TRUE; - return SDL_TRUE; /* this audio target is available. */ + return SDL_TRUE; /* this audio target is available. */ } AudioBootStrap COREAUDIO_bootstrap = { diff --git a/src/audio/directsound/SDL_directsound.c b/src/audio/directsound/SDL_directsound.c index e000cf71e..d7a65d4fd 100644 --- a/src/audio/directsound/SDL_directsound.c +++ b/src/audio/directsound/SDL_directsound.c @@ -44,21 +44,20 @@ static SDL_bool SupportsIMMDevice = SDL_FALSE; #endif /* HAVE_MMDEVICEAPI_H */ /* DirectX function pointers for audio */ -static void* DSoundDLL = NULL; -typedef HRESULT (WINAPI *fnDirectSoundCreate8)(LPGUID,LPDIRECTSOUND*,LPUNKNOWN); -typedef HRESULT (WINAPI *fnDirectSoundEnumerateW)(LPDSENUMCALLBACKW, LPVOID); -typedef HRESULT (WINAPI *fnDirectSoundCaptureCreate8)(LPCGUID,LPDIRECTSOUNDCAPTURE8 *,LPUNKNOWN); -typedef HRESULT (WINAPI *fnDirectSoundCaptureEnumerateW)(LPDSENUMCALLBACKW,LPVOID); +static void *DSoundDLL = NULL; +typedef HRESULT(WINAPI *fnDirectSoundCreate8)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN); +typedef HRESULT(WINAPI *fnDirectSoundEnumerateW)(LPDSENUMCALLBACKW, LPVOID); +typedef HRESULT(WINAPI *fnDirectSoundCaptureCreate8)(LPCGUID, LPDIRECTSOUNDCAPTURE8 *, LPUNKNOWN); +typedef HRESULT(WINAPI *fnDirectSoundCaptureEnumerateW)(LPDSENUMCALLBACKW, LPVOID); static fnDirectSoundCreate8 pDirectSoundCreate8 = NULL; static fnDirectSoundEnumerateW pDirectSoundEnumerateW = NULL; static fnDirectSoundCaptureCreate8 pDirectSoundCaptureCreate8 = NULL; static fnDirectSoundCaptureEnumerateW pDirectSoundCaptureEnumerateW = NULL; -static const GUID SDL_KSDATAFORMAT_SUBTYPE_PCM = { 0x00000001, 0x0000, 0x0010,{ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } }; -static const GUID SDL_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = { 0x00000003, 0x0000, 0x0010,{ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } }; +static const GUID SDL_KSDATAFORMAT_SUBTYPE_PCM = { 0x00000001, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } }; +static const GUID SDL_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = { 0x00000003, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } }; -static void -DSOUND_Unload(void) +static void DSOUND_Unload(void) { pDirectSoundCreate8 = NULL; pDirectSoundEnumerateW = NULL; @@ -71,9 +70,7 @@ DSOUND_Unload(void) } } - -static int -DSOUND_Load(void) +static int DSOUND_Load(void) { int loaded = 0; @@ -83,17 +80,19 @@ DSOUND_Load(void) if (DSoundDLL == NULL) { SDL_SetError("DirectSound: failed to load DSOUND.DLL"); } else { - /* Now make sure we have DirectX 8 or better... */ - #define DSOUNDLOAD(f) { \ - p##f = (fn##f) SDL_LoadFunction(DSoundDLL, #f); \ - if (!p##f) loaded = 0; \ - } - loaded = 1; /* will reset if necessary. */ +/* Now make sure we have DirectX 8 or better... */ +#define DSOUNDLOAD(f) \ + { \ + p##f = (fn##f)SDL_LoadFunction(DSoundDLL, #f); \ + if (!p##f) \ + loaded = 0; \ + } + loaded = 1; /* will reset if necessary. */ DSOUNDLOAD(DirectSoundCreate8); DSOUNDLOAD(DirectSoundEnumerateW); DSOUNDLOAD(DirectSoundCaptureCreate8); DSOUNDLOAD(DirectSoundCaptureEnumerateW); - #undef DSOUNDLOAD +#undef DSOUNDLOAD if (!loaded) { SDL_SetError("DirectSound: System doesn't appear to have DX8."); @@ -107,8 +106,7 @@ DSOUND_Load(void) return loaded; } -static int -SetDSerror(const char *function, int code) +static int SetDSerror(const char *function, int code) { const char *error; @@ -154,14 +152,12 @@ SetDSerror(const char *function, int code) return SDL_SetError("%s: %s (0x%x)", function, error, code); } -static void -DSOUND_FreeDeviceHandle(void *handle) +static void DSOUND_FreeDeviceHandle(void *handle) { SDL_free(handle); } -static int -DSOUND_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) +static int DSOUND_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) { #if HAVE_MMDEVICEAPI_H if (SupportsIMMDevice) { @@ -171,29 +167,27 @@ DSOUND_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) return SDL_Unsupported(); } -static BOOL CALLBACK -FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID data) +static BOOL CALLBACK FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID data) { - const int iscapture = (int) ((size_t) data); - if (guid != NULL) { /* skip default device */ + const int iscapture = (int)((size_t)data); + if (guid != NULL) { /* skip default device */ char *str = WIN_LookupAudioDeviceName(desc, guid); if (str != NULL) { - LPGUID cpyguid = (LPGUID) SDL_malloc(sizeof (GUID)); - SDL_memcpy(cpyguid, guid, sizeof (GUID)); + LPGUID cpyguid = (LPGUID)SDL_malloc(sizeof(GUID)); + SDL_memcpy(cpyguid, guid, sizeof(GUID)); /* Note that spec is NULL, because we are required to connect to the * device before getting the channel mask and output format, making * this information inaccessible at enumeration time */ SDL_AddAudioDevice(iscapture, str, NULL, cpyguid); - SDL_free(str); /* addfn() makes a copy of this string. */ + SDL_free(str); /* addfn() makes a copy of this string. */ } } - return TRUE; /* keep enumerating. */ + return TRUE; /* keep enumerating. */ } -static void -DSOUND_DetectDevices(void) +static void DSOUND_DetectDevices(void) { #if HAVE_MMDEVICEAPI_H if (SupportsIMMDevice) { @@ -207,9 +201,7 @@ DSOUND_DetectDevices(void) #endif /* HAVE_MMDEVICEAPI_H*/ } - -static void -DSOUND_WaitDevice(_THIS) +static void DSOUND_WaitDevice(_THIS) { DWORD status = 0; DWORD cursor = 0; @@ -266,8 +258,7 @@ DSOUND_WaitDevice(_THIS) } } -static void -DSOUND_PlayDevice(_THIS) +static void DSOUND_PlayDevice(_THIS) { /* Unlock the buffer, allowing it to play */ if (this->hidden->locked_buf) { @@ -277,8 +268,7 @@ DSOUND_PlayDevice(_THIS) } } -static Uint8 * -DSOUND_GetDeviceBuf(_THIS) +static Uint8 *DSOUND_GetDeviceBuf(_THIS) { DWORD cursor = 0; DWORD junk = 0; @@ -319,14 +309,13 @@ DSOUND_GetDeviceBuf(_THIS) /* Lock the audio buffer */ result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor, this->spec.size, - (LPVOID *) & this->hidden->locked_buf, + (LPVOID *)&this->hidden->locked_buf, &rawlen, NULL, &junk, 0); if (result == DSERR_BUFFERLOST) { IDirectSoundBuffer_Restore(this->hidden->mixbuf); result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor, this->spec.size, - (LPVOID *) & this-> - hidden->locked_buf, &rawlen, NULL, + (LPVOID *)&this->hidden->locked_buf, &rawlen, NULL, &junk, 0); } if (result != DS_OK) { @@ -336,8 +325,7 @@ DSOUND_GetDeviceBuf(_THIS) return this->hidden->locked_buf; } -static int -DSOUND_CaptureFromDevice(_THIS, void *buffer, int buflen) +static int DSOUND_CaptureFromDevice(_THIS, void *buffer, int buflen) { struct SDL_PrivateAudioData *h = this->hidden; DWORD junk, cursor, ptr1len, ptr2len; @@ -346,7 +334,7 @@ DSOUND_CaptureFromDevice(_THIS, void *buffer, int buflen) SDL_assert(buflen == this->spec.size); while (SDL_TRUE) { - if (SDL_AtomicGet(&this->shutdown)) { /* in case the buffer froze... */ + if (SDL_AtomicGet(&this->shutdown)) { /* in case the buffer froze... */ SDL_memset(buffer, this->spec.silence, buflen); return buflen; } @@ -355,7 +343,7 @@ DSOUND_CaptureFromDevice(_THIS, void *buffer, int buflen) return -1; } if ((cursor / this->spec.size) == h->lastchunk) { - SDL_Delay(1); /* FIXME: find out how much time is left and sleep that long */ + SDL_Delay(1); /* FIXME: find out how much time is left and sleep that long */ } else { break; } @@ -380,8 +368,7 @@ DSOUND_CaptureFromDevice(_THIS, void *buffer, int buflen) return ptr1len; } -static void -DSOUND_FlushCapture(_THIS) +static void DSOUND_FlushCapture(_THIS) { struct SDL_PrivateAudioData *h = this->hidden; DWORD junk, cursor; @@ -390,8 +377,7 @@ DSOUND_FlushCapture(_THIS) } } -static void -DSOUND_CloseDevice(_THIS) +static void DSOUND_CloseDevice(_THIS) { if (this->hidden->mixbuf != NULL) { IDirectSoundBuffer_Stop(this->hidden->mixbuf); @@ -414,8 +400,7 @@ DSOUND_CloseDevice(_THIS) number of audio chunks available in the created buffer. This is for playback devices, not capture. */ -static int -CreateSecondary(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt) +static int CreateSecondary(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt) { LPDIRECTSOUND sndObj = this->hidden->sound; LPDIRECTSOUNDBUFFER *sndbuf = &this->hidden->mixbuf; @@ -439,14 +424,14 @@ CreateSecondary(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt) /* Silence the initial audio buffer */ result = IDirectSoundBuffer_Lock(*sndbuf, 0, format.dwBufferBytes, - (LPVOID *) & pvAudioPtr1, &dwAudioBytes1, - (LPVOID *) & pvAudioPtr2, &dwAudioBytes2, + (LPVOID *)&pvAudioPtr1, &dwAudioBytes1, + (LPVOID *)&pvAudioPtr2, &dwAudioBytes2, DSBLOCK_ENTIREBUFFER); if (result == DS_OK) { SDL_memset(pvAudioPtr1, this->spec.silence, dwAudioBytes1); IDirectSoundBuffer_Unlock(*sndbuf, - (LPVOID) pvAudioPtr1, dwAudioBytes1, - (LPVOID) pvAudioPtr2, dwAudioBytes2); + (LPVOID)pvAudioPtr1, dwAudioBytes1, + (LPVOID)pvAudioPtr2, dwAudioBytes2); } /* We're ready to go */ @@ -457,8 +442,7 @@ CreateSecondary(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt) number of audio chunks available in the created buffer. This is for capture devices, not playback. */ -static int -CreateCaptureBuffer(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt) +static int CreateCaptureBuffer(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt) { LPDIRECTSOUNDCAPTURE capture = this->hidden->capture; LPDIRECTSOUNDCAPTUREBUFFER *capturebuf = &this->hidden->capturebuf; @@ -466,7 +450,7 @@ CreateCaptureBuffer(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt) HRESULT result; SDL_zero(format); - format.dwSize = sizeof (format); + format.dwSize = sizeof(format); format.dwFlags = DSCBCAPS_WAVEMAPPED; format.dwBufferBytes = bufsize; format.lpwfxFormat = wfmt; @@ -497,15 +481,14 @@ CreateCaptureBuffer(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt) return 0; } -static int -DSOUND_OpenDevice(_THIS, const char *devname) +static int DSOUND_OpenDevice(_THIS, const char *devname) { const DWORD numchunks = 8; HRESULT result; SDL_bool tried_format = SDL_FALSE; SDL_bool iscapture = this->iscapture; SDL_AudioFormat test_format; - LPGUID guid = (LPGUID) this->handle; + LPGUID guid = (LPGUID)this->handle; DWORD bufsize; /* Initialize all variables that we clean on shutdown */ @@ -551,8 +534,8 @@ DSOUND_OpenDevice(_THIS, const char *devname) bufsize = numchunks * this->spec.size; if ((bufsize < DSBSIZE_MIN) || (bufsize > DSBSIZE_MAX)) { SDL_SetError("Sound buffer size must be between %d and %d", - (int) ((DSBSIZE_MIN < numchunks) ? 1 : DSBSIZE_MIN / numchunks), - (int) (DSBSIZE_MAX / numchunks)); + (int)((DSBSIZE_MIN < numchunks) ? 1 : DSBSIZE_MIN / numchunks), + (int)(DSBSIZE_MAX / numchunks)); } else { int rc; WAVEFORMATEXTENSIBLE wfmt; @@ -568,8 +551,7 @@ DSOUND_OpenDevice(_THIS, const char *devname) } wfmt.Samples.wValidBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format); - switch (this->spec.channels) - { + switch (this->spec.channels) { case 3: /* 3.0 (or 2.1) */ wfmt.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER; break; @@ -604,7 +586,7 @@ DSOUND_OpenDevice(_THIS, const char *devname) wfmt.Format.nBlockAlign = wfmt.Format.nChannels * (wfmt.Format.wBitsPerSample / 8); wfmt.Format.nAvgBytesPerSec = wfmt.Format.nSamplesPerSec * wfmt.Format.nBlockAlign; - rc = iscapture ? CreateCaptureBuffer(this, bufsize, (WAVEFORMATEX*) &wfmt) : CreateSecondary(this, bufsize, (WAVEFORMATEX*) &wfmt); + rc = iscapture ? CreateCaptureBuffer(this, bufsize, (WAVEFORMATEX *)&wfmt) : CreateSecondary(this, bufsize, (WAVEFORMATEX *)&wfmt); if (rc == 0) { this->hidden->num_buffers = numchunks; break; @@ -619,19 +601,17 @@ DSOUND_OpenDevice(_THIS, const char *devname) if (!test_format) { if (tried_format) { - return -1; /* CreateSecondary() should have called SDL_SetError(). */ + return -1; /* CreateSecondary() should have called SDL_SetError(). */ } return SDL_SetError("%s: Unsupported audio format", "directsound"); } /* Playback buffers will auto-start playing in DSOUND_WaitDevice() */ - return 0; /* good to go. */ + return 0; /* good to go. */ } - -static void -DSOUND_Deinitialize(void) +static void DSOUND_Deinitialize(void) { #if HAVE_MMDEVICEAPI_H if (SupportsIMMDevice) { @@ -642,9 +622,7 @@ DSOUND_Deinitialize(void) DSOUND_Unload(); } - -static SDL_bool -DSOUND_Init(SDL_AudioDriverImpl * impl) +static SDL_bool DSOUND_Init(SDL_AudioDriverImpl *impl) { if (!DSOUND_Load()) { return SDL_FALSE; @@ -670,7 +648,7 @@ DSOUND_Init(SDL_AudioDriverImpl * impl) impl->HasCaptureSupport = SDL_TRUE; impl->SupportsNonPow2Samples = SDL_TRUE; - return SDL_TRUE; /* this audio target is available. */ + return SDL_TRUE; /* this audio target is available. */ } AudioBootStrap DSOUND_bootstrap = { diff --git a/src/audio/directsound/SDL_directsound.h b/src/audio/directsound/SDL_directsound.h index 365de770c..342f3634c 100644 --- a/src/audio/directsound/SDL_directsound.h +++ b/src/audio/directsound/SDL_directsound.h @@ -28,7 +28,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this /* The DirectSound objects */ struct SDL_PrivateAudioData diff --git a/src/audio/disk/SDL_diskaudio.c b/src/audio/disk/SDL_diskaudio.c index 1a7f08b2e..a784bd27f 100644 --- a/src/audio/disk/SDL_diskaudio.c +++ b/src/audio/disk/SDL_diskaudio.c @@ -36,21 +36,19 @@ /* !!! FIXME: these should be SDL hints, not environment variables. */ /* environment variables and defaults. */ -#define DISKENVR_OUTFILE "SDL_DISKAUDIOFILE" -#define DISKDEFAULT_OUTFILE "sdlaudio.raw" -#define DISKENVR_INFILE "SDL_DISKAUDIOFILEIN" -#define DISKDEFAULT_INFILE "sdlaudio-in.raw" -#define DISKENVR_IODELAY "SDL_DISKAUDIODELAY" +#define DISKENVR_OUTFILE "SDL_DISKAUDIOFILE" +#define DISKDEFAULT_OUTFILE "sdlaudio.raw" +#define DISKENVR_INFILE "SDL_DISKAUDIOFILEIN" +#define DISKDEFAULT_INFILE "sdlaudio-in.raw" +#define DISKENVR_IODELAY "SDL_DISKAUDIODELAY" /* This function waits until it is possible to write a full sound buffer */ -static void -DISKAUDIO_WaitDevice(_THIS) +static void DISKAUDIO_WaitDevice(_THIS) { SDL_Delay(_this->hidden->io_delay); } -static void -DISKAUDIO_PlayDevice(_THIS) +static void DISKAUDIO_PlayDevice(_THIS) { const size_t written = SDL_RWwrite(_this->hidden->io, _this->hidden->mixbuf, @@ -65,14 +63,12 @@ DISKAUDIO_PlayDevice(_THIS) #endif } -static Uint8 * -DISKAUDIO_GetDeviceBuf(_THIS) +static Uint8 *DISKAUDIO_GetDeviceBuf(_THIS) { return _this->hidden->mixbuf; } -static int -DISKAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) +static int DISKAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) { struct SDL_PrivateAudioData *h = _this->hidden; const int origbuflen = buflen; @@ -81,9 +77,9 @@ DISKAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) if (h->io) { const size_t br = SDL_RWread(h->io, buffer, 1, buflen); - buflen -= (int) br; - buffer = ((Uint8 *) buffer) + br; - if (buflen > 0) { /* EOF (or error, but whatever). */ + buflen -= (int)br; + buffer = ((Uint8 *)buffer) + br; + if (buflen > 0) { /* EOF (or error, but whatever). */ SDL_RWclose(h->io); h->io = NULL; } @@ -95,15 +91,12 @@ DISKAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) return origbuflen; } -static void -DISKAUDIO_FlushCapture(_THIS) +static void DISKAUDIO_FlushCapture(_THIS) { /* no op...we don't advance the file pointer or anything. */ } - -static void -DISKAUDIO_CloseDevice(_THIS) +static void DISKAUDIO_CloseDevice(_THIS) { if (_this->hidden->io != NULL) { SDL_RWclose(_this->hidden->io); @@ -112,9 +105,7 @@ DISKAUDIO_CloseDevice(_THIS) SDL_free(_this->hidden); } - -static const char * -get_filename(const SDL_bool iscapture, const char *devname) +static const char *get_filename(const SDL_bool iscapture, const char *devname) { if (devname == NULL) { devname = SDL_getenv(iscapture ? DISKENVR_INFILE : DISKENVR_OUTFILE); @@ -125,8 +116,7 @@ get_filename(const SDL_bool iscapture, const char *devname) return devname; } -static int -DISKAUDIO_OpenDevice(_THIS, const char *devname) +static int DISKAUDIO_OpenDevice(_THIS, const char *devname) { void *handle = _this->handle; /* handle != NULL means "user specified the placeholder name on the fake detected device list" */ @@ -155,7 +145,7 @@ DISKAUDIO_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ if (!iscapture) { - _this->hidden->mixbuf = (Uint8 *) SDL_malloc(_this->spec.size); + _this->hidden->mixbuf = (Uint8 *)SDL_malloc(_this->spec.size); if (_this->hidden->mixbuf == NULL) { return SDL_OutOfMemory(); } @@ -163,24 +153,22 @@ DISKAUDIO_OpenDevice(_THIS, const char *devname) } SDL_LogCritical(SDL_LOG_CATEGORY_AUDIO, - "You are using the SDL disk i/o audio driver!\n"); + "You are using the SDL disk i/o audio driver!\n"); SDL_LogCritical(SDL_LOG_CATEGORY_AUDIO, - " %s file [%s].\n", iscapture ? "Reading from" : "Writing to", - fname); + " %s file [%s].\n", iscapture ? "Reading from" : "Writing to", + fname); /* We're ready to rock and roll. :-) */ return 0; } -static void -DISKAUDIO_DetectDevices(void) +static void DISKAUDIO_DetectDevices(void) { - SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, NULL, (void *) 0x1); - SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, NULL, (void *) 0x2); + SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, NULL, (void *)0x1); + SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, NULL, (void *)0x2); } -static SDL_bool -DISKAUDIO_Init(SDL_AudioDriverImpl * impl) +static SDL_bool DISKAUDIO_Init(SDL_AudioDriverImpl *impl) { /* Set the function pointers */ impl->OpenDevice = DISKAUDIO_OpenDevice; @@ -197,7 +185,7 @@ DISKAUDIO_Init(SDL_AudioDriverImpl * impl) impl->HasCaptureSupport = SDL_TRUE; impl->SupportsNonPow2Samples = SDL_TRUE; - return SDL_TRUE; /* this audio target is available. */ + return SDL_TRUE; /* this audio target is available. */ } AudioBootStrap DISKAUDIO_bootstrap = { diff --git a/src/audio/disk/SDL_diskaudio.h b/src/audio/disk/SDL_diskaudio.h index e7739250a..a7893bc36 100644 --- a/src/audio/disk/SDL_diskaudio.h +++ b/src/audio/disk/SDL_diskaudio.h @@ -27,7 +27,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *_this +#define _THIS SDL_AudioDevice *_this struct SDL_PrivateAudioData { diff --git a/src/audio/dsp/SDL_dspaudio.c b/src/audio/dsp/SDL_dspaudio.c index de67bf0eb..77705fc27 100644 --- a/src/audio/dsp/SDL_dspaudio.c +++ b/src/audio/dsp/SDL_dspaudio.c @@ -24,8 +24,8 @@ /* Allow access to a raw mixing buffer */ -#include /* For perror() */ -#include /* For strerror() */ +#include /* For perror() */ +#include /* For strerror() */ #include #include #include @@ -42,16 +42,12 @@ #include "../SDL_audiodev_c.h" #include "SDL_dspaudio.h" - -static void -DSP_DetectDevices(void) +static void DSP_DetectDevices(void) { SDL_EnumUnixAudioDevices(0, NULL); } - -static void -DSP_CloseDevice(_THIS) +static void DSP_CloseDevice(_THIS) { if (this->hidden->audio_fd >= 0) { close(this->hidden->audio_fd); @@ -60,9 +56,7 @@ DSP_CloseDevice(_THIS) SDL_free(this->hidden); } - -static int -DSP_OpenDevice(_THIS, const char *devname) +static int DSP_OpenDevice(_THIS, const char *devname) { SDL_bool iscapture = this->iscapture; const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT); @@ -205,11 +199,12 @@ DSP_OpenDevice(_THIS, const char *devname) SDL_CalculateAudioSpec(&this->spec); /* Determine the power of two of the fragment size */ - for (frag_spec = 0; (0x01U << frag_spec) < this->spec.size; ++frag_spec); + for (frag_spec = 0; (0x01U << frag_spec) < this->spec.size; ++frag_spec) + ; if ((0x01U << frag_spec) != this->spec.size) { return SDL_SetError("Fragment size must be a power of two"); } - frag_spec |= 0x00020000; /* two fragments, for low latency */ + frag_spec |= 0x00020000; /* two fragments, for low latency */ /* Set the audio buffering parameters */ #ifdef DEBUG_AUDIO @@ -233,7 +228,7 @@ DSP_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ if (!iscapture) { this->hidden->mixlen = this->spec.size; - this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); + this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen); if (this->hidden->mixbuf == NULL) { return SDL_OutOfMemory(); } @@ -244,9 +239,7 @@ DSP_OpenDevice(_THIS, const char *devname) return 0; } - -static void -DSP_PlayDevice(_THIS) +static void DSP_PlayDevice(_THIS) { struct SDL_PrivateAudioData *h = this->hidden; if (write(h->audio_fd, h->mixbuf, h->mixlen) == -1) { @@ -258,27 +251,24 @@ DSP_PlayDevice(_THIS) #endif } -static Uint8 * -DSP_GetDeviceBuf(_THIS) +static Uint8 *DSP_GetDeviceBuf(_THIS) { return this->hidden->mixbuf; } -static int -DSP_CaptureFromDevice(_THIS, void *buffer, int buflen) +static int DSP_CaptureFromDevice(_THIS, void *buffer, int buflen) { return (int)read(this->hidden->audio_fd, buffer, buflen); } -static void -DSP_FlushCapture(_THIS) +static void DSP_FlushCapture(_THIS) { struct SDL_PrivateAudioData *h = this->hidden; audio_buf_info info; if (ioctl(h->audio_fd, SNDCTL_DSP_GETISPACE, &info) == 0) { while (info.bytes > 0) { char buf[512]; - const size_t len = SDL_min(sizeof (buf), info.bytes); + const size_t len = SDL_min(sizeof(buf), info.bytes); const ssize_t br = read(h->audio_fd, buf, len); if (br <= 0) { break; @@ -289,22 +279,20 @@ DSP_FlushCapture(_THIS) } static SDL_bool InitTimeDevicesExist = SDL_FALSE; -static int -look_for_devices_test(int fd) +static int look_for_devices_test(int fd) { - InitTimeDevicesExist = SDL_TRUE; /* note that _something_ exists. */ + InitTimeDevicesExist = SDL_TRUE; /* note that _something_ exists. */ /* Don't add to the device list, we're just seeing if any devices exist. */ return 0; } -static SDL_bool -DSP_Init(SDL_AudioDriverImpl * impl) +static SDL_bool DSP_Init(SDL_AudioDriverImpl *impl) { InitTimeDevicesExist = SDL_FALSE; SDL_EnumUnixAudioDevices(0, look_for_devices_test); if (!InitTimeDevicesExist) { SDL_SetError("dsp: No such audio device"); - return SDL_FALSE; /* maybe try a different backend. */ + return SDL_FALSE; /* maybe try a different backend. */ } /* Set the function pointers */ @@ -319,10 +307,9 @@ DSP_Init(SDL_AudioDriverImpl * impl) impl->AllowsArbitraryDeviceNames = SDL_TRUE; impl->HasCaptureSupport = SDL_TRUE; - return SDL_TRUE; /* this audio target is available. */ + return SDL_TRUE; /* this audio target is available. */ } - AudioBootStrap DSP_bootstrap = { "dsp", "OSS /dev/dsp standard audio", DSP_Init, SDL_FALSE }; diff --git a/src/audio/dsp/SDL_dspaudio.h b/src/audio/dsp/SDL_dspaudio.h index b9ce50e2f..2abd27934 100644 --- a/src/audio/dsp/SDL_dspaudio.h +++ b/src/audio/dsp/SDL_dspaudio.h @@ -26,7 +26,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { @@ -37,7 +37,7 @@ struct SDL_PrivateAudioData Uint8 *mixbuf; int mixlen; }; -#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */ +#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */ #endif /* SDL_dspaudio_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/dummy/SDL_dummyaudio.c b/src/audio/dummy/SDL_dummyaudio.c index dab1edb59..e3fb43336 100644 --- a/src/audio/dummy/SDL_dummyaudio.c +++ b/src/audio/dummy/SDL_dummyaudio.c @@ -27,15 +27,14 @@ #include "../SDL_audio_c.h" #include "SDL_dummyaudio.h" -static int -DUMMYAUDIO_OpenDevice(_THIS, const char *devname) +static int DUMMYAUDIO_OpenDevice(_THIS, const char *devname) { - _this->hidden = (void *) 0x1; /* just something non-NULL */ - return 0; /* always succeeds. */ + _this->hidden = (void *)0x1; /* just something non-NULL */ + + return 0; /* always succeeds. */ } -static int -DUMMYAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) +static int DUMMYAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) { /* Delay to make this sort of simulate real audio input. */ SDL_Delay((_this->spec.samples * 1000) / _this->spec.freq); @@ -45,8 +44,7 @@ DUMMYAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) return buflen; } -static SDL_bool -DUMMYAUDIO_Init(SDL_AudioDriverImpl * impl) +static SDL_bool DUMMYAUDIO_Init(SDL_AudioDriverImpl *impl) { /* Set the function pointers */ impl->OpenDevice = DUMMYAUDIO_OpenDevice; @@ -56,7 +54,7 @@ DUMMYAUDIO_Init(SDL_AudioDriverImpl * impl) impl->OnlyHasDefaultCaptureDevice = SDL_TRUE; impl->HasCaptureSupport = SDL_TRUE; - return SDL_TRUE; /* this audio target is available. */ + return SDL_TRUE; /* this audio target is available. */ } AudioBootStrap DUMMYAUDIO_bootstrap = { diff --git a/src/audio/dummy/SDL_dummyaudio.h b/src/audio/dummy/SDL_dummyaudio.h index 6ac650d4d..ab5ac0874 100644 --- a/src/audio/dummy/SDL_dummyaudio.h +++ b/src/audio/dummy/SDL_dummyaudio.h @@ -26,7 +26,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *_this +#define _THIS SDL_AudioDevice *_this struct SDL_PrivateAudioData { diff --git a/src/audio/emscripten/SDL_emscriptenaudio.c b/src/audio/emscripten/SDL_emscriptenaudio.c index bfe42821a..0858bfa4a 100644 --- a/src/audio/emscripten/SDL_emscriptenaudio.c +++ b/src/audio/emscripten/SDL_emscriptenaudio.c @@ -33,10 +33,10 @@ !!! FIXME: true always once pthread support becomes widespread. Revisit this code !!! FIXME: at some point and see what needs to be done for that! */ -static void -FeedAudioDevice(_THIS, const void *buf, const int buflen) +static void FeedAudioDevice(_THIS, const void *buf, const int buflen) { const int framelen = (SDL_AUDIO_BITSIZE(this->spec.format) / 8) * this->spec.channels; + /* *INDENT-OFF* */ /* clang-format off */ MAIN_THREAD_EM_ASM({ var SDL2 = Module['SDL2']; var numChannels = SDL2.audio.currentOutputBuffer['numberOfChannels']; @@ -51,10 +51,10 @@ FeedAudioDevice(_THIS, const void *buf, const int buflen) } } }, buf, buflen / framelen); +/* *INDENT-ON* */ /* clang-format on */ } -static void -HandleAudioProcess(_THIS) +static void HandleAudioProcess(_THIS) { SDL_AudioCallback callback = this->callbackspec.callback; const int stream_len = this->callbackspec.size; @@ -70,12 +70,12 @@ HandleAudioProcess(_THIS) return; } - if (this->stream == NULL) { /* no conversion necessary. */ + if (this->stream == NULL) { /* no conversion necessary. */ SDL_assert(this->spec.size == stream_len); callback(this->callbackspec.userdata, this->work_buffer, stream_len); - } else { /* streaming/converting */ + } else { /* streaming/converting */ int got; - while (SDL_AudioStreamAvailable(this->stream) < ((int) this->spec.size)) { + while (SDL_AudioStreamAvailable(this->stream) < ((int)this->spec.size)) { callback(this->callbackspec.userdata, this->work_buffer, stream_len); if (SDL_AudioStreamPut(this->stream, this->work_buffer, stream_len) == -1) { SDL_AudioStreamClear(this->stream); @@ -94,8 +94,7 @@ HandleAudioProcess(_THIS) FeedAudioDevice(this, this->work_buffer, this->spec.size); } -static void -HandleCaptureProcess(_THIS) +static void HandleCaptureProcess(_THIS) { SDL_AudioCallback callback = this->callbackspec.callback; const int stream_len = this->callbackspec.size; @@ -106,6 +105,7 @@ HandleCaptureProcess(_THIS) return; } + /* *INDENT-OFF* */ /* clang-format off */ MAIN_THREAD_EM_ASM({ var SDL2 = Module['SDL2']; var numChannels = SDL2.capture.currentCaptureBuffer.numberOfChannels; @@ -126,13 +126,14 @@ HandleCaptureProcess(_THIS) } } }, this->work_buffer, (this->spec.size / sizeof (float)) / this->spec.channels); +/* *INDENT-ON* */ /* clang-format on */ /* okay, we've got an interleaved float32 array in C now. */ - if (this->stream == NULL) { /* no conversion necessary. */ + if (this->stream == NULL) { /* no conversion necessary. */ SDL_assert(this->spec.size == stream_len); callback(this->callbackspec.userdata, this->work_buffer, stream_len); - } else { /* streaming/converting */ + } else { /* streaming/converting */ if (SDL_AudioStreamPut(this->stream, this->work_buffer, this->spec.size) == -1) { SDL_AtomicSet(&this->enabled, 0); } @@ -143,15 +144,14 @@ HandleCaptureProcess(_THIS) if (got != stream_len) { SDL_memset(this->work_buffer, this->callbackspec.silence, stream_len); } - callback(this->callbackspec.userdata, this->work_buffer, stream_len); /* Send it to the app. */ + callback(this->callbackspec.userdata, this->work_buffer, stream_len); /* Send it to the app. */ } } } - -static void -EMSCRIPTENAUDIO_CloseDevice(_THIS) +static void EMSCRIPTENAUDIO_CloseDevice(_THIS) { + /* *INDENT-OFF* */ /* clang-format off */ MAIN_THREAD_EM_ASM({ var SDL2 = Module['SDL2']; if ($0) { @@ -190,14 +190,14 @@ EMSCRIPTENAUDIO_CloseDevice(_THIS) SDL2.audioContext = undefined; } }, this->iscapture); +/* *INDENT-ON* */ /* clang-format on */ #if 0 /* !!! FIXME: currently not used. Can we move some stuff off the SDL2 namespace? --ryan. */ SDL_free(this->hidden); #endif } -static int -EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname) +static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname) { SDL_AudioFormat test_format; SDL_bool iscapture = this->iscapture; @@ -205,6 +205,7 @@ EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname) /* based on parts of library_sdl.js */ + /* *INDENT-OFF* */ /* clang-format off */ /* create context */ result = MAIN_THREAD_EM_ASM_INT({ if(typeof(Module['SDL2']) === 'undefined') { @@ -229,6 +230,8 @@ EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname) } return SDL2.audioContext === undefined ? -1 : 0; }, iscapture); +/* *INDENT-ON* */ /* clang-format on */ + if (result < 0) { return SDL_SetError("Web Audio API is not available!"); } @@ -268,6 +271,7 @@ EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname) SDL_CalculateAudioSpec(&this->spec); + /* *INDENT-OFF* */ /* clang-format off */ if (iscapture) { /* The idea is to take the capture media stream, hook it up to an audio graph where we can pass it through a ScriptProcessorNode @@ -339,17 +343,16 @@ EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname) SDL2.audio.scriptProcessorNode['connect'](SDL2.audioContext['destination']); }, this->spec.channels, this->spec.samples, HandleAudioProcess, this); } +/* *INDENT-ON* */ /* clang-format on */ return 0; } -static void -EMSCRIPTENAUDIO_LockOrUnlockDeviceWithNoMixerLock(SDL_AudioDevice * device) +static void EMSCRIPTENAUDIO_LockOrUnlockDeviceWithNoMixerLock(SDL_AudioDevice *device) { } -static SDL_bool -EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl * impl) +static SDL_bool EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl *impl) { SDL_bool available, capture_available; @@ -363,6 +366,7 @@ EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl * impl) impl->LockDevice = impl->UnlockDevice = EMSCRIPTENAUDIO_LockOrUnlockDeviceWithNoMixerLock; impl->ProvidesOwnCallbackThread = SDL_TRUE; + /* *INDENT-OFF* */ /* clang-format off */ /* check availability */ available = MAIN_THREAD_EM_ASM_INT({ if (typeof(AudioContext) !== 'undefined') { @@ -372,11 +376,13 @@ EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl * impl) } return false; }); +/* *INDENT-ON* */ /* clang-format on */ if (!available) { SDL_SetError("No audio context available"); } + /* *INDENT-OFF* */ /* clang-format off */ capture_available = available && MAIN_THREAD_EM_ASM_INT({ if ((typeof(navigator.mediaDevices) !== 'undefined') && (typeof(navigator.mediaDevices.getUserMedia) !== 'undefined')) { return true; @@ -385,6 +391,7 @@ EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl * impl) } return false; }); +/* *INDENT-ON* */ /* clang-format on */ impl->HasCaptureSupport = capture_available ? SDL_TRUE : SDL_FALSE; impl->OnlyHasDefaultCaptureDevice = capture_available ? SDL_TRUE : SDL_FALSE; diff --git a/src/audio/emscripten/SDL_emscriptenaudio.h b/src/audio/emscripten/SDL_emscriptenaudio.h index f51695a0a..df4c32256 100644 --- a/src/audio/emscripten/SDL_emscriptenaudio.h +++ b/src/audio/emscripten/SDL_emscriptenaudio.h @@ -26,7 +26,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { diff --git a/src/audio/haiku/SDL_haikuaudio.cc b/src/audio/haiku/SDL_haikuaudio.cc index aec5f4a25..fc13e313d 100644 --- a/src/audio/haiku/SDL_haikuaudio.cc +++ b/src/audio/haiku/SDL_haikuaudio.cc @@ -42,8 +42,7 @@ extern "C" /* !!! FIXME: have the callback call the higher level to avoid code dupe. */ /* The Haiku callback for handling the audio buffer */ -static void -FillSound(void *device, void *stream, size_t len, +static void FillSound(void *device, void *stream, size_t len, const media_raw_audio_format & format) { SDL_AudioDevice *audio = (SDL_AudioDevice *) device; @@ -85,8 +84,7 @@ FillSound(void *device, void *stream, size_t len, SDL_UnlockMutex(audio->mixer_lock); } -static void -HAIKUAUDIO_CloseDevice(_THIS) +static void HAIKUAUDIO_CloseDevice(_THIS) { if (_this->hidden->audio_obj) { _this->hidden->audio_obj->Stop(); @@ -100,8 +98,7 @@ static const int sig_list[] = { SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGWINCH, 0 }; -static inline void -MaskSignals(sigset_t * omask) +static inline void MaskSignals(sigset_t * omask) { sigset_t mask; int i; @@ -113,15 +110,13 @@ MaskSignals(sigset_t * omask) sigprocmask(SIG_BLOCK, &mask, omask); } -static inline void -UnmaskSignals(sigset_t * omask) +static inline void UnmaskSignals(sigset_t * omask) { sigprocmask(SIG_SETMASK, omask, NULL); } -static int -HAIKUAUDIO_OpenDevice(_THIS, const char *devname) +static int HAIKUAUDIO_OpenDevice(_THIS, const char *devname) { media_raw_audio_format format; SDL_AudioFormat test_format; @@ -208,14 +203,12 @@ HAIKUAUDIO_OpenDevice(_THIS, const char *devname) return 0; } -static void -HAIKUAUDIO_Deinitialize(void) +static void HAIKUAUDIO_Deinitialize(void) { SDL_QuitBeApp(); } -static SDL_bool -HAIKUAUDIO_Init(SDL_AudioDriverImpl * impl) +static SDL_bool HAIKUAUDIO_Init(SDL_AudioDriverImpl * impl) { /* Initialize the Be Application, if it's not already started */ if (SDL_InitBeApp() < 0) { diff --git a/src/audio/haiku/SDL_haikuaudio.h b/src/audio/haiku/SDL_haikuaudio.h index 91cc2843f..b78f569ce 100644 --- a/src/audio/haiku/SDL_haikuaudio.h +++ b/src/audio/haiku/SDL_haikuaudio.h @@ -26,7 +26,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *_this +#define _THIS SDL_AudioDevice *_this struct SDL_PrivateAudioData { diff --git a/src/audio/jack/SDL_jackaudio.c b/src/audio/jack/SDL_jackaudio.c index 3302c3450..41949b8f5 100644 --- a/src/audio/jack/SDL_jackaudio.c +++ b/src/audio/jack/SDL_jackaudio.c @@ -29,36 +29,33 @@ #include "SDL_loadso.h" #include "../../thread/SDL_systhread.h" - -static jack_client_t * (*JACK_jack_client_open) (const char *, jack_options_t, jack_status_t *, ...); -static int (*JACK_jack_client_close) (jack_client_t *); -static void (*JACK_jack_on_shutdown) (jack_client_t *, JackShutdownCallback, void *); -static int (*JACK_jack_activate) (jack_client_t *); -static int (*JACK_jack_deactivate) (jack_client_t *); -static void * (*JACK_jack_port_get_buffer) (jack_port_t *, jack_nframes_t); -static int (*JACK_jack_port_unregister) (jack_client_t *, jack_port_t *); -static void (*JACK_jack_free) (void *); -static const char ** (*JACK_jack_get_ports) (jack_client_t *, const char *, const char *, unsigned long); -static jack_nframes_t (*JACK_jack_get_sample_rate) (jack_client_t *); -static jack_nframes_t (*JACK_jack_get_buffer_size) (jack_client_t *); -static jack_port_t * (*JACK_jack_port_register) (jack_client_t *, const char *, const char *, unsigned long, unsigned long); -static jack_port_t * (*JACK_jack_port_by_name) (jack_client_t *, const char *); -static const char * (*JACK_jack_port_name) (const jack_port_t *); -static const char * (*JACK_jack_port_type) (const jack_port_t *); -static int (*JACK_jack_connect) (jack_client_t *, const char *, const char *); -static int (*JACK_jack_set_process_callback) (jack_client_t *, JackProcessCallback, void *); +static jack_client_t *(*JACK_jack_client_open)(const char *, jack_options_t, jack_status_t *, ...); +static int (*JACK_jack_client_close)(jack_client_t *); +static void (*JACK_jack_on_shutdown)(jack_client_t *, JackShutdownCallback, void *); +static int (*JACK_jack_activate)(jack_client_t *); +static int (*JACK_jack_deactivate)(jack_client_t *); +static void *(*JACK_jack_port_get_buffer)(jack_port_t *, jack_nframes_t); +static int (*JACK_jack_port_unregister)(jack_client_t *, jack_port_t *); +static void (*JACK_jack_free)(void *); +static const char **(*JACK_jack_get_ports)(jack_client_t *, const char *, const char *, unsigned long); +static jack_nframes_t (*JACK_jack_get_sample_rate)(jack_client_t *); +static jack_nframes_t (*JACK_jack_get_buffer_size)(jack_client_t *); +static jack_port_t *(*JACK_jack_port_register)(jack_client_t *, const char *, const char *, unsigned long, unsigned long); +static jack_port_t *(*JACK_jack_port_by_name)(jack_client_t *, const char *); +static const char *(*JACK_jack_port_name)(const jack_port_t *); +static const char *(*JACK_jack_port_type)(const jack_port_t *); +static int (*JACK_jack_connect)(jack_client_t *, const char *, const char *); +static int (*JACK_jack_set_process_callback)(jack_client_t *, JackProcessCallback, void *); static int load_jack_syms(void); - #ifdef SDL_AUDIO_DRIVER_JACK_DYNAMIC static const char *jack_library = SDL_AUDIO_DRIVER_JACK_DYNAMIC; static void *jack_handle = NULL; /* !!! FIXME: this is copy/pasted in several places now */ -static int -load_jack_sym(const char *fn, void **addr) +static int load_jack_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(jack_handle, fn); if (*addr == NULL) { @@ -70,11 +67,11 @@ load_jack_sym(const char *fn, void **addr) } /* cast funcs to char* first, to please GCC's strict aliasing rules. */ -#define SDL_JACK_SYM(x) \ - if (!load_jack_sym(#x, (void **) (char *) &JACK_##x)) return -1 +#define SDL_JACK_SYM(x) \ + if (!load_jack_sym(#x, (void **)(char *)&JACK_##x)) \ + return -1 -static void -UnloadJackLibrary(void) +static void UnloadJackLibrary(void) { if (jack_handle != NULL) { SDL_UnloadObject(jack_handle); @@ -82,8 +79,7 @@ UnloadJackLibrary(void) } } -static int -LoadJackLibrary(void) +static int LoadJackLibrary(void) { int retval = 0; if (jack_handle == NULL) { @@ -105,13 +101,11 @@ LoadJackLibrary(void) #define SDL_JACK_SYM(x) JACK_##x = x -static void -UnloadJackLibrary(void) +static void UnloadJackLibrary(void) { } -static int -LoadJackLibrary(void) +static int LoadJackLibrary(void) { load_jack_syms(); return 0; @@ -119,9 +113,7 @@ LoadJackLibrary(void) #endif /* SDL_AUDIO_DRIVER_JACK_DYNAMIC */ - -static int -load_jack_syms(void) +static int load_jack_syms(void) { SDL_JACK_SYM(jack_client_open); SDL_JACK_SYM(jack_client_close); @@ -143,23 +135,20 @@ load_jack_syms(void) return 0; } - -static void -jackShutdownCallback(void *arg) /* JACK went away; device is lost. */ +static void jackShutdownCallback(void *arg) /* JACK went away; device is lost. */ { - SDL_AudioDevice *this = (SDL_AudioDevice *) arg; + SDL_AudioDevice *this = (SDL_AudioDevice *)arg; SDL_OpenedAudioDeviceDisconnected(this); - SDL_SemPost(this->hidden->iosem); /* unblock the SDL thread. */ + SDL_SemPost(this->hidden->iosem); /* unblock the SDL thread. */ } // !!! FIXME: implement and register these! -//typedef int(* JackSampleRateCallback)(jack_nframes_t nframes, void *arg) -//typedef int(* JackBufferSizeCallback)(jack_nframes_t nframes, void *arg) +// typedef int(* JackSampleRateCallback)(jack_nframes_t nframes, void *arg) +// typedef int(* JackBufferSizeCallback)(jack_nframes_t nframes, void *arg) -static int -jackProcessPlaybackCallback(jack_nframes_t nframes, void *arg) +static int jackProcessPlaybackCallback(jack_nframes_t nframes, void *arg) { - SDL_AudioDevice *this = (SDL_AudioDevice *) arg; + SDL_AudioDevice *this = (SDL_AudioDevice *)arg; jack_port_t **ports = this->hidden->sdlports; const int total_channels = this->spec.channels; const int total_frames = this->spec.samples; @@ -171,9 +160,9 @@ jackProcessPlaybackCallback(jack_nframes_t nframes, void *arg) } for (channelsi = 0; channelsi < total_channels; channelsi++) { - float *dst = (float *) JACK_jack_port_get_buffer(ports[channelsi], nframes); + float *dst = (float *)JACK_jack_port_get_buffer(ports[channelsi], nframes); if (dst) { - const float *src = ((float *) this->hidden->iobuffer) + channelsi; + const float *src = ((float *)this->hidden->iobuffer) + channelsi; int framesi; for (framesi = 0; framesi < total_frames; framesi++) { *(dst++) = *src; @@ -182,14 +171,12 @@ jackProcessPlaybackCallback(jack_nframes_t nframes, void *arg) } } - SDL_SemPost(this->hidden->iosem); /* tell SDL thread we're done; refill the buffer. */ - return 0; /* success */ + SDL_SemPost(this->hidden->iosem); /* tell SDL thread we're done; refill the buffer. */ + return 0; } - /* This function waits until it is possible to write a full sound buffer */ -static void -JACK_WaitDevice(_THIS) +static void JACK_WaitDevice(_THIS) { if (SDL_AtomicGet(&this->enabled)) { if (SDL_SemWait(this->hidden->iosem) == -1) { @@ -198,27 +185,24 @@ JACK_WaitDevice(_THIS) } } -static Uint8 * -JACK_GetDeviceBuf(_THIS) +static Uint8 *JACK_GetDeviceBuf(_THIS) { - return (Uint8 *) this->hidden->iobuffer; + return (Uint8 *)this->hidden->iobuffer; } - -static int -jackProcessCaptureCallback(jack_nframes_t nframes, void *arg) +static int jackProcessCaptureCallback(jack_nframes_t nframes, void *arg) { - SDL_AudioDevice *this = (SDL_AudioDevice *) arg; + SDL_AudioDevice *this = (SDL_AudioDevice *)arg; if (SDL_AtomicGet(&this->enabled)) { jack_port_t **ports = this->hidden->sdlports; const int total_channels = this->spec.channels; const int total_frames = this->spec.samples; int channelsi; - + for (channelsi = 0; channelsi < total_channels; channelsi++) { - const float *src = (const float *) JACK_jack_port_get_buffer(ports[channelsi], nframes); + const float *src = (const float *)JACK_jack_port_get_buffer(ports[channelsi], nframes); if (src) { - float *dst = ((float *) this->hidden->iobuffer) + channelsi; + float *dst = ((float *)this->hidden->iobuffer) + channelsi; int framesi; for (framesi = 0; framesi < total_frames; framesi++) { *dst = *(src++); @@ -228,14 +212,13 @@ jackProcessCaptureCallback(jack_nframes_t nframes, void *arg) } } - SDL_SemPost(this->hidden->iosem); /* tell SDL thread we're done; new buffer is ready! */ - return 0; /* success */ + SDL_SemPost(this->hidden->iosem); /* tell SDL thread we're done; new buffer is ready! */ + return 0; } -static int -JACK_CaptureFromDevice(_THIS, void *buffer, int buflen) +static int JACK_CaptureFromDevice(_THIS, void *buffer, int buflen) { - SDL_assert(buflen == this->spec.size); /* we always fill a full buffer. */ + SDL_assert(buflen == this->spec.size); /* we always fill a full buffer. */ /* Wait for JACK to fill the iobuffer */ if (SDL_SemWait(this->hidden->iosem) == -1) { @@ -246,15 +229,12 @@ JACK_CaptureFromDevice(_THIS, void *buffer, int buflen) return buflen; } -static void -JACK_FlushCapture(_THIS) +static void JACK_FlushCapture(_THIS) { SDL_SemWait(this->hidden->iosem); } - -static void -JACK_CloseDevice(_THIS) +static void JACK_CloseDevice(_THIS) { if (this->hidden->client) { JACK_jack_deactivate(this->hidden->client); @@ -279,8 +259,7 @@ JACK_CloseDevice(_THIS) SDL_free(this->hidden); } -static int -JACK_OpenDevice(_THIS, const char *devname) +static int JACK_OpenDevice(_THIS, const char *devname) { /* Note that JACK uses "output" for capture devices (they output audio data to us) and "input" for playback (we input audio data to them). @@ -300,7 +279,7 @@ JACK_OpenDevice(_THIS, const char *devname) int i; /* Initialize all variables that we clean on shutdown */ - this->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof (*this->hidden)); + this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden)); if (this->hidden == NULL) { return SDL_OutOfMemory(); } @@ -328,7 +307,7 @@ JACK_OpenDevice(_THIS, const char *devname) const char *type = JACK_jack_port_type(dport); const int len = SDL_strlen(type); /* See if type ends with "audio" */ - if (len >= 5 && !SDL_memcmp(type+len-5, "audio", 5)) { + if (len >= 5 && !SDL_memcmp(type + len - 5, "audio", 5)) { audio_ports[channels++] = i; } } @@ -336,7 +315,6 @@ JACK_OpenDevice(_THIS, const char *devname) return SDL_SetError("No physical JACK ports available"); } - /* !!! FIXME: docs say about buffer size: "This size may change, clients that depend on it must register a bufsize_callback so they will be notified if it does." */ /* Jack pretty much demands what it wants. */ @@ -349,23 +327,23 @@ JACK_OpenDevice(_THIS, const char *devname) this->hidden->iosem = SDL_CreateSemaphore(0); if (!this->hidden->iosem) { - return -1; /* error was set by SDL_CreateSemaphore */ + return -1; /* error was set by SDL_CreateSemaphore */ } - this->hidden->iobuffer = (float *) SDL_calloc(1, this->spec.size); + this->hidden->iobuffer = (float *)SDL_calloc(1, this->spec.size); if (!this->hidden->iobuffer) { return SDL_OutOfMemory(); } /* Build SDL's ports, which we will connect to the device ports. */ - this->hidden->sdlports = (jack_port_t **) SDL_calloc(channels, sizeof (jack_port_t *)); + this->hidden->sdlports = (jack_port_t **)SDL_calloc(channels, sizeof(jack_port_t *)); if (this->hidden->sdlports == NULL) { return SDL_OutOfMemory(); } for (i = 0; i < channels; i++) { char portname[32]; - SDL_snprintf(portname, sizeof (portname), "sdl_jack_%s_%d", sdlportstr, i); + SDL_snprintf(portname, sizeof(portname), "sdl_jack_%s_%d", sdlportstr, i); this->hidden->sdlports[i] = JACK_jack_port_register(client, portname, JACK_DEFAULT_AUDIO_TYPE, sdlportflags, 0); if (this->hidden->sdlports[i] == NULL) { return SDL_SetError("jack_port_register failed"); @@ -400,14 +378,12 @@ JACK_OpenDevice(_THIS, const char *devname) return 0; } -static void -JACK_Deinitialize(void) +static void JACK_Deinitialize(void) { UnloadJackLibrary(); } -static SDL_bool -JACK_Init(SDL_AudioDriverImpl * impl) +static SDL_bool JACK_Init(SDL_AudioDriverImpl *impl) { if (LoadJackLibrary() < 0) { return SDL_FALSE; @@ -434,7 +410,7 @@ JACK_Init(SDL_AudioDriverImpl * impl) impl->OnlyHasDefaultCaptureDevice = SDL_TRUE; impl->HasCaptureSupport = SDL_TRUE; - return SDL_TRUE; /* this audio target is available. */ + return SDL_TRUE; /* this audio target is available. */ } AudioBootStrap JACK_bootstrap = { diff --git a/src/audio/n3ds/SDL_n3dsaudio.c b/src/audio/n3ds/SDL_n3dsaudio.c index 484bec8ae..9d99f19d3 100644 --- a/src/audio/n3ds/SDL_n3dsaudio.c +++ b/src/audio/n3ds/SDL_n3dsaudio.c @@ -38,32 +38,27 @@ static SDL_AudioDevice *audio_device; static void FreePrivateData(_THIS); static int FindAudioFormat(_THIS); -static SDL_INLINE void -contextLock(_THIS) +static SDL_INLINE void contextLock(_THIS) { LightLock_Lock(&this->hidden->lock); } -static SDL_INLINE void -contextUnlock(_THIS) +static SDL_INLINE void contextUnlock(_THIS) { LightLock_Unlock(&this->hidden->lock); } -static void -N3DSAUD_LockAudio(_THIS) +static void N3DSAUD_LockAudio(_THIS) { contextLock(this); } -static void -N3DSAUD_UnlockAudio(_THIS) +static void N3DSAUD_UnlockAudio(_THIS) { contextUnlock(this); } -static void -N3DSAUD_DspHook(DSP_HookType hook) +static void N3DSAUD_DspHook(DSP_HookType hook) { if (hook == DSPHOOK_ONCANCEL) { contextLock(audio_device); @@ -74,12 +69,11 @@ N3DSAUD_DspHook(DSP_HookType hook) } } -static void -AudioFrameFinished(void *device) +static void AudioFrameFinished(void *device) { bool shouldBroadcast = false; unsigned i; - SDL_AudioDevice *this = (SDL_AudioDevice *) device; + SDL_AudioDevice *this = (SDL_AudioDevice *)device; contextLock(this); @@ -97,13 +91,12 @@ AudioFrameFinished(void *device) contextUnlock(this); } -static int -N3DSAUDIO_OpenDevice(_THIS, const char *devname) +static int N3DSAUDIO_OpenDevice(_THIS, const char *devname) { Result ndsp_init_res; Uint8 *data_vaddr; float mix[12]; - this->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof *this->hidden); + this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof *this->hidden); if (this->hidden == NULL) { return SDL_OutOfMemory(); @@ -142,14 +135,14 @@ N3DSAUDIO_OpenDevice(_THIS, const char *devname) } this->hidden->mixlen = this->spec.size; - this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->spec.size); + this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->spec.size); if (this->hidden->mixbuf == NULL) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); - data_vaddr = (Uint8 *) linearAlloc(this->hidden->mixlen * NUM_BUFFERS); + data_vaddr = (Uint8 *)linearAlloc(this->hidden->mixlen * NUM_BUFFERS); if (data_vaddr == NULL) { return SDL_OutOfMemory(); } @@ -188,8 +181,7 @@ N3DSAUDIO_OpenDevice(_THIS, const char *devname) return 0; } -static int -N3DSAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) +static int N3DSAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) { /* Delay to make this sort of simulate real audio input. */ SDL_Delay((this->spec.samples * 1000) / this->spec.freq); @@ -199,8 +191,7 @@ N3DSAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) return buflen; } -static void -N3DSAUDIO_PlayDevice(_THIS) +static void N3DSAUDIO_PlayDevice(_THIS) { size_t nextbuf; size_t sampleLen; @@ -219,15 +210,14 @@ N3DSAUDIO_PlayDevice(_THIS) contextUnlock(this); - memcpy((void *) this->hidden->waveBuf[nextbuf].data_vaddr, + memcpy((void *)this->hidden->waveBuf[nextbuf].data_vaddr, this->hidden->mixbuf, sampleLen); DSP_FlushDataCache(this->hidden->waveBuf[nextbuf].data_vaddr, sampleLen); ndspChnWaveBufAdd(0, &this->hidden->waveBuf[nextbuf]); } -static void -N3DSAUDIO_WaitDevice(_THIS) +static void N3DSAUDIO_WaitDevice(_THIS) { contextLock(this); while (!this->hidden->isCancelled && @@ -237,14 +227,12 @@ N3DSAUDIO_WaitDevice(_THIS) contextUnlock(this); } -static Uint8 * -N3DSAUDIO_GetDeviceBuf(_THIS) +static Uint8 *N3DSAUDIO_GetDeviceBuf(_THIS) { return this->hidden->mixbuf; } -static void -N3DSAUDIO_CloseDevice(_THIS) +static void N3DSAUDIO_CloseDevice(_THIS) { contextLock(this); @@ -264,8 +252,7 @@ N3DSAUDIO_CloseDevice(_THIS) FreePrivateData(this); } -static void -N3DSAUDIO_ThreadInit(_THIS) +static void N3DSAUDIO_ThreadInit(_THIS) { s32 current_priority; svcGetThreadPriority(¤t_priority, CUR_THREAD_HANDLE); @@ -275,8 +262,7 @@ N3DSAUDIO_ThreadInit(_THIS) svcSetThreadPriority(CUR_THREAD_HANDLE, current_priority); } -static SDL_bool -N3DSAUDIO_Init(SDL_AudioDriverImpl *impl) +static SDL_bool N3DSAUDIO_Init(SDL_AudioDriverImpl *impl) { /* Set the function pointers */ impl->OpenDevice = N3DSAUDIO_OpenDevice; @@ -306,15 +292,14 @@ AudioBootStrap N3DSAUDIO_bootstrap = { /** * Cleans up all allocated memory, safe to call with null pointers */ -static void -FreePrivateData(_THIS) +static void FreePrivateData(_THIS) { if (!this->hidden) { return; } if (this->hidden->waveBuf[0].data_vaddr) { - linearFree((void *) this->hidden->waveBuf[0].data_vaddr); + linearFree((void *)this->hidden->waveBuf[0].data_vaddr); } if (this->hidden->mixbuf) { @@ -326,8 +311,7 @@ FreePrivateData(_THIS) this->hidden = NULL; } -static int -FindAudioFormat(_THIS) +static int FindAudioFormat(_THIS) { SDL_bool found_valid_format = SDL_FALSE; Uint16 test_format = SDL_FirstAudioFormat(this->spec.format); diff --git a/src/audio/netbsd/SDL_netbsdaudio.c b/src/audio/netbsd/SDL_netbsdaudio.c index 9a223fb83..c00affab3 100644 --- a/src/audio/netbsd/SDL_netbsdaudio.c +++ b/src/audio/netbsd/SDL_netbsdaudio.c @@ -45,15 +45,12 @@ /* #define DEBUG_AUDIO */ -static void -NETBSDAUDIO_DetectDevices(void) +static void NETBSDAUDIO_DetectDevices(void) { SDL_EnumUnixAudioDevices(0, NULL); } - -static void -NETBSDAUDIO_Status(_THIS) +static void NETBSDAUDIO_Status(_THIS) { #ifdef DEBUG_AUDIO /* *INDENT-OFF* */ /* clang-format off */ @@ -119,12 +116,11 @@ NETBSDAUDIO_Status(_THIS) this->spec.format, this->spec.size); /* *INDENT-ON* */ /* clang-format on */ + #endif /* DEBUG_AUDIO */ } - -static void -NETBSDAUDIO_PlayDevice(_THIS) +static void NETBSDAUDIO_PlayDevice(_THIS) { struct SDL_PrivateAudioData *h = this->hidden; int written; @@ -143,17 +139,14 @@ NETBSDAUDIO_PlayDevice(_THIS) #endif } -static Uint8 * -NETBSDAUDIO_GetDeviceBuf(_THIS) +static Uint8 *NETBSDAUDIO_GetDeviceBuf(_THIS) { return this->hidden->mixbuf; } - -static int -NETBSDAUDIO_CaptureFromDevice(_THIS, void *_buffer, int buflen) +static int NETBSDAUDIO_CaptureFromDevice(_THIS, void *_buffer, int buflen) { - Uint8 *buffer = (Uint8 *) _buffer; + Uint8 *buffer = (Uint8 *)_buffer; int br; br = read(this->hidden->audio_fd, buffer, buflen); @@ -169,30 +162,28 @@ NETBSDAUDIO_CaptureFromDevice(_THIS, void *_buffer, int buflen) return 0; } -static void -NETBSDAUDIO_FlushCapture(_THIS) +static void NETBSDAUDIO_FlushCapture(_THIS) { audio_info_t info; size_t remain; Uint8 buf[512]; if (ioctl(this->hidden->audio_fd, AUDIO_GETINFO, &info) < 0) { - return; /* oh well. */ + return; /* oh well. */ } - remain = (size_t) (info.record.samples * (SDL_AUDIO_BITSIZE(this->spec.format) / 8)); + remain = (size_t)(info.record.samples * (SDL_AUDIO_BITSIZE(this->spec.format) / 8)); while (remain > 0) { - const size_t len = SDL_min(sizeof (buf), remain); + const size_t len = SDL_min(sizeof(buf), remain); const int br = read(this->hidden->audio_fd, buf, len); if (br <= 0) { - return; /* oh well. */ + return; /* oh well. */ } remain -= br; } } -static void -NETBSDAUDIO_CloseDevice(_THIS) +static void NETBSDAUDIO_CloseDevice(_THIS) { if (this->hidden->audio_fd >= 0) { close(this->hidden->audio_fd); @@ -201,8 +192,7 @@ NETBSDAUDIO_CloseDevice(_THIS) SDL_free(this->hidden); } -static int -NETBSDAUDIO_OpenDevice(_THIS, const char *devname) +static int NETBSDAUDIO_OpenDevice(_THIS, const char *devname) { SDL_bool iscapture = this->iscapture; SDL_AudioFormat test_format; @@ -241,8 +231,7 @@ NETBSDAUDIO_OpenDevice(_THIS, const char *devname) * Use the device's native sample rate so the kernel doesn't have to * resample. */ - this->spec.freq = iscapture ? - hwinfo.record.sample_rate : hwinfo.play.sample_rate; + this->spec.freq = iscapture ? hwinfo.record.sample_rate : hwinfo.play.sample_rate; } #endif @@ -307,7 +296,7 @@ NETBSDAUDIO_OpenDevice(_THIS, const char *devname) if (!iscapture) { /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; - this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); + this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen); if (this->hidden->mixbuf == NULL) { return SDL_OutOfMemory(); } @@ -320,8 +309,7 @@ NETBSDAUDIO_OpenDevice(_THIS, const char *devname) return 0; } -static SDL_bool -NETBSDAUDIO_Init(SDL_AudioDriverImpl * impl) +static SDL_bool NETBSDAUDIO_Init(SDL_AudioDriverImpl *impl) { /* Set the function pointers */ impl->DetectDevices = NETBSDAUDIO_DetectDevices; @@ -335,10 +323,9 @@ NETBSDAUDIO_Init(SDL_AudioDriverImpl * impl) impl->HasCaptureSupport = SDL_TRUE; impl->AllowsArbitraryDeviceNames = SDL_TRUE; - return SDL_TRUE; /* this audio target is available. */ + return SDL_TRUE; /* this audio target is available. */ } - AudioBootStrap NETBSDAUDIO_bootstrap = { "netbsd", "NetBSD audio", NETBSDAUDIO_Init, SDL_FALSE }; diff --git a/src/audio/netbsd/SDL_netbsdaudio.h b/src/audio/netbsd/SDL_netbsdaudio.h index 862d431b6..5b5ad7f9d 100644 --- a/src/audio/netbsd/SDL_netbsdaudio.h +++ b/src/audio/netbsd/SDL_netbsdaudio.h @@ -25,7 +25,7 @@ #include "../SDL_sysaudio.h" -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { @@ -41,7 +41,7 @@ struct SDL_PrivateAudioData float next_frame; }; -#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */ +#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */ #endif /* SDL_netbsdaudio_h_ */ diff --git a/src/audio/openslES/SDL_openslES.c b/src/audio/openslES/SDL_openslES.c index 814a75aaa..b1c8e268e 100644 --- a/src/audio/openslES/SDL_openslES.c +++ b/src/audio/openslES/SDL_openslES.c @@ -38,9 +38,9 @@ #include #if 0 -#define LOG_TAG "SDL_openslES" -#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) -#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) +#define LOG_TAG "SDL_openslES" +#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) +#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) //#define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE,LOG_TAG,__VA_ARGS__) #define LOGV(...) #else @@ -70,9 +70,9 @@ #define SL_SPEAKER_TOP_BACK_RIGHT ((SLuint32) 0x00020000) */ #define SL_ANDROID_SPEAKER_STEREO (SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT) -#define SL_ANDROID_SPEAKER_QUAD (SL_ANDROID_SPEAKER_STEREO | SL_SPEAKER_BACK_LEFT | SL_SPEAKER_BACK_RIGHT) -#define SL_ANDROID_SPEAKER_5DOT1 (SL_ANDROID_SPEAKER_QUAD | SL_SPEAKER_FRONT_CENTER | SL_SPEAKER_LOW_FREQUENCY) -#define SL_ANDROID_SPEAKER_7DOT1 (SL_ANDROID_SPEAKER_5DOT1 | SL_SPEAKER_SIDE_LEFT | SL_SPEAKER_SIDE_RIGHT) +#define SL_ANDROID_SPEAKER_QUAD (SL_ANDROID_SPEAKER_STEREO | SL_SPEAKER_BACK_LEFT | SL_SPEAKER_BACK_RIGHT) +#define SL_ANDROID_SPEAKER_5DOT1 (SL_ANDROID_SPEAKER_QUAD | SL_SPEAKER_FRONT_CENTER | SL_SPEAKER_LOW_FREQUENCY) +#define SL_ANDROID_SPEAKER_7DOT1 (SL_ANDROID_SPEAKER_5DOT1 | SL_SPEAKER_SIDE_LEFT | SL_SPEAKER_SIDE_RIGHT) /* engine interfaces */ static SLObjectItf engineObject = NULL; @@ -98,8 +98,8 @@ static SLAndroidSimpleBufferQueueItf recorderBufferQueue = NULL; static const char *sldevaudiorecorderstr = "SLES Audio Recorder"; static const char *sldevaudioplayerstr = "SLES Audio Player"; -#define SLES_DEV_AUDIO_RECORDER sldevaudiorecorderstr -#define SLES_DEV_AUDIO_PLAYER sldevaudioplayerstr +#define SLES_DEV_AUDIO_RECORDER sldevaudiorecorderstr +#define SLES_DEV_AUDIO_PLAYER sldevaudioplayerstr static void openslES_DetectDevices( int iscapture ) { LOGI( "openSLES_DetectDevices()" ); @@ -128,8 +128,7 @@ static void openslES_DestroyEngine(void) } } -static int -openslES_CreateEngine(void) +static int openslES_CreateEngine(void) { const SLInterfaceID ids[1] = { SL_IID_VOLUME }; const SLboolean req[1] = { SL_BOOLEAN_FALSE }; @@ -183,17 +182,15 @@ error: } /* this callback handler is called every time a buffer finishes recording */ -static void -bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void *context) +static void bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void *context) { - struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *) context; + struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *)context; LOGV("SLES: Recording Callback"); SDL_SemPost(audiodata->playsem); } -static void -openslES_DestroyPCMRecorder(_THIS) +static void openslES_DestroyPCMRecorder(_THIS) { struct SDL_PrivateAudioData *audiodata = this->hidden; SLresult result; @@ -224,8 +221,7 @@ openslES_DestroyPCMRecorder(_THIS) } } -static int -openslES_CreatePCMRecorder(_THIS) +static int openslES_CreatePCMRecorder(_THIS) { struct SDL_PrivateAudioData *audiodata = this->hidden; SLDataFormat_PCM format_pcm; @@ -252,8 +248,8 @@ openslES_CreatePCMRecorder(_THIS) SDL_CalculateAudioSpec(&this->spec); LOGI("Try to open %u hz %u bit chan %u %s samples %u", - this->spec.freq, SDL_AUDIO_BITSIZE(this->spec.format), - this->spec.channels, (this->spec.format & 0x1000) ? "BE" : "LE", this->spec.samples); + this->spec.freq, SDL_AUDIO_BITSIZE(this->spec.format), + this->spec.channels, (this->spec.format & 0x1000) ? "BE" : "LE", this->spec.samples); /* configure audio source */ loc_dev.locatorType = SL_DATALOCATOR_IODEVICE; @@ -267,13 +263,13 @@ openslES_CreatePCMRecorder(_THIS) loc_bufq.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE; loc_bufq.numBuffers = NUM_BUFFERS; - format_pcm.formatType = SL_DATAFORMAT_PCM; - format_pcm.numChannels = this->spec.channels; - format_pcm.samplesPerSec = this->spec.freq * 1000; /* / kilo Hz to milli Hz */ + format_pcm.formatType = SL_DATAFORMAT_PCM; + format_pcm.numChannels = this->spec.channels; + format_pcm.samplesPerSec = this->spec.freq * 1000; /* / kilo Hz to milli Hz */ format_pcm.bitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format); format_pcm.containerSize = SDL_AUDIO_BITSIZE(this->spec.format); - format_pcm.endianness = SL_BYTEORDER_LITTLEENDIAN; - format_pcm.channelMask = SL_SPEAKER_FRONT_CENTER; + format_pcm.endianness = SL_BYTEORDER_LITTLEENDIAN; + format_pcm.channelMask = SL_SPEAKER_FRONT_CENTER; audioSnk.pLocator = &loc_bufq; audioSnk.pFormat = &format_pcm; @@ -323,7 +319,7 @@ openslES_CreatePCMRecorder(_THIS) } /* Create the sound buffers */ - audiodata->mixbuff = (Uint8 *) SDL_malloc(NUM_BUFFERS * this->spec.size); + audiodata->mixbuff = (Uint8 *)SDL_malloc(NUM_BUFFERS * this->spec.size); if (audiodata->mixbuff == NULL) { LOGE("mixbuffer allocate - out of memory"); goto failed; @@ -363,17 +359,15 @@ failed: } /* this callback handler is called every time a buffer finishes playing */ -static void -bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context) +static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context) { - struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *) context; + struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *)context; LOGV("SLES: Playback Callback"); SDL_SemPost(audiodata->playsem); } -static void -openslES_DestroyPCMPlayer(_THIS) +static void openslES_DestroyPCMPlayer(_THIS) { struct SDL_PrivateAudioData *audiodata = this->hidden; SLresult result; @@ -405,8 +399,7 @@ openslES_DestroyPCMPlayer(_THIS) } } -static int -openslES_CreatePCMPlayer(_THIS) +static int openslES_CreatePCMPlayer(_THIS) { struct SDL_PrivateAudioData *audiodata = this->hidden; SLDataLocator_AndroidSimpleBufferQueue loc_bufq; @@ -434,7 +427,7 @@ openslES_CreatePCMPlayer(_THIS) if (!test_format) { /* Didn't find a compatible format : */ - LOGI( "No compatible audio format, using signed 16-bit audio" ); + LOGI("No compatible audio format, using signed 16-bit audio"); test_format = AUDIO_S16SYS; } this->spec.format = test_format; @@ -447,16 +440,16 @@ openslES_CreatePCMPlayer(_THIS) SDL_CalculateAudioSpec(&this->spec); LOGI("Try to open %u hz %s %u bit chan %u %s samples %u", - this->spec.freq, SDL_AUDIO_ISFLOAT(this->spec.format) ? "float" : "pcm", SDL_AUDIO_BITSIZE(this->spec.format), - this->spec.channels, (this->spec.format & 0x1000) ? "BE" : "LE", this->spec.samples); + this->spec.freq, SDL_AUDIO_ISFLOAT(this->spec.format) ? "float" : "pcm", SDL_AUDIO_BITSIZE(this->spec.format), + this->spec.channels, (this->spec.format & 0x1000) ? "BE" : "LE", this->spec.samples); /* configure audio source */ loc_bufq.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE; loc_bufq.numBuffers = NUM_BUFFERS; - format_pcm.formatType = SL_DATAFORMAT_PCM; - format_pcm.numChannels = this->spec.channels; - format_pcm.samplesPerSec = this->spec.freq * 1000; /* / kilo Hz to milli Hz */ + format_pcm.formatType = SL_DATAFORMAT_PCM; + format_pcm.numChannels = this->spec.channels; + format_pcm.samplesPerSec = this->spec.freq * 1000; /* / kilo Hz to milli Hz */ format_pcm.bitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format); format_pcm.containerSize = SDL_AUDIO_BITSIZE(this->spec.format); @@ -466,8 +459,7 @@ openslES_CreatePCMPlayer(_THIS) format_pcm.endianness = SL_BYTEORDER_LITTLEENDIAN; } - switch (this->spec.channels) - { + switch (this->spec.channels) { case 1: format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT; break; @@ -512,7 +504,7 @@ openslES_CreatePCMPlayer(_THIS) } audioSrc.pLocator = &loc_bufq; - audioSrc.pFormat = SDL_AUDIO_ISFLOAT(this->spec.format) ? (void*)&format_pcm_ex : (void*)&format_pcm; + audioSrc.pFormat = SDL_AUDIO_ISFLOAT(this->spec.format) ? (void *)&format_pcm_ex : (void *)&format_pcm; /* configure audio sink */ loc_outmix.locatorType = SL_DATALOCATOR_OUTPUTMIX; @@ -573,7 +565,7 @@ openslES_CreatePCMPlayer(_THIS) } /* Create the sound buffers */ - audiodata->mixbuff = (Uint8 *) SDL_malloc(NUM_BUFFERS * this->spec.size); + audiodata->mixbuff = (Uint8 *)SDL_malloc(NUM_BUFFERS * this->spec.size); if (audiodata->mixbuff == NULL) { LOGE("mixbuffer allocate - out of memory"); goto failed; @@ -596,10 +588,9 @@ failed: return -1; } -static int -openslES_OpenDevice(_THIS, const char *devname) +static int openslES_OpenDevice(_THIS, const char *devname) { - this->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, (sizeof *this->hidden)); + this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, (sizeof *this->hidden)); if (this->hidden == NULL) { return SDL_OutOfMemory(); } @@ -625,12 +616,10 @@ openslES_OpenDevice(_THIS, const char *devname) } else { return SDL_SetError("Open device failed!"); } - } } -static void -openslES_WaitDevice(_THIS) +static void openslES_WaitDevice(_THIS) { struct SDL_PrivateAudioData *audiodata = this->hidden; @@ -640,8 +629,7 @@ openslES_WaitDevice(_THIS) SDL_SemWait(audiodata->playsem); } -static void -openslES_PlayDevice(_THIS) +static void openslES_PlayDevice(_THIS) { struct SDL_PrivateAudioData *audiodata = this->hidden; SLresult result; @@ -675,8 +663,7 @@ openslES_PlayDevice(_THIS) /* */ /* okay.. */ -static Uint8 * -openslES_GetDeviceBuf(_THIS) +static Uint8 *openslES_GetDeviceBuf(_THIS) { struct SDL_PrivateAudioData *audiodata = this->hidden; @@ -684,8 +671,7 @@ openslES_GetDeviceBuf(_THIS) return audiodata->pmixbuff[audiodata->next_buffer]; } -static int -openslES_CaptureFromDevice(_THIS, void *buffer, int buflen) +static int openslES_CaptureFromDevice(_THIS, void *buffer, int buflen) { struct SDL_PrivateAudioData *audiodata = this->hidden; SLresult result; @@ -712,8 +698,7 @@ openslES_CaptureFromDevice(_THIS, void *buffer, int buflen) return this->spec.size; } -static void -openslES_CloseDevice(_THIS) +static void openslES_CloseDevice(_THIS) { /* struct SDL_PrivateAudioData *audiodata = this->hidden; */ @@ -728,8 +713,7 @@ openslES_CloseDevice(_THIS) SDL_free(this->hidden); } -static SDL_bool -openslES_Init(SDL_AudioDriverImpl * impl) +static SDL_bool openslES_Init(SDL_AudioDriverImpl *impl) { LOGI("openslES_Init() called"); @@ -741,13 +725,13 @@ openslES_Init(SDL_AudioDriverImpl * impl) /* Set the function pointers */ /* impl->DetectDevices = openslES_DetectDevices; */ - impl->OpenDevice = openslES_OpenDevice; - impl->WaitDevice = openslES_WaitDevice; - impl->PlayDevice = openslES_PlayDevice; - impl->GetDeviceBuf = openslES_GetDeviceBuf; + impl->OpenDevice = openslES_OpenDevice; + impl->WaitDevice = openslES_WaitDevice; + impl->PlayDevice = openslES_PlayDevice; + impl->GetDeviceBuf = openslES_GetDeviceBuf; impl->CaptureFromDevice = openslES_CaptureFromDevice; - impl->CloseDevice = openslES_CloseDevice; - impl->Deinitialize = openslES_DestroyEngine; + impl->CloseDevice = openslES_CloseDevice; + impl->Deinitialize = openslES_DestroyEngine; /* and the capabilities */ impl->HasCaptureSupport = SDL_TRUE; diff --git a/src/audio/openslES/SDL_openslES.h b/src/audio/openslES/SDL_openslES.h index 10ff588a1..5379cd7d8 100644 --- a/src/audio/openslES/SDL_openslES.h +++ b/src/audio/openslES/SDL_openslES.h @@ -26,15 +26,15 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this -#define NUM_BUFFERS 2 /* -- Don't lower this! */ +#define NUM_BUFFERS 2 /* -- Don't lower this! */ struct SDL_PrivateAudioData { - Uint8 *mixbuff; - int next_buffer; - Uint8 *pmixbuff[NUM_BUFFERS]; + Uint8 *mixbuff; + int next_buffer; + Uint8 *pmixbuff[NUM_BUFFERS]; SDL_sem *playsem; }; diff --git a/src/audio/pipewire/SDL_pipewire.c b/src/audio/pipewire/SDL_pipewire.c index f707a2df1..00bff48f1 100644 --- a/src/audio/pipewire/SDL_pipewire.c +++ b/src/audio/pipewire/SDL_pipewire.c @@ -77,7 +77,7 @@ enum PW_READY_FLAGS { PW_READY_FLAG_BUFFER_ADDED = 0x1, PW_READY_FLAG_STREAM_READY = 0x2, - PW_READY_FLAG_ALL_BITS = 0x3 + PW_READY_FLAG_ALL_BITS = 0x3 }; #define PW_ID_TO_HANDLE(x) (void *)((uintptr_t)x) @@ -117,17 +117,16 @@ static struct pw_properties *(*PIPEWIRE_pw_properties_new)(const char *, ...)SPA static int (*PIPEWIRE_pw_properties_set)(struct pw_properties *, const char *, const char *); static int (*PIPEWIRE_pw_properties_setf)(struct pw_properties *, const char *, const char *, ...) SPA_PRINTF_FUNC(3, 4); -static int pipewire_version_major; -static int pipewire_version_minor; -static int pipewire_version_patch; +static int pipewire_version_major; +static int pipewire_version_minor; +static int pipewire_version_patch; #ifdef SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC static const char *pipewire_library = SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC; -static void *pipewire_handle = NULL; +static void *pipewire_handle = NULL; -static int -pipewire_dlsym(const char *fn, void **addr) +static int pipewire_dlsym(const char *fn, void **addr) { *addr = SDL_LoadFunction(pipewire_handle, fn); if (*addr == NULL) { @@ -143,8 +142,7 @@ pipewire_dlsym(const char *fn, void **addr) return -1; \ } -static int -load_pipewire_library() +static int load_pipewire_library() { if ((pipewire_handle = SDL_LoadObject(pipewire_library))) { return 0; @@ -153,8 +151,7 @@ load_pipewire_library() return -1; } -static void -unload_pipewire_library() +static void unload_pipewire_library() { if (pipewire_handle) { SDL_UnloadObject(pipewire_handle); @@ -166,21 +163,18 @@ unload_pipewire_library() #define SDL_PIPEWIRE_SYM(x) PIPEWIRE_##x = x -static int -load_pipewire_library() +static int load_pipewire_library() { return 0; } -static void -unload_pipewire_library() +static void unload_pipewire_library() { /* Nothing to do */ } #endif /* SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC */ -static int -load_pipewire_syms() +static int load_pipewire_syms() { SDL_PIPEWIRE_SYM(pw_get_library_version); SDL_PIPEWIRE_SYM(pw_init); @@ -222,8 +216,7 @@ pipewire_version_at_least(int major, int minor, int patch) (pipewire_version_major > major || pipewire_version_minor > minor || pipewire_version_patch >= patch); } -static int -init_pipewire_library() +static int init_pipewire_library() { if (!load_pipewire_library()) { if (!load_pipewire_syms()) { @@ -245,8 +238,7 @@ init_pipewire_library() return -1; } -static void -deinit_pipewire_library() +static void deinit_pipewire_library() { PIPEWIRE_pw_deinit(); unload_pipewire_library(); @@ -257,8 +249,8 @@ struct node_object { struct spa_list link; - Uint32 id; - int seq; + Uint32 id; + int seq; SDL_bool persist; /* @@ -271,8 +263,8 @@ struct node_object void *userdata; struct pw_proxy *proxy; - struct spa_hook node_listener; - struct spa_hook core_listener; + struct spa_hook node_listener; + struct spa_hook core_listener; }; /* A sink/source node used for stream I/O. */ @@ -280,8 +272,8 @@ struct io_node { struct spa_list link; - Uint32 id; - SDL_bool is_capture; + Uint32 id; + SDL_bool is_capture; SDL_AudioSpec spec; const char *name; /* Friendly name */ @@ -292,26 +284,25 @@ struct io_node /* The global hotplug thread and associated objects. */ static struct pw_thread_loop *hotplug_loop; -static struct pw_core *hotplug_core; -static struct pw_context *hotplug_context; -static struct pw_registry *hotplug_registry; -static struct spa_hook hotplug_registry_listener; -static struct spa_hook hotplug_core_listener; -static struct spa_list hotplug_pending_list; -static struct spa_list hotplug_io_list; -static int hotplug_init_seq_val; -static SDL_bool hotplug_init_complete; -static SDL_bool hotplug_events_enabled; +static struct pw_core *hotplug_core; +static struct pw_context *hotplug_context; +static struct pw_registry *hotplug_registry; +static struct spa_hook hotplug_registry_listener; +static struct spa_hook hotplug_core_listener; +static struct spa_list hotplug_pending_list; +static struct spa_list hotplug_io_list; +static int hotplug_init_seq_val; +static SDL_bool hotplug_init_complete; +static SDL_bool hotplug_events_enabled; -static char *pipewire_default_sink_id = NULL; +static char *pipewire_default_sink_id = NULL; static char *pipewire_default_source_id = NULL; /* The active node list */ -static SDL_bool -io_list_check_add(struct io_node *node) +static SDL_bool io_list_check_add(struct io_node *node) { struct io_node *n; - SDL_bool ret = SDL_TRUE; + SDL_bool ret = SDL_TRUE; /* See if the node is already in the list */ spa_list_for_each (n, &hotplug_io_list, link) { @@ -333,8 +324,7 @@ dup_found: return ret; } -static void -io_list_remove(Uint32 id) +static void io_list_remove(Uint32 id) { struct io_node *n, *temp; @@ -354,8 +344,7 @@ io_list_remove(Uint32 id) } } -static void -io_list_sort() +static void io_list_sort() { struct io_node *default_sink = NULL, *default_source = NULL; struct io_node *n, *temp; @@ -380,8 +369,7 @@ io_list_sort() } } -static void -io_list_clear() +static void io_list_clear() { struct io_node *n, *temp; @@ -391,7 +379,7 @@ io_list_clear() } } -static struct io_node* +static struct io_node * io_list_get_by_id(Uint32 id) { struct io_node *n, *temp; @@ -403,7 +391,7 @@ io_list_get_by_id(Uint32 id) return NULL; } -static struct io_node* +static struct io_node * io_list_get_by_path(char *path) { struct io_node *n, *temp; @@ -415,8 +403,7 @@ io_list_get_by_path(char *path) return NULL; } -static void -node_object_destroy(struct node_object *node) +static void node_object_destroy(struct node_object *node) { SDL_assert(node); @@ -428,15 +415,13 @@ node_object_destroy(struct node_object *node) } /* The pending node list */ -static void -pending_list_add(struct node_object *node) +static void pending_list_add(struct node_object *node) { SDL_assert(node); spa_list_append(&hotplug_pending_list, &node->link); } -static void -pending_list_remove(Uint32 id) +static void pending_list_remove(Uint32 id) { struct node_object *node, *temp; @@ -447,8 +432,7 @@ pending_list_remove(Uint32 id) } } -static void -pending_list_clear() +static void pending_list_clear() { struct node_object *node, *temp; @@ -457,10 +441,9 @@ pending_list_clear() } } -static void * -node_object_new(Uint32 id, const char *type, Uint32 version, const void *funcs, const struct pw_core_events *core_events) +static void *node_object_new(Uint32 id, const char *type, Uint32 version, const void *funcs, const struct pw_core_events *core_events) { - struct pw_proxy *proxy; + struct pw_proxy *proxy; struct node_object *node; /* Create the proxy object */ @@ -473,7 +456,7 @@ node_object_new(Uint32 id, const char *type, Uint32 version, const void *funcs, node = PIPEWIRE_pw_proxy_get_user_data(proxy); SDL_zerop(node); - node->id = id; + node->id = id; node->proxy = proxy; /* Add the callbacks */ @@ -487,8 +470,7 @@ node_object_new(Uint32 id, const char *type, Uint32 version, const void *funcs, } /* Core sync points */ -static void -core_events_hotplug_init_callback(void *object, uint32_t id, int seq) +static void core_events_hotplug_init_callback(void *object, uint32_t id, int seq) { if (id == PW_ID_CORE && seq == hotplug_init_seq_val) { /* This core listener is no longer needed. */ @@ -500,11 +482,10 @@ core_events_hotplug_init_callback(void *object, uint32_t id, int seq) } } -static void -core_events_interface_callback(void *object, uint32_t id, int seq) +static void core_events_interface_callback(void *object, uint32_t id, int seq) { struct node_object *node = object; - struct io_node *io = node->userdata; + struct io_node *io = node->userdata; if (id == PW_ID_CORE && seq == node->seq) { /* @@ -519,8 +500,7 @@ core_events_interface_callback(void *object, uint32_t id, int seq) } } -static void -core_events_metadata_callback(void *object, uint32_t id, int seq) +static void core_events_metadata_callback(void *object, uint32_t id, int seq) { struct node_object *node = object; @@ -530,11 +510,10 @@ core_events_metadata_callback(void *object, uint32_t id, int seq) } static const struct pw_core_events hotplug_init_core_events = { PW_VERSION_CORE_EVENTS, .done = core_events_hotplug_init_callback }; -static const struct pw_core_events interface_core_events = { PW_VERSION_CORE_EVENTS, .done = core_events_interface_callback }; -static const struct pw_core_events metadata_core_events = { PW_VERSION_CORE_EVENTS, .done = core_events_metadata_callback }; +static const struct pw_core_events interface_core_events = { PW_VERSION_CORE_EVENTS, .done = core_events_interface_callback }; +static const struct pw_core_events metadata_core_events = { PW_VERSION_CORE_EVENTS, .done = core_events_metadata_callback }; -static void -hotplug_core_sync(struct node_object *node) +static void hotplug_core_sync(struct node_object *node) { /* * Node sync events *must* come before the hotplug init sync events or the initial @@ -550,12 +529,11 @@ hotplug_core_sync(struct node_object *node) } /* Helpers for retrieving values from params */ -static SDL_bool -get_range_param(const struct spa_pod *param, Uint32 key, int *def, int *min, int *max) +static SDL_bool get_range_param(const struct spa_pod *param, Uint32 key, int *def, int *min, int *max) { const struct spa_pod_prop *prop; - struct spa_pod *value; - Uint32 n_values, choice; + struct spa_pod *value; + Uint32 n_values, choice; prop = spa_pod_find_prop(param, NULL, key); @@ -584,11 +562,10 @@ get_range_param(const struct spa_pod *param, Uint32 key, int *def, int *min, int return SDL_FALSE; } -static SDL_bool -get_int_param(const struct spa_pod *param, Uint32 key, int *val) +static SDL_bool get_int_param(const struct spa_pod *param, Uint32 key, int *val) { const struct spa_pod_prop *prop; - Sint32 v; + Sint32 v; prop = spa_pod_find_prop(param, NULL, key); @@ -604,13 +581,12 @@ get_int_param(const struct spa_pod *param, Uint32 key, int *val) } /* Interface node callbacks */ -static void -node_event_info(void *object, const struct pw_node_info *info) +static void node_event_info(void *object, const struct pw_node_info *info) { struct node_object *node = object; - struct io_node *io = node->userdata; - const char *prop_val; - Uint32 i; + struct io_node *io = node->userdata; + const char *prop_val; + Uint32 i; if (info) { prop_val = spa_dict_lookup(info->props, PW_KEY_AUDIO_CHANNELS); @@ -627,11 +603,10 @@ node_event_info(void *object, const struct pw_node_info *info) } } -static void -node_event_param(void *object, int seq, uint32_t id, uint32_t index, uint32_t next, const struct spa_pod *param) +static void node_event_param(void *object, int seq, uint32_t id, uint32_t index, uint32_t next, const struct spa_pod *param) { struct node_object *node = object; - struct io_node *io = node->userdata; + struct io_node *io = node->userdata; /* Get the default frequency */ if (io->spec.freq == 0) { @@ -653,8 +628,7 @@ node_event_param(void *object, int seq, uint32_t id, uint32_t index, uint32_t ne static const struct pw_node_events interface_node_events = { PW_VERSION_NODE_EVENTS, .info = node_event_info, .param = node_event_param }; -static char* -get_name_from_json(const char *json) +static char *get_name_from_json(const char *json) { struct spa_json parser[2]; char key[7]; /* "name" */ @@ -676,8 +650,7 @@ get_name_from_json(const char *json) } /* Metadata node callback */ -static int -metadata_property(void *object, Uint32 subject, const char *key, const char *type, const char *value) +static int metadata_property(void *object, Uint32 subject, const char *key, const char *type, const char *value) { struct node_object *node = object; @@ -703,9 +676,8 @@ metadata_property(void *object, Uint32 subject, const char *key, const char *typ static const struct pw_metadata_events metadata_node_events = { PW_VERSION_METADATA_EVENTS, .property = metadata_property }; /* Global registry callbacks */ -static void -registry_event_global_callback(void *object, uint32_t id, uint32_t permissions, const char *type, uint32_t version, - const struct spa_dict *props) +static void registry_event_global_callback(void *object, uint32_t id, uint32_t permissions, const char *type, uint32_t version, + const struct spa_dict *props) { struct node_object *node; @@ -714,12 +686,12 @@ registry_event_global_callback(void *object, uint32_t id, uint32_t permissions, const char *media_class = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS); if (media_class) { - const char *node_desc; - const char *node_path; + const char *node_desc; + const char *node_path; struct io_node *io; - SDL_bool is_capture; - int desc_buffer_len; - int path_buffer_len; + SDL_bool is_capture; + int desc_buffer_len; + int path_buffer_len; /* Just want sink and capture */ if (!SDL_strcasecmp(media_class, "Audio/Sink")) { @@ -751,11 +723,11 @@ registry_event_global_callback(void *object, uint32_t id, uint32_t permissions, } /* Begin setting the node properties */ - io->id = id; - io->is_capture = is_capture; + io->id = id; + io->is_capture = is_capture; io->spec.format = AUDIO_F32; /* Pipewire uses floats internally, other formats require conversion. */ - io->name = io->buf; - io->path = io->buf + desc_buffer_len; + io->name = io->buf; + io->path = io->buf + desc_buffer_len; SDL_strlcpy(io->buf, node_desc, desc_buffer_len); SDL_strlcpy(io->buf + desc_buffer_len, node_path, path_buffer_len); @@ -775,8 +747,7 @@ registry_event_global_callback(void *object, uint32_t id, uint32_t permissions, } } -static void -registry_event_remove_callback(void *object, uint32_t id) +static void registry_event_remove_callback(void *object, uint32_t id) { io_list_remove(id); pending_list_remove(id); @@ -786,8 +757,7 @@ static const struct pw_registry_events registry_events = { PW_VERSION_REGISTRY_E .global_remove = registry_event_remove_callback }; /* The hotplug thread */ -static int -hotplug_loop_init() +static int hotplug_loop_init() { int res; @@ -830,8 +800,7 @@ hotplug_loop_init() return 0; } -static void -hotplug_loop_destroy() +static void hotplug_loop_destroy() { if (hotplug_loop) { PIPEWIRE_pw_thread_loop_stop(hotplug_loop); @@ -840,7 +809,7 @@ hotplug_loop_destroy() pending_list_clear(); io_list_clear(); - hotplug_init_complete = SDL_FALSE; + hotplug_init_complete = SDL_FALSE; hotplug_events_enabled = SDL_FALSE; if (pipewire_default_sink_id != NULL) { @@ -873,8 +842,7 @@ hotplug_loop_destroy() } } -static void -PIPEWIRE_DetectDevices() +static void PIPEWIRE_DetectDevices() { struct io_node *io; @@ -916,11 +884,10 @@ static const enum spa_audio_channel PIPEWIRE_channel_map_8[] = { SPA_AUDIO_CHANN #define COPY_CHANNEL_MAP(c) SDL_memcpy(info->position, PIPEWIRE_channel_map_##c, sizeof(PIPEWIRE_channel_map_##c)) -static void -initialize_spa_info(const SDL_AudioSpec *spec, struct spa_audio_info_raw *info) +static void initialize_spa_info(const SDL_AudioSpec *spec, struct spa_audio_info_raw *info) { info->channels = spec->channels; - info->rate = spec->freq; + info->rate = spec->freq; switch (spec->channels) { case 1: @@ -984,14 +951,13 @@ initialize_spa_info(const SDL_AudioSpec *spec, struct spa_audio_info_raw *info) } } -static void -output_callback(void *data) +static void output_callback(void *data) { - struct pw_buffer *pw_buf; + struct pw_buffer *pw_buf; struct spa_buffer *spa_buf; - Uint8 *dst; + Uint8 *dst; - _THIS = (SDL_AudioDevice *)data; + _THIS = (SDL_AudioDevice *)data; struct pw_stream *stream = this->hidden->stream; /* Shutting down, don't do anything */ @@ -1045,18 +1011,17 @@ output_callback(void *data) spa_buf->datas[0].chunk->offset = 0; spa_buf->datas[0].chunk->stride = this->hidden->stride; - spa_buf->datas[0].chunk->size = this->spec.size; + spa_buf->datas[0].chunk->size = this->spec.size; PIPEWIRE_pw_stream_queue_buffer(stream, pw_buf); } -static void -input_callback(void *data) +static void input_callback(void *data) { - struct pw_buffer *pw_buf; + struct pw_buffer *pw_buf; struct spa_buffer *spa_buf; - Uint8 *src; - _THIS = (SDL_AudioDevice *)data; + Uint8 *src; + _THIS = (SDL_AudioDevice *)data; struct pw_stream *stream = this->hidden->stream; /* Shutting down, don't do anything */ @@ -1078,7 +1043,7 @@ input_callback(void *data) if (!SDL_AtomicGet(&this->paused)) { /* Calculate the offset and data size */ const Uint32 offset = SPA_MIN(spa_buf->datas[0].chunk->offset, spa_buf->datas[0].maxsize); - const Uint32 size = SPA_MIN(spa_buf->datas[0].chunk->size, spa_buf->datas[0].maxsize - offset); + const Uint32 size = SPA_MIN(spa_buf->datas[0].chunk->size, spa_buf->datas[0].maxsize - offset); src += offset; @@ -1106,8 +1071,7 @@ input_callback(void *data) PIPEWIRE_pw_stream_queue_buffer(stream, pw_buf); } -static void -stream_add_buffer_callback(void *data, struct pw_buffer *buffer) +static void stream_add_buffer_callback(void *data, struct pw_buffer *buffer) { _THIS = data; @@ -1118,7 +1082,7 @@ stream_add_buffer_callback(void *data, struct pw_buffer *buffer) */ if (this->spec.size > buffer->buffer->datas[0].maxsize) { this->spec.samples = buffer->buffer->datas[0].maxsize / this->hidden->stride; - this->spec.size = buffer->buffer->datas[0].maxsize; + this->spec.size = buffer->buffer->datas[0].maxsize; } } else if (this->hidden->buffer == NULL) { /* @@ -1130,15 +1094,14 @@ stream_add_buffer_callback(void *data, struct pw_buffer *buffer) * A packet size of 2 periods should be more than is ever needed. */ this->hidden->input_buffer_packet_size = SPA_MAX(this->spec.size, buffer->buffer->datas[0].maxsize) * 2; - this->hidden->buffer = SDL_NewDataQueue(this->hidden->input_buffer_packet_size, this->hidden->input_buffer_packet_size); + this->hidden->buffer = SDL_NewDataQueue(this->hidden->input_buffer_packet_size, this->hidden->input_buffer_packet_size); } this->hidden->stream_init_status |= PW_READY_FLAG_BUFFER_ADDED; PIPEWIRE_pw_thread_loop_signal(this->hidden->loop, false); } -static void -stream_state_changed_callback(void *data, enum pw_stream_state old, enum pw_stream_state state, const char *error) +static void stream_state_changed_callback(void *data, enum pw_stream_state old, enum pw_stream_state state, const char *error) { _THIS = data; @@ -1153,15 +1116,14 @@ stream_state_changed_callback(void *data, enum pw_stream_state old, enum pw_stre static const struct pw_stream_events stream_output_events = { PW_VERSION_STREAM_EVENTS, .state_changed = stream_state_changed_callback, - .add_buffer = stream_add_buffer_callback, - .process = output_callback }; -static const struct pw_stream_events stream_input_events = { PW_VERSION_STREAM_EVENTS, - .state_changed = stream_state_changed_callback, - .add_buffer = stream_add_buffer_callback, - .process = input_callback }; + .add_buffer = stream_add_buffer_callback, + .process = output_callback }; +static const struct pw_stream_events stream_input_events = { PW_VERSION_STREAM_EVENTS, + .state_changed = stream_state_changed_callback, + .add_buffer = stream_add_buffer_callback, + .process = input_callback }; -static int -PIPEWIRE_OpenDevice(_THIS, const char *devname) +static int PIPEWIRE_OpenDevice(_THIS, const char *devname) { /* * NOTE: The PW_STREAM_FLAG_RT_PROCESS flag can be set to call the stream @@ -1172,17 +1134,17 @@ PIPEWIRE_OpenDevice(_THIS, const char *devname) */ static const enum pw_stream_flags STREAM_FLAGS = PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_MAP_BUFFERS; - char thread_name[PW_THREAD_NAME_BUFFER_LENGTH]; - Uint8 pod_buffer[PW_POD_BUFFER_LENGTH]; - struct spa_pod_builder b = SPA_POD_BUILDER_INIT(pod_buffer, sizeof(pod_buffer)); - struct spa_audio_info_raw spa_info = { 0 }; - const struct spa_pod *params = NULL; + char thread_name[PW_THREAD_NAME_BUFFER_LENGTH]; + Uint8 pod_buffer[PW_POD_BUFFER_LENGTH]; + struct spa_pod_builder b = SPA_POD_BUILDER_INIT(pod_buffer, sizeof(pod_buffer)); + struct spa_audio_info_raw spa_info = { 0 }; + const struct spa_pod *params = NULL; struct SDL_PrivateAudioData *priv; - struct pw_properties *props; - const char *app_name, *stream_name, *stream_role, *error; - Uint32 node_id = this->handle == NULL ? PW_ID_ANY : PW_HANDLE_TO_ID(this->handle); - SDL_bool iscapture = this->iscapture; - int res; + struct pw_properties *props; + const char *app_name, *stream_name, *stream_role, *error; + Uint32 node_id = this->handle == NULL ? PW_ID_ANY : PW_HANDLE_TO_ID(this->handle); + SDL_bool iscapture = this->iscapture; + int res; /* Clamp the period size to sane values */ const int min_period = PW_MIN_SAMPLES * SPA_MAX(this->spec.freq / PW_BASE_CLOCK_RATE, 1); @@ -1226,7 +1188,7 @@ PIPEWIRE_OpenDevice(_THIS, const char *devname) if (this->spec.samples < min_period) { this->spec.samples = min_period; - this->spec.size = this->spec.samples * priv->stride; + this->spec.size = this->spec.samples * priv->stride; } SDL_snprintf(thread_name, sizeof(thread_name), "SDLAudio%c%ld", (iscapture) ? 'C' : 'P', (long)this->handle); @@ -1344,8 +1306,7 @@ static void PIPEWIRE_CloseDevice(_THIS) SDL_free(this->hidden); } -static int -PIPEWIRE_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) +static int PIPEWIRE_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) { struct io_node *node; char *target; @@ -1383,8 +1344,7 @@ failed: return ret; } -static void -PIPEWIRE_Deinitialize() +static void PIPEWIRE_Deinitialize() { if (pipewire_initialized) { hotplug_loop_destroy(); @@ -1393,8 +1353,7 @@ PIPEWIRE_Deinitialize() } } -static SDL_bool -PIPEWIRE_Init(SDL_AudioDriverImpl *impl) +static SDL_bool PIPEWIRE_Init(SDL_AudioDriverImpl *impl) { if (!pipewire_initialized) { if (init_pipewire_library() < 0) { @@ -1410,15 +1369,15 @@ PIPEWIRE_Init(SDL_AudioDriverImpl *impl) } /* Set the function pointers */ - impl->DetectDevices = PIPEWIRE_DetectDevices; - impl->OpenDevice = PIPEWIRE_OpenDevice; - impl->CloseDevice = PIPEWIRE_CloseDevice; - impl->Deinitialize = PIPEWIRE_Deinitialize; + impl->DetectDevices = PIPEWIRE_DetectDevices; + impl->OpenDevice = PIPEWIRE_OpenDevice; + impl->CloseDevice = PIPEWIRE_CloseDevice; + impl->Deinitialize = PIPEWIRE_Deinitialize; impl->GetDefaultAudioInfo = PIPEWIRE_GetDefaultAudioInfo; - impl->HasCaptureSupport = SDL_TRUE; + impl->HasCaptureSupport = SDL_TRUE; impl->ProvidesOwnCallbackThread = SDL_TRUE; - impl->SupportsNonPow2Samples = SDL_TRUE; + impl->SupportsNonPow2Samples = SDL_TRUE; return SDL_TRUE; } diff --git a/src/audio/pipewire/SDL_pipewire.h b/src/audio/pipewire/SDL_pipewire.h index 767b8f10c..2d5c8e0fc 100644 --- a/src/audio/pipewire/SDL_pipewire.h +++ b/src/audio/pipewire/SDL_pipewire.h @@ -33,13 +33,13 @@ struct SDL_PrivateAudioData { struct pw_thread_loop *loop; - struct pw_stream *stream; - struct pw_context *context; - struct SDL_DataQueue *buffer; + struct pw_stream *stream; + struct pw_context *context; + struct SDL_DataQueue *buffer; size_t input_buffer_packet_size; Sint32 stride; /* Bytes-per-frame */ - int stream_init_status; + int stream_init_status; }; #endif /* SDL_pipewire_h_ */ diff --git a/src/audio/ps2/SDL_ps2audio.c b/src/audio/ps2/SDL_ps2audio.c index fa85f0437..c777064f1 100644 --- a/src/audio/ps2/SDL_ps2audio.c +++ b/src/audio/ps2/SDL_ps2audio.c @@ -33,10 +33,9 @@ #include /* The tag name used by PS2 audio */ -#define PS2AUDIO_DRIVER_NAME "ps2" +#define PS2AUDIO_DRIVER_NAME "ps2" -static int -PS2AUDIO_OpenDevice(_THIS, const char *devname) +static int PS2AUDIO_OpenDevice(_THIS, const char *devname) { int i, mixlen; struct audsrv_fmt_t format; @@ -48,21 +47,20 @@ PS2AUDIO_OpenDevice(_THIS, const char *devname) } SDL_zerop(this->hidden); - /* These are the native supported audio PS2 configs */ switch (this->spec.freq) { - case 11025: - case 12000: - case 22050: - case 24000: - case 32000: - case 44100: - case 48000: - this->spec.freq = this->spec.freq; - break; - default: - this->spec.freq = 48000; - break; + case 11025: + case 12000: + case 22050: + case 24000: + case 32000: + case 44100: + case 48000: + this->spec.freq = this->spec.freq; + break; + default: + this->spec.freq = 48000; + break; } this->spec.samples = 512; @@ -71,8 +69,8 @@ PS2AUDIO_OpenDevice(_THIS, const char *devname) SDL_CalculateAudioSpec(&this->spec); - format.bits = this->spec.format == AUDIO_S8 ? 8 : 16; - format.freq = this->spec.freq; + format.bits = this->spec.format == AUDIO_S8 ? 8 : 16; + format.freq = this->spec.freq; format.channels = this->spec.channels; this->hidden->channel = audsrv_set_format(&format); @@ -91,7 +89,7 @@ PS2AUDIO_OpenDevice(_THIS, const char *devname) be a multiple of 64 bytes. Our sample count is already a multiple of 64, so spec->size should be a multiple of 64 as well. */ mixlen = this->spec.size * NUM_BUFFERS; - this->hidden->rawbuf = (Uint8 *) memalign(64, mixlen); + this->hidden->rawbuf = (Uint8 *)memalign(64, mixlen); if (this->hidden->rawbuf == NULL) { return SDL_SetError("Couldn't allocate mixing buffer"); } @@ -154,7 +152,7 @@ static void PS2AUDIO_Deinitialize(void) deinit_audio_driver(); } -static SDL_bool PS2AUDIO_Init(SDL_AudioDriverImpl * impl) +static SDL_bool PS2AUDIO_Init(SDL_AudioDriverImpl *impl) { if (init_audio_driver() < 0) { return SDL_FALSE; @@ -169,7 +167,7 @@ static SDL_bool PS2AUDIO_Init(SDL_AudioDriverImpl * impl) impl->ThreadInit = PS2AUDIO_ThreadInit; impl->Deinitialize = PS2AUDIO_Deinitialize; impl->OnlyHasDefaultOutputDevice = SDL_TRUE; - return SDL_TRUE; /* this audio target is available. */ + return SDL_TRUE; /* this audio target is available. */ } AudioBootStrap PS2AUDIO_bootstrap = { diff --git a/src/audio/ps2/SDL_ps2audio.h b/src/audio/ps2/SDL_ps2audio.h index 0de2506c2..0c072c9c2 100644 --- a/src/audio/ps2/SDL_ps2audio.h +++ b/src/audio/ps2/SDL_ps2audio.h @@ -26,20 +26,20 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this #define NUM_BUFFERS 2 struct SDL_PrivateAudioData { - /* The hardware output channel. */ - int channel; - /* The raw allocated mixing buffer. */ - Uint8 *rawbuf; - /* Individual mixing buffers. */ - Uint8 *mixbufs[NUM_BUFFERS]; - /* Index of the next available mixing buffer. */ - int next_buffer; + /* The hardware output channel. */ + int channel; + /* The raw allocated mixing buffer. */ + Uint8 *rawbuf; + /* Individual mixing buffers. */ + Uint8 *mixbufs[NUM_BUFFERS]; + /* Index of the next available mixing buffer. */ + int next_buffer; }; #endif /* SDL_ps2audio_h_ */ diff --git a/src/audio/psp/SDL_pspaudio.c b/src/audio/psp/SDL_pspaudio.c index 077b001b6..43f7f4a32 100644 --- a/src/audio/psp/SDL_pspaudio.c +++ b/src/audio/psp/SDL_pspaudio.c @@ -39,10 +39,9 @@ #include /* The tag name used by PSP audio */ -#define PSPAUDIO_DRIVER_NAME "psp" +#define PSPAUDIO_DRIVER_NAME "psp" -static int -PSPAUDIO_OpenDevice(_THIS, const char *devname) +static int PSPAUDIO_OpenDevice(_THIS, const char *devname) { int format, mixlen, i; @@ -64,7 +63,7 @@ PSPAUDIO_OpenDevice(_THIS, const char *devname) format = PSP_AUDIO_FORMAT_MONO; } else { format = PSP_AUDIO_FORMAT_STEREO; - this->spec.channels = 2; /* we're forcing the hardware to stereo. */ + this->spec.channels = 2; /* we're forcing the hardware to stereo. */ } /* PSP has some limitations with the Audio. It fully supports 44.1KHz (Mono & Stereo), @@ -75,7 +74,7 @@ PSPAUDIO_OpenDevice(_THIS, const char *devname) } else { this->hidden->channel = sceAudioSRCChReserve(this->spec.samples, this->spec.freq, 2); } - + if (this->hidden->channel < 0) { free(this->hidden->rawbuf); this->hidden->rawbuf = NULL; @@ -89,7 +88,7 @@ PSPAUDIO_OpenDevice(_THIS, const char *devname) be a multiple of 64 bytes. Our sample count is already a multiple of 64, so spec->size should be a multiple of 64 as well. */ mixlen = this->spec.size * NUM_BUFFERS; - this->hidden->rawbuf = (Uint8 *) memalign(64, mixlen); + this->hidden->rawbuf = (Uint8 *)memalign(64, mixlen); if (this->hidden->rawbuf == NULL) { return SDL_SetError("Couldn't allocate mixing buffer"); } @@ -158,8 +157,7 @@ static void PSPAUDIO_ThreadInit(_THIS) } } -static SDL_bool -PSPAUDIO_Init(SDL_AudioDriverImpl * impl) +static SDL_bool PSPAUDIO_Init(SDL_AudioDriverImpl *impl) { /* Set the function pointers */ impl->OpenDevice = PSPAUDIO_OpenDevice; @@ -175,7 +173,7 @@ PSPAUDIO_Init(SDL_AudioDriverImpl * impl) impl->HasCaptureSupport = SDL_TRUE; impl->OnlyHasDefaultCaptureDevice = SDL_TRUE; */ - return SDL_TRUE; /* this audio target is available. */ + return SDL_TRUE; /* this audio target is available. */ } AudioBootStrap PSPAUDIO_bootstrap = { diff --git a/src/audio/psp/SDL_pspaudio.h b/src/audio/psp/SDL_pspaudio.h index 0e1af2cda..70a40abdb 100644 --- a/src/audio/psp/SDL_pspaudio.h +++ b/src/audio/psp/SDL_pspaudio.h @@ -25,19 +25,20 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this #define NUM_BUFFERS 2 -struct SDL_PrivateAudioData { +struct SDL_PrivateAudioData +{ /* The hardware output channel. */ - int channel; + int channel; /* The raw allocated mixing buffer. */ - Uint8 *rawbuf; + Uint8 *rawbuf; /* Individual mixing buffers. */ - Uint8 *mixbufs[NUM_BUFFERS]; + Uint8 *mixbufs[NUM_BUFFERS]; /* Index of the next available mixing buffer. */ - int next_buffer; + int next_buffer; }; #endif /* SDL_pspaudio_h_ */ diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c index a6360dad9..28bb2978b 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/src/audio/pulseaudio/SDL_pulseaudio.c @@ -49,81 +49,79 @@ /* should we include monitors in the device list? Set at SDL_Init time */ static SDL_bool include_monitors = SDL_FALSE; - #if (PA_API_VERSION < 12) /** Return non-zero if the passed state is one of the connected states */ -static SDL_INLINE int PA_CONTEXT_IS_GOOD(pa_context_state_t x) { +static SDL_INLINE int PA_CONTEXT_IS_GOOD(pa_context_state_t x) +{ return x == PA_CONTEXT_CONNECTING || x == PA_CONTEXT_AUTHORIZING || x == PA_CONTEXT_SETTING_NAME || x == PA_CONTEXT_READY; } /** Return non-zero if the passed state is one of the connected states */ -static SDL_INLINE int PA_STREAM_IS_GOOD(pa_stream_state_t x) { +static SDL_INLINE int PA_STREAM_IS_GOOD(pa_stream_state_t x) +{ return x == PA_STREAM_CREATING || x == PA_STREAM_READY; } #endif /* pulseaudio <= 0.9.10 */ - -static const char *(*PULSEAUDIO_pa_get_library_version) (void); -static pa_channel_map *(*PULSEAUDIO_pa_channel_map_init_auto) ( +static const char *(*PULSEAUDIO_pa_get_library_version)(void); +static pa_channel_map *(*PULSEAUDIO_pa_channel_map_init_auto)( pa_channel_map *, unsigned, pa_channel_map_def_t); -static const char * (*PULSEAUDIO_pa_strerror) (int); -static pa_mainloop * (*PULSEAUDIO_pa_mainloop_new) (void); -static pa_mainloop_api * (*PULSEAUDIO_pa_mainloop_get_api) (pa_mainloop *); -static int (*PULSEAUDIO_pa_mainloop_iterate) (pa_mainloop *, int, int *); -static int (*PULSEAUDIO_pa_mainloop_run) (pa_mainloop *, int *); -static void (*PULSEAUDIO_pa_mainloop_quit) (pa_mainloop *, int); -static void (*PULSEAUDIO_pa_mainloop_free) (pa_mainloop *); +static const char *(*PULSEAUDIO_pa_strerror)(int); +static pa_mainloop *(*PULSEAUDIO_pa_mainloop_new)(void); +static pa_mainloop_api *(*PULSEAUDIO_pa_mainloop_get_api)(pa_mainloop *); +static int (*PULSEAUDIO_pa_mainloop_iterate)(pa_mainloop *, int, int *); +static int (*PULSEAUDIO_pa_mainloop_run)(pa_mainloop *, int *); +static void (*PULSEAUDIO_pa_mainloop_quit)(pa_mainloop *, int); +static void (*PULSEAUDIO_pa_mainloop_free)(pa_mainloop *); -static pa_operation_state_t (*PULSEAUDIO_pa_operation_get_state) ( +static pa_operation_state_t (*PULSEAUDIO_pa_operation_get_state)( const pa_operation *); -static void (*PULSEAUDIO_pa_operation_cancel) (pa_operation *); -static void (*PULSEAUDIO_pa_operation_unref) (pa_operation *); +static void (*PULSEAUDIO_pa_operation_cancel)(pa_operation *); +static void (*PULSEAUDIO_pa_operation_unref)(pa_operation *); -static pa_context * (*PULSEAUDIO_pa_context_new) (pa_mainloop_api *, - const char *); -static int (*PULSEAUDIO_pa_context_connect) (pa_context *, const char *, - pa_context_flags_t, const pa_spawn_api *); -static pa_operation * (*PULSEAUDIO_pa_context_get_sink_info_list) (pa_context *, pa_sink_info_cb_t, void *); -static pa_operation * (*PULSEAUDIO_pa_context_get_source_info_list) (pa_context *, pa_source_info_cb_t, void *); -static pa_operation * (*PULSEAUDIO_pa_context_get_sink_info_by_index) (pa_context *, uint32_t, pa_sink_info_cb_t, void *); -static pa_operation * (*PULSEAUDIO_pa_context_get_source_info_by_index) (pa_context *, uint32_t, pa_source_info_cb_t, void *); -static pa_context_state_t (*PULSEAUDIO_pa_context_get_state) (const pa_context *); -static pa_operation * (*PULSEAUDIO_pa_context_subscribe) (pa_context *, pa_subscription_mask_t, pa_context_success_cb_t, void *); -static void (*PULSEAUDIO_pa_context_set_subscribe_callback) (pa_context *, pa_context_subscribe_cb_t, void *); -static void (*PULSEAUDIO_pa_context_disconnect) (pa_context *); -static void (*PULSEAUDIO_pa_context_unref) (pa_context *); +static pa_context *(*PULSEAUDIO_pa_context_new)(pa_mainloop_api *, + const char *); +static int (*PULSEAUDIO_pa_context_connect)(pa_context *, const char *, + pa_context_flags_t, const pa_spawn_api *); +static pa_operation *(*PULSEAUDIO_pa_context_get_sink_info_list)(pa_context *, pa_sink_info_cb_t, void *); +static pa_operation *(*PULSEAUDIO_pa_context_get_source_info_list)(pa_context *, pa_source_info_cb_t, void *); +static pa_operation *(*PULSEAUDIO_pa_context_get_sink_info_by_index)(pa_context *, uint32_t, pa_sink_info_cb_t, void *); +static pa_operation *(*PULSEAUDIO_pa_context_get_source_info_by_index)(pa_context *, uint32_t, pa_source_info_cb_t, void *); +static pa_context_state_t (*PULSEAUDIO_pa_context_get_state)(const pa_context *); +static pa_operation *(*PULSEAUDIO_pa_context_subscribe)(pa_context *, pa_subscription_mask_t, pa_context_success_cb_t, void *); +static void (*PULSEAUDIO_pa_context_set_subscribe_callback)(pa_context *, pa_context_subscribe_cb_t, void *); +static void (*PULSEAUDIO_pa_context_disconnect)(pa_context *); +static void (*PULSEAUDIO_pa_context_unref)(pa_context *); -static pa_stream * (*PULSEAUDIO_pa_stream_new) (pa_context *, const char *, - const pa_sample_spec *, const pa_channel_map *); -static int (*PULSEAUDIO_pa_stream_connect_playback) (pa_stream *, const char *, - const pa_buffer_attr *, pa_stream_flags_t, const pa_cvolume *, pa_stream *); -static int (*PULSEAUDIO_pa_stream_connect_record) (pa_stream *, const char *, - const pa_buffer_attr *, pa_stream_flags_t); -static pa_stream_state_t (*PULSEAUDIO_pa_stream_get_state) (const pa_stream *); -static size_t (*PULSEAUDIO_pa_stream_writable_size) (const pa_stream *); -static size_t (*PULSEAUDIO_pa_stream_readable_size) (const pa_stream *); -static int (*PULSEAUDIO_pa_stream_write) (pa_stream *, const void *, size_t, - pa_free_cb_t, int64_t, pa_seek_mode_t); -static pa_operation * (*PULSEAUDIO_pa_stream_drain) (pa_stream *, - pa_stream_success_cb_t, void *); -static int (*PULSEAUDIO_pa_stream_peek) (pa_stream *, const void **, size_t *); -static int (*PULSEAUDIO_pa_stream_drop) (pa_stream *); -static pa_operation * (*PULSEAUDIO_pa_stream_flush) (pa_stream *, - pa_stream_success_cb_t, void *); -static int (*PULSEAUDIO_pa_stream_disconnect) (pa_stream *); -static void (*PULSEAUDIO_pa_stream_unref) (pa_stream *); +static pa_stream *(*PULSEAUDIO_pa_stream_new)(pa_context *, const char *, + const pa_sample_spec *, const pa_channel_map *); +static int (*PULSEAUDIO_pa_stream_connect_playback)(pa_stream *, const char *, + const pa_buffer_attr *, pa_stream_flags_t, const pa_cvolume *, pa_stream *); +static int (*PULSEAUDIO_pa_stream_connect_record)(pa_stream *, const char *, + const pa_buffer_attr *, pa_stream_flags_t); +static pa_stream_state_t (*PULSEAUDIO_pa_stream_get_state)(const pa_stream *); +static size_t (*PULSEAUDIO_pa_stream_writable_size)(const pa_stream *); +static size_t (*PULSEAUDIO_pa_stream_readable_size)(const pa_stream *); +static int (*PULSEAUDIO_pa_stream_write)(pa_stream *, const void *, size_t, + pa_free_cb_t, int64_t, pa_seek_mode_t); +static pa_operation *(*PULSEAUDIO_pa_stream_drain)(pa_stream *, + pa_stream_success_cb_t, void *); +static int (*PULSEAUDIO_pa_stream_peek)(pa_stream *, const void **, size_t *); +static int (*PULSEAUDIO_pa_stream_drop)(pa_stream *); +static pa_operation *(*PULSEAUDIO_pa_stream_flush)(pa_stream *, + pa_stream_success_cb_t, void *); +static int (*PULSEAUDIO_pa_stream_disconnect)(pa_stream *); +static void (*PULSEAUDIO_pa_stream_unref)(pa_stream *); static void (*PULSEAUDIO_pa_stream_set_write_callback)(pa_stream *, pa_stream_request_cb_t, void *); -static pa_operation * (*PULSEAUDIO_pa_context_get_server_info)(pa_context *, pa_server_info_cb_t, void *); +static pa_operation *(*PULSEAUDIO_pa_context_get_server_info)(pa_context *, pa_server_info_cb_t, void *); static int load_pulseaudio_syms(void); - #ifdef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC static const char *pulseaudio_library = SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC; static void *pulseaudio_handle = NULL; -static int -load_pulseaudio_sym(const char *fn, void **addr) +static int load_pulseaudio_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(pulseaudio_handle, fn); if (*addr == NULL) { @@ -135,11 +133,11 @@ load_pulseaudio_sym(const char *fn, void **addr) } /* cast funcs to char* first, to please GCC's strict aliasing rules. */ -#define SDL_PULSEAUDIO_SYM(x) \ - if (!load_pulseaudio_sym(#x, (void **) (char *) &PULSEAUDIO_##x)) return -1 +#define SDL_PULSEAUDIO_SYM(x) \ + if (!load_pulseaudio_sym(#x, (void **)(char *)&PULSEAUDIO_##x)) \ + return -1 -static void -UnloadPulseAudioLibrary(void) +static void UnloadPulseAudioLibrary(void) { if (pulseaudio_handle != NULL) { SDL_UnloadObject(pulseaudio_handle); @@ -147,8 +145,7 @@ UnloadPulseAudioLibrary(void) } } -static int -LoadPulseAudioLibrary(void) +static int LoadPulseAudioLibrary(void) { int retval = 0; if (pulseaudio_handle == NULL) { @@ -170,13 +167,11 @@ LoadPulseAudioLibrary(void) #define SDL_PULSEAUDIO_SYM(x) PULSEAUDIO_##x = x -static void -UnloadPulseAudioLibrary(void) +static void UnloadPulseAudioLibrary(void) { } -static int -LoadPulseAudioLibrary(void) +static int LoadPulseAudioLibrary(void) { load_pulseaudio_syms(); return 0; @@ -184,9 +179,7 @@ LoadPulseAudioLibrary(void) #endif /* SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC */ - -static int -load_pulseaudio_syms(void) +static int load_pulseaudio_syms(void) { SDL_PULSEAUDIO_SYM(pa_get_library_version); SDL_PULSEAUDIO_SYM(pa_mainloop_new); @@ -229,15 +222,13 @@ load_pulseaudio_syms(void) return 0; } -static SDL_INLINE int -squashVersion(const int major, const int minor, const int patch) +static SDL_INLINE int squashVersion(const int major, const int minor, const int patch) { return ((major & 0xFF) << 16) | ((minor & 0xFF) << 8) | (patch & 0xFF); } /* Workaround for older pulse: pa_context_new() must have non-NULL appname */ -static const char * -getAppName(void) +static const char *getAppName(void) { const char *retval = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_APP_NAME); if (retval && *retval) { @@ -248,12 +239,12 @@ getAppName(void) return retval; } else { const char *verstr = PULSEAUDIO_pa_get_library_version(); - retval = "SDL Application"; /* the "oh well" default. */ + retval = "SDL Application"; /* the "oh well" default. */ if (verstr != NULL) { int maj, min, patch; if (SDL_sscanf(verstr, "%d.%d.%d", &maj, &min, &patch) == 3) { if (squashVersion(maj, min, patch) >= squashVersion(0, 9, 15)) { - retval = NULL; /* 0.9.15+ handles NULL correctly. */ + retval = NULL; /* 0.9.15+ handles NULL correctly. */ } } } @@ -261,8 +252,7 @@ getAppName(void) return retval; } -static void -WaitForPulseOperation(pa_mainloop *mainloop, pa_operation *o) +static void WaitForPulseOperation(pa_mainloop *mainloop, pa_operation *o) { /* This checks for NO errors currently. Either fix that, check results elsewhere, or do things you don't care about. */ if (mainloop && o) { @@ -274,8 +264,7 @@ WaitForPulseOperation(pa_mainloop *mainloop, pa_operation *o) } } -static void -DisconnectFromPulseServer(pa_mainloop *mainloop, pa_context *context) +static void DisconnectFromPulseServer(pa_mainloop *mainloop, pa_context *context) { if (context) { PULSEAUDIO_pa_context_disconnect(context); @@ -286,8 +275,7 @@ DisconnectFromPulseServer(pa_mainloop *mainloop, pa_context *context) } } -static int -ConnectToPulseServer_Internal(pa_mainloop **_mainloop, pa_context **_context) +static int ConnectToPulseServer_Internal(pa_mainloop **_mainloop, pa_context **_context) { pa_mainloop *mainloop = NULL; pa_context *context = NULL; @@ -303,7 +291,7 @@ ConnectToPulseServer_Internal(pa_mainloop **_mainloop, pa_context **_context) } mainloop_api = PULSEAUDIO_pa_mainloop_get_api(mainloop); - SDL_assert(mainloop_api); /* this never fails, right? */ + SDL_assert(mainloop_api); /* this never fails, right? */ context = PULSEAUDIO_pa_context_new(mainloop_api, getAppName()); if (context == NULL) { @@ -335,11 +323,10 @@ ConnectToPulseServer_Internal(pa_mainloop **_mainloop, pa_context **_context) *_context = context; *_mainloop = mainloop; - return 0; /* connected and ready! */ + return 0; /* connected and ready! */ } -static int -ConnectToPulseServer(pa_mainloop **_mainloop, pa_context **_context) +static int ConnectToPulseServer(pa_mainloop **_mainloop, pa_context **_context) { const int retval = ConnectToPulseServer_Internal(_mainloop, _context); if (retval < 0) { @@ -348,23 +335,20 @@ ConnectToPulseServer(pa_mainloop **_mainloop, pa_context **_context) return retval; } - /* This function waits until it is possible to write a full sound buffer */ -static void -PULSEAUDIO_WaitDevice(_THIS) +static void PULSEAUDIO_WaitDevice(_THIS) { /* this is a no-op; we wait in PULSEAUDIO_PlayDevice now. */ } static void WriteCallback(pa_stream *p, size_t nbytes, void *userdata) { - struct SDL_PrivateAudioData *h = (struct SDL_PrivateAudioData *) userdata; + struct SDL_PrivateAudioData *h = (struct SDL_PrivateAudioData *)userdata; /*printf("PULSEAUDIO WRITE CALLBACK! nbytes=%u\n", (unsigned int) nbytes);*/ h->bytes_requested += nbytes; } -static void -PULSEAUDIO_PlayDevice(_THIS) +static void PULSEAUDIO_PlayDevice(_THIS) { struct SDL_PrivateAudioData *h = this->hidden; int available = h->mixlen; @@ -399,15 +383,12 @@ PULSEAUDIO_PlayDevice(_THIS) /*printf("PULSEAUDIO PLAYDEVICE END! written=%d\n", written);*/ } -static Uint8 * -PULSEAUDIO_GetDeviceBuf(_THIS) +static Uint8 *PULSEAUDIO_GetDeviceBuf(_THIS) { return this->hidden->mixbuf; } - -static int -PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) +static int PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) { struct SDL_PrivateAudioData *h = this->hidden; const void *data = NULL; @@ -422,40 +403,40 @@ PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) h->capturelen -= cpy; if (h->capturelen == 0) { h->capturebuf = NULL; - PULSEAUDIO_pa_stream_drop(h->stream); /* done with this fragment. */ + PULSEAUDIO_pa_stream_drop(h->stream); /* done with this fragment. */ } - return cpy; /* new data, return it. */ + return cpy; /* new data, return it. */ } if (PULSEAUDIO_pa_context_get_state(h->context) != PA_CONTEXT_READY || PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY || PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) { SDL_OpenedAudioDeviceDisconnected(this); - return -1; /* uhoh, pulse failed! */ + return -1; /* uhoh, pulse failed! */ } if (PULSEAUDIO_pa_stream_readable_size(h->stream) == 0) { - continue; /* no data available yet. */ + continue; /* no data available yet. */ } /* a new fragment is available! */ PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes); SDL_assert(nbytes > 0); - if (data == NULL) { /* NULL==buffer had a hole. Ignore that. */ - PULSEAUDIO_pa_stream_drop(h->stream); /* drop this fragment. */ + /* If data == NULL, then the buffer had a hole, ignore that */ + if (data == NULL) { + PULSEAUDIO_pa_stream_drop(h->stream); /* drop this fragment. */ } else { /* store this fragment's data, start feeding it to SDL. */ /*printf("PULSEAUDIO: captured %d new bytes\n", (int) nbytes);*/ - h->capturebuf = (const Uint8 *) data; + h->capturebuf = (const Uint8 *)data; h->capturelen = nbytes; } } - return -1; /* not enabled? */ + return -1; /* not enabled? */ } -static void -PULSEAUDIO_FlushCapture(_THIS) +static void PULSEAUDIO_FlushCapture(_THIS) { struct SDL_PrivateAudioData *h = this->hidden; const void *data = NULL; @@ -472,21 +453,20 @@ PULSEAUDIO_FlushCapture(_THIS) PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY || PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) { SDL_OpenedAudioDeviceDisconnected(this); - return; /* uhoh, pulse failed! */ + return; /* uhoh, pulse failed! */ } if (PULSEAUDIO_pa_stream_readable_size(h->stream) == 0) { - break; /* no data available, so we're done. */ + break; /* no data available, so we're done. */ } /* a new fragment is available! Just dump it. */ PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes); - PULSEAUDIO_pa_stream_drop(h->stream); /* drop this fragment. */ + PULSEAUDIO_pa_stream_drop(h->stream); /* drop this fragment. */ } } -static void -PULSEAUDIO_CloseDevice(_THIS) +static void PULSEAUDIO_CloseDevice(_THIS) { if (this->hidden->stream) { if (this->hidden->capturebuf != NULL) { @@ -502,48 +482,44 @@ PULSEAUDIO_CloseDevice(_THIS) SDL_free(this->hidden); } -static void -SinkDeviceNameCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data) +static void SinkDeviceNameCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data) { if (i) { - char **devname = (char **) data; + char **devname = (char **)data; *devname = SDL_strdup(i->name); } } -static void -SourceDeviceNameCallback(pa_context *c, const pa_source_info *i, int is_last, void *data) +static void SourceDeviceNameCallback(pa_context *c, const pa_source_info *i, int is_last, void *data) { if (i) { - char **devname = (char **) data; + char **devname = (char **)data; *devname = SDL_strdup(i->name); } } -static SDL_bool -FindDeviceName(struct SDL_PrivateAudioData *h, const SDL_bool iscapture, void *handle) +static SDL_bool FindDeviceName(struct SDL_PrivateAudioData *h, const SDL_bool iscapture, void *handle) { - const uint32_t idx = ((uint32_t) ((intptr_t) handle)) - 1; + const uint32_t idx = ((uint32_t)((intptr_t)handle)) - 1; - if (handle == NULL) { /* NULL == default device. */ + if (handle == NULL) { /* NULL == default device. */ return SDL_TRUE; } if (iscapture) { WaitForPulseOperation(h->mainloop, - PULSEAUDIO_pa_context_get_source_info_by_index(h->context, idx, - SourceDeviceNameCallback, &h->device_name)); + PULSEAUDIO_pa_context_get_source_info_by_index(h->context, idx, + SourceDeviceNameCallback, &h->device_name)); } else { WaitForPulseOperation(h->mainloop, - PULSEAUDIO_pa_context_get_sink_info_by_index(h->context, idx, - SinkDeviceNameCallback, &h->device_name)); + PULSEAUDIO_pa_context_get_sink_info_by_index(h->context, idx, + SinkDeviceNameCallback, &h->device_name)); } return h->device_name != NULL; } -static int -PULSEAUDIO_OpenDevice(_THIS, const char *devname) +static int PULSEAUDIO_OpenDevice(_THIS, const char *devname) { struct SDL_PrivateAudioData *h = NULL; SDL_AudioFormat test_format; @@ -608,7 +584,7 @@ PULSEAUDIO_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ if (!iscapture) { h->mixlen = this->spec.size; - h->mixbuf = (Uint8 *) SDL_malloc(h->mixlen); + h->mixbuf = (Uint8 *)SDL_malloc(h->mixlen); if (h->mixbuf == NULL) { return SDL_OutOfMemory(); } @@ -644,9 +620,9 @@ PULSEAUDIO_OpenDevice(_THIS, const char *devname) h->stream = PULSEAUDIO_pa_stream_new( h->context, (name && *name) ? name : "Audio Stream", /* stream description */ - &paspec, /* sample format spec */ - &pacmap /* channel map */ - ); + &paspec, /* sample format spec */ + &pacmap /* channel map */ + ); if (h->stream == NULL) { return SDL_SetError("Could not set up PulseAudio stream"); @@ -696,8 +672,7 @@ static char *default_source_name = NULL; /* device handles are device index + 1, cast to void*, so we never pass a NULL. */ -static SDL_AudioFormat -PulseFormatToSDLFormat(pa_sample_format_t format) +static SDL_AudioFormat PulseFormatToSDLFormat(pa_sample_format_t format) { switch (format) { case PA_SAMPLE_U8: @@ -720,11 +695,10 @@ PulseFormatToSDLFormat(pa_sample_format_t format) } /* This is called when PulseAudio adds an output ("sink") device. */ -static void -SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data) +static void SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data) { SDL_AudioSpec spec; - SDL_bool add = (SDL_bool) ((intptr_t) data); + SDL_bool add = (SDL_bool)((intptr_t)data); if (i) { spec.freq = i->sample_spec.rate; spec.channels = i->sample_spec.channels; @@ -736,7 +710,7 @@ SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data) spec.userdata = NULL; if (add) { - SDL_AddAudioDevice(SDL_FALSE, i->description, &spec, (void *) ((intptr_t) i->index+1)); + SDL_AddAudioDevice(SDL_FALSE, i->description, &spec, (void *)((intptr_t)i->index + 1)); } if (default_sink_path != NULL && SDL_strcmp(i->name, default_sink_path) == 0) { @@ -749,11 +723,10 @@ SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data) } /* This is called when PulseAudio adds a capture ("source") device. */ -static void -SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_last, void *data) +static void SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_last, void *data) { SDL_AudioSpec spec; - SDL_bool add = (SDL_bool) ((intptr_t) data); + SDL_bool add = (SDL_bool)((intptr_t)data); if (i) { /* Maybe skip "monitor" sources. These are just output from other sinks. */ if (include_monitors || (i->monitor_of_sink == PA_INVALID_INDEX)) { @@ -767,7 +740,7 @@ SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_last, void *da spec.userdata = NULL; if (add) { - SDL_AddAudioDevice(SDL_TRUE, i->description, &spec, (void *) ((intptr_t) i->index+1)); + SDL_AddAudioDevice(SDL_TRUE, i->description, &spec, (void *)((intptr_t)i->index + 1)); } if (default_source_path != NULL && SDL_strcmp(i->name, default_source_path) == 0) { @@ -780,8 +753,7 @@ SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_last, void *da } } -static void -ServerInfoCallback(pa_context *c, const pa_server_info *i, void *data) +static void ServerInfoCallback(pa_context *c, const pa_server_info *i, void *data) { if (default_sink_path != NULL) { SDL_free(default_sink_path); @@ -794,14 +766,13 @@ ServerInfoCallback(pa_context *c, const pa_server_info *i, void *data) } /* This is called when PulseAudio has a device connected/removed/changed. */ -static void -HotplugCallback(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *data) +static void HotplugCallback(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *data) { const SDL_bool added = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW); const SDL_bool removed = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE); const SDL_bool changed = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_CHANGE); - if (added || removed || changed) { /* we only care about add/remove events. */ + if (added || removed || changed) { /* we only care about add/remove events. */ const SDL_bool sink = ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK); const SDL_bool source = ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SOURCE); @@ -810,45 +781,42 @@ HotplugCallback(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, voi if (changed) { PULSEAUDIO_pa_context_get_server_info(hotplug_context, ServerInfoCallback, NULL); } - PULSEAUDIO_pa_context_get_sink_info_by_index(hotplug_context, idx, SinkInfoCallback, (void*) ((intptr_t) added)); + PULSEAUDIO_pa_context_get_sink_info_by_index(hotplug_context, idx, SinkInfoCallback, (void *)((intptr_t)added)); } else if ((added || changed) && source) { if (changed) { PULSEAUDIO_pa_context_get_server_info(hotplug_context, ServerInfoCallback, NULL); } - PULSEAUDIO_pa_context_get_source_info_by_index(hotplug_context, idx, SourceInfoCallback, (void*) ((intptr_t) added)); + PULSEAUDIO_pa_context_get_source_info_by_index(hotplug_context, idx, SourceInfoCallback, (void *)((intptr_t)added)); } else if (removed && (sink || source)) { /* removes we can handle just with the device index. */ - SDL_RemoveAudioDevice(source != 0, (void *) ((intptr_t) idx+1)); + SDL_RemoveAudioDevice(source != 0, (void *)((intptr_t)idx + 1)); } } } /* this runs as a thread while the Pulse target is initialized to catch hotplug events. */ -static int SDLCALL -HotplugThread(void *data) +static int SDLCALL HotplugThread(void *data) { pa_operation *o; SDL_SetThreadPriority(SDL_THREAD_PRIORITY_LOW); PULSEAUDIO_pa_context_set_subscribe_callback(hotplug_context, HotplugCallback, NULL); o = PULSEAUDIO_pa_context_subscribe(hotplug_context, PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE, NULL, NULL); - PULSEAUDIO_pa_operation_unref(o); /* don't wait for it, just do our thing. */ + PULSEAUDIO_pa_operation_unref(o); /* don't wait for it, just do our thing. */ PULSEAUDIO_pa_mainloop_run(hotplug_mainloop, NULL); return 0; } -static void -PULSEAUDIO_DetectDevices() +static void PULSEAUDIO_DetectDevices() { WaitForPulseOperation(hotplug_mainloop, PULSEAUDIO_pa_context_get_server_info(hotplug_context, ServerInfoCallback, NULL)); - WaitForPulseOperation(hotplug_mainloop, PULSEAUDIO_pa_context_get_sink_info_list(hotplug_context, SinkInfoCallback, (void*) ((intptr_t) SDL_TRUE))); - WaitForPulseOperation(hotplug_mainloop, PULSEAUDIO_pa_context_get_source_info_list(hotplug_context, SourceInfoCallback, (void*) ((intptr_t) SDL_TRUE))); + WaitForPulseOperation(hotplug_mainloop, PULSEAUDIO_pa_context_get_sink_info_list(hotplug_context, SinkInfoCallback, (void *)((intptr_t)SDL_TRUE))); + WaitForPulseOperation(hotplug_mainloop, PULSEAUDIO_pa_context_get_source_info_list(hotplug_context, SourceInfoCallback, (void *)((intptr_t)SDL_TRUE))); /* ok, we have a sane list, let's set up hotplug notifications now... */ hotplug_thread = SDL_CreateThreadInternal(HotplugThread, "PulseHotplug", 256 * 1024, NULL); } -static int -PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) +static int PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) { int i; int numdevices; @@ -879,8 +847,7 @@ PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) return SDL_SetError("Could not find default PulseAudio device"); } -static void -PULSEAUDIO_Deinitialize(void) +static void PULSEAUDIO_Deinitialize(void) { if (hotplug_thread) { PULSEAUDIO_pa_mainloop_quit(hotplug_mainloop, 0); @@ -912,8 +879,7 @@ PULSEAUDIO_Deinitialize(void) UnloadPulseAudioLibrary(); } -static SDL_bool -PULSEAUDIO_Init(SDL_AudioDriverImpl * impl) +static SDL_bool PULSEAUDIO_Init(SDL_AudioDriverImpl *impl) { if (LoadPulseAudioLibrary() < 0) { return SDL_FALSE; @@ -941,7 +907,7 @@ PULSEAUDIO_Init(SDL_AudioDriverImpl * impl) impl->HasCaptureSupport = SDL_TRUE; impl->SupportsNonPow2Samples = SDL_TRUE; - return SDL_TRUE; /* this audio target is available. */ + return SDL_TRUE; /* this audio target is available. */ } AudioBootStrap PULSEAUDIO_bootstrap = { diff --git a/src/audio/pulseaudio/SDL_pulseaudio.h b/src/audio/pulseaudio/SDL_pulseaudio.h index 7ef45fe25..b9ac75984 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.h +++ b/src/audio/pulseaudio/SDL_pulseaudio.h @@ -43,7 +43,7 @@ struct SDL_PrivateAudioData Uint8 *mixbuf; int mixlen; - int bytes_requested; /* bytes of data the hardware wants _now_. */ + int bytes_requested; /* bytes of data the hardware wants _now_. */ const Uint8 *capturebuf; int capturelen; diff --git a/src/audio/sndio/SDL_sndioaudio.c b/src/audio/sndio/SDL_sndioaudio.c index 29e5315b9..e0c7b8785 100644 --- a/src/audio/sndio/SDL_sndioaudio.c +++ b/src/audio/sndio/SDL_sndioaudio.c @@ -52,7 +52,7 @@ #define SIO_DEVANY "default" #endif -static struct sio_hdl * (*SNDIO_sio_open)(const char *, unsigned int, int); +static struct sio_hdl *(*SNDIO_sio_open)(const char *, unsigned int, int); static void (*SNDIO_sio_close)(struct sio_hdl *); static int (*SNDIO_sio_setpar)(struct sio_hdl *, struct sio_par *); static int (*SNDIO_sio_getpar)(struct sio_hdl *, struct sio_par *); @@ -70,8 +70,7 @@ static void (*SNDIO_sio_initpar)(struct sio_par *); static const char *sndio_library = SDL_AUDIO_DRIVER_SNDIO_DYNAMIC; static void *sndio_handle = NULL; -static int -load_sndio_sym(const char *fn, void **addr) +static int load_sndio_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(sndio_handle, fn); if (*addr == NULL) { @@ -83,14 +82,14 @@ load_sndio_sym(const char *fn, void **addr) } /* cast funcs to char* first, to please GCC's strict aliasing rules. */ -#define SDL_SNDIO_SYM(x) \ - if (!load_sndio_sym(#x, (void **) (char *) &SNDIO_##x)) return -1 +#define SDL_SNDIO_SYM(x) \ + if (!load_sndio_sym(#x, (void **)(char *)&SNDIO_##x)) \ + return -1 #else #define SDL_SNDIO_SYM(x) SNDIO_##x = x #endif -static int -load_sndio_syms(void) +static int load_sndio_syms(void) { SDL_SNDIO_SYM(sio_open); SDL_SNDIO_SYM(sio_close); @@ -112,8 +111,7 @@ load_sndio_syms(void) #ifdef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC -static void -UnloadSNDIOLibrary(void) +static void UnloadSNDIOLibrary(void) { if (sndio_handle != NULL) { SDL_UnloadObject(sndio_handle); @@ -121,8 +119,7 @@ UnloadSNDIOLibrary(void) } } -static int -LoadSNDIOLibrary(void) +static int LoadSNDIOLibrary(void) { int retval = 0; if (sndio_handle == NULL) { @@ -142,13 +139,11 @@ LoadSNDIOLibrary(void) #else -static void -UnloadSNDIOLibrary(void) +static void UnloadSNDIOLibrary(void) { } -static int -LoadSNDIOLibrary(void) +static int LoadSNDIOLibrary(void) { load_sndio_syms(); return 0; @@ -156,24 +151,19 @@ LoadSNDIOLibrary(void) #endif /* SDL_AUDIO_DRIVER_SNDIO_DYNAMIC */ - - - -static void -SNDIO_WaitDevice(_THIS) +static void SNDIO_WaitDevice(_THIS) { /* no-op; SNDIO_sio_write() blocks if necessary. */ } -static void -SNDIO_PlayDevice(_THIS) +static void SNDIO_PlayDevice(_THIS) { const int written = SNDIO_sio_write(this->hidden->dev, this->hidden->mixbuf, this->hidden->mixlen); /* If we couldn't write, assume fatal error for now */ - if ( written == 0 ) { + if (written == 0) { SDL_OpenedAudioDeviceDisconnected(this); } #ifdef DEBUG_AUDIO @@ -181,8 +171,7 @@ SNDIO_PlayDevice(_THIS) #endif } -static int -SNDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) +static int SNDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) { size_t r; int revents; @@ -191,8 +180,7 @@ SNDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) /* Emulate a blocking read */ r = SNDIO_sio_read(this->hidden->dev, buffer, buflen); while (r == 0 && !SNDIO_sio_eof(this->hidden->dev)) { - if ((nfds = SNDIO_sio_pollfd(this->hidden->dev, this->hidden->pfd, POLLIN)) <= 0 - || poll(this->hidden->pfd, nfds, INFTIM) < 0) { + if ((nfds = SNDIO_sio_pollfd(this->hidden->dev, this->hidden->pfd, POLLIN)) <= 0 || poll(this->hidden->pfd, nfds, INFTIM) < 0) { return -1; } revents = SNDIO_sio_revents(this->hidden->dev, this->hidden->pfd); @@ -203,11 +191,10 @@ SNDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) break; } } - return (int) r; + return (int)r; } -static void -SNDIO_FlushCapture(_THIS) +static void SNDIO_FlushCapture(_THIS) { char buf[512]; @@ -216,19 +203,17 @@ SNDIO_FlushCapture(_THIS) } } -static Uint8 * -SNDIO_GetDeviceBuf(_THIS) +static Uint8 *SNDIO_GetDeviceBuf(_THIS) { return this->hidden->mixbuf; } -static void -SNDIO_CloseDevice(_THIS) +static void SNDIO_CloseDevice(_THIS) { - if ( this->hidden->pfd != NULL ) { + if (this->hidden->pfd != NULL) { SDL_free(this->hidden->pfd); } - if ( this->hidden->dev != NULL ) { + if (this->hidden->dev != NULL) { SNDIO_sio_stop(this->hidden->dev); SNDIO_sio_close(this->hidden->dev); } @@ -236,8 +221,7 @@ SNDIO_CloseDevice(_THIS) SDL_free(this->hidden); } -static int -SNDIO_OpenDevice(_THIS, const char *devname) +static int SNDIO_OpenDevice(_THIS, const char *devname) { SDL_AudioFormat test_format; struct sio_par par; @@ -254,14 +238,14 @@ SNDIO_OpenDevice(_THIS, const char *devname) /* Capture devices must be non-blocking for SNDIO_FlushCapture */ if ((this->hidden->dev = - SNDIO_sio_open(devname != NULL ? devname : SIO_DEVANY, - iscapture ? SIO_REC : SIO_PLAY, iscapture)) == NULL) { + SNDIO_sio_open(devname != NULL ? devname : SIO_DEVANY, + iscapture ? SIO_REC : SIO_PLAY, iscapture)) == NULL) { return SDL_SetError("sio_open() failed"); } /* Allocate the pollfd array for capture devices */ if (iscapture && (this->hidden->pfd = - SDL_malloc(sizeof(struct pollfd) * SNDIO_sio_nfds(this->hidden->dev))) == NULL) { + SDL_malloc(sizeof(struct pollfd) * SNDIO_sio_nfds(this->hidden->dev))) == NULL) { return SDL_OutOfMemory(); } @@ -327,7 +311,7 @@ SNDIO_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; - this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); + this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen); if (this->hidden->mixbuf == NULL) { return SDL_OutOfMemory(); } @@ -341,21 +325,18 @@ SNDIO_OpenDevice(_THIS, const char *devname) return 0; } -static void -SNDIO_Deinitialize(void) +static void SNDIO_Deinitialize(void) { UnloadSNDIOLibrary(); } -static void -SNDIO_DetectDevices(void) +static void SNDIO_DetectDevices(void) { - SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, NULL, (void *) 0x1); - SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, NULL, (void *) 0x2); + SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, NULL, (void *)0x1); + SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, NULL, (void *)0x2); } -static SDL_bool -SNDIO_Init(SDL_AudioDriverImpl * impl) +static SDL_bool SNDIO_Init(SDL_AudioDriverImpl *impl) { if (LoadSNDIOLibrary() < 0) { return SDL_FALSE; @@ -375,7 +356,7 @@ SNDIO_Init(SDL_AudioDriverImpl * impl) impl->AllowsArbitraryDeviceNames = SDL_TRUE; impl->HasCaptureSupport = SDL_TRUE; - return SDL_TRUE; /* this audio target is available. */ + return SDL_TRUE; /* this audio target is available. */ } AudioBootStrap SNDIO_bootstrap = { diff --git a/src/audio/sndio/SDL_sndioaudio.h b/src/audio/sndio/SDL_sndioaudio.h index 57db05cb9..bdd13b7fc 100644 --- a/src/audio/sndio/SDL_sndioaudio.h +++ b/src/audio/sndio/SDL_sndioaudio.h @@ -29,7 +29,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { diff --git a/src/audio/vita/SDL_vitaaudio.c b/src/audio/vita/SDL_vitaaudio.c index 41a785b60..803ac4fec 100644 --- a/src/audio/vita/SDL_vitaaudio.c +++ b/src/audio/vita/SDL_vitaaudio.c @@ -39,11 +39,10 @@ #include #include -#define SCE_AUDIO_SAMPLE_ALIGN(s) (((s) + 63) & ~63) -#define SCE_AUDIO_MAX_VOLUME 0x8000 +#define SCE_AUDIO_SAMPLE_ALIGN(s) (((s) + 63) & ~63) +#define SCE_AUDIO_MAX_VOLUME 0x8000 -static int -VITAAUD_OpenCaptureDevice(_THIS) +static int VITAAUD_OpenCaptureDevice(_THIS) { this->spec.freq = 16000; this->spec.samples = 512; @@ -51,7 +50,7 @@ VITAAUD_OpenCaptureDevice(_THIS) SDL_CalculateAudioSpec(&this->spec); - this->hidden->port = sceAudioInOpenPort(SCE_AUDIO_IN_PORT_TYPE_VOICE , 512, 16000, SCE_AUDIO_IN_PARAM_FORMAT_S16_MONO); + this->hidden->port = sceAudioInOpenPort(SCE_AUDIO_IN_PORT_TYPE_VOICE, 512, 16000, SCE_AUDIO_IN_PARAM_FORMAT_S16_MONO); if (this->hidden->port < 0) { return SDL_SetError("Couldn't open audio in port: %x", this->hidden->port); @@ -60,11 +59,10 @@ VITAAUD_OpenCaptureDevice(_THIS) return 0; } -static int -VITAAUD_OpenDevice(_THIS, const char *devname) +static int VITAAUD_OpenDevice(_THIS, const char *devname) { int format, mixlen, i, port = SCE_AUDIO_OUT_PORT_TYPE_MAIN; - int vols[2] = {SCE_AUDIO_MAX_VOLUME, SCE_AUDIO_MAX_VOLUME}; + int vols[2] = { SCE_AUDIO_MAX_VOLUME, SCE_AUDIO_MAX_VOLUME }; SDL_AudioFormat test_format; this->hidden = (struct SDL_PrivateAudioData *) @@ -99,7 +97,7 @@ VITAAUD_OpenDevice(_THIS, const char *devname) be a multiple of 64 bytes. Our sample count is already a multiple of 64, so spec->size should be a multiple of 64 as well. */ mixlen = this->spec.size * NUM_BUFFERS; - this->hidden->rawbuf = (Uint8 *) memalign(64, mixlen); + this->hidden->rawbuf = (Uint8 *)memalign(64, mixlen); if (this->hidden->rawbuf == NULL) { return SDL_SetError("Couldn't allocate mixing buffer"); } @@ -122,7 +120,7 @@ VITAAUD_OpenDevice(_THIS, const char *devname) return SDL_SetError("Couldn't open audio out port: %x", this->hidden->port); } - sceAudioOutSetVolume(this->hidden->port, SCE_AUDIO_VOLUME_FLAG_L_CH|SCE_AUDIO_VOLUME_FLAG_R_CH, vols); + sceAudioOutSetVolume(this->hidden->port, SCE_AUDIO_VOLUME_FLAG_L_CH | SCE_AUDIO_VOLUME_FLAG_R_CH, vols); SDL_memset(this->hidden->rawbuf, 0, mixlen); for (i = 0; i < NUM_BUFFERS; i++) { @@ -165,7 +163,7 @@ static void VITAAUD_CloseDevice(_THIS) } if (!this->iscapture && this->hidden->rawbuf != NULL) { - free(this->hidden->rawbuf); /* this uses memalign(), not SDL_malloc(). */ + free(this->hidden->rawbuf); /* this uses memalign(), not SDL_malloc(). */ this->hidden->rawbuf = NULL; } } @@ -194,8 +192,7 @@ static void VITAAUD_ThreadInit(_THIS) } } -static SDL_bool -VITAAUD_Init(SDL_AudioDriverImpl * impl) +static SDL_bool VITAAUD_Init(SDL_AudioDriverImpl *impl) { /* Set the function pointers */ impl->OpenDevice = VITAAUD_OpenDevice; @@ -212,7 +209,7 @@ VITAAUD_Init(SDL_AudioDriverImpl * impl) impl->OnlyHasDefaultOutputDevice = SDL_TRUE; impl->OnlyHasDefaultCaptureDevice = SDL_TRUE; - return SDL_TRUE; /* this audio target is available. */ + return SDL_TRUE; /* this audio target is available. */ } AudioBootStrap VITAAUD_bootstrap = { diff --git a/src/audio/vita/SDL_vitaaudio.h b/src/audio/vita/SDL_vitaaudio.h index a5601b28c..5bc32cdf4 100644 --- a/src/audio/vita/SDL_vitaaudio.h +++ b/src/audio/vita/SDL_vitaaudio.h @@ -25,19 +25,20 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this #define NUM_BUFFERS 2 -struct SDL_PrivateAudioData { +struct SDL_PrivateAudioData +{ /* The hardware input/output port. */ - int port; + int port; /* The raw allocated mixing buffer. */ - Uint8 *rawbuf; + Uint8 *rawbuf; /* Individual mixing buffers. */ - Uint8 *mixbufs[NUM_BUFFERS]; + Uint8 *mixbufs[NUM_BUFFERS]; /* Index of the next available mixing buffer. */ - int next_buffer; + int next_buffer; }; #endif /* _SDL_vitaaudio_h */ diff --git a/src/audio/wasapi/SDL_wasapi.c b/src/audio/wasapi/SDL_wasapi.c index 3a1acfeb0..e24ba47de 100644 --- a/src/audio/wasapi/SDL_wasapi.c +++ b/src/audio/wasapi/SDL_wasapi.c @@ -36,7 +36,7 @@ /* These constants aren't available in older SDKs */ #ifndef AUDCLNT_STREAMFLAGS_RATEADJUST -#define AUDCLNT_STREAMFLAGS_RATEADJUST 0x00100000 +#define AUDCLNT_STREAMFLAGS_RATEADJUST 0x00100000 #endif #ifndef AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY #define AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY 0x08000000 @@ -46,17 +46,15 @@ #endif /* Some GUIDs we need to know without linking to libraries that aren't available before Vista. */ -static const IID SDL_IID_IAudioRenderClient = { 0xf294acfc, 0x3146, 0x4483,{ 0xa7, 0xbf, 0xad, 0xdc, 0xa7, 0xc2, 0x60, 0xe2 } }; -static const IID SDL_IID_IAudioCaptureClient = { 0xc8adbd64, 0xe71e, 0x48a0,{ 0xa4, 0xde, 0x18, 0x5c, 0x39, 0x5c, 0xd3, 0x17 } }; +static const IID SDL_IID_IAudioRenderClient = { 0xf294acfc, 0x3146, 0x4483, { 0xa7, 0xbf, 0xad, 0xdc, 0xa7, 0xc2, 0x60, 0xe2 } }; +static const IID SDL_IID_IAudioCaptureClient = { 0xc8adbd64, 0xe71e, 0x48a0, { 0xa4, 0xde, 0x18, 0x5c, 0x39, 0x5c, 0xd3, 0x17 } }; -static void -WASAPI_DetectDevices(void) +static void WASAPI_DetectDevices(void) { WASAPI_EnumerateEndpoints(); } -static SDL_INLINE SDL_bool -WasapiFailed(_THIS, const HRESULT err) +static SDL_INLINE SDL_bool WasapiFailed(_THIS, const HRESULT err) { if (err == S_OK) { return SDL_FALSE; @@ -73,39 +71,38 @@ WasapiFailed(_THIS, const HRESULT err) return SDL_TRUE; } -static int -UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec) +static int UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec) { /* Since WASAPI requires us to handle all audio conversion, and our device format might have changed, we might have to add/remove/change the audio stream that the higher level uses to convert data, so SDL keeps firing the callback as if nothing happened here. */ - if ( (this->callbackspec.channels == this->spec.channels) && - (this->callbackspec.format == this->spec.format) && - (this->callbackspec.freq == this->spec.freq) && - (this->callbackspec.samples == this->spec.samples) ) { + if ((this->callbackspec.channels == this->spec.channels) && + (this->callbackspec.format == this->spec.format) && + (this->callbackspec.freq == this->spec.freq) && + (this->callbackspec.samples == this->spec.samples)) { /* no need to buffer/convert in an AudioStream! */ SDL_FreeAudioStream(this->stream); this->stream = NULL; - } else if ( (oldspec->channels == this->spec.channels) && - (oldspec->format == this->spec.format) && - (oldspec->freq == this->spec.freq) ) { + } else if ((oldspec->channels == this->spec.channels) && + (oldspec->format == this->spec.format) && + (oldspec->freq == this->spec.freq)) { /* The existing audio stream is okay to keep using. */ } else { /* replace the audiostream for new format */ SDL_FreeAudioStream(this->stream); if (this->iscapture) { this->stream = SDL_NewAudioStream(this->spec.format, - this->spec.channels, this->spec.freq, - this->callbackspec.format, - this->callbackspec.channels, - this->callbackspec.freq); + this->spec.channels, this->spec.freq, + this->callbackspec.format, + this->callbackspec.channels, + this->callbackspec.freq); } else { this->stream = SDL_NewAudioStream(this->callbackspec.format, - this->callbackspec.channels, - this->callbackspec.freq, this->spec.format, - this->spec.channels, this->spec.freq); + this->callbackspec.channels, + this->callbackspec.freq, this->spec.format, + this->spec.channels, this->spec.freq); } if (!this->stream) { @@ -115,7 +112,7 @@ UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec) /* make sure our scratch buffer can cover the new device spec. */ if (this->spec.size > this->work_buffer_len) { - Uint8 *ptr = (Uint8 *) SDL_realloc(this->work_buffer, this->spec.size); + Uint8 *ptr = (Uint8 *)SDL_realloc(this->work_buffer, this->spec.size); if (ptr == NULL) { return SDL_OutOfMemory(); } @@ -126,16 +123,14 @@ UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec) return 0; } - static void ReleaseWasapiDevice(_THIS); -static SDL_bool -RecoverWasapiDevice(_THIS) +static SDL_bool RecoverWasapiDevice(_THIS) { - ReleaseWasapiDevice(this); /* dump the lost device's handles. */ + ReleaseWasapiDevice(this); /* dump the lost device's handles. */ if (this->hidden->default_device_generation) { - this->hidden->default_device_generation = SDL_AtomicGet(this->iscapture ? &SDL_IMMDevice_DefaultCaptureGeneration : &SDL_IMMDevice_DefaultPlaybackGeneration); + this->hidden->default_device_generation = SDL_AtomicGet(this->iscapture ? &SDL_IMMDevice_DefaultCaptureGeneration : &SDL_IMMDevice_DefaultPlaybackGeneration); } /* this can fail for lots of reasons, but the most likely is we had a @@ -150,26 +145,25 @@ RecoverWasapiDevice(_THIS) this->hidden->device_lost = SDL_FALSE; - return SDL_TRUE; /* okay, carry on with new device details! */ + return SDL_TRUE; /* okay, carry on with new device details! */ } -static SDL_bool -RecoverWasapiIfLost(_THIS) +static SDL_bool RecoverWasapiIfLost(_THIS) { const int generation = this->hidden->default_device_generation; SDL_bool lost = this->hidden->device_lost; if (!SDL_AtomicGet(&this->enabled)) { - return SDL_FALSE; /* already failed. */ + return SDL_FALSE; /* already failed. */ } if (!this->hidden->client) { - return SDL_TRUE; /* still waiting for activation. */ + return SDL_TRUE; /* still waiting for activation. */ } if (!lost && (generation > 0)) { /* is a default device? */ const int newgen = SDL_AtomicGet(this->iscapture ? &SDL_IMMDevice_DefaultCaptureGeneration : &SDL_IMMDevice_DefaultPlaybackGeneration); - if (generation != newgen) { /* the desired default device was changed, jump over to it. */ + if (generation != newgen) { /* the desired default device was changed, jump over to it. */ lost = SDL_TRUE; } } @@ -177,33 +171,30 @@ RecoverWasapiIfLost(_THIS) return lost ? RecoverWasapiDevice(this) : SDL_TRUE; } -static Uint8 * -WASAPI_GetDeviceBuf(_THIS) +static Uint8 *WASAPI_GetDeviceBuf(_THIS) { /* get an endpoint buffer from WASAPI. */ BYTE *buffer = NULL; while (RecoverWasapiIfLost(this) && this->hidden->render) { if (!WasapiFailed(this, IAudioRenderClient_GetBuffer(this->hidden->render, this->spec.samples, &buffer))) { - return (Uint8 *) buffer; + return (Uint8 *)buffer; } SDL_assert(buffer == NULL); } - return (Uint8 *) buffer; + return (Uint8 *)buffer; } -static void -WASAPI_PlayDevice(_THIS) +static void WASAPI_PlayDevice(_THIS) { - if (this->hidden->render != NULL) { /* definitely activated? */ + if (this->hidden->render != NULL) { /* definitely activated? */ /* WasapiFailed() will mark the device for reacquisition or removal elsewhere. */ WasapiFailed(this, IAudioRenderClient_ReleaseBuffer(this->hidden->render, this->spec.samples, 0)); } } -static void -WASAPI_WaitDevice(_THIS) +static void WASAPI_WaitDevice(_THIS) { while (RecoverWasapiIfLost(this) && this->hidden->client && this->hidden->event) { DWORD waitResult = WaitForSingleObjectEx(this->hidden->event, 200, FALSE); @@ -230,8 +221,7 @@ WASAPI_WaitDevice(_THIS) } } -static int -WASAPI_CaptureFromDevice(_THIS, void *buffer, int buflen) +static int WASAPI_CaptureFromDevice(_THIS, void *buffer, int buflen) { SDL_AudioStream *stream = this->hidden->capturestream; const int avail = SDL_AudioStreamAvailable(stream); @@ -263,7 +253,7 @@ WASAPI_CaptureFromDevice(_THIS, void *buffer, int buflen) if ((ret == AUDCLNT_S_BUFFER_EMPTY) || !frames) { WASAPI_WaitDevice(this); } else if (ret == S_OK) { - const int total = ((int) frames) * this->hidden->framesize; + const int total = ((int)frames) * this->hidden->framesize; const int cpy = SDL_min(buflen, total); const int leftover = total - cpy; const SDL_bool silent = (flags & AUDCLNT_BUFFERFLAGS_SILENT) ? SDL_TRUE : SDL_FALSE; @@ -273,15 +263,15 @@ WASAPI_CaptureFromDevice(_THIS, void *buffer, int buflen) } else { SDL_memcpy(buffer, ptr, cpy); } - + if (leftover > 0) { ptr += cpy; if (silent) { - SDL_memset(ptr, this->spec.silence, leftover); /* I guess this is safe? */ + SDL_memset(ptr, this->spec.silence, leftover); /* I guess this is safe? */ } if (SDL_AudioStreamPut(stream, ptr, leftover) == -1) { - return -1; /* uhoh, out of memory, etc. Kill device. :( */ + return -1; /* uhoh, out of memory, etc. Kill device. :( */ } } @@ -292,36 +282,34 @@ WASAPI_CaptureFromDevice(_THIS, void *buffer, int buflen) } } - return -1; /* unrecoverable error. */ + return -1; /* unrecoverable error. */ } -static void -WASAPI_FlushCapture(_THIS) +static void WASAPI_FlushCapture(_THIS) { BYTE *ptr = NULL; UINT32 frames = 0; DWORD flags = 0; if (!this->hidden->capture) { - return; /* not activated yet? */ + return; /* not activated yet? */ } /* just read until we stop getting packets, throwing them away. */ while (SDL_TRUE) { const HRESULT ret = IAudioCaptureClient_GetBuffer(this->hidden->capture, &ptr, &frames, &flags, NULL, NULL); if (ret == AUDCLNT_S_BUFFER_EMPTY) { - break; /* no more buffered data; we're done. */ + break; /* no more buffered data; we're done. */ } else if (WasapiFailed(this, ret)) { - break; /* failed for some other reason, abort. */ + break; /* failed for some other reason, abort. */ } else if (WasapiFailed(this, IAudioCaptureClient_ReleaseBuffer(this->hidden->capture, frames))) { - break; /* something broke. */ + break; /* something broke. */ } } SDL_AudioStreamClear(this->hidden->capturestream); } -static void -ReleaseWasapiDevice(_THIS) +static void ReleaseWasapiDevice(_THIS) { if (this->hidden->client) { IAudioClient_Stop(this->hidden->client); @@ -360,20 +348,17 @@ ReleaseWasapiDevice(_THIS) } } -static void -WASAPI_CloseDevice(_THIS) +static void WASAPI_CloseDevice(_THIS) { WASAPI_UnrefDevice(this); } -void -WASAPI_RefDevice(_THIS) +void WASAPI_RefDevice(_THIS) { SDL_AtomicIncRef(&this->hidden->refcount); } -void -WASAPI_UnrefDevice(_THIS) +void WASAPI_UnrefDevice(_THIS) { if (!SDL_AtomicDecRef(&this->hidden->refcount)) { return; @@ -390,8 +375,7 @@ WASAPI_UnrefDevice(_THIS) } /* This is called once a device is activated, possibly asynchronously. */ -int -WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) +int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) { /* !!! FIXME: we could request an exclusive mode stream, which is lower latency; !!! it will write into the kernel's audio buffer directly instead of @@ -406,7 +390,7 @@ WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) !!! do in any case. */ const SDL_AudioSpec oldspec = this->spec; const AUDCLNT_SHAREMODE sharemode = AUDCLNT_SHAREMODE_SHARED; - UINT32 bufsize = 0; /* this is in sample frames, not samples, not bytes. */ + UINT32 bufsize = 0; /* this is in sample frames, not samples, not bytes. */ REFERENCE_TIME default_period = 0; IAudioClient *client = this->hidden->client; IAudioRenderClient *render = NULL; @@ -437,7 +421,7 @@ WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) SDL_assert(waveformat != NULL); this->hidden->waveformat = waveformat; - this->spec.channels = (Uint8) waveformat->nChannels; + this->spec.channels = (Uint8)waveformat->nChannels; /* Make sure we have a valid format that we can convert to whatever WASAPI wants. */ wasapi_format = WaveFormatToSDLFormat(waveformat); @@ -504,10 +488,10 @@ WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) if (this->iscapture) { this->hidden->capturestream = SDL_NewAudioStream(this->spec.format, this->spec.channels, this->spec.freq, this->spec.format, this->spec.channels, this->spec.freq); if (!this->hidden->capturestream) { - return -1; /* already set SDL_Error */ + return -1; /* already set SDL_Error */ } - ret = IAudioClient_GetService(client, &SDL_IID_IAudioCaptureClient, (void**) &capture); + ret = IAudioClient_GetService(client, &SDL_IID_IAudioCaptureClient, (void **)&capture); if (FAILED(ret)) { return WIN_SetErrorFromHRESULT("WASAPI can't get capture client service", ret); } @@ -519,9 +503,9 @@ WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) return WIN_SetErrorFromHRESULT("WASAPI can't start capture", ret); } - WASAPI_FlushCapture(this); /* MSDN says you should flush capture endpoint right after startup. */ + WASAPI_FlushCapture(this); /* MSDN says you should flush capture endpoint right after startup. */ } else { - ret = IAudioClient_GetService(client, &SDL_IID_IAudioRenderClient, (void**) &render); + ret = IAudioClient_GetService(client, &SDL_IID_IAudioRenderClient, (void **)&render); if (FAILED(ret)) { return WIN_SetErrorFromHRESULT("WASAPI can't get render client service", ret); } @@ -538,14 +522,12 @@ WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) return UpdateAudioStream(this, &oldspec); } - return 0; /* good to go. */ + return 0; /* good to go. */ } - -static int -WASAPI_OpenDevice(_THIS, const char *devname) +static int WASAPI_OpenDevice(_THIS, const char *devname) { - LPCWSTR devid = (LPCWSTR) this->handle; + LPCWSTR devid = (LPCWSTR)this->handle; /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *) @@ -555,9 +537,9 @@ WASAPI_OpenDevice(_THIS, const char *devname) } SDL_zerop(this->hidden); - WASAPI_RefDevice(this); /* so CloseDevice() will unref to zero. */ + WASAPI_RefDevice(this); /* so CloseDevice() will unref to zero. */ - if (!devid) { /* is default device? */ + if (!devid) { /* is default device? */ this->hidden->default_device_generation = SDL_AtomicGet(this->iscapture ? &SDL_IMMDevice_DefaultCaptureGeneration : &SDL_IMMDevice_DefaultPlaybackGeneration); } else { this->hidden->devid = SDL_wcsdup(devid); @@ -567,7 +549,7 @@ WASAPI_OpenDevice(_THIS, const char *devname) } if (WASAPI_ActivateDevice(this, SDL_FALSE) == -1) { - return -1; /* already set error. */ + return -1; /* already set error. */ } /* Ready, but waiting for async device activation. @@ -581,26 +563,22 @@ WASAPI_OpenDevice(_THIS, const char *devname) return 0; } -static void -WASAPI_ThreadInit(_THIS) +static void WASAPI_ThreadInit(_THIS) { WASAPI_PlatformThreadInit(this); } -static void -WASAPI_ThreadDeinit(_THIS) +static void WASAPI_ThreadDeinit(_THIS) { WASAPI_PlatformThreadDeinit(this); } -static void -WASAPI_Deinitialize(void) +static void WASAPI_Deinitialize(void) { WASAPI_PlatformDeinit(); } -static SDL_bool -WASAPI_Init(SDL_AudioDriverImpl * impl) +static SDL_bool WASAPI_Init(SDL_AudioDriverImpl *impl) { if (WASAPI_PlatformInit() == -1) { return SDL_FALSE; @@ -622,13 +600,13 @@ WASAPI_Init(SDL_AudioDriverImpl * impl) impl->HasCaptureSupport = SDL_TRUE; impl->SupportsNonPow2Samples = SDL_TRUE; - return SDL_TRUE; /* this audio target is available. */ + return SDL_TRUE; /* this audio target is available. */ } AudioBootStrap WASAPI_bootstrap = { "wasapi", "WASAPI", WASAPI_Init, SDL_FALSE }; -#endif /* SDL_AUDIO_DRIVER_WASAPI */ +#endif /* SDL_AUDIO_DRIVER_WASAPI */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/wasapi/SDL_wasapi_win32.c b/src/audio/wasapi/SDL_wasapi_win32.c index 13f05b661..df772d8b6 100644 --- a/src/audio/wasapi/SDL_wasapi_win32.c +++ b/src/audio/wasapi/SDL_wasapi_win32.c @@ -47,26 +47,24 @@ static pfnAvSetMmThreadCharacteristicsW pAvSetMmThreadCharacteristicsW = NULL; static pfnAvRevertMmThreadCharacteristics pAvRevertMmThreadCharacteristics = NULL; /* Some GUIDs we need to know without linking to libraries that aren't available before Vista. */ -static const IID SDL_IID_IAudioClient = { 0x1cb9ad4c, 0xdbfa, 0x4c32,{ 0xb1, 0x78, 0xc2, 0xf5, 0x68, 0xa7, 0x03, 0xb2 } }; +static const IID SDL_IID_IAudioClient = { 0x1cb9ad4c, 0xdbfa, 0x4c32, { 0xb1, 0x78, 0xc2, 0xf5, 0x68, 0xa7, 0x03, 0xb2 } }; -int -WASAPI_PlatformInit(void) +int WASAPI_PlatformInit(void) { if (SDL_IMMDevice_Init() < 0) { return -1; /* This is set by SDL_IMMDevice_Init */ } - libavrt = LoadLibrary(TEXT("avrt.dll")); /* this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now! */ + libavrt = LoadLibrary(TEXT("avrt.dll")); /* this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now! */ if (libavrt) { - pAvSetMmThreadCharacteristicsW = (pfnAvSetMmThreadCharacteristicsW) GetProcAddress(libavrt, "AvSetMmThreadCharacteristicsW"); - pAvRevertMmThreadCharacteristics = (pfnAvRevertMmThreadCharacteristics) GetProcAddress(libavrt, "AvRevertMmThreadCharacteristics"); + pAvSetMmThreadCharacteristicsW = (pfnAvSetMmThreadCharacteristicsW)GetProcAddress(libavrt, "AvSetMmThreadCharacteristicsW"); + pAvRevertMmThreadCharacteristics = (pfnAvRevertMmThreadCharacteristics)GetProcAddress(libavrt, "AvRevertMmThreadCharacteristics"); } return 0; } -void -WASAPI_PlatformDeinit(void) +void WASAPI_PlatformDeinit(void) { if (libavrt) { FreeLibrary(libavrt); @@ -79,11 +77,10 @@ WASAPI_PlatformDeinit(void) SDL_IMMDevice_Quit(); } -void -WASAPI_PlatformThreadInit(_THIS) +void WASAPI_PlatformThreadInit(_THIS) { /* this thread uses COM. */ - if (SUCCEEDED(WIN_CoInitialize())) { /* can't report errors, hope it worked! */ + if (SUCCEEDED(WIN_CoInitialize())) { /* can't report errors, hope it worked! */ this->hidden->coinitialized = SDL_TRUE; } @@ -94,8 +91,7 @@ WASAPI_PlatformThreadInit(_THIS) } } -void -WASAPI_PlatformThreadDeinit(_THIS) +void WASAPI_PlatformThreadDeinit(_THIS) { /* Set this thread back to normal priority. */ if (this->hidden->task && pAvRevertMmThreadCharacteristics) { @@ -109,8 +105,7 @@ WASAPI_PlatformThreadDeinit(_THIS) } } -int -WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery) +int WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery) { IMMDevice *device = NULL; HRESULT ret; @@ -121,7 +116,7 @@ WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery) } /* this is not async in standard win32, yay! */ - ret = IMMDevice_Activate(device, &SDL_IID_IAudioClient, CLSCTX_ALL, NULL, (void **) &this->hidden->client); + ret = IMMDevice_Activate(device, &SDL_IID_IAudioClient, CLSCTX_ALL, NULL, (void **)&this->hidden->client); IMMDevice_Release(device); if (FAILED(ret)) { @@ -130,33 +125,29 @@ WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery) } SDL_assert(this->hidden->client != NULL); - if (WASAPI_PrepDevice(this, isrecovery) == -1) { /* not async, fire it right away. */ + if (WASAPI_PrepDevice(this, isrecovery) == -1) { /* not async, fire it right away. */ return -1; } - return 0; /* good to go. */ + return 0; /* good to go. */ } -void -WASAPI_EnumerateEndpoints(void) +void WASAPI_EnumerateEndpoints(void) { SDL_IMMDevice_EnumerateEndpoints(SDL_FALSE); } -int -WASAPI_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) +int WASAPI_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) { return SDL_IMMDevice_GetDefaultAudioInfo(name, spec, iscapture); } -void -WASAPI_PlatformDeleteActivationHandler(void *handler) +void WASAPI_PlatformDeleteActivationHandler(void *handler) { /* not asynchronous. */ SDL_assert(!"This function should have only been called on WinRT."); } -#endif /* SDL_AUDIO_DRIVER_WASAPI && !defined(__WINRT__) */ +#endif /* SDL_AUDIO_DRIVER_WASAPI && !defined(__WINRT__) */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/audio/wasapi/SDL_wasapi_winrt.cpp b/src/audio/wasapi/SDL_wasapi_winrt.cpp index 40dd00278..7615b3f68 100644 --- a/src/audio/wasapi/SDL_wasapi_winrt.cpp +++ b/src/audio/wasapi/SDL_wasapi_winrt.cpp @@ -53,13 +53,13 @@ using namespace Windows::Media::Devices; using namespace Windows::Foundation; using namespace Microsoft::WRL; -static Platform::String^ SDL_PKEY_AudioEngine_DeviceFormat = L"{f19f064d-082c-4e27-bc73-6882a1bb8e4c} 0"; +static Platform::String ^ SDL_PKEY_AudioEngine_DeviceFormat = L"{f19f064d-082c-4e27-bc73-6882a1bb8e4c} 0"; static void WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, WAVEFORMATEXTENSIBLE *fmt, LPCWSTR devid); static void WASAPI_RemoveDevice(const SDL_bool iscapture, LPCWSTR devid); extern "C" { - SDL_atomic_t SDL_IMMDevice_DefaultPlaybackGeneration; - SDL_atomic_t SDL_IMMDevice_DefaultCaptureGeneration; +SDL_atomic_t SDL_IMMDevice_DefaultPlaybackGeneration; +SDL_atomic_t SDL_IMMDevice_DefaultCaptureGeneration; } /* This is a list of device id strings we have inflight, so we have consistent pointers to the same device. */ @@ -73,20 +73,20 @@ static DevIdList *deviceid_list = NULL; class SDL_WasapiDeviceEventHandler { -public: + public: SDL_WasapiDeviceEventHandler(const SDL_bool _iscapture); ~SDL_WasapiDeviceEventHandler(); - void OnDeviceAdded(DeviceWatcher^ sender, DeviceInformation^ args); - void OnDeviceRemoved(DeviceWatcher^ sender, DeviceInformationUpdate^ args); - void OnDeviceUpdated(DeviceWatcher^ sender, DeviceInformationUpdate^ args); - void OnEnumerationCompleted(DeviceWatcher^ sender, Platform::Object^ args); - void OnDefaultRenderDeviceChanged(Platform::Object^ sender, DefaultAudioRenderDeviceChangedEventArgs^ args); - void OnDefaultCaptureDeviceChanged(Platform::Object^ sender, DefaultAudioCaptureDeviceChangedEventArgs^ args); - SDL_semaphore* completed; + void OnDeviceAdded(DeviceWatcher ^ sender, DeviceInformation ^ args); + void OnDeviceRemoved(DeviceWatcher ^ sender, DeviceInformationUpdate ^ args); + void OnDeviceUpdated(DeviceWatcher ^ sender, DeviceInformationUpdate ^ args); + void OnEnumerationCompleted(DeviceWatcher ^ sender, Platform::Object ^ args); + void OnDefaultRenderDeviceChanged(Platform::Object ^ sender, DefaultAudioRenderDeviceChangedEventArgs ^ args); + void OnDefaultCaptureDeviceChanged(Platform::Object ^ sender, DefaultAudioCaptureDeviceChangedEventArgs ^ args); + SDL_semaphore *completed; -private: + private: const SDL_bool iscapture; - DeviceWatcher^ watcher; + DeviceWatcher ^ watcher; Windows::Foundation::EventRegistrationToken added_handler; Windows::Foundation::EventRegistrationToken removed_handler; Windows::Foundation::EventRegistrationToken updated_handler; @@ -95,29 +95,27 @@ private: }; SDL_WasapiDeviceEventHandler::SDL_WasapiDeviceEventHandler(const SDL_bool _iscapture) - : iscapture(_iscapture) - , completed(SDL_CreateSemaphore(0)) + : iscapture(_iscapture), completed(SDL_CreateSemaphore(0)) { if (!completed) - return; // uhoh. + return; // uhoh. - Platform::String^ selector = _iscapture ? MediaDevice::GetAudioCaptureSelector() : - MediaDevice::GetAudioRenderSelector(); - Platform::Collections::Vector properties; + Platform::String ^ selector = _iscapture ? MediaDevice::GetAudioCaptureSelector() : MediaDevice::GetAudioRenderSelector(); + Platform::Collections::Vector properties; properties.Append(SDL_PKEY_AudioEngine_DeviceFormat); watcher = DeviceInformation::CreateWatcher(selector, properties.GetView()); if (!watcher) - return; // uhoh. + return; // uhoh. // !!! FIXME: this doesn't need a lambda here, I think, if I make SDL_WasapiDeviceEventHandler a proper C++/CX class. --ryan. - added_handler = watcher->Added += ref new TypedEventHandler([this](DeviceWatcher^ sender, DeviceInformation^ args) { OnDeviceAdded(sender, args); } ); - removed_handler = watcher->Removed += ref new TypedEventHandler([this](DeviceWatcher^ sender, DeviceInformationUpdate^ args) { OnDeviceRemoved(sender, args); } ); - updated_handler = watcher->Updated += ref new TypedEventHandler([this](DeviceWatcher^ sender, DeviceInformationUpdate^ args) { OnDeviceUpdated(sender, args); } ); - completed_handler = watcher->EnumerationCompleted += ref new TypedEventHandler([this](DeviceWatcher^ sender, Platform::Object^ args) { OnEnumerationCompleted(sender, args); } ); + added_handler = watcher->Added += ref new TypedEventHandler([this](DeviceWatcher ^ sender, DeviceInformation ^ args) { OnDeviceAdded(sender, args); }); + removed_handler = watcher->Removed += ref new TypedEventHandler([this](DeviceWatcher ^ sender, DeviceInformationUpdate ^ args) { OnDeviceRemoved(sender, args); }); + updated_handler = watcher->Updated += ref new TypedEventHandler([this](DeviceWatcher ^ sender, DeviceInformationUpdate ^ args) { OnDeviceUpdated(sender, args); }); + completed_handler = watcher->EnumerationCompleted += ref new TypedEventHandler([this](DeviceWatcher ^ sender, Platform::Object ^ args) { OnEnumerationCompleted(sender, args); }); if (iscapture) { - default_changed_handler = MediaDevice::DefaultAudioCaptureDeviceChanged += ref new TypedEventHandler([this](Platform::Object^ sender, DefaultAudioCaptureDeviceChangedEventArgs^ args) { OnDefaultCaptureDeviceChanged(sender, args); } ); + default_changed_handler = MediaDevice::DefaultAudioCaptureDeviceChanged += ref new TypedEventHandler([this](Platform::Object ^ sender, DefaultAudioCaptureDeviceChangedEventArgs ^ args) { OnDefaultCaptureDeviceChanged(sender, args); }); } else { - default_changed_handler = MediaDevice::DefaultAudioRenderDeviceChanged += ref new TypedEventHandler([this](Platform::Object^ sender, DefaultAudioRenderDeviceChangedEventArgs^ args) { OnDefaultRenderDeviceChanged(sender, args); } ); + default_changed_handler = MediaDevice::DefaultAudioRenderDeviceChanged += ref new TypedEventHandler([this](Platform::Object ^ sender, DefaultAudioRenderDeviceChangedEventArgs ^ args) { OnDefaultRenderDeviceChanged(sender, args); }); } watcher->Start(); } @@ -144,17 +142,16 @@ SDL_WasapiDeviceEventHandler::~SDL_WasapiDeviceEventHandler() } } -void -SDL_WasapiDeviceEventHandler::OnDeviceAdded(DeviceWatcher^ sender, DeviceInformation^ info) +void SDL_WasapiDeviceEventHandler::OnDeviceAdded(DeviceWatcher ^ sender, DeviceInformation ^ info) { SDL_assert(sender == this->watcher); char *utf8dev = WIN_StringToUTF8(info->Name->Data()); if (utf8dev) { WAVEFORMATEXTENSIBLE fmt; - Platform::Object^ obj = info->Properties->Lookup(SDL_PKEY_AudioEngine_DeviceFormat); + Platform::Object ^ obj = info->Properties->Lookup(SDL_PKEY_AudioEngine_DeviceFormat); if (obj) { - IPropertyValue^ property = (IPropertyValue^) obj; - Platform::Array^ data; + IPropertyValue ^ property = (IPropertyValue ^) obj; + Platform::Array ^ data; property->GetUInt8Array(&data); SDL_memcpy(&fmt, data->Data, SDL_min(data->Length, sizeof(WAVEFORMATEXTENSIBLE))); } else { @@ -166,41 +163,35 @@ SDL_WasapiDeviceEventHandler::OnDeviceAdded(DeviceWatcher^ sender, DeviceInforma } } -void -SDL_WasapiDeviceEventHandler::OnDeviceRemoved(DeviceWatcher^ sender, DeviceInformationUpdate^ info) +void SDL_WasapiDeviceEventHandler::OnDeviceRemoved(DeviceWatcher ^ sender, DeviceInformationUpdate ^ info) { SDL_assert(sender == this->watcher); WASAPI_RemoveDevice(this->iscapture, info->Id->Data()); } -void -SDL_WasapiDeviceEventHandler::OnDeviceUpdated(DeviceWatcher^ sender, DeviceInformationUpdate^ args) +void SDL_WasapiDeviceEventHandler::OnDeviceUpdated(DeviceWatcher ^ sender, DeviceInformationUpdate ^ args) { SDL_assert(sender == this->watcher); } -void -SDL_WasapiDeviceEventHandler::OnEnumerationCompleted(DeviceWatcher^ sender, Platform::Object^ args) +void SDL_WasapiDeviceEventHandler::OnEnumerationCompleted(DeviceWatcher ^ sender, Platform::Object ^ args) { SDL_assert(sender == this->watcher); SDL_SemPost(this->completed); } -void -SDL_WasapiDeviceEventHandler::OnDefaultRenderDeviceChanged(Platform::Object^ sender, DefaultAudioRenderDeviceChangedEventArgs^ args) +void SDL_WasapiDeviceEventHandler::OnDefaultRenderDeviceChanged(Platform::Object ^ sender, DefaultAudioRenderDeviceChangedEventArgs ^ args) { SDL_assert(this->iscapture); SDL_AtomicAdd(&SDL_IMMDevice_DefaultPlaybackGeneration, 1); } -void -SDL_WasapiDeviceEventHandler::OnDefaultCaptureDeviceChanged(Platform::Object^ sender, DefaultAudioCaptureDeviceChangedEventArgs^ args) +void SDL_WasapiDeviceEventHandler::OnDefaultCaptureDeviceChanged(Platform::Object ^ sender, DefaultAudioCaptureDeviceChangedEventArgs ^ args) { SDL_assert(!this->iscapture); SDL_AtomicAdd(&SDL_IMMDevice_DefaultCaptureGeneration, 1); } - static SDL_WasapiDeviceEventHandler *playback_device_event_handler; static SDL_WasapiDeviceEventHandler *capture_device_event_handler; @@ -240,10 +231,11 @@ void WASAPI_EnumerateEndpoints(void) SDL_SemWait(capture_device_event_handler->completed); } -struct SDL_WasapiActivationHandler : public RuntimeClass< RuntimeClassFlags< ClassicCom >, FtmBase, IActivateAudioInterfaceCompletionHandler > +struct SDL_WasapiActivationHandler : public RuntimeClass, FtmBase, IActivateAudioInterfaceCompletionHandler> { SDL_WasapiActivationHandler() : device(nullptr) {} - STDMETHOD(ActivateCompleted)(IActivateAudioInterfaceAsyncOperation *operation); + STDMETHOD(ActivateCompleted) + (IActivateAudioInterfaceAsyncOperation *operation); SDL_AudioDevice *device; }; @@ -256,23 +248,20 @@ SDL_WasapiActivationHandler::ActivateCompleted(IActivateAudioInterfaceAsyncOpera return S_OK; } -void -WASAPI_PlatformDeleteActivationHandler(void *handler) +void WASAPI_PlatformDeleteActivationHandler(void *handler) { - ((SDL_WasapiActivationHandler *) handler)->Release(); + ((SDL_WasapiActivationHandler *)handler)->Release(); } -int -WASAPI_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) +int WASAPI_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) { return SDL_Unsupported(); } -int -WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery) +int WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery) { LPCWSTR devid = _this->hidden->devid; - Platform::String^ defdevid; + Platform::String ^ defdevid; if (devid == nullptr) { defdevid = _this->iscapture ? MediaDevice::GetDefaultAudioCaptureId(AudioDeviceRole::Default) : MediaDevice::GetDefaultAudioRenderId(AudioDeviceRole::Default); @@ -288,11 +277,11 @@ WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery) return SDL_SetError("Failed to allocate WASAPI activation handler"); } - handler.Get()->AddRef(); // we hold a reference after ComPtr destructs on return, causing a Release, and Release ourselves in WASAPI_PlatformDeleteActivationHandler(), etc. + handler.Get()->AddRef(); // we hold a reference after ComPtr destructs on return, causing a Release, and Release ourselves in WASAPI_PlatformDeleteActivationHandler(), etc. handler.Get()->device = _this; _this->hidden->activation_handler = handler.Get(); - WASAPI_RefDevice(_this); /* completion handler will unref it. */ + WASAPI_RefDevice(_this); /* completion handler will unref it. */ IActivateAudioInterfaceAsyncOperation *async = nullptr; const HRESULT ret = ActivateAudioInterfaceAsync(devid, __uuidof(IAudioClient), nullptr, handler.Get(), &async); @@ -339,22 +328,20 @@ WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery) return 0; } -void -WASAPI_PlatformThreadInit(_THIS) +void WASAPI_PlatformThreadInit(_THIS) { // !!! FIXME: set this thread to "Pro Audio" priority. } -void -WASAPI_PlatformThreadDeinit(_THIS) +void WASAPI_PlatformThreadDeinit(_THIS) { // !!! FIXME: set this thread to "Pro Audio" priority. } /* Everything below was copied from SDL_wasapi.c, before it got moved to SDL_immdevice.c! */ -static const GUID SDL_KSDATAFORMAT_SUBTYPE_PCM = { 0x00000001, 0x0000, 0x0010,{ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } }; -static const GUID SDL_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = { 0x00000003, 0x0000, 0x0010,{ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } }; +static const GUID SDL_KSDATAFORMAT_SUBTYPE_PCM = { 0x00000001, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } }; +static const GUID SDL_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = { 0x00000003, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } }; extern "C" SDL_AudioFormat WaveFormatToSDLFormat(WAVEFORMATEX *waveformat) @@ -378,8 +365,7 @@ WaveFormatToSDLFormat(WAVEFORMATEX *waveformat) return 0; } -static void -WASAPI_RemoveDevice(const SDL_bool iscapture, LPCWSTR devid) +static void WASAPI_RemoveDevice(const SDL_bool iscapture, LPCWSTR devid) { DevIdList *i; DevIdList *next; @@ -401,8 +387,7 @@ WASAPI_RemoveDevice(const SDL_bool iscapture, LPCWSTR devid) } } -static void -WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, WAVEFORMATEXTENSIBLE *fmt, LPCWSTR devid) +static void WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, WAVEFORMATEXTENSIBLE *fmt, LPCWSTR devid) { DevIdList *devidlist; SDL_AudioSpec spec; @@ -412,22 +397,22 @@ WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, WAVEFORMATEXTENS phones and tablets, where you might have an internal speaker and a headphone jack and expect both to be available and switch automatically. (!!! FIXME...?) */ - /* see if we already have this one. */ + /* see if we already have this one. */ for (devidlist = deviceid_list; devidlist; devidlist = devidlist->next) { if (SDL_wcscmp(devidlist->str, devid) == 0) { - return; /* we already have this. */ + return; /* we already have this. */ } } devidlist = (DevIdList *)SDL_malloc(sizeof(*devidlist)); if (devidlist == NULL) { - return; /* oh well. */ + return; /* oh well. */ } devid = SDL_wcsdup(devid); if (!devid) { SDL_free(devidlist); - return; /* oh well. */ + return; /* oh well. */ } devidlist->str = (WCHAR *)devid; @@ -441,6 +426,6 @@ WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, WAVEFORMATEXTENS SDL_AddAudioDevice(iscapture, devname, &spec, (void *)devid); } -#endif // SDL_AUDIO_DRIVER_WASAPI && defined(__WINRT__) +#endif // SDL_AUDIO_DRIVER_WASAPI && defined(__WINRT__) /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index ea1eb51f4..83d378c53 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -50,176 +50,176 @@ #include #include -#define SDL_JAVA_PREFIX org_libsdl_app -#define CONCAT1(prefix, class, function) CONCAT2(prefix, class, function) -#define CONCAT2(prefix, class, function) Java_ ## prefix ## _ ## class ## _ ## function -#define SDL_JAVA_INTERFACE(function) CONCAT1(SDL_JAVA_PREFIX, SDLActivity, function) -#define SDL_JAVA_AUDIO_INTERFACE(function) CONCAT1(SDL_JAVA_PREFIX, SDLAudioManager, function) -#define SDL_JAVA_CONTROLLER_INTERFACE(function) CONCAT1(SDL_JAVA_PREFIX, SDLControllerManager, function) -#define SDL_JAVA_INTERFACE_INPUT_CONNECTION(function) CONCAT1(SDL_JAVA_PREFIX, SDLInputConnection, function) +#define SDL_JAVA_PREFIX org_libsdl_app +#define CONCAT1(prefix, class, function) CONCAT2(prefix, class, function) +#define CONCAT2(prefix, class, function) Java_##prefix##_##class##_##function +#define SDL_JAVA_INTERFACE(function) CONCAT1(SDL_JAVA_PREFIX, SDLActivity, function) +#define SDL_JAVA_AUDIO_INTERFACE(function) CONCAT1(SDL_JAVA_PREFIX, SDLAudioManager, function) +#define SDL_JAVA_CONTROLLER_INTERFACE(function) CONCAT1(SDL_JAVA_PREFIX, SDLControllerManager, function) +#define SDL_JAVA_INTERFACE_INPUT_CONNECTION(function) CONCAT1(SDL_JAVA_PREFIX, SDLInputConnection, function) /* Audio encoding definitions */ -#define ENCODING_PCM_8BIT 3 -#define ENCODING_PCM_16BIT 2 -#define ENCODING_PCM_FLOAT 4 +#define ENCODING_PCM_8BIT 3 +#define ENCODING_PCM_16BIT 2 +#define ENCODING_PCM_FLOAT 4 /* Java class SDLActivity */ JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetVersion)( - JNIEnv *env, jclass cls); + JNIEnv *env, jclass cls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)( - JNIEnv *env, jclass cls); + JNIEnv *env, jclass cls); JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)( - JNIEnv *env, jclass cls, - jstring library, jstring function, jobject array); + JNIEnv *env, jclass cls, + jstring library, jstring function, jobject array); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)( - JNIEnv *env, jclass jcls, - jstring filename); + JNIEnv *env, jclass jcls, + jstring filename); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetScreenResolution)( - JNIEnv *env, jclass jcls, - jint surfaceWidth, jint surfaceHeight, - jint deviceWidth, jint deviceHeight, jfloat rate); + JNIEnv *env, jclass jcls, + jint surfaceWidth, jint surfaceHeight, + jint deviceWidth, jint deviceHeight, jfloat rate); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeResize)( - JNIEnv *env, jclass cls); + JNIEnv *env, jclass cls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceCreated)( - JNIEnv *env, jclass jcls); + JNIEnv *env, jclass jcls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceChanged)( - JNIEnv *env, jclass jcls); + JNIEnv *env, jclass jcls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceDestroyed)( - JNIEnv *env, jclass jcls); + JNIEnv *env, jclass jcls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyDown)( - JNIEnv *env, jclass jcls, - jint keycode); + JNIEnv *env, jclass jcls, + jint keycode); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyUp)( - JNIEnv *env, jclass jcls, - jint keycode); + JNIEnv *env, jclass jcls, + jint keycode); JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE(onNativeSoftReturnKey)( - JNIEnv *env, jclass jcls); + JNIEnv *env, jclass jcls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyboardFocusLost)( - JNIEnv *env, jclass jcls); + JNIEnv *env, jclass jcls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeTouch)( - JNIEnv *env, jclass jcls, - jint touch_device_id_in, jint pointer_finger_id_in, - jint action, jfloat x, jfloat y, jfloat p); + JNIEnv *env, jclass jcls, + jint touch_device_id_in, jint pointer_finger_id_in, + jint action, jfloat x, jfloat y, jfloat p); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeMouse)( - JNIEnv *env, jclass jcls, - jint button, jint action, jfloat x, jfloat y, jboolean relative); + JNIEnv *env, jclass jcls, + jint button, jint action, jfloat x, jfloat y, jboolean relative); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)( - JNIEnv *env, jclass jcls, - jfloat x, jfloat y, jfloat z); + JNIEnv *env, jclass jcls, + jfloat x, jfloat y, jfloat z); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeClipboardChanged)( - JNIEnv *env, jclass jcls); + JNIEnv *env, jclass jcls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeLowMemory)( - JNIEnv *env, jclass cls); + JNIEnv *env, jclass cls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeLocaleChanged)( - JNIEnv *env, jclass cls); + JNIEnv *env, jclass cls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSendQuit)( - JNIEnv *env, jclass cls); + JNIEnv *env, jclass cls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)( - JNIEnv *env, jclass cls); + JNIEnv *env, jclass cls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)( - JNIEnv *env, jclass cls); + JNIEnv *env, jclass cls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeResume)( - JNIEnv *env, jclass cls); + JNIEnv *env, jclass cls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeFocusChanged)( - JNIEnv *env, jclass cls, jboolean hasFocus); + JNIEnv *env, jclass cls, jboolean hasFocus); JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetHint)( - JNIEnv *env, jclass cls, - jstring name); + JNIEnv *env, jclass cls, + jstring name); JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE(nativeGetHintBoolean)( - JNIEnv *env, jclass cls, - jstring name, jboolean default_value); + JNIEnv *env, jclass cls, + jstring name, jboolean default_value); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetenv)( - JNIEnv *env, jclass cls, - jstring name, jstring value); + JNIEnv *env, jclass cls, + jstring name, jstring value); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeOrientationChanged)( - JNIEnv *env, jclass cls, - jint orientation); + JNIEnv *env, jclass cls, + jint orientation); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeAddTouch)( - JNIEnv* env, jclass cls, - jint touchId, jstring name); + JNIEnv *env, jclass cls, + jint touchId, jstring name); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePermissionResult)( - JNIEnv* env, jclass cls, - jint requestCode, jboolean result); + JNIEnv *env, jclass cls, + jint requestCode, jboolean result); static JNINativeMethod SDLActivity_tab[] = { - { "nativeGetVersion", "()Ljava/lang/String;", SDL_JAVA_INTERFACE(nativeGetVersion) }, - { "nativeSetupJNI", "()I", SDL_JAVA_INTERFACE(nativeSetupJNI) }, - { "nativeRunMain", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;)I", SDL_JAVA_INTERFACE(nativeRunMain) }, - { "onNativeDropFile", "(Ljava/lang/String;)V", SDL_JAVA_INTERFACE(onNativeDropFile) }, - { "nativeSetScreenResolution", "(IIIIF)V", SDL_JAVA_INTERFACE(nativeSetScreenResolution) }, - { "onNativeResize", "()V", SDL_JAVA_INTERFACE(onNativeResize) }, - { "onNativeSurfaceCreated", "()V", SDL_JAVA_INTERFACE(onNativeSurfaceCreated) }, - { "onNativeSurfaceChanged", "()V", SDL_JAVA_INTERFACE(onNativeSurfaceChanged) }, - { "onNativeSurfaceDestroyed", "()V", SDL_JAVA_INTERFACE(onNativeSurfaceDestroyed) }, - { "onNativeKeyDown", "(I)V", SDL_JAVA_INTERFACE(onNativeKeyDown) }, - { "onNativeKeyUp", "(I)V", SDL_JAVA_INTERFACE(onNativeKeyUp) }, - { "onNativeSoftReturnKey", "()Z", SDL_JAVA_INTERFACE(onNativeSoftReturnKey) }, - { "onNativeKeyboardFocusLost", "()V", SDL_JAVA_INTERFACE(onNativeKeyboardFocusLost) }, - { "onNativeTouch", "(IIIFFF)V", SDL_JAVA_INTERFACE(onNativeTouch) }, - { "onNativeMouse", "(IIFFZ)V", SDL_JAVA_INTERFACE(onNativeMouse) }, - { "onNativeAccel", "(FFF)V", SDL_JAVA_INTERFACE(onNativeAccel) }, - { "onNativeClipboardChanged", "()V", SDL_JAVA_INTERFACE(onNativeClipboardChanged) }, - { "nativeLowMemory", "()V", SDL_JAVA_INTERFACE(nativeLowMemory) }, - { "onNativeLocaleChanged", "()V", SDL_JAVA_INTERFACE(onNativeLocaleChanged) }, - { "nativeSendQuit", "()V", SDL_JAVA_INTERFACE(nativeSendQuit) }, - { "nativeQuit", "()V", SDL_JAVA_INTERFACE(nativeQuit) }, - { "nativePause", "()V", SDL_JAVA_INTERFACE(nativePause) }, - { "nativeResume", "()V", SDL_JAVA_INTERFACE(nativeResume) }, - { "nativeFocusChanged", "(Z)V", SDL_JAVA_INTERFACE(nativeFocusChanged) }, - { "nativeGetHint", "(Ljava/lang/String;)Ljava/lang/String;", SDL_JAVA_INTERFACE(nativeGetHint) }, - { "nativeGetHintBoolean", "(Ljava/lang/String;Z)Z", SDL_JAVA_INTERFACE(nativeGetHintBoolean) }, - { "nativeSetenv", "(Ljava/lang/String;Ljava/lang/String;)V", SDL_JAVA_INTERFACE(nativeSetenv) }, + { "nativeGetVersion", "()Ljava/lang/String;", SDL_JAVA_INTERFACE(nativeGetVersion) }, + { "nativeSetupJNI", "()I", SDL_JAVA_INTERFACE(nativeSetupJNI) }, + { "nativeRunMain", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;)I", SDL_JAVA_INTERFACE(nativeRunMain) }, + { "onNativeDropFile", "(Ljava/lang/String;)V", SDL_JAVA_INTERFACE(onNativeDropFile) }, + { "nativeSetScreenResolution", "(IIIIF)V", SDL_JAVA_INTERFACE(nativeSetScreenResolution) }, + { "onNativeResize", "()V", SDL_JAVA_INTERFACE(onNativeResize) }, + { "onNativeSurfaceCreated", "()V", SDL_JAVA_INTERFACE(onNativeSurfaceCreated) }, + { "onNativeSurfaceChanged", "()V", SDL_JAVA_INTERFACE(onNativeSurfaceChanged) }, + { "onNativeSurfaceDestroyed", "()V", SDL_JAVA_INTERFACE(onNativeSurfaceDestroyed) }, + { "onNativeKeyDown", "(I)V", SDL_JAVA_INTERFACE(onNativeKeyDown) }, + { "onNativeKeyUp", "(I)V", SDL_JAVA_INTERFACE(onNativeKeyUp) }, + { "onNativeSoftReturnKey", "()Z", SDL_JAVA_INTERFACE(onNativeSoftReturnKey) }, + { "onNativeKeyboardFocusLost", "()V", SDL_JAVA_INTERFACE(onNativeKeyboardFocusLost) }, + { "onNativeTouch", "(IIIFFF)V", SDL_JAVA_INTERFACE(onNativeTouch) }, + { "onNativeMouse", "(IIFFZ)V", SDL_JAVA_INTERFACE(onNativeMouse) }, + { "onNativeAccel", "(FFF)V", SDL_JAVA_INTERFACE(onNativeAccel) }, + { "onNativeClipboardChanged", "()V", SDL_JAVA_INTERFACE(onNativeClipboardChanged) }, + { "nativeLowMemory", "()V", SDL_JAVA_INTERFACE(nativeLowMemory) }, + { "onNativeLocaleChanged", "()V", SDL_JAVA_INTERFACE(onNativeLocaleChanged) }, + { "nativeSendQuit", "()V", SDL_JAVA_INTERFACE(nativeSendQuit) }, + { "nativeQuit", "()V", SDL_JAVA_INTERFACE(nativeQuit) }, + { "nativePause", "()V", SDL_JAVA_INTERFACE(nativePause) }, + { "nativeResume", "()V", SDL_JAVA_INTERFACE(nativeResume) }, + { "nativeFocusChanged", "(Z)V", SDL_JAVA_INTERFACE(nativeFocusChanged) }, + { "nativeGetHint", "(Ljava/lang/String;)Ljava/lang/String;", SDL_JAVA_INTERFACE(nativeGetHint) }, + { "nativeGetHintBoolean", "(Ljava/lang/String;Z)Z", SDL_JAVA_INTERFACE(nativeGetHintBoolean) }, + { "nativeSetenv", "(Ljava/lang/String;Ljava/lang/String;)V", SDL_JAVA_INTERFACE(nativeSetenv) }, { "onNativeOrientationChanged", "(I)V", SDL_JAVA_INTERFACE(onNativeOrientationChanged) }, - { "nativeAddTouch", "(ILjava/lang/String;)V", SDL_JAVA_INTERFACE(nativeAddTouch) }, - { "nativePermissionResult", "(IZ)V", SDL_JAVA_INTERFACE(nativePermissionResult) } + { "nativeAddTouch", "(ILjava/lang/String;)V", SDL_JAVA_INTERFACE(nativeAddTouch) }, + { "nativePermissionResult", "(IZ)V", SDL_JAVA_INTERFACE(nativePermissionResult) } }; /* Java class SDLInputConnection */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeCommitText)( - JNIEnv *env, jclass cls, - jstring text, jint newCursorPosition); + JNIEnv *env, jclass cls, + jstring text, jint newCursorPosition); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeGenerateScancodeForUnichar)( - JNIEnv *env, jclass cls, - jchar chUnicode); + JNIEnv *env, jclass cls, + jchar chUnicode); static JNINativeMethod SDLInputConnection_tab[] = { - { "nativeCommitText", "(Ljava/lang/String;I)V", SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeCommitText) }, - { "nativeGenerateScancodeForUnichar", "(C)V", SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeGenerateScancodeForUnichar) } + { "nativeCommitText", "(Ljava/lang/String;I)V", SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeCommitText) }, + { "nativeGenerateScancodeForUnichar", "(C)V", SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeGenerateScancodeForUnichar) } }; /* Java class SDLAudioManager */ JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI)( - JNIEnv *env, jclass jcls); + JNIEnv *env, jclass jcls); static JNINativeMethod SDLAudioManager_tab[] = { { "nativeSetupJNI", "()I", SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI) } @@ -227,54 +227,53 @@ static JNINativeMethod SDLAudioManager_tab[] = { /* Java class SDLControllerManager */ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)( - JNIEnv *env, jclass jcls); + JNIEnv *env, jclass jcls); JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)( - JNIEnv *env, jclass jcls, - jint device_id, jint keycode); + JNIEnv *env, jclass jcls, + jint device_id, jint keycode); JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)( - JNIEnv *env, jclass jcls, - jint device_id, jint keycode); + JNIEnv *env, jclass jcls, + jint device_id, jint keycode); JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeJoy)( - JNIEnv *env, jclass jcls, - jint device_id, jint axis, jfloat value); + JNIEnv *env, jclass jcls, + jint device_id, jint axis, jfloat value); JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat)( - JNIEnv *env, jclass jcls, - jint device_id, jint hat_id, jint x, jint y); + JNIEnv *env, jclass jcls, + jint device_id, jint hat_id, jint x, jint y); JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)( - JNIEnv *env, jclass jcls, - jint device_id, jstring device_name, jstring device_desc, jint vendor_id, jint product_id, - jboolean is_accelerometer, jint button_mask, jint naxes, jint nhats, jint nballs); + JNIEnv *env, jclass jcls, + jint device_id, jstring device_name, jstring device_desc, jint vendor_id, jint product_id, + jboolean is_accelerometer, jint button_mask, jint naxes, jint nhats, jint nballs); JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick)( - JNIEnv *env, jclass jcls, - jint device_id); + JNIEnv *env, jclass jcls, + jint device_id); JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)( - JNIEnv *env, jclass jcls, - jint device_id, jstring device_name); + JNIEnv *env, jclass jcls, + jint device_id, jstring device_name); JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic)( - JNIEnv *env, jclass jcls, - jint device_id); + JNIEnv *env, jclass jcls, + jint device_id); static JNINativeMethod SDLControllerManager_tab[] = { - { "nativeSetupJNI", "()I", SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI) }, - { "onNativePadDown", "(II)I", SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown) }, - { "onNativePadUp", "(II)I", SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp) }, - { "onNativeJoy", "(IIF)V", SDL_JAVA_CONTROLLER_INTERFACE(onNativeJoy) }, - { "onNativeHat", "(IIII)V", SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat) }, - { "nativeAddJoystick", "(ILjava/lang/String;Ljava/lang/String;IIZIIII)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick) }, - { "nativeRemoveJoystick", "(I)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick) }, - { "nativeAddHaptic", "(ILjava/lang/String;)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic) }, - { "nativeRemoveHaptic", "(I)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic) } + { "nativeSetupJNI", "()I", SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI) }, + { "onNativePadDown", "(II)I", SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown) }, + { "onNativePadUp", "(II)I", SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp) }, + { "onNativeJoy", "(IIF)V", SDL_JAVA_CONTROLLER_INTERFACE(onNativeJoy) }, + { "onNativeHat", "(IIII)V", SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat) }, + { "nativeAddJoystick", "(ILjava/lang/String;Ljava/lang/String;IIZIIII)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick) }, + { "nativeRemoveJoystick", "(I)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick) }, + { "nativeAddHaptic", "(ILjava/lang/String;)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic) }, + { "nativeRemoveHaptic", "(I)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic) } }; - /* Uncomment this to log messages entering and exiting methods in this file */ /* #define DEBUG_JNI */ @@ -285,7 +284,6 @@ static void checkJNIReady(void); *******************************************************************************/ #include - /******************************************************************************* Globals *******************************************************************************/ @@ -396,8 +394,8 @@ static jobject javaAssetManagerRef = 0; */ /* Set local storage value */ -static int -Android_JNI_SetEnv(JNIEnv *env) { +static int Android_JNI_SetEnv(JNIEnv *env) +{ int status = pthread_setspecific(mThreadKey, env); if (status < 0) { __android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed pthread_setspecific() in Android_JNI_SetEnv() (err=%d)", status); @@ -406,7 +404,7 @@ Android_JNI_SetEnv(JNIEnv *env) { } /* Get local storage value */ -JNIEnv* Android_JNI_GetEnv(void) +JNIEnv *Android_JNI_GetEnv(void) { /* Get JNIEnv from the Thread local storage */ JNIEnv *env = pthread_getspecific(mThreadKey); @@ -466,11 +464,10 @@ int Android_JNI_SetupThread(void) } /* Destructor called for each thread where mThreadKey is not NULL */ -static void -Android_JNI_ThreadDestroyed(void *value) +static void Android_JNI_ThreadDestroyed(void *value) { /* The thread is being destroyed, detach it from the Java VM and set the mThreadKey value to NULL as required */ - JNIEnv *env = (JNIEnv *) value; + JNIEnv *env = (JNIEnv *)value; if (env != NULL) { (*mJavaVM)->DetachCurrentThread(mJavaVM); Android_JNI_SetEnv(NULL); @@ -478,8 +475,7 @@ Android_JNI_ThreadDestroyed(void *value) } /* Creation of local storage mThreadKey */ -static void -Android_JNI_CreateKey(void) +static void Android_JNI_CreateKey(void) { int status = pthread_key_create(&mThreadKey, Android_JNI_ThreadDestroyed); if (status < 0) { @@ -487,8 +483,7 @@ Android_JNI_CreateKey(void) } } -static void -Android_JNI_CreateKey_once(void) +static void Android_JNI_CreateKey_once(void) { int status = pthread_once(&key_once, Android_JNI_CreateKey); if (status < 0) { @@ -496,8 +491,7 @@ Android_JNI_CreateKey_once(void) } } -static void -register_methods(JNIEnv *env, const char *classname, JNINativeMethod *methods, int nb) +static void register_methods(JNIEnv *env, const char *classname, JNINativeMethod *methods, int nb) { jclass clazz = (*env)->FindClass(env, classname); if (clazz == NULL || (*env)->RegisterNatives(env, clazz, methods, nb) < 0) { @@ -575,7 +569,6 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl __android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to create Android_ActivityMutex mutex"); } - Android_PauseSem = SDL_CreateSemaphore(0); if (Android_PauseSem == NULL) { __android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to create Android_PauseSem semaphore"); @@ -593,30 +586,30 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl midClipboardSetText = (*env)->GetStaticMethodID(env, mActivityClass, "clipboardSetText", "(Ljava/lang/String;)V"); midCreateCustomCursor = (*env)->GetStaticMethodID(env, mActivityClass, "createCustomCursor", "([IIIII)I"); midDestroyCustomCursor = (*env)->GetStaticMethodID(env, mActivityClass, "destroyCustomCursor", "(I)V"); - midGetContext = (*env)->GetStaticMethodID(env, mActivityClass, "getContext","()Landroid/content/Context;"); + midGetContext = (*env)->GetStaticMethodID(env, mActivityClass, "getContext", "()Landroid/content/Context;"); midGetDisplayDPI = (*env)->GetStaticMethodID(env, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;"); midGetManifestEnvironmentVariables = (*env)->GetStaticMethodID(env, mActivityClass, "getManifestEnvironmentVariables", "()Z"); - midGetNativeSurface = (*env)->GetStaticMethodID(env, mActivityClass, "getNativeSurface","()Landroid/view/Surface;"); + midGetNativeSurface = (*env)->GetStaticMethodID(env, mActivityClass, "getNativeSurface", "()Landroid/view/Surface;"); midInitTouch = (*env)->GetStaticMethodID(env, mActivityClass, "initTouch", "()V"); - midIsAndroidTV = (*env)->GetStaticMethodID(env, mActivityClass, "isAndroidTV","()Z"); + midIsAndroidTV = (*env)->GetStaticMethodID(env, mActivityClass, "isAndroidTV", "()Z"); midIsChromebook = (*env)->GetStaticMethodID(env, mActivityClass, "isChromebook", "()Z"); midIsDeXMode = (*env)->GetStaticMethodID(env, mActivityClass, "isDeXMode", "()Z"); - midIsScreenKeyboardShown = (*env)->GetStaticMethodID(env, mActivityClass, "isScreenKeyboardShown","()Z"); + midIsScreenKeyboardShown = (*env)->GetStaticMethodID(env, mActivityClass, "isScreenKeyboardShown", "()Z"); midIsTablet = (*env)->GetStaticMethodID(env, mActivityClass, "isTablet", "()Z"); midManualBackButton = (*env)->GetStaticMethodID(env, mActivityClass, "manualBackButton", "()V"); - midMinimizeWindow = (*env)->GetStaticMethodID(env, mActivityClass, "minimizeWindow","()V"); + midMinimizeWindow = (*env)->GetStaticMethodID(env, mActivityClass, "minimizeWindow", "()V"); midOpenURL = (*env)->GetStaticMethodID(env, mActivityClass, "openURL", "(Ljava/lang/String;)I"); midRequestPermission = (*env)->GetStaticMethodID(env, mActivityClass, "requestPermission", "(Ljava/lang/String;I)V"); midShowToast = (*env)->GetStaticMethodID(env, mActivityClass, "showToast", "(Ljava/lang/String;IIII)I"); midSendMessage = (*env)->GetStaticMethodID(env, mActivityClass, "sendMessage", "(II)Z"); - midSetActivityTitle = (*env)->GetStaticMethodID(env, mActivityClass, "setActivityTitle","(Ljava/lang/String;)Z"); + midSetActivityTitle = (*env)->GetStaticMethodID(env, mActivityClass, "setActivityTitle", "(Ljava/lang/String;)Z"); midSetCustomCursor = (*env)->GetStaticMethodID(env, mActivityClass, "setCustomCursor", "(I)Z"); - midSetOrientation = (*env)->GetStaticMethodID(env, mActivityClass, "setOrientation","(IIZLjava/lang/String;)V"); + midSetOrientation = (*env)->GetStaticMethodID(env, mActivityClass, "setOrientation", "(IIZLjava/lang/String;)V"); midSetRelativeMouseEnabled = (*env)->GetStaticMethodID(env, mActivityClass, "setRelativeMouseEnabled", "(Z)Z"); midSetSystemCursor = (*env)->GetStaticMethodID(env, mActivityClass, "setSystemCursor", "(I)Z"); - midSetWindowStyle = (*env)->GetStaticMethodID(env, mActivityClass, "setWindowStyle","(Z)V"); - midShouldMinimizeOnFocusLoss = (*env)->GetStaticMethodID(env, mActivityClass, "shouldMinimizeOnFocusLoss","()Z"); - midShowTextInput = (*env)->GetStaticMethodID(env, mActivityClass, "showTextInput", "(IIII)Z"); + midSetWindowStyle = (*env)->GetStaticMethodID(env, mActivityClass, "setWindowStyle", "(Z)V"); + midShouldMinimizeOnFocusLoss = (*env)->GetStaticMethodID(env, mActivityClass, "shouldMinimizeOnFocusLoss", "()Z"); + midShowTextInput = (*env)->GetStaticMethodID(env, mActivityClass, "showTextInput", "(IIII)Z"); midSupportsRelativeMouse = (*env)->GetStaticMethodID(env, mActivityClass, "supportsRelativeMouse", "()Z"); if (!midClipboardGetText || @@ -663,30 +656,30 @@ JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI)(JNIEnv *env, jcl mAudioManagerClass = (jclass)((*env)->NewGlobalRef(env, cls)); midAudioOpen = (*env)->GetStaticMethodID(env, mAudioManagerClass, - "audioOpen", "(IIII)[I"); + "audioOpen", "(IIII)[I"); midAudioWriteByteBuffer = (*env)->GetStaticMethodID(env, mAudioManagerClass, - "audioWriteByteBuffer", "([B)V"); + "audioWriteByteBuffer", "([B)V"); midAudioWriteShortBuffer = (*env)->GetStaticMethodID(env, mAudioManagerClass, - "audioWriteShortBuffer", "([S)V"); + "audioWriteShortBuffer", "([S)V"); midAudioWriteFloatBuffer = (*env)->GetStaticMethodID(env, mAudioManagerClass, - "audioWriteFloatBuffer", "([F)V"); + "audioWriteFloatBuffer", "([F)V"); midAudioClose = (*env)->GetStaticMethodID(env, mAudioManagerClass, - "audioClose", "()V"); + "audioClose", "()V"); midCaptureOpen = (*env)->GetStaticMethodID(env, mAudioManagerClass, - "captureOpen", "(IIII)[I"); + "captureOpen", "(IIII)[I"); midCaptureReadByteBuffer = (*env)->GetStaticMethodID(env, mAudioManagerClass, - "captureReadByteBuffer", "([BZ)I"); + "captureReadByteBuffer", "([BZ)I"); midCaptureReadShortBuffer = (*env)->GetStaticMethodID(env, mAudioManagerClass, - "captureReadShortBuffer", "([SZ)I"); + "captureReadShortBuffer", "([SZ)I"); midCaptureReadFloatBuffer = (*env)->GetStaticMethodID(env, mAudioManagerClass, - "captureReadFloatBuffer", "([FZ)I"); + "captureReadFloatBuffer", "([FZ)I"); midCaptureClose = (*env)->GetStaticMethodID(env, mAudioManagerClass, - "captureClose", "()V"); + "captureClose", "()V"); midAudioSetThreadPriority = (*env)->GetStaticMethodID(env, mAudioManagerClass, - "audioSetThreadPriority", "(ZI)V"); + "audioSetThreadPriority", "(ZI)V"); if (!midAudioOpen || !midAudioWriteByteBuffer || !midAudioWriteShortBuffer || !midAudioWriteFloatBuffer || !midAudioClose || - !midCaptureOpen || !midCaptureReadByteBuffer || !midCaptureReadShortBuffer || !midCaptureReadFloatBuffer || !midCaptureClose || !midAudioSetThreadPriority) { + !midCaptureOpen || !midCaptureReadByteBuffer || !midCaptureReadShortBuffer || !midCaptureReadFloatBuffer || !midCaptureClose || !midAudioSetThreadPriority) { __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLAudioManager.java?"); } @@ -701,13 +694,13 @@ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)(JNIEnv *env mControllerManagerClass = (jclass)((*env)->NewGlobalRef(env, cls)); midPollInputDevices = (*env)->GetStaticMethodID(env, mControllerManagerClass, - "pollInputDevices", "()V"); + "pollInputDevices", "()V"); midPollHapticDevices = (*env)->GetStaticMethodID(env, mControllerManagerClass, - "pollHapticDevices", "()V"); + "pollHapticDevices", "()V"); midHapticRun = (*env)->GetStaticMethodID(env, mControllerManagerClass, - "hapticRun", "(IFI)V"); + "hapticRun", "(IFI)V"); midHapticStop = (*env)->GetStaticMethodID(env, mControllerManagerClass, - "hapticStop", "(I)V"); + "hapticStop", "(I)V"); if (!midPollInputDevices || !midPollHapticDevices || !midHapticRun || !midHapticStop) { __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLControllerManager.java?"); @@ -759,7 +752,7 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv *env, jclass cls, /* Prepare the arguments. */ len = (*env)->GetArrayLength(env, array); - argv = SDL_small_alloc(char *, 1 + len + 1, &isstack); /* !!! FIXME: check for NULL */ + argv = SDL_small_alloc(char *, 1 + len + 1, &isstack); /* !!! FIXME: check for NULL */ argc = 0; /* Use the name "app_process" so PHYSFS_platformCalcBaseDir() works. https://bitbucket.org/MartinFelis/love-android-sdl2/issue/23/release-build-crash-on-start @@ -784,7 +777,6 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv *env, jclass cls, } argv[argc] = NULL; - /* Run the application. */ status = SDL_main(argc, argv); @@ -818,8 +810,8 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv *env, jclass cls, /* Drop file */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)( - JNIEnv *env, jclass jcls, - jstring filename) + JNIEnv *env, jclass jcls, + jstring filename) { const char *path = (*env)->GetStringUTFChars(env, filename, NULL); SDL_SendDropFile(NULL, path); @@ -828,16 +820,19 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)( } /* Lock / Unlock Mutex */ -void Android_ActivityMutex_Lock() { +void Android_ActivityMutex_Lock() +{ SDL_LockMutex(Android_ActivityMutex); } -void Android_ActivityMutex_Unlock() { +void Android_ActivityMutex_Unlock() +{ SDL_UnlockMutex(Android_ActivityMutex); } /* Lock the Mutex when the Activity is in its 'Running' state */ -void Android_ActivityMutex_Lock_Running() { +void Android_ActivityMutex_Lock_Running() +{ int pauseSignaled = 0; int resumeSignaled = 0; @@ -857,9 +852,9 @@ retry: /* Set screen resolution */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetScreenResolution)( - JNIEnv *env, jclass jcls, - jint surfaceWidth, jint surfaceHeight, - jint deviceWidth, jint deviceHeight, jfloat rate) + JNIEnv *env, jclass jcls, + jint surfaceWidth, jint surfaceHeight, + jint deviceWidth, jint deviceHeight, jfloat rate) { SDL_LockMutex(Android_ActivityMutex); @@ -870,7 +865,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetScreenResolution)( /* Resize */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeResize)( - JNIEnv *env, jclass jcls) + JNIEnv *env, jclass jcls) { SDL_LockMutex(Android_ActivityMutex); @@ -882,8 +877,8 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeResize)( } JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeOrientationChanged)( - JNIEnv *env, jclass jcls, - jint orientation) + JNIEnv *env, jclass jcls, + jint orientation) { SDL_LockMutex(Android_ActivityMutex); @@ -898,19 +893,19 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeOrientationChanged)( } JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeAddTouch)( - JNIEnv* env, jclass cls, - jint touchId, jstring name) + JNIEnv *env, jclass cls, + jint touchId, jstring name) { const char *utfname = (*env)->GetStringUTFChars(env, name, NULL); - SDL_AddTouch((SDL_TouchID) touchId, SDL_TOUCH_DEVICE_DIRECT, utfname); + SDL_AddTouch((SDL_TouchID)touchId, SDL_TOUCH_DEVICE_DIRECT, utfname); (*env)->ReleaseStringUTFChars(env, name, utfname); } JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePermissionResult)( - JNIEnv* env, jclass cls, - jint requestCode, jboolean result) + JNIEnv *env, jclass cls, + jint requestCode, jboolean result) { bPermissionRequestResult = result; SDL_AtomicSet(&bPermissionRequestPending, SDL_FALSE); @@ -918,42 +913,41 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePermissionResult)( /* Paddown */ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)( - JNIEnv *env, jclass jcls, - jint device_id, jint keycode) + JNIEnv *env, jclass jcls, + jint device_id, jint keycode) { return Android_OnPadDown(device_id, keycode); } /* Padup */ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)( - JNIEnv *env, jclass jcls, - jint device_id, jint keycode) + JNIEnv *env, jclass jcls, + jint device_id, jint keycode) { return Android_OnPadUp(device_id, keycode); } /* Joy */ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeJoy)( - JNIEnv *env, jclass jcls, - jint device_id, jint axis, jfloat value) + JNIEnv *env, jclass jcls, + jint device_id, jint axis, jfloat value) { Android_OnJoy(device_id, axis, value); } /* POV Hat */ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat)( - JNIEnv *env, jclass jcls, - jint device_id, jint hat_id, jint x, jint y) + JNIEnv *env, jclass jcls, + jint device_id, jint hat_id, jint x, jint y) { Android_OnHat(device_id, hat_id, x, y); } - JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)( - JNIEnv *env, jclass jcls, - jint device_id, jstring device_name, jstring device_desc, - jint vendor_id, jint product_id, jboolean is_accelerometer, - jint button_mask, jint naxes, jint nhats, jint nballs) + JNIEnv *env, jclass jcls, + jint device_id, jstring device_name, jstring device_desc, + jint vendor_id, jint product_id, jboolean is_accelerometer, + jint button_mask, jint naxes, jint nhats, jint nballs) { int retval; const char *name = (*env)->GetStringUTFChars(env, device_name, NULL); @@ -968,8 +962,8 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)( } JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick)( - JNIEnv *env, jclass jcls, - jint device_id) + JNIEnv *env, jclass jcls, + jint device_id) { return Android_RemoveJoystick(device_id); } @@ -999,7 +993,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceCreated)(JNIEnv *env, j SDL_LockMutex(Android_ActivityMutex); if (Android_Window) { - SDL_WindowData *data = (SDL_WindowData *) Android_Window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)Android_Window->driverdata; data->native_window = Android_JNI_GetNativeWindow(); if (data->native_window == NULL) { @@ -1018,11 +1012,11 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceChanged)(JNIEnv *env, j #if SDL_VIDEO_OPENGL_EGL if (Android_Window) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); - SDL_WindowData *data = (SDL_WindowData *) Android_Window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)Android_Window->driverdata; /* If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here */ if (data->egl_surface == EGL_NO_SURFACE) { - data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->native_window); + data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType)data->native_window); } /* GL Context handling is done in the event loop because this function is run from the Java thread */ @@ -1043,10 +1037,10 @@ retry: if (Android_Window) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); - SDL_WindowData *data = (SDL_WindowData *) Android_Window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)Android_Window->driverdata; /* Wait for Main thread being paused and context un-activated to release 'egl_surface' */ - if (! data->backup_done) { + if (!data->backup_done) { nb_attempt -= 1; if (nb_attempt == 0) { SDL_SetError("Try to release egl_surface with context probably still active"); @@ -1077,23 +1071,23 @@ retry: /* Keydown */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyDown)( - JNIEnv *env, jclass jcls, - jint keycode) + JNIEnv *env, jclass jcls, + jint keycode) { Android_OnKeyDown(keycode); } /* Keyup */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyUp)( - JNIEnv *env, jclass jcls, - jint keycode) + JNIEnv *env, jclass jcls, + jint keycode) { Android_OnKeyUp(keycode); } /* Virtual keyboard return key might stop text input */ JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE(onNativeSoftReturnKey)( - JNIEnv *env, jclass jcls) + JNIEnv *env, jclass jcls) { if (SDL_GetHintBoolean(SDL_HINT_RETURN_KEY_HIDES_IME, SDL_FALSE)) { SDL_StopTextInput(); @@ -1104,18 +1098,17 @@ JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE(onNativeSoftReturnKey)( /* Keyboard Focus Lost */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyboardFocusLost)( - JNIEnv *env, jclass jcls) + JNIEnv *env, jclass jcls) { /* Calling SDL_StopTextInput will take care of hiding the keyboard and cleaning up the DummyText widget */ SDL_StopTextInput(); } - /* Touch */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeTouch)( - JNIEnv *env, jclass jcls, - jint touch_device_id_in, jint pointer_finger_id_in, - jint action, jfloat x, jfloat y, jfloat p) + JNIEnv *env, jclass jcls, + jint touch_device_id_in, jint pointer_finger_id_in, + jint action, jfloat x, jfloat y, jfloat p) { SDL_LockMutex(Android_ActivityMutex); @@ -1126,8 +1119,8 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeTouch)( /* Mouse */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeMouse)( - JNIEnv *env, jclass jcls, - jint button, jint action, jfloat x, jfloat y, jboolean relative) + JNIEnv *env, jclass jcls, + jint button, jint action, jfloat x, jfloat y, jboolean relative) { SDL_LockMutex(Android_ActivityMutex); @@ -1138,8 +1131,8 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeMouse)( /* Accelerometer */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)( - JNIEnv *env, jclass jcls, - jfloat x, jfloat y, jfloat z) + JNIEnv *env, jclass jcls, + jfloat x, jfloat y, jfloat z) { fLastAccelerometer[0] = x; fLastAccelerometer[1] = y; @@ -1149,14 +1142,14 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)( /* Clipboard */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeClipboardChanged)( - JNIEnv *env, jclass jcls) + JNIEnv *env, jclass jcls) { SDL_SendClipboardUpdate(); } /* Low memory */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeLowMemory)( - JNIEnv *env, jclass cls) + JNIEnv *env, jclass cls) { SDL_SendAppEvent(SDL_APP_LOWMEMORY); } @@ -1164,15 +1157,14 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeLowMemory)( /* Locale * requires android:configChanges="layoutDirection|locale" in AndroidManifest.xml */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeLocaleChanged)( - JNIEnv *env, jclass cls) + JNIEnv *env, jclass cls) { SDL_SendAppEvent(SDL_LOCALECHANGED); } - /* Send Quit event to "SDLThread" thread */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSendQuit)( - JNIEnv *env, jclass cls) + JNIEnv *env, jclass cls) { /* Discard previous events. The user should have handled state storage * in SDL_APP_WILLENTERBACKGROUND. After nativeSendQuit() is called, no @@ -1192,7 +1184,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSendQuit)( /* Activity ends */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)( - JNIEnv *env, jclass cls) + JNIEnv *env, jclass cls) { const char *str; @@ -1223,7 +1215,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)( /* Pause */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)( - JNIEnv *env, jclass cls) + JNIEnv *env, jclass cls) { __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativePause()"); @@ -1234,7 +1226,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)( /* Resume */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeResume)( - JNIEnv *env, jclass cls) + JNIEnv *env, jclass cls) { __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativeResume()"); @@ -1246,7 +1238,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeResume)( } JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeFocusChanged)( - JNIEnv *env, jclass cls, jboolean hasFocus) + JNIEnv *env, jclass cls, jboolean hasFocus) { SDL_LockMutex(Android_ActivityMutex); @@ -1259,8 +1251,8 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeFocusChanged)( } JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeCommitText)( - JNIEnv *env, jclass cls, - jstring text, jint newCursorPosition) + JNIEnv *env, jclass cls, + jstring text, jint newCursorPosition) { const char *utftext = (*env)->GetStringUTFChars(env, text, NULL); @@ -1270,15 +1262,15 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeCommitText)( } JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeGenerateScancodeForUnichar)( - JNIEnv *env, jclass cls, - jchar chUnicode) + JNIEnv *env, jclass cls, + jchar chUnicode) { SDL_SendKeyboardUnicodeKey(chUnicode); } JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetHint)( - JNIEnv *env, jclass cls, - jstring name) + JNIEnv *env, jclass cls, + jstring name) { const char *utfname = (*env)->GetStringUTFChars(env, name, NULL); const char *hint = SDL_GetHint(utfname); @@ -1290,8 +1282,8 @@ JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetHint)( } JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE(nativeGetHintBoolean)( - JNIEnv *env, jclass cls, - jstring name, jboolean default_value) + JNIEnv *env, jclass cls, + jstring name, jboolean default_value) { jboolean result; @@ -1303,8 +1295,8 @@ JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE(nativeGetHintBoolean)( } JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetenv)( - JNIEnv *env, jclass cls, - jstring name, jstring value) + JNIEnv *env, jclass cls, + jstring name, jstring value) { const char *utfname = (*env)->GetStringUTFChars(env, name, NULL); const char *utfvalue = (*env)->GetStringUTFChars(env, value, NULL); @@ -1313,7 +1305,6 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetenv)( (*env)->ReleaseStringUTFChars(env, name, utfname); (*env)->ReleaseStringUTFChars(env, value, utfvalue); - } /******************************************************************************* @@ -1362,7 +1353,7 @@ static void LocalReferenceHolder_Cleanup(struct LocalReferenceHolder *refholder) } } -ANativeWindow* Android_JNI_GetNativeWindow(void) +ANativeWindow *Android_JNI_GetNativeWindow(void) { ANativeWindow *anw = NULL; jobject s; @@ -1397,7 +1388,7 @@ void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint) JNIEnv *env = Android_JNI_GetEnv(); jstring jhint = (*env)->NewStringUTF(env, (hint ? hint : "")); - (*env)->CallStaticVoidMethod(env, mActivityClass, midSetOrientation, w, h, (resizable? 1 : 0), jhint); + (*env)->CallStaticVoidMethod(env, mActivityClass, midSetOrientation, w, h, (resizable ? 1 : 0), jhint); (*env)->DeleteLocalRef(env, jhint); } @@ -1503,32 +1494,29 @@ int Android_JNI_OpenAudioDevice(int iscapture, SDL_AudioSpec *spec) * Android >= 4.2 due to a "stale global reference" error. So now we allocate this buffer directly from this side. */ switch (audioformat) { case ENCODING_PCM_8BIT: - { - jbyteArray audioBufferLocal = (*env)->NewByteArray(env, spec->samples * spec->channels); - if (audioBufferLocal) { - jbufobj = (*env)->NewGlobalRef(env, audioBufferLocal); - (*env)->DeleteLocalRef(env, audioBufferLocal); - } + { + jbyteArray audioBufferLocal = (*env)->NewByteArray(env, spec->samples * spec->channels); + if (audioBufferLocal) { + jbufobj = (*env)->NewGlobalRef(env, audioBufferLocal); + (*env)->DeleteLocalRef(env, audioBufferLocal); } - break; + } break; case ENCODING_PCM_16BIT: - { - jshortArray audioBufferLocal = (*env)->NewShortArray(env, spec->samples * spec->channels); - if (audioBufferLocal) { - jbufobj = (*env)->NewGlobalRef(env, audioBufferLocal); - (*env)->DeleteLocalRef(env, audioBufferLocal); - } + { + jshortArray audioBufferLocal = (*env)->NewShortArray(env, spec->samples * spec->channels); + if (audioBufferLocal) { + jbufobj = (*env)->NewGlobalRef(env, audioBufferLocal); + (*env)->DeleteLocalRef(env, audioBufferLocal); } - break; + } break; case ENCODING_PCM_FLOAT: - { - jfloatArray audioBufferLocal = (*env)->NewFloatArray(env, spec->samples * spec->channels); - if (audioBufferLocal) { - jbufobj = (*env)->NewGlobalRef(env, audioBufferLocal); - (*env)->DeleteLocalRef(env, audioBufferLocal); - } + { + jfloatArray audioBufferLocal = (*env)->NewFloatArray(env, spec->samples * spec->channels); + if (audioBufferLocal) { + jbufobj = (*env)->NewGlobalRef(env, audioBufferLocal); + (*env)->DeleteLocalRef(env, audioBufferLocal); } - break; + } break; default: return SDL_SetError("Unexpected audio format from Java: %d\n", audioformat); } @@ -1586,7 +1574,6 @@ int Android_JNI_GetDisplayDPI(float *ddpi, float *xdpi, float *ydpi) float nativeYdpi = (*env)->GetFloatField(env, jDisplayObj, fidYdpi); int nativeDdpi = (*env)->GetIntField(env, jDisplayObj, fidDdpi); - (*env)->DeleteLocalRef(env, jDisplayObj); (*env)->DeleteLocalRef(env, jDisplayClass); @@ -1603,7 +1590,7 @@ int Android_JNI_GetDisplayDPI(float *ddpi, float *xdpi, float *ydpi) return 0; } -void * Android_JNI_GetAudioBuffer(void) +void *Android_JNI_GetAudioBuffer(void) { return audioBufferPinned; } @@ -1679,7 +1666,7 @@ int Android_JNI_CaptureAudioBuffer(void *buffer, int buflen) void Android_JNI_FlushCapturedAudio(void) { JNIEnv *env = Android_JNI_GetEnv(); -#if 0 /* !!! FIXME: this needs API 23, or it'll do blocking reads and never end. */ +#if 0 /* !!! FIXME: this needs API 23, or it'll do blocking reads and never end. */ switch (captureBufferFormat) { case ENCODING_PCM_8BIT: { @@ -1795,7 +1782,8 @@ static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent) return SDL_FALSE; } -static void Internal_Android_Create_AssetManager() { +static void Internal_Android_Create_AssetManager() +{ struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); JNIEnv *env = Android_JNI_GetEnv(); @@ -1813,7 +1801,7 @@ static void Internal_Android_Create_AssetManager() { /* javaAssetManager = context.getAssets(); */ mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context), - "getAssets", "()Landroid/content/res/AssetManager;"); + "getAssets", "()Landroid/content/res/AssetManager;"); javaAssetManager = (*env)->CallObjectMethod(env, context, mid); /** @@ -1833,7 +1821,8 @@ static void Internal_Android_Create_AssetManager() { LocalReferenceHolder_Cleanup(&refs); } -static void Internal_Android_Destroy_AssetManager() { +static void Internal_Android_Destroy_AssetManager() +{ JNIEnv *env = Android_JNI_GetEnv(); if (asset_manager) { @@ -1843,7 +1832,7 @@ static void Internal_Android_Destroy_AssetManager() { } int Android_JNI_FileOpen(SDL_RWops *ctx, - const char *fileName, const char *mode) + const char *fileName, const char *mode) { AAsset *asset = NULL; ctx->hidden.androidio.asset = NULL; @@ -1861,16 +1850,15 @@ int Android_JNI_FileOpen(SDL_RWops *ctx, return -1; } - - ctx->hidden.androidio.asset = (void*) asset; + ctx->hidden.androidio.asset = (void *)asset; return 0; } -size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer, - size_t size, size_t maxnum) +size_t Android_JNI_FileRead(SDL_RWops *ctx, void *buffer, + size_t size, size_t maxnum) { size_t result; - AAsset *asset = (AAsset*) ctx->hidden.androidio.asset; + AAsset *asset = (AAsset *)ctx->hidden.androidio.asset; result = AAsset_read(asset, buffer, size * maxnum); if (result > 0) { @@ -1883,7 +1871,7 @@ size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer, } size_t Android_JNI_FileWrite(SDL_RWops *ctx, const void *buffer, - size_t size, size_t num) + size_t size, size_t num) { SDL_SetError("Cannot write to Android package filesystem"); return 0; @@ -1892,22 +1880,22 @@ size_t Android_JNI_FileWrite(SDL_RWops *ctx, const void *buffer, Sint64 Android_JNI_FileSize(SDL_RWops *ctx) { off64_t result; - AAsset *asset = (AAsset*) ctx->hidden.androidio.asset; + AAsset *asset = (AAsset *)ctx->hidden.androidio.asset; result = AAsset_getLength64(asset); return result; } -Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence) +Sint64 Android_JNI_FileSeek(SDL_RWops *ctx, Sint64 offset, int whence) { off64_t result; - AAsset *asset = (AAsset*) ctx->hidden.androidio.asset; + AAsset *asset = (AAsset *)ctx->hidden.androidio.asset; result = AAsset_seek64(asset, offset, whence); return result; } int Android_JNI_FileClose(SDL_RWops *ctx) { - AAsset *asset = (AAsset*) ctx->hidden.androidio.asset; + AAsset *asset = (AAsset *)ctx->hidden.androidio.asset; AAsset_close(asset); return 0; } @@ -1921,7 +1909,7 @@ int Android_JNI_SetClipboardText(const char *text) return 0; } -char* Android_JNI_GetClipboardText(void) +char *Android_JNI_GetClipboardText(void) { JNIEnv *env = Android_JNI_GetEnv(); char *text = NULL; @@ -1970,7 +1958,6 @@ int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seco return -1; } - /* context = SDLActivity.getContext(); */ context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext); @@ -1993,18 +1980,18 @@ int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seco imid = (*env)->GetMethodID(env, cls, "getIntExtra", "(Ljava/lang/String;I)I"); /* Watch out for C89 scoping rules because of the macro */ -#define GET_INT_EXTRA(var, key) \ - int var; \ - iname = (*env)->NewStringUTF(env, key); \ +#define GET_INT_EXTRA(var, key) \ + int var; \ + iname = (*env)->NewStringUTF(env, key); \ (var) = (*env)->CallIntMethod(env, intent, imid, iname, -1); \ (*env)->DeleteLocalRef(env, iname); bmid = (*env)->GetMethodID(env, cls, "getBooleanExtra", "(Ljava/lang/String;Z)Z"); /* Watch out for C89 scoping rules because of the macro */ -#define GET_BOOL_EXTRA(var, key) \ - int var; \ - bname = (*env)->NewStringUTF(env, key); \ +#define GET_BOOL_EXTRA(var, key) \ + int var; \ + bname = (*env)->NewStringUTF(env, key); \ (var) = (*env)->CallBooleanMethod(env, intent, bmid, bname, JNI_FALSE); \ (*env)->DeleteLocalRef(env, bname); @@ -2069,8 +2056,9 @@ int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seco } /* Add all touch devices */ -void Android_JNI_InitTouch() { - JNIEnv *env = Android_JNI_GetEnv(); +void Android_JNI_InitTouch() +{ + JNIEnv *env = Android_JNI_GetEnv(); (*env)->CallStaticVoidMethod(env, mActivityClass, midInitTouch); } @@ -2099,8 +2087,7 @@ void Android_JNI_HapticStop(int device_id) } /* See SDLActivity.java for constants. */ -#define COMMAND_SET_KEEP_SCREEN_ON 5 - +#define COMMAND_SET_KEEP_SCREEN_ON 5 int SDL_AndroidSendMessage(Uint32 command, int param) { @@ -2128,10 +2115,10 @@ void Android_JNI_ShowTextInput(SDL_Rect *inputRect) { JNIEnv *env = Android_JNI_GetEnv(); (*env)->CallStaticBooleanMethod(env, mActivityClass, midShowTextInput, - inputRect->x, - inputRect->y, - inputRect->w, - inputRect->h ); + inputRect->x, + inputRect->y, + inputRect->w, + inputRect->h); } void Android_JNI_HideTextInput(void) @@ -2149,7 +2136,6 @@ SDL_bool Android_JNI_IsScreenKeyboardShown(void) return is_shown; } - int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { JNIEnv *env; @@ -2178,7 +2164,7 @@ int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *bu button_flags = (*env)->NewIntArray(env, messageboxdata->numbuttons); button_ids = (*env)->NewIntArray(env, messageboxdata->numbuttons); button_texts = (*env)->NewObjectArray(env, messageboxdata->numbuttons, - clazz, NULL); + clazz, NULL); for (i = 0; i < messageboxdata->numbuttons; ++i) { const SDL_MessageBoxButtonData *sdlButton; @@ -2218,15 +2204,15 @@ int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *bu clazz = (*env)->GetObjectClass(env, context); mid = (*env)->GetMethodID(env, clazz, - "messageboxShowMessageBox", "(ILjava/lang/String;Ljava/lang/String;[I[I[Ljava/lang/String;[I)I"); + "messageboxShowMessageBox", "(ILjava/lang/String;Ljava/lang/String;[I[I[Ljava/lang/String;[I)I"); *buttonid = (*env)->CallIntMethod(env, context, mid, - messageboxdata->flags, - title, - message, - button_flags, - button_ids, - button_texts, - colors); + messageboxdata->flags, + title, + message, + button_flags, + button_ids, + button_texts, + colors); (*env)->DeleteLocalRef(env, context); (*env)->DeleteLocalRef(env, clazz); @@ -2272,7 +2258,7 @@ int SDL_GetAndroidSDKVersion(void) { static int sdk_version; if (!sdk_version) { - char sdk[PROP_VALUE_MAX] = {0}; + char sdk[PROP_VALUE_MAX] = { 0 }; if (__system_property_get("ro.build.version.sdk", sdk) != 0) { sdk_version = SDL_atoi(sdk); } @@ -2310,7 +2296,7 @@ void SDL_AndroidBackButton(void) (*env)->CallStaticVoidMethod(env, mActivityClass, midManualBackButton); } -const char * SDL_AndroidGetInternalStoragePath(void) +const char *SDL_AndroidGetInternalStoragePath(void) { static char *s_AndroidInternalFilesPath = NULL; @@ -2338,7 +2324,7 @@ const char * SDL_AndroidGetInternalStoragePath(void) /* fileObj = context.getFilesDir(); */ mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context), - "getFilesDir", "()Ljava/io/File;"); + "getFilesDir", "()Ljava/io/File;"); fileObject = (*env)->CallObjectMethod(env, context, mid); if (!fileObject) { SDL_SetError("Couldn't get internal directory"); @@ -2348,7 +2334,7 @@ const char * SDL_AndroidGetInternalStoragePath(void) /* path = fileObject.getCanonicalPath(); */ mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, fileObject), - "getCanonicalPath", "()Ljava/lang/String;"); + "getCanonicalPath", "()Ljava/lang/String;"); pathString = (jstring)(*env)->CallObjectMethod(env, fileObject, mid); if (Android_JNI_ExceptionOccurred(SDL_FALSE)) { LocalReferenceHolder_Cleanup(&refs); @@ -2381,7 +2367,7 @@ int SDL_AndroidGetExternalStorageState(void) cls = (*env)->FindClass(env, "android/os/Environment"); mid = (*env)->GetStaticMethodID(env, cls, - "getExternalStorageState", "()Ljava/lang/String;"); + "getExternalStorageState", "()Ljava/lang/String;"); stateString = (jstring)(*env)->CallStaticObjectMethod(env, cls, mid); state = (*env)->GetStringUTFChars(env, stateString, NULL); @@ -2403,7 +2389,7 @@ int SDL_AndroidGetExternalStorageState(void) return stateFlags; } -const char * SDL_AndroidGetExternalStoragePath(void) +const char *SDL_AndroidGetExternalStoragePath(void) { static char *s_AndroidExternalFilesPath = NULL; @@ -2426,7 +2412,7 @@ const char * SDL_AndroidGetExternalStoragePath(void) /* fileObj = context.getExternalFilesDir(); */ mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context), - "getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;"); + "getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;"); fileObject = (*env)->CallObjectMethod(env, context, mid, NULL); if (!fileObject) { SDL_SetError("Couldn't get external directory"); @@ -2436,7 +2422,7 @@ const char * SDL_AndroidGetExternalStoragePath(void) /* path = fileObject.getAbsolutePath(); */ mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, fileObject), - "getAbsolutePath", "()Ljava/lang/String;"); + "getAbsolutePath", "()Ljava/lang/String;"); pathString = (jstring)(*env)->CallObjectMethod(env, fileObject, mid); path = (*env)->GetStringUTFChars(env, pathString, NULL); @@ -2453,7 +2439,7 @@ SDL_bool SDL_AndroidRequestPermission(const char *permission) return Android_JNI_RequestPermission(permission); } -int SDL_AndroidShowToast(const char* message, int duration, int gravity, int xOffset, int yOffset) +int SDL_AndroidShowToast(const char *message, int duration, int gravity, int xOffset, int yOffset) { return Android_JNI_ShowToast(message, duration, gravity, xOffset, yOffset); } @@ -2545,7 +2531,7 @@ SDL_bool Android_JNI_RequestPermission(const char *permission) } /* Show toast notification */ -int Android_JNI_ShowToast(const char* message, int duration, int gravity, int xOffset, int yOffset) +int Android_JNI_ShowToast(const char *message, int duration, int gravity, int xOffset, int yOffset) { int result = 0; JNIEnv *env = Android_JNI_GetEnv(); @@ -2603,7 +2589,7 @@ int Android_JNI_GetLocale(char *buf, size_t buflen) buf[id++] = country[1]; } } - + buf[id++] = '\0'; SDL_assert(id <= buflen); } @@ -2613,8 +2599,7 @@ int Android_JNI_GetLocale(char *buf, size_t buflen) return 0; } -int -Android_JNI_OpenURL(const char *url) +int Android_JNI_OpenURL(const char *url) { JNIEnv *env = Android_JNI_GetEnv(); jstring jurl = (*env)->NewStringUTF(env, url); diff --git a/src/core/android/SDL_android.h b/src/core/android/SDL_android.h index 0df411186..62ae65311 100644 --- a/src/core/android/SDL_android.h +++ b/src/core/android/SDL_android.h @@ -46,14 +46,14 @@ extern SDL_bool Android_JNI_GetAccelerometerValues(float values[3]); extern void Android_JNI_ShowTextInput(SDL_Rect *inputRect); extern void Android_JNI_HideTextInput(void); extern SDL_bool Android_JNI_IsScreenKeyboardShown(void); -extern ANativeWindow* Android_JNI_GetNativeWindow(void); +extern ANativeWindow *Android_JNI_GetNativeWindow(void); extern SDL_DisplayOrientation Android_JNI_GetDisplayOrientation(void); extern int Android_JNI_GetDisplayDPI(float *ddpi, float *xdpi, float *ydpi); /* Audio support */ extern int Android_JNI_OpenAudioDevice(int iscapture, SDL_AudioSpec *spec); -extern void* Android_JNI_GetAudioBuffer(void); +extern void *Android_JNI_GetAudioBuffer(void); extern void Android_JNI_WriteAudioBuffer(void); extern int Android_JNI_CaptureAudioBuffer(void *buffer, int buflen); extern void Android_JNI_FlushCapturedAudio(void); @@ -77,12 +77,12 @@ int Android_JNI_FileClose(SDL_RWops* ctx); void Android_JNI_GetManifestEnvironmentVariables(void); /* Clipboard support */ -int Android_JNI_SetClipboardText(const char* text); -char* Android_JNI_GetClipboardText(void); +int Android_JNI_SetClipboardText(const char *text); +char *Android_JNI_GetClipboardText(void); SDL_bool Android_JNI_HasClipboardText(void); /* Power support */ -int Android_JNI_GetPowerInfo(int* plugged, int* charged, int* battery, int* seconds, int* percent); +int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seconds, int *percent); /* Joystick support */ void Android_JNI_PollInputDevices(void); @@ -110,7 +110,7 @@ int Android_JNI_GetLocale(char *buf, size_t buflen); int Android_JNI_SendMessage(int command, int param); /* Init */ -JNIEXPORT void JNICALL SDL_Android_Init(JNIEnv* mEnv, jclass cls); +JNIEXPORT void JNICALL SDL_Android_Init(JNIEnv *mEnv, jclass cls); /* MessageBox */ #include "SDL_messagebox.h" @@ -130,7 +130,7 @@ SDL_bool Android_JNI_SetRelativeMouseEnabled(SDL_bool enabled); SDL_bool Android_JNI_RequestPermission(const char *permission); /* Show toast notification */ -int Android_JNI_ShowToast(const char* message, int duration, int gravity, int xOffset, int yOffset); +int Android_JNI_ShowToast(const char *message, int duration, int gravity, int xOffset, int yOffset); int Android_JNI_OpenURL(const char *url); diff --git a/src/core/freebsd/SDL_evdev_kbd_default_keyaccmap.h b/src/core/freebsd/SDL_evdev_kbd_default_keyaccmap.h index 909afad88..8cb7430ab 100644 --- a/src/core/freebsd/SDL_evdev_kbd_default_keyaccmap.h +++ b/src/core/freebsd/SDL_evdev_kbd_default_keyaccmap.h @@ -1,5 +1,6 @@ #include +/* *INDENT-OFF* */ /* clang-format off */ /* * Automatically generated from /usr/share/vt/keymaps/us.acc.kbd. * DO NOT EDIT! @@ -163,3 +164,4 @@ static accentmap_t accentmap_default_us_acc = { 11, { { 0x00 }, } }; +/* *INDENT-ON* */ /* clang-format on */ diff --git a/src/core/freebsd/SDL_evdev_kbd_freebsd.c b/src/core/freebsd/SDL_evdev_kbd_freebsd.c index b44656f2c..56f5d6fcb 100644 --- a/src/core/freebsd/SDL_evdev_kbd_freebsd.c +++ b/src/core/freebsd/SDL_evdev_kbd_freebsd.c @@ -39,7 +39,7 @@ #include "../../events/SDL_events_c.h" #include "SDL_evdev_kbd_default_keyaccmap.h" -typedef void (fn_handler_fn)(SDL_EVDEV_keyboard_state *kbd); +typedef void(fn_handler_fn)(SDL_EVDEV_keyboard_state *kbd); /* * Keyboard State @@ -51,14 +51,14 @@ struct SDL_EVDEV_keyboard_state int keyboard_fd; unsigned long old_kbd_mode; unsigned short **key_maps; - keymap_t* key_map; - keyboard_info_t* kbInfo; - unsigned char shift_down[4]; /* shift state counters.. */ + keymap_t *key_map; + keyboard_info_t *kbInfo; + unsigned char shift_down[4]; /* shift state counters.. */ SDL_bool dead_key_next; - int npadch; /* -1 or number assembled on pad */ + int npadch; /* -1 or number assembled on pad */ accentmap_t *accents; unsigned int diacr; - SDL_bool rep; /* flag telling character repeat */ + SDL_bool rep; /* flag telling character repeat */ unsigned char lockstate; unsigned char ledflagstate; char shift_state; @@ -71,24 +71,23 @@ static int SDL_EVDEV_kbd_load_keymaps(SDL_EVDEV_keyboard_state *kbd) return ioctl(kbd->keyboard_fd, GIO_KEYMAP, kbd->key_map) >= 0; } -static SDL_EVDEV_keyboard_state * kbd_cleanup_state = NULL; +static SDL_EVDEV_keyboard_state *kbd_cleanup_state = NULL; static int kbd_cleanup_sigactions_installed = 0; static int kbd_cleanup_atexit_installed = 0; static struct sigaction old_sigaction[NSIG]; -static int fatal_signals[] = -{ +static int fatal_signals[] = { /* Handlers for SIGTERM and SIGINT are installed in SDL_QuitInit. */ - SIGHUP, SIGQUIT, SIGILL, SIGABRT, - SIGFPE, SIGSEGV, SIGPIPE, SIGBUS, + SIGHUP, SIGQUIT, SIGILL, SIGABRT, + SIGFPE, SIGSEGV, SIGPIPE, SIGBUS, SIGSYS }; static void kbd_cleanup(void) { struct mouse_info mData; - SDL_EVDEV_keyboard_state* kbd = kbd_cleanup_state; + SDL_EVDEV_keyboard_state *kbd = kbd_cleanup_state; if (kbd == NULL) { return; } @@ -103,18 +102,17 @@ static void kbd_cleanup(void) ioctl(kbd->console_fd, CONS_MOUSECTL, &mData); } -void -SDL_EVDEV_kbd_reraise_signal(int sig) +void SDL_EVDEV_kbd_reraise_signal(int sig) { raise(sig); } -siginfo_t* SDL_EVDEV_kdb_cleanup_siginfo = NULL; -void* SDL_EVDEV_kdb_cleanup_ucontext = NULL; +siginfo_t *SDL_EVDEV_kdb_cleanup_siginfo = NULL; +void *SDL_EVDEV_kdb_cleanup_ucontext = NULL; -static void kbd_cleanup_signal_action(int signum, siginfo_t* info, void* ucontext) +static void kbd_cleanup_signal_action(int signum, siginfo_t *info, void *ucontext) { - struct sigaction* old_action_p = &(old_sigaction[signum]); + struct sigaction *old_action_p = &(old_sigaction[signum]); sigset_t sigset; /* Restore original signal handler before going any further. */ @@ -148,7 +146,7 @@ static void kbd_unregister_emerg_cleanup() kbd_cleanup_sigactions_installed = 0; for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) { - struct sigaction* old_action_p; + struct sigaction *old_action_p; struct sigaction cur_action; signum = fatal_signals[tabidx]; old_action_p = &(old_sigaction[signum]); @@ -177,7 +175,7 @@ static void kbd_cleanup_atexit(void) kbd_unregister_emerg_cleanup(); } -static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state * kbd) +static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd) { int tabidx, signum; @@ -201,9 +199,9 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state * kbd) kbd_cleanup_sigactions_installed = 1; for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) { - struct sigaction* old_action_p; + struct sigaction *old_action_p; struct sigaction new_action; - signum = fatal_signals[tabidx]; + signum = fatal_signals[tabidx]; old_action_p = &(old_sigaction[signum]); if (sigaction(signum, NULL, old_action_p)) { continue; @@ -212,7 +210,7 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state * kbd) /* Skip SIGHUP and SIGPIPE if handler is already installed * - assume the handler will do the cleanup */ - if ((signum == SIGHUP || signum == SIGPIPE) && (old_action_p->sa_handler != SIG_DFL || (void(*)(int))old_action_p->sa_sigaction != SIG_DFL)) { + if ((signum == SIGHUP || signum == SIGPIPE) && (old_action_p->sa_handler != SIG_DFL || (void (*)(int))old_action_p->sa_sigaction != SIG_DFL)) { continue; } @@ -229,7 +227,7 @@ SDL_EVDEV_kbd_init(void) SDL_EVDEV_keyboard_state *kbd; struct mouse_info mData; char flag_state; - char* devicePath; + char *devicePath; SDL_zero(mData); mData.operation = MOUSE_HIDE; @@ -247,15 +245,15 @@ SDL_EVDEV_kbd_init(void) kbd->accents = SDL_calloc(sizeof(accentmap_t), 1); kbd->key_map = SDL_calloc(sizeof(keymap_t), 1); - kbd->kbInfo = SDL_calloc(sizeof(keyboard_info_t), 1); + kbd->kbInfo = SDL_calloc(sizeof(keyboard_info_t), 1); ioctl(kbd->console_fd, KDGKBINFO, kbd->kbInfo); ioctl(kbd->console_fd, CONS_MOUSECTL, &mData); - + if (ioctl(kbd->console_fd, KDGKBSTATE, &flag_state) == 0) { kbd->ledflagstate = flag_state; } - + if (ioctl(kbd->console_fd, GIO_DEADKEYMAP, kbd->accents) < 0) { SDL_free(kbd->accents); kbd->accents = &accentmap_default_us_acc; @@ -289,14 +287,14 @@ SDL_EVDEV_kbd_init(void) kbd_register_emerg_cleanup(kbd); } SDL_free(devicePath); - } else kbd->keyboard_fd = kbd->console_fd; + } else + kbd->keyboard_fd = kbd->console_fd; } return kbd; } -void -SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd) +void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd) { struct mouse_info mData; @@ -330,7 +328,7 @@ SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd) static void put_queue(SDL_EVDEV_keyboard_state *kbd, uint c) { /* c is already part of a UTF-8 sequence and safe to add as a character */ - if (kbd->text_len < (sizeof(kbd->text)-1)) { + if (kbd->text_len < (sizeof(kbd->text) - 1)) { kbd->text[kbd->text_len++] = (char)c; } } @@ -381,12 +379,12 @@ static unsigned int handle_diacr(SDL_EVDEV_keyboard_state *kbd, unsigned int ch) for (i = 0; i < kbd->accents->n_accs; i++) { if (kbd->accents->acc[i].accchar == d) { for (j = 0; j < NUM_ACCENTCHARS; ++j) { - if (kbd->accents->acc[i].map[j][0] == 0) { /* end of table */ - break; - } - if (kbd->accents->acc[i].map[j][0] == ch) { - return kbd->accents->acc[i].map[j][1]; - } + if (kbd->accents->acc[i].map[j][0] == 0) { /* end of table */ + break; + } + if (kbd->accents->acc[i].map[j][0] == ch) { + return kbd->accents->acc[i].map[j][1]; + } } } } @@ -471,8 +469,7 @@ static void k_shift(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_ } } -void -SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, int down) +void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, int down) { keymap_t key_map; struct keyent_t keysym; @@ -526,7 +523,7 @@ SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, int d k_deadunicode(kbd, kbd->accents->acc[accent_index].accchar, !down); } } else { - switch(map_from_key_sym) { + switch (map_from_key_sym) { case ASH: /* alt/meta shift */ k_shift(kbd, 3, down == 0); break; diff --git a/src/core/gdk/SDL_gdk.cpp b/src/core/gdk/SDL_gdk.cpp index 11033ff7c..44880470b 100644 --- a/src/core/gdk/SDL_gdk.cpp +++ b/src/core/gdk/SDL_gdk.cpp @@ -39,16 +39,15 @@ PAPPSTATE_REGISTRATION hPLM = {}; HANDLE plmSuspendComplete = nullptr; extern "C" DECLSPEC int -SDL_GDKGetTaskQueue(XTaskQueueHandle * outTaskQueue) +SDL_GDKGetTaskQueue(XTaskQueueHandle *outTaskQueue) { /* If this is the first call, first create the global task queue. */ if (!GDK_GlobalTaskQueue) { HRESULT hr; hr = XTaskQueueCreate(XTaskQueueDispatchMode::ThreadPool, - XTaskQueueDispatchMode::Manual, - &GDK_GlobalTaskQueue - ); + XTaskQueueDispatchMode::Manual, + &GDK_GlobalTaskQueue); if (FAILED(hr)) { return SDL_SetError("[GDK] Could not create global task queue"); } @@ -88,7 +87,7 @@ OutOfMemory(void) /* Gets the arguments with GetCommandLine, converts them to argc and argv and calls SDL_main */ -extern "C" DECLSPEC int +extern "C" DECLSPEC int SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved) { LPWSTR *argvw; @@ -108,7 +107,7 @@ SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved) */ /* Parse it into argv and argc */ - argv = (char **) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (argc + 1) * sizeof(*argv)); + argv = (char **)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (argc + 1) * sizeof(*argv)); if (argv == NULL) { return OutOfMemory(); } @@ -118,8 +117,8 @@ SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved) if (arg == NULL) { return OutOfMemory(); } - len = (DWORD) SDL_strlen(arg); - argv[i] = (char *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len + 1); + len = (DWORD)SDL_strlen(arg); + argv[i] = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len + 1); if (!argv[i]) { return OutOfMemory(); } @@ -154,12 +153,11 @@ SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved) /* Register suspend/resume handling */ plmSuspendComplete = CreateEventEx(nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE); - if (!plmSuspendComplete ) { + if (!plmSuspendComplete) { SDL_SetError("[GDK] Unable to create plmSuspendComplete event"); return -1; } - auto rascn = [](BOOLEAN quiesced, PVOID context) - { + auto rascn = [](BOOLEAN quiesced, PVOID context) { SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "[GDK] in RegisterAppStateChangeNotification handler"); if (quiesced) { ResetEvent(plmSuspendComplete); @@ -214,7 +212,8 @@ SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved) } extern "C" DECLSPEC void -SDL_GDKSuspendComplete() { +SDL_GDKSuspendComplete() +{ if (plmSuspendComplete) { SetEvent(plmSuspendComplete); } diff --git a/src/core/linux/SDL_dbus.c b/src/core/linux/SDL_dbus.c index a35dc4aa1..e8b138575 100644 --- a/src/core/linux/SDL_dbus.c +++ b/src/core/linux/SDL_dbus.c @@ -34,14 +34,14 @@ static char *inhibit_handle = NULL; static unsigned int screensaver_cookie = 0; static SDL_DBusContext dbus; -static int -LoadDBUSSyms(void) +static int LoadDBUSSyms(void) { - #define SDL_DBUS_SYM2(x, y) \ - if (!(dbus.x = SDL_LoadFunction(dbus_handle, #y))) return -1 - - #define SDL_DBUS_SYM(x) \ - SDL_DBUS_SYM2(x, dbus_##x) +#define SDL_DBUS_SYM2(x, y) \ + if (!(dbus.x = SDL_LoadFunction(dbus_handle, #y))) \ + return -1 + +#define SDL_DBUS_SYM(x) \ + SDL_DBUS_SYM2(x, dbus_##x) SDL_DBUS_SYM(bus_get_private); SDL_DBUS_SYM(bus_register); @@ -83,14 +83,13 @@ LoadDBUSSyms(void) SDL_DBUS_SYM(free_string_array); SDL_DBUS_SYM(shutdown); - #undef SDL_DBUS_SYM - #undef SDL_DBUS_SYM2 +#undef SDL_DBUS_SYM +#undef SDL_DBUS_SYM2 return 0; } -static void -UnloadDBUSLibrary(void) +static void UnloadDBUSLibrary(void) { if (dbus_handle != NULL) { SDL_UnloadObject(dbus_handle); @@ -98,8 +97,7 @@ UnloadDBUSLibrary(void) } } -static int -LoadDBUSLibrary(void) +static int LoadDBUSLibrary(void) { int retval = 0; if (dbus_handle == NULL) { @@ -118,24 +116,22 @@ LoadDBUSLibrary(void) return retval; } - static SDL_SpinLock spinlock_dbus_init = 0; /* you must hold spinlock_dbus_init before calling this! */ -static void -SDL_DBus_Init_Spinlocked(void) +static void SDL_DBus_Init_Spinlocked(void) { static SDL_bool is_dbus_available = SDL_TRUE; if (!is_dbus_available) { - return; /* don't keep trying if this fails. */ + return; /* don't keep trying if this fails. */ } if (!dbus.session_conn) { DBusError err; if (LoadDBUSLibrary() == -1) { - is_dbus_available = SDL_FALSE; /* can't load at all? Don't keep trying. */ - return; /* oh well */ + is_dbus_available = SDL_FALSE; /* can't load at all? Don't keep trying. */ + return; } if (!dbus.threads_init_default()) { @@ -151,7 +147,7 @@ SDL_DBus_Init_Spinlocked(void) dbus.error_free(&err); SDL_DBus_Quit(); is_dbus_available = SDL_FALSE; - return; /* oh well */ + return; /* oh well */ } dbus.connection_set_exit_on_disconnect(dbus.session_conn, 0); @@ -165,16 +161,14 @@ SDL_DBus_Init_Spinlocked(void) } } -void -SDL_DBus_Init(void) +void SDL_DBus_Init(void) { - SDL_AtomicLock(&spinlock_dbus_init); /* make sure two threads can't init at same time, since this can happen before SDL_Init. */ + SDL_AtomicLock(&spinlock_dbus_init); /* make sure two threads can't init at same time, since this can happen before SDL_Init. */ SDL_DBus_Init_Spinlocked(); SDL_AtomicUnlock(&spinlock_dbus_init); } -void -SDL_DBus_Quit(void) +void SDL_DBus_Quit(void) { if (dbus.system_conn) { dbus.connection_close(dbus.system_conn); @@ -204,12 +198,11 @@ SDL_DBus_GetContext(void) if (dbus_handle == NULL || !dbus.session_conn) { SDL_DBus_Init(); } - + return (dbus_handle && dbus.session_conn) ? &dbus : NULL; } -static SDL_bool -SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap) +static SDL_bool SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap) { SDL_bool retval = SDL_FALSE; @@ -218,7 +211,7 @@ SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *node, const char * if (msg) { int firstarg; va_list ap_reply; - va_copy(ap_reply, ap); /* copy the arg list so we don't compete with D-Bus for it */ + va_copy(ap_reply, ap); /* copy the arg list so we don't compete with D-Bus for it */ firstarg = va_arg(ap, int); if ((firstarg == DBUS_TYPE_INVALID) || dbus.message_append_args_valist(msg, firstarg, ap)) { DBusMessage *reply = dbus.connection_send_with_reply_and_block(conn, msg, 300, NULL); @@ -226,9 +219,15 @@ SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *node, const char * /* skip any input args, get to output args. */ while ((firstarg = va_arg(ap_reply, int)) != DBUS_TYPE_INVALID) { /* we assume D-Bus already validated all this. */ - { void *dumpptr = va_arg(ap_reply, void*); (void) dumpptr; } + { + void *dumpptr = va_arg(ap_reply, void *); + (void)dumpptr; + } if (firstarg == DBUS_TYPE_ARRAY) { - { const int dumpint = va_arg(ap_reply, int); (void) dumpint; } + { + const int dumpint = va_arg(ap_reply, int); + (void)dumpint; + } } } firstarg = va_arg(ap_reply, int); @@ -268,8 +267,7 @@ SDL_DBus_CallMethod(const char *node, const char *path, const char *interface, c return retval; } -static SDL_bool -SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap) +static SDL_bool SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap) { SDL_bool retval = SDL_FALSE; @@ -291,8 +289,7 @@ SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char *node, const ch return retval; } -static SDL_bool -SDL_DBus_CallWithBasicReply(DBusConnection *conn, DBusMessage *msg, const int expectedtype, void *result) +static SDL_bool SDL_DBus_CallWithBasicReply(DBusConnection *conn, DBusMessage *msg, const int expectedtype, void *result) { SDL_bool retval = SDL_FALSE; @@ -363,19 +360,16 @@ SDL_DBus_QueryProperty(const char *node, const char *path, const char *interface return SDL_DBus_QueryPropertyOnConnection(dbus.session_conn, node, path, interface, property, expectedtype, result); } - -void -SDL_DBus_ScreensaverTickle(void) +void SDL_DBus_ScreensaverTickle(void) { - if (screensaver_cookie == 0 && inhibit_handle == NULL) { /* no need to tickle if we're inhibiting. */ + if (screensaver_cookie == 0 && inhibit_handle == NULL) { /* no need to tickle if we're inhibiting. */ /* org.gnome.ScreenSaver is the legacy interface, but it'll either do nothing or just be a second harmless tickle on newer systems, so we leave it for now. */ SDL_DBus_CallVoidMethod("org.gnome.ScreenSaver", "/org/gnome/ScreenSaver", "org.gnome.ScreenSaver", "SimulateUserActivity", DBUS_TYPE_INVALID); SDL_DBus_CallVoidMethod("org.freedesktop.ScreenSaver", "/org/freedesktop/ScreenSaver", "org.freedesktop.ScreenSaver", "SimulateUserActivity", DBUS_TYPE_INVALID); } } -static SDL_bool -SDL_DBus_AppendDictWithKeyValue(DBusMessageIter *iterInit, const char *key, const char *value) +static SDL_bool SDL_DBus_AppendDictWithKeyValue(DBusMessageIter *iterInit, const char *key, const char *value) { DBusMessageIter iterDict, iterEntry, iterValue; @@ -399,9 +393,7 @@ SDL_DBus_AppendDictWithKeyValue(DBusMessageIter *iterInit, const char *key, cons goto failed; } - if (!dbus.message_iter_close_container(&iterEntry, &iterValue) - || !dbus.message_iter_close_container(&iterDict, &iterEntry) - || !dbus.message_iter_close_container(iterInit, &iterDict)) { + if (!dbus.message_iter_close_container(&iterEntry, &iterValue) || !dbus.message_iter_close_container(&iterDict, &iterEntry) || !dbus.message_iter_close_container(iterInit, &iterDict)) { goto failed; } @@ -419,8 +411,7 @@ SDL_DBus_ScreensaverInhibit(SDL_bool inhibit) { const char *default_inhibit_reason = "Playing a game"; - if ( (inhibit && (screensaver_cookie != 0 || inhibit_handle != NULL)) - || (!inhibit && (screensaver_cookie == 0 && inhibit_handle == NULL)) ) { + if ((inhibit && (screensaver_cookie != 0 || inhibit_handle != NULL)) || (!inhibit && (screensaver_cookie == 0 && inhibit_handle == NULL))) { return SDL_TRUE; } @@ -434,7 +425,7 @@ SDL_DBus_ScreensaverInhibit(SDL_bool inhibit) const char *bus_name = "org.freedesktop.portal.Desktop"; const char *path = "/org/freedesktop/portal/desktop"; const char *interface = "org.freedesktop.portal.Inhibit"; - const char *window = ""; /* As a future improvement we could gather the X11 XID or Wayland surface identifier */ + const char *window = ""; /* As a future improvement we could gather the X11 XID or Wayland surface identifier */ static const unsigned int INHIBIT_IDLE = 8; /* Taken from the portal API reference */ DBusMessageIter iterInit; @@ -487,15 +478,15 @@ SDL_DBus_ScreensaverInhibit(SDL_bool inhibit) const char *app = SDL_GetHint(SDL_HINT_APP_NAME); const char *reason = SDL_GetHint(SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME); if (app == NULL || !app[0]) { - app = "My SDL application"; + app = "My SDL application"; } if (reason == NULL || !reason[0]) { reason = default_inhibit_reason; } if (!SDL_DBus_CallMethod(bus_name, path, interface, "Inhibit", - DBUS_TYPE_STRING, &app, DBUS_TYPE_STRING, &reason, DBUS_TYPE_INVALID, - DBUS_TYPE_UINT32, &screensaver_cookie, DBUS_TYPE_INVALID)) { + DBUS_TYPE_STRING, &app, DBUS_TYPE_STRING, &reason, DBUS_TYPE_INVALID, + DBUS_TYPE_UINT32, &screensaver_cookie, DBUS_TYPE_INVALID)) { return SDL_FALSE; } return (screensaver_cookie != 0) ? SDL_TRUE : SDL_FALSE; diff --git a/src/core/linux/SDL_dbus.h b/src/core/linux/SDL_dbus.h index 04ab2a80d..4d895cf54 100644 --- a/src/core/linux/SDL_dbus.h +++ b/src/core/linux/SDL_dbus.h @@ -29,20 +29,20 @@ #include "SDL_stdinc.h" #include - -typedef struct SDL_DBusContext { +typedef struct SDL_DBusContext +{ DBusConnection *session_conn; DBusConnection *system_conn; DBusConnection *(*bus_get_private)(DBusBusType, DBusError *); dbus_bool_t (*bus_register)(DBusConnection *, DBusError *); void (*bus_add_match)(DBusConnection *, const char *, DBusError *); - DBusConnection * (*connection_open_private)(const char *, DBusError *); + DBusConnection *(*connection_open_private)(const char *, DBusError *); void (*connection_set_exit_on_disconnect)(DBusConnection *, dbus_bool_t); dbus_bool_t (*connection_get_is_connected)(DBusConnection *); dbus_bool_t (*connection_add_filter)(DBusConnection *, DBusHandleMessageFunction, void *, DBusFreeFunction); dbus_bool_t (*connection_try_register_object_path)(DBusConnection *, const char *, - const DBusObjectPathVTable *, void *, DBusError *); + const DBusObjectPathVTable *, void *, DBusError *); dbus_bool_t (*connection_send)(DBusConnection *, DBusMessage *, dbus_uint32_t *); DBusMessage *(*connection_send_with_reply_and_block)(DBusConnection *, DBusMessage *, int, DBusError *); void (*connection_close)(DBusConnection *); @@ -50,7 +50,7 @@ typedef struct SDL_DBusContext { void (*connection_flush)(DBusConnection *); dbus_bool_t (*connection_read_write)(DBusConnection *, int); DBusDispatchStatus (*connection_dispatch)(DBusConnection *); - dbus_bool_t (*message_is_signal)(DBusMessage *, const char *, const char *); + dbus_bool_t (*message_is_signal)(DBusMessage *, const char *, const char *); DBusMessage *(*message_new_method_call)(const char *, const char *, const char *, const char *); dbus_bool_t (*message_append_args)(DBusMessage *, int, ...); dbus_bool_t (*message_append_args_valist)(DBusMessage *, int, va_list); @@ -64,7 +64,7 @@ typedef struct SDL_DBusContext { dbus_bool_t (*message_iter_next)(DBusMessageIter *); void (*message_iter_get_basic)(DBusMessageIter *, void *); int (*message_iter_get_arg_type)(DBusMessageIter *); - void (*message_iter_recurse)(DBusMessageIter *, DBusMessageIter *); + void (*message_iter_recurse)(DBusMessageIter *, DBusMessageIter *); void (*message_unref)(DBusMessage *); dbus_bool_t (*threads_init_default)(void); void (*error_init)(DBusError *); @@ -79,7 +79,7 @@ typedef struct SDL_DBusContext { extern void SDL_DBus_Init(void); extern void SDL_DBus_Quit(void); -extern SDL_DBusContext * SDL_DBus_GetContext(void); +extern SDL_DBusContext *SDL_DBus_GetContext(void); /* These use the built-in Session connection. */ extern SDL_bool SDL_DBus_CallMethod(const char *node, const char *path, const char *interface, const char *method, ...); diff --git a/src/core/linux/SDL_evdev.c b/src/core/linux/SDL_evdev.c index d24b16e90..12481bb7a 100644 --- a/src/core/linux/SDL_evdev.c +++ b/src/core/linux/SDL_evdev.c @@ -23,7 +23,7 @@ #ifdef SDL_INPUT_LINUXEV /* This is based on the linux joystick driver */ -/* References: https://www.kernel.org/doc/Documentation/input/input.txt +/* References: https://www.kernel.org/doc/Documentation/input/input.txt * https://www.kernel.org/doc/Documentation/input/event-codes.txt * /usr/include/linux/input.h * The evtest application is also useful to debug the protocol @@ -51,15 +51,15 @@ #define SYN_DROPPED 3 #endif #ifndef ABS_MT_SLOT -#define ABS_MT_SLOT 0x2f -#define ABS_MT_POSITION_X 0x35 -#define ABS_MT_POSITION_Y 0x36 -#define ABS_MT_TRACKING_ID 0x39 -#define ABS_MT_PRESSURE 0x3a +#define ABS_MT_SLOT 0x2f +#define ABS_MT_POSITION_X 0x35 +#define ABS_MT_POSITION_Y 0x36 +#define ABS_MT_TRACKING_ID 0x39 +#define ABS_MT_PRESSURE 0x3a #endif #ifndef REL_WHEEL_HI_RES -#define REL_WHEEL_HI_RES 0x0b -#define REL_HWHEEL_HI_RES 0x0c +#define REL_WHEEL_HI_RES 0x0b +#define REL_HWHEEL_HI_RES 0x0c #endif typedef struct SDL_evdevlist_item @@ -74,8 +74,9 @@ typedef struct SDL_evdevlist_item keyboard, touchpad, etc.). Also there's probably some things in here we can pull out to the SDL_evdevlist_item i.e. name */ SDL_bool is_touchscreen; - struct { - char* name; + struct + { + char *name; int min_x, max_x, range_x; int min_y, max_y, range_y; @@ -83,8 +84,10 @@ typedef struct SDL_evdevlist_item int max_slots; int current_slot; - struct { - enum { + struct + { + enum + { EVDEV_TOUCH_SLOTDELTA_NONE = 0, EVDEV_TOUCH_SLOTDELTA_DOWN, EVDEV_TOUCH_SLOTDELTA_UP, @@ -126,33 +129,30 @@ static int SDL_EVDEV_device_removed(const char *dev_path); static int SDL_EVDEV_device_added(const char *dev_path, int udev_class); #if SDL_USE_LIBUDEV static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, - const char *dev_path); + const char *dev_path); #endif /* SDL_USE_LIBUDEV */ static Uint8 EVDEV_MouseButtons[] = { - SDL_BUTTON_LEFT, /* BTN_LEFT 0x110 */ - SDL_BUTTON_RIGHT, /* BTN_RIGHT 0x111 */ - SDL_BUTTON_MIDDLE, /* BTN_MIDDLE 0x112 */ - SDL_BUTTON_X1, /* BTN_SIDE 0x113 */ - SDL_BUTTON_X2, /* BTN_EXTRA 0x114 */ - SDL_BUTTON_X2 + 1, /* BTN_FORWARD 0x115 */ - SDL_BUTTON_X2 + 2, /* BTN_BACK 0x116 */ - SDL_BUTTON_X2 + 3 /* BTN_TASK 0x117 */ + SDL_BUTTON_LEFT, /* BTN_LEFT 0x110 */ + SDL_BUTTON_RIGHT, /* BTN_RIGHT 0x111 */ + SDL_BUTTON_MIDDLE, /* BTN_MIDDLE 0x112 */ + SDL_BUTTON_X1, /* BTN_SIDE 0x113 */ + SDL_BUTTON_X2, /* BTN_EXTRA 0x114 */ + SDL_BUTTON_X2 + 1, /* BTN_FORWARD 0x115 */ + SDL_BUTTON_X2 + 2, /* BTN_BACK 0x116 */ + SDL_BUTTON_X2 + 3 /* BTN_TASK 0x117 */ }; -static int -SDL_EVDEV_SetRelativeMouseMode(SDL_bool enabled) +static int SDL_EVDEV_SetRelativeMouseMode(SDL_bool enabled) { /* Mice already send relative events through this interface */ return 0; } - -int -SDL_EVDEV_Init(void) +int SDL_EVDEV_Init(void) { if (_this == NULL) { - _this = (SDL_EVDEV_PrivateData*)SDL_calloc(1, sizeof(*_this)); + _this = (SDL_EVDEV_PrivateData *)SDL_calloc(1, sizeof(*_this)); if (_this == NULL) { return SDL_OutOfMemory(); } @@ -182,14 +182,14 @@ SDL_EVDEV_Init(void) where device class is an integer representing the SDL_UDEV_deviceclass and path is the full path to the event device. */ - const char* devices = SDL_getenv("SDL_EVDEV_DEVICES"); + const char *devices = SDL_getenv("SDL_EVDEV_DEVICES"); if (devices) { /* Assume this is the old use of the env var and it is not in ROM. */ - char* rest = (char*) devices; - char* spec; + char *rest = (char *)devices; + char *spec; while ((spec = SDL_strtokr(rest, ",", &rest))) { - char* endofcls = 0; + char *endofcls = 0; long cls = SDL_strtol(spec, &endofcls, 0); if (endofcls) { SDL_EVDEV_device_added(endofcls + 1, cls); @@ -211,8 +211,7 @@ SDL_EVDEV_Init(void) return 0; } -void -SDL_EVDEV_Quit(void) +void SDL_EVDEV_Quit(void) { if (_this == NULL) { return; @@ -244,13 +243,13 @@ SDL_EVDEV_Quit(void) #if SDL_USE_LIBUDEV static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_class, - const char* dev_path) + const char *dev_path) { if (dev_path == NULL) { return; } - switch(udev_event) { + switch (udev_event) { case SDL_UDEV_DEVICEADDED: if (!(udev_class & (SDL_UDEV_DEVICE_MOUSE | SDL_UDEV_DEVICE_KEYBOARD | SDL_UDEV_DEVICE_TOUCHSCREEN | SDL_UDEV_DEVICE_TOUCHPAD))) { return; @@ -261,7 +260,7 @@ static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_cl } SDL_EVDEV_device_added(dev_path, udev_class); - break; + break; case SDL_UDEV_DEVICEREMOVED: SDL_EVDEV_device_removed(dev_path); break; @@ -271,8 +270,7 @@ static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_cl } #endif /* SDL_USE_LIBUDEV */ -void -SDL_EVDEV_Poll(void) +void SDL_EVDEV_Poll(void) { struct input_event events[32]; int i, j, len; @@ -341,11 +339,11 @@ SDL_EVDEV_Poll(void) SDL_EVDEV_kbd_keycode(_this->kbd, events[i].code, events[i].value); break; case EV_ABS: - switch(events[i].code) { + switch (events[i].code) { case ABS_MT_SLOT: if (!item->is_touchscreen) { /* FIXME: temp hack */ break; - } + } item->touchscreen_data->current_slot = events[i].value; break; case ABS_MT_TRACKING_ID: @@ -413,7 +411,7 @@ SDL_EVDEV_Poll(void) } break; case EV_REL: - switch(events[i].code) { + switch (events[i].code) { case REL_X: if (item->relative_mouse) { item->mouse_x += events[i].value; @@ -468,13 +466,13 @@ SDL_EVDEV_Poll(void) for (j = 0; j < item->touchscreen_data->max_slots; j++) { norm_x = (float)(item->touchscreen_data->slots[j].x - item->touchscreen_data->min_x) / - (float)item->touchscreen_data->range_x; + (float)item->touchscreen_data->range_x; norm_y = (float)(item->touchscreen_data->slots[j].y - item->touchscreen_data->min_y) / - (float)item->touchscreen_data->range_y; + (float)item->touchscreen_data->range_y; if (item->touchscreen_data->range_pressure > 0) { norm_pressure = (float)(item->touchscreen_data->slots[j].pressure - item->touchscreen_data->min_pressure) / - (float)item->touchscreen_data->range_pressure; + (float)item->touchscreen_data->range_pressure; } else { /* This touchscreen does not support pressure */ norm_pressure = 1.0f; @@ -483,7 +481,7 @@ SDL_EVDEV_Poll(void) /* FIXME: the touch's window shouldn't be null, but * the coordinate space of touch positions needs to * be window-relative in that case. */ - switch(item->touchscreen_data->slots[j].delta) { + switch (item->touchscreen_data->slots[j].delta) { case EVDEV_TOUCH_SLOTDELTA_DOWN: SDL_SendTouch(item->fd, item->touchscreen_data->slots[j].tracking_id, NULL, SDL_TRUE, norm_x, norm_y, norm_pressure); item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE; @@ -518,12 +516,11 @@ SDL_EVDEV_Poll(void) break; } } - } + } } } -static SDL_Scancode -SDL_EVDEV_translate_keycode(int keycode) +static SDL_Scancode SDL_EVDEV_translate_keycode(int keycode) { SDL_Scancode scancode = SDL_GetScancodeFromTable(SDL_SCANCODE_TABLE_LINUX, keycode); @@ -535,8 +532,9 @@ SDL_EVDEV_translate_keycode(int keycode) SDL_Log message about an unknown key. */ if (keycode != BTN_TOUCH) { SDL_Log("The key you just pressed is not recognized by SDL. To help " - "get this fixed, please report this to the SDL forums/mailing list " - " EVDEV KeyCode %d", keycode); + "get this fixed, please report this to the SDL forums/mailing list " + " EVDEV KeyCode %d", + keycode); } } #endif /* DEBUG_SCANCODES */ @@ -544,8 +542,7 @@ SDL_EVDEV_translate_keycode(int keycode) return scancode; } -static int -SDL_EVDEV_init_touchscreen(SDL_evdevlist_item* item, int udev_class) +static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class) { int ret, i; unsigned long xreq, yreq; @@ -634,8 +631,8 @@ SDL_EVDEV_init_touchscreen(SDL_evdevlist_item* item, int udev_class) } ret = SDL_AddTouch(item->fd, /* I guess our fd is unique enough */ - (udev_class & SDL_UDEV_DEVICE_TOUCHPAD) ? SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE : SDL_TOUCH_DEVICE_DIRECT, - item->touchscreen_data->name); + (udev_class & SDL_UDEV_DEVICE_TOUCHPAD) ? SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE : SDL_TOUCH_DEVICE_DIRECT, + item->touchscreen_data->name); if (ret < 0) { SDL_free(item->touchscreen_data->slots); SDL_free(item->touchscreen_data->name); @@ -646,8 +643,8 @@ SDL_EVDEV_init_touchscreen(SDL_evdevlist_item* item, int udev_class) return 0; } -static void -SDL_EVDEV_destroy_touchscreen(SDL_evdevlist_item* item) { +static void SDL_EVDEV_destroy_touchscreen(SDL_evdevlist_item *item) +{ if (!item->is_touchscreen) { return; } @@ -658,8 +655,7 @@ SDL_EVDEV_destroy_touchscreen(SDL_evdevlist_item* item) { SDL_free(item->touchscreen_data); } -static void -SDL_EVDEV_sync_device(SDL_evdevlist_item *item) +static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item) { #ifdef EVIOCGMTSLOTS int i, ret; @@ -672,8 +668,8 @@ SDL_EVDEV_sync_device(SDL_evdevlist_item *item) * * this is the structure we're trying to emulate */ - Uint32* mt_req_code; - Sint32* mt_req_values; + Uint32 *mt_req_code; + Sint32 *mt_req_values; size_t mt_req_size; /* TODO: sync devices other than touchscreen */ @@ -682,14 +678,14 @@ SDL_EVDEV_sync_device(SDL_evdevlist_item *item) } mt_req_size = sizeof(*mt_req_code) + - sizeof(*mt_req_values) * item->touchscreen_data->max_slots; + sizeof(*mt_req_values) * item->touchscreen_data->max_slots; mt_req_code = SDL_calloc(1, mt_req_size); if (mt_req_code == NULL) { return; } - mt_req_values = (Sint32*)mt_req_code + 1; + mt_req_values = (Sint32 *)mt_req_code + 1; *mt_req_code = ABS_MT_TRACKING_ID; ret = ioctl(item->fd, EVIOCGMTSLOTS(mt_req_size), mt_req_code); @@ -712,7 +708,7 @@ SDL_EVDEV_sync_device(SDL_evdevlist_item *item) item->touchscreen_data->slots[i].tracking_id = mt_req_values[i]; item->touchscreen_data->slots[i].delta = EVDEV_TOUCH_SLOTDELTA_DOWN; } else if (item->touchscreen_data->slots[i].tracking_id >= 0 && - mt_req_values[i] < 0) { + mt_req_values[i] < 0) { item->touchscreen_data->slots[i].tracking_id = -1; item->touchscreen_data->slots[i].delta = EVDEV_TOUCH_SLOTDELTA_UP; } @@ -784,8 +780,7 @@ SDL_EVDEV_sync_device(SDL_evdevlist_item *item) #endif /* EVIOCGMTSLOTS */ } -static int -SDL_EVDEV_device_added(const char *dev_path, int udev_class) +static int SDL_EVDEV_device_added(const char *dev_path, int udev_class) { int ret; SDL_evdevlist_item *item; @@ -794,11 +789,11 @@ SDL_EVDEV_device_added(const char *dev_path, int udev_class) /* Check to make sure it's not already in list. */ for (item = _this->first; item != NULL; item = item->next) { if (SDL_strcmp(dev_path, item->path) == 0) { - return -1; /* already have this one */ + return -1; /* already have this one */ } } - item = (SDL_evdevlist_item *) SDL_calloc(1, sizeof (SDL_evdevlist_item)); + item = (SDL_evdevlist_item *)SDL_calloc(1, sizeof(SDL_evdevlist_item)); if (item == NULL) { return SDL_OutOfMemory(); } @@ -846,8 +841,7 @@ SDL_EVDEV_device_added(const char *dev_path, int udev_class) return _this->num_devices++; } -static int -SDL_EVDEV_device_removed(const char *dev_path) +static int SDL_EVDEV_device_removed(const char *dev_path) { SDL_evdevlist_item *item; SDL_evdevlist_item *prev = NULL; @@ -879,7 +873,6 @@ SDL_EVDEV_device_removed(const char *dev_path) return -1; } - #endif /* SDL_INPUT_LINUXEV */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/core/linux/SDL_evdev_capabilities.c b/src/core/linux/SDL_evdev_capabilities.c index cf5530f84..cc9784302 100644 --- a/src/core/linux/SDL_evdev_capabilities.c +++ b/src/core/linux/SDL_evdev_capabilities.c @@ -23,7 +23,6 @@ #include "SDL_evdev_capabilities.h" - #if HAVE_LINUX_INPUT_H /* missing defines in older Linux kernel headers */ @@ -31,10 +30,10 @@ #define BTN_TRIGGER_HAPPY 0x2c0 #endif #ifndef BTN_DPAD_UP -#define BTN_DPAD_UP 0x220 +#define BTN_DPAD_UP 0x220 #endif #ifndef KEY_ALS_TOGGLE -#define KEY_ALS_TOGGLE 0x230 +#define KEY_ALS_TOGGLE 0x230 #endif extern int @@ -43,7 +42,8 @@ SDL_EVDEV_GuessDeviceClass(unsigned long bitmask_ev[NBITS(EV_MAX)], unsigned long bitmask_key[NBITS(KEY_MAX)], unsigned long bitmask_rel[NBITS(REL_MAX)]) { - struct range { + struct range + { unsigned start; unsigned end; }; @@ -114,7 +114,7 @@ SDL_EVDEV_GuessDeviceClass(unsigned long bitmask_ev[NBITS(EV_MAX)], unsigned i; unsigned long found = 0; - for (i = 0; i < BTN_MISC/BITS_PER_LONG; ++i) { + for (i = 0; i < BTN_MISC / BITS_PER_LONG; ++i) { found |= bitmask_key[i]; } /* If there are no keys in the lower block, check the higher blocks */ diff --git a/src/core/linux/SDL_evdev_capabilities.h b/src/core/linux/SDL_evdev_capabilities.h index 67b7075cc..1b12f3824 100644 --- a/src/core/linux/SDL_evdev_capabilities.h +++ b/src/core/linux/SDL_evdev_capabilities.h @@ -31,21 +31,21 @@ /* A device can be any combination of these classes */ typedef enum { - SDL_UDEV_DEVICE_UNKNOWN = 0x0000, - SDL_UDEV_DEVICE_MOUSE = 0x0001, - SDL_UDEV_DEVICE_KEYBOARD = 0x0002, - SDL_UDEV_DEVICE_JOYSTICK = 0x0004, - SDL_UDEV_DEVICE_SOUND = 0x0008, + SDL_UDEV_DEVICE_UNKNOWN = 0x0000, + SDL_UDEV_DEVICE_MOUSE = 0x0001, + SDL_UDEV_DEVICE_KEYBOARD = 0x0002, + SDL_UDEV_DEVICE_JOYSTICK = 0x0004, + SDL_UDEV_DEVICE_SOUND = 0x0008, SDL_UDEV_DEVICE_TOUCHSCREEN = 0x0010, SDL_UDEV_DEVICE_ACCELEROMETER = 0x0020, - SDL_UDEV_DEVICE_TOUCHPAD = 0x0040 + SDL_UDEV_DEVICE_TOUCHPAD = 0x0040 } SDL_UDEV_deviceclass; -#define BITS_PER_LONG (sizeof(unsigned long) * 8) -#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1) -#define EVDEV_OFF(x) ((x)%BITS_PER_LONG) -#define EVDEV_LONG(x) ((x)/BITS_PER_LONG) -#define test_bit(bit, array) ((array[EVDEV_LONG(bit)] >> EVDEV_OFF(bit)) & 1) +#define BITS_PER_LONG (sizeof(unsigned long) * 8) +#define NBITS(x) ((((x)-1) / BITS_PER_LONG) + 1) +#define EVDEV_OFF(x) ((x) % BITS_PER_LONG) +#define EVDEV_LONG(x) ((x) / BITS_PER_LONG) +#define test_bit(bit, array) ((array[EVDEV_LONG(bit)] >> EVDEV_OFF(bit)) & 1) extern int SDL_EVDEV_GuessDeviceClass(unsigned long bitmask_ev[NBITS(EV_MAX)], unsigned long bitmask_abs[NBITS(ABS_MAX)], diff --git a/src/core/linux/SDL_evdev_kbd.c b/src/core/linux/SDL_evdev_kbd.c index f7f01deb4..42b634a92 100644 --- a/src/core/linux/SDL_evdev_kbd.c +++ b/src/core/linux/SDL_evdev_kbd.c @@ -53,33 +53,31 @@ * Handler Tables. */ -#define K_HANDLERS\ - k_self, k_fn, k_spec, k_pad,\ - k_dead, k_cons, k_cur, k_shift,\ - k_meta, k_ascii, k_lock, k_lowercase,\ - k_slock, k_dead2, k_brl, k_ignore +#define K_HANDLERS \ + k_self, k_fn, k_spec, k_pad, \ + k_dead, k_cons, k_cur, k_shift, \ + k_meta, k_ascii, k_lock, k_lowercase, \ + k_slock, k_dead2, k_brl, k_ignore -typedef void (k_handler_fn)(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag); +typedef void(k_handler_fn)(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag); static k_handler_fn K_HANDLERS; static k_handler_fn *k_handler[16] = { K_HANDLERS }; -typedef void (fn_handler_fn)(SDL_EVDEV_keyboard_state *kbd); +typedef void(fn_handler_fn)(SDL_EVDEV_keyboard_state *kbd); static void fn_enter(SDL_EVDEV_keyboard_state *kbd); static void fn_caps_toggle(SDL_EVDEV_keyboard_state *kbd); static void fn_caps_on(SDL_EVDEV_keyboard_state *kbd); static void fn_num(SDL_EVDEV_keyboard_state *kbd); static void fn_compose(SDL_EVDEV_keyboard_state *kbd); -static fn_handler_fn *fn_handler[] = -{ - NULL, fn_enter, NULL, NULL, - NULL, NULL, NULL, fn_caps_toggle, - fn_num, NULL, NULL, NULL, - NULL, fn_caps_on, fn_compose, NULL, - NULL, NULL, NULL, fn_num +static fn_handler_fn *fn_handler[] = { + NULL, fn_enter, NULL, NULL, + NULL, NULL, NULL, fn_caps_toggle, + fn_num, NULL, NULL, NULL, + NULL, fn_caps_on, fn_compose, NULL, + NULL, NULL, NULL, fn_num }; - /* * Keyboard State */ @@ -89,12 +87,12 @@ struct SDL_EVDEV_keyboard_state int console_fd; int old_kbd_mode; unsigned short **key_maps; - unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */ + unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */ SDL_bool dead_key_next; - int npadch; /* -1 or number assembled on pad */ + int npadch; /* -1 or number assembled on pad */ struct kbdiacrs *accents; unsigned int diacr; - SDL_bool rep; /* flag telling character repeat */ + SDL_bool rep; /* flag telling character repeat */ unsigned char lockstate; unsigned char slockstate; unsigned char ledflagstate; @@ -114,7 +112,7 @@ static void SDL_EVDEV_dump_accents(SDL_EVDEV_keyboard_state *kbd) for (i = 0; i < kbd->accents->kb_cnt; ++i) { struct kbdiacr *diacr = &kbd->accents->kbdiacr[i]; printf(" { 0x%.2x, 0x%.2x, 0x%.2x },\n", - diacr->diacr, diacr->base, diacr->result); + diacr->diacr, diacr->base, diacr->result); } while (i < 256) { printf(" { 0x00, 0x00, 0x00 },\n"); @@ -134,7 +132,7 @@ static void SDL_EVDEV_dump_keymap(SDL_EVDEV_keyboard_state *kbd) if (kbd->key_maps[i]) { printf("static unsigned short default_key_map_%d[NR_KEYS] = {", i); for (j = 0; j < NR_KEYS; ++j) { - if ((j%8) == 0) { + if ((j % 8) == 0) { printf("\n "); } printf("0x%.4x, ", kbd->key_maps[i][j]); @@ -194,23 +192,22 @@ static int SDL_EVDEV_kbd_load_keymaps(SDL_EVDEV_keyboard_state *kbd) return 0; } -static SDL_EVDEV_keyboard_state * kbd_cleanup_state = NULL; +static SDL_EVDEV_keyboard_state *kbd_cleanup_state = NULL; static int kbd_cleanup_sigactions_installed = 0; static int kbd_cleanup_atexit_installed = 0; static struct sigaction old_sigaction[NSIG]; -static int fatal_signals[] = -{ +static int fatal_signals[] = { /* Handlers for SIGTERM and SIGINT are installed in SDL_QuitInit. */ - SIGHUP, SIGQUIT, SIGILL, SIGABRT, - SIGFPE, SIGSEGV, SIGPIPE, SIGBUS, + SIGHUP, SIGQUIT, SIGILL, SIGABRT, + SIGFPE, SIGSEGV, SIGPIPE, SIGBUS, SIGSYS }; static void kbd_cleanup(void) { - SDL_EVDEV_keyboard_state* kbd = kbd_cleanup_state; + SDL_EVDEV_keyboard_state *kbd = kbd_cleanup_state; if (kbd == NULL) { return; } @@ -219,18 +216,17 @@ static void kbd_cleanup(void) ioctl(kbd->console_fd, KDSKBMODE, kbd->old_kbd_mode); } -static void -SDL_EVDEV_kbd_reraise_signal(int sig) +static void SDL_EVDEV_kbd_reraise_signal(int sig) { raise(sig); } -siginfo_t* SDL_EVDEV_kdb_cleanup_siginfo = NULL; -void* SDL_EVDEV_kdb_cleanup_ucontext = NULL; +siginfo_t *SDL_EVDEV_kdb_cleanup_siginfo = NULL; +void *SDL_EVDEV_kdb_cleanup_ucontext = NULL; -static void kbd_cleanup_signal_action(int signum, siginfo_t* info, void* ucontext) +static void kbd_cleanup_signal_action(int signum, siginfo_t *info, void *ucontext) { - struct sigaction* old_action_p = &(old_sigaction[signum]); + struct sigaction *old_action_p = &(old_sigaction[signum]); sigset_t sigset; /* Restore original signal handler before going any further. */ @@ -264,7 +260,7 @@ static void kbd_unregister_emerg_cleanup() kbd_cleanup_sigactions_installed = 0; for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) { - struct sigaction* old_action_p; + struct sigaction *old_action_p; struct sigaction cur_action; signum = fatal_signals[tabidx]; old_action_p = &(old_sigaction[signum]); @@ -293,7 +289,7 @@ static void kbd_cleanup_atexit(void) kbd_unregister_emerg_cleanup(); } -static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state * kbd) +static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd) { int tabidx, signum; @@ -317,9 +313,9 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state * kbd) kbd_cleanup_sigactions_installed = 1; for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) { - struct sigaction* old_action_p; + struct sigaction *old_action_p; struct sigaction new_action; - signum = fatal_signals[tabidx]; + signum = fatal_signals[tabidx]; old_action_p = &(old_sigaction[signum]); if (sigaction(signum, NULL, old_action_p)) { continue; @@ -328,7 +324,7 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state * kbd) /* Skip SIGHUP and SIGPIPE if handler is already installed * - assume the handler will do the cleanup */ - if ((signum == SIGHUP || signum == SIGPIPE) && (old_action_p->sa_handler != SIG_DFL || (void(*)(int))old_action_p->sa_sigaction != SIG_DFL)) { + if ((signum == SIGHUP || signum == SIGPIPE) && (old_action_p->sa_handler != SIG_DFL || (void (*)(int))old_action_p->sa_sigaction != SIG_DFL)) { continue; } @@ -345,7 +341,7 @@ SDL_EVDEV_kbd_init(void) SDL_EVDEV_keyboard_state *kbd; int i; char flag_state; - char shift_state[ sizeof (long) ] = {TIOCL_GETSHIFTSTATE, 0}; + char shift_state[sizeof(long)] = { TIOCL_GETSHIFTSTATE, 0 }; kbd = (SDL_EVDEV_keyboard_state *)SDL_calloc(1, sizeof(*kbd)); if (kbd == NULL) { @@ -411,8 +407,7 @@ SDL_EVDEV_kbd_init(void) return kbd; } -void -SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd) +void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd) { if (kbd == NULL) { return; @@ -447,7 +442,7 @@ SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd) static void put_queue(SDL_EVDEV_keyboard_state *kbd, uint c) { /* c is already part of a UTF-8 sequence and safe to add as a character */ - if (kbd->text_len < (sizeof(kbd->text)-1)) { + if (kbd->text_len < (sizeof(kbd->text) - 1)) { kbd->text[kbd->text_len++] = (char)c; } } @@ -615,7 +610,7 @@ static void k_self(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_f { if (up_flag) { return; /* no action, if this is a key release */ - } + } if (kbd->diacr) { value = handle_diacr(kbd, value); @@ -639,7 +634,7 @@ static void k_deadunicode(SDL_EVDEV_keyboard_state *kbd, unsigned int value, cha static void k_dead(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag) { - const unsigned char ret_diacr[NR_DEAD] = {'`', '\'', '^', '~', '"', ',' }; + const unsigned char ret_diacr[NR_DEAD] = { '`', '\'', '^', '~', '"', ',' }; k_deadunicode(kbd, ret_diacr[value], up_flag); } @@ -666,7 +661,7 @@ static void k_pad(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_fl static const char pad_chars[] = "0123456789+-*/\015,.?()#"; if (up_flag) - return; /* no action, if this is a key release */ + return; /* no action, if this is a key release */ if (!vc_kbd_led(kbd, K_NUMLOCK)) { /* unprintable action */ @@ -768,8 +763,7 @@ static void k_brl(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_fl { } -void -SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, int down) +void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, int down) { unsigned char shift_final; unsigned char type; @@ -841,13 +835,11 @@ SDL_EVDEV_kbd_init(void) return NULL; } -void -SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down) +void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down) { } -void -SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state) +void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state) { } diff --git a/src/core/linux/SDL_evdev_kbd_default_keymap.h b/src/core/linux/SDL_evdev_kbd_default_keymap.h index 30affb0b2..48305e2ac 100644 --- a/src/core/linux/SDL_evdev_kbd_default_keymap.h +++ b/src/core/linux/SDL_evdev_kbd_default_keymap.h @@ -19,6 +19,8 @@ 3. This notice may not be removed or altered from any source distribution. */ +/* *INDENT-OFF* */ /* clang-format off */ + static unsigned short default_key_map_0[NR_KEYS] = { 0xf200, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, @@ -4374,6 +4376,8 @@ static unsigned short default_key_map_127[NR_KEYS] = { }; #endif /* INCLUDE_EXTENDED_KEYMAP */ +/* *INDENT-ON* */ /* clang-format on */ + static unsigned short *default_key_maps[MAX_NR_KEYMAPS] = { default_key_map_0, default_key_map_1, @@ -4504,7 +4508,7 @@ static unsigned short *default_key_maps[MAX_NR_KEYMAPS] = { default_key_map_125, default_key_map_126, default_key_map_127, -#else /* !INCLUDE_EXTENDED_KEYMAP */ +#else /* !INCLUDE_EXTENDED_KEYMAP */ NULL, NULL, NULL, diff --git a/src/core/linux/SDL_fcitx.c b/src/core/linux/SDL_fcitx.c index 5e5e8f06f..aebe4db1f 100644 --- a/src/core/linux/SDL_fcitx.c +++ b/src/core/linux/SDL_fcitx.c @@ -55,8 +55,7 @@ typedef struct _FcitxClient static FcitxClient fcitx_client; -static char* -GetAppName() +static char *GetAppName() { #if defined(__LINUX__) || defined(__FREEBSD__) char *spot; @@ -86,10 +85,10 @@ GetAppName() static size_t Fcitx_GetPreeditString(SDL_DBusContext *dbus, - DBusMessage *msg, - char **ret, - Sint32 *start_pos, - Sint32 *end_pos) + DBusMessage *msg, + char **ret, + Sint32 *start_pos, + Sint32 *end_pos) { char *text = NULL, *subtext; size_t text_bytes = 0; @@ -141,7 +140,7 @@ Fcitx_GetPreeditString(SDL_DBusContext *dbus, } if (text) { - char* pivot = text; + char *pivot = text; /* Second pass: join all the sub string */ dbus->message_iter_recurse(&iter, &array); while (dbus->message_iter_get_arg_type(&array) == DBUS_TYPE_STRUCT) { @@ -167,8 +166,7 @@ Fcitx_GetPreeditString(SDL_DBusContext *dbus, return text_bytes; } -static Sint32 -Fcitx_GetPreeditCursorByte(SDL_DBusContext *dbus, DBusMessage *msg) +static Sint32 Fcitx_GetPreeditCursorByte(SDL_DBusContext *dbus, DBusMessage *msg) { Sint32 byte = -1; DBusMessageIter iter; @@ -186,8 +184,7 @@ Fcitx_GetPreeditCursorByte(SDL_DBusContext *dbus, DBusMessage *msg) return byte; } -static DBusHandlerResult -DBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *data) +static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *data) { SDL_DBusContext *dbus = (SDL_DBusContext *)data; @@ -203,7 +200,7 @@ DBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *data) size_t text_bytes = SDL_strlen(text), i = 0; while (i < text_bytes) { - size_t sz = SDL_utf8strlcpy(buf, text+i, sizeof(buf)); + size_t sz = SDL_utf8strlcpy(buf, text + i, sizeof(buf)); SDL_SendKeyboardText(buf); i += sz; @@ -250,8 +247,7 @@ DBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *data) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } -static void -FcitxClientICCallMethod(FcitxClient *client, const char *method) +static void FcitxClientICCallMethod(FcitxClient *client, const char *method) { if (!client->ic_path) { return; @@ -259,11 +255,10 @@ FcitxClientICCallMethod(FcitxClient *client, const char *method) SDL_DBus_CallVoidMethod(FCITX_DBUS_SERVICE, client->ic_path, FCITX_IC_DBUS_INTERFACE, method, DBUS_TYPE_INVALID); } -static void SDLCALL -Fcitx_SetCapabilities(void *data, - const char *name, - const char *old_val, - const char *internal_editing) +static void SDLCALL Fcitx_SetCapabilities(void *data, + const char *name, + const char *old_val, + const char *internal_editing) { FcitxClient *client = (FcitxClient *)data; Uint64 caps = 0; @@ -279,8 +274,8 @@ Fcitx_SetCapabilities(void *data, SDL_DBus_CallVoidMethod(FCITX_DBUS_SERVICE, client->ic_path, FCITX_IC_DBUS_INTERFACE, "SetCapability", DBUS_TYPE_UINT64, &caps, DBUS_TYPE_INVALID); } -static SDL_bool -FcitxCreateInputContext(SDL_DBusContext* dbus, const char *appname, char **ic_path) { +static SDL_bool FcitxCreateInputContext(SDL_DBusContext *dbus, const char *appname, char **ic_path) +{ const char *program = "program"; SDL_bool retval = SDL_FALSE; if (dbus->session_conn) { @@ -308,8 +303,7 @@ FcitxCreateInputContext(SDL_DBusContext* dbus, const char *appname, char **ic_pa return retval; } -static SDL_bool -FcitxClientCreateIC(FcitxClient *client) +static SDL_bool FcitxClientCreateIC(FcitxClient *client) { char *appname = GetAppName(); char *ic_path = NULL; @@ -317,7 +311,7 @@ FcitxClientCreateIC(FcitxClient *client) /* SDL_DBus_CallMethod cannot handle a(ss) type, call dbus function directly */ if (!FcitxCreateInputContext(dbus, appname, &ic_path)) { - ic_path = NULL; /* just in case. */ + ic_path = NULL; /* just in case. */ } SDL_free(appname); @@ -327,11 +321,11 @@ FcitxClientCreateIC(FcitxClient *client) client->ic_path = SDL_strdup(ic_path); dbus->bus_add_match(dbus->session_conn, - "type='signal', interface='org.fcitx.Fcitx.InputContext1'", - NULL); + "type='signal', interface='org.fcitx.Fcitx.InputContext1'", + NULL); dbus->connection_add_filter(dbus->session_conn, - &DBus_MessageFilter, dbus, - NULL); + &DBus_MessageFilter, dbus, + NULL); dbus->connection_flush(dbus->session_conn); SDL_AddHintCallback(SDL_HINT_IME_INTERNAL_EDITING, Fcitx_SetCapabilities, client); @@ -341,8 +335,7 @@ FcitxClientCreateIC(FcitxClient *client) return SDL_FALSE; } -static Uint32 -Fcitx_ModState(void) +static Uint32 Fcitx_ModState(void) { Uint32 fcitx_mods = 0; SDL_Keymod sdl_mods = SDL_GetModState(); @@ -388,8 +381,7 @@ SDL_Fcitx_Init() return FcitxClientCreateIC(&fcitx_client); } -void -SDL_Fcitx_Quit() +void SDL_Fcitx_Quit() { FcitxClientICCallMethod(&fcitx_client, "DestroyIC"); if (fcitx_client.ic_path) { @@ -398,8 +390,7 @@ SDL_Fcitx_Quit() } } -void -SDL_Fcitx_SetFocus(SDL_bool focused) +void SDL_Fcitx_SetFocus(SDL_bool focused) { if (focused) { FcitxClientICCallMethod(&fcitx_client, "FocusIn"); @@ -408,8 +399,7 @@ SDL_Fcitx_SetFocus(SDL_bool focused) } } -void -SDL_Fcitx_Reset(void) +void SDL_Fcitx_Reset(void) { FcitxClientICCallMethod(&fcitx_client, "Reset"); FcitxClientICCallMethod(&fcitx_client, "CloseIC"); @@ -428,8 +418,8 @@ SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state) } if (SDL_DBus_CallMethod(FCITX_DBUS_SERVICE, fcitx_client.ic_path, FCITX_IC_DBUS_INTERFACE, "ProcessKeyEvent", - DBUS_TYPE_UINT32, &keysym, DBUS_TYPE_UINT32, &keycode, DBUS_TYPE_UINT32, &mod_state, DBUS_TYPE_BOOLEAN, &is_release, DBUS_TYPE_UINT32, &event_time, DBUS_TYPE_INVALID, - DBUS_TYPE_BOOLEAN, &handled, DBUS_TYPE_INVALID)) { + DBUS_TYPE_UINT32, &keysym, DBUS_TYPE_UINT32, &keycode, DBUS_TYPE_UINT32, &mod_state, DBUS_TYPE_BOOLEAN, &is_release, DBUS_TYPE_UINT32, &event_time, DBUS_TYPE_INVALID, + DBUS_TYPE_BOOLEAN, &handled, DBUS_TYPE_INVALID)) { if (handled) { SDL_Fcitx_UpdateTextRect(NULL); return SDL_TRUE; @@ -439,8 +429,7 @@ SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state) return SDL_FALSE; } -void -SDL_Fcitx_UpdateTextRect(const SDL_Rect *rect) +void SDL_Fcitx_UpdateTextRect(const SDL_Rect *rect) { SDL_Window *focused_win = NULL; SDL_SysWMinfo info; @@ -453,7 +442,7 @@ SDL_Fcitx_UpdateTextRect(const SDL_Rect *rect) focused_win = SDL_GetKeyboardFocus(); if (focused_win == NULL) { - return ; + return; } SDL_VERSION(&info.version); @@ -487,11 +476,10 @@ SDL_Fcitx_UpdateTextRect(const SDL_Rect *rect) y += cursor->y; SDL_DBus_CallVoidMethod(FCITX_DBUS_SERVICE, fcitx_client.ic_path, FCITX_IC_DBUS_INTERFACE, "SetCursorRect", - DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y, DBUS_TYPE_INT32, &cursor->w, DBUS_TYPE_INT32, &cursor->h, DBUS_TYPE_INVALID); + DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y, DBUS_TYPE_INT32, &cursor->w, DBUS_TYPE_INT32, &cursor->h, DBUS_TYPE_INVALID); } -void -SDL_Fcitx_PumpEvents(void) +void SDL_Fcitx_PumpEvents(void) { SDL_DBusContext *dbus = fcitx_client.dbus; DBusConnection *conn = dbus->session_conn; diff --git a/src/core/linux/SDL_ibus.c b/src/core/linux/SDL_ibus.c index d56c5d5ce..1f270c726 100644 --- a/src/core/linux/SDL_ibus.c +++ b/src/core/linux/SDL_ibus.c @@ -37,14 +37,14 @@ #include #include -static const char IBUS_PATH[] = "/org/freedesktop/IBus"; +static const char IBUS_PATH[] = "/org/freedesktop/IBus"; -static const char IBUS_SERVICE[] = "org.freedesktop.IBus"; -static const char IBUS_INTERFACE[] = "org.freedesktop.IBus"; +static const char IBUS_SERVICE[] = "org.freedesktop.IBus"; +static const char IBUS_INTERFACE[] = "org.freedesktop.IBus"; static const char IBUS_INPUT_INTERFACE[] = "org.freedesktop.IBus.InputContext"; -static const char IBUS_PORTAL_SERVICE[] = "org.freedesktop.portal.IBus"; -static const char IBUS_PORTAL_INTERFACE[] = "org.freedesktop.IBus.Portal"; +static const char IBUS_PORTAL_SERVICE[] = "org.freedesktop.portal.IBus"; +static const char IBUS_PORTAL_INTERFACE[] = "org.freedesktop.IBus.Portal"; static const char IBUS_PORTAL_INPUT_INTERFACE[] = "org.freedesktop.IBus.InputContext"; static const char *ibus_service = NULL; @@ -57,13 +57,11 @@ static SDL_bool ibus_is_portal_interface = SDL_FALSE; static char *ibus_addr_file = NULL; static int inotify_fd = -1, inotify_wd = -1; - -static Uint32 -IBus_ModState(void) +static Uint32 IBus_ModState(void) { Uint32 ibus_mods = 0; SDL_Keymod sdl_mods = SDL_GetModState(); - + /* Not sure about MOD3, MOD4 and HYPER mappings */ if (sdl_mods & KMOD_LSHIFT) { ibus_mods |= IBUS_SHIFT_MASK; @@ -93,9 +91,8 @@ IBus_ModState(void) return ibus_mods; } -static SDL_bool -IBus_EnterVariant(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus, - DBusMessageIter *inside, const char * struct_id, size_t id_size) +static SDL_bool IBus_EnterVariant(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus, + DBusMessageIter *inside, const char *struct_id, size_t id_size) { DBusMessageIter sub; if (dbus->message_iter_get_arg_type(iter) != DBUS_TYPE_VARIANT) { @@ -121,9 +118,8 @@ IBus_EnterVariant(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext * return SDL_TRUE; } -static SDL_bool -IBus_GetDecorationPosition(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus, - Uint32 *start_pos, Uint32 *end_pos) +static SDL_bool IBus_GetDecorationPosition(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus, + Uint32 *start_pos, Uint32 *end_pos) { DBusMessageIter sub1, sub2, array; @@ -186,8 +182,7 @@ IBus_GetDecorationPosition(DBusConnection *conn, DBusMessageIter *iter, SDL_DBus return SDL_FALSE; } -static const char * -IBus_GetVariantText(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus) +static const char *IBus_GetVariantText(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus) { /* The text we need is nested weirdly, use dbus-monitor to see the structure better */ const char *text = NULL; @@ -208,9 +203,8 @@ IBus_GetVariantText(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext return text; } -static SDL_bool -IBus_GetVariantCursorPos(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus, - Uint32 *pos) +static SDL_bool IBus_GetVariantCursorPos(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus, + Uint32 *pos) { dbus->message_iter_next(iter); @@ -223,8 +217,7 @@ IBus_GetVariantCursorPos(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusCo return SDL_TRUE; } -static DBusHandlerResult -IBus_MessageHandler(DBusConnection *conn, DBusMessage *msg, void *user_data) +static DBusHandlerResult IBus_MessageHandler(DBusConnection *conn, DBusMessage *msg, void *user_data) { SDL_DBusContext *dbus = (SDL_DBusContext *)user_data; @@ -240,7 +233,7 @@ IBus_MessageHandler(DBusConnection *conn, DBusMessage *msg, void *user_data) size_t text_bytes = SDL_strlen(text), i = 0; while (i < text_bytes) { - size_t sz = SDL_utf8strlcpy(buf, text+i, sizeof(buf)); + size_t sz = SDL_utf8strlcpy(buf, text + i, sizeof(buf)); SDL_SendKeyboardText(buf); i += sz; @@ -283,7 +276,7 @@ IBus_MessageHandler(DBusConnection *conn, DBusMessage *msg, void *user_data) size_t cursor = 0; do { - const size_t sz = SDL_utf8strlcpy(buf, text+i, sizeof(buf)); + const size_t sz = SDL_utf8strlcpy(buf, text + i, sizeof(buf)); const size_t chars = SDL_utf8strlen(buf); SDL_SendEditingText(buf, cursor, chars); @@ -306,8 +299,7 @@ IBus_MessageHandler(DBusConnection *conn, DBusMessage *msg, void *user_data) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } -static char * -IBus_ReadAddressFromFile(const char *file_path) +static char *IBus_ReadAddressFromFile(const char *file_path) { char addr_buf[1024]; SDL_bool success = SDL_FALSE; @@ -319,7 +311,7 @@ IBus_ReadAddressFromFile(const char *file_path) } while (fgets(addr_buf, sizeof(addr_buf), addr_file)) { - if (SDL_strncmp(addr_buf, "IBUS_ADDRESS=", sizeof("IBUS_ADDRESS=")-1) == 0) { + if (SDL_strncmp(addr_buf, "IBUS_ADDRESS=", sizeof("IBUS_ADDRESS=") - 1) == 0) { size_t sz = SDL_strlen(addr_buf); if (addr_buf[sz - 1] == '\n') { addr_buf[sz - 1] = 0; @@ -341,8 +333,7 @@ IBus_ReadAddressFromFile(const char *file_path) } } -static char * -IBus_GetDBusAddressFilename(void) +static char *IBus_GetDBusAddressFilename(void) { SDL_DBusContext *dbus; const char *disp_env; @@ -358,18 +349,18 @@ IBus_GetDBusAddressFilename(void) if (ibus_addr_file) { return SDL_strdup(ibus_addr_file); } - + dbus = SDL_DBus_GetContext(); if (dbus == NULL) { return NULL; } - + /* Use this environment variable if it exists. */ addr = SDL_getenv("IBUS_ADDRESS"); if (addr && *addr) { return SDL_strdup(addr); } - + /* Otherwise, we have to get the hostname, display, machine id, config dir and look up the address from a filepath using all those bits, eek. */ disp_env = SDL_getenv("DISPLAY"); @@ -379,23 +370,23 @@ IBus_GetDBusAddressFilename(void) } else { display = SDL_strdup(disp_env); } - + host = display; - disp_num = SDL_strrchr(display, ':'); + disp_num = SDL_strrchr(display, ':'); screen_num = SDL_strrchr(display, '.'); - + if (disp_num == NULL) { SDL_free(display); return NULL; } - + *disp_num = 0; disp_num++; - + if (screen_num) { *screen_num = 0; } - + if (!*host) { const char *session = SDL_getenv("XDG_SESSION_TYPE"); if (session != NULL && SDL_strcmp(session, "wayland") == 0) { @@ -404,9 +395,9 @@ IBus_GetDBusAddressFilename(void) host = "unix"; } } - + SDL_memset(config_dir, 0, sizeof(config_dir)); - + conf_env = SDL_getenv("XDG_CONFIG_HOME"); if (conf_env && *conf_env) { SDL_strlcpy(config_dir, conf_env, sizeof(config_dir)); @@ -418,26 +409,25 @@ IBus_GetDBusAddressFilename(void) } SDL_snprintf(config_dir, sizeof(config_dir), "%s/.config", home_env); } - + key = dbus->get_local_machine_id(); SDL_memset(file_path, 0, sizeof(file_path)); - SDL_snprintf(file_path, sizeof(file_path), "%s/ibus/bus/%s-%s-%s", - config_dir, key, host, disp_num); + SDL_snprintf(file_path, sizeof(file_path), "%s/ibus/bus/%s-%s-%s", + config_dir, key, host, disp_num); dbus->free(key); SDL_free(display); - + return SDL_strdup(file_path); } static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus); -static void SDLCALL -IBus_SetCapabilities(void *data, const char *name, const char *old_val, - const char *internal_editing) +static void SDLCALL IBus_SetCapabilities(void *data, const char *name, const char *old_val, + const char *internal_editing) { SDL_DBusContext *dbus = SDL_DBus_GetContext(); - + if (IBus_CheckConnection(dbus)) { Uint32 caps = IBUS_CAP_FOCUS; if (!(internal_editing && *internal_editing == '1')) { @@ -445,19 +435,17 @@ IBus_SetCapabilities(void *data, const char *name, const char *old_val, } SDL_DBus_CallVoidMethodOnConnection(ibus_conn, ibus_service, input_ctx_path, ibus_input_interface, "SetCapabilities", - DBUS_TYPE_UINT32, &caps, DBUS_TYPE_INVALID); + DBUS_TYPE_UINT32, &caps, DBUS_TYPE_INVALID); } } - -static SDL_bool -IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr) +static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr) { const char *client_name = "SDL2_Application"; const char *path = NULL; SDL_bool result = SDL_FALSE; DBusObjectPathVTable ibus_vtable; - + SDL_zero(ibus_vtable); ibus_vtable.message_function = &IBus_MessageHandler; @@ -481,16 +469,16 @@ IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr) ibus_conn = dbus->connection_open_private(addr, NULL); if (ibus_conn == NULL) { - return SDL_FALSE; /* oh well. */ + return SDL_FALSE; /* oh well. */ } dbus->connection_flush(ibus_conn); - + if (!dbus->bus_register(ibus_conn, NULL)) { ibus_conn = NULL; return SDL_FALSE; } - + dbus->connection_flush(ibus_conn); result = SDL_DBus_CallMethodOnConnection(ibus_conn, ibus_service, IBUS_PATH, ibus_interface, "CreateInputContext", @@ -500,7 +488,7 @@ IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr) if (result) { char matchstr[128]; - SDL_snprintf(matchstr, sizeof (matchstr), "type='signal',interface='%s'", ibus_input_interface); + SDL_snprintf(matchstr, sizeof(matchstr), "type='signal',interface='%s'", ibus_input_interface); SDL_free(input_ctx_path); input_ctx_path = SDL_strdup(path); SDL_AddHintCallback(SDL_HINT_IME_INTERNAL_EDITING, IBus_SetCapabilities, NULL); @@ -511,46 +499,45 @@ IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr) SDL_IBus_SetFocus(SDL_GetKeyboardFocus() != NULL); SDL_IBus_UpdateTextRect(NULL); - + return result; } -static SDL_bool -IBus_CheckConnection(SDL_DBusContext *dbus) +static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus) { if (dbus == NULL) { return SDL_FALSE; } - + if (ibus_conn && dbus->connection_get_is_connected(ibus_conn)) { return SDL_TRUE; } - + if (inotify_fd > 0 && inotify_wd > 0) { char buf[1024]; ssize_t readsize = read(inotify_fd, buf, sizeof(buf)); if (readsize > 0) { - + char *p; SDL_bool file_updated = SDL_FALSE; - + for (p = buf; p < buf + readsize; /**/) { - struct inotify_event *event = (struct inotify_event*) p; + struct inotify_event *event = (struct inotify_event *)p; if (event->len > 0) { char *addr_file_no_path = SDL_strrchr(ibus_addr_file, '/'); if (addr_file_no_path == NULL) { return SDL_FALSE; } - + if (SDL_strcmp(addr_file_no_path + 1, event->name) == 0) { file_updated = SDL_TRUE; break; } } - + p += sizeof(struct inotify_event) + event->len; } - + if (file_updated) { char *addr = IBus_ReadAddressFromFile(ibus_addr_file); if (addr) { @@ -561,7 +548,7 @@ IBus_CheckConnection(SDL_DBusContext *dbus) } } } - + return SDL_FALSE; } @@ -570,7 +557,7 @@ SDL_IBus_Init(void) { SDL_bool result = SDL_FALSE; SDL_DBusContext *dbus = SDL_DBus_GetContext(); - + if (dbus) { char *addr_file = IBus_GetDBusAddressFilename(); char *addr; @@ -579,29 +566,29 @@ SDL_IBus_Init(void) if (addr_file == NULL) { return SDL_FALSE; } - + /* !!! FIXME: if ibus_addr_file != NULL, this will overwrite it and leak (twice!) */ ibus_addr_file = SDL_strdup(addr_file); - + addr = IBus_ReadAddressFromFile(addr_file); if (addr == NULL) { SDL_free(addr_file); return SDL_FALSE; } - + if (inotify_fd < 0) { inotify_fd = inotify_init(); fcntl(inotify_fd, F_SETFL, O_NONBLOCK); } - + addr_file_dir = SDL_strrchr(addr_file, '/'); if (addr_file_dir) { *addr_file_dir = 0; } - + inotify_wd = inotify_add_watch(inotify_fd, addr_file, IN_CREATE | IN_MODIFY); SDL_free(addr_file); - + result = IBus_SetupConnection(dbus, addr); SDL_free(addr); @@ -617,27 +604,26 @@ SDL_IBus_Init(void) } } } - + return result; } -void -SDL_IBus_Quit(void) -{ +void SDL_IBus_Quit(void) +{ SDL_DBusContext *dbus; if (input_ctx_path) { SDL_free(input_ctx_path); input_ctx_path = NULL; } - + if (ibus_addr_file) { SDL_free(ibus_addr_file); ibus_addr_file = NULL; } - + dbus = SDL_DBus_GetContext(); - + /* if using portal, ibus_conn == session_conn; don't release it here. */ if (dbus && ibus_conn && !ibus_is_portal_interface) { dbus->connection_close(ibus_conn); @@ -658,40 +644,36 @@ SDL_IBus_Quit(void) /* !!! FIXME: should we close(inotify_fd) here? */ SDL_DelHintCallback(SDL_HINT_IME_INTERNAL_EDITING, IBus_SetCapabilities, NULL); - + SDL_memset(&ibus_cursor_rect, 0, sizeof(ibus_cursor_rect)); } -static void -IBus_SimpleMessage(const char *method) -{ +static void IBus_SimpleMessage(const char *method) +{ SDL_DBusContext *dbus = SDL_DBus_GetContext(); - + if ((input_ctx_path != NULL) && (IBus_CheckConnection(dbus))) { SDL_DBus_CallVoidMethodOnConnection(ibus_conn, ibus_service, input_ctx_path, ibus_input_interface, method, DBUS_TYPE_INVALID); } } -void -SDL_IBus_SetFocus(SDL_bool focused) -{ +void SDL_IBus_SetFocus(SDL_bool focused) +{ const char *method = focused ? "FocusIn" : "FocusOut"; IBus_SimpleMessage(method); } -void -SDL_IBus_Reset(void) +void SDL_IBus_Reset(void) { IBus_SimpleMessage("Reset"); } SDL_bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state) -{ +{ Uint32 result = 0; SDL_DBusContext *dbus = SDL_DBus_GetContext(); - if (IBus_CheckConnection(dbus)) { Uint32 mods = IBus_ModState(); Uint32 ibus_keycode = keycode - 8; @@ -699,19 +681,18 @@ SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state) mods |= (1 << 30); // IBUS_RELEASE_MASK } if (!SDL_DBus_CallMethodOnConnection(ibus_conn, ibus_service, input_ctx_path, ibus_input_interface, "ProcessKeyEvent", - DBUS_TYPE_UINT32, &keysym, DBUS_TYPE_UINT32, &ibus_keycode, DBUS_TYPE_UINT32, &mods, DBUS_TYPE_INVALID, - DBUS_TYPE_BOOLEAN, &result, DBUS_TYPE_INVALID)) { + DBUS_TYPE_UINT32, &keysym, DBUS_TYPE_UINT32, &ibus_keycode, DBUS_TYPE_UINT32, &mods, DBUS_TYPE_INVALID, + DBUS_TYPE_BOOLEAN, &result, DBUS_TYPE_INVALID)) { result = 0; } } - + SDL_IBus_UpdateTextRect(NULL); return result ? SDL_TRUE : SDL_FALSE; } -void -SDL_IBus_UpdateTextRect(const SDL_Rect *rect) +void SDL_IBus_UpdateTextRect(const SDL_Rect *rect) { SDL_Window *focused_win; SDL_SysWMinfo info; @@ -749,23 +730,22 @@ SDL_IBus_UpdateTextRect(const SDL_Rect *rect) x += ibus_cursor_rect.x; y += ibus_cursor_rect.y; - + dbus = SDL_DBus_GetContext(); - + if (IBus_CheckConnection(dbus)) { SDL_DBus_CallVoidMethodOnConnection(ibus_conn, ibus_service, input_ctx_path, ibus_input_interface, "SetCursorLocation", - DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y, DBUS_TYPE_INT32, &ibus_cursor_rect.w, DBUS_TYPE_INT32, &ibus_cursor_rect.h, DBUS_TYPE_INVALID); + DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y, DBUS_TYPE_INT32, &ibus_cursor_rect.w, DBUS_TYPE_INT32, &ibus_cursor_rect.h, DBUS_TYPE_INVALID); } } -void -SDL_IBus_PumpEvents(void) +void SDL_IBus_PumpEvents(void) { SDL_DBusContext *dbus = SDL_DBus_GetContext(); - + if (IBus_CheckConnection(dbus)) { dbus->connection_read_write(ibus_conn, 0); - + while (dbus->connection_dispatch(ibus_conn) == DBUS_DISPATCH_DATA_REMAINS) { /* Do nothing, actual work happens in IBus_MessageHandler */ } diff --git a/src/core/linux/SDL_ibus.h b/src/core/linux/SDL_ibus.h index 7c0bd8da7..29fc09783 100644 --- a/src/core/linux/SDL_ibus.h +++ b/src/core/linux/SDL_ibus.h @@ -43,11 +43,11 @@ extern void SDL_IBus_Reset(void); called some time after this, to receive the TextInput / TextEditing event back. */ extern SDL_bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state); -/* Update the position of IBus' candidate list. If rect is NULL then this will +/* Update the position of IBus' candidate list. If rect is NULL then this will just reposition it relative to the focused window's new position. */ extern void SDL_IBus_UpdateTextRect(const SDL_Rect *window_relative_rect); -/* Checks DBus for new IBus events, and calls SDL_SendKeyboardText / +/* Checks DBus for new IBus events, and calls SDL_SendKeyboardText / SDL_SendEditingText for each event it finds */ extern void SDL_IBus_PumpEvents(void); diff --git a/src/core/linux/SDL_ime.c b/src/core/linux/SDL_ime.c index e43fe8691..038f1112a 100644 --- a/src/core/linux/SDL_ime.c +++ b/src/core/linux/SDL_ime.c @@ -40,8 +40,7 @@ static _SDL_IME_ProcessKeyEvent SDL_IME_ProcessKeyEvent_Real = NULL; static _SDL_IME_UpdateTextRect SDL_IME_UpdateTextRect_Real = NULL; static _SDL_IME_PumpEvents SDL_IME_PumpEvents_Real = NULL; -static void -InitIME() +static void InitIME() { static SDL_bool inited = SDL_FALSE; #ifdef HAVE_FCITX @@ -107,24 +106,21 @@ SDL_IME_Init(void) return SDL_FALSE; } -void -SDL_IME_Quit(void) +void SDL_IME_Quit(void) { if (SDL_IME_Quit_Real) { SDL_IME_Quit_Real(); } } -void -SDL_IME_SetFocus(SDL_bool focused) +void SDL_IME_SetFocus(SDL_bool focused) { if (SDL_IME_SetFocus_Real) { SDL_IME_SetFocus_Real(focused); } } -void -SDL_IME_Reset(void) +void SDL_IME_Reset(void) { if (SDL_IME_Reset_Real) { SDL_IME_Reset_Real(); @@ -141,16 +137,14 @@ SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state) return SDL_FALSE; } -void -SDL_IME_UpdateTextRect(const SDL_Rect *rect) +void SDL_IME_UpdateTextRect(const SDL_Rect *rect) { if (SDL_IME_UpdateTextRect_Real) { SDL_IME_UpdateTextRect_Real(rect); } } -void -SDL_IME_PumpEvents() +void SDL_IME_PumpEvents() { if (SDL_IME_PumpEvents_Real) { SDL_IME_PumpEvents_Real(); diff --git a/src/core/linux/SDL_sandbox.c b/src/core/linux/SDL_sandbox.c index 3987890ad..9cfdc7e6b 100644 --- a/src/core/linux/SDL_sandbox.c +++ b/src/core/linux/SDL_sandbox.c @@ -33,9 +33,7 @@ SDL_Sandbox SDL_DetectSandbox(void) /* For Snap, we check multiple variables because they might be set for * unrelated reasons. This is the same thing WebKitGTK does. */ - if (SDL_getenv("SNAP") != NULL - && SDL_getenv("SNAP_NAME") != NULL - && SDL_getenv("SNAP_REVISION") != NULL) { + if (SDL_getenv("SNAP") != NULL && SDL_getenv("SNAP_NAME") != NULL && SDL_getenv("SNAP_REVISION") != NULL) { return SDL_SANDBOX_SNAP; } diff --git a/src/core/linux/SDL_threadprio.c b/src/core/linux/SDL_threadprio.c index 1648317d1..de6316cfd 100644 --- a/src/core/linux/SDL_threadprio.c +++ b/src/core/linux/SDL_threadprio.c @@ -48,16 +48,16 @@ #include /* d-bus queries to org.freedesktop.RealtimeKit1. */ -#define RTKIT_DBUS_NODE "org.freedesktop.RealtimeKit1" -#define RTKIT_DBUS_PATH "/org/freedesktop/RealtimeKit1" +#define RTKIT_DBUS_NODE "org.freedesktop.RealtimeKit1" +#define RTKIT_DBUS_PATH "/org/freedesktop/RealtimeKit1" #define RTKIT_DBUS_INTERFACE "org.freedesktop.RealtimeKit1" /* d-bus queries to the XDG portal interface to RealtimeKit1 */ -#define XDG_PORTAL_DBUS_NODE "org.freedesktop.portal.Desktop" -#define XDG_PORTAL_DBUS_PATH "/org/freedesktop/portal/desktop" +#define XDG_PORTAL_DBUS_NODE "org.freedesktop.portal.Desktop" +#define XDG_PORTAL_DBUS_PATH "/org/freedesktop/portal/desktop" #define XDG_PORTAL_DBUS_INTERFACE "org.freedesktop.portal.Realtime" -static SDL_bool rtkit_use_session_conn; +static SDL_bool rtkit_use_session_conn; static const char *rtkit_dbus_node; static const char *rtkit_dbus_path; static const char *rtkit_dbus_interface; @@ -72,16 +72,14 @@ static Sint64 rtkit_max_rttime_usec = 200000; * - The desktop portal exists and supports the realtime interface. * - The realtime interface is new enough to have the required bug fixes applied. */ -static SDL_bool -realtime_portal_supported(DBusConnection *conn) +static SDL_bool realtime_portal_supported(DBusConnection *conn) { Sint64 res; return SDL_DBus_QueryPropertyOnConnection(conn, XDG_PORTAL_DBUS_NODE, XDG_PORTAL_DBUS_PATH, XDG_PORTAL_DBUS_INTERFACE, "RTTimeUSecMax", DBUS_TYPE_INT64, &res); } -static void -set_rtkit_interface() +static void set_rtkit_interface() { SDL_DBusContext *dbus = SDL_DBus_GetContext(); @@ -99,8 +97,7 @@ set_rtkit_interface() } } -static DBusConnection* -get_rtkit_dbus_connection() +static DBusConnection *get_rtkit_dbus_connection() { SDL_DBusContext *dbus = SDL_DBus_GetContext(); @@ -111,8 +108,7 @@ get_rtkit_dbus_connection() return NULL; } -static void -rtkit_initialize() +static void rtkit_initialize() { DBusConnection *dbus_conn; @@ -138,8 +134,7 @@ rtkit_initialize() } } -static SDL_bool -rtkit_initialize_realtime_thread() +static SDL_bool rtkit_initialize_realtime_thread() { // Following is an excerpt from rtkit README that outlines the requirements // a thread must meet before making rtkit requests: @@ -164,7 +159,7 @@ rtkit_initialize_realtime_thread() int err; struct rlimit rlimit; int nLimit = RLIMIT_RTTIME; - pid_t nPid = 0; //self + pid_t nPid = 0; // self int nSchedPolicy = sched_getscheduler(nPid) | SCHED_RESET_ON_FORK; struct sched_param schedParam; @@ -198,8 +193,7 @@ rtkit_initialize_realtime_thread() return SDL_TRUE; } -static SDL_bool -rtkit_setpriority_nice(pid_t thread, int nice_level) +static SDL_bool rtkit_setpriority_nice(pid_t thread, int nice_level) { DBusConnection *dbus_conn; Uint64 pid = (Uint64)getpid(); @@ -222,8 +216,7 @@ rtkit_setpriority_nice(pid_t thread, int nice_level) return SDL_TRUE; } -static SDL_bool -rtkit_setpriority_realtime(pid_t thread, int rt_priority) +static SDL_bool rtkit_setpriority_realtime(pid_t thread, int rt_priority) { DBusConnection *dbus_conn; Uint64 pid = (Uint64)getpid(); @@ -261,8 +254,7 @@ rtkit_setpriority_realtime(pid_t thread, int rt_priority) #endif /* threads */ /* this is a public symbol, so it has to exist even if threads are disabled. */ -int -SDL_LinuxSetThreadPriority(Sint64 threadID, int priority) +int SDL_LinuxSetThreadPriority(Sint64 threadID, int priority) { #if SDL_THREADS_DISABLED return SDL_Unsupported(); @@ -294,8 +286,7 @@ SDL_LinuxSetThreadPriority(Sint64 threadID, int priority) } /* this is a public symbol, so it has to exist even if threads are disabled. */ -int -SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy) +int SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy) { #if SDL_THREADS_DISABLED return SDL_Unsupported(); @@ -356,6 +347,6 @@ SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedP #endif } -#endif /* __LINUX__ */ +#endif /* __LINUX__ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/core/linux/SDL_udev.c b/src/core/linux/SDL_udev.c index ce6c0597c..09ce0f719 100644 --- a/src/core/linux/SDL_udev.c +++ b/src/core/linux/SDL_udev.c @@ -49,8 +49,7 @@ static int SDL_UDEV_load_syms(void); static SDL_bool SDL_UDEV_hotplug_update_available(void); static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev); -static SDL_bool -SDL_UDEV_load_sym(const char *fn, void **addr) +static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(_this->udev_handle, fn); if (*addr == NULL) { @@ -61,12 +60,12 @@ SDL_UDEV_load_sym(const char *fn, void **addr) return SDL_TRUE; } -static int -SDL_UDEV_load_syms(void) +static int SDL_UDEV_load_syms(void) { - /* cast funcs to char* first, to please GCC's strict aliasing rules. */ - #define SDL_UDEV_SYM(x) \ - if (!SDL_UDEV_load_sym(#x, (void **) (char *) & _this->syms.x)) return -1 +/* cast funcs to char* first, to please GCC's strict aliasing rules. */ +#define SDL_UDEV_SYM(x) \ + if (!SDL_UDEV_load_sym(#x, (void **)(char *)&_this->syms.x)) \ + return -1 SDL_UDEV_SYM(udev_device_get_action); SDL_UDEV_SYM(udev_device_get_devnode); @@ -94,13 +93,12 @@ SDL_UDEV_load_syms(void) SDL_UDEV_SYM(udev_unref); SDL_UDEV_SYM(udev_device_new_from_devnum); SDL_UDEV_SYM(udev_device_get_devnum); - #undef SDL_UDEV_SYM +#undef SDL_UDEV_SYM return 0; } -static SDL_bool -SDL_UDEV_hotplug_update_available(void) +static SDL_bool SDL_UDEV_hotplug_update_available(void) { if (_this->udev_mon != NULL) { const int fd = _this->syms.udev_monitor_get_fd(_this->udev_mon); @@ -111,14 +109,12 @@ SDL_UDEV_hotplug_update_available(void) return SDL_FALSE; } - -int -SDL_UDEV_Init(void) +int SDL_UDEV_Init(void) { int retval = 0; if (_this == NULL) { - _this = (SDL_UDEV_PrivateData *) SDL_calloc(1, sizeof(*_this)); + _this = (SDL_UDEV_PrivateData *)SDL_calloc(1, sizeof(*_this)); if (_this == NULL) { return SDL_OutOfMemory(); } @@ -151,7 +147,6 @@ SDL_UDEV_Init(void) /* Do an initial scan of existing devices */ SDL_UDEV_Scan(); - } _this->ref_count += 1; @@ -159,8 +154,7 @@ SDL_UDEV_Init(void) return retval; } -void -SDL_UDEV_Quit(void) +void SDL_UDEV_Quit(void) { SDL_UDEV_CallbackList *item; @@ -194,8 +188,7 @@ SDL_UDEV_Quit(void) } } -void -SDL_UDEV_Scan(void) +void SDL_UDEV_Scan(void) { struct udev_enumerate *enumerate = NULL; struct udev_list_entry *devs = NULL; @@ -283,11 +276,7 @@ SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product return found; } - - - -void -SDL_UDEV_UnloadLibrary(void) +void SDL_UDEV_UnloadLibrary(void) { if (_this == NULL) { return; @@ -299,8 +288,7 @@ SDL_UDEV_UnloadLibrary(void) } } -int -SDL_UDEV_LoadLibrary(void) +int SDL_UDEV_LoadLibrary(void) { int retval = 0, i; @@ -327,7 +315,7 @@ SDL_UDEV_LoadLibrary(void) #endif if (_this->udev_handle == NULL) { - for ( i = 0 ; i < SDL_arraysize(SDL_UDEV_LIBS); i++) { + for (i = 0; i < SDL_arraysize(SDL_UDEV_LIBS); i++) { _this->udev_handle = SDL_LoadObject(SDL_UDEV_LIBS[i]); if (_this->udev_handle != NULL) { retval = SDL_UDEV_load_syms(); @@ -356,7 +344,7 @@ static void get_caps(struct udev_device *dev, struct udev_device *pdev, const ch int i; unsigned long v; - SDL_memset(bitmask, 0, bitmask_len*sizeof(*bitmask)); + SDL_memset(bitmask, 0, bitmask_len * sizeof(*bitmask)); value = _this->syms.udev_device_get_sysattr_value(pdev, attr); if (value == NULL) { return; @@ -365,7 +353,7 @@ static void get_caps(struct udev_device *dev, struct udev_device *pdev, const ch SDL_strlcpy(text, value, sizeof(text)); i = 0; while ((word = SDL_strrchr(text, ' ')) != NULL) { - v = SDL_strtoul(word+1, NULL, 16); + v = SDL_strtoul(word + 1, NULL, 16); if (i < bitmask_len) { bitmask[i] = v; } @@ -378,8 +366,7 @@ static void get_caps(struct udev_device *dev, struct udev_device *pdev, const ch } } -static int -guess_device_class(struct udev_device *dev) +static int guess_device_class(struct udev_device *dev) { struct udev_device *pdev; unsigned long bitmask_ev[NBITS(EV_MAX)]; @@ -408,8 +395,7 @@ guess_device_class(struct udev_device *dev) &bitmask_rel[0]); } -static void -device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) +static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) { const char *subsystem; const char *val = NULL; @@ -429,23 +415,23 @@ device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) /* udev rules reference: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c */ val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK"); - if (val != NULL && SDL_strcmp(val, "1") == 0 ) { + if (val != NULL && SDL_strcmp(val, "1") == 0) { devclass |= SDL_UDEV_DEVICE_JOYSTICK; } val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_ACCELEROMETER"); if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE) && - val != NULL && SDL_strcmp(val, "1") == 0 ) { + val != NULL && SDL_strcmp(val, "1") == 0) { devclass |= SDL_UDEV_DEVICE_JOYSTICK; } val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_MOUSE"); - if (val != NULL && SDL_strcmp(val, "1") == 0 ) { + if (val != NULL && SDL_strcmp(val, "1") == 0) { devclass |= SDL_UDEV_DEVICE_MOUSE; } val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_TOUCHSCREEN"); - if (val != NULL && SDL_strcmp(val, "1") == 0 ) { + if (val != NULL && SDL_strcmp(val, "1") == 0) { devclass |= SDL_UDEV_DEVICE_TOUCHSCREEN; } @@ -456,7 +442,7 @@ device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) Ref: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c#n183 */ val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_KEY"); - if (val != NULL && SDL_strcmp(val, "1") == 0 ) { + if (val != NULL && SDL_strcmp(val, "1") == 0) { devclass |= SDL_UDEV_DEVICE_KEYBOARD; } @@ -488,8 +474,7 @@ device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) } } -void -SDL_UDEV_Poll(void) +void SDL_UDEV_Poll(void) { struct udev_device *dev = NULL; const char *action = NULL; @@ -517,11 +502,10 @@ SDL_UDEV_Poll(void) } } -int -SDL_UDEV_AddCallback(SDL_UDEV_Callback cb) +int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb) { SDL_UDEV_CallbackList *item; - item = (SDL_UDEV_CallbackList *) SDL_calloc(1, sizeof (SDL_UDEV_CallbackList)); + item = (SDL_UDEV_CallbackList *)SDL_calloc(1, sizeof(SDL_UDEV_CallbackList)); if (item == NULL) { return SDL_OutOfMemory(); } @@ -538,8 +522,7 @@ SDL_UDEV_AddCallback(SDL_UDEV_Callback cb) return 1; } -void -SDL_UDEV_DelCallback(SDL_UDEV_Callback cb) +void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb) { SDL_UDEV_CallbackList *item; SDL_UDEV_CallbackList *prev = NULL; @@ -578,8 +561,7 @@ SDL_UDEV_GetUdevSyms(void) return &_this->syms; } -void -SDL_UDEV_ReleaseUdevSyms(void) +void SDL_UDEV_ReleaseUdevSyms(void) { SDL_UDEV_Quit(); } diff --git a/src/core/linux/SDL_udev.h b/src/core/linux/SDL_udev.h index 8ac6cbe89..9436189f3 100644 --- a/src/core/linux/SDL_udev.h +++ b/src/core/linux/SDL_udev.h @@ -48,12 +48,14 @@ typedef enum typedef void (*SDL_UDEV_Callback)(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath); -typedef struct SDL_UDEV_CallbackList { +typedef struct SDL_UDEV_CallbackList +{ SDL_UDEV_Callback callback; struct SDL_UDEV_CallbackList *next; } SDL_UDEV_CallbackList; -typedef struct SDL_UDEV_Symbols { +typedef struct SDL_UDEV_Symbols +{ const char *(*udev_device_get_action)(struct udev_device *); const char *(*udev_device_get_devnode)(struct udev_device *); const char *(*udev_device_get_subsystem)(struct udev_device *); @@ -78,8 +80,8 @@ typedef struct SDL_UDEV_Symbols { void (*udev_monitor_unref)(struct udev_monitor *); struct udev *(*udev_new)(void); void (*udev_unref)(struct udev *); - struct udev_device * (*udev_device_new_from_devnum)(struct udev *udev, char type, dev_t devnum); - dev_t (*udev_device_get_devnum) (struct udev_device *udev_device); + struct udev_device *(*udev_device_new_from_devnum)(struct udev *udev, char type, dev_t devnum); + dev_t (*udev_device_get_devnum)(struct udev_device *udev_device); } SDL_UDEV_Symbols; typedef struct SDL_UDEV_PrivateData @@ -90,7 +92,7 @@ typedef struct SDL_UDEV_PrivateData struct udev_monitor *udev_mon; int ref_count; SDL_UDEV_CallbackList *first, *last; - + /* Function pointers */ SDL_UDEV_Symbols syms; } SDL_UDEV_PrivateData; @@ -107,7 +109,6 @@ extern void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb); extern const SDL_UDEV_Symbols *SDL_UDEV_GetUdevSyms(void); extern void SDL_UDEV_ReleaseUdevSyms(void); - #endif /* HAVE_LIBUDEV_H && HAVE_LINUX_INPUT_H */ #endif /* SDL_udev_h_ */ diff --git a/src/core/openbsd/SDL_wscons.h b/src/core/openbsd/SDL_wscons.h index 936d343d0..1a1a1e89e 100644 --- a/src/core/openbsd/SDL_wscons.h +++ b/src/core/openbsd/SDL_wscons.h @@ -19,9 +19,7 @@ 3. This notice may not be removed or altered from any source distribution. */ - void SDL_WSCONS_Init(); void SDL_WSCONS_Quit(); void SDL_WSCONS_PumpEvents(); - diff --git a/src/core/openbsd/SDL_wscons_kbd.c b/src/core/openbsd/SDL_wscons_kbd.c index f17b4009d..44ee56828 100644 --- a/src/core/openbsd/SDL_wscons_kbd.c +++ b/src/core/openbsd/SDL_wscons_kbd.c @@ -39,195 +39,201 @@ #include "../../events/SDL_events_c.h" #ifdef __NetBSD__ -#define KS_GROUP_Ascii KS_GROUP_Plain +#define KS_GROUP_Ascii KS_GROUP_Plain #define KS_Cmd_ScrollBack KS_Cmd_ScrollFastUp -#define KS_Cmd_ScrollFwd KS_Cmd_ScrollFastDown +#define KS_Cmd_ScrollFwd KS_Cmd_ScrollFastDown #endif -#define RETIFIOCTLERR(x) if (x == -1) { free(input); input = NULL; return NULL;} +#define RETIFIOCTLERR(x) \ + if (x == -1) { \ + free(input); \ + input = NULL; \ + return NULL; \ + } typedef struct SDL_WSCONS_mouse_input_data SDL_WSCONS_mouse_input_data; -extern SDL_WSCONS_mouse_input_data* SDL_WSCONS_Init_Mouse(); -extern void updateMouse(SDL_WSCONS_mouse_input_data* input); -extern void SDL_WSCONS_Quit_Mouse(SDL_WSCONS_mouse_input_data* input); +extern SDL_WSCONS_mouse_input_data *SDL_WSCONS_Init_Mouse(); +extern void updateMouse(SDL_WSCONS_mouse_input_data *input); +extern void SDL_WSCONS_Quit_Mouse(SDL_WSCONS_mouse_input_data *input); /* Conversion table courtesy of /usr/src/sys/dev/wscons/wskbdutil.c */ static const unsigned char latin1_to_upper[256] = { /* 0 8 1 9 2 a 3 b 4 c 5 d 6 e 7 f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 2 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 2 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 3 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 3 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 4 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 4 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 5 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 5 */ - 0x00, 'A', 'B', 'C', 'D', 'E', 'F', 'G', /* 6 */ - 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', /* 6 */ - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', /* 7 */ - 'X', 'Y', 'Z', 0x00, 0x00, 0x00, 0x00, 0x00, /* 7 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d */ - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* e */ - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* e */ - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0x00, /* f */ - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0x00, /* f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 2 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 2 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 3 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 3 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 4 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 4 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 5 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 5 */ + 0x00, 'A', 'B', 'C', 'D', 'E', 'F', 'G', /* 6 */ + 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', /* 6 */ + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', /* 7 */ + 'X', 'Y', 'Z', 0x00, 0x00, 0x00, 0x00, 0x00, /* 7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d */ + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* e */ + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* e */ + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0x00, /* f */ + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0x00, /* f */ }; /* Compose table courtesy of /usr/src/sys/dev/wscons/wskbdutil.c */ -static struct SDL_wscons_compose_tab_s { +static struct SDL_wscons_compose_tab_s +{ keysym_t elem[2]; keysym_t result; } compose_tab[] = { - { { KS_plus, KS_plus }, KS_numbersign }, - { { KS_a, KS_a }, KS_at }, - { { KS_parenleft, KS_parenleft }, KS_bracketleft }, - { { KS_slash, KS_slash }, KS_backslash }, - { { KS_parenright, KS_parenright }, KS_bracketright }, - { { KS_parenleft, KS_minus }, KS_braceleft }, - { { KS_slash, KS_minus }, KS_bar }, - { { KS_parenright, KS_minus }, KS_braceright }, - { { KS_exclam, KS_exclam }, KS_exclamdown }, - { { KS_c, KS_slash }, KS_cent }, - { { KS_l, KS_minus }, KS_sterling }, - { { KS_y, KS_minus }, KS_yen }, - { { KS_s, KS_o }, KS_section }, - { { KS_x, KS_o }, KS_currency }, - { { KS_c, KS_o }, KS_copyright }, - { { KS_less, KS_less }, KS_guillemotleft }, - { { KS_greater, KS_greater }, KS_guillemotright }, - { { KS_question, KS_question }, KS_questiondown }, - { { KS_dead_acute, KS_space }, KS_apostrophe }, - { { KS_dead_grave, KS_space }, KS_grave }, - { { KS_dead_tilde, KS_space }, KS_asciitilde }, - { { KS_dead_circumflex, KS_space }, KS_asciicircum }, - { { KS_dead_diaeresis, KS_space }, KS_quotedbl }, - { { KS_dead_cedilla, KS_space }, KS_comma }, - { { KS_dead_circumflex, KS_A }, KS_Acircumflex }, - { { KS_dead_diaeresis, KS_A }, KS_Adiaeresis }, - { { KS_dead_grave, KS_A }, KS_Agrave }, - { { KS_dead_abovering, KS_A }, KS_Aring }, - { { KS_dead_tilde, KS_A }, KS_Atilde }, - { { KS_dead_cedilla, KS_C }, KS_Ccedilla }, - { { KS_dead_acute, KS_E }, KS_Eacute }, - { { KS_dead_circumflex, KS_E }, KS_Ecircumflex }, - { { KS_dead_diaeresis, KS_E }, KS_Ediaeresis }, - { { KS_dead_grave, KS_E }, KS_Egrave }, - { { KS_dead_acute, KS_I }, KS_Iacute }, - { { KS_dead_circumflex, KS_I }, KS_Icircumflex }, - { { KS_dead_diaeresis, KS_I }, KS_Idiaeresis }, - { { KS_dead_grave, KS_I }, KS_Igrave }, - { { KS_dead_tilde, KS_N }, KS_Ntilde }, - { { KS_dead_acute, KS_O }, KS_Oacute }, - { { KS_dead_circumflex, KS_O }, KS_Ocircumflex }, - { { KS_dead_diaeresis, KS_O }, KS_Odiaeresis }, - { { KS_dead_grave, KS_O }, KS_Ograve }, - { { KS_dead_tilde, KS_O }, KS_Otilde }, - { { KS_dead_acute, KS_U }, KS_Uacute }, - { { KS_dead_circumflex, KS_U }, KS_Ucircumflex }, - { { KS_dead_diaeresis, KS_U }, KS_Udiaeresis }, - { { KS_dead_grave, KS_U }, KS_Ugrave }, - { { KS_dead_acute, KS_Y }, KS_Yacute }, - { { KS_dead_acute, KS_a }, KS_aacute }, - { { KS_dead_circumflex, KS_a }, KS_acircumflex }, - { { KS_dead_diaeresis, KS_a }, KS_adiaeresis }, - { { KS_dead_grave, KS_a }, KS_agrave }, - { { KS_dead_abovering, KS_a }, KS_aring }, - { { KS_dead_tilde, KS_a }, KS_atilde }, - { { KS_dead_cedilla, KS_c }, KS_ccedilla }, - { { KS_dead_acute, KS_e }, KS_eacute }, - { { KS_dead_circumflex, KS_e }, KS_ecircumflex }, - { { KS_dead_diaeresis, KS_e }, KS_ediaeresis }, - { { KS_dead_grave, KS_e }, KS_egrave }, - { { KS_dead_acute, KS_i }, KS_iacute }, - { { KS_dead_circumflex, KS_i }, KS_icircumflex }, - { { KS_dead_diaeresis, KS_i }, KS_idiaeresis }, - { { KS_dead_grave, KS_i }, KS_igrave }, - { { KS_dead_tilde, KS_n }, KS_ntilde }, - { { KS_dead_acute, KS_o }, KS_oacute }, - { { KS_dead_circumflex, KS_o }, KS_ocircumflex }, - { { KS_dead_diaeresis, KS_o }, KS_odiaeresis }, - { { KS_dead_grave, KS_o }, KS_ograve }, - { { KS_dead_tilde, KS_o }, KS_otilde }, - { { KS_dead_acute, KS_u }, KS_uacute }, - { { KS_dead_circumflex, KS_u }, KS_ucircumflex }, - { { KS_dead_diaeresis, KS_u }, KS_udiaeresis }, - { { KS_dead_grave, KS_u }, KS_ugrave }, - { { KS_dead_acute, KS_y }, KS_yacute }, - { { KS_dead_diaeresis, KS_y }, KS_ydiaeresis }, - { { KS_quotedbl, KS_A }, KS_Adiaeresis }, - { { KS_quotedbl, KS_E }, KS_Ediaeresis }, - { { KS_quotedbl, KS_I }, KS_Idiaeresis }, - { { KS_quotedbl, KS_O }, KS_Odiaeresis }, - { { KS_quotedbl, KS_U }, KS_Udiaeresis }, - { { KS_quotedbl, KS_a }, KS_adiaeresis }, - { { KS_quotedbl, KS_e }, KS_ediaeresis }, - { { KS_quotedbl, KS_i }, KS_idiaeresis }, - { { KS_quotedbl, KS_o }, KS_odiaeresis }, - { { KS_quotedbl, KS_u }, KS_udiaeresis }, - { { KS_quotedbl, KS_y }, KS_ydiaeresis }, - { { KS_acute, KS_A }, KS_Aacute }, - { { KS_asciicircum, KS_A }, KS_Acircumflex }, - { { KS_grave, KS_A }, KS_Agrave }, - { { KS_asterisk, KS_A }, KS_Aring }, - { { KS_asciitilde, KS_A }, KS_Atilde }, - { { KS_cedilla, KS_C }, KS_Ccedilla }, - { { KS_acute, KS_E }, KS_Eacute }, - { { KS_asciicircum, KS_E }, KS_Ecircumflex }, - { { KS_grave, KS_E }, KS_Egrave }, - { { KS_acute, KS_I }, KS_Iacute }, - { { KS_asciicircum, KS_I }, KS_Icircumflex }, - { { KS_grave, KS_I }, KS_Igrave }, - { { KS_asciitilde, KS_N }, KS_Ntilde }, - { { KS_acute, KS_O }, KS_Oacute }, - { { KS_asciicircum, KS_O }, KS_Ocircumflex }, - { { KS_grave, KS_O }, KS_Ograve }, - { { KS_asciitilde, KS_O }, KS_Otilde }, - { { KS_acute, KS_U }, KS_Uacute }, - { { KS_asciicircum, KS_U }, KS_Ucircumflex }, - { { KS_grave, KS_U }, KS_Ugrave }, - { { KS_acute, KS_Y }, KS_Yacute }, - { { KS_acute, KS_a }, KS_aacute }, - { { KS_asciicircum, KS_a }, KS_acircumflex }, - { { KS_grave, KS_a }, KS_agrave }, - { { KS_asterisk, KS_a }, KS_aring }, - { { KS_asciitilde, KS_a }, KS_atilde }, - { { KS_cedilla, KS_c }, KS_ccedilla }, - { { KS_acute, KS_e }, KS_eacute }, - { { KS_asciicircum, KS_e }, KS_ecircumflex }, - { { KS_grave, KS_e }, KS_egrave }, - { { KS_acute, KS_i }, KS_iacute }, - { { KS_asciicircum, KS_i }, KS_icircumflex }, - { { KS_grave, KS_i }, KS_igrave }, - { { KS_asciitilde, KS_n }, KS_ntilde }, - { { KS_acute, KS_o }, KS_oacute }, - { { KS_asciicircum, KS_o }, KS_ocircumflex }, - { { KS_grave, KS_o }, KS_ograve }, - { { KS_asciitilde, KS_o }, KS_otilde }, - { { KS_acute, KS_u }, KS_uacute }, - { { KS_asciicircum, KS_u }, KS_ucircumflex }, - { { KS_grave, KS_u }, KS_ugrave }, - { { KS_acute, KS_y }, KS_yacute }, + { { KS_plus, KS_plus }, KS_numbersign }, + { { KS_a, KS_a }, KS_at }, + { { KS_parenleft, KS_parenleft }, KS_bracketleft }, + { { KS_slash, KS_slash }, KS_backslash }, + { { KS_parenright, KS_parenright }, KS_bracketright }, + { { KS_parenleft, KS_minus }, KS_braceleft }, + { { KS_slash, KS_minus }, KS_bar }, + { { KS_parenright, KS_minus }, KS_braceright }, + { { KS_exclam, KS_exclam }, KS_exclamdown }, + { { KS_c, KS_slash }, KS_cent }, + { { KS_l, KS_minus }, KS_sterling }, + { { KS_y, KS_minus }, KS_yen }, + { { KS_s, KS_o }, KS_section }, + { { KS_x, KS_o }, KS_currency }, + { { KS_c, KS_o }, KS_copyright }, + { { KS_less, KS_less }, KS_guillemotleft }, + { { KS_greater, KS_greater }, KS_guillemotright }, + { { KS_question, KS_question }, KS_questiondown }, + { { KS_dead_acute, KS_space }, KS_apostrophe }, + { { KS_dead_grave, KS_space }, KS_grave }, + { { KS_dead_tilde, KS_space }, KS_asciitilde }, + { { KS_dead_circumflex, KS_space }, KS_asciicircum }, + { { KS_dead_diaeresis, KS_space }, KS_quotedbl }, + { { KS_dead_cedilla, KS_space }, KS_comma }, + { { KS_dead_circumflex, KS_A }, KS_Acircumflex }, + { { KS_dead_diaeresis, KS_A }, KS_Adiaeresis }, + { { KS_dead_grave, KS_A }, KS_Agrave }, + { { KS_dead_abovering, KS_A }, KS_Aring }, + { { KS_dead_tilde, KS_A }, KS_Atilde }, + { { KS_dead_cedilla, KS_C }, KS_Ccedilla }, + { { KS_dead_acute, KS_E }, KS_Eacute }, + { { KS_dead_circumflex, KS_E }, KS_Ecircumflex }, + { { KS_dead_diaeresis, KS_E }, KS_Ediaeresis }, + { { KS_dead_grave, KS_E }, KS_Egrave }, + { { KS_dead_acute, KS_I }, KS_Iacute }, + { { KS_dead_circumflex, KS_I }, KS_Icircumflex }, + { { KS_dead_diaeresis, KS_I }, KS_Idiaeresis }, + { { KS_dead_grave, KS_I }, KS_Igrave }, + { { KS_dead_tilde, KS_N }, KS_Ntilde }, + { { KS_dead_acute, KS_O }, KS_Oacute }, + { { KS_dead_circumflex, KS_O }, KS_Ocircumflex }, + { { KS_dead_diaeresis, KS_O }, KS_Odiaeresis }, + { { KS_dead_grave, KS_O }, KS_Ograve }, + { { KS_dead_tilde, KS_O }, KS_Otilde }, + { { KS_dead_acute, KS_U }, KS_Uacute }, + { { KS_dead_circumflex, KS_U }, KS_Ucircumflex }, + { { KS_dead_diaeresis, KS_U }, KS_Udiaeresis }, + { { KS_dead_grave, KS_U }, KS_Ugrave }, + { { KS_dead_acute, KS_Y }, KS_Yacute }, + { { KS_dead_acute, KS_a }, KS_aacute }, + { { KS_dead_circumflex, KS_a }, KS_acircumflex }, + { { KS_dead_diaeresis, KS_a }, KS_adiaeresis }, + { { KS_dead_grave, KS_a }, KS_agrave }, + { { KS_dead_abovering, KS_a }, KS_aring }, + { { KS_dead_tilde, KS_a }, KS_atilde }, + { { KS_dead_cedilla, KS_c }, KS_ccedilla }, + { { KS_dead_acute, KS_e }, KS_eacute }, + { { KS_dead_circumflex, KS_e }, KS_ecircumflex }, + { { KS_dead_diaeresis, KS_e }, KS_ediaeresis }, + { { KS_dead_grave, KS_e }, KS_egrave }, + { { KS_dead_acute, KS_i }, KS_iacute }, + { { KS_dead_circumflex, KS_i }, KS_icircumflex }, + { { KS_dead_diaeresis, KS_i }, KS_idiaeresis }, + { { KS_dead_grave, KS_i }, KS_igrave }, + { { KS_dead_tilde, KS_n }, KS_ntilde }, + { { KS_dead_acute, KS_o }, KS_oacute }, + { { KS_dead_circumflex, KS_o }, KS_ocircumflex }, + { { KS_dead_diaeresis, KS_o }, KS_odiaeresis }, + { { KS_dead_grave, KS_o }, KS_ograve }, + { { KS_dead_tilde, KS_o }, KS_otilde }, + { { KS_dead_acute, KS_u }, KS_uacute }, + { { KS_dead_circumflex, KS_u }, KS_ucircumflex }, + { { KS_dead_diaeresis, KS_u }, KS_udiaeresis }, + { { KS_dead_grave, KS_u }, KS_ugrave }, + { { KS_dead_acute, KS_y }, KS_yacute }, + { { KS_dead_diaeresis, KS_y }, KS_ydiaeresis }, + { { KS_quotedbl, KS_A }, KS_Adiaeresis }, + { { KS_quotedbl, KS_E }, KS_Ediaeresis }, + { { KS_quotedbl, KS_I }, KS_Idiaeresis }, + { { KS_quotedbl, KS_O }, KS_Odiaeresis }, + { { KS_quotedbl, KS_U }, KS_Udiaeresis }, + { { KS_quotedbl, KS_a }, KS_adiaeresis }, + { { KS_quotedbl, KS_e }, KS_ediaeresis }, + { { KS_quotedbl, KS_i }, KS_idiaeresis }, + { { KS_quotedbl, KS_o }, KS_odiaeresis }, + { { KS_quotedbl, KS_u }, KS_udiaeresis }, + { { KS_quotedbl, KS_y }, KS_ydiaeresis }, + { { KS_acute, KS_A }, KS_Aacute }, + { { KS_asciicircum, KS_A }, KS_Acircumflex }, + { { KS_grave, KS_A }, KS_Agrave }, + { { KS_asterisk, KS_A }, KS_Aring }, + { { KS_asciitilde, KS_A }, KS_Atilde }, + { { KS_cedilla, KS_C }, KS_Ccedilla }, + { { KS_acute, KS_E }, KS_Eacute }, + { { KS_asciicircum, KS_E }, KS_Ecircumflex }, + { { KS_grave, KS_E }, KS_Egrave }, + { { KS_acute, KS_I }, KS_Iacute }, + { { KS_asciicircum, KS_I }, KS_Icircumflex }, + { { KS_grave, KS_I }, KS_Igrave }, + { { KS_asciitilde, KS_N }, KS_Ntilde }, + { { KS_acute, KS_O }, KS_Oacute }, + { { KS_asciicircum, KS_O }, KS_Ocircumflex }, + { { KS_grave, KS_O }, KS_Ograve }, + { { KS_asciitilde, KS_O }, KS_Otilde }, + { { KS_acute, KS_U }, KS_Uacute }, + { { KS_asciicircum, KS_U }, KS_Ucircumflex }, + { { KS_grave, KS_U }, KS_Ugrave }, + { { KS_acute, KS_Y }, KS_Yacute }, + { { KS_acute, KS_a }, KS_aacute }, + { { KS_asciicircum, KS_a }, KS_acircumflex }, + { { KS_grave, KS_a }, KS_agrave }, + { { KS_asterisk, KS_a }, KS_aring }, + { { KS_asciitilde, KS_a }, KS_atilde }, + { { KS_cedilla, KS_c }, KS_ccedilla }, + { { KS_acute, KS_e }, KS_eacute }, + { { KS_asciicircum, KS_e }, KS_ecircumflex }, + { { KS_grave, KS_e }, KS_egrave }, + { { KS_acute, KS_i }, KS_iacute }, + { { KS_asciicircum, KS_i }, KS_icircumflex }, + { { KS_grave, KS_i }, KS_igrave }, + { { KS_asciitilde, KS_n }, KS_ntilde }, + { { KS_acute, KS_o }, KS_oacute }, + { { KS_asciicircum, KS_o }, KS_ocircumflex }, + { { KS_grave, KS_o }, KS_ograve }, + { { KS_asciitilde, KS_o }, KS_otilde }, + { { KS_acute, KS_u }, KS_uacute }, + { { KS_asciicircum, KS_u }, KS_ucircumflex }, + { { KS_grave, KS_u }, KS_ugrave }, + { { KS_acute, KS_y }, KS_yacute }, #ifndef __NetBSD__ - { { KS_dead_caron, KS_space }, KS_L2_caron }, - { { KS_dead_caron, KS_S }, KS_L2_Scaron }, - { { KS_dead_caron, KS_Z }, KS_L2_Zcaron }, - { { KS_dead_caron, KS_s }, KS_L2_scaron }, - { { KS_dead_caron, KS_z }, KS_L2_zcaron } + { { KS_dead_caron, KS_space }, KS_L2_caron }, + { { KS_dead_caron, KS_S }, KS_L2_Scaron }, + { { KS_dead_caron, KS_Z }, KS_L2_Zcaron }, + { { KS_dead_caron, KS_s }, KS_L2_scaron }, + { { KS_dead_caron, KS_z }, KS_L2_zcaron } #endif }; @@ -243,146 +249,148 @@ static keysym_t ksym_upcase(keysym_t ksym) return ksym; } -static struct wscons_keycode_to_SDL { +static struct wscons_keycode_to_SDL +{ keysym_t sourcekey; SDL_Scancode targetKey; } conversion_table[] = { - {KS_Menu, SDL_SCANCODE_APPLICATION}, - {KS_Up, SDL_SCANCODE_UP}, - {KS_Down, SDL_SCANCODE_DOWN}, - {KS_Left, SDL_SCANCODE_LEFT}, - {KS_Right, SDL_SCANCODE_RIGHT}, - {KS_Hold_Screen, SDL_SCANCODE_SCROLLLOCK}, - {KS_Num_Lock, SDL_SCANCODE_NUMLOCKCLEAR}, - {KS_Caps_Lock, SDL_SCANCODE_CAPSLOCK}, - {KS_BackSpace, SDL_SCANCODE_BACKSPACE}, - {KS_space, SDL_SCANCODE_SPACE}, - {KS_Delete, SDL_SCANCODE_BACKSPACE}, - {KS_Home, SDL_SCANCODE_HOME}, - {KS_End, SDL_SCANCODE_END}, - {KS_Pause, SDL_SCANCODE_PAUSE}, - {KS_Print_Screen, SDL_SCANCODE_PRINTSCREEN}, - {KS_Insert, SDL_SCANCODE_INSERT}, - {KS_Escape, SDL_SCANCODE_ESCAPE}, - {KS_Return, SDL_SCANCODE_RETURN}, - {KS_Linefeed, SDL_SCANCODE_RETURN}, - {KS_KP_Delete, SDL_SCANCODE_DELETE}, - {KS_KP_Insert, SDL_SCANCODE_INSERT}, - {KS_Control_L, SDL_SCANCODE_LCTRL}, - {KS_Control_R, SDL_SCANCODE_RCTRL}, - {KS_Shift_L, SDL_SCANCODE_LSHIFT}, - {KS_Shift_R, SDL_SCANCODE_RSHIFT}, - {KS_Alt_L, SDL_SCANCODE_LALT}, - {KS_Alt_R, SDL_SCANCODE_RALT}, - {KS_grave, SDL_SCANCODE_GRAVE}, + { KS_Menu, SDL_SCANCODE_APPLICATION }, + { KS_Up, SDL_SCANCODE_UP }, + { KS_Down, SDL_SCANCODE_DOWN }, + { KS_Left, SDL_SCANCODE_LEFT }, + { KS_Right, SDL_SCANCODE_RIGHT }, + { KS_Hold_Screen, SDL_SCANCODE_SCROLLLOCK }, + { KS_Num_Lock, SDL_SCANCODE_NUMLOCKCLEAR }, + { KS_Caps_Lock, SDL_SCANCODE_CAPSLOCK }, + { KS_BackSpace, SDL_SCANCODE_BACKSPACE }, + { KS_space, SDL_SCANCODE_SPACE }, + { KS_Delete, SDL_SCANCODE_BACKSPACE }, + { KS_Home, SDL_SCANCODE_HOME }, + { KS_End, SDL_SCANCODE_END }, + { KS_Pause, SDL_SCANCODE_PAUSE }, + { KS_Print_Screen, SDL_SCANCODE_PRINTSCREEN }, + { KS_Insert, SDL_SCANCODE_INSERT }, + { KS_Escape, SDL_SCANCODE_ESCAPE }, + { KS_Return, SDL_SCANCODE_RETURN }, + { KS_Linefeed, SDL_SCANCODE_RETURN }, + { KS_KP_Delete, SDL_SCANCODE_DELETE }, + { KS_KP_Insert, SDL_SCANCODE_INSERT }, + { KS_Control_L, SDL_SCANCODE_LCTRL }, + { KS_Control_R, SDL_SCANCODE_RCTRL }, + { KS_Shift_L, SDL_SCANCODE_LSHIFT }, + { KS_Shift_R, SDL_SCANCODE_RSHIFT }, + { KS_Alt_L, SDL_SCANCODE_LALT }, + { KS_Alt_R, SDL_SCANCODE_RALT }, + { KS_grave, SDL_SCANCODE_GRAVE }, - {KS_KP_0, SDL_SCANCODE_KP_0}, - {KS_KP_1, SDL_SCANCODE_KP_1}, - {KS_KP_2, SDL_SCANCODE_KP_2}, - {KS_KP_3, SDL_SCANCODE_KP_3}, - {KS_KP_4, SDL_SCANCODE_KP_4}, - {KS_KP_5, SDL_SCANCODE_KP_5}, - {KS_KP_6, SDL_SCANCODE_KP_6}, - {KS_KP_7, SDL_SCANCODE_KP_7}, - {KS_KP_8, SDL_SCANCODE_KP_8}, - {KS_KP_9, SDL_SCANCODE_KP_9}, - {KS_KP_Enter, SDL_SCANCODE_KP_ENTER}, - {KS_KP_Multiply, SDL_SCANCODE_KP_MULTIPLY}, - {KS_KP_Add, SDL_SCANCODE_KP_PLUS}, - {KS_KP_Subtract, SDL_SCANCODE_KP_MINUS}, - {KS_KP_Divide, SDL_SCANCODE_KP_DIVIDE}, - {KS_KP_Up, SDL_SCANCODE_UP}, - {KS_KP_Down, SDL_SCANCODE_DOWN}, - {KS_KP_Left, SDL_SCANCODE_LEFT}, - {KS_KP_Right, SDL_SCANCODE_RIGHT}, - {KS_KP_Equal, SDL_SCANCODE_KP_EQUALS}, - {KS_f1, SDL_SCANCODE_F1}, - {KS_f2, SDL_SCANCODE_F2}, - {KS_f3, SDL_SCANCODE_F3}, - {KS_f4, SDL_SCANCODE_F4}, - {KS_f5, SDL_SCANCODE_F5}, - {KS_f6, SDL_SCANCODE_F6}, - {KS_f7, SDL_SCANCODE_F7}, - {KS_f8, SDL_SCANCODE_F8}, - {KS_f9, SDL_SCANCODE_F9}, - {KS_f10, SDL_SCANCODE_F10}, - {KS_f11, SDL_SCANCODE_F11}, - {KS_f12, SDL_SCANCODE_F12}, - {KS_f13, SDL_SCANCODE_F13}, - {KS_f14, SDL_SCANCODE_F14}, - {KS_f15, SDL_SCANCODE_F15}, - {KS_f16, SDL_SCANCODE_F16}, - {KS_f17, SDL_SCANCODE_F17}, - {KS_f18, SDL_SCANCODE_F18}, - {KS_f19, SDL_SCANCODE_F19}, - {KS_f20, SDL_SCANCODE_F20}, + { KS_KP_0, SDL_SCANCODE_KP_0 }, + { KS_KP_1, SDL_SCANCODE_KP_1 }, + { KS_KP_2, SDL_SCANCODE_KP_2 }, + { KS_KP_3, SDL_SCANCODE_KP_3 }, + { KS_KP_4, SDL_SCANCODE_KP_4 }, + { KS_KP_5, SDL_SCANCODE_KP_5 }, + { KS_KP_6, SDL_SCANCODE_KP_6 }, + { KS_KP_7, SDL_SCANCODE_KP_7 }, + { KS_KP_8, SDL_SCANCODE_KP_8 }, + { KS_KP_9, SDL_SCANCODE_KP_9 }, + { KS_KP_Enter, SDL_SCANCODE_KP_ENTER }, + { KS_KP_Multiply, SDL_SCANCODE_KP_MULTIPLY }, + { KS_KP_Add, SDL_SCANCODE_KP_PLUS }, + { KS_KP_Subtract, SDL_SCANCODE_KP_MINUS }, + { KS_KP_Divide, SDL_SCANCODE_KP_DIVIDE }, + { KS_KP_Up, SDL_SCANCODE_UP }, + { KS_KP_Down, SDL_SCANCODE_DOWN }, + { KS_KP_Left, SDL_SCANCODE_LEFT }, + { KS_KP_Right, SDL_SCANCODE_RIGHT }, + { KS_KP_Equal, SDL_SCANCODE_KP_EQUALS }, + { KS_f1, SDL_SCANCODE_F1 }, + { KS_f2, SDL_SCANCODE_F2 }, + { KS_f3, SDL_SCANCODE_F3 }, + { KS_f4, SDL_SCANCODE_F4 }, + { KS_f5, SDL_SCANCODE_F5 }, + { KS_f6, SDL_SCANCODE_F6 }, + { KS_f7, SDL_SCANCODE_F7 }, + { KS_f8, SDL_SCANCODE_F8 }, + { KS_f9, SDL_SCANCODE_F9 }, + { KS_f10, SDL_SCANCODE_F10 }, + { KS_f11, SDL_SCANCODE_F11 }, + { KS_f12, SDL_SCANCODE_F12 }, + { KS_f13, SDL_SCANCODE_F13 }, + { KS_f14, SDL_SCANCODE_F14 }, + { KS_f15, SDL_SCANCODE_F15 }, + { KS_f16, SDL_SCANCODE_F16 }, + { KS_f17, SDL_SCANCODE_F17 }, + { KS_f18, SDL_SCANCODE_F18 }, + { KS_f19, SDL_SCANCODE_F19 }, + { KS_f20, SDL_SCANCODE_F20 }, #if !defined(__NetBSD__) - {KS_f21, SDL_SCANCODE_F21}, - {KS_f22, SDL_SCANCODE_F22}, - {KS_f23, SDL_SCANCODE_F23}, - {KS_f24, SDL_SCANCODE_F24}, + { KS_f21, SDL_SCANCODE_F21 }, + { KS_f22, SDL_SCANCODE_F22 }, + { KS_f23, SDL_SCANCODE_F23 }, + { KS_f24, SDL_SCANCODE_F24 }, #endif - {KS_Meta_L, SDL_SCANCODE_LGUI}, - {KS_Meta_R, SDL_SCANCODE_RGUI}, - {KS_Zenkaku_Hankaku, SDL_SCANCODE_LANG5}, - {KS_Hiragana_Katakana, SDL_SCANCODE_INTERNATIONAL2}, - {KS_yen, SDL_SCANCODE_INTERNATIONAL3}, - {KS_Henkan, SDL_SCANCODE_INTERNATIONAL4}, - {KS_Muhenkan, SDL_SCANCODE_INTERNATIONAL5}, - {KS_KP_Prior, SDL_SCANCODE_PRIOR}, + { KS_Meta_L, SDL_SCANCODE_LGUI }, + { KS_Meta_R, SDL_SCANCODE_RGUI }, + { KS_Zenkaku_Hankaku, SDL_SCANCODE_LANG5 }, + { KS_Hiragana_Katakana, SDL_SCANCODE_INTERNATIONAL2 }, + { KS_yen, SDL_SCANCODE_INTERNATIONAL3 }, + { KS_Henkan, SDL_SCANCODE_INTERNATIONAL4 }, + { KS_Muhenkan, SDL_SCANCODE_INTERNATIONAL5 }, + { KS_KP_Prior, SDL_SCANCODE_PRIOR }, - {KS_a, SDL_SCANCODE_A}, - {KS_b, SDL_SCANCODE_B}, - {KS_c, SDL_SCANCODE_C}, - {KS_d, SDL_SCANCODE_D}, - {KS_e, SDL_SCANCODE_E}, - {KS_f, SDL_SCANCODE_F}, - {KS_g, SDL_SCANCODE_G}, - {KS_h, SDL_SCANCODE_H}, - {KS_i, SDL_SCANCODE_I}, - {KS_j, SDL_SCANCODE_J}, - {KS_k, SDL_SCANCODE_K}, - {KS_l, SDL_SCANCODE_L}, - {KS_m, SDL_SCANCODE_M}, - {KS_n, SDL_SCANCODE_N}, - {KS_o, SDL_SCANCODE_O}, - {KS_p, SDL_SCANCODE_P}, - {KS_q, SDL_SCANCODE_Q}, - {KS_r, SDL_SCANCODE_R}, - {KS_s, SDL_SCANCODE_S}, - {KS_t, SDL_SCANCODE_T}, - {KS_u, SDL_SCANCODE_U}, - {KS_v, SDL_SCANCODE_V}, - {KS_w, SDL_SCANCODE_W}, - {KS_x, SDL_SCANCODE_X}, - {KS_y, SDL_SCANCODE_Y}, - {KS_z, SDL_SCANCODE_Z}, + { KS_a, SDL_SCANCODE_A }, + { KS_b, SDL_SCANCODE_B }, + { KS_c, SDL_SCANCODE_C }, + { KS_d, SDL_SCANCODE_D }, + { KS_e, SDL_SCANCODE_E }, + { KS_f, SDL_SCANCODE_F }, + { KS_g, SDL_SCANCODE_G }, + { KS_h, SDL_SCANCODE_H }, + { KS_i, SDL_SCANCODE_I }, + { KS_j, SDL_SCANCODE_J }, + { KS_k, SDL_SCANCODE_K }, + { KS_l, SDL_SCANCODE_L }, + { KS_m, SDL_SCANCODE_M }, + { KS_n, SDL_SCANCODE_N }, + { KS_o, SDL_SCANCODE_O }, + { KS_p, SDL_SCANCODE_P }, + { KS_q, SDL_SCANCODE_Q }, + { KS_r, SDL_SCANCODE_R }, + { KS_s, SDL_SCANCODE_S }, + { KS_t, SDL_SCANCODE_T }, + { KS_u, SDL_SCANCODE_U }, + { KS_v, SDL_SCANCODE_V }, + { KS_w, SDL_SCANCODE_W }, + { KS_x, SDL_SCANCODE_X }, + { KS_y, SDL_SCANCODE_Y }, + { KS_z, SDL_SCANCODE_Z }, - {KS_0, SDL_SCANCODE_0}, - {KS_1, SDL_SCANCODE_1}, - {KS_2, SDL_SCANCODE_2}, - {KS_3, SDL_SCANCODE_3}, - {KS_4, SDL_SCANCODE_4}, - {KS_5, SDL_SCANCODE_5}, - {KS_6, SDL_SCANCODE_6}, - {KS_7, SDL_SCANCODE_7}, - {KS_8, SDL_SCANCODE_8}, - {KS_9, SDL_SCANCODE_9}, - {KS_minus, SDL_SCANCODE_MINUS}, - {KS_equal, SDL_SCANCODE_EQUALS}, - {KS_Tab, SDL_SCANCODE_TAB}, - {KS_KP_Tab, SDL_SCANCODE_KP_TAB}, - {KS_apostrophe, SDL_SCANCODE_APOSTROPHE}, - {KS_bracketleft, SDL_SCANCODE_LEFTBRACKET}, - {KS_bracketright, SDL_SCANCODE_RIGHTBRACKET}, - {KS_semicolon, SDL_SCANCODE_SEMICOLON}, - {KS_comma, SDL_SCANCODE_COMMA}, - {KS_period, SDL_SCANCODE_PERIOD}, - {KS_slash, SDL_SCANCODE_SLASH}, - {KS_backslash, SDL_SCANCODE_BACKSLASH} + { KS_0, SDL_SCANCODE_0 }, + { KS_1, SDL_SCANCODE_1 }, + { KS_2, SDL_SCANCODE_2 }, + { KS_3, SDL_SCANCODE_3 }, + { KS_4, SDL_SCANCODE_4 }, + { KS_5, SDL_SCANCODE_5 }, + { KS_6, SDL_SCANCODE_6 }, + { KS_7, SDL_SCANCODE_7 }, + { KS_8, SDL_SCANCODE_8 }, + { KS_9, SDL_SCANCODE_9 }, + { KS_minus, SDL_SCANCODE_MINUS }, + { KS_equal, SDL_SCANCODE_EQUALS }, + { KS_Tab, SDL_SCANCODE_TAB }, + { KS_KP_Tab, SDL_SCANCODE_KP_TAB }, + { KS_apostrophe, SDL_SCANCODE_APOSTROPHE }, + { KS_bracketleft, SDL_SCANCODE_LEFTBRACKET }, + { KS_bracketright, SDL_SCANCODE_RIGHTBRACKET }, + { KS_semicolon, SDL_SCANCODE_SEMICOLON }, + { KS_comma, SDL_SCANCODE_COMMA }, + { KS_period, SDL_SCANCODE_PERIOD }, + { KS_slash, SDL_SCANCODE_SLASH }, + { KS_backslash, SDL_SCANCODE_BACKSLASH } }; -typedef struct { +typedef struct +{ int fd; struct wskbd_map_data keymap; int ledstate; @@ -398,27 +406,27 @@ typedef struct { int type; } SDL_WSCONS_input_data; -static SDL_WSCONS_input_data* inputs[4] = {NULL, NULL, NULL, NULL}; -static SDL_WSCONS_mouse_input_data* mouseInputData = NULL; -#define IS_CONTROL_HELD (input->shiftstate[2] > 0) -#define IS_ALT_HELD (input->shiftstate[1] > 0) -#define IS_SHIFT_HELD ((input->shiftstate[0] > 0) || (input->ledstate & (1 << 5))) +static SDL_WSCONS_input_data *inputs[4] = { NULL, NULL, NULL, NULL }; +static SDL_WSCONS_mouse_input_data *mouseInputData = NULL; +#define IS_CONTROL_HELD (input->shiftstate[2] > 0) +#define IS_ALT_HELD (input->shiftstate[1] > 0) +#define IS_SHIFT_HELD ((input->shiftstate[0] > 0) || (input->ledstate & (1 << 5))) #define IS_ALTGR_MODE ((input->ledstate & (1 << 4)) || (input->shiftstate[3] > 0)) #define IS_NUMLOCK_ON (input->ledstate & LED_NUM) #define IS_SCROLLLOCK_ON (input->ledstate & LED_SCR) #define IS_CAPSLOCK_ON (input->ledstate & LED_CAP) -static SDL_WSCONS_input_data* SDL_WSCONS_Init_Keyboard(const char* dev) +static SDL_WSCONS_input_data *SDL_WSCONS_Init_Keyboard(const char *dev) { #ifdef WSKBDIO_SETVERSION int version = WSKBDIO_EVENT_VERSION; #endif - SDL_WSCONS_input_data* input = (SDL_WSCONS_input_data*)SDL_calloc(1, sizeof(SDL_WSCONS_input_data)); + SDL_WSCONS_input_data *input = (SDL_WSCONS_input_data *)SDL_calloc(1, sizeof(SDL_WSCONS_input_data)); if (input == NULL) { return input; } - input->fd = open(dev,O_RDWR | O_NONBLOCK | O_CLOEXEC); + input->fd = open(dev, O_RDWR | O_NONBLOCK | O_CLOEXEC); if (input->fd == -1) { free(input); input = NULL; @@ -455,7 +463,7 @@ void SDL_WSCONS_Init() void SDL_WSCONS_Quit() { int i = 0; - SDL_WSCONS_input_data* input = NULL; + SDL_WSCONS_input_data *input = NULL; SDL_WSCONS_Quit_Mouse(mouseInputData); mouseInputData = NULL; @@ -463,7 +471,7 @@ void SDL_WSCONS_Quit() input = inputs[i]; if (input) { if (input->fd != -1 && input->fd != 0) { - ioctl(input->fd,WSKBDIO_SETLEDS, &input->origledstate); + ioctl(input->fd, WSKBDIO_SETLEDS, &input->origledstate); close(input->fd); input->fd = -1; } @@ -477,12 +485,12 @@ void SDL_WSCONS_Quit() static void put_queue(SDL_WSCONS_input_data *kbd, uint c) { /* c is already part of a UTF-8 sequence and safe to add as a character */ - if (kbd->text_len < (sizeof(kbd->text)-1)) { + if (kbd->text_len < (sizeof(kbd->text) - 1)) { kbd->text[kbd->text_len++] = (char)(c); } } -static void put_utf8(SDL_WSCONS_input_data* input, uint c) +static void put_utf8(SDL_WSCONS_input_data *input, uint c) { if (c < 0x80) /* 0******* */ @@ -511,14 +519,14 @@ static void put_utf8(SDL_WSCONS_input_data* input, uint c) } } -static void Translate_to_text(SDL_WSCONS_input_data* input, keysym_t ksym) +static void Translate_to_text(SDL_WSCONS_input_data *input, keysym_t ksym) { if (KS_GROUP(ksym) == KS_GROUP_Keypad) { if (SDL_isprint(ksym & 0xFF)) { ksym &= 0xFF; } } - switch(ksym) { + switch (ksym) { case KS_Escape: case KS_Delete: case KS_BackSpace: @@ -539,19 +547,21 @@ static void Translate_to_text(SDL_WSCONS_input_data* input, keysym_t ksym) } } -static void Translate_to_keycode(SDL_WSCONS_input_data* input, int type, keysym_t ksym) +static void Translate_to_keycode(SDL_WSCONS_input_data *input, int type, keysym_t ksym) { struct wscons_keymap keyDesc = input->keymap.map[ksym]; - keysym_t* group = &keyDesc.group1[KS_GROUP(keyDesc.group1[0]) == KS_GROUP_Keypad && IS_NUMLOCK_ON ? !IS_SHIFT_HELD : 0]; + keysym_t *group = &keyDesc.group1[KS_GROUP(keyDesc.group1[0]) == KS_GROUP_Keypad && IS_NUMLOCK_ON ? !IS_SHIFT_HELD : 0]; int i = 0; /* Check command first, then group[0]*/ switch (keyDesc.command) { - case KS_Cmd_ScrollBack: { + case KS_Cmd_ScrollBack: + { SDL_SendKeyboardKey(type == WSCONS_EVENT_KEY_DOWN ? SDL_PRESSED : SDL_RELEASED, SDL_SCANCODE_PAGEUP); return; } - case KS_Cmd_ScrollFwd: { + case KS_Cmd_ScrollFwd: + { SDL_SendKeyboardKey(type == WSCONS_EVENT_KEY_DOWN ? SDL_PRESSED : SDL_RELEASED, SDL_SCANCODE_PAGEDOWN); return; } @@ -563,14 +573,13 @@ static void Translate_to_keycode(SDL_WSCONS_input_data* input, int type, keysym_ } } SDL_SendKeyboardKey(type == WSCONS_EVENT_KEY_DOWN ? SDL_PRESSED : SDL_RELEASED, SDL_SCANCODE_UNKNOWN); - } -static void updateKeyboard(SDL_WSCONS_input_data* input) +static void updateKeyboard(SDL_WSCONS_input_data *input) { struct wscons_event events[64]; int type; - int n,i,gindex,acc_i; + int n, i, gindex, acc_i; keysym_t *group; keysym_t ksym, result; @@ -581,30 +590,34 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) n /= sizeof(struct wscons_event); for (i = 0; i < n; i++) { type = events[i].type; - switch(type) { - case WSCONS_EVENT_KEY_DOWN: { + switch (type) { + case WSCONS_EVENT_KEY_DOWN: + { switch (input->keymap.map[events[i].value].group1[0]) { - case KS_Hold_Screen: { + case KS_Hold_Screen: + { if (input->lockheldstate[0] >= 1) { - break; + break; } input->ledstate ^= LED_SCR; ioctl(input->fd, WSKBDIO_SETLEDS, &input->ledstate); input->lockheldstate[0] = 1; break; } - case KS_Num_Lock: { + case KS_Num_Lock: + { if (input->lockheldstate[1] >= 1) { - break; + break; } input->ledstate ^= LED_NUM; ioctl(input->fd, WSKBDIO_SETLEDS, &input->ledstate); input->lockheldstate[1] = 1; break; } - case KS_Caps_Lock: { + case KS_Caps_Lock: + { if (input->lockheldstate[2] >= 1) { - break; + break; } input->ledstate ^= LED_CAP; ioctl(input->fd, WSKBDIO_SETLEDS, &input->ledstate); @@ -612,9 +625,10 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) break; } #ifndef __NetBSD__ - case KS_Mode_Lock: { + case KS_Mode_Lock: + { if (input->lockheldstate[3] >= 1) { - break; + break; } input->ledstate ^= 1 << 4; ioctl(input->fd, WSKBDIO_SETLEDS, &input->ledstate); @@ -622,160 +636,174 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) break; } #endif - case KS_Shift_Lock: { + case KS_Shift_Lock: + { if (input->lockheldstate[4] >= 1) { - break; + break; } input->ledstate ^= 1 << 5; ioctl(input->fd, WSKBDIO_SETLEDS, &input->ledstate); input->lockheldstate[4] = 1; break; } - case KS_Shift_L: { + case KS_Shift_L: + { if (input->shiftheldstate[0]) { - break; + break; } input->shiftstate[0]++; input->shiftheldstate[0] = 1; break; } - case KS_Shift_R: { + case KS_Shift_R: + { if (input->shiftheldstate[1]) { - break; + break; } input->shiftstate[0]++; input->shiftheldstate[1] = 1; break; } - case KS_Alt_L: { + case KS_Alt_L: + { if (input->shiftheldstate[2]) { - break; + break; } input->shiftstate[1]++; input->shiftheldstate[2] = 1; break; } - case KS_Alt_R: { + case KS_Alt_R: + { if (input->shiftheldstate[3]) { - break; + break; } input->shiftstate[1]++; input->shiftheldstate[3] = 1; break; } - case KS_Control_L: { + case KS_Control_L: + { if (input->shiftheldstate[4]) { - break; + break; } input->shiftstate[2]++; input->shiftheldstate[4] = 1; break; } - case KS_Control_R: { + case KS_Control_R: + { if (input->shiftheldstate[5]) { - break; + break; } input->shiftstate[2]++; input->shiftheldstate[5] = 1; break; } - case KS_Mode_switch: { + case KS_Mode_switch: + { if (input->shiftheldstate[6]) { - break; + break; } input->shiftstate[3]++; input->shiftheldstate[6] = 1; break; } } - } - break; - case WSCONS_EVENT_KEY_UP: { - switch(input->keymap.map[events[i].value].group1[0]) { - case KS_Hold_Screen: { + } break; + case WSCONS_EVENT_KEY_UP: + { + switch (input->keymap.map[events[i].value].group1[0]) { + case KS_Hold_Screen: + { if (input->lockheldstate[0]) { - input->lockheldstate[0] = 0; + input->lockheldstate[0] = 0; } - } - break; - case KS_Num_Lock: { + } break; + case KS_Num_Lock: + { if (input->lockheldstate[1]) { - input->lockheldstate[1] = 0; + input->lockheldstate[1] = 0; } - } - break; - case KS_Caps_Lock: { + } break; + case KS_Caps_Lock: + { if (input->lockheldstate[2]) { - input->lockheldstate[2] = 0; + input->lockheldstate[2] = 0; } - } - break; + } break; #ifndef __NetBSD__ - case KS_Mode_Lock: { + case KS_Mode_Lock: + { if (input->lockheldstate[3]) { - input->lockheldstate[3] = 0; + input->lockheldstate[3] = 0; } - } - break; + } break; #endif - case KS_Shift_Lock: { + case KS_Shift_Lock: + { if (input->lockheldstate[4]) { - input->lockheldstate[4] = 0; + input->lockheldstate[4] = 0; } - } - break; - case KS_Shift_L: { + } break; + case KS_Shift_L: + { input->shiftheldstate[0] = 0; if (input->shiftstate[0]) { - input->shiftstate[0]--; + input->shiftstate[0]--; } break; } - case KS_Shift_R: { + case KS_Shift_R: + { input->shiftheldstate[1] = 0; if (input->shiftstate[0]) { - input->shiftstate[0]--; + input->shiftstate[0]--; } break; } - case KS_Alt_L: { + case KS_Alt_L: + { input->shiftheldstate[2] = 0; if (input->shiftstate[1]) { - input->shiftstate[1]--; + input->shiftstate[1]--; } break; } - case KS_Alt_R: { + case KS_Alt_R: + { input->shiftheldstate[3] = 0; if (input->shiftstate[1]) { - input->shiftstate[1]--; + input->shiftstate[1]--; } break; } - case KS_Control_L: { + case KS_Control_L: + { input->shiftheldstate[4] = 0; if (input->shiftstate[2]) { - input->shiftstate[2]--; + input->shiftstate[2]--; } break; } - case KS_Control_R: { + case KS_Control_R: + { input->shiftheldstate[5] = 0; if (input->shiftstate[2]) { - input->shiftstate[2]--; + input->shiftstate[2]--; } break; } - case KS_Mode_switch: { + case KS_Mode_switch: + { input->shiftheldstate[6] = 0; if (input->shiftstate[3]) { - input->shiftstate[3]--; + input->shiftstate[3]--; } break; } } - } - break; + } break; case WSCONS_EVENT_ALL_KEYS_UP: for (i = 0; i < SDL_NUM_SCANCODES; i++) { SDL_SendKeyboardKey(SDL_RELEASED, i); @@ -785,7 +813,7 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) if (input->type == WSKBD_TYPE_USB && events[i].value <= 0xE7) SDL_SendKeyboardKey(type == WSCONS_EVENT_KEY_DOWN ? SDL_PRESSED : SDL_RELEASED, (SDL_Scancode)events[i].value); - else + else Translate_to_keycode(input, type, events[i].value); if (type == WSCONS_EVENT_KEY_UP) { @@ -820,7 +848,7 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) case KS_GROUP_Mod: if (ksym == KS_Multi_key) { input->ledstate |= WSKBD_LED_COMPOSE; - ioctl(input->fd,WSKBDIO_SETLEDS, &input->ledstate); + ioctl(input->fd, WSKBDIO_SETLEDS, &input->ledstate); input->composelen = 2; input->composebuffer[0] = input->composebuffer[1] = 0; } @@ -828,11 +856,12 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) case KS_GROUP_Dead: if (input->composelen == 0) { input->ledstate |= WSKBD_LED_COMPOSE; - ioctl(input->fd,WSKBDIO_SETLEDS, &input->ledstate); + ioctl(input->fd, WSKBDIO_SETLEDS, &input->ledstate); input->composelen = 1; input->composebuffer[0] = ksym; input->composebuffer[1] = 0; - } else result = ksym; + } else + result = ksym; break; } if (result == KS_voidSymbol) { @@ -852,17 +881,15 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) if (--input->composelen == 0) { result = KS_voidSymbol; input->ledstate &= ~WSKBD_LED_COMPOSE; - ioctl(input->fd,WSKBDIO_SETLEDS, &input->ledstate); + ioctl(input->fd, WSKBDIO_SETLEDS, &input->ledstate); for (acc_i = 0; acc_i < SDL_arraysize(compose_tab); acc_i++) { - if ((compose_tab[acc_i].elem[0] == input->composebuffer[0] - && compose_tab[acc_i].elem[1] == input->composebuffer[1]) - || (compose_tab[acc_i].elem[0] == input->composebuffer[1] - && compose_tab[acc_i].elem[1] == input->composebuffer[0])) { + if ((compose_tab[acc_i].elem[0] == input->composebuffer[0] && compose_tab[acc_i].elem[1] == input->composebuffer[1]) || (compose_tab[acc_i].elem[0] == input->composebuffer[1] && compose_tab[acc_i].elem[1] == input->composebuffer[0])) { result = compose_tab[acc_i].result; break; } } - } else continue; + } else + continue; } } @@ -875,7 +902,7 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) } else if (result >= KS_3 && result <= KS_7) { result = KS_Escape + (result - KS_3); } else if (result == KS_8) { - result = KS_Delete; + result = KS_Delete; } } if (IS_ALT_HELD) { @@ -884,11 +911,11 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) Translate_to_text(input, result); continue; } else { - result |= 0x80; + result |= 0x80; } } } - Translate_to_text(input,result); + Translate_to_text(input, result); continue; } } diff --git a/src/core/openbsd/SDL_wscons_mouse.c b/src/core/openbsd/SDL_wscons_mouse.c index 683acae0a..277cb78f1 100644 --- a/src/core/openbsd/SDL_wscons_mouse.c +++ b/src/core/openbsd/SDL_wscons_mouse.c @@ -35,18 +35,21 @@ typedef struct SDL_WSCONS_mouse_input_data int fd; } SDL_WSCONS_mouse_input_data; -SDL_WSCONS_mouse_input_data* SDL_WSCONS_Init_Mouse() +SDL_WSCONS_mouse_input_data *SDL_WSCONS_Init_Mouse() { #ifdef WSMOUSEIO_SETVERSION int version = WSMOUSE_EVENT_VERSION; #endif - SDL_WSCONS_mouse_input_data* mouseInputData = SDL_calloc(1, sizeof(SDL_WSCONS_mouse_input_data)); + SDL_WSCONS_mouse_input_data *mouseInputData = SDL_calloc(1, sizeof(SDL_WSCONS_mouse_input_data)); if (mouseInputData == NULL) { return NULL; } - mouseInputData->fd = open("/dev/wsmouse",O_RDWR | O_NONBLOCK | O_CLOEXEC); - if (mouseInputData->fd == -1) {free(mouseInputData); return NULL; } + mouseInputData->fd = open("/dev/wsmouse", O_RDWR | O_NONBLOCK | O_CLOEXEC); + if (mouseInputData->fd == -1) { + free(mouseInputData); + return NULL; + } #ifdef WSMOUSEIO_SETMODE ioctl(mouseInputData->fd, WSMOUSEIO_SETMODE, WSMOUSE_COMPAT); #endif @@ -56,77 +59,72 @@ SDL_WSCONS_mouse_input_data* SDL_WSCONS_Init_Mouse() return mouseInputData; } -void updateMouse(SDL_WSCONS_mouse_input_data* inputData) +void updateMouse(SDL_WSCONS_mouse_input_data *inputData) { struct wscons_event events[64]; int type; - int n,i; - SDL_Mouse* mouse = SDL_GetMouse(); + int n, i; + SDL_Mouse *mouse = SDL_GetMouse(); if ((n = read(inputData->fd, events, sizeof(events))) > 0) { n /= sizeof(struct wscons_event); for (i = 0; i < n; i++) { type = events[i].type; - switch(type) - { + switch (type) { case WSCONS_EVENT_MOUSE_DOWN: - { - switch (events[i].value) - { - case 0: /* Left Mouse Button. */ - SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, SDL_BUTTON_LEFT); - break; - case 1: /* Middle Mouse Button. */ - SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, SDL_BUTTON_MIDDLE); - break; - case 2: /* Right Mouse Button. */ - SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, SDL_BUTTON_RIGHT); - break; - } + { + switch (events[i].value) { + case 0: /* Left Mouse Button. */ + SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, SDL_BUTTON_LEFT); + break; + case 1: /* Middle Mouse Button. */ + SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, SDL_BUTTON_MIDDLE); + break; + case 2: /* Right Mouse Button. */ + SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, SDL_BUTTON_RIGHT); + break; } - break; + } break; case WSCONS_EVENT_MOUSE_UP: - { - switch (events[i].value) - { - case 0: /* Left Mouse Button. */ - SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, SDL_BUTTON_LEFT); - break; - case 1: /* Middle Mouse Button. */ - SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, SDL_BUTTON_MIDDLE); - break; - case 2: /* Right Mouse Button. */ - SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, SDL_BUTTON_RIGHT); - break; - } + { + switch (events[i].value) { + case 0: /* Left Mouse Button. */ + SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, SDL_BUTTON_LEFT); + break; + case 1: /* Middle Mouse Button. */ + SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, SDL_BUTTON_MIDDLE); + break; + case 2: /* Right Mouse Button. */ + SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, SDL_BUTTON_RIGHT); + break; } - break; + } break; case WSCONS_EVENT_MOUSE_DELTA_X: - { - SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 1, events[i].value, 0); - break; - } + { + SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 1, events[i].value, 0); + break; + } case WSCONS_EVENT_MOUSE_DELTA_Y: - { - SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 1, 0, -events[i].value); - break; - } + { + SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 1, 0, -events[i].value); + break; + } case WSCONS_EVENT_MOUSE_DELTA_W: - { - SDL_SendMouseWheel(mouse->focus, mouse->mouseID, events[i].value, 0, SDL_MOUSEWHEEL_NORMAL); - break; - } + { + SDL_SendMouseWheel(mouse->focus, mouse->mouseID, events[i].value, 0, SDL_MOUSEWHEEL_NORMAL); + break; + } case WSCONS_EVENT_MOUSE_DELTA_Z: - { - SDL_SendMouseWheel(mouse->focus, mouse->mouseID, 0, -events[i].value, SDL_MOUSEWHEEL_NORMAL); - break; - } + { + SDL_SendMouseWheel(mouse->focus, mouse->mouseID, 0, -events[i].value, SDL_MOUSEWHEEL_NORMAL); + break; + } } } } } -void SDL_WSCONS_Quit_Mouse(SDL_WSCONS_mouse_input_data* inputData) +void SDL_WSCONS_Quit_Mouse(SDL_WSCONS_mouse_input_data *inputData) { if (inputData == NULL) { return; diff --git a/src/core/unix/SDL_poll.c b/src/core/unix/SDL_poll.c index f86b3ada6..9a1836ee4 100644 --- a/src/core/unix/SDL_poll.c +++ b/src/core/unix/SDL_poll.c @@ -32,17 +32,14 @@ #endif #include - -int -SDL_IOReady(int fd, int flags, int timeoutMS) +int SDL_IOReady(int fd, int flags, int timeoutMS) { int result; SDL_assert(flags & (SDL_IOR_READ | SDL_IOR_WRITE)); /* Note: We don't bother to account for elapsed time if we get EINTR */ - do - { + do { #ifdef HAVE_POLL struct pollfd info; @@ -83,7 +80,7 @@ SDL_IOReady(int fd, int flags, int timeoutMS) result = select(fd + 1, rfdp, wfdp, NULL, tvp); #endif /* HAVE_POLL */ - } while ( result < 0 && errno == EINTR && !(flags & SDL_IOR_NO_RETRY)); + } while (result < 0 && errno == EINTR && !(flags & SDL_IOR_NO_RETRY)); return result; } diff --git a/src/core/windows/SDL_directx.h b/src/core/windows/SDL_directx.h index bb69c5781..0f24d15aa 100644 --- a/src/core/windows/SDL_directx.h +++ b/src/core/windows/SDL_directx.h @@ -30,7 +30,7 @@ #ifndef WIN32 #define WIN32 #endif -#undef WINNT +#undef WINNT /* Far pointers don't exist in 32-bit code */ #ifndef FAR @@ -39,35 +39,35 @@ /* Error codes not yet included in Win32 API header files */ #ifndef MAKE_HRESULT -#define MAKE_HRESULT(sev,fac,code) \ - ((HRESULT)(((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code)))) +#define MAKE_HRESULT(sev, fac, code) \ + ((HRESULT)(((unsigned long)(sev) << 31) | ((unsigned long)(fac) << 16) | ((unsigned long)(code)))) #endif #ifndef S_OK -#define S_OK (HRESULT)0x00000000L +#define S_OK (HRESULT)0x00000000L #endif #ifndef SUCCEEDED -#define SUCCEEDED(x) ((HRESULT)(x) >= 0) +#define SUCCEEDED(x) ((HRESULT)(x) >= 0) #endif #ifndef FAILED -#define FAILED(x) ((HRESULT)(x)<0) +#define FAILED(x) ((HRESULT)(x) < 0) #endif #ifndef E_FAIL -#define E_FAIL (HRESULT)0x80000008L +#define E_FAIL (HRESULT)0x80000008L #endif #ifndef E_NOINTERFACE -#define E_NOINTERFACE (HRESULT)0x80004002L +#define E_NOINTERFACE (HRESULT)0x80004002L #endif #ifndef E_OUTOFMEMORY -#define E_OUTOFMEMORY (HRESULT)0x8007000EL +#define E_OUTOFMEMORY (HRESULT)0x8007000EL #endif #ifndef E_INVALIDARG -#define E_INVALIDARG (HRESULT)0x80070057L +#define E_INVALIDARG (HRESULT)0x80070057L #endif #ifndef E_NOTIMPL -#define E_NOTIMPL (HRESULT)0x80004001L +#define E_NOTIMPL (HRESULT)0x80004001L #endif #ifndef REGDB_E_CLASSNOTREG #define REGDB_E_CLASSNOTREG (HRESULT)0x80040154L @@ -75,16 +75,16 @@ /* Severity codes */ #ifndef SEVERITY_ERROR -#define SEVERITY_ERROR 1 +#define SEVERITY_ERROR 1 #endif /* Error facility codes */ #ifndef FACILITY_WIN32 -#define FACILITY_WIN32 7 +#define FACILITY_WIN32 7 #endif #ifndef FIELD_OFFSET -#define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field)) +#define FIELD_OFFSET(type, field) ((LONG) & (((type *)0)->field)) #endif /* DirectX headers (if it isn't included, I haven't tested it yet) @@ -103,7 +103,10 @@ #ifdef HAVE_DINPUT_H #include #else -typedef struct { int unused; } DIDEVICEINSTANCE; +typedef struct +{ + int unused; +} DIDEVICEINSTANCE; #endif #endif /* SDL_directx_h_ */ diff --git a/src/core/windows/SDL_hid.c b/src/core/windows/SDL_hid.c index 225fe703b..0fe2cfb3c 100644 --- a/src/core/windows/SDL_hid.c +++ b/src/core/windows/SDL_hid.c @@ -24,7 +24,6 @@ #include "SDL_hid.h" - HidD_GetString_t SDL_HidD_GetManufacturerString; HidD_GetString_t SDL_HidD_GetProductString; HidP_GetCaps_t SDL_HidP_GetCaps; @@ -36,14 +35,12 @@ HidP_GetData_t SDL_HidP_GetData; static HMODULE s_pHIDDLL = 0; static int s_HIDDLLRefCount = 0; - -int -WIN_LoadHIDDLL(void) +int WIN_LoadHIDDLL(void) { if (s_pHIDDLL) { SDL_assert(s_HIDDLLRefCount > 0); s_HIDDLLRefCount++; - return 0; /* already loaded */ + return 0; /* already loaded */ } s_pHIDDLL = LoadLibrary(TEXT("hid.dll")); @@ -71,8 +68,7 @@ WIN_LoadHIDDLL(void) return 0; } -void -WIN_UnloadHIDDLL(void) +void WIN_UnloadHIDDLL(void) { if (s_pHIDDLL) { SDL_assert(s_HIDDLLRefCount > 0); diff --git a/src/core/windows/SDL_hid.h b/src/core/windows/SDL_hid.h index 82a001a2e..844fdaf34 100644 --- a/src/core/windows/SDL_hid.h +++ b/src/core/windows/SDL_hid.h @@ -39,155 +39,166 @@ typedef struct _HIDD_ATTRIBUTES USHORT VersionNumber; } HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES; -typedef enum { +typedef enum +{ HidP_Input = 0, HidP_Output = 1, HidP_Feature = 2 } HIDP_REPORT_TYPE; -typedef struct { - USAGE UsagePage; - UCHAR ReportID; +typedef struct +{ + USAGE UsagePage; + UCHAR ReportID; BOOLEAN IsAlias; - USHORT BitField; - USHORT LinkCollection; - USAGE LinkUsage; - USAGE LinkUsagePage; + USHORT BitField; + USHORT LinkCollection; + USAGE LinkUsage; + USAGE LinkUsagePage; BOOLEAN IsRange; BOOLEAN IsStringRange; BOOLEAN IsDesignatorRange; BOOLEAN IsAbsolute; - ULONG Reserved[ 10 ]; - union { - struct { - USAGE UsageMin; - USAGE UsageMax; - USHORT StringMin; - USHORT StringMax; - USHORT DesignatorMin; - USHORT DesignatorMax; - USHORT DataIndexMin; - USHORT DataIndexMax; + ULONG Reserved[10]; + union + { + struct + { + USAGE UsageMin; + USAGE UsageMax; + USHORT StringMin; + USHORT StringMax; + USHORT DesignatorMin; + USHORT DesignatorMax; + USHORT DataIndexMin; + USHORT DataIndexMax; } Range; - struct { - USAGE Usage; - USAGE Reserved1; - USHORT StringIndex; - USHORT Reserved2; - USHORT DesignatorIndex; - USHORT Reserved3; - USHORT DataIndex; - USHORT Reserved4; + struct + { + USAGE Usage; + USAGE Reserved1; + USHORT StringIndex; + USHORT Reserved2; + USHORT DesignatorIndex; + USHORT Reserved3; + USHORT DataIndex; + USHORT Reserved4; } NotRange; }; } HIDP_BUTTON_CAPS, *PHIDP_BUTTON_CAPS; -typedef struct { - USAGE UsagePage; - UCHAR ReportID; +typedef struct +{ + USAGE UsagePage; + UCHAR ReportID; BOOLEAN IsAlias; - USHORT BitField; - USHORT LinkCollection; - USAGE LinkUsage; - USAGE LinkUsagePage; + USHORT BitField; + USHORT LinkCollection; + USAGE LinkUsage; + USAGE LinkUsagePage; BOOLEAN IsRange; BOOLEAN IsStringRange; BOOLEAN IsDesignatorRange; BOOLEAN IsAbsolute; BOOLEAN HasNull; - UCHAR Reserved; - USHORT BitSize; - USHORT ReportCount; - USHORT Reserved2[ 5 ]; - ULONG UnitsExp; - ULONG Units; - LONG LogicalMin; - LONG LogicalMax; - LONG PhysicalMin; - LONG PhysicalMax; - union { - struct { - USAGE UsageMin; - USAGE UsageMax; - USHORT StringMin; - USHORT StringMax; - USHORT DesignatorMin; - USHORT DesignatorMax; - USHORT DataIndexMin; - USHORT DataIndexMax; + UCHAR Reserved; + USHORT BitSize; + USHORT ReportCount; + USHORT Reserved2[5]; + ULONG UnitsExp; + ULONG Units; + LONG LogicalMin; + LONG LogicalMax; + LONG PhysicalMin; + LONG PhysicalMax; + union + { + struct + { + USAGE UsageMin; + USAGE UsageMax; + USHORT StringMin; + USHORT StringMax; + USHORT DesignatorMin; + USHORT DesignatorMax; + USHORT DataIndexMin; + USHORT DataIndexMax; } Range; - struct { - USAGE Usage; - USAGE Reserved1; - USHORT StringIndex; - USHORT Reserved2; - USHORT DesignatorIndex; - USHORT Reserved3; - USHORT DataIndex; - USHORT Reserved4; + struct + { + USAGE Usage; + USAGE Reserved1; + USHORT StringIndex; + USHORT Reserved2; + USHORT DesignatorIndex; + USHORT Reserved3; + USHORT DataIndex; + USHORT Reserved4; } NotRange; }; } HIDP_VALUE_CAPS, *PHIDP_VALUE_CAPS; -typedef struct { - USAGE Usage; - USAGE UsagePage; - USHORT InputReportByteLength; - USHORT OutputReportByteLength; - USHORT FeatureReportByteLength; - USHORT Reserved[ 17 ]; - USHORT NumberLinkCollectionNodes; - USHORT NumberInputButtonCaps; - USHORT NumberInputValueCaps; - USHORT NumberInputDataIndices; - USHORT NumberOutputButtonCaps; - USHORT NumberOutputValueCaps; - USHORT NumberOutputDataIndices; - USHORT NumberFeatureButtonCaps; - USHORT NumberFeatureValueCaps; - USHORT NumberFeatureDataIndices; +typedef struct +{ + USAGE Usage; + USAGE UsagePage; + USHORT InputReportByteLength; + USHORT OutputReportByteLength; + USHORT FeatureReportByteLength; + USHORT Reserved[17]; + USHORT NumberLinkCollectionNodes; + USHORT NumberInputButtonCaps; + USHORT NumberInputValueCaps; + USHORT NumberInputDataIndices; + USHORT NumberOutputButtonCaps; + USHORT NumberOutputValueCaps; + USHORT NumberOutputDataIndices; + USHORT NumberFeatureButtonCaps; + USHORT NumberFeatureValueCaps; + USHORT NumberFeatureDataIndices; } HIDP_CAPS, *PHIDP_CAPS; -typedef struct { - USHORT DataIndex; - USHORT Reserved; - union { - ULONG RawValue; +typedef struct +{ + USHORT DataIndex; + USHORT Reserved; + union + { + ULONG RawValue; BOOLEAN On; }; } HIDP_DATA, *PHIDP_DATA; -#define HIDP_ERROR_CODES( p1, p2 ) ((NTSTATUS)(((p1) << 28) | (0x11 << 16) | (p2))) -#define HIDP_STATUS_SUCCESS HIDP_ERROR_CODES( 0x0, 0x0000 ) -#define HIDP_STATUS_NULL HIDP_ERROR_CODES( 0x8, 0x0001 ) -#define HIDP_STATUS_INVALID_PREPARSED_DATA HIDP_ERROR_CODES( 0xC, 0x0001 ) -#define HIDP_STATUS_INVALID_REPORT_TYPE HIDP_ERROR_CODES( 0xC, 0x0002 ) -#define HIDP_STATUS_INVALID_REPORT_LENGTH HIDP_ERROR_CODES( 0xC, 0x0003 ) -#define HIDP_STATUS_USAGE_NOT_FOUND HIDP_ERROR_CODES( 0xC, 0x0004 ) -#define HIDP_STATUS_VALUE_OUT_OF_RANGE HIDP_ERROR_CODES( 0xC, 0x0005 ) -#define HIDP_STATUS_BAD_LOG_PHY_VALUES HIDP_ERROR_CODES( 0xC, 0x0006 ) -#define HIDP_STATUS_BUFFER_TOO_SMALL HIDP_ERROR_CODES( 0xC, 0x0007 ) -#define HIDP_STATUS_INTERNAL_ERROR HIDP_ERROR_CODES( 0xC, 0x0008 ) -#define HIDP_STATUS_I8042_TRANS_UNKNOWN HIDP_ERROR_CODES( 0xC, 0x0009 ) -#define HIDP_STATUS_INCOMPATIBLE_REPORT_ID HIDP_ERROR_CODES( 0xC, 0x000A ) -#define HIDP_STATUS_NOT_VALUE_ARRAY HIDP_ERROR_CODES( 0xC, 0x000B ) -#define HIDP_STATUS_IS_VALUE_ARRAY HIDP_ERROR_CODES( 0xC, 0x000C ) -#define HIDP_STATUS_DATA_INDEX_NOT_FOUND HIDP_ERROR_CODES( 0xC, 0x000D ) -#define HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE HIDP_ERROR_CODES( 0xC, 0x000E ) -#define HIDP_STATUS_BUTTON_NOT_PRESSED HIDP_ERROR_CODES( 0xC, 0x000F ) -#define HIDP_STATUS_REPORT_DOES_NOT_EXIST HIDP_ERROR_CODES( 0xC, 0x0010 ) -#define HIDP_STATUS_NOT_IMPLEMENTED HIDP_ERROR_CODES( 0xC, 0x0020 ) - +#define HIDP_ERROR_CODES(p1, p2) ((NTSTATUS)(((p1) << 28) | (0x11 << 16) | (p2))) +#define HIDP_STATUS_SUCCESS HIDP_ERROR_CODES(0x0, 0x0000) +#define HIDP_STATUS_NULL HIDP_ERROR_CODES(0x8, 0x0001) +#define HIDP_STATUS_INVALID_PREPARSED_DATA HIDP_ERROR_CODES(0xC, 0x0001) +#define HIDP_STATUS_INVALID_REPORT_TYPE HIDP_ERROR_CODES(0xC, 0x0002) +#define HIDP_STATUS_INVALID_REPORT_LENGTH HIDP_ERROR_CODES(0xC, 0x0003) +#define HIDP_STATUS_USAGE_NOT_FOUND HIDP_ERROR_CODES(0xC, 0x0004) +#define HIDP_STATUS_VALUE_OUT_OF_RANGE HIDP_ERROR_CODES(0xC, 0x0005) +#define HIDP_STATUS_BAD_LOG_PHY_VALUES HIDP_ERROR_CODES(0xC, 0x0006) +#define HIDP_STATUS_BUFFER_TOO_SMALL HIDP_ERROR_CODES(0xC, 0x0007) +#define HIDP_STATUS_INTERNAL_ERROR HIDP_ERROR_CODES(0xC, 0x0008) +#define HIDP_STATUS_I8042_TRANS_UNKNOWN HIDP_ERROR_CODES(0xC, 0x0009) +#define HIDP_STATUS_INCOMPATIBLE_REPORT_ID HIDP_ERROR_CODES(0xC, 0x000A) +#define HIDP_STATUS_NOT_VALUE_ARRAY HIDP_ERROR_CODES(0xC, 0x000B) +#define HIDP_STATUS_IS_VALUE_ARRAY HIDP_ERROR_CODES(0xC, 0x000C) +#define HIDP_STATUS_DATA_INDEX_NOT_FOUND HIDP_ERROR_CODES(0xC, 0x000D) +#define HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE HIDP_ERROR_CODES(0xC, 0x000E) +#define HIDP_STATUS_BUTTON_NOT_PRESSED HIDP_ERROR_CODES(0xC, 0x000F) +#define HIDP_STATUS_REPORT_DOES_NOT_EXIST HIDP_ERROR_CODES(0xC, 0x0010) +#define HIDP_STATUS_NOT_IMPLEMENTED HIDP_ERROR_CODES(0xC, 0x0020) extern int WIN_LoadHIDDLL(void); extern void WIN_UnloadHIDDLL(void); -typedef BOOLEAN (WINAPI *HidD_GetString_t)(HANDLE HidDeviceObject, PVOID Buffer, ULONG BufferLength); -typedef NTSTATUS (WINAPI *HidP_GetCaps_t)(PHIDP_PREPARSED_DATA PreparsedData, PHIDP_CAPS Capabilities); -typedef NTSTATUS (WINAPI *HidP_GetButtonCaps_t)(HIDP_REPORT_TYPE ReportType, PHIDP_BUTTON_CAPS ButtonCaps, PUSHORT ButtonCapsLength, PHIDP_PREPARSED_DATA PreparsedData); -typedef NTSTATUS (WINAPI *HidP_GetValueCaps_t)(HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS ValueCaps, PUSHORT ValueCapsLength, PHIDP_PREPARSED_DATA PreparsedData); -typedef ULONG (WINAPI *HidP_MaxDataListLength_t)(HIDP_REPORT_TYPE ReportType, PHIDP_PREPARSED_DATA PreparsedData); -typedef NTSTATUS (WINAPI *HidP_GetData_t)(HIDP_REPORT_TYPE ReportType, PHIDP_DATA DataList, PULONG DataLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength); +typedef BOOLEAN(WINAPI *HidD_GetString_t)(HANDLE HidDeviceObject, PVOID Buffer, ULONG BufferLength); +typedef NTSTATUS(WINAPI *HidP_GetCaps_t)(PHIDP_PREPARSED_DATA PreparsedData, PHIDP_CAPS Capabilities); +typedef NTSTATUS(WINAPI *HidP_GetButtonCaps_t)(HIDP_REPORT_TYPE ReportType, PHIDP_BUTTON_CAPS ButtonCaps, PUSHORT ButtonCapsLength, PHIDP_PREPARSED_DATA PreparsedData); +typedef NTSTATUS(WINAPI *HidP_GetValueCaps_t)(HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS ValueCaps, PUSHORT ValueCapsLength, PHIDP_PREPARSED_DATA PreparsedData); +typedef ULONG(WINAPI *HidP_MaxDataListLength_t)(HIDP_REPORT_TYPE ReportType, PHIDP_PREPARSED_DATA PreparsedData); +typedef NTSTATUS(WINAPI *HidP_GetData_t)(HIDP_REPORT_TYPE ReportType, PHIDP_DATA DataList, PULONG DataLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength); extern HidD_GetString_t SDL_HidD_GetManufacturerString; extern HidD_GetString_t SDL_HidD_GetProductString; diff --git a/src/core/windows/SDL_immdevice.c b/src/core/windows/SDL_immdevice.c index f55a31b87..41f7adfd2 100644 --- a/src/core/windows/SDL_immdevice.c +++ b/src/core/windows/SDL_immdevice.c @@ -27,7 +27,7 @@ #include "../../audio/SDL_sysaudio.h" #include /* For CLSIDFromString */ -static const ERole SDL_IMMDevice_role = eConsole; /* !!! FIXME: should this be eMultimedia? Should be a hint? */ +static const ERole SDL_IMMDevice_role = eConsole; /* !!! FIXME: should this be eMultimedia? Should be a hint? */ /* This is global to the WASAPI target, to handle hotplug and default device lookup. */ static IMMDeviceEnumerator *enumerator = NULL; @@ -39,6 +39,7 @@ static IMMDeviceEnumerator *enumerator = NULL; #define PropVariantInit(p) SDL_zerop(p) /* Some GUIDs we need to know without linking to libraries that aren't available before Vista. */ +/* *INDENT-OFF* */ /* clang-format off */ static const CLSID SDL_CLSID_MMDeviceEnumerator = { 0xbcde0395, 0xe52f, 0x467c,{ 0x8e, 0x3d, 0xc4, 0x57, 0x92, 0x91, 0x69, 0x2e } }; static const IID SDL_IID_IMMDeviceEnumerator = { 0xa95664d2, 0x9614, 0x4f35,{ 0xa7, 0x46, 0xde, 0x8d, 0xb6, 0x36, 0x17, 0xe6 } }; static const IID SDL_IID_IMMNotificationClient = { 0x7991eec9, 0x7e89, 0x4d85,{ 0x83, 0x90, 0x6c, 0x70, 0x3c, 0xec, 0x60, 0xc0 } }; @@ -48,13 +49,13 @@ static const PROPERTYKEY SDL_PKEY_AudioEngine_DeviceFormat = { { 0xf19f064d, 0x8 static const PROPERTYKEY SDL_PKEY_AudioEndpoint_GUID = { { 0x1da5d803, 0xd492, 0x4edd,{ 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, } }, 4 }; static const GUID SDL_KSDATAFORMAT_SUBTYPE_PCM = { 0x00000001, 0x0000, 0x0010,{ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } }; static const GUID SDL_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = { 0x00000003, 0x0000, 0x0010,{ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } }; +/* *INDENT-ON* */ /* clang-format on */ /* these increment as default devices change. Opened default devices pick up changes in their threads. */ SDL_atomic_t SDL_IMMDevice_DefaultPlaybackGeneration; SDL_atomic_t SDL_IMMDevice_DefaultCaptureGeneration; -static void -GetMMDeviceInfo(IMMDevice *device, char **utf8dev, WAVEFORMATEXTENSIBLE *fmt, GUID *guid) +static void GetMMDeviceInfo(IMMDevice *device, char **utf8dev, WAVEFORMATEXTENSIBLE *fmt, GUID *guid) { /* PKEY_Device_FriendlyName gives you "Speakers (SoundBlaster Pro)" which drives me nuts. I'd rather it be "SoundBlaster Pro (Speakers)" but I guess that's developers vs users. Windows uses the FriendlyName in @@ -91,8 +92,7 @@ typedef struct DevIdList static DevIdList *deviceid_list = NULL; -static void -SDL_IMMDevice_Remove(const SDL_bool iscapture, LPCWSTR devid, SDL_bool useguid) +static void SDL_IMMDevice_Remove(const SDL_bool iscapture, LPCWSTR devid, SDL_bool useguid) { DevIdList *i; DevIdList *next; @@ -105,7 +105,7 @@ SDL_IMMDevice_Remove(const SDL_bool iscapture, LPCWSTR devid, SDL_bool useguid) } else { deviceid_list = next; } - SDL_RemoveAudioDevice(iscapture, useguid ? ((void *) i->guid) : ((void *) i->str)); + SDL_RemoveAudioDevice(iscapture, useguid ? ((void *)i->guid) : ((void *)i->str)); SDL_free(i->str); SDL_free(i); } else { @@ -114,8 +114,7 @@ SDL_IMMDevice_Remove(const SDL_bool iscapture, LPCWSTR devid, SDL_bool useguid) } } -static void -SDL_IMMDevice_Add(const SDL_bool iscapture, const char *devname, WAVEFORMATEXTENSIBLE *fmt, LPCWSTR devid, GUID *dsoundguid, SDL_bool useguid) +static void SDL_IMMDevice_Add(const SDL_bool iscapture, const char *devname, WAVEFORMATEXTENSIBLE *fmt, LPCWSTR devid, GUID *dsoundguid, SDL_bool useguid) { DevIdList *devidlist; SDL_AudioSpec spec; @@ -128,22 +127,22 @@ SDL_IMMDevice_Add(const SDL_bool iscapture, const char *devname, WAVEFORMATEXTEN phones and tablets, where you might have an internal speaker and a headphone jack and expect both to be available and switch automatically. (!!! FIXME...?) */ - /* see if we already have this one. */ + /* see if we already have this one. */ for (devidlist = deviceid_list; devidlist; devidlist = devidlist->next) { if (SDL_wcscmp(devidlist->str, devid) == 0) { - return; /* we already have this. */ + return; /* we already have this. */ } } devidlist = (DevIdList *)SDL_malloc(sizeof(*devidlist)); if (devidlist == NULL) { - return; /* oh well. */ + return; /* oh well. */ } devidcopy = SDL_wcsdup(devid); if (!devidcopy) { SDL_free(devidlist); - return; /* oh well. */ + return; /* oh well. */ } if (useguid) { @@ -185,8 +184,7 @@ typedef struct SDLMMNotificationClient SDL_bool useguid; } SDLMMNotificationClient; -static HRESULT STDMETHODCALLTYPE -SDLMMNotificationClient_QueryInterface(IMMNotificationClient *this, REFIID iid, void **ppv) +static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_QueryInterface(IMMNotificationClient *this, REFIID iid, void **ppv) { if ((WIN_IsEqualIID(iid, &IID_IUnknown)) || (WIN_IsEqualIID(iid, &SDL_IID_IMMNotificationClient))) { *ppv = this; @@ -198,32 +196,29 @@ SDLMMNotificationClient_QueryInterface(IMMNotificationClient *this, REFIID iid, return E_NOINTERFACE; } -static ULONG STDMETHODCALLTYPE -SDLMMNotificationClient_AddRef(IMMNotificationClient *ithis) +static ULONG STDMETHODCALLTYPE SDLMMNotificationClient_AddRef(IMMNotificationClient *ithis) { SDLMMNotificationClient *this = (SDLMMNotificationClient *)ithis; return (ULONG)(SDL_AtomicIncRef(&this->refcount) + 1); } -static ULONG STDMETHODCALLTYPE -SDLMMNotificationClient_Release(IMMNotificationClient *ithis) +static ULONG STDMETHODCALLTYPE SDLMMNotificationClient_Release(IMMNotificationClient *ithis) { /* this is a static object; we don't ever free it. */ SDLMMNotificationClient *this = (SDLMMNotificationClient *)ithis; const ULONG retval = SDL_AtomicDecRef(&this->refcount); if (retval == 0) { - SDL_AtomicSet(&this->refcount, 0); /* uhh... */ + SDL_AtomicSet(&this->refcount, 0); /* uhh... */ return 0; } return retval - 1; } /* These are the entry points called when WASAPI device endpoints change. */ -static HRESULT STDMETHODCALLTYPE -SDLMMNotificationClient_OnDefaultDeviceChanged(IMMNotificationClient *ithis, EDataFlow flow, ERole role, LPCWSTR pwstrDeviceId) +static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_OnDefaultDeviceChanged(IMMNotificationClient *ithis, EDataFlow flow, ERole role, LPCWSTR pwstrDeviceId) { if (role != SDL_IMMDevice_role) { - return S_OK; /* ignore it. */ + return S_OK; /* ignore it. */ } /* Increment the "generation," so opened devices will pick this up in their threads. */ @@ -249,8 +244,7 @@ SDLMMNotificationClient_OnDefaultDeviceChanged(IMMNotificationClient *ithis, EDa return S_OK; } -static HRESULT STDMETHODCALLTYPE -SDLMMNotificationClient_OnDeviceAdded(IMMNotificationClient *ithis, LPCWSTR pwstrDeviceId) +static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_OnDeviceAdded(IMMNotificationClient *ithis, LPCWSTR pwstrDeviceId) { /* we ignore this; devices added here then progress to ACTIVE, if appropriate, in OnDeviceStateChange, making that a better place to deal with device adds. More @@ -260,15 +254,13 @@ SDLMMNotificationClient_OnDeviceAdded(IMMNotificationClient *ithis, LPCWSTR pwst return S_OK; } -static HRESULT STDMETHODCALLTYPE -SDLMMNotificationClient_OnDeviceRemoved(IMMNotificationClient *ithis, LPCWSTR pwstrDeviceId) +static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_OnDeviceRemoved(IMMNotificationClient *ithis, LPCWSTR pwstrDeviceId) { /* See notes in OnDeviceAdded handler about why we ignore this. */ return S_OK; } -static HRESULT STDMETHODCALLTYPE -SDLMMNotificationClient_OnDeviceStateChanged(IMMNotificationClient *ithis, LPCWSTR pwstrDeviceId, DWORD dwNewState) +static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_OnDeviceStateChanged(IMMNotificationClient *ithis, LPCWSTR pwstrDeviceId, DWORD dwNewState) { IMMDevice *device = NULL; @@ -278,7 +270,7 @@ SDLMMNotificationClient_OnDeviceStateChanged(IMMNotificationClient *ithis, LPCWS EDataFlow flow; if (SUCCEEDED(IMMEndpoint_GetDataFlow(endpoint, &flow))) { const SDL_bool iscapture = (flow == eCapture); - const SDLMMNotificationClient *client = (SDLMMNotificationClient*) ithis; + const SDLMMNotificationClient *client = (SDLMMNotificationClient *)ithis; if (dwNewState == DEVICE_STATE_ACTIVE) { char *utf8dev; WAVEFORMATEXTENSIBLE fmt; @@ -300,10 +292,9 @@ SDLMMNotificationClient_OnDeviceStateChanged(IMMNotificationClient *ithis, LPCWS return S_OK; } -static HRESULT STDMETHODCALLTYPE -SDLMMNotificationClient_OnPropertyValueChanged(IMMNotificationClient *this, LPCWSTR pwstrDeviceId, const PROPERTYKEY key) +static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_OnPropertyValueChanged(IMMNotificationClient *this, LPCWSTR pwstrDeviceId, const PROPERTYKEY key) { - return S_OK; /* we don't care about these. */ + return S_OK; /* we don't care about these. */ } static const IMMNotificationClientVtbl notification_client_vtbl = { @@ -319,8 +310,7 @@ static const IMMNotificationClientVtbl notification_client_vtbl = { static SDLMMNotificationClient notification_client = { ¬ification_client_vtbl, { 1 } }; -int -SDL_IMMDevice_Init(void) +int SDL_IMMDevice_Init(void) { HRESULT ret; @@ -344,8 +334,7 @@ SDL_IMMDevice_Init(void) return 0; } -void -SDL_IMMDevice_Quit(void) +void SDL_IMMDevice_Quit(void) { DevIdList *devidlist; DevIdList *next; @@ -366,8 +355,7 @@ SDL_IMMDevice_Quit(void) deviceid_list = NULL; } -int -SDL_IMMDevice_Get(LPCWSTR devid, IMMDevice **device, SDL_bool iscapture) +int SDL_IMMDevice_Get(LPCWSTR devid, IMMDevice **device, SDL_bool iscapture) { HRESULT ret; @@ -422,8 +410,7 @@ static int SDLCALL sort_endpoints(const void *_a, const void *_b) return 0; } -static void -EnumerateEndpointsForFlow(const SDL_bool iscapture) +static void EnumerateEndpointsForFlow(const SDL_bool iscapture) { IMMDeviceCollection *collection = NULL; EndpointItem *items; @@ -443,7 +430,7 @@ EnumerateEndpointsForFlow(const SDL_bool iscapture) items = (EndpointItem *)SDL_calloc(total, sizeof(EndpointItem)); if (items == NULL) { - return; /* oh well. */ + return; /* oh well. */ } for (i = 0; i < total; i++) { @@ -474,20 +461,18 @@ EnumerateEndpointsForFlow(const SDL_bool iscapture) IMMDeviceCollection_Release(collection); } -void -SDL_IMMDevice_EnumerateEndpoints(SDL_bool useguid) +void SDL_IMMDevice_EnumerateEndpoints(SDL_bool useguid) { notification_client.useguid = useguid; - EnumerateEndpointsForFlow(SDL_FALSE); /* playback */ + EnumerateEndpointsForFlow(SDL_FALSE); /* playback */ EnumerateEndpointsForFlow(SDL_TRUE); /* capture */ /* if this fails, we just won't get hotplug events. Carry on anyhow. */ IMMDeviceEnumerator_RegisterEndpointNotificationCallback(enumerator, (IMMNotificationClient *)¬ification_client); } -int -SDL_IMMDevice_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) +int SDL_IMMDevice_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) { WAVEFORMATEXTENSIBLE fmt; IMMDevice *device = NULL; @@ -516,7 +501,7 @@ SDL_IMMDevice_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscaptur SDL_zerop(spec); spec->channels = (Uint8)fmt.Format.nChannels; spec->freq = fmt.Format.nSamplesPerSec; - spec->format = WaveFormatToSDLFormat((WAVEFORMATEX *) &fmt); + spec->format = WaveFormatToSDLFormat((WAVEFORMATEX *)&fmt); return 0; } diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c index ea2378bc1..2dff2f7ff 100644 --- a/src/core/windows/SDL_windows.c +++ b/src/core/windows/SDL_windows.c @@ -26,40 +26,39 @@ #include "SDL_error.h" #include "SDL_system.h" -#include /* for CoInitialize/CoUninitialize (Win32 only) */ +#include /* for CoInitialize/CoUninitialize (Win32 only) */ #if defined(HAVE_ROAPI_H) -#include /* For RoInitialize/RoUninitialize (Win32 only) */ +#include /* For RoInitialize/RoUninitialize (Win32 only) */ #else -typedef enum RO_INIT_TYPE { - RO_INIT_SINGLETHREADED = 0, - RO_INIT_MULTITHREADED = 1 +typedef enum RO_INIT_TYPE +{ + RO_INIT_SINGLETHREADED = 0, + RO_INIT_MULTITHREADED = 1 } RO_INIT_TYPE; #endif #ifndef _WIN32_WINNT_VISTA -#define _WIN32_WINNT_VISTA 0x0600 +#define _WIN32_WINNT_VISTA 0x0600 #endif #ifndef _WIN32_WINNT_WIN7 -#define _WIN32_WINNT_WIN7 0x0601 +#define _WIN32_WINNT_WIN7 0x0601 #endif #ifndef _WIN32_WINNT_WIN8 -#define _WIN32_WINNT_WIN8 0x0602 +#define _WIN32_WINNT_WIN8 0x0602 #endif #ifndef LOAD_LIBRARY_SEARCH_SYSTEM32 #define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 #endif - /* Sets an error message based on an HRESULT */ -int -WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr) +int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr) { TCHAR buffer[1024]; char *message; TCHAR *p = buffer; DWORD c = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr, 0, - buffer, SDL_arraysize(buffer), NULL); + buffer, SDL_arraysize(buffer), NULL); buffer[c] = 0; /* kill CR/LF that FormatMessage() sticks at the end */ while (*p) { @@ -76,8 +75,7 @@ WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr) } /* Sets an error message based on GetLastError() */ -int -WIN_SetError(const char *prefix) +int WIN_SetError(const char *prefix) { return WIN_SetErrorFromHRESULT(prefix, GetLastError()); } @@ -116,8 +114,7 @@ WIN_CoInitialize(void) #endif } -void -WIN_CoUninitialize(void) +void WIN_CoUninitialize(void) { #ifndef __WINRT__ CoUninitialize(); @@ -130,10 +127,10 @@ WIN_LoadComBaseFunction(const char *name) { static SDL_bool s_bLoaded; static HMODULE s_hComBase; - + if (!s_bLoaded) { - s_hComBase = LoadLibraryEx(TEXT("combase.dll"), NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); - s_bLoaded = SDL_TRUE; + s_hComBase = LoadLibraryEx(TEXT("combase.dll"), NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); + s_bLoaded = SDL_TRUE; } if (s_hComBase) { return GetProcAddress(s_hComBase, name); @@ -149,7 +146,7 @@ WIN_RoInitialize(void) #ifdef __WINRT__ return S_OK; #else - typedef HRESULT (WINAPI *RoInitialize_t)(RO_INIT_TYPE initType); + typedef HRESULT(WINAPI * RoInitialize_t)(RO_INIT_TYPE initType); RoInitialize_t RoInitializeFunc = (RoInitialize_t)WIN_LoadComBaseFunction("RoInitialize"); if (RoInitializeFunc) { /* RO_INIT_SINGLETHREADED is equivalent to COINIT_APARTMENTTHREADED */ @@ -171,11 +168,10 @@ WIN_RoInitialize(void) #endif } -void -WIN_RoUninitialize(void) +void WIN_RoUninitialize(void) { #ifndef __WINRT__ - typedef void (WINAPI *RoUninitialize_t)(void); + typedef void(WINAPI * RoUninitialize_t)(void); RoUninitialize_t RoUninitializeFunc = (RoUninitialize_t)WIN_LoadComBaseFunction("RoUninitialize"); if (RoUninitializeFunc) { RoUninitializeFunc(); @@ -184,16 +180,15 @@ WIN_RoUninitialize(void) } #if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) -static BOOL -IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor) +static BOOL IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor) { OSVERSIONINFOEXW osvi; DWORDLONG const dwlConditionMask = VerSetConditionMask( VerSetConditionMask( - VerSetConditionMask( - 0, VER_MAJORVERSION, VER_GREATER_EQUAL ), - VER_MINORVERSION, VER_GREATER_EQUAL ), - VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL ); + VerSetConditionMask( + 0, VER_MAJORVERSION, VER_GREATER_EQUAL), + VER_MINORVERSION, VER_GREATER_EQUAL), + VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); SDL_zero(osvi); osvi.dwOSVersionInfoSize = sizeof(osvi); @@ -257,7 +252,7 @@ char * WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid) { #if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__) - return WIN_StringToUTF8(name); /* No registry access on WinRT/UWP and Xbox, go with what we've got. */ + return WIN_StringToUTF8(name); /* No registry access on WinRT/UWP and Xbox, go with what we've got. */ #else static const GUID nullguid = { 0 }; const unsigned char *ptr; @@ -269,42 +264,42 @@ WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid) char *retval = NULL; if (WIN_IsEqualGUID(guid, &nullguid)) { - return WIN_StringToUTF8(name); /* No GUID, go with what we've got. */ + return WIN_StringToUTF8(name); /* No GUID, go with what we've got. */ } - ptr = (const unsigned char *) guid; - SDL_snprintf(keystr, sizeof (keystr), - "System\\CurrentControlSet\\Control\\MediaCategories\\{%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X}", - ptr[3], ptr[2], ptr[1], ptr[0], ptr[5], ptr[4], ptr[7], ptr[6], - ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13], ptr[14], ptr[15]); + ptr = (const unsigned char *)guid; + SDL_snprintf(keystr, sizeof(keystr), + "System\\CurrentControlSet\\Control\\MediaCategories\\{%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X}", + ptr[3], ptr[2], ptr[1], ptr[0], ptr[5], ptr[4], ptr[7], ptr[6], + ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13], ptr[14], ptr[15]); strw = WIN_UTF8ToString(keystr); rc = (RegOpenKeyExW(HKEY_LOCAL_MACHINE, strw, 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS); SDL_free(strw); if (!rc) { - return WIN_StringToUTF8(name); /* oh well. */ + return WIN_StringToUTF8(name); /* oh well. */ } rc = (RegQueryValueExW(hkey, L"Name", NULL, NULL, NULL, &len) == ERROR_SUCCESS); if (!rc) { RegCloseKey(hkey); - return WIN_StringToUTF8(name); /* oh well. */ + return WIN_StringToUTF8(name); /* oh well. */ } - strw = (WCHAR *) SDL_malloc(len + sizeof (WCHAR)); + strw = (WCHAR *)SDL_malloc(len + sizeof(WCHAR)); if (strw == NULL) { RegCloseKey(hkey); - return WIN_StringToUTF8(name); /* oh well. */ + return WIN_StringToUTF8(name); /* oh well. */ } - rc = (RegQueryValueExW(hkey, L"Name", NULL, NULL, (LPBYTE) strw, &len) == ERROR_SUCCESS); + rc = (RegQueryValueExW(hkey, L"Name", NULL, NULL, (LPBYTE)strw, &len) == ERROR_SUCCESS); RegCloseKey(hkey); if (!rc) { SDL_free(strw); - return WIN_StringToUTF8(name); /* oh well. */ + return WIN_StringToUTF8(name); /* oh well. */ } - strw[len / 2] = 0; /* make sure it's null-terminated. */ + strw[len / 2] = 0; /* make sure it's null-terminated. */ retval = WIN_StringToUTF8(strw); SDL_free(strw); @@ -312,20 +307,17 @@ WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid) #endif /* if __WINRT__ / else */ } -BOOL -WIN_IsEqualGUID(const GUID * a, const GUID * b) +BOOL WIN_IsEqualGUID(const GUID *a, const GUID *b) { return SDL_memcmp(a, b, sizeof(*a)) == 0; } -BOOL -WIN_IsEqualIID(REFIID a, REFIID b) +BOOL WIN_IsEqualIID(REFIID a, REFIID b) { return SDL_memcmp(a, b, sizeof(*a)) == 0; } -void -WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect) +void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect) { sdlrect->x = winrect->left; sdlrect->w = (winrect->right - winrect->left) + 1; @@ -333,8 +325,7 @@ WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect) sdlrect->h = (winrect->bottom - winrect->top) + 1; } -void -WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect) +void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect) { winrect->left = sdlrect->x; winrect->right = sdlrect->x + sdlrect->w - 1; @@ -344,24 +335,21 @@ WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect) #endif /* defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) */ - /* * Public APIs */ #if !defined(SDL_VIDEO_DRIVER_WINDOWS) #if defined(__WIN32__) || defined(__GDK__) -int -SDL_RegisterApp(const char *name, Uint32 style, void *hInst) +int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) { - (void) name; - (void) style; - (void) hInst; + (void)name; + (void)style; + (void)hInst; return 0; } -void -SDL_UnregisterApp(void) +void SDL_UnregisterApp(void) { } @@ -371,17 +359,16 @@ void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata) #endif /* __WIN32__ || __GDK__ */ #if defined(__WIN32__) || defined(__WINGDK__) -int -SDL_Direct3D9GetAdapterIndex(int displayIndex) +int SDL_Direct3D9GetAdapterIndex(int displayIndex) { - (void) displayIndex; + (void)displayIndex; return 0; /* D3DADAPTER_DEFAULT */ } SDL_bool SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputIndex) { - (void) displayIndex; + (void)displayIndex; if (adapterIndex) { *adapterIndex = -1; } diff --git a/src/core/windows/SDL_windows.h b/src/core/windows/SDL_windows.h index 8b124d797..13b781067 100644 --- a/src/core/windows/SDL_windows.h +++ b/src/core/windows/SDL_windows.h @@ -37,13 +37,13 @@ #undef WINVER #undef _WIN32_WINNT #if defined(SDL_VIDEO_RENDER_D3D12) -#define _WIN32_WINNT 0xA00 /* For D3D12, 0xA00 is required */ +#define _WIN32_WINNT 0xA00 /* For D3D12, 0xA00 is required */ #elif defined(HAVE_SHELLSCALINGAPI_H) -#define _WIN32_WINNT 0x603 /* For DPI support */ +#define _WIN32_WINNT 0x603 /* For DPI support */ #else -#define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */ +#define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */ #endif -#define WINVER _WIN32_WINNT +#define WINVER _WIN32_WINNT #elif defined(__WINGDK__) #ifndef WIN32_LEAN_AND_MEAN @@ -57,8 +57,8 @@ #endif #undef WINVER #undef _WIN32_WINNT -#define _WIN32_WINNT 0xA00 -#define WINVER _WIN32_WINNT +#define _WIN32_WINNT 0xA00 +#define WINVER _WIN32_WINNT #elif defined(__XBOXONE__) || defined(__XBOXSERIES__) #ifndef WIN32_LEAN_AND_MEAN @@ -77,7 +77,7 @@ #endif #include -#include /* for REFIID with broken mingw.org headers */ +#include /* for REFIID with broken mingw.org headers */ /* Older Visual C++ headers don't have the Win64-compatible typedefs... */ #if defined(_MSC_VER) && (_MSC_VER <= 1200) @@ -92,21 +92,21 @@ #include "SDL_rect.h" /* Routines to convert from UTF8 to native Windows text */ -#define WIN_StringToUTF8W(S) SDL_iconv_string("UTF-8", "UTF-16LE", (const char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR)) -#define WIN_UTF8ToStringW(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (const char *)(S), SDL_strlen(S)+1) +#define WIN_StringToUTF8W(S) SDL_iconv_string("UTF-8", "UTF-16LE", (const char *)(S), (SDL_wcslen(S) + 1) * sizeof(WCHAR)) +#define WIN_UTF8ToStringW(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (const char *)(S), SDL_strlen(S) + 1) /* !!! FIXME: UTF8ToString() can just be a SDL_strdup() here. */ -#define WIN_StringToUTF8A(S) SDL_iconv_string("UTF-8", "ASCII", (const char *)(S), (SDL_strlen(S)+1)) -#define WIN_UTF8ToStringA(S) SDL_iconv_string("ASCII", "UTF-8", (const char *)(S), SDL_strlen(S)+1) +#define WIN_StringToUTF8A(S) SDL_iconv_string("UTF-8", "ASCII", (const char *)(S), (SDL_strlen(S) + 1)) +#define WIN_UTF8ToStringA(S) SDL_iconv_string("ASCII", "UTF-8", (const char *)(S), SDL_strlen(S) + 1) #if UNICODE #define WIN_StringToUTF8 WIN_StringToUTF8W #define WIN_UTF8ToString WIN_UTF8ToStringW -#define SDL_tcslen SDL_wcslen -#define SDL_tcsstr SDL_wcsstr +#define SDL_tcslen SDL_wcslen +#define SDL_tcsstr SDL_wcsstr #else #define WIN_StringToUTF8 WIN_StringToUTF8A #define WIN_UTF8ToString WIN_UTF8ToStringA -#define SDL_tcslen SDL_strlen -#define SDL_tcsstr SDL_strstr +#define SDL_tcslen SDL_strlen +#define SDL_tcsstr SDL_strstr #endif /* Set up for C function definitions, even when using C++ */ @@ -146,7 +146,7 @@ extern BOOL WIN_IsWindows8OrGreater(void); extern char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid); /* Checks to see if two GUID are the same. */ -extern BOOL WIN_IsEqualGUID(const GUID * a, const GUID * b); +extern BOOL WIN_IsEqualGUID(const GUID *a, const GUID *b); extern BOOL WIN_IsEqualIID(REFIID a, REFIID b); /* Convert between SDL_rect and RECT */ diff --git a/src/core/windows/SDL_xinput.c b/src/core/windows/SDL_xinput.c index 675ed608c..3015e6e21 100644 --- a/src/core/windows/SDL_xinput.c +++ b/src/core/windows/SDL_xinput.c @@ -36,11 +36,9 @@ DWORD SDL_XInputVersion = 0; static HANDLE s_pXInputDLL = 0; static int s_XInputDLLRefCount = 0; - #if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__) -int -WIN_LoadXInputDLL(void) +int WIN_LoadXInputDLL(void) { /* Getting handles to system dlls (via LoadLibrary and its variants) is not * supported on WinRT, thus, pointers to XInput's functions can't be @@ -65,22 +63,20 @@ WIN_LoadXInputDLL(void) return 0; } -void -WIN_UnloadXInputDLL(void) +void WIN_UnloadXInputDLL(void) { } #else /* !(defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__)) */ -int -WIN_LoadXInputDLL(void) +int WIN_LoadXInputDLL(void) { DWORD version = 0; if (s_pXInputDLL) { SDL_assert(s_XInputDLLRefCount > 0); s_XInputDLLRefCount++; - return 0; /* already loaded */ + return 0; /* already loaded */ } /* NOTE: Don't load XinputUap.dll @@ -88,10 +84,10 @@ WIN_LoadXInputDLL(void) * limitations of that API (no devices at startup, no background input, etc.) */ version = (1 << 16) | 4; - s_pXInputDLL = LoadLibrary(TEXT("XInput1_4.dll")); /* 1.4 Ships with Windows 8. */ + s_pXInputDLL = LoadLibrary(TEXT("XInput1_4.dll")); /* 1.4 Ships with Windows 8. */ if (!s_pXInputDLL) { version = (1 << 16) | 3; - s_pXInputDLL = LoadLibrary(TEXT("XInput1_3.dll")); /* 1.3 can be installed as a redistributable component. */ + s_pXInputDLL = LoadLibrary(TEXT("XInput1_3.dll")); /* 1.3 can be installed as a redistributable component. */ } if (!s_pXInputDLL) { s_pXInputDLL = LoadLibrary(TEXT("bin\\XInput1_3.dll")); @@ -115,7 +111,7 @@ WIN_LoadXInputDLL(void) } SDL_XInputSetState = (XInputSetState_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputSetState"); SDL_XInputGetCapabilities = (XInputGetCapabilities_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputGetCapabilities"); - SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)GetProcAddress( (HMODULE)s_pXInputDLL, "XInputGetBatteryInformation" ); + SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputGetBatteryInformation"); if (SDL_XInputGetState == NULL || SDL_XInputSetState == NULL || SDL_XInputGetCapabilities == NULL) { WIN_UnloadXInputDLL(); return -1; @@ -124,8 +120,7 @@ WIN_LoadXInputDLL(void) return 0; } -void -WIN_UnloadXInputDLL(void) +void WIN_UnloadXInputDLL(void) { if (s_pXInputDLL) { SDL_assert(s_XInputDLLRefCount > 0); diff --git a/src/core/windows/SDL_xinput.h b/src/core/windows/SDL_xinput.h index 5f6d36a98..9aa6c4728 100644 --- a/src/core/windows/SDL_xinput.h +++ b/src/core/windows/SDL_xinput.h @@ -39,7 +39,7 @@ using namespace XInputOnGameInput; #define XUSER_MAX_COUNT 4 #endif #ifndef XUSER_INDEX_ANY -#define XUSER_INDEX_ANY 0x000000FF +#define XUSER_INDEX_ANY 0x000000FF #endif #ifndef XINPUT_CAPS_FFB_SUPPORTED #define XINPUT_CAPS_FFB_SUPPORTED 0x0001 @@ -131,29 +131,29 @@ using namespace XInputOnGameInput; #endif #ifndef BATTERY_DEVTYPE_GAMEPAD -#define BATTERY_DEVTYPE_GAMEPAD 0x00 +#define BATTERY_DEVTYPE_GAMEPAD 0x00 #endif #ifndef BATTERY_TYPE_DISCONNECTED -#define BATTERY_TYPE_DISCONNECTED 0x00 +#define BATTERY_TYPE_DISCONNECTED 0x00 #endif #ifndef BATTERY_TYPE_WIRED -#define BATTERY_TYPE_WIRED 0x01 +#define BATTERY_TYPE_WIRED 0x01 #endif #ifndef BATTERY_TYPE_UNKNOWN -#define BATTERY_TYPE_UNKNOWN 0xFF +#define BATTERY_TYPE_UNKNOWN 0xFF #endif #ifndef BATTERY_LEVEL_EMPTY -#define BATTERY_LEVEL_EMPTY 0x00 +#define BATTERY_LEVEL_EMPTY 0x00 #endif #ifndef BATTERY_LEVEL_LOW -#define BATTERY_LEVEL_LOW 0x01 +#define BATTERY_LEVEL_LOW 0x01 #endif #ifndef BATTERY_LEVEL_MEDIUM -#define BATTERY_LEVEL_MEDIUM 0x02 +#define BATTERY_LEVEL_MEDIUM 0x02 #endif #ifndef BATTERY_LEVEL_FULL -#define BATTERY_LEVEL_FULL 0x03 +#define BATTERY_LEVEL_FULL 0x03 #endif /* Set up for C function definitions, even when using C++ */ @@ -222,31 +222,26 @@ typedef struct #endif /* HAVE_XINPUT_H */ /* Forward decl's for XInput API's we load dynamically and use if available */ -typedef DWORD (WINAPI *XInputGetState_t) - ( - DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ - XINPUT_STATE_EX* pState /* [out] Receives the current state */ - ); +typedef DWORD(WINAPI *XInputGetState_t)( + DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ + XINPUT_STATE_EX *pState /* [out] Receives the current state */ +); -typedef DWORD (WINAPI *XInputSetState_t) - ( - DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ - XINPUT_VIBRATION* pVibration /* [in, out] The vibration information to send to the controller */ - ); +typedef DWORD(WINAPI *XInputSetState_t)( + DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ + XINPUT_VIBRATION *pVibration /* [in, out] The vibration information to send to the controller */ +); -typedef DWORD (WINAPI *XInputGetCapabilities_t) - ( - DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ - DWORD dwFlags, /* [in] Input flags that identify the device type */ - XINPUT_CAPABILITIES* pCapabilities /* [out] Receives the capabilities */ - ); +typedef DWORD(WINAPI *XInputGetCapabilities_t)( + DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ + DWORD dwFlags, /* [in] Input flags that identify the device type */ + XINPUT_CAPABILITIES *pCapabilities /* [out] Receives the capabilities */ +); -typedef DWORD (WINAPI *XInputGetBatteryInformation_t) - ( - DWORD dwUserIndex, - BYTE devType, - XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation - ); +typedef DWORD(WINAPI *XInputGetBatteryInformation_t)( + DWORD dwUserIndex, + BYTE devType, + XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation); extern int WIN_LoadXInputDLL(void); extern void WIN_UnloadXInputDLL(void); @@ -255,17 +250,17 @@ extern XInputGetState_t SDL_XInputGetState; extern XInputSetState_t SDL_XInputSetState; extern XInputGetCapabilities_t SDL_XInputGetCapabilities; extern XInputGetBatteryInformation_t SDL_XInputGetBatteryInformation; -extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */ +extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */ /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif -#define XINPUTGETSTATE SDL_XInputGetState -#define XINPUTSETSTATE SDL_XInputSetState -#define XINPUTGETCAPABILITIES SDL_XInputGetCapabilities -#define XINPUTGETBATTERYINFORMATION SDL_XInputGetBatteryInformation +#define XINPUTGETSTATE SDL_XInputGetState +#define XINPUTSETSTATE SDL_XInputSetState +#define XINPUTGETCAPABILITIES SDL_XInputGetCapabilities +#define XINPUTGETBATTERYINFORMATION SDL_XInputGetBatteryInformation #endif /* SDL_xinput_h_ */ diff --git a/src/core/winrt/SDL_winrtapp_common.cpp b/src/core/winrt/SDL_winrtapp_common.cpp index e5ada4c04..c99859b66 100644 --- a/src/core/winrt/SDL_winrtapp_common.cpp +++ b/src/core/winrt/SDL_winrtapp_common.cpp @@ -30,7 +30,7 @@ int (*WINRT_SDLAppEntryPoint)(int, char **) = NULL; extern "C" DECLSPEC int -SDL_WinRTRunApp(SDL_main_func mainFunction, void * xamlBackgroundPanel) +SDL_WinRTRunApp(SDL_main_func mainFunction, void *xamlBackgroundPanel) { if (xamlBackgroundPanel) { return SDL_WinRTInitXAMLApp(mainFunction, xamlBackgroundPanel); @@ -42,12 +42,11 @@ SDL_WinRTRunApp(SDL_main_func mainFunction, void * xamlBackgroundPanel) } } - extern "C" DECLSPEC SDL_WinRT_DeviceFamily SDL_WinRTGetDeviceFamily() { -#if NTDDI_VERSION >= NTDDI_WIN10 /* !!! FIXME: I have no idea if this is the right test. This is a UWP API, I think. Older windows should...just return "mobile"? I don't know. --ryan. */ - Platform::String^ deviceFamily = Windows::System::Profile::AnalyticsInfo::VersionInfo->DeviceFamily; +#if NTDDI_VERSION >= NTDDI_WIN10 /* !!! FIXME: I have no idea if this is the right test. This is a UWP API, I think. Older windows should...just return "mobile"? I don't know. --ryan. */ + Platform::String ^ deviceFamily = Windows::System::Profile::AnalyticsInfo::VersionInfo->DeviceFamily; if (deviceFamily->Equals("Windows.Desktop")) { return SDL_WINRT_DEVICEFAMILY_DESKTOP; diff --git a/src/core/winrt/SDL_winrtapp_direct3d.cpp b/src/core/winrt/SDL_winrtapp_direct3d.cpp index db27e729b..4baeed39a 100644 --- a/src/core/winrt/SDL_winrtapp_direct3d.cpp +++ b/src/core/winrt/SDL_winrtapp_direct3d.cpp @@ -26,7 +26,6 @@ #include using namespace std; - /* Windows includes */ #include "ppltasks.h" using namespace concurrency; @@ -44,7 +43,6 @@ using namespace Windows::UI::Input; using namespace Windows::Phone::UI::Input; #endif - /* SDL includes */ extern "C" { #include "SDL_events.h" @@ -74,14 +72,12 @@ extern "C" { extern "C" void D3D11_Trim(SDL_Renderer *); #endif - // Compile-time debugging options: // To enable, uncomment; to disable, comment them out. //#define LOG_POINTER_EVENTS 1 //#define LOG_WINDOW_EVENTS 1 //#define LOG_ORIENTATION_EVENTS 1 - // HACK, DLudwig: record a reference to the global, WinRT 'app'/view. // SDL/WinRT will use this throughout its code. // @@ -93,11 +89,11 @@ SDL_WinRTApp ^ SDL_WinRTGlobalApp = nullptr; ref class SDLApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource { -public: - virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView(); + public: + virtual Windows::ApplicationModel::Core::IFrameworkView ^ CreateView(); }; -IFrameworkView^ SDLApplicationSource::CreateView() +IFrameworkView ^ SDLApplicationSource::CreateView() { // TODO, WinRT: see if this function (CreateView) can ever get called // more than once. For now, just prevent it from ever assigning @@ -118,14 +114,13 @@ int SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **)) return 0; } -static void -WINRT_ProcessWindowSizeChange() // TODO: Pass an SDL_Window-identifying thing into WINRT_ProcessWindowSizeChange() +static void WINRT_ProcessWindowSizeChange() // TODO: Pass an SDL_Window-identifying thing into WINRT_ProcessWindowSizeChange() { CoreWindow ^ coreWindow = CoreWindow::GetForCurrentThread(); if (coreWindow) { if (WINRT_GlobalSDLWindow) { - SDL_Window * window = WINRT_GlobalSDLWindow; - SDL_WindowData * data = (SDL_WindowData *) window->driverdata; + SDL_Window *window = WINRT_GlobalSDLWindow; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; int x = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Left); int y = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Top); @@ -144,12 +139,13 @@ WINRT_ProcessWindowSizeChange() // TODO: Pass an SDL_Window-identifying thing in */ const DisplayOrientations currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation); switch (currentOrientation) { - case DisplayOrientations::Landscape: - case DisplayOrientations::LandscapeFlipped: { - int tmp = w; - w = h; - h = tmp; - } break; + case DisplayOrientations::Landscape: + case DisplayOrientations::LandscapeFlipped: + { + int tmp = w; + w = h; + h = tmp; + } break; } #endif @@ -170,25 +166,24 @@ WINRT_ProcessWindowSizeChange() // TODO: Pass an SDL_Window-identifying thing in } } -SDL_WinRTApp::SDL_WinRTApp() : - m_windowClosed(false), - m_windowVisible(true) +SDL_WinRTApp::SDL_WinRTApp() : m_windowClosed(false), + m_windowVisible(true) { } -void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView) +void SDL_WinRTApp::Initialize(CoreApplicationView ^ applicationView) { applicationView->Activated += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnAppActivated); + ref new TypedEventHandler(this, &SDL_WinRTApp::OnAppActivated); CoreApplication::Suspending += - ref new EventHandler(this, &SDL_WinRTApp::OnSuspending); + ref new EventHandler(this, &SDL_WinRTApp::OnSuspending); CoreApplication::Resuming += - ref new EventHandler(this, &SDL_WinRTApp::OnResuming); + ref new EventHandler(this, &SDL_WinRTApp::OnResuming); CoreApplication::Exiting += - ref new EventHandler(this, &SDL_WinRTApp::OnExiting); + ref new EventHandler(this, &SDL_WinRTApp::OnExiting); #if NTDDI_VERSION >= NTDDI_WIN10 /* HACK ALERT! Xbox One doesn't seem to detect gamepads unless something @@ -197,37 +192,36 @@ void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView) sure that gamepad detection works later on, if requested. */ Windows::Gaming::Input::Gamepad::GamepadAdded += - ref new Windows::Foundation::EventHandler( - this, &SDL_WinRTApp::OnGamepadAdded - ); + ref new Windows::Foundation::EventHandler( + this, &SDL_WinRTApp::OnGamepadAdded); #endif } #if NTDDI_VERSION > NTDDI_WIN8 -void SDL_WinRTApp::OnOrientationChanged(DisplayInformation^ sender, Object^ args) +void SDL_WinRTApp::OnOrientationChanged(DisplayInformation ^ sender, Object ^ args) #else -void SDL_WinRTApp::OnOrientationChanged(Object^ sender) +void SDL_WinRTApp::OnOrientationChanged(Object ^ sender) #endif { -#if LOG_ORIENTATION_EVENTS==1 +#if LOG_ORIENTATION_EVENTS == 1 { - CoreWindow^ window = CoreWindow::GetForCurrentThread(); + CoreWindow ^ window = CoreWindow::GetForCurrentThread(); if (window) { SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, CoreWindow Bounds={%f,%f,%f,%f}\n", - __FUNCTION__, - WINRT_DISPLAY_PROPERTY(CurrentOrientation), - WINRT_DISPLAY_PROPERTY(NativeOrientation), - WINRT_DISPLAY_PROPERTY(AutoRotationPreferences), - window->Bounds.X, - window->Bounds.Y, - window->Bounds.Width, - window->Bounds.Height); + __FUNCTION__, + WINRT_DISPLAY_PROPERTY(CurrentOrientation), + WINRT_DISPLAY_PROPERTY(NativeOrientation), + WINRT_DISPLAY_PROPERTY(AutoRotationPreferences), + window->Bounds.X, + window->Bounds.Y, + window->Bounds.Width, + window->Bounds.Height); } else { SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d\n", - __FUNCTION__, - WINRT_DISPLAY_PROPERTY(CurrentOrientation), - WINRT_DISPLAY_PROPERTY(NativeOrientation), - WINRT_DISPLAY_PROPERTY(AutoRotationPreferences)); + __FUNCTION__, + WINRT_DISPLAY_PROPERTY(CurrentOrientation), + WINRT_DISPLAY_PROPERTY(NativeOrientation), + WINRT_DISPLAY_PROPERTY(AutoRotationPreferences)); } } #endif @@ -244,108 +238,106 @@ void SDL_WinRTApp::OnOrientationChanged(Object^ sender) // I'm not currently sure why this is, but it seems to work fine. -- David L. // // TODO, WinRT: do more extensive research into why orientation changes on Win 8.x don't need D3D changes, or if they might, in some cases - SDL_Window * window = WINRT_GlobalSDLWindow; + SDL_Window *window = WINRT_GlobalSDLWindow; if (window) { - SDL_WindowData * data = (SDL_WindowData *)window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; int w = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Width); int h = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Height); SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_SIZE_CHANGED, w, h); } #endif - } -void SDL_WinRTApp::SetWindow(CoreWindow^ window) +void SDL_WinRTApp::SetWindow(CoreWindow ^ window) { -#if LOG_WINDOW_EVENTS==1 +#if LOG_WINDOW_EVENTS == 1 SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, window bounds={%f, %f, %f,%f}\n", - __FUNCTION__, - WINRT_DISPLAY_PROPERTY(CurrentOrientation), - WINRT_DISPLAY_PROPERTY(NativeOrientation), - WINRT_DISPLAY_PROPERTY(AutoRotationPreferences), - window->Bounds.X, - window->Bounds.Y, - window->Bounds.Width, - window->Bounds.Height); + __FUNCTION__, + WINRT_DISPLAY_PROPERTY(CurrentOrientation), + WINRT_DISPLAY_PROPERTY(NativeOrientation), + WINRT_DISPLAY_PROPERTY(AutoRotationPreferences), + window->Bounds.X, + window->Bounds.Y, + window->Bounds.Width, + window->Bounds.Height); #endif - window->SizeChanged += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnWindowSizeChanged); + window->SizeChanged += + ref new TypedEventHandler(this, &SDL_WinRTApp::OnWindowSizeChanged); window->VisibilityChanged += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnVisibilityChanged); + ref new TypedEventHandler(this, &SDL_WinRTApp::OnVisibilityChanged); window->Activated += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnWindowActivated); + ref new TypedEventHandler(this, &SDL_WinRTApp::OnWindowActivated); - window->Closed += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnWindowClosed); + window->Closed += + ref new TypedEventHandler(this, &SDL_WinRTApp::OnWindowClosed); #if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0); #endif window->PointerPressed += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerPressed); + ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerPressed); window->PointerMoved += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerMoved); + ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerMoved); window->PointerReleased += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerReleased); + ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerReleased); window->PointerEntered += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerEntered); + ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerEntered); window->PointerExited += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerExited); + ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerExited); window->PointerWheelChanged += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerWheelChanged); + ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerWheelChanged); #if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP // Retrieves relative-only mouse movements: Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnMouseMoved); + ref new TypedEventHandler(this, &SDL_WinRTApp::OnMouseMoved); #endif window->KeyDown += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnKeyDown); + ref new TypedEventHandler(this, &SDL_WinRTApp::OnKeyDown); window->KeyUp += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnKeyUp); + ref new TypedEventHandler(this, &SDL_WinRTApp::OnKeyUp); window->CharacterReceived += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnCharacterReceived); + ref new TypedEventHandler(this, &SDL_WinRTApp::OnCharacterReceived); #if NTDDI_VERSION >= NTDDI_WIN10 Windows::UI::Core::SystemNavigationManager::GetForCurrentView()->BackRequested += - ref new EventHandler(this, &SDL_WinRTApp::OnBackButtonPressed); + ref new EventHandler(this, &SDL_WinRTApp::OnBackButtonPressed); #elif WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP HardwareButtons::BackPressed += - ref new EventHandler(this, &SDL_WinRTApp::OnBackButtonPressed); + ref new EventHandler(this, &SDL_WinRTApp::OnBackButtonPressed); #endif #if NTDDI_VERSION > NTDDI_WIN8 DisplayInformation::GetForCurrentView()->OrientationChanged += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnOrientationChanged); + ref new TypedEventHandler(this, &SDL_WinRTApp::OnOrientationChanged); #else DisplayProperties::OrientationChanged += ref new DisplayPropertiesEventHandler(this, &SDL_WinRTApp::OnOrientationChanged); #endif -#if (WINAPI_FAMILY == WINAPI_FAMILY_APP) && (NTDDI_VERSION < NTDDI_WIN10) // for Windows 8/8.1/RT apps... (and not Phone apps) +#if (WINAPI_FAMILY == WINAPI_FAMILY_APP) && (NTDDI_VERSION < NTDDI_WIN10) // for Windows 8/8.1/RT apps... (and not Phone apps) // Make sure we know when a user has opened the app's settings pane. // This is needed in order to display a privacy policy, which needs // to be done for network-enabled apps, as per Windows Store requirements. using namespace Windows::UI::ApplicationSettings; SettingsPane::GetForCurrentView()->CommandsRequested += - ref new TypedEventHandler - (this, &SDL_WinRTApp::OnSettingsPaneCommandsRequested); + ref new TypedEventHandler(this, &SDL_WinRTApp::OnSettingsPaneCommandsRequested); #endif } -void SDL_WinRTApp::Load(Platform::String^ entryPoint) +void SDL_WinRTApp::Load(Platform::String ^ entryPoint) { } @@ -371,7 +363,7 @@ void SDL_WinRTApp::Run() static bool IsSDLWindowEventPending(SDL_WindowEventID windowEventID) { SDL_Event events[128]; - const int count = SDL_PeepEvents(events, sizeof(events)/sizeof(SDL_Event), SDL_PEEKEVENT, SDL_WINDOWEVENT, SDL_WINDOWEVENT); + const int count = SDL_PeepEvents(events, sizeof(events) / sizeof(SDL_Event), SDL_PEEKEVENT, SDL_WINDOWEVENT, SDL_WINDOWEVENT); for (int i = 0; i < count; ++i) { if (events[i].window.event == windowEventID) { return true; @@ -386,7 +378,7 @@ bool SDL_WinRTApp::ShouldWaitForAppResumeEvents() if (m_windowVisible) { return false; } - + /* Don't wait until the window-hide events finish processing. * Do note that if an app-suspend event is sent (as indicated * by SDL_APP_WILLENTERBACKGROUND and SDL_APP_DIDENTERBACKGROUND @@ -435,17 +427,17 @@ void SDL_WinRTApp::Uninitialize() #if (WINAPI_FAMILY == WINAPI_FAMILY_APP) && (NTDDI_VERSION < NTDDI_WIN10) void SDL_WinRTApp::OnSettingsPaneCommandsRequested( - Windows::UI::ApplicationSettings::SettingsPane ^p, - Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs ^args) + Windows::UI::ApplicationSettings::SettingsPane ^ p, + Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs ^ args) { using namespace Platform; using namespace Windows::UI::ApplicationSettings; using namespace Windows::UI::Popups; - String ^privacyPolicyURL = nullptr; // a URL to an app's Privacy Policy - String ^privacyPolicyLabel = nullptr; // label/link text - const char *tmpHintValue = NULL; // SDL_GetHint-retrieved value, used immediately - wchar_t *tmpStr = NULL; // used for UTF8 to UCS2 conversion + String ^ privacyPolicyURL = nullptr; // a URL to an app's Privacy Policy + String ^ privacyPolicyLabel = nullptr; // label/link text + const char *tmpHintValue = NULL; // SDL_GetHint-retrieved value, used immediately + wchar_t *tmpStr = NULL; // used for UTF8 to UCS2 conversion // Setup a 'Privacy Policy' link, if one is available (via SDL_GetHint): tmpHintValue = SDL_GetHint(SDL_HINT_WINRT_PRIVACY_POLICY_URL); @@ -469,39 +461,39 @@ void SDL_WinRTApp::OnSettingsPaneCommandsRequested( // Register the link, along with a handler to be called if and when it is // clicked: auto cmd = ref new SettingsCommand(L"privacyPolicy", privacyPolicyLabel, - ref new UICommandInvokedHandler([=](IUICommand ^) { - Windows::System::Launcher::LaunchUriAsync(ref new Uri(privacyPolicyURL)); - })); + ref new UICommandInvokedHandler([=](IUICommand ^) { + Windows::System::Launcher::LaunchUriAsync(ref new Uri(privacyPolicyURL)); + })); args->Request->ApplicationCommands->Append(cmd); } } #endif // if (WINAPI_FAMILY == WINAPI_FAMILY_APP) && (NTDDI_VERSION < NTDDI_WIN10) -void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args) +void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow ^ sender, WindowSizeChangedEventArgs ^ args) { -#if LOG_WINDOW_EVENTS==1 +#if LOG_WINDOW_EVENTS == 1 SDL_Log("%s, size={%f,%f}, bounds={%f,%f,%f,%f}, current orientation=%d, native orientation=%d, auto rot. pref=%d, WINRT_GlobalSDLWindow?=%s\n", - __FUNCTION__, - args->Size.Width, args->Size.Height, - sender->Bounds.X, sender->Bounds.Y, sender->Bounds.Width, sender->Bounds.Height, - WINRT_DISPLAY_PROPERTY(CurrentOrientation), - WINRT_DISPLAY_PROPERTY(NativeOrientation), - WINRT_DISPLAY_PROPERTY(AutoRotationPreferences), - (WINRT_GlobalSDLWindow ? "yes" : "no")); + __FUNCTION__, + args->Size.Width, args->Size.Height, + sender->Bounds.X, sender->Bounds.Y, sender->Bounds.Width, sender->Bounds.Height, + WINRT_DISPLAY_PROPERTY(CurrentOrientation), + WINRT_DISPLAY_PROPERTY(NativeOrientation), + WINRT_DISPLAY_PROPERTY(AutoRotationPreferences), + (WINRT_GlobalSDLWindow ? "yes" : "no")); #endif WINRT_ProcessWindowSizeChange(); } -void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args) +void SDL_WinRTApp::OnVisibilityChanged(CoreWindow ^ sender, VisibilityChangedEventArgs ^ args) { -#if LOG_WINDOW_EVENTS==1 +#if LOG_WINDOW_EVENTS == 1 SDL_Log("%s, visible?=%s, bounds={%f,%f,%f,%f}, WINRT_GlobalSDLWindow?=%s\n", - __FUNCTION__, - (args->Visible ? "yes" : "no"), - sender->Bounds.X, sender->Bounds.Y, - sender->Bounds.Width, sender->Bounds.Height, - (WINRT_GlobalSDLWindow ? "yes" : "no")); + __FUNCTION__, + (args->Visible ? "yes" : "no"), + sender->Bounds.X, sender->Bounds.Y, + sender->Bounds.Width, sender->Bounds.Height, + (WINRT_GlobalSDLWindow ? "yes" : "no")); #endif m_windowVisible = args->Visible; @@ -532,12 +524,12 @@ void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEven } } -void SDL_WinRTApp::OnWindowActivated(CoreWindow^ sender, WindowActivatedEventArgs^ args) +void SDL_WinRTApp::OnWindowActivated(CoreWindow ^ sender, WindowActivatedEventArgs ^ args) { -#if LOG_WINDOW_EVENTS==1 +#if LOG_WINDOW_EVENTS == 1 SDL_Log("%s, WINRT_GlobalSDLWindow?=%s\n\n", - __FUNCTION__, - (WINRT_GlobalSDLWindow ? "yes" : "no")); + __FUNCTION__, + (WINRT_GlobalSDLWindow ? "yes" : "no")); #endif /* There's no property in Win 8.x to tell whether a window is active or @@ -547,14 +539,14 @@ void SDL_WinRTApp::OnWindowActivated(CoreWindow^ sender, WindowActivatedEventArg */ sender->CustomProperties->Insert("SDLHelperWindowActivationState", args->WindowActivationState); - SDL_Window * window = WINRT_GlobalSDLWindow; + SDL_Window *window = WINRT_GlobalSDLWindow; if (window) { if (args->WindowActivationState != CoreWindowActivationState::Deactivated) { SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SHOWN, 0, 0); if (SDL_GetKeyboardFocus() != window) { SDL_SetKeyboardFocus(window); } - + /* Send a mouse-motion event as appropriate. This doesn't work when called from OnPointerEntered, at least not in WinRT CoreWindow apps (as OnPointerEntered doesn't @@ -570,13 +562,13 @@ void SDL_WinRTApp::OnWindowActivated(CoreWindow^ sender, WindowActivatedEventArg #endif /* TODO, WinRT: see if the Win32 bugfix from https://hg.libsdl.org/SDL/rev/d278747da408 needs to be applied (on window activation) */ - //WIN_CheckAsyncMouseRelease(data); + // WIN_CheckAsyncMouseRelease(data); /* TODO, WinRT: implement clipboard support, if possible */ ///* // * FIXME: Update keyboard state // */ - //WIN_CheckClipboardUpdate(data->videodata); + // WIN_CheckClipboardUpdate(data->videodata); // HACK: Resetting the mouse-cursor here seems to fix // https://bugzilla.libsdl.org/show_bug.cgi?id=3217, whereby a @@ -594,20 +586,20 @@ void SDL_WinRTApp::OnWindowActivated(CoreWindow^ sender, WindowActivatedEventArg } } -void SDL_WinRTApp::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args) +void SDL_WinRTApp::OnWindowClosed(CoreWindow ^ sender, CoreWindowEventArgs ^ args) { -#if LOG_WINDOW_EVENTS==1 +#if LOG_WINDOW_EVENTS == 1 SDL_Log("%s\n", __FUNCTION__); #endif m_windowClosed = true; } -void SDL_WinRTApp::OnAppActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args) +void SDL_WinRTApp::OnAppActivated(CoreApplicationView ^ applicationView, IActivatedEventArgs ^ args) { CoreWindow::GetForCurrentThread()->Activate(); } -void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args) +void SDL_WinRTApp::OnSuspending(Platform::Object ^ sender, SuspendingEventArgs ^ args) { // Save app state asynchronously after requesting a deferral. Holding a deferral // indicates that the application is busy performing suspending operations. Be @@ -623,9 +615,8 @@ void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ a // this could be important. SDL_SendAppEvent(SDL_APP_WILLENTERBACKGROUND); - SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral(); - create_task([this, deferral]() - { + SuspendingDeferral ^ deferral = args->SuspendingOperation->GetDeferral(); + create_task([this, deferral]() { // Send an app did-enter-background event immediately to observers. // CoreDispatcher::ProcessEvents, which is the backbone on which // SDL_WinRTApp::PumpEvents is built, will not return to its caller @@ -640,7 +631,7 @@ void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ a // More details at: http://msdn.microsoft.com/en-us/library/windows/apps/Hh994929.aspx #if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED if (WINRT_GlobalSDLWindow) { - SDL_Renderer * renderer = SDL_GetRenderer(WINRT_GlobalSDLWindow); + SDL_Renderer *renderer = SDL_GetRenderer(WINRT_GlobalSDLWindow); if (renderer && (SDL_strcmp(renderer->info.name, "direct3d11") == 0)) { D3D11_Trim(renderer); } @@ -651,7 +642,7 @@ void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ a }); } -void SDL_WinRTApp::OnResuming(Platform::Object^ sender, Platform::Object^ args) +void SDL_WinRTApp::OnResuming(Platform::Object ^ sender, Platform::Object ^ args) { // Restore any data or state that was unloaded on suspend. By default, data // and state are persisted when resuming from suspend. Note that these events @@ -660,29 +651,28 @@ void SDL_WinRTApp::OnResuming(Platform::Object^ sender, Platform::Object^ args) SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND); } -void SDL_WinRTApp::OnExiting(Platform::Object^ sender, Platform::Object^ args) +void SDL_WinRTApp::OnExiting(Platform::Object ^ sender, Platform::Object ^ args) { SDL_SendAppEvent(SDL_APP_TERMINATING); } -static void -WINRT_LogPointerEvent(const char * header, Windows::UI::Core::PointerEventArgs ^ args, Windows::Foundation::Point transformedPoint) +static void WINRT_LogPointerEvent(const char *header, Windows::UI::Core::PointerEventArgs ^ args, Windows::Foundation::Point transformedPoint) { Uint8 button, pressed; Windows::UI::Input::PointerPoint ^ pt = args->CurrentPoint; WINRT_GetSDLButtonForPointerPoint(pt, &button, &pressed); SDL_Log("%s: Position={%f,%f}, Transformed Pos={%f, %f}, MouseWheelDelta=%d, FrameId=%d, PointerId=%d, SDL button=%d pressed=%d\n", - header, - pt->Position.X, pt->Position.Y, - transformedPoint.X, transformedPoint.Y, - pt->Properties->MouseWheelDelta, - pt->FrameId, - pt->PointerId, - button, - pressed); + header, + pt->Position.X, pt->Position.Y, + transformedPoint.X, transformedPoint.Y, + pt->Properties->MouseWheelDelta, + pt->FrameId, + pt->PointerId, + button, + pressed); } -void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args) +void SDL_WinRTApp::OnPointerPressed(CoreWindow ^ sender, PointerEventArgs ^ args) { #if LOG_POINTER_EVENTS WINRT_LogPointerEvent("pointer pressed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize)); @@ -691,7 +681,7 @@ void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args) WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint); } -void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args) +void SDL_WinRTApp::OnPointerMoved(CoreWindow ^ sender, PointerEventArgs ^ args) { #if LOG_POINTER_EVENTS WINRT_LogPointerEvent("pointer moved", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize)); @@ -700,16 +690,16 @@ void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args) WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint); } -void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args) +void SDL_WinRTApp::OnPointerReleased(CoreWindow ^ sender, PointerEventArgs ^ args) { #if LOG_POINTER_EVENTS WINRT_LogPointerEvent("pointer released", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize)); #endif - + WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint); } -void SDL_WinRTApp::OnPointerEntered(CoreWindow^ sender, PointerEventArgs^ args) +void SDL_WinRTApp::OnPointerEntered(CoreWindow ^ sender, PointerEventArgs ^ args) { #if LOG_POINTER_EVENTS WINRT_LogPointerEvent("pointer entered", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize)); @@ -718,7 +708,7 @@ void SDL_WinRTApp::OnPointerEntered(CoreWindow^ sender, PointerEventArgs^ args) WINRT_ProcessPointerEnteredEvent(WINRT_GlobalSDLWindow, args->CurrentPoint); } -void SDL_WinRTApp::OnPointerExited(CoreWindow^ sender, PointerEventArgs^ args) +void SDL_WinRTApp::OnPointerExited(CoreWindow ^ sender, PointerEventArgs ^ args) { #if LOG_POINTER_EVENTS WINRT_LogPointerEvent("pointer exited", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize)); @@ -727,7 +717,7 @@ void SDL_WinRTApp::OnPointerExited(CoreWindow^ sender, PointerEventArgs^ args) WINRT_ProcessPointerExitedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint); } -void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args) +void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow ^ sender, PointerEventArgs ^ args) { #if LOG_POINTER_EVENTS WINRT_LogPointerEvent("pointer wheel changed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize)); @@ -736,22 +726,22 @@ void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ a WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint); } -void SDL_WinRTApp::OnMouseMoved(MouseDevice^ mouseDevice, MouseEventArgs^ args) +void SDL_WinRTApp::OnMouseMoved(MouseDevice ^ mouseDevice, MouseEventArgs ^ args) { WINRT_ProcessMouseMovedEvent(WINRT_GlobalSDLWindow, args); } -void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args) +void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args) { WINRT_ProcessKeyDownEvent(args); } -void SDL_WinRTApp::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args) +void SDL_WinRTApp::OnKeyUp(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args) { WINRT_ProcessKeyUpEvent(args); } -void SDL_WinRTApp::OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CharacterReceivedEventArgs^ args) +void SDL_WinRTApp::OnCharacterReceived(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::CharacterReceivedEventArgs ^ args) { WINRT_ProcessCharacterReceivedEvent(args); } @@ -768,13 +758,13 @@ static void WINRT_OnBackButtonPressed(BackButtonEventArgs ^ args) } #if NTDDI_VERSION >= NTDDI_WIN10 -void SDL_WinRTApp::OnBackButtonPressed(Platform::Object^ sender, Windows::UI::Core::BackRequestedEventArgs^ args) +void SDL_WinRTApp::OnBackButtonPressed(Platform::Object ^ sender, Windows::UI::Core::BackRequestedEventArgs ^ args) { WINRT_OnBackButtonPressed(args); } #elif WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP -void SDL_WinRTApp::OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args) +void SDL_WinRTApp::OnBackButtonPressed(Platform::Object ^ sender, Windows::Phone::UI::Input::BackPressedEventArgs ^ args) { WINRT_OnBackButtonPressed(args); @@ -782,7 +772,7 @@ void SDL_WinRTApp::OnBackButtonPressed(Platform::Object^ sender, Windows::Phone: #endif #if NTDDI_VERSION >= NTDDI_WIN10 -void SDL_WinRTApp::OnGamepadAdded(Platform::Object ^sender, Windows::Gaming::Input::Gamepad ^gamepad) +void SDL_WinRTApp::OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ gamepad) { /* HACK ALERT: Nothing needs to be done here, as this method currently only exists to allow something to be registered with Win10's diff --git a/src/core/winrt/SDL_winrtapp_direct3d.h b/src/core/winrt/SDL_winrtapp_direct3d.h index 1f7c917a6..44dc2102e 100644 --- a/src/core/winrt/SDL_winrtapp_direct3d.h +++ b/src/core/winrt/SDL_winrtapp_direct3d.h @@ -24,67 +24,68 @@ extern int SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **)); ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView { -public: + public: SDL_WinRTApp(); - + // IFrameworkView Methods. - virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView); - virtual void SetWindow(Windows::UI::Core::CoreWindow^ window); - virtual void Load(Platform::String^ entryPoint); + virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView ^ applicationView); + virtual void SetWindow(Windows::UI::Core::CoreWindow ^ window); + virtual void Load(Platform::String ^ entryPoint); virtual void Run(); virtual void Uninitialize(); -internal: - // SDL-specific methods - void PumpEvents(); + internal : + // SDL-specific methods + void + PumpEvents(); -protected: + protected: bool ShouldWaitForAppResumeEvents(); // Event Handlers. -#if (WINAPI_FAMILY == WINAPI_FAMILY_APP) && (NTDDI_VERSION < NTDDI_WIN10) // for Windows 8/8.1/RT apps... (and not Phone apps) +#if (WINAPI_FAMILY == WINAPI_FAMILY_APP) && (NTDDI_VERSION < NTDDI_WIN10) // for Windows 8/8.1/RT apps... (and not Phone apps) void OnSettingsPaneCommandsRequested( - Windows::UI::ApplicationSettings::SettingsPane ^p, - Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs ^args); + Windows::UI::ApplicationSettings::SettingsPane ^ p, + Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs ^ args); #endif // if (WINAPI_FAMILY == WINAPI_FAMILY_APP) && (NTDDI_VERSION < NTDDI_WIN10) #if NTDDI_VERSION > NTDDI_WIN8 - void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args); + void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation ^ sender, Platform::Object ^ args); #else - void OnOrientationChanged(Platform::Object^ sender); + void OnOrientationChanged(Platform::Object ^ sender); #endif - void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args); - void OnLogicalDpiChanged(Platform::Object^ sender); - void OnAppActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args); - void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args); - void OnResuming(Platform::Object^ sender, Platform::Object^ args); - void OnExiting(Platform::Object^ sender, Platform::Object^ args); - void OnWindowActivated(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowActivatedEventArgs^ args); - void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args); - void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args); - void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); - void OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); - void OnPointerWheelChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); - void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); - void OnPointerEntered(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); - void OnPointerExited(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); - void OnMouseMoved(Windows::Devices::Input::MouseDevice^ mouseDevice, Windows::Devices::Input::MouseEventArgs^ args); - void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args); - void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args); - void OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CharacterReceivedEventArgs^ args); + void OnWindowSizeChanged(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::WindowSizeChangedEventArgs ^ args); + void OnLogicalDpiChanged(Platform::Object ^ sender); + void OnAppActivated(Windows::ApplicationModel::Core::CoreApplicationView ^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs ^ args); + void OnSuspending(Platform::Object ^ sender, Windows::ApplicationModel::SuspendingEventArgs ^ args); + void OnResuming(Platform::Object ^ sender, Platform::Object ^ args); + void OnExiting(Platform::Object ^ sender, Platform::Object ^ args); + void OnWindowActivated(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::WindowActivatedEventArgs ^ args); + void OnWindowClosed(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::CoreWindowEventArgs ^ args); + void OnVisibilityChanged(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::VisibilityChangedEventArgs ^ args); + void OnPointerPressed(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args); + void OnPointerReleased(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args); + void OnPointerWheelChanged(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args); + void OnPointerMoved(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args); + void OnPointerEntered(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args); + void OnPointerExited(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args); + void OnMouseMoved(Windows::Devices::Input::MouseDevice ^ mouseDevice, Windows::Devices::Input::MouseEventArgs ^ args); + void OnKeyDown(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args); + void OnKeyUp(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args); + void OnCharacterReceived(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::CharacterReceivedEventArgs ^ args); #if NTDDI_VERSION >= NTDDI_WIN10 - void OnBackButtonPressed(Platform::Object^ sender, Windows::UI::Core::BackRequestedEventArgs^ args); + void OnBackButtonPressed(Platform::Object ^ sender, Windows::UI::Core::BackRequestedEventArgs ^ args); #elif WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP - void OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args); + void OnBackButtonPressed(Platform::Object ^ sender, Windows::Phone::UI::Input::BackPressedEventArgs ^ args); #endif #if NTDDI_VERSION >= NTDDI_WIN10 - void OnGamepadAdded(Platform::Object ^sender, Windows::Gaming::Input::Gamepad ^gamepad); + void OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ gamepad); #endif -private: + private: bool m_windowClosed; bool m_windowVisible; }; diff --git a/src/core/winrt/SDL_winrtapp_xaml.cpp b/src/core/winrt/SDL_winrtapp_xaml.cpp index 69716e11d..fe7fbc4fb 100644 --- a/src/core/winrt/SDL_winrtapp_xaml.cpp +++ b/src/core/winrt/SDL_winrtapp_xaml.cpp @@ -27,7 +27,6 @@ #include #endif - /* SDL includes */ #include "../../SDL_internal.h" #include "SDL.h" @@ -36,70 +35,58 @@ #include "SDL_winrtapp_common.h" #include "SDL_winrtapp_xaml.h" - - /* SDL-internal globals: */ SDL_bool WINRT_XAMLWasEnabled = SDL_FALSE; #if WINAPI_FAMILY == WINAPI_FAMILY_APP -extern "C" -ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNative = NULL; -static Windows::Foundation::EventRegistrationToken WINRT_XAMLAppEventToken; +extern "C" ISwapChainBackgroundPanelNative *WINRT_GlobalSwapChainBackgroundPanelNative = NULL; +static Windows::Foundation::EventRegistrationToken WINRT_XAMLAppEventToken; #endif - /* * Input event handlers (XAML) */ #if WINAPI_FAMILY == WINAPI_FAMILY_APP -static void -WINRT_OnPointerPressedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args) +static void WINRT_OnPointerPressedViaXAML(Platform::Object ^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ args) { WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); } -static void -WINRT_OnPointerMovedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args) +static void WINRT_OnPointerMovedViaXAML(Platform::Object ^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ args) { WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); } -static void -WINRT_OnPointerReleasedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args) +static void WINRT_OnPointerReleasedViaXAML(Platform::Object ^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ args) { WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); } -static void -WINRT_OnPointerWheelChangedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args) +static void WINRT_OnPointerWheelChangedViaXAML(Platform::Object ^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ args) { WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); } #endif // WINAPI_FAMILY == WINAPI_FAMILY_APP - /* * XAML-to-SDL Rendering Callback */ #if WINAPI_FAMILY == WINAPI_FAMILY_APP -static void -WINRT_OnRenderViaXAML(_In_ Platform::Object^ sender, _In_ Platform::Object^ args) +static void WINRT_OnRenderViaXAML(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args) { WINRT_CycleXAMLThread(); } #endif // WINAPI_FAMILY == WINAPI_FAMILY_APP - /* * SDL + XAML Initialization */ -int -SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void * backgroundPanelAsIInspectable) +int SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void *backgroundPanelAsIInspectable) { #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP return SDL_SetError("XAML support is not yet available in Windows Phone."); @@ -114,13 +101,13 @@ SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void * backgroundPanelAs using namespace Windows::UI::Xaml::Media; // Make sure we have a valid XAML element (to draw onto): - if ( ! backgroundPanelAsIInspectable) { + if (!backgroundPanelAsIInspectable) { return SDL_InvalidParamError("backgroundPanelAsIInspectable"); } - Platform::Object ^ backgroundPanel = reinterpret_cast((IInspectable *) backgroundPanelAsIInspectable); - SwapChainBackgroundPanel ^swapChainBackgroundPanel = dynamic_cast(backgroundPanel); - if ( ! swapChainBackgroundPanel) { + Platform::Object ^ backgroundPanel = reinterpret_cast((IInspectable *)backgroundPanelAsIInspectable); + SwapChainBackgroundPanel ^ swapChainBackgroundPanel = dynamic_cast(backgroundPanel); + if (!swapChainBackgroundPanel) { return SDL_SetError("An unknown or unsupported type of XAML control was specified."); } @@ -131,10 +118,10 @@ SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void * backgroundPanelAs swapChainBackgroundPanel->PointerMoved += ref new PointerEventHandler(WINRT_OnPointerMovedViaXAML); // Setup for rendering: - IInspectable *panelInspectable = (IInspectable*) reinterpret_cast(swapChainBackgroundPanel); + IInspectable *panelInspectable = (IInspectable *)reinterpret_cast(swapChainBackgroundPanel); panelInspectable->QueryInterface(__uuidof(ISwapChainBackgroundPanelNative), (void **)&WINRT_GlobalSwapChainBackgroundPanelNative); - WINRT_XAMLAppEventToken = CompositionTarget::Rendering::add(ref new EventHandler(WINRT_OnRenderViaXAML)); + WINRT_XAMLAppEventToken = CompositionTarget::Rendering::add(ref new EventHandler(WINRT_OnRenderViaXAML)); // Make sure the app is ready to call the SDL-centric main() function: WINRT_SDLAppEntryPoint = mainFunction; diff --git a/src/core/winrt/SDL_winrtapp_xaml.h b/src/core/winrt/SDL_winrtapp_xaml.h index e26e21884..79624b078 100644 --- a/src/core/winrt/SDL_winrtapp_xaml.h +++ b/src/core/winrt/SDL_winrtapp_xaml.h @@ -27,7 +27,7 @@ #ifdef __cplusplus extern SDL_bool WINRT_XAMLWasEnabled; -extern int SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void * backgroundPanelAsIInspectable); +extern int SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void *backgroundPanelAsIInspectable); #endif // ifdef __cplusplus #endif // SDL_winrtapp_xaml_h_ diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index a4fa5d6e3..d644ad92a 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -102,41 +102,39 @@ #include #endif -#define CPU_HAS_RDTSC (1 << 0) -#define CPU_HAS_ALTIVEC (1 << 1) -#define CPU_HAS_MMX (1 << 2) -#define CPU_HAS_3DNOW (1 << 3) -#define CPU_HAS_SSE (1 << 4) -#define CPU_HAS_SSE2 (1 << 5) -#define CPU_HAS_SSE3 (1 << 6) -#define CPU_HAS_SSE41 (1 << 7) -#define CPU_HAS_SSE42 (1 << 8) -#define CPU_HAS_AVX (1 << 9) -#define CPU_HAS_AVX2 (1 << 10) -#define CPU_HAS_NEON (1 << 11) -#define CPU_HAS_AVX512F (1 << 12) +#define CPU_HAS_RDTSC (1 << 0) +#define CPU_HAS_ALTIVEC (1 << 1) +#define CPU_HAS_MMX (1 << 2) +#define CPU_HAS_3DNOW (1 << 3) +#define CPU_HAS_SSE (1 << 4) +#define CPU_HAS_SSE2 (1 << 5) +#define CPU_HAS_SSE3 (1 << 6) +#define CPU_HAS_SSE41 (1 << 7) +#define CPU_HAS_SSE42 (1 << 8) +#define CPU_HAS_AVX (1 << 9) +#define CPU_HAS_AVX2 (1 << 10) +#define CPU_HAS_NEON (1 << 11) +#define CPU_HAS_AVX512F (1 << 12) #define CPU_HAS_ARM_SIMD (1 << 13) -#define CPU_HAS_LSX (1 << 14) -#define CPU_HAS_LASX (1 << 15) +#define CPU_HAS_LSX (1 << 14) +#define CPU_HAS_LASX (1 << 15) -#define CPU_CFG2 0x2 -#define CPU_CFG2_LSX (1 << 6) -#define CPU_CFG2_LASX (1 << 7) +#define CPU_CFG2 0x2 +#define CPU_CFG2_LSX (1 << 6) +#define CPU_CFG2_LASX (1 << 7) #if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__ && !__OpenBSD__ && !__FreeBSD__ /* This is the brute force way of detecting instruction sets... the idea is borrowed from the libmpeg2 library - thanks! */ static jmp_buf jmpbuf; -static void -illegal_instruction(int sig) +static void illegal_instruction(int sig) { longjmp(jmpbuf, 1); } #endif /* HAVE_SETJMP */ -static int -CPU_haveCPUID(void) +static int CPU_haveCPUID(void) { int has_CPUID = 0; @@ -234,23 +232,25 @@ done: } #if (defined(__GNUC__) || defined(__llvm__)) && defined(__i386__) -#define cpuid(func, a, b, c, d) \ - __asm__ __volatile__ ( \ -" pushl %%ebx \n" \ -" xorl %%ecx,%%ecx \n" \ -" cpuid \n" \ -" movl %%ebx, %%esi \n" \ -" popl %%ebx \n" : \ - "=a" (a), "=S" (b), "=c" (c), "=d" (d) : "a" (func)) +#define cpuid(func, a, b, c, d) \ + __asm__ __volatile__( \ + " pushl %%ebx \n" \ + " xorl %%ecx,%%ecx \n" \ + " cpuid \n" \ + " movl %%ebx, %%esi \n" \ + " popl %%ebx \n" \ + : "=a"(a), "=S"(b), "=c"(c), "=d"(d) \ + : "a"(func)) #elif (defined(__GNUC__) || defined(__llvm__)) && defined(__x86_64__) -#define cpuid(func, a, b, c, d) \ - __asm__ __volatile__ ( \ -" pushq %%rbx \n" \ -" xorq %%rcx,%%rcx \n" \ -" cpuid \n" \ -" movq %%rbx, %%rsi \n" \ -" popq %%rbx \n" : \ - "=a" (a), "=S" (b), "=c" (c), "=d" (d) : "a" (func)) +#define cpuid(func, a, b, c, d) \ + __asm__ __volatile__( \ + " pushq %%rbx \n" \ + " xorq %%rcx,%%rcx \n" \ + " cpuid \n" \ + " movq %%rbx, %%rsi \n" \ + " popq %%rbx \n" \ + : "=a"(a), "=S"(b), "=c"(c), "=d"(d) \ + : "a"(func)) #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) #define cpuid(func, a, b, c, d) \ __asm { \ @@ -260,21 +260,27 @@ done: __asm mov a, eax \ __asm mov b, ebx \ __asm mov c, ecx \ - __asm mov d, edx \ -} + __asm mov d, edx \ + } #elif defined(_MSC_VER) && defined(_M_X64) #define cpuid(func, a, b, c, d) \ -{ \ - int CPUInfo[4]; \ - __cpuid(CPUInfo, func); \ - a = CPUInfo[0]; \ - b = CPUInfo[1]; \ - c = CPUInfo[2]; \ - d = CPUInfo[3]; \ -} + { \ + int CPUInfo[4]; \ + __cpuid(CPUInfo, func); \ + a = CPUInfo[0]; \ + b = CPUInfo[1]; \ + c = CPUInfo[2]; \ + d = CPUInfo[3]; \ + } #else #define cpuid(func, a, b, c, d) \ - do { a = b = c = d = 0; (void) a; (void) b; (void) c; (void) d; } while (0) + do { \ + a = b = c = d = 0; \ + (void)a; \ + (void)b; \ + (void)c; \ + (void)d; \ + } while (0) #endif static int CPU_CPUIDFeatures[4]; @@ -282,8 +288,7 @@ static int CPU_CPUIDMaxFunction = 0; static SDL_bool CPU_OSSavesYMM = SDL_FALSE; static SDL_bool CPU_OSSavesZMM = SDL_FALSE; -static void -CPU_calcCPUIDFeatures(void) +static void CPU_calcCPUIDFeatures(void) { static SDL_bool checked = SDL_FALSE; if (!checked) { @@ -303,16 +308,19 @@ CPU_calcCPUIDFeatures(void) if (c & 0x08000000) { /* Call xgetbv to see if YMM (etc) register state is saved */ #if (defined(__GNUC__) || defined(__llvm__)) && (defined(__i386__) || defined(__x86_64__)) - __asm__(".byte 0x0f, 0x01, 0xd0" : "=a" (a) : "c" (0) : "%edx"); + __asm__(".byte 0x0f, 0x01, 0xd0" + : "=a"(a) + : "c"(0) + : "%edx"); #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) && (_MSC_FULL_VER >= 160040219) /* VS2010 SP1 */ a = (int)_xgetbv(0); #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) __asm - { + { xor ecx, ecx _asm _emit 0x0f _asm _emit 0x01 _asm _emit 0xd0 mov a, eax - } + } #endif CPU_OSSavesYMM = ((a & 6) == 6) ? SDL_TRUE : SDL_FALSE; CPU_OSSavesZMM = (CPU_OSSavesYMM && ((a & 0xe0) == 0xe0)) ? SDL_TRUE : SDL_FALSE; @@ -322,8 +330,7 @@ CPU_calcCPUIDFeatures(void) } } -static int -CPU_haveAltiVec(void) +static int CPU_haveAltiVec(void) { volatile int altivec = 0; #ifndef SDL_CPUINFO_DISABLED @@ -345,10 +352,11 @@ CPU_haveAltiVec(void) altivec = cpufeatures & PPC_FEATURE_HAS_ALTIVEC; return altivec; #elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP - void (*handler) (int sig); + void (*handler)(int sig); handler = signal(SIGILL, illegal_instruction); if (setjmp(jmpbuf) == 0) { - asm volatile ("mtspr 256, %0\n\t" "vand %%v0, %%v0, %%v0"::"r" (-1)); + asm volatile("mtspr 256, %0\n\t" + "vand %%v0, %%v0, %%v0" ::"r"(-1)); altivec = 1; } signal(SIGILL, handler); @@ -358,22 +366,19 @@ CPU_haveAltiVec(void) } #if (defined(__ARM_ARCH) && (__ARM_ARCH >= 6)) || defined(__aarch64__) -static int -CPU_haveARMSIMD(void) +static int CPU_haveARMSIMD(void) { return 1; } #elif !defined(__arm__) -static int -CPU_haveARMSIMD(void) +static int CPU_haveARMSIMD(void) { return 0; } #elif defined(__LINUX__) -static int -CPU_haveARMSIMD(void) +static int CPU_haveARMSIMD(void) { int arm_simd = 0; int fd; @@ -383,7 +388,7 @@ CPU_haveARMSIMD(void) Elf32_auxv_t aux; while (read(fd, &aux, sizeof aux) == sizeof aux) { if (aux.a_type == AT_PLATFORM) { - const char *plat = (const char *) aux.a_un.a_val; + const char *plat = (const char *)aux.a_un.a_val; if (plat) { arm_simd = SDL_strncmp(plat, "v6l", 3) == 0 || SDL_strncmp(plat, "v7l", 3) == 0; @@ -396,8 +401,7 @@ CPU_haveARMSIMD(void) } #elif defined(__RISCOS__) -static int -CPU_haveARMSIMD(void) +static int CPU_haveARMSIMD(void) { _kernel_swi_regs regs; regs.r[0] = 0; @@ -419,8 +423,7 @@ CPU_haveARMSIMD(void) } #else -static int -CPU_haveARMSIMD(void) +static int CPU_haveARMSIMD(void) { #warning SDL_HasARMSIMD is not implemented for this ARM platform. Write me. return 0; @@ -428,8 +431,7 @@ CPU_haveARMSIMD(void) #endif #if defined(__LINUX__) && defined(__arm__) && !defined(HAVE_GETAUXVAL) -static int -readProcAuxvForNeon(void) +static int readProcAuxvForNeon(void) { int neon = 0; int fd; @@ -437,7 +439,7 @@ readProcAuxvForNeon(void) fd = open("/proc/self/auxv", O_RDONLY | O_CLOEXEC); if (fd >= 0) { Elf32_auxv_t aux; - while (read(fd, &aux, sizeof (aux)) == sizeof (aux)) { + while (read(fd, &aux, sizeof(aux)) == sizeof(aux)) { if (aux.a_type == AT_HWCAP) { neon = (aux.a_un.a_val & HWCAP_NEON) == HWCAP_NEON; break; @@ -449,36 +451,35 @@ readProcAuxvForNeon(void) } #endif -static int -CPU_haveNEON(void) +static int CPU_haveNEON(void) { /* The way you detect NEON is a privileged instruction on ARM, so you have query the OS kernel in a platform-specific way. :/ */ #if defined(SDL_CPUINFO_DISABLED) - return 0; /* disabled */ + return 0; /* disabled */ #elif (defined(__WINDOWS__) || defined(__WINRT__) || defined(__GDK__)) && (defined(_M_ARM) || defined(_M_ARM64)) /* Visual Studio, for ARM, doesn't define __ARM_ARCH. Handle this first. */ /* Seems to have been removed */ -# if !defined(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) -# define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19 -# endif -/* All WinRT ARM devices are required to support NEON, but just in case. */ +#if !defined(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) +#define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19 +#endif + /* All WinRT ARM devices are required to support NEON, but just in case. */ return IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) != 0; #elif (defined(__ARM_ARCH) && (__ARM_ARCH >= 8)) || defined(__aarch64__) - return 1; /* ARMv8 always has non-optional NEON support. */ + return 1; /* ARMv8 always has non-optional NEON support. */ #elif __VITA__ return 1; #elif __3DS__ return 0; #elif defined(__APPLE__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7) /* (note that sysctlbyname("hw.optional.neon") doesn't work!) */ - return 1; /* all Apple ARMv7 chips and later have NEON. */ + return 1; /* all Apple ARMv7 chips and later have NEON. */ #elif defined(__APPLE__) - return 0; /* assume anything else from Apple doesn't have NEON. */ + return 0; /* assume anything else from Apple doesn't have NEON. */ #elif !defined(__arm__) - return 0; /* not an ARM CPU at all. */ + return 0; /* not an ARM CPU at all. */ #elif defined(__OpenBSD__) - return 1; /* OpenBSD only supports ARMv7 CPUs that have NEON. */ + return 1; /* OpenBSD only supports ARMv7 CPUs that have NEON. */ #elif defined(HAVE_ELF_AUX_INFO) unsigned long hasneon = 0; if (elf_aux_info(AT_HWCAP, (void *)&hasneon, (int)sizeof(hasneon)) != 0) { @@ -521,21 +522,19 @@ CPU_haveNEON(void) #endif } -static int -CPU_readCPUCFG(void) +static int CPU_readCPUCFG(void) { uint32_t cfg2 = 0; #if defined __loongarch__ __asm__ volatile( "cpucfg %0, %1 \n\t" : "+&r"(cfg2) - : "r"(CPU_CFG2) - ); + : "r"(CPU_CFG2)); #endif return cfg2; } -#define CPU_haveLSX() (CPU_readCPUCFG() & CPU_CFG2_LSX) +#define CPU_haveLSX() (CPU_readCPUCFG() & CPU_CFG2_LSX) #define CPU_haveLASX() (CPU_readCPUCFG() & CPU_CFG2_LASX) #if defined(__e2k__) @@ -549,10 +548,9 @@ CPU_have3DNow(void) #endif } #else -static int -CPU_have3DNow(void) +static int CPU_have3DNow(void) { - if (CPU_CPUIDMaxFunction > 0) { /* that is, do we have CPUID at all? */ + if (CPU_CPUIDMaxFunction > 0) { /* that is, do we have CPUID at all? */ int a, b, c, d; cpuid(0x80000000, a, b, c, d); if (a >= 0x80000001) { @@ -603,13 +601,13 @@ CPU_have3DNow(void) #endif #else #define CPU_haveRDTSC() (CPU_CPUIDFeatures[3] & 0x00000010) -#define CPU_haveMMX() (CPU_CPUIDFeatures[3] & 0x00800000) -#define CPU_haveSSE() (CPU_CPUIDFeatures[3] & 0x02000000) -#define CPU_haveSSE2() (CPU_CPUIDFeatures[3] & 0x04000000) -#define CPU_haveSSE3() (CPU_CPUIDFeatures[2] & 0x00000001) +#define CPU_haveMMX() (CPU_CPUIDFeatures[3] & 0x00800000) +#define CPU_haveSSE() (CPU_CPUIDFeatures[3] & 0x02000000) +#define CPU_haveSSE2() (CPU_CPUIDFeatures[3] & 0x04000000) +#define CPU_haveSSE3() (CPU_CPUIDFeatures[2] & 0x00000001) #define CPU_haveSSE41() (CPU_CPUIDFeatures[2] & 0x00080000) #define CPU_haveSSE42() (CPU_CPUIDFeatures[2] & 0x00100000) -#define CPU_haveAVX() (CPU_OSSavesYMM && (CPU_CPUIDFeatures[2] & 0x10000000)) +#define CPU_haveAVX() (CPU_OSSavesYMM && (CPU_CPUIDFeatures[2] & 0x10000000)) #endif #if defined(__e2k__) @@ -623,12 +621,14 @@ CPU_haveAVX2(void) #endif } #else -static int -CPU_haveAVX2(void) +static int CPU_haveAVX2(void) { if (CPU_OSSavesYMM && (CPU_CPUIDMaxFunction >= 7)) { int a, b, c, d; - (void) a; (void) b; (void) c; (void) d; /* compiler warnings... */ + (void)a; + (void)b; + (void)c; + (void)d; /* compiler warnings... */ cpuid(7, a, b, c, d); return b & 0x00000020; } @@ -643,12 +643,14 @@ CPU_haveAVX512F(void) return 0; } #else -static int -CPU_haveAVX512F(void) +static int CPU_haveAVX512F(void) { if (CPU_OSSavesZMM && (CPU_CPUIDMaxFunction >= 7)) { int a, b, c, d; - (void) a; (void) b; (void) c; (void) d; /* compiler warnings... */ + (void)a; + (void)b; + (void)c; + (void)d; /* compiler warnings... */ cpuid(7, a, b, c, d); return b & 0x00010000; } @@ -658,8 +660,7 @@ CPU_haveAVX512F(void) static int SDL_CPUCount = 0; -int -SDL_GetCPUCount(void) +int SDL_GetCPUCount(void) { if (!SDL_CPUCount) { #ifndef SDL_CPUINFO_DISABLED @@ -708,8 +709,7 @@ SDL_GetCPUType(void) } #else /* Oh, such a sweet sweet trick, just not very useful. :) */ -static const char * -SDL_GetCPUType(void) +static const char *SDL_GetCPUType(void) { static char SDL_CPUType[13]; @@ -717,23 +717,32 @@ SDL_GetCPUType(void) int i = 0; CPU_calcCPUIDFeatures(); - if (CPU_CPUIDMaxFunction > 0) { /* do we have CPUID at all? */ + if (CPU_CPUIDMaxFunction > 0) { /* do we have CPUID at all? */ int a, b, c, d; cpuid(0x00000000, a, b, c, d); - (void) a; - SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; + (void)a; + SDL_CPUType[i++] = (char)(b & 0xff); + b >>= 8; + SDL_CPUType[i++] = (char)(b & 0xff); + b >>= 8; + SDL_CPUType[i++] = (char)(b & 0xff); + b >>= 8; SDL_CPUType[i++] = (char)(b & 0xff); - SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUType[i++] = (char)(d & 0xff); + d >>= 8; + SDL_CPUType[i++] = (char)(d & 0xff); + d >>= 8; + SDL_CPUType[i++] = (char)(d & 0xff); + d >>= 8; SDL_CPUType[i++] = (char)(d & 0xff); - SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; + SDL_CPUType[i++] = (char)(c & 0xff); + c >>= 8; + SDL_CPUType[i++] = (char)(c & 0xff); + c >>= 8; + SDL_CPUType[i++] = (char)(c & 0xff); + c >>= 8; SDL_CPUType[i++] = (char)(c & 0xff); } if (!SDL_CPUType[0]) { @@ -744,8 +753,7 @@ SDL_GetCPUType(void) } #endif - -#ifdef TEST_MAIN /* !!! FIXME: only used for test at the moment. */ +#ifdef TEST_MAIN /* !!! FIXME: only used for test at the moment. */ #if defined(__e2k__) inline const char * SDL_GetCPUName(void) @@ -757,8 +765,7 @@ SDL_GetCPUName(void) return SDL_CPUName; } #else -static const char * -SDL_GetCPUName(void) +static const char *SDL_GetCPUName(void) { static char SDL_CPUName[48]; @@ -767,60 +774,108 @@ SDL_GetCPUName(void) int a, b, c, d; CPU_calcCPUIDFeatures(); - if (CPU_CPUIDMaxFunction > 0) { /* do we have CPUID at all? */ + if (CPU_CPUIDMaxFunction > 0) { /* do we have CPUID at all? */ cpuid(0x80000000, a, b, c, d); if (a >= 0x80000004) { cpuid(0x80000002, a, b, c, d); - SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); + a >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); + a >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); + a >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); + a >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); + b >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); + b >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); + b >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); + b >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); + c >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); + c >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); + c >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); + c >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); + d >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); + d >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); + d >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); + d >>= 8; cpuid(0x80000003, a, b, c, d); - SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); + a >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); + a >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); + a >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); + a >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); + b >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); + b >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); + b >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); + b >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); + c >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); + c >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); + c >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); + c >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); + d >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); + d >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); + d >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); + d >>= 8; cpuid(0x80000004, a, b, c, d); - SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); + a >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); + a >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); + a >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); + a >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); + b >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); + b >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); + b >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); + b >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); + c >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); + c >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); + c >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); + c >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); + d >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); + d >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); + d >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); + d >>= 8; } } if (!SDL_CPUName[0]) { @@ -832,13 +887,15 @@ SDL_GetCPUName(void) #endif #endif -int -SDL_GetCPUCacheLineSize(void) +int SDL_GetCPUCacheLineSize(void) { const char *cpuType = SDL_GetCPUType(); int a, b, c, d; - (void) a; (void) b; (void) c; (void) d; - if (SDL_strcmp(cpuType, "GenuineIntel") == 0 || SDL_strcmp(cpuType, "CentaurHauls") == 0 || SDL_strcmp(cpuType, " Shanghai ") == 0) { + (void)a; + (void)b; + (void)c; + (void)d; + if (SDL_strcmp(cpuType, "GenuineIntel") == 0 || SDL_strcmp(cpuType, "CentaurHauls") == 0 || SDL_strcmp(cpuType, " Shanghai ") == 0) { cpuid(0x00000001, a, b, c, d); return ((b >> 8) & 0xff) * 8; } else if (SDL_strcmp(cpuType, "AuthenticAMD") == 0 || SDL_strcmp(cpuType, "HygonGenuine") == 0) { @@ -853,13 +910,12 @@ SDL_GetCPUCacheLineSize(void) static Uint32 SDL_CPUFeatures = 0xFFFFFFFF; static Uint32 SDL_SIMDAlignment = 0xFFFFFFFF; -static Uint32 -SDL_GetCPUFeatures(void) +static Uint32 SDL_GetCPUFeatures(void) { if (SDL_CPUFeatures == 0xFFFFFFFF) { CPU_calcCPUIDFeatures(); SDL_CPUFeatures = 0; - SDL_SIMDAlignment = sizeof(void *); /* a good safe base value */ + SDL_SIMDAlignment = sizeof(void *); /* a good safe base value */ if (CPU_haveRDTSC()) { SDL_CPUFeatures |= CPU_HAS_RDTSC; } @@ -1026,33 +1082,32 @@ SDL_HasLASX(void) static int SDL_SystemRAM = 0; -int -SDL_GetSystemRAM(void) +int SDL_GetSystemRAM(void) { if (!SDL_SystemRAM) { #ifndef SDL_CPUINFO_DISABLED #if defined(HAVE_SYSCONF) && defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE) if (SDL_SystemRAM <= 0) { - SDL_SystemRAM = (int)((Sint64)sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE) / (1024*1024)); + SDL_SystemRAM = (int)((Sint64)sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE) / (1024 * 1024)); } #endif #ifdef HAVE_SYSCTLBYNAME if (SDL_SystemRAM <= 0) { #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__DragonFly__) #ifdef HW_REALMEM - int mib[2] = {CTL_HW, HW_REALMEM}; + int mib[2] = { CTL_HW, HW_REALMEM }; #else /* might only report up to 2 GiB */ - int mib[2] = {CTL_HW, HW_PHYSMEM}; + int mib[2] = { CTL_HW, HW_PHYSMEM }; #endif /* HW_REALMEM */ #else - int mib[2] = {CTL_HW, HW_MEMSIZE}; + int mib[2] = { CTL_HW, HW_MEMSIZE }; #endif /* __FreeBSD__ || __FreeBSD_kernel__ */ Uint64 memsize = 0; size_t len = sizeof(memsize); - + if (sysctl(mib, 2, &memsize, &len, NULL, 0) == 0) { - SDL_SystemRAM = (int)(memsize / (1024*1024)); + SDL_SystemRAM = (int)(memsize / (1024 * 1024)); } } #endif @@ -1099,12 +1154,11 @@ SDL_GetSystemRAM(void) return SDL_SystemRAM; } - size_t SDL_SIMDGetAlignment(void) { if (SDL_SIMDAlignment == 0xFFFFFFFF) { - SDL_GetCPUFeatures(); /* make sure this has been calculated */ + SDL_GetCPUFeatures(); /* make sure this has been calculated */ } SDL_assert(SDL_SIMDAlignment != 0); return SDL_SIMDAlignment; @@ -1121,16 +1175,16 @@ SDL_SIMDAlloc(const size_t len) /* alignment + padding + sizeof (void *) is bounded (a few hundred * bytes max), so no need to check for overflow within that argument */ - if (SDL_size_add_overflow(len, alignment + padding + sizeof (void *), &to_allocate)) { + if (SDL_size_add_overflow(len, alignment + padding + sizeof(void *), &to_allocate)) { return NULL; } - ptr = (Uint8 *) SDL_malloc(to_allocate); + ptr = (Uint8 *)SDL_malloc(to_allocate); if (ptr) { /* store the actual allocated pointer right before our aligned pointer. */ - retval = ptr + sizeof (void *); - retval += alignment - (((size_t) retval) % alignment); - *(((void **) retval) - 1) = ptr; + retval = ptr + sizeof(void *); + retval += alignment - (((size_t)retval) % alignment); + *(((void **)retval) - 1) = ptr; } return retval; } @@ -1140,7 +1194,7 @@ SDL_SIMDRealloc(void *mem, const size_t len) { const size_t alignment = SDL_SIMDGetAlignment(); const size_t padding = (alignment - (len % alignment)) % alignment; - Uint8 *retval = (Uint8*) mem; + Uint8 *retval = (Uint8 *)mem; void *oldmem = mem; size_t memdiff = 0, ptrdiff; Uint8 *ptr; @@ -1148,32 +1202,32 @@ SDL_SIMDRealloc(void *mem, const size_t len) /* alignment + padding + sizeof (void *) is bounded (a few hundred * bytes max), so no need to check for overflow within that argument */ - if (SDL_size_add_overflow(len, alignment + padding + sizeof (void *), &to_allocate)) { + if (SDL_size_add_overflow(len, alignment + padding + sizeof(void *), &to_allocate)) { return NULL; } if (mem) { - mem = *(((void **) mem) - 1); + mem = *(((void **)mem) - 1); /* Check the delta between the real pointer and user pointer */ - memdiff = ((size_t) oldmem) - ((size_t) mem); + memdiff = ((size_t)oldmem) - ((size_t)mem); } - ptr = (Uint8 *) SDL_realloc(mem, to_allocate); + ptr = (Uint8 *)SDL_realloc(mem, to_allocate); if (ptr == NULL) { return NULL; /* Out of memory, bail! */ } /* Store the actual allocated pointer right before our aligned pointer. */ - retval = ptr + sizeof (void *); - retval += alignment - (((size_t) retval) % alignment); + retval = ptr + sizeof(void *); + retval += alignment - (((size_t)retval) % alignment); /* Make sure the delta is the same! */ if (mem) { - ptrdiff = ((size_t) retval) - ((size_t) ptr); + ptrdiff = ((size_t)retval) - ((size_t)ptr); if (memdiff != ptrdiff) { /* Delta has changed, copy to new offset! */ - oldmem = (void*) (((uintptr_t) ptr) + memdiff); + oldmem = (void *)(((uintptr_t)ptr) + memdiff); /* Even though the data past the old `len` is undefined, this is the * only length value we have, and it guarantees that we copy all the @@ -1184,25 +1238,22 @@ SDL_SIMDRealloc(void *mem, const size_t len) } /* Actually store the allocated pointer, finally. */ - *(((void **) retval) - 1) = ptr; + *(((void **)retval) - 1) = ptr; return retval; } -void -SDL_SIMDFree(void *ptr) +void SDL_SIMDFree(void *ptr) { if (ptr) { - SDL_free(*(((void **) ptr) - 1)); + SDL_free(*(((void **)ptr) - 1)); } } - #ifdef TEST_MAIN #include -int -main() +int main() { printf("CPU count: %d\n", SDL_GetCPUCount()); printf("CPU type: %s\n", SDL_GetCPUType()); diff --git a/src/dynapi/SDL_dynapi.c b/src/dynapi/SDL_dynapi.c index 936c1a0f8..7219a622c 100644 --- a/src/dynapi/SDL_dynapi.c +++ b/src/dynapi/SDL_dynapi.c @@ -55,7 +55,6 @@ static void SDL_InitDynamicAPI(void); /* BE CAREFUL CALLING ANY SDL CODE IN HERE, IT WILL BLOW UP. Even self-contained stuff might call SDL_Error and break everything. */ - /* behold, the macro salsa! */ /* !!! FIXME: ...disabled...until we write it. :) */ @@ -63,110 +62,134 @@ static void SDL_InitDynamicAPI(void); #if DISABLE_JUMP_MAGIC /* Can't use the macro for varargs nonsense. This is atrocious. */ -#define SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, logname, prio) \ - _static void SDLCALL SDL_Log##logname##name(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ - va_list ap; initcall; va_start(ap, fmt); \ - jump_table.SDL_LogMessageV(category, SDL_LOG_PRIORITY_##prio, fmt, ap); \ - va_end(ap); \ +#define SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, logname, prio) \ + _static void SDLCALL SDL_Log##logname##name(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) \ + { \ + va_list ap; \ + initcall; \ + va_start(ap, fmt); \ + jump_table.SDL_LogMessageV(category, SDL_LOG_PRIORITY_##prio, fmt, ap); \ + va_end(ap); \ } -#define SDL_DYNAPI_VARARGS(_static, name, initcall) \ - _static int SDLCALL SDL_SetError##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ - char buf[128], *str = buf; \ - int result; \ - va_list ap; initcall; \ - va_start(ap, fmt); \ - result = jump_table.SDL_vsnprintf(buf, sizeof(buf), fmt, ap); \ - va_end(ap); \ - if (result >= 0 && (size_t)result >= sizeof(buf)) { \ - size_t len = (size_t)result + 1; \ - str = (char *)jump_table.SDL_malloc(len); \ - if (str) { \ - va_start(ap, fmt); \ - result = jump_table.SDL_vsnprintf(str, len, fmt, ap); \ - va_end(ap); \ - } \ - } \ - if (result >= 0) { \ - result = jump_table.SDL_SetError("%s", str); \ - } \ - if (str != buf) { \ - jump_table.SDL_free(str); \ - } \ - return result; \ - } \ - _static int SDLCALL SDL_sscanf##name(const char *buf, SDL_SCANF_FORMAT_STRING const char *fmt, ...) { \ - int retval; va_list ap; initcall; va_start(ap, fmt); \ - retval = jump_table.SDL_vsscanf(buf, fmt, ap); \ - va_end(ap); \ - return retval; \ - } \ - _static int SDLCALL SDL_snprintf##name(SDL_OUT_Z_CAP(maxlen) char *buf, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ - int retval; va_list ap; initcall; va_start(ap, fmt); \ - retval = jump_table.SDL_vsnprintf(buf, maxlen, fmt, ap); \ - va_end(ap); \ - return retval; \ - } \ - _static int SDLCALL SDL_asprintf##name(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ - int retval; va_list ap; initcall; va_start(ap, fmt); \ - retval = jump_table.SDL_vasprintf(strp, fmt, ap); \ - va_end(ap); \ - return retval; \ - } \ - _static void SDLCALL SDL_Log##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ - va_list ap; initcall; va_start(ap, fmt); \ - jump_table.SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap); \ - va_end(ap); \ - } \ - _static void SDLCALL SDL_LogMessage##name(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ - va_list ap; initcall; va_start(ap, fmt); \ - jump_table.SDL_LogMessageV(category, priority, fmt, ap); \ - va_end(ap); \ - } \ - SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Verbose, VERBOSE) \ - SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Debug, DEBUG) \ - SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Info, INFO) \ - SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Warn, WARN) \ - SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Error, ERROR) \ +#define SDL_DYNAPI_VARARGS(_static, name, initcall) \ + _static int SDLCALL SDL_SetError##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) \ + { \ + char buf[128], *str = buf; \ + int result; \ + va_list ap; \ + initcall; \ + va_start(ap, fmt); \ + result = jump_table.SDL_vsnprintf(buf, sizeof(buf), fmt, ap); \ + va_end(ap); \ + if (result >= 0 && (size_t)result >= sizeof(buf)) { \ + size_t len = (size_t)result + 1; \ + str = (char *)jump_table.SDL_malloc(len); \ + if (str) { \ + va_start(ap, fmt); \ + result = jump_table.SDL_vsnprintf(str, len, fmt, ap); \ + va_end(ap); \ + } \ + } \ + if (result >= 0) { \ + result = jump_table.SDL_SetError("%s", str); \ + } \ + if (str != buf) { \ + jump_table.SDL_free(str); \ + } \ + return result; \ + } \ + _static int SDLCALL SDL_sscanf##name(const char *buf, SDL_SCANF_FORMAT_STRING const char *fmt, ...) \ + { \ + int retval; \ + va_list ap; \ + initcall; \ + va_start(ap, fmt); \ + retval = jump_table.SDL_vsscanf(buf, fmt, ap); \ + va_end(ap); \ + return retval; \ + } \ + _static int SDLCALL SDL_snprintf##name(SDL_OUT_Z_CAP(maxlen) char *buf, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) \ + { \ + int retval; \ + va_list ap; \ + initcall; \ + va_start(ap, fmt); \ + retval = jump_table.SDL_vsnprintf(buf, maxlen, fmt, ap); \ + va_end(ap); \ + return retval; \ + } \ + _static int SDLCALL SDL_asprintf##name(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) \ + { \ + int retval; \ + va_list ap; \ + initcall; \ + va_start(ap, fmt); \ + retval = jump_table.SDL_vasprintf(strp, fmt, ap); \ + va_end(ap); \ + return retval; \ + } \ + _static void SDLCALL SDL_Log##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) \ + { \ + va_list ap; \ + initcall; \ + va_start(ap, fmt); \ + jump_table.SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap); \ + va_end(ap); \ + } \ + _static void SDLCALL SDL_LogMessage##name(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) \ + { \ + va_list ap; \ + initcall; \ + va_start(ap, fmt); \ + jump_table.SDL_LogMessageV(category, priority, fmt, ap); \ + va_end(ap); \ + } \ + SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Verbose, VERBOSE) \ + SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Debug, DEBUG) \ + SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Info, INFO) \ + SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Warn, WARN) \ + SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Error, ERROR) \ SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Critical, CRITICAL) #endif - /* Typedefs for function pointers for jump table, and predeclare funcs */ /* The DEFAULT funcs will init jump table and then call real function. */ /* The REAL funcs are the actual functions, name-mangled to not clash. */ -#define SDL_DYNAPI_PROC(rc,fn,params,args,ret) \ - typedef rc (SDLCALL *SDL_DYNAPIFN_##fn) params; \ - static rc SDLCALL fn##_DEFAULT params; \ +#define SDL_DYNAPI_PROC(rc, fn, params, args, ret) \ + typedef rc(SDLCALL *SDL_DYNAPIFN_##fn) params; \ + static rc SDLCALL fn##_DEFAULT params; \ extern rc SDLCALL fn##_REAL params; #include "SDL_dynapi_procs.h" #undef SDL_DYNAPI_PROC /* The jump table! */ -typedef struct { - #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) SDL_DYNAPIFN_##fn fn; - #include "SDL_dynapi_procs.h" - #undef SDL_DYNAPI_PROC +typedef struct +{ +#define SDL_DYNAPI_PROC(rc, fn, params, args, ret) SDL_DYNAPIFN_##fn fn; +#include "SDL_dynapi_procs.h" +#undef SDL_DYNAPI_PROC } SDL_DYNAPI_jump_table; /* Predeclare the default functions for initializing the jump table. */ -#define SDL_DYNAPI_PROC(rc,fn,params,args,ret) static rc SDLCALL fn##_DEFAULT params; +#define SDL_DYNAPI_PROC(rc, fn, params, args, ret) static rc SDLCALL fn##_DEFAULT params; #include "SDL_dynapi_procs.h" #undef SDL_DYNAPI_PROC /* The actual jump table. */ static SDL_DYNAPI_jump_table jump_table = { - #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) fn##_DEFAULT, - #include "SDL_dynapi_procs.h" - #undef SDL_DYNAPI_PROC +#define SDL_DYNAPI_PROC(rc, fn, params, args, ret) fn##_DEFAULT, +#include "SDL_dynapi_procs.h" +#undef SDL_DYNAPI_PROC }; /* Default functions init the function table then call right thing. */ #if DISABLE_JUMP_MAGIC -#define SDL_DYNAPI_PROC(rc,fn,params,args,ret) \ - static rc SDLCALL fn##_DEFAULT params { \ - SDL_InitDynamicAPI(); \ - ret jump_table.fn args; \ +#define SDL_DYNAPI_PROC(rc, fn, params, args, ret) \ + static rc SDLCALL fn##_DEFAULT params \ + { \ + SDL_InitDynamicAPI(); \ + ret jump_table.fn args; \ } #define SDL_DYNAPI_PROC_NO_VARARGS 1 #include "SDL_dynapi_procs.h" @@ -180,13 +203,13 @@ SDL_DYNAPI_VARARGS(static, _DEFAULT, SDL_InitDynamicAPI()) /* Public API functions to jump into the jump table. */ #if DISABLE_JUMP_MAGIC -#define SDL_DYNAPI_PROC(rc,fn,params,args,ret) \ +#define SDL_DYNAPI_PROC(rc, fn, params, args, ret) \ rc SDLCALL fn params { ret jump_table.fn args; } #define SDL_DYNAPI_PROC_NO_VARARGS 1 #include "SDL_dynapi_procs.h" #undef SDL_DYNAPI_PROC #undef SDL_DYNAPI_PROC_NO_VARARGS -SDL_DYNAPI_VARARGS(,,) +SDL_DYNAPI_VARARGS(, , ) #else /* !!! FIXME: need the jump magic. */ #error Write me. @@ -194,16 +217,18 @@ SDL_DYNAPI_VARARGS(,,) #define ENABLE_SDL_CALL_LOGGING 0 #if ENABLE_SDL_CALL_LOGGING -static int SDLCALL SDL_SetError_LOGSDLCALLS(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { - char buf[512]; /* !!! FIXME: dynamic allocation */ \ +static int SDLCALL SDL_SetError_LOGSDLCALLS(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) +{ + char buf[512]; /* !!! FIXME: dynamic allocation */ va_list ap; SDL_Log_REAL("SDL2CALL SDL_SetError"); va_start(ap, fmt); - SDL_vsnprintf_REAL(buf, sizeof (buf), fmt, ap); + SDL_vsnprintf_REAL(buf, sizeof(buf), fmt, ap); va_end(ap); return SDL_SetError_REAL("%s", buf); } -static int SDLCALL SDL_sscanf_LOGSDLCALLS(const char *buf, SDL_SCANF_FORMAT_STRING const char *fmt, ...) { +static int SDLCALL SDL_sscanf_LOGSDLCALLS(const char *buf, SDL_SCANF_FORMAT_STRING const char *fmt, ...) +{ int retval; va_list ap; SDL_Log_REAL("SDL2CALL SDL_sscanf"); @@ -212,7 +237,8 @@ static int SDLCALL SDL_sscanf_LOGSDLCALLS(const char *buf, SDL_SCANF_FORMAT_STRI va_end(ap); return retval; } -static int SDLCALL SDL_snprintf_LOGSDLCALLS(SDL_OUT_Z_CAP(maxlen) char *buf, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { +static int SDLCALL SDL_snprintf_LOGSDLCALLS(SDL_OUT_Z_CAP(maxlen) char *buf, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) +{ int retval; va_list ap; SDL_Log_REAL("SDL2CALL SDL_snprintf"); @@ -221,7 +247,8 @@ static int SDLCALL SDL_snprintf_LOGSDLCALLS(SDL_OUT_Z_CAP(maxlen) char *buf, siz va_end(ap); return retval; } -static int SDLCALL SDL_asprintf_LOGSDLCALLS(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { +static int SDLCALL SDL_asprintf_LOGSDLCALLS(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) +{ int retval; va_list ap; SDL_Log_REAL("SDL2CALL SDL_asprintf"); @@ -230,14 +257,16 @@ static int SDLCALL SDL_asprintf_LOGSDLCALLS(char **strp, SDL_PRINTF_FORMAT_STRIN va_end(ap); return retval; } -static void SDLCALL SDL_Log_LOGSDLCALLS(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { +static void SDLCALL SDL_Log_LOGSDLCALLS(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) +{ va_list ap; SDL_Log_REAL("SDL2CALL SDL_Log"); va_start(ap, fmt); - SDL_LogMessageV_REAL(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap); \ + SDL_LogMessageV_REAL(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap); va_end(ap); } -static void SDLCALL SDL_LogMessage_LOGSDLCALLS(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { +static void SDLCALL SDL_LogMessage_LOGSDLCALLS(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) +{ va_list ap; SDL_Log_REAL("SDL2CALL SDL_LogMessage"); va_start(ap, fmt); @@ -267,38 +296,37 @@ SDL_DYNAPI_VARARGS_LOGFN_LOGSDLCALLS(Critical, CRITICAL) /* we make this a static function so we can call the correct one without the system's dynamic linker resolving to the wrong version of this. */ -static Sint32 -initialize_jumptable(Uint32 apiver, void *table, Uint32 tablesize) +static Sint32 initialize_jumptable(Uint32 apiver, void *table, Uint32 tablesize) { - SDL_DYNAPI_jump_table *output_jump_table = (SDL_DYNAPI_jump_table *) table; + SDL_DYNAPI_jump_table *output_jump_table = (SDL_DYNAPI_jump_table *)table; if (apiver != SDL_DYNAPI_VERSION) { /* !!! FIXME: can maybe handle older versions? */ - return -1; /* not compatible. */ - } else if (tablesize > sizeof (jump_table)) { - return -1; /* newer version of SDL with functions we can't provide. */ + return -1; /* not compatible. */ + } else if (tablesize > sizeof(jump_table)) { + return -1; /* newer version of SDL with functions we can't provide. */ } - /* Init our jump table first. */ - #if ENABLE_SDL_CALL_LOGGING +/* Init our jump table first. */ +#if ENABLE_SDL_CALL_LOGGING { const char *env = SDL_getenv_REAL("SDL_DYNAPI_LOG_CALLS"); const SDL_bool log_calls = (env && SDL_atoi_REAL(env)); if (log_calls) { - #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) jump_table.fn = fn##_LOGSDLCALLS; - #include "SDL_dynapi_procs.h" - #undef SDL_DYNAPI_PROC +#define SDL_DYNAPI_PROC(rc, fn, params, args, ret) jump_table.fn = fn##_LOGSDLCALLS; +#include "SDL_dynapi_procs.h" +#undef SDL_DYNAPI_PROC } else { - #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) jump_table.fn = fn##_REAL; - #include "SDL_dynapi_procs.h" - #undef SDL_DYNAPI_PROC +#define SDL_DYNAPI_PROC(rc, fn, params, args, ret) jump_table.fn = fn##_REAL; +#include "SDL_dynapi_procs.h" +#undef SDL_DYNAPI_PROC } } - #else - #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) jump_table.fn = fn##_REAL; - #include "SDL_dynapi_procs.h" - #undef SDL_DYNAPI_PROC - #endif +#else +#define SDL_DYNAPI_PROC(rc, fn, params, args, ret) jump_table.fn = fn##_REAL; +#include "SDL_dynapi_procs.h" +#undef SDL_DYNAPI_PROC +#endif /* Then the external table... */ if (output_jump_table != &jump_table) { @@ -307,13 +335,12 @@ initialize_jumptable(Uint32 apiver, void *table, Uint32 tablesize) /* Safe to call SDL functions now; jump table is initialized! */ - return 0; /* success! */ + return 0; /* success! */ } - /* Here's the exported entry point that fills in the jump table. */ /* Use specific types when an "int" might suffice to keep this sane. */ -typedef Sint32 (SDLCALL *SDL_DYNAPI_ENTRYFN)(Uint32 apiver, void *table, Uint32 tablesize); +typedef Sint32(SDLCALL *SDL_DYNAPI_ENTRYFN)(Uint32 apiver, void *table, Uint32 tablesize); extern DECLSPEC Sint32 SDLCALL SDL_DYNAPI_entry(Uint32, void *, Uint32); Sint32 @@ -322,7 +349,6 @@ SDL_DYNAPI_entry(Uint32 apiver, void *table, Uint32 tablesize) return initialize_jumptable(apiver, table, tablesize); } - /* Obviously we can't use SDL_LoadObject() to load SDL. :) */ /* Also obviously, we never close the loaded library. */ #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) @@ -376,17 +402,16 @@ static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym) #error Please define your platform. #endif - static void dynapi_warn(const char *msg) { const char *caption = "SDL Dynamic API Failure!"; - /* SDL_ShowSimpleMessageBox() is a too heavy for here. */ - #if (defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +/* SDL_ShowSimpleMessageBox() is a too heavy for here. */ +#if (defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) MessageBoxA(NULL, msg, caption, MB_OK | MB_ICONERROR); - #elif defined(HAVE_STDIO_H) +#elif defined(HAVE_STDIO_H) fprintf(stderr, "\n\n%s\n%s\n\n", caption, msg); fflush(stderr); - #endif +#endif } /* This is not declared in any header, although it is shared between some @@ -398,16 +423,14 @@ void SDL_ExitProcess(int exitcode); #endif SDL_NORETURN void SDL_ExitProcess(int exitcode); - -static void -SDL_InitDynamicAPILocked(void) +static void SDL_InitDynamicAPILocked(void) { const char *libname = SDL_getenv_REAL(SDL_DYNAMIC_API_ENVVAR); - SDL_DYNAPI_ENTRYFN entry = NULL; /* funcs from here by default. */ + SDL_DYNAPI_ENTRYFN entry = NULL; /* funcs from here by default. */ SDL_bool use_internal = SDL_TRUE; if (libname) { - entry = (SDL_DYNAPI_ENTRYFN) get_sdlapi_entry(libname, "SDL_DYNAPI_entry"); + entry = (SDL_DYNAPI_ENTRYFN)get_sdlapi_entry(libname, "SDL_DYNAPI_entry"); if (!entry) { dynapi_warn("Couldn't load overriding SDL library. Please fix or remove the " SDL_DYNAMIC_API_ENVVAR " environment variable. Using the default SDL."); /* Just fill in the function pointers from this library, later. */ @@ -415,17 +438,17 @@ SDL_InitDynamicAPILocked(void) } if (entry) { - if (entry(SDL_DYNAPI_VERSION, &jump_table, sizeof (jump_table)) < 0) { + if (entry(SDL_DYNAPI_VERSION, &jump_table, sizeof(jump_table)) < 0) { dynapi_warn("Couldn't override SDL library. Using a newer SDL build might help. Please fix or remove the " SDL_DYNAMIC_API_ENVVAR " environment variable. Using the default SDL."); /* Just fill in the function pointers from this library, later. */ } else { - use_internal = SDL_FALSE; /* We overrode SDL! Don't use the internal version! */ + use_internal = SDL_FALSE; /* We overrode SDL! Don't use the internal version! */ } } /* Just fill in the function pointers from this library. */ if (use_internal) { - if (initialize_jumptable(SDL_DYNAPI_VERSION, &jump_table, sizeof (jump_table)) < 0) { + if (initialize_jumptable(SDL_DYNAPI_VERSION, &jump_table, sizeof(jump_table)) < 0) { /* Now we're screwed. Should definitely abort now. */ dynapi_warn("Failed to initialize internal SDL dynapi. As this would otherwise crash, we have to abort now."); SDL_ExitProcess(86); @@ -435,8 +458,7 @@ SDL_InitDynamicAPILocked(void) /* we intentionally never close the newly-loaded lib, of course. */ } -static void -SDL_InitDynamicAPI(void) +static void SDL_InitDynamicAPI(void) { /* So the theory is that every function in the jump table defaults to * calling this function, and then replaces itself with a version that @@ -451,24 +473,24 @@ SDL_InitDynamicAPI(void) */ static SDL_bool already_initialized = SDL_FALSE; - /* SDL_AtomicLock calls SDL mutex functions to emulate if - SDL_ATOMIC_DISABLED, which we can't do here, so in such a - configuration, you're on your own. */ - #if !SDL_ATOMIC_DISABLED +/* SDL_AtomicLock calls SDL mutex functions to emulate if + SDL_ATOMIC_DISABLED, which we can't do here, so in such a + configuration, you're on your own. */ +#if !SDL_ATOMIC_DISABLED static SDL_SpinLock lock = 0; SDL_AtomicLock_REAL(&lock); - #endif +#endif if (!already_initialized) { SDL_InitDynamicAPILocked(); already_initialized = SDL_TRUE; } - #if !SDL_ATOMIC_DISABLED +#if !SDL_ATOMIC_DISABLED SDL_AtomicUnlock_REAL(&lock); - #endif +#endif } -#endif /* SDL_DYNAMIC_API */ +#endif /* SDL_DYNAMIC_API */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/dynapi/SDL_dynapi.h b/src/dynapi/SDL_dynapi.h index d71946213..7543f2a6b 100644 --- a/src/dynapi/SDL_dynapi.h +++ b/src/dynapi/SDL_dynapi.h @@ -35,7 +35,7 @@ updated SDL can transparently take advantage of them, but your program will not without this feature. Think hard before turning it off. */ -#ifdef SDL_DYNAMIC_API /* Tried to force it on the command line? */ +#ifdef SDL_DYNAMIC_API /* Tried to force it on the command line? */ #error Nope, you have to edit this file to force this off. #endif @@ -43,7 +43,7 @@ #include "TargetConditionals.h" #endif -#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE /* probably not useful on iOS. */ +#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE /* probably not useful on iOS. */ #define SDL_DYNAMIC_API 0 #elif defined(__ANDROID__) /* probably not useful on Android. */ #define SDL_DYNAMIC_API 0 @@ -51,7 +51,7 @@ #define SDL_DYNAMIC_API 0 #elif defined(__EMSCRIPTEN__) && __EMSCRIPTEN__ /* probably not useful on Emscripten. */ #define SDL_DYNAMIC_API 0 -#elif defined(SDL_BUILDING_WINRT) && SDL_BUILDING_WINRT /* probably not useful on WinRT, given current .dll loading restrictions */ +#elif defined(SDL_BUILDING_WINRT) && SDL_BUILDING_WINRT /* probably not useful on WinRT, given current .dll loading restrictions */ #define SDL_DYNAMIC_API 0 #elif defined(__PS2__) && __PS2__ #define SDL_DYNAMIC_API 0 @@ -60,15 +60,15 @@ #elif defined(__riscos__) && __riscos__ /* probably not useful on RISC OS, since dlopen() can't be used when using static linking. */ #define SDL_DYNAMIC_API 0 #elif defined(__clang_analyzer__) -#define SDL_DYNAMIC_API 0 /* Turn off for static analysis, so reports are more clear. */ +#define SDL_DYNAMIC_API 0 /* Turn off for static analysis, so reports are more clear. */ #elif defined(__VITA__) -#define SDL_DYNAMIC_API 0 /* vitasdk doesn't support dynamic linking */ +#define SDL_DYNAMIC_API 0 /* vitasdk doesn't support dynamic linking */ #elif defined(__NGAGE__) -#define SDL_DYNAMIC_API 0 /* The N-Gage doesn't support dynamic linking either */ +#define SDL_DYNAMIC_API 0 /* The N-Gage doesn't support dynamic linking either */ #elif defined(__3DS__) -#define SDL_DYNAMIC_API 0 /* devkitARM doesn't support dynamic linking */ +#define SDL_DYNAMIC_API 0 /* devkitARM doesn't support dynamic linking */ #elif defined(DYNAPI_NEEDS_DLOPEN) && !defined(HAVE_DLOPEN) -#define SDL_DYNAMIC_API 0 /* we need dlopen(), but don't have it.... */ +#define SDL_DYNAMIC_API 0 /* we need dlopen(), but don't have it.... */ #endif /* everyone else. This is where we turn on the API if nothing forced it off. */ diff --git a/src/events/SDL_clipboardevents.c b/src/events/SDL_clipboardevents.c index de5d0137a..a015aa37c 100644 --- a/src/events/SDL_clipboardevents.c +++ b/src/events/SDL_clipboardevents.c @@ -26,9 +26,7 @@ #include "SDL_events_c.h" #include "SDL_clipboardevents_c.h" - -int -SDL_SendClipboardUpdate(void) +int SDL_SendClipboardUpdate(void) { int posted; diff --git a/src/events/SDL_displayevents.c b/src/events/SDL_displayevents.c index 3eabf1ad0..6cf122440 100644 --- a/src/events/SDL_displayevents.c +++ b/src/events/SDL_displayevents.c @@ -25,9 +25,7 @@ #include "SDL_events.h" #include "SDL_events_c.h" - -int -SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data1) +int SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data1) { int posted; diff --git a/src/events/SDL_dropevents.c b/src/events/SDL_dropevents.c index daefeb09b..367964986 100644 --- a/src/events/SDL_dropevents.c +++ b/src/events/SDL_dropevents.c @@ -26,11 +26,9 @@ #include "SDL_events_c.h" #include "SDL_dropevents_c.h" -#include "../video/SDL_sysvideo.h" /* for SDL_Window internals. */ +#include "../video/SDL_sysvideo.h" /* for SDL_Window internals. */ - -static int -SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const char *data) +static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const char *data) { static SDL_bool app_is_dropping = SDL_FALSE; int posted = 0; @@ -76,23 +74,19 @@ SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const char *data) return posted; } -int -SDL_SendDropFile(SDL_Window *window, const char *file) +int SDL_SendDropFile(SDL_Window *window, const char *file) { return SDL_SendDrop(window, SDL_DROPFILE, file); } -int -SDL_SendDropText(SDL_Window *window, const char *text) +int SDL_SendDropText(SDL_Window *window, const char *text) { return SDL_SendDrop(window, SDL_DROPTEXT, text); } -int -SDL_SendDropComplete(SDL_Window *window) +int SDL_SendDropComplete(SDL_Window *window) { return SDL_SendDrop(window, SDL_DROPCOMPLETE, NULL); } - /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index 189413231..cf22f547a 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -36,18 +36,19 @@ #undef SDL_PRIs64 #if (defined(__WIN32__) || defined(__GDK__)) && !defined(__CYGWIN__) -#define SDL_PRIs64 "I64d" +#define SDL_PRIs64 "I64d" #else -#define SDL_PRIs64 "lld" +#define SDL_PRIs64 "lld" #endif /* An arbitrary limit so we don't have unbounded growth */ -#define SDL_MAX_QUEUED_EVENTS 65535 +#define SDL_MAX_QUEUED_EVENTS 65535 /* Determines how often we wake to call SDL_PumpEvents() in SDL_WaitEventTimeout_Device() */ #define PERIODIC_POLL_INTERVAL_MS 3000 -typedef struct SDL_EventWatcher { +typedef struct SDL_EventWatcher +{ SDL_EventFilter callback; void *userdata; SDL_bool removed; @@ -61,7 +62,8 @@ static SDL_bool SDL_event_watchers_dispatching = SDL_FALSE; static SDL_bool SDL_event_watchers_removed = SDL_FALSE; static SDL_atomic_t SDL_sentinel_pending; -typedef struct { +typedef struct +{ Uint32 bits[8]; } SDL_DisabledEventBlock; @@ -96,13 +98,11 @@ static struct SDL_SysWMEntry *wmmsg_free; } SDL_EventQ = { NULL, SDL_FALSE, { 0 }, 0, NULL, NULL, NULL, NULL, NULL }; - #if !SDL_JOYSTICK_DISABLED static SDL_bool SDL_update_joysticks = SDL_TRUE; -static void -SDL_CalculateShouldUpdateJoysticks(SDL_bool hint_value) +static void SDL_CalculateShouldUpdateJoysticks(SDL_bool hint_value) { if (hint_value && (!SDL_disabled_events[SDL_JOYAXISMOTION >> 8] || SDL_JoystickEventState(SDL_QUERY))) { @@ -112,21 +112,18 @@ SDL_CalculateShouldUpdateJoysticks(SDL_bool hint_value) } } -static void SDLCALL -SDL_AutoUpdateJoysticksChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_AutoUpdateJoysticksChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_CalculateShouldUpdateJoysticks(SDL_GetStringBoolean(hint, SDL_TRUE)); } #endif /* !SDL_JOYSTICK_DISABLED */ - #if !SDL_SENSOR_DISABLED static SDL_bool SDL_update_sensors = SDL_TRUE; -static void -SDL_CalculateShouldUpdateSensors(SDL_bool hint_value) +static void SDL_CalculateShouldUpdateSensors(SDL_bool hint_value) { if (hint_value && !SDL_disabled_events[SDL_SENSORUPDATE >> 8]) { @@ -136,16 +133,14 @@ SDL_CalculateShouldUpdateSensors(SDL_bool hint_value) } } -static void SDLCALL -SDL_AutoUpdateSensorsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_AutoUpdateSensorsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_CalculateShouldUpdateSensors(SDL_GetStringBoolean(hint, SDL_TRUE)); } #endif /* !SDL_SENSOR_DISABLED */ -static void SDLCALL -SDL_PollSentinelChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_PollSentinelChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { (void)SDL_EventState(SDL_POLLSENTINEL, SDL_GetStringBoolean(hint, SDL_TRUE) ? SDL_ENABLE : SDL_DISABLE); } @@ -159,25 +154,23 @@ SDL_PollSentinelChanged(void *userdata, const char *name, const char *oldValue, */ static int SDL_EventLoggingVerbosity = 0; -static void SDLCALL -SDL_EventLoggingChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_EventLoggingChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_EventLoggingVerbosity = (hint && *hint) ? SDL_clamp(SDL_atoi(hint), 0, 3) : 0; } -static void -SDL_LogEvent(const SDL_Event *event) +static void SDL_LogEvent(const SDL_Event *event) { char name[32]; char details[128]; /* sensor/mouse/finger motion are spammy, ignore these if they aren't demanded. */ - if ( (SDL_EventLoggingVerbosity < 2) && - ( (event->type == SDL_MOUSEMOTION) || - (event->type == SDL_FINGERMOTION) || - (event->type == SDL_CONTROLLERTOUCHPADMOTION) || - (event->type == SDL_CONTROLLERSENSORUPDATE) || - (event->type == SDL_SENSORUPDATE) ) ) { + if ((SDL_EventLoggingVerbosity < 2) && + ((event->type == SDL_MOUSEMOTION) || + (event->type == SDL_FINGERMOTION) || + (event->type == SDL_CONTROLLERTOUCHPADMOTION) || + (event->type == SDL_CONTROLLERSENSORUPDATE) || + (event->type == SDL_SENSORUPDATE))) { return; } @@ -186,8 +179,8 @@ SDL_LogEvent(const SDL_Event *event) return; } - /* this is to make SDL_snprintf() calls cleaner. */ - #define uint unsigned int +/* this is to make SDL_snprintf() calls cleaner. */ +#define uint unsigned int name[0] = '\0'; details[0] = '\0'; @@ -196,54 +189,85 @@ SDL_LogEvent(const SDL_Event *event) if ((event->type >= SDL_USEREVENT) && (event->type <= SDL_LASTEVENT)) { char plusstr[16]; - SDL_strlcpy(name, "SDL_USEREVENT", sizeof (name)); + SDL_strlcpy(name, "SDL_USEREVENT", sizeof(name)); if (event->type > SDL_USEREVENT) { - SDL_snprintf(plusstr, sizeof (plusstr), "+%u", ((uint) event->type) - SDL_USEREVENT); + SDL_snprintf(plusstr, sizeof(plusstr), "+%u", ((uint)event->type) - SDL_USEREVENT); } else { plusstr[0] = '\0'; } - SDL_snprintf(details, sizeof (details), "%s (timestamp=%u windowid=%u code=%d data1=%p data2=%p)", - plusstr, (uint) event->user.timestamp, (uint) event->user.windowID, - (int) event->user.code, event->user.data1, event->user.data2); + SDL_snprintf(details, sizeof(details), "%s (timestamp=%u windowid=%u code=%d data1=%p data2=%p)", + plusstr, (uint)event->user.timestamp, (uint)event->user.windowID, + (int)event->user.code, event->user.data1, event->user.data2); } switch (event->type) { - #define SDL_EVENT_CASE(x) case x: SDL_strlcpy(name, #x, sizeof (name)); - SDL_EVENT_CASE(SDL_FIRSTEVENT) SDL_strlcpy(details, " (THIS IS PROBABLY A BUG!)", sizeof (details)); break; - SDL_EVENT_CASE(SDL_QUIT) SDL_snprintf(details, sizeof (details), " (timestamp=%u)", (uint) event->quit.timestamp); break; - SDL_EVENT_CASE(SDL_APP_TERMINATING) break; - SDL_EVENT_CASE(SDL_APP_LOWMEMORY) break; - SDL_EVENT_CASE(SDL_APP_WILLENTERBACKGROUND) break; - SDL_EVENT_CASE(SDL_APP_DIDENTERBACKGROUND) break; - SDL_EVENT_CASE(SDL_APP_WILLENTERFOREGROUND) break; - SDL_EVENT_CASE(SDL_APP_DIDENTERFOREGROUND) break; - SDL_EVENT_CASE(SDL_LOCALECHANGED) break; - SDL_EVENT_CASE(SDL_KEYMAPCHANGED) break; - SDL_EVENT_CASE(SDL_CLIPBOARDUPDATE) break; - SDL_EVENT_CASE(SDL_RENDER_TARGETS_RESET) break; - SDL_EVENT_CASE(SDL_RENDER_DEVICE_RESET) break; +#define SDL_EVENT_CASE(x) \ + case x: \ + SDL_strlcpy(name, #x, sizeof(name)); + SDL_EVENT_CASE(SDL_FIRSTEVENT) + SDL_strlcpy(details, " (THIS IS PROBABLY A BUG!)", sizeof(details)); + break; + SDL_EVENT_CASE(SDL_QUIT) + SDL_snprintf(details, sizeof(details), " (timestamp=%u)", (uint)event->quit.timestamp); + break; + SDL_EVENT_CASE(SDL_APP_TERMINATING) + break; + SDL_EVENT_CASE(SDL_APP_LOWMEMORY) + break; + SDL_EVENT_CASE(SDL_APP_WILLENTERBACKGROUND) + break; + SDL_EVENT_CASE(SDL_APP_DIDENTERBACKGROUND) + break; + SDL_EVENT_CASE(SDL_APP_WILLENTERFOREGROUND) + break; + SDL_EVENT_CASE(SDL_APP_DIDENTERFOREGROUND) + break; + SDL_EVENT_CASE(SDL_LOCALECHANGED) + break; + SDL_EVENT_CASE(SDL_KEYMAPCHANGED) + break; + SDL_EVENT_CASE(SDL_CLIPBOARDUPDATE) + break; + SDL_EVENT_CASE(SDL_RENDER_TARGETS_RESET) + break; + SDL_EVENT_CASE(SDL_RENDER_DEVICE_RESET) + break; - SDL_EVENT_CASE(SDL_DISPLAYEVENT) { + SDL_EVENT_CASE(SDL_DISPLAYEVENT) + { char name2[64]; switch (event->display.event) { - case SDL_DISPLAYEVENT_NONE: SDL_strlcpy(name2, "SDL_DISPLAYEVENT_NONE (THIS IS PROBABLY A BUG!)", sizeof(name2)); break; - #define SDL_DISPLAYEVENT_CASE(x) case x: SDL_strlcpy(name2, #x, sizeof (name2)); break + case SDL_DISPLAYEVENT_NONE: + SDL_strlcpy(name2, "SDL_DISPLAYEVENT_NONE (THIS IS PROBABLY A BUG!)", sizeof(name2)); + break; +#define SDL_DISPLAYEVENT_CASE(x) \ + case x: \ + SDL_strlcpy(name2, #x, sizeof(name2)); \ + break SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_ORIENTATION); SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_CONNECTED); SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_DISCONNECTED); - #undef SDL_DISPLAYEVENT_CASE - default: SDL_strlcpy(name2, "UNKNOWN (bug? fixme?)", sizeof(name2)); break; +#undef SDL_DISPLAYEVENT_CASE + default: + SDL_strlcpy(name2, "UNKNOWN (bug? fixme?)", sizeof(name2)); + break; } - SDL_snprintf(details, sizeof (details), " (timestamp=%u display=%u event=%s data1=%d)", - (uint) event->display.timestamp, (uint) event->display.display, name2, (int) event->display.data1); + SDL_snprintf(details, sizeof(details), " (timestamp=%u display=%u event=%s data1=%d)", + (uint)event->display.timestamp, (uint)event->display.display, name2, (int)event->display.data1); break; } - SDL_EVENT_CASE(SDL_WINDOWEVENT) { + SDL_EVENT_CASE(SDL_WINDOWEVENT) + { char name2[64]; - switch(event->window.event) { - case SDL_WINDOWEVENT_NONE: SDL_strlcpy(name2, "SDL_WINDOWEVENT_NONE (THIS IS PROBABLY A BUG!)", sizeof (name2)); break; - #define SDL_WINDOWEVENT_CASE(x) case x: SDL_strlcpy(name2, #x, sizeof (name2)); break + switch (event->window.event) { + case SDL_WINDOWEVENT_NONE: + SDL_strlcpy(name2, "SDL_WINDOWEVENT_NONE (THIS IS PROBABLY A BUG!)", sizeof(name2)); + break; +#define SDL_WINDOWEVENT_CASE(x) \ + case x: \ + SDL_strlcpy(name2, #x, sizeof(name2)); \ + break SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_SHOWN); SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_HIDDEN); SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_EXPOSED); @@ -262,208 +286,259 @@ SDL_LogEvent(const SDL_Event *event) SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_HIT_TEST); SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_ICCPROF_CHANGED); SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_DISPLAY_CHANGED); - #undef SDL_WINDOWEVENT_CASE - default: SDL_strlcpy(name2, "UNKNOWN (bug? fixme?)", sizeof (name2)); break; +#undef SDL_WINDOWEVENT_CASE + default: + SDL_strlcpy(name2, "UNKNOWN (bug? fixme?)", sizeof(name2)); + break; } - SDL_snprintf(details, sizeof (details), " (timestamp=%u windowid=%u event=%s data1=%d data2=%d)", - (uint) event->window.timestamp, (uint) event->window.windowID, name2, (int) event->window.data1, (int) event->window.data2); + SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u event=%s data1=%d data2=%d)", + (uint)event->window.timestamp, (uint)event->window.windowID, name2, (int)event->window.data1, (int)event->window.data2); break; } SDL_EVENT_CASE(SDL_SYSWMEVENT) - /* !!! FIXME: we don't delve further at the moment. */ - SDL_snprintf(details, sizeof (details), " (timestamp=%u)", (uint) event->syswm.timestamp); - break; + /* !!! FIXME: we don't delve further at the moment. */ + SDL_snprintf(details, sizeof(details), " (timestamp=%u)", (uint)event->syswm.timestamp); + break; - #define PRINT_KEY_EVENT(event) \ - SDL_snprintf(details, sizeof (details), " (timestamp=%u windowid=%u state=%s repeat=%s scancode=%u keycode=%u mod=%u)", \ - (uint) event->key.timestamp, (uint) event->key.windowID, \ - event->key.state == SDL_PRESSED ? "pressed" : "released", \ - event->key.repeat ? "true" : "false", \ - (uint) event->key.keysym.scancode, \ - (uint) event->key.keysym.sym, \ - (uint) event->key.keysym.mod) - SDL_EVENT_CASE(SDL_KEYDOWN) PRINT_KEY_EVENT(event); break; - SDL_EVENT_CASE(SDL_KEYUP) PRINT_KEY_EVENT(event); break; - #undef PRINT_KEY_EVENT +#define PRINT_KEY_EVENT(event) \ + SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u state=%s repeat=%s scancode=%u keycode=%u mod=%u)", \ + (uint)event->key.timestamp, (uint)event->key.windowID, \ + event->key.state == SDL_PRESSED ? "pressed" : "released", \ + event->key.repeat ? "true" : "false", \ + (uint)event->key.keysym.scancode, \ + (uint)event->key.keysym.sym, \ + (uint)event->key.keysym.mod) + SDL_EVENT_CASE(SDL_KEYDOWN) + PRINT_KEY_EVENT(event); + break; + SDL_EVENT_CASE(SDL_KEYUP) + PRINT_KEY_EVENT(event); + break; +#undef PRINT_KEY_EVENT SDL_EVENT_CASE(SDL_TEXTEDITING) - SDL_snprintf(details, sizeof (details), " (timestamp=%u windowid=%u text='%s' start=%d length=%d)", - (uint) event->edit.timestamp, (uint) event->edit.windowID, - event->edit.text, (int) event->edit.start, (int) event->edit.length); - break; + SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u text='%s' start=%d length=%d)", + (uint)event->edit.timestamp, (uint)event->edit.windowID, + event->edit.text, (int)event->edit.start, (int)event->edit.length); + break; SDL_EVENT_CASE(SDL_TEXTINPUT) - SDL_snprintf(details, sizeof (details), " (timestamp=%u windowid=%u text='%s')", (uint) event->text.timestamp, (uint) event->text.windowID, event->text.text); - break; - + SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u text='%s')", (uint)event->text.timestamp, (uint)event->text.windowID, event->text.text); + break; SDL_EVENT_CASE(SDL_MOUSEMOTION) - SDL_snprintf(details, sizeof (details), " (timestamp=%u windowid=%u which=%u state=%u x=%d y=%d xrel=%d yrel=%d)", - (uint) event->motion.timestamp, (uint) event->motion.windowID, - (uint) event->motion.which, (uint) event->motion.state, - (int) event->motion.x, (int) event->motion.y, - (int) event->motion.xrel, (int) event->motion.yrel); - break; - - #define PRINT_MBUTTON_EVENT(event) \ - SDL_snprintf(details, sizeof (details), " (timestamp=%u windowid=%u which=%u button=%u state=%s clicks=%u x=%d y=%d)", \ - (uint) event->button.timestamp, (uint) event->button.windowID, \ - (uint) event->button.which, (uint) event->button.button, \ - event->button.state == SDL_PRESSED ? "pressed" : "released", \ - (uint) event->button.clicks, (int) event->button.x, (int) event->button.y) - SDL_EVENT_CASE(SDL_MOUSEBUTTONDOWN) PRINT_MBUTTON_EVENT(event); break; - SDL_EVENT_CASE(SDL_MOUSEBUTTONUP) PRINT_MBUTTON_EVENT(event); break; - #undef PRINT_MBUTTON_EVENT + SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u which=%u state=%u x=%d y=%d xrel=%d yrel=%d)", + (uint)event->motion.timestamp, (uint)event->motion.windowID, + (uint)event->motion.which, (uint)event->motion.state, + (int)event->motion.x, (int)event->motion.y, + (int)event->motion.xrel, (int)event->motion.yrel); + break; +#define PRINT_MBUTTON_EVENT(event) \ + SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u which=%u button=%u state=%s clicks=%u x=%d y=%d)", \ + (uint)event->button.timestamp, (uint)event->button.windowID, \ + (uint)event->button.which, (uint)event->button.button, \ + event->button.state == SDL_PRESSED ? "pressed" : "released", \ + (uint)event->button.clicks, (int)event->button.x, (int)event->button.y) + SDL_EVENT_CASE(SDL_MOUSEBUTTONDOWN) + PRINT_MBUTTON_EVENT(event); + break; + SDL_EVENT_CASE(SDL_MOUSEBUTTONUP) + PRINT_MBUTTON_EVENT(event); + break; +#undef PRINT_MBUTTON_EVENT SDL_EVENT_CASE(SDL_MOUSEWHEEL) - SDL_snprintf(details, sizeof (details), " (timestamp=%u windowid=%u which=%u x=%d y=%d preciseX=%f preciseY=%f direction=%s)", - (uint) event->wheel.timestamp, (uint) event->wheel.windowID, - (uint) event->wheel.which, (int) event->wheel.x, (int) event->wheel.y, - event->wheel.preciseX, event->wheel.preciseY, - event->wheel.direction == SDL_MOUSEWHEEL_NORMAL ? "normal" : "flipped"); - break; + SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u which=%u x=%d y=%d preciseX=%f preciseY=%f direction=%s)", + (uint)event->wheel.timestamp, (uint)event->wheel.windowID, + (uint)event->wheel.which, (int)event->wheel.x, (int)event->wheel.y, + event->wheel.preciseX, event->wheel.preciseY, + event->wheel.direction == SDL_MOUSEWHEEL_NORMAL ? "normal" : "flipped"); + break; SDL_EVENT_CASE(SDL_JOYAXISMOTION) - SDL_snprintf(details, sizeof (details), " (timestamp=%u which=%d axis=%u value=%d)", - (uint) event->jaxis.timestamp, (int) event->jaxis.which, - (uint) event->jaxis.axis, (int) event->jaxis.value); - break; + SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d axis=%u value=%d)", + (uint)event->jaxis.timestamp, (int)event->jaxis.which, + (uint)event->jaxis.axis, (int)event->jaxis.value); + break; SDL_EVENT_CASE(SDL_JOYBALLMOTION) - SDL_snprintf(details, sizeof (details), " (timestamp=%u which=%d ball=%u xrel=%d yrel=%d)", - (uint) event->jball.timestamp, (int) event->jball.which, - (uint) event->jball.ball, (int) event->jball.xrel, (int) event->jball.yrel); - break; + SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d ball=%u xrel=%d yrel=%d)", + (uint)event->jball.timestamp, (int)event->jball.which, + (uint)event->jball.ball, (int)event->jball.xrel, (int)event->jball.yrel); + break; SDL_EVENT_CASE(SDL_JOYHATMOTION) - SDL_snprintf(details, sizeof (details), " (timestamp=%u which=%d hat=%u value=%u)", - (uint) event->jhat.timestamp, (int) event->jhat.which, - (uint) event->jhat.hat, (uint) event->jhat.value); - break; + SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d hat=%u value=%u)", + (uint)event->jhat.timestamp, (int)event->jhat.which, + (uint)event->jhat.hat, (uint)event->jhat.value); + break; - #define PRINT_JBUTTON_EVENT(event) \ - SDL_snprintf(details, sizeof (details), " (timestamp=%u which=%d button=%u state=%s)", \ - (uint) event->jbutton.timestamp, (int) event->jbutton.which, \ - (uint) event->jbutton.button, event->jbutton.state == SDL_PRESSED ? "pressed" : "released") - SDL_EVENT_CASE(SDL_JOYBUTTONDOWN) PRINT_JBUTTON_EVENT(event); break; - SDL_EVENT_CASE(SDL_JOYBUTTONUP) PRINT_JBUTTON_EVENT(event); break; - #undef PRINT_JBUTTON_EVENT +#define PRINT_JBUTTON_EVENT(event) \ + SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d button=%u state=%s)", \ + (uint)event->jbutton.timestamp, (int)event->jbutton.which, \ + (uint)event->jbutton.button, event->jbutton.state == SDL_PRESSED ? "pressed" : "released") + SDL_EVENT_CASE(SDL_JOYBUTTONDOWN) + PRINT_JBUTTON_EVENT(event); + break; + SDL_EVENT_CASE(SDL_JOYBUTTONUP) + PRINT_JBUTTON_EVENT(event); + break; +#undef PRINT_JBUTTON_EVENT - #define PRINT_JOYDEV_EVENT(event) SDL_snprintf(details, sizeof (details), " (timestamp=%u which=%d)", (uint) event->jdevice.timestamp, (int) event->jdevice.which) - SDL_EVENT_CASE(SDL_JOYDEVICEADDED) PRINT_JOYDEV_EVENT(event); break; - SDL_EVENT_CASE(SDL_JOYDEVICEREMOVED) PRINT_JOYDEV_EVENT(event); break; - #undef PRINT_JOYDEV_EVENT +#define PRINT_JOYDEV_EVENT(event) SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d)", (uint)event->jdevice.timestamp, (int)event->jdevice.which) + SDL_EVENT_CASE(SDL_JOYDEVICEADDED) + PRINT_JOYDEV_EVENT(event); + break; + SDL_EVENT_CASE(SDL_JOYDEVICEREMOVED) + PRINT_JOYDEV_EVENT(event); + break; +#undef PRINT_JOYDEV_EVENT SDL_EVENT_CASE(SDL_CONTROLLERAXISMOTION) - SDL_snprintf(details, sizeof (details), " (timestamp=%u which=%d axis=%u value=%d)", - (uint) event->caxis.timestamp, (int) event->caxis.which, - (uint) event->caxis.axis, (int) event->caxis.value); - break; + SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d axis=%u value=%d)", + (uint)event->caxis.timestamp, (int)event->caxis.which, + (uint)event->caxis.axis, (int)event->caxis.value); + break; - #define PRINT_CBUTTON_EVENT(event) \ - SDL_snprintf(details, sizeof (details), " (timestamp=%u which=%d button=%u state=%s)", \ - (uint) event->cbutton.timestamp, (int) event->cbutton.which, \ - (uint) event->cbutton.button, event->cbutton.state == SDL_PRESSED ? "pressed" : "released") - SDL_EVENT_CASE(SDL_CONTROLLERBUTTONDOWN) PRINT_CBUTTON_EVENT(event); break; - SDL_EVENT_CASE(SDL_CONTROLLERBUTTONUP) PRINT_CBUTTON_EVENT(event); break; - #undef PRINT_CBUTTON_EVENT +#define PRINT_CBUTTON_EVENT(event) \ + SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d button=%u state=%s)", \ + (uint)event->cbutton.timestamp, (int)event->cbutton.which, \ + (uint)event->cbutton.button, event->cbutton.state == SDL_PRESSED ? "pressed" : "released") + SDL_EVENT_CASE(SDL_CONTROLLERBUTTONDOWN) + PRINT_CBUTTON_EVENT(event); + break; + SDL_EVENT_CASE(SDL_CONTROLLERBUTTONUP) + PRINT_CBUTTON_EVENT(event); + break; +#undef PRINT_CBUTTON_EVENT - #define PRINT_CONTROLLERDEV_EVENT(event) SDL_snprintf(details, sizeof (details), " (timestamp=%u which=%d)", (uint) event->cdevice.timestamp, (int) event->cdevice.which) - SDL_EVENT_CASE(SDL_CONTROLLERDEVICEADDED) PRINT_CONTROLLERDEV_EVENT(event); break; - SDL_EVENT_CASE(SDL_CONTROLLERDEVICEREMOVED) PRINT_CONTROLLERDEV_EVENT(event); break; - SDL_EVENT_CASE(SDL_CONTROLLERDEVICEREMAPPED) PRINT_CONTROLLERDEV_EVENT(event); break; - #undef PRINT_CONTROLLERDEV_EVENT +#define PRINT_CONTROLLERDEV_EVENT(event) SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d)", (uint)event->cdevice.timestamp, (int)event->cdevice.which) + SDL_EVENT_CASE(SDL_CONTROLLERDEVICEADDED) + PRINT_CONTROLLERDEV_EVENT(event); + break; + SDL_EVENT_CASE(SDL_CONTROLLERDEVICEREMOVED) + PRINT_CONTROLLERDEV_EVENT(event); + break; + SDL_EVENT_CASE(SDL_CONTROLLERDEVICEREMAPPED) + PRINT_CONTROLLERDEV_EVENT(event); + break; +#undef PRINT_CONTROLLERDEV_EVENT - #define PRINT_CTOUCHPAD_EVENT(event) \ - SDL_snprintf(details, sizeof (details), " (timestamp=%u which=%d touchpad=%d finger=%d x=%f y=%f pressure=%f)", \ - (uint) event->ctouchpad.timestamp, (int) event->ctouchpad.which, \ - (int) event->ctouchpad.touchpad, (int) event->ctouchpad.finger, \ - event->ctouchpad.x, event->ctouchpad.y, event->ctouchpad.pressure) - SDL_EVENT_CASE(SDL_CONTROLLERTOUCHPADDOWN) PRINT_CTOUCHPAD_EVENT(event); break; - SDL_EVENT_CASE(SDL_CONTROLLERTOUCHPADUP) PRINT_CTOUCHPAD_EVENT(event); break; - SDL_EVENT_CASE(SDL_CONTROLLERTOUCHPADMOTION) PRINT_CTOUCHPAD_EVENT(event); break; - #undef PRINT_CTOUCHPAD_EVENT +#define PRINT_CTOUCHPAD_EVENT(event) \ + SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d touchpad=%d finger=%d x=%f y=%f pressure=%f)", \ + (uint)event->ctouchpad.timestamp, (int)event->ctouchpad.which, \ + (int)event->ctouchpad.touchpad, (int)event->ctouchpad.finger, \ + event->ctouchpad.x, event->ctouchpad.y, event->ctouchpad.pressure) + SDL_EVENT_CASE(SDL_CONTROLLERTOUCHPADDOWN) + PRINT_CTOUCHPAD_EVENT(event); + break; + SDL_EVENT_CASE(SDL_CONTROLLERTOUCHPADUP) + PRINT_CTOUCHPAD_EVENT(event); + break; + SDL_EVENT_CASE(SDL_CONTROLLERTOUCHPADMOTION) + PRINT_CTOUCHPAD_EVENT(event); + break; +#undef PRINT_CTOUCHPAD_EVENT - SDL_EVENT_CASE(SDL_CONTROLLERSENSORUPDATE) - SDL_snprintf(details, sizeof (details), " (timestamp=%u which=%d sensor=%d data[0]=%f data[1]=%f data[2]=%f)", \ - (uint) event->csensor.timestamp, (int) event->csensor.which, (int) event->csensor.sensor, \ - event->csensor.data[0], event->csensor.data[1], event->csensor.data[2]); - break; + SDL_EVENT_CASE(SDL_CONTROLLERSENSORUPDATE) + SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d sensor=%d data[0]=%f data[1]=%f data[2]=%f)", + (uint)event->csensor.timestamp, (int)event->csensor.which, (int)event->csensor.sensor, + event->csensor.data[0], event->csensor.data[1], event->csensor.data[2]); + break; - #define PRINT_FINGER_EVENT(event) \ - SDL_snprintf(details, sizeof (details), " (timestamp=%u touchid=%"SDL_PRIs64" fingerid=%"SDL_PRIs64" x=%f y=%f dx=%f dy=%f pressure=%f)", \ - (uint) event->tfinger.timestamp, (long long)event->tfinger.touchId, \ - (long long)event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, \ - event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure) - SDL_EVENT_CASE(SDL_FINGERDOWN) PRINT_FINGER_EVENT(event); break; - SDL_EVENT_CASE(SDL_FINGERUP) PRINT_FINGER_EVENT(event); break; - SDL_EVENT_CASE(SDL_FINGERMOTION) PRINT_FINGER_EVENT(event); break; - #undef PRINT_FINGER_EVENT +#define PRINT_FINGER_EVENT(event) \ + SDL_snprintf(details, sizeof(details), " (timestamp=%u touchid=%" SDL_PRIs64 " fingerid=%" SDL_PRIs64 " x=%f y=%f dx=%f dy=%f pressure=%f)", \ + (uint)event->tfinger.timestamp, (long long)event->tfinger.touchId, \ + (long long)event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, \ + event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure) + SDL_EVENT_CASE(SDL_FINGERDOWN) + PRINT_FINGER_EVENT(event); + break; + SDL_EVENT_CASE(SDL_FINGERUP) + PRINT_FINGER_EVENT(event); + break; + SDL_EVENT_CASE(SDL_FINGERMOTION) + PRINT_FINGER_EVENT(event); + break; +#undef PRINT_FINGER_EVENT - #define PRINT_DOLLAR_EVENT(event) \ - SDL_snprintf(details, sizeof (details), " (timestamp=%u touchid=%"SDL_PRIs64" gestureid=%"SDL_PRIs64" numfingers=%u error=%f x=%f y=%f)", \ - (uint) event->dgesture.timestamp, (long long)event->dgesture.touchId, \ - (long long)event->dgesture.gestureId, (uint) event->dgesture.numFingers, \ - event->dgesture.error, event->dgesture.x, event->dgesture.y) - SDL_EVENT_CASE(SDL_DOLLARGESTURE) PRINT_DOLLAR_EVENT(event); break; - SDL_EVENT_CASE(SDL_DOLLARRECORD) PRINT_DOLLAR_EVENT(event); break; - #undef PRINT_DOLLAR_EVENT +#define PRINT_DOLLAR_EVENT(event) \ + SDL_snprintf(details, sizeof(details), " (timestamp=%u touchid=%" SDL_PRIs64 " gestureid=%" SDL_PRIs64 " numfingers=%u error=%f x=%f y=%f)", \ + (uint)event->dgesture.timestamp, (long long)event->dgesture.touchId, \ + (long long)event->dgesture.gestureId, (uint)event->dgesture.numFingers, \ + event->dgesture.error, event->dgesture.x, event->dgesture.y) + SDL_EVENT_CASE(SDL_DOLLARGESTURE) + PRINT_DOLLAR_EVENT(event); + break; + SDL_EVENT_CASE(SDL_DOLLARRECORD) + PRINT_DOLLAR_EVENT(event); + break; +#undef PRINT_DOLLAR_EVENT SDL_EVENT_CASE(SDL_MULTIGESTURE) - SDL_snprintf(details, sizeof (details), " (timestamp=%u touchid=%"SDL_PRIs64" dtheta=%f ddist=%f x=%f y=%f numfingers=%u)", - (uint) event->mgesture.timestamp, (long long)event->mgesture.touchId, - event->mgesture.dTheta, event->mgesture.dDist, - event->mgesture.x, event->mgesture.y, (uint) event->mgesture.numFingers); - break; + SDL_snprintf(details, sizeof(details), " (timestamp=%u touchid=%" SDL_PRIs64 " dtheta=%f ddist=%f x=%f y=%f numfingers=%u)", + (uint)event->mgesture.timestamp, (long long)event->mgesture.touchId, + event->mgesture.dTheta, event->mgesture.dDist, + event->mgesture.x, event->mgesture.y, (uint)event->mgesture.numFingers); + break; - #define PRINT_DROP_EVENT(event) SDL_snprintf(details, sizeof (details), " (file='%s' timestamp=%u windowid=%u)", event->drop.file, (uint) event->drop.timestamp, (uint) event->drop.windowID) - SDL_EVENT_CASE(SDL_DROPFILE) PRINT_DROP_EVENT(event); break; - SDL_EVENT_CASE(SDL_DROPTEXT) PRINT_DROP_EVENT(event); break; - SDL_EVENT_CASE(SDL_DROPBEGIN) PRINT_DROP_EVENT(event); break; - SDL_EVENT_CASE(SDL_DROPCOMPLETE) PRINT_DROP_EVENT(event); break; - #undef PRINT_DROP_EVENT +#define PRINT_DROP_EVENT(event) SDL_snprintf(details, sizeof(details), " (file='%s' timestamp=%u windowid=%u)", event->drop.file, (uint)event->drop.timestamp, (uint)event->drop.windowID) + SDL_EVENT_CASE(SDL_DROPFILE) + PRINT_DROP_EVENT(event); + break; + SDL_EVENT_CASE(SDL_DROPTEXT) + PRINT_DROP_EVENT(event); + break; + SDL_EVENT_CASE(SDL_DROPBEGIN) + PRINT_DROP_EVENT(event); + break; + SDL_EVENT_CASE(SDL_DROPCOMPLETE) + PRINT_DROP_EVENT(event); + break; +#undef PRINT_DROP_EVENT - #define PRINT_AUDIODEV_EVENT(event) SDL_snprintf(details, sizeof (details), " (timestamp=%u which=%u iscapture=%s)", (uint) event->adevice.timestamp, (uint) event->adevice.which, event->adevice.iscapture ? "true" : "false") - SDL_EVENT_CASE(SDL_AUDIODEVICEADDED) PRINT_AUDIODEV_EVENT(event); break; - SDL_EVENT_CASE(SDL_AUDIODEVICEREMOVED) PRINT_AUDIODEV_EVENT(event); break; - #undef PRINT_AUDIODEV_EVENT +#define PRINT_AUDIODEV_EVENT(event) SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%u iscapture=%s)", (uint)event->adevice.timestamp, (uint)event->adevice.which, event->adevice.iscapture ? "true" : "false") + SDL_EVENT_CASE(SDL_AUDIODEVICEADDED) + PRINT_AUDIODEV_EVENT(event); + break; + SDL_EVENT_CASE(SDL_AUDIODEVICEREMOVED) + PRINT_AUDIODEV_EVENT(event); + break; +#undef PRINT_AUDIODEV_EVENT SDL_EVENT_CASE(SDL_SENSORUPDATE) - SDL_snprintf(details, sizeof (details), " (timestamp=%u which=%d data[0]=%f data[1]=%f data[2]=%f data[3]=%f data[4]=%f data[5]=%f)", \ - (uint) event->sensor.timestamp, (int) event->sensor.which, \ - event->sensor.data[0], event->sensor.data[1], event->sensor.data[2], \ - event->sensor.data[3], event->sensor.data[4], event->sensor.data[5]); - break; + SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d data[0]=%f data[1]=%f data[2]=%f data[3]=%f data[4]=%f data[5]=%f)", + (uint)event->sensor.timestamp, (int)event->sensor.which, + event->sensor.data[0], event->sensor.data[1], event->sensor.data[2], + event->sensor.data[3], event->sensor.data[4], event->sensor.data[5]); + break; - #undef SDL_EVENT_CASE +#undef SDL_EVENT_CASE - case SDL_POLLSENTINEL: - /* No logging necessary for this one */ - break; + case SDL_POLLSENTINEL: + /* No logging necessary for this one */ + break; - default: - if (!name[0]) { - SDL_strlcpy(name, "UNKNOWN", sizeof (name)); - SDL_snprintf(details, sizeof (details), " #%u! (Bug? FIXME?)", (uint) event->type); - } - break; + default: + if (!name[0]) { + SDL_strlcpy(name, "UNKNOWN", sizeof(name)); + SDL_snprintf(details, sizeof(details), " #%u! (Bug? FIXME?)", (uint)event->type); + } + break; } if (name[0]) { SDL_Log("SDL EVENT: %s%s", name, details); } - #undef uint +#undef uint } - - /* Public functions */ -void -SDL_StopEventLoop(void) +void SDL_StopEventLoop(void) { const char *report = SDL_GetHint("SDL_EVENT_QUEUE_STATISTICS"); int i; @@ -482,22 +557,22 @@ SDL_StopEventLoop(void) } /* Clean out EventQ */ - for (entry = SDL_EventQ.head; entry; ) { + for (entry = SDL_EventQ.head; entry;) { SDL_EventEntry *next = entry->next; SDL_free(entry); entry = next; } - for (entry = SDL_EventQ.free; entry; ) { + for (entry = SDL_EventQ.free; entry;) { SDL_EventEntry *next = entry->next; SDL_free(entry); entry = next; } - for (wmmsg = SDL_EventQ.wmmsg_used; wmmsg; ) { + for (wmmsg = SDL_EventQ.wmmsg_used; wmmsg;) { SDL_SysWMEntry *next = wmmsg->next; SDL_free(wmmsg); wmmsg = next; } - for (wmmsg = SDL_EventQ.wmmsg_free; wmmsg; ) { + for (wmmsg = SDL_EventQ.wmmsg_free; wmmsg;) { SDL_SysWMEntry *next = wmmsg->next; SDL_free(wmmsg); wmmsg = next; @@ -537,8 +612,7 @@ SDL_StopEventLoop(void) } /* This function (and associated calls) may be called more than once */ -int -SDL_StartEventLoop(void) +int SDL_StartEventLoop(void) { /* We'll leave the event queue alone, since we might have gotten some important events at launch (like SDL_DROPFILE) @@ -581,10 +655,8 @@ SDL_StartEventLoop(void) return 0; } - /* Add an event to the event queue -- called with the queue locked */ -static int -SDL_AddEvent(SDL_Event * event) +static int SDL_AddEvent(SDL_Event *event) { SDL_EventEntry *entry; const int initial_count = SDL_AtomicGet(&SDL_EventQ.count); @@ -639,8 +711,7 @@ SDL_AddEvent(SDL_Event * event) } /* Remove an event from the queue -- called with the queue locked */ -static void -SDL_CutEvent(SDL_EventEntry *entry) +static void SDL_CutEvent(SDL_EventEntry *entry) { if (entry->prev) { entry->prev->next = entry->next; @@ -668,8 +739,7 @@ SDL_CutEvent(SDL_EventEntry *entry) SDL_AtomicAdd(&SDL_EventQ.count, -1); } -static int -SDL_SendWakeupEvent() +static int SDL_SendWakeupEvent() { SDL_VideoDevice *_this = SDL_GetVideoDevice(); if (_this == NULL || !_this->SendWakeupEvent) { @@ -690,9 +760,8 @@ SDL_SendWakeupEvent() } /* Lock the event queue, take a peep at it, and unlock it */ -static int -SDL_PeepEventsInternal(SDL_Event * events, int numevents, SDL_eventaction action, - Uint32 minType, Uint32 maxType, SDL_bool include_sentinel) +static int SDL_PeepEventsInternal(SDL_Event *events, int numevents, SDL_eventaction action, + Uint32 minType, Uint32 maxType, SDL_bool include_sentinel) { int i, used, sentinels_expected = 0; @@ -789,9 +858,8 @@ SDL_PeepEventsInternal(SDL_Event * events, int numevents, SDL_eventaction action return used; } -int -SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action, - Uint32 minType, Uint32 maxType) +int SDL_PeepEvents(SDL_Event *events, int numevents, SDL_eventaction action, + Uint32 minType, Uint32 maxType) { return SDL_PeepEventsInternal(events, numevents, action, minType, maxType, SDL_FALSE); } @@ -808,14 +876,12 @@ SDL_HasEvents(Uint32 minType, Uint32 maxType) return SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, minType, maxType) > 0; } -void -SDL_FlushEvent(Uint32 type) +void SDL_FlushEvent(Uint32 type) { SDL_FlushEvents(type, type); } -void -SDL_FlushEvents(Uint32 minType, Uint32 maxType) +void SDL_FlushEvents(Uint32 minType, Uint32 maxType) { SDL_EventEntry *entry, *next; Uint32 type; @@ -854,8 +920,7 @@ SDL_FlushEvents(Uint32 minType, Uint32 maxType) } /* Run the system dependent event loops */ -static void -SDL_PumpEventsInternal(SDL_bool push_sentinel) +static void SDL_PumpEventsInternal(SDL_bool push_sentinel) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); @@ -881,7 +946,7 @@ SDL_PumpEventsInternal(SDL_bool push_sentinel) } #endif - SDL_SendPendingSignalEvents(); /* in case we had a signal handler fire, etc. */ + SDL_SendPendingSignalEvents(); /* in case we had a signal handler fire, etc. */ if (push_sentinel && SDL_GetEventState(SDL_POLLSENTINEL) == SDL_ENABLE) { SDL_Event sentinel; @@ -892,22 +957,20 @@ SDL_PumpEventsInternal(SDL_bool push_sentinel) } } -void -SDL_PumpEvents() +void SDL_PumpEvents() { SDL_PumpEventsInternal(SDL_FALSE); } /* Public functions */ -int -SDL_PollEvent(SDL_Event * event) +int SDL_PollEvent(SDL_Event *event) { return SDL_WaitEventTimeout(event, 0); } -static SDL_bool -SDL_events_need_periodic_poll() { +static SDL_bool SDL_events_need_periodic_poll() +{ SDL_bool need_periodic_poll = SDL_FALSE; #if !SDL_JOYSTICK_DISABLED @@ -917,14 +980,13 @@ SDL_events_need_periodic_poll() { #if !SDL_SENSOR_DISABLED need_periodic_poll = need_periodic_poll || - (SDL_WasInit(SDL_INIT_SENSOR) && SDL_update_sensors); + (SDL_WasInit(SDL_INIT_SENSOR) && SDL_update_sensors); #endif return need_periodic_poll; } -static int -SDL_WaitEventTimeout_Device(_THIS, SDL_Window *wakeup_window, SDL_Event * event, Uint32 start, int timeout) +static int SDL_WaitEventTimeout_Device(_THIS, SDL_Window *wakeup_window, SDL_Event *event, Uint32 start, int timeout) { int loop_timeout = timeout; SDL_bool need_periodic_poll = SDL_events_need_periodic_poll(); @@ -995,8 +1057,8 @@ SDL_WaitEventTimeout_Device(_THIS, SDL_Window *wakeup_window, SDL_Event * event, return 0; } -static SDL_bool -SDL_events_need_polling() { +static SDL_bool SDL_events_need_polling() +{ SDL_bool need_polling = SDL_FALSE; #if !SDL_JOYSTICK_DISABLED @@ -1008,14 +1070,13 @@ SDL_events_need_polling() { #if !SDL_SENSOR_DISABLED need_polling = need_polling || - (SDL_WasInit(SDL_INIT_SENSOR) && SDL_update_sensors && (SDL_NumSensors() > 0)); + (SDL_WasInit(SDL_INIT_SENSOR) && SDL_update_sensors && (SDL_NumSensors() > 0)); #endif return need_polling; } -static SDL_Window * -SDL_find_active_window(SDL_VideoDevice * _this) +static SDL_Window *SDL_find_active_window(SDL_VideoDevice *_this) { SDL_Window *window; for (window = _this->windows; window; window = window->next) { @@ -1026,14 +1087,12 @@ SDL_find_active_window(SDL_VideoDevice * _this) return NULL; } -int -SDL_WaitEvent(SDL_Event * event) +int SDL_WaitEvent(SDL_Event *event) { return SDL_WaitEventTimeout(event, -1); } -int -SDL_WaitEventTimeout(SDL_Event * event, int timeout) +int SDL_WaitEventTimeout(SDL_Event *event, int timeout) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); SDL_Window *wakeup_window; @@ -1122,8 +1181,7 @@ SDL_WaitEventTimeout(SDL_Event * event, int timeout) } } -int -SDL_PushEvent(SDL_Event * event) +int SDL_PushEvent(SDL_Event *event) { event->common.timestamp = SDL_GetTicks(); @@ -1149,11 +1207,11 @@ SDL_PushEvent(SDL_Event * event) SDL_event_watchers_dispatching = SDL_FALSE; if (SDL_event_watchers_removed) { - for (i = SDL_event_watchers_count; i--; ) { + for (i = SDL_event_watchers_count; i--;) { if (SDL_event_watchers[i].removed) { --SDL_event_watchers_count; if (i < SDL_event_watchers_count) { - SDL_memmove(&SDL_event_watchers[i], &SDL_event_watchers[i+1], (SDL_event_watchers_count - i) * sizeof(SDL_event_watchers[i])); + SDL_memmove(&SDL_event_watchers[i], &SDL_event_watchers[i + 1], (SDL_event_watchers_count - i) * sizeof(SDL_event_watchers[i])); } } } @@ -1176,8 +1234,7 @@ SDL_PushEvent(SDL_Event * event) return 1; } -void -SDL_SetEventFilter(SDL_EventFilter filter, void *userdata) +void SDL_SetEventFilter(SDL_EventFilter filter, void *userdata) { if (SDL_event_watchers_lock == NULL || SDL_LockMutex(SDL_event_watchers_lock) == 0) { /* Set filter and discard pending events */ @@ -1192,7 +1249,7 @@ SDL_SetEventFilter(SDL_EventFilter filter, void *userdata) } SDL_bool -SDL_GetEventFilter(SDL_EventFilter * filter, void **userdata) +SDL_GetEventFilter(SDL_EventFilter *filter, void **userdata) { SDL_EventWatcher event_ok; @@ -1215,8 +1272,7 @@ SDL_GetEventFilter(SDL_EventFilter * filter, void **userdata) return event_ok.callback ? SDL_TRUE : SDL_FALSE; } -void -SDL_AddEventWatch(SDL_EventFilter filter, void *userdata) +void SDL_AddEventWatch(SDL_EventFilter filter, void *userdata) { if (SDL_event_watchers_lock == NULL || SDL_LockMutex(SDL_event_watchers_lock) == 0) { SDL_EventWatcher *event_watchers; @@ -1239,8 +1295,7 @@ SDL_AddEventWatch(SDL_EventFilter filter, void *userdata) } } -void -SDL_DelEventWatch(SDL_EventFilter filter, void *userdata) +void SDL_DelEventWatch(SDL_EventFilter filter, void *userdata) { if (SDL_event_watchers_lock == NULL || SDL_LockMutex(SDL_event_watchers_lock) == 0) { int i; @@ -1253,7 +1308,7 @@ SDL_DelEventWatch(SDL_EventFilter filter, void *userdata) } else { --SDL_event_watchers_count; if (i < SDL_event_watchers_count) { - SDL_memmove(&SDL_event_watchers[i], &SDL_event_watchers[i+1], (SDL_event_watchers_count - i) * sizeof(SDL_event_watchers[i])); + SDL_memmove(&SDL_event_watchers[i], &SDL_event_watchers[i + 1], (SDL_event_watchers_count - i) * sizeof(SDL_event_watchers[i])); } } break; @@ -1266,8 +1321,7 @@ SDL_DelEventWatch(SDL_EventFilter filter, void *userdata) } } -void -SDL_FilterEvents(SDL_EventFilter filter, void *userdata) +void SDL_FilterEvents(SDL_EventFilter filter, void *userdata) { if (!SDL_EventQ.lock || SDL_LockMutex(SDL_EventQ.lock) == 0) { SDL_EventEntry *entry, *next; @@ -1283,8 +1337,7 @@ SDL_FilterEvents(SDL_EventFilter filter, void *userdata) } } -Uint8 -SDL_EventState(Uint32 type, int state) +Uint8 SDL_EventState(Uint32 type, int state) { const SDL_bool isde = (state == SDL_DISABLE) || (state == SDL_ENABLE); Uint8 current_state; @@ -1292,7 +1345,7 @@ SDL_EventState(Uint32 type, int state) Uint8 lo = (type & 0xff); if (SDL_disabled_events[hi] && - (SDL_disabled_events[hi]->bits[lo/32] & (1 << (lo&31)))) { + (SDL_disabled_events[hi]->bits[lo / 32] & (1 << (lo & 31)))) { current_state = SDL_DISABLE; } else { current_state = SDL_ENABLE; @@ -1302,15 +1355,15 @@ SDL_EventState(Uint32 type, int state) if (state == SDL_DISABLE) { /* Disable this event type and discard pending events */ if (!SDL_disabled_events[hi]) { - SDL_disabled_events[hi] = (SDL_DisabledEventBlock*) SDL_calloc(1, sizeof(SDL_DisabledEventBlock)); + SDL_disabled_events[hi] = (SDL_DisabledEventBlock *)SDL_calloc(1, sizeof(SDL_DisabledEventBlock)); } /* Out of memory, nothing we can do... */ if (SDL_disabled_events[hi]) { - SDL_disabled_events[hi]->bits[lo/32] |= (1 << (lo&31)); + SDL_disabled_events[hi]->bits[lo / 32] |= (1 << (lo & 31)); SDL_FlushEvent(type); } } else { // state == SDL_ENABLE - SDL_disabled_events[hi]->bits[lo/32] &= ~(1 << (lo&31)); + SDL_disabled_events[hi]->bits[lo / 32] &= ~(1 << (lo & 31)); } #if !SDL_JOYSTICK_DISABLED @@ -1335,7 +1388,7 @@ SDL_RegisterEvents(int numevents) { Uint32 event_base; - if ((numevents > 0) && (SDL_userevents+numevents <= SDL_LASTEVENT)) { + if ((numevents > 0) && (SDL_userevents + numevents <= SDL_LASTEVENT)) { event_base = SDL_userevents; SDL_userevents += numevents; } else { @@ -1344,8 +1397,7 @@ SDL_RegisterEvents(int numevents) return event_base; } -int -SDL_SendAppEvent(SDL_EventType eventType) +int SDL_SendAppEvent(SDL_EventType eventType) { int posted; @@ -1358,8 +1410,7 @@ SDL_SendAppEvent(SDL_EventType eventType) return posted; } -int -SDL_SendSysWMEvent(SDL_SysWMmsg * message) +int SDL_SendSysWMEvent(SDL_SysWMmsg *message) { int posted; @@ -1375,20 +1426,17 @@ SDL_SendSysWMEvent(SDL_SysWMmsg * message) return posted; } -int -SDL_SendKeymapChangedEvent(void) +int SDL_SendKeymapChangedEvent(void) { return SDL_SendAppEvent(SDL_KEYMAPCHANGED); } -int -SDL_SendLocaleChangedEvent(void) +int SDL_SendLocaleChangedEvent(void) { return SDL_SendAppEvent(SDL_LOCALECHANGED); } -int -SDL_EventsInit(void) +int SDL_EventsInit(void) { #if !SDL_JOYSTICK_DISABLED SDL_AddHintCallback(SDL_HINT_AUTO_UPDATE_JOYSTICKS, SDL_AutoUpdateJoysticksChanged, NULL); @@ -1408,8 +1456,7 @@ SDL_EventsInit(void) return 0; } -void -SDL_EventsQuit(void) +void SDL_EventsQuit(void) { SDL_QuitQuit(); SDL_StopEventLoop(); diff --git a/src/events/SDL_events_c.h b/src/events/SDL_events_c.h index ba52b1155..24c8c5fc9 100644 --- a/src/events/SDL_events_c.h +++ b/src/events/SDL_events_c.h @@ -44,7 +44,7 @@ extern void SDL_StopEventLoop(void); extern void SDL_QuitInterrupt(void); extern int SDL_SendAppEvent(SDL_EventType eventType); -extern int SDL_SendSysWMEvent(SDL_SysWMmsg * message); +extern int SDL_SendSysWMEvent(SDL_SysWMmsg *message); extern int SDL_SendKeymapChangedEvent(void); extern int SDL_SendLocaleChangedEvent(void); diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c index 2433a5b35..57665621f 100644 --- a/src/events/SDL_gesture.c +++ b/src/events/SDL_gesture.c @@ -41,27 +41,31 @@ #define DOLLARNPOINTS 64 #if defined(ENABLE_DOLLAR) -# define DOLLARSIZE 256 -# define PHI 0.618033989 +#define DOLLARSIZE 256 +#define PHI 0.618033989 #endif -typedef struct { - float x,y; +typedef struct +{ + float x, y; } SDL_FloatPoint; -typedef struct { +typedef struct +{ float length; int numPoints; SDL_FloatPoint p[MAXPATHSIZE]; } SDL_DollarPath; -typedef struct { +typedef struct +{ SDL_FloatPoint path[DOLLARNPOINTS]; unsigned long hash; } SDL_DollarTemplate; -typedef struct { +typedef struct +{ SDL_TouchID id; SDL_FloatPoint centroid; SDL_DollarPath dollarPath; @@ -112,18 +116,17 @@ void SDL_GestureQuit() SDL_gestureTouch = NULL; } -static unsigned long SDL_HashDollar(SDL_FloatPoint* points) +static unsigned long SDL_HashDollar(SDL_FloatPoint *points) { unsigned long hash = 5381; int i; for (i = 0; i < DOLLARNPOINTS; i++) { - hash = ((hash<<5) + hash) + (unsigned long)points[i].x; - hash = ((hash<<5) + hash) + (unsigned long)points[i].y; + hash = ((hash << 5) + hash) + (unsigned long)points[i].x; + hash = ((hash << 5) + hash) + (unsigned long)points[i].y; } return hash; } - static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst) { if (dst == NULL) { @@ -135,7 +138,7 @@ static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst) #if SDL_BYTEORDER == SDL_LIL_ENDIAN if (SDL_RWwrite(dst, templ->path, - sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS) { + sizeof(templ->path[0]), DOLLARNPOINTS) != DOLLARNPOINTS) { return 0; } #else @@ -149,7 +152,7 @@ static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst) } if (SDL_RWwrite(dst, copy.path, - sizeof(copy.path[0]),DOLLARNPOINTS) != DOLLARNPOINTS) { + sizeof(copy.path[0]), DOLLARNPOINTS) != DOLLARNPOINTS) { return 0; } } @@ -158,12 +161,11 @@ static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst) return 1; } - int SDL_SaveAllDollarTemplates(SDL_RWops *dst) { - int i,j,rtrn = 0; + int i, j, rtrn = 0; for (i = 0; i < SDL_numGestureTouches; i++) { - SDL_GestureTouch* touch = &SDL_gestureTouch[i]; + SDL_GestureTouch *touch = &SDL_gestureTouch[i]; for (j = 0; j < touch->numDollarTemplates; j++) { rtrn += SaveTemplate(&touch->dollarTemplate[j], dst); } @@ -173,9 +175,9 @@ int SDL_SaveAllDollarTemplates(SDL_RWops *dst) int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *dst) { - int i,j; + int i, j; for (i = 0; i < SDL_numGestureTouches; i++) { - SDL_GestureTouch* touch = &SDL_gestureTouch[i]; + SDL_GestureTouch *touch = &SDL_gestureTouch[i]; for (j = 0; j < touch->numDollarTemplates; j++) { if (touch->dollarTemplate[j].hash == gestureId) { return SaveTemplate(&touch->dollarTemplate[j], dst); @@ -187,9 +189,9 @@ int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *dst) /* path is an already sampled set of points Returns the index of the gesture on success, or -1 */ -static int SDL_AddDollarGesture_one(SDL_GestureTouch* inTouch, SDL_FloatPoint* path) +static int SDL_AddDollarGesture_one(SDL_GestureTouch *inTouch, SDL_FloatPoint *path) { - SDL_DollarTemplate* dollarTemplate; + SDL_DollarTemplate *dollarTemplate; SDL_DollarTemplate *templ; int index; @@ -197,21 +199,21 @@ static int SDL_AddDollarGesture_one(SDL_GestureTouch* inTouch, SDL_FloatPoint* p dollarTemplate = (SDL_DollarTemplate *)SDL_realloc(inTouch->dollarTemplate, (index + 1) * - sizeof(SDL_DollarTemplate)); + sizeof(SDL_DollarTemplate)); if (dollarTemplate == NULL) { return SDL_OutOfMemory(); } inTouch->dollarTemplate = dollarTemplate; templ = &inTouch->dollarTemplate[index]; - SDL_memcpy(templ->path, path, DOLLARNPOINTS*sizeof(SDL_FloatPoint)); + SDL_memcpy(templ->path, path, DOLLARNPOINTS * sizeof(SDL_FloatPoint)); templ->hash = SDL_HashDollar(templ->path); inTouch->numDollarTemplates++; return index; } -static int SDL_AddDollarGesture(SDL_GestureTouch* inTouch, SDL_FloatPoint* path) +static int SDL_AddDollarGesture(SDL_GestureTouch *inTouch, SDL_FloatPoint *path) { int index = -1; int i = 0; @@ -234,7 +236,7 @@ static int SDL_AddDollarGesture(SDL_GestureTouch* inTouch, SDL_FloatPoint* path) int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) { - int i,loaded = 0; + int i, loaded = 0; SDL_GestureTouch *touch = NULL; if (src == NULL) { return 0; @@ -253,7 +255,7 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) while (1) { SDL_DollarTemplate templ; - if (SDL_RWread(src,templ.path,sizeof(templ.path[0]),DOLLARNPOINTS) < DOLLARNPOINTS) { + if (SDL_RWread(src, templ.path, sizeof(templ.path[0]), DOLLARNPOINTS) < DOLLARNPOINTS) { if (loaded == 0) { return SDL_SetError("could not read any dollar gesture from rwops"); } @@ -279,7 +281,7 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) touch = &SDL_gestureTouch[i]; /* printf("Adding loaded gesture to + touches\n"); */ /* TODO: What if this fails? */ - SDL_AddDollarGesture(touch,templ.path); + SDL_AddDollarGesture(touch, templ.path); } loaded++; } @@ -288,9 +290,8 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) return loaded; } - #if defined(ENABLE_DOLLAR) -static float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float ang) +static float dollarDifference(SDL_FloatPoint *points, SDL_FloatPoint *templ, float ang) { /* SDL_FloatPoint p[DOLLARNPOINTS]; */ float dist = 0; @@ -299,14 +300,13 @@ static float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float for (i = 0; i < DOLLARNPOINTS; i++) { p.x = (float)(points[i].x * SDL_cos(ang) - points[i].y * SDL_sin(ang)); p.y = (float)(points[i].x * SDL_sin(ang) + points[i].y * SDL_cos(ang)); - dist += (float)(SDL_sqrt((p.x-templ[i].x)*(p.x-templ[i].x)+ - (p.y-templ[i].y)*(p.y-templ[i].y))); + dist += (float)(SDL_sqrt((p.x - templ[i].x) * (p.x - templ[i].x) + + (p.y - templ[i].y) * (p.y - templ[i].y))); } return dist / DOLLARNPOINTS; - } -static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) +static float bestDollarDifference(SDL_FloatPoint *points, SDL_FloatPoint *templ) { /*------------BEGIN DOLLAR BLACKBOX------------------ -TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT- @@ -324,14 +324,14 @@ static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) tb = x2; x2 = x1; f2 = f1; - x1 = (float)(PHI*ta + (1-PHI)*tb); - f1 = dollarDifference(points,templ,x1); + x1 = (float)(PHI * ta + (1 - PHI) * tb); + f1 = dollarDifference(points, templ, x1); } else { ta = x1; x1 = x2; f1 = f2; - x2 = (float)((1-PHI)*ta + PHI*tb); - f2 = dollarDifference(points,templ,x2); + x2 = (float)((1 - PHI) * ta + PHI * tb); + f2 = dollarDifference(points, templ, x2); } } /* @@ -344,43 +344,44 @@ static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) } /* DollarPath contains raw points, plus (possibly) the calculated length */ -static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points, SDL_bool is_recording) +static int dollarNormalize(const SDL_DollarPath *path, SDL_FloatPoint *points, SDL_bool is_recording) { int i; float interval; float dist; int numPoints = 0; SDL_FloatPoint centroid; - float xmin,xmax,ymin,ymax; + float xmin, xmax, ymin, ymax; float ang; - float w,h; + float w, h; float length = path->length; /* Calculate length if it hasn't already been done */ if (length <= 0) { - for (i=1;i < path->numPoints; i++) { - float dx = path->p[i ].x - path->p[i-1].x; - float dy = path->p[i ].y - path->p[i-1].y; - length += (float)(SDL_sqrt(dx*dx+dy*dy)); + for (i = 1; i < path->numPoints; i++) { + float dx = path->p[i].x - path->p[i - 1].x; + float dy = path->p[i].y - path->p[i - 1].y; + length += (float)(SDL_sqrt(dx * dx + dy * dy)); } } /* Resample */ - interval = length/(DOLLARNPOINTS - 1); + interval = length / (DOLLARNPOINTS - 1); dist = interval; - centroid.x = 0;centroid.y = 0; + centroid.x = 0; + centroid.y = 0; /* printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y); */ for (i = 1; i < path->numPoints; i++) { - float d = (float)(SDL_sqrt((path->p[i-1].x-path->p[i].x)*(path->p[i-1].x-path->p[i].x)+ - (path->p[i-1].y-path->p[i].y)*(path->p[i-1].y-path->p[i].y))); + float d = (float)(SDL_sqrt((path->p[i - 1].x - path->p[i].x) * (path->p[i - 1].x - path->p[i].x) + + (path->p[i - 1].y - path->p[i].y) * (path->p[i - 1].y - path->p[i].y))); /* printf("d = %f dist = %f/%f\n",d,dist,interval); */ while (dist + d > interval) { - points[numPoints].x = path->p[i-1].x + - ((interval-dist)/d)*(path->p[i].x-path->p[i-1].x); - points[numPoints].y = path->p[i-1].y + - ((interval-dist)/d)*(path->p[i].y-path->p[i-1].y); + points[numPoints].x = path->p[i - 1].x + + ((interval - dist) / d) * (path->p[i].x - path->p[i - 1].x); + points[numPoints].y = path->p[i - 1].y + + ((interval - dist) / d) * (path->p[i].y - path->p[i - 1].y); centroid.x += points[numPoints].x; centroid.y += points[numPoints].y; numPoints++; @@ -389,14 +390,14 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points, SD } dist += d; } - if (numPoints < DOLLARNPOINTS-1) { + if (numPoints < DOLLARNPOINTS - 1) { if (is_recording) { SDL_SetError("ERROR: NumPoints = %i", numPoints); } return 0; } /* copy the last point */ - points[DOLLARNPOINTS-1] = path->p[path->numPoints-1]; + points[DOLLARNPOINTS - 1] = path->p[path->numPoints - 1]; numPoints = DOLLARNPOINTS; centroid.x /= numPoints; @@ -412,14 +413,13 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points, SD ang = (float)(SDL_atan2(centroid.y - points[0].y, centroid.x - points[0].x)); - for (i = 0; inumDollarTemplates; i++) { - float diff = bestDollarDifference(points,touch->dollarTemplate[i].path); - if (diff < bestDiff) {bestDiff = diff; *bestTempl = i;} + float diff = bestDollarDifference(points, touch->dollarTemplate[i].path); + if (diff < bestDiff) { + bestDiff = diff; + *bestTempl = i; + } } return bestDiff; } @@ -470,7 +473,7 @@ int SDL_GestureAddTouch(SDL_TouchID touchId) { SDL_GestureTouch *gestureTouch = (SDL_GestureTouch *)SDL_realloc(SDL_gestureTouch, (SDL_numGestureTouches + 1) * - sizeof(SDL_GestureTouch)); + sizeof(SDL_GestureTouch)); if (gestureTouch == NULL) { return SDL_OutOfMemory(); @@ -508,7 +511,7 @@ int SDL_GestureDelTouch(SDL_TouchID touchId) return 0; } -static SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id) +static SDL_GestureTouch *SDL_GetGestureTouch(SDL_TouchID id) { int i; for (i = 0; i < SDL_numGestureTouches; i++) { @@ -520,7 +523,7 @@ static SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id) return NULL; } -static void SDL_SendGestureMulti(SDL_GestureTouch* touch,float dTheta,float dDist) +static void SDL_SendGestureMulti(SDL_GestureTouch *touch, float dTheta, float dDist) { if (SDL_GetEventState(SDL_MULTIGESTURE) == SDL_ENABLE) { SDL_Event event; @@ -536,8 +539,8 @@ static void SDL_SendGestureMulti(SDL_GestureTouch* touch,float dTheta,float dDis } #if defined(ENABLE_DOLLAR) -static void SDL_SendGestureDollar(SDL_GestureTouch* touch, - SDL_GestureID gestureId,float error) +static void SDL_SendGestureDollar(SDL_GestureTouch *touch, + SDL_GestureID gestureId, float error) { if (SDL_GetEventState(SDL_DOLLARGESTURE) == SDL_ENABLE) { SDL_Event event; @@ -553,7 +556,7 @@ static void SDL_SendGestureDollar(SDL_GestureTouch* touch, } } -static void SDL_SendDollarRecord(SDL_GestureTouch* touch,SDL_GestureID gestureId) +static void SDL_SendDollarRecord(SDL_GestureTouch *touch, SDL_GestureID gestureId) { if (SDL_GetEventState(SDL_DOLLARRECORD) == SDL_ENABLE) { SDL_Event event; @@ -565,10 +568,9 @@ static void SDL_SendDollarRecord(SDL_GestureTouch* touch,SDL_GestureID gestureId } #endif - -void SDL_GestureProcessEvent(SDL_Event* event) +void SDL_GestureProcessEvent(SDL_Event *event) { - float x,y; + float x, y; #if defined(ENABLE_DOLLAR) int index; int i; @@ -584,7 +586,7 @@ void SDL_GestureProcessEvent(SDL_Event* event) if (event->type == SDL_FINGERMOTION || event->type == SDL_FINGERDOWN || event->type == SDL_FINGERUP) { - SDL_GestureTouch* inTouch = SDL_GetGestureTouch(event->tfinger.touchId); + SDL_GestureTouch *inTouch = SDL_GetGestureTouch(event->tfinger.touchId); /* Shouldn't be possible */ if (inTouch == NULL) { @@ -608,52 +610,54 @@ void SDL_GestureProcessEvent(SDL_Event* event) dollarNormalize(&inTouch->dollarPath, path, SDL_TRUE); /* PrintPath(path); */ if (recordAll) { - index = SDL_AddDollarGesture(NULL,path); + index = SDL_AddDollarGesture(NULL, path); for (i = 0; i < SDL_numGestureTouches; i++) { SDL_gestureTouch[i].recording = SDL_FALSE; } } else { - index = SDL_AddDollarGesture(inTouch,path); + index = SDL_AddDollarGesture(inTouch, path); } if (index >= 0) { - SDL_SendDollarRecord(inTouch,inTouch->dollarTemplate[index].hash); + SDL_SendDollarRecord(inTouch, inTouch->dollarTemplate[index].hash); } else { - SDL_SendDollarRecord(inTouch,-1); + SDL_SendDollarRecord(inTouch, -1); } } else { int bestTempl; float error; error = dollarRecognize(&inTouch->dollarPath, - &bestTempl,inTouch); + &bestTempl, inTouch); if (bestTempl >= 0) { /* Send Event */ unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash; - SDL_SendGestureDollar(inTouch,gestureId,error); + SDL_SendGestureDollar(inTouch, gestureId, error); /* printf ("%s\n",);("Dollar error: %f\n",error); */ } } #endif /* inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers]; */ if (inTouch->numDownFingers > 0) { - inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers+1)- - x)/inTouch->numDownFingers; - inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers+1)- - y)/inTouch->numDownFingers; + inTouch->centroid.x = (inTouch->centroid.x * (inTouch->numDownFingers + 1) - + x) / + inTouch->numDownFingers; + inTouch->centroid.y = (inTouch->centroid.y * (inTouch->numDownFingers + 1) - + y) / + inTouch->numDownFingers; } } else if (event->type == SDL_FINGERMOTION) { float dx = event->tfinger.dx; float dy = event->tfinger.dy; #if defined(ENABLE_DOLLAR) - SDL_DollarPath* path = &inTouch->dollarPath; + SDL_DollarPath *path = &inTouch->dollarPath; if (path->numPoints < MAXPATHSIZE) { path->p[path->numPoints].x = inTouch->centroid.x; path->p[path->numPoints].y = inTouch->centroid.y; pathDx = - (path->p[path->numPoints].x-path->p[path->numPoints-1].x); + (path->p[path->numPoints].x - path->p[path->numPoints - 1].x); pathDy = - (path->p[path->numPoints].y-path->p[path->numPoints-1].y); - path->length += (float)SDL_sqrt(pathDx*pathDx + pathDy*pathDy); + (path->p[path->numPoints].y - path->p[path->numPoints - 1].y); + path->length += (float)SDL_sqrt(pathDx * pathDx + pathDy * pathDy); path->numPoints++; } #endif @@ -661,29 +665,29 @@ void SDL_GestureProcessEvent(SDL_Event* event) lastP.y = y - dy; lastCentroid = inTouch->centroid; - inTouch->centroid.x += dx/inTouch->numDownFingers; - inTouch->centroid.y += dy/inTouch->numDownFingers; + inTouch->centroid.x += dx / inTouch->numDownFingers; + inTouch->centroid.y += dy / inTouch->numDownFingers; /* printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y); */ if (inTouch->numDownFingers > 1) { SDL_FloatPoint lv; /* Vector from centroid to last x,y position */ - SDL_FloatPoint v; /* Vector from centroid to current x,y position */ + SDL_FloatPoint v; /* Vector from centroid to current x,y position */ /* lv = inTouch->gestureLast[j].cv; */ lv.x = lastP.x - lastCentroid.x; lv.y = lastP.y - lastCentroid.y; - lDist = (float)SDL_sqrt(lv.x*lv.x + lv.y*lv.y); + lDist = (float)SDL_sqrt(lv.x * lv.x + lv.y * lv.y); /* printf("lDist = %f\n",lDist); */ v.x = x - inTouch->centroid.x; v.y = y - inTouch->centroid.y; /* inTouch->gestureLast[j].cv = v; */ - Dist = (float)SDL_sqrt(v.x*v.x+v.y*v.y); + Dist = (float)SDL_sqrt(v.x * v.x + v.y * v.y); /* SDL_cos(dTheta) = (v . lv)/(|v| * |lv|) */ /* Normalize Vectors to simplify angle calculation */ - lv.x/=lDist; - lv.y/=lDist; - v.x/=Dist; - v.y/=Dist; - dtheta = (float)SDL_atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y); + lv.x /= lDist; + lv.y /= lDist; + v.x /= Dist; + v.y /= Dist; + dtheta = (float)SDL_atan2(lv.x * v.y - lv.y * v.x, lv.x * v.x + lv.y * v.y); dDist = (Dist - lDist); if (lDist == 0) { @@ -692,7 +696,6 @@ void SDL_GestureProcessEvent(SDL_Event* event) dtheta = 0; } - /* inTouch->gestureLast[j].dDist = dDist; inTouch->gestureLast[j].dtheta = dtheta; @@ -703,7 +706,7 @@ void SDL_GestureProcessEvent(SDL_Event* event) knob.ang += dtheta; printf("thetaSum = %f, distSum = %f\n",gdtheta,gdDist); printf("id: %i dTheta = %f, dDist = %f\n",j,dtheta,dDist); */ - SDL_SendGestureMulti(inTouch,dtheta,dDist); + SDL_SendGestureMulti(inTouch, dtheta, dDist); } else { /* inTouch->gestureLast[j].dDist = 0; inTouch->gestureLast[j].dtheta = 0; @@ -717,10 +720,12 @@ void SDL_GestureProcessEvent(SDL_Event* event) } else if (event->type == SDL_FINGERDOWN) { inTouch->numDownFingers++; - inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers - 1)+ - x)/inTouch->numDownFingers; - inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers - 1)+ - y)/inTouch->numDownFingers; + inTouch->centroid.x = (inTouch->centroid.x * (inTouch->numDownFingers - 1) + + x) / + inTouch->numDownFingers; + inTouch->centroid.y = (inTouch->centroid.y * (inTouch->numDownFingers - 1) + + y) / + inTouch->numDownFingers; /* printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y, inTouch->centroid.x,inTouch->centroid.y); */ diff --git a/src/events/SDL_gesture_c.h b/src/events/SDL_gesture_c.h index 84855aa88..8e8f0cee2 100644 --- a/src/events/SDL_gesture_c.h +++ b/src/events/SDL_gesture_c.h @@ -26,7 +26,7 @@ extern int SDL_GestureAddTouch(SDL_TouchID touchId); extern int SDL_GestureDelTouch(SDL_TouchID touchId); -extern void SDL_GestureProcessEvent(SDL_Event* event); +extern void SDL_GestureProcessEvent(SDL_Event *event); extern void SDL_GestureQuit(void); diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index bcfe581a5..94b9be538 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -29,13 +29,12 @@ #include "../video/SDL_sysvideo.h" #include "scancodes_ascii.h" - /* #define DEBUG_KEYBOARD */ /* Global keyboard information */ -#define KEYBOARD_HARDWARE 0x01 -#define KEYBOARD_AUTORELEASE 0x02 +#define KEYBOARD_HARDWARE 0x01 +#define KEYBOARD_AUTORELEASE 0x02 typedef struct SDL_Keyboard SDL_Keyboard; @@ -644,40 +643,38 @@ static const char *SDL_scancode_names[SDL_NUM_SCANCODES] = { char * SDL_UCS4ToUTF8(Uint32 ch, char *dst) { - Uint8 *p = (Uint8 *) dst; + Uint8 *p = (Uint8 *)dst; if (ch <= 0x7F) { - *p = (Uint8) ch; + *p = (Uint8)ch; ++dst; } else if (ch <= 0x7FF) { - p[0] = 0xC0 | (Uint8) ((ch >> 6) & 0x1F); - p[1] = 0x80 | (Uint8) (ch & 0x3F); + p[0] = 0xC0 | (Uint8)((ch >> 6) & 0x1F); + p[1] = 0x80 | (Uint8)(ch & 0x3F); dst += 2; } else if (ch <= 0xFFFF) { - p[0] = 0xE0 | (Uint8) ((ch >> 12) & 0x0F); - p[1] = 0x80 | (Uint8) ((ch >> 6) & 0x3F); - p[2] = 0x80 | (Uint8) (ch & 0x3F); + p[0] = 0xE0 | (Uint8)((ch >> 12) & 0x0F); + p[1] = 0x80 | (Uint8)((ch >> 6) & 0x3F); + p[2] = 0x80 | (Uint8)(ch & 0x3F); dst += 3; } else { - p[0] = 0xF0 | (Uint8) ((ch >> 18) & 0x07); - p[1] = 0x80 | (Uint8) ((ch >> 12) & 0x3F); - p[2] = 0x80 | (Uint8) ((ch >> 6) & 0x3F); - p[3] = 0x80 | (Uint8) (ch & 0x3F); + p[0] = 0xF0 | (Uint8)((ch >> 18) & 0x07); + p[1] = 0x80 | (Uint8)((ch >> 12) & 0x3F); + p[2] = 0x80 | (Uint8)((ch >> 6) & 0x3F); + p[3] = 0x80 | (Uint8)(ch & 0x3F); dst += 4; } return dst; } /* Public functions */ -int -SDL_KeyboardInit(void) +int SDL_KeyboardInit(void) { /* Set the default keymap */ SDL_SetKeymap(0, SDL_default_keymap, SDL_NUM_SCANCODES, SDL_FALSE); return 0; } -void -SDL_ResetKeyboard(void) +void SDL_ResetKeyboard(void) { SDL_Keyboard *keyboard = &SDL_keyboard; SDL_Scancode scancode; @@ -685,21 +682,19 @@ SDL_ResetKeyboard(void) #ifdef DEBUG_KEYBOARD printf("Resetting keyboard\n"); #endif - for (scancode = (SDL_Scancode) 0; scancode < SDL_NUM_SCANCODES; ++scancode) { + for (scancode = (SDL_Scancode)0; scancode < SDL_NUM_SCANCODES; ++scancode) { if (keyboard->keystate[scancode] == SDL_PRESSED) { SDL_SendKeyboardKey(SDL_RELEASED, scancode); } } } -void -SDL_GetDefaultKeymap(SDL_Keycode * keymap) +void SDL_GetDefaultKeymap(SDL_Keycode *keymap) { SDL_memcpy(keymap, SDL_default_keymap, sizeof(SDL_default_keymap)); } -void -SDL_SetKeymap(int start, const SDL_Keycode * keys, int length, SDL_bool send_event) +void SDL_SetKeymap(int start, const SDL_Keycode *keys, int length, SDL_bool send_event) { SDL_Keyboard *keyboard = &SDL_keyboard; SDL_Scancode scancode; @@ -732,8 +727,7 @@ SDL_SetKeymap(int start, const SDL_Keycode * keys, int length, SDL_bool send_eve } } -void -SDL_SetScancodeName(SDL_Scancode scancode, const char *name) +void SDL_SetScancodeName(SDL_Scancode scancode, const char *name) { if (scancode >= SDL_NUM_SCANCODES) { return; @@ -749,8 +743,7 @@ SDL_GetKeyboardFocus(void) return keyboard->focus; } -void -SDL_SetKeyboardFocus(SDL_Window * window) +void SDL_SetKeyboardFocus(SDL_Window *window) { SDL_Keyboard *keyboard = &SDL_keyboard; @@ -767,7 +760,7 @@ SDL_SetKeyboardFocus(SDL_Window * window) /* old window must lose an existing mouse capture. */ if (keyboard->focus->flags & SDL_WINDOW_MOUSE_CAPTURE) { - SDL_CaptureMouse(SDL_FALSE); /* drop the capture. */ + SDL_CaptureMouse(SDL_FALSE); /* drop the capture. */ SDL_UpdateMouseCapture(SDL_TRUE); SDL_assert(!(keyboard->focus->flags & SDL_WINDOW_MOUSE_CAPTURE)); } @@ -799,8 +792,7 @@ SDL_SetKeyboardFocus(SDL_Window * window) } } -static int -SDL_SendKeyboardKeyInternal(Uint8 source, Uint8 state, SDL_Scancode scancode, SDL_Keycode keycode) +static int SDL_SendKeyboardKeyInternal(Uint8 source, Uint8 state, SDL_Scancode scancode, SDL_Keycode keycode) { SDL_Keyboard *keyboard = &SDL_keyboard; int posted; @@ -934,7 +926,7 @@ SDL_SendKeyboardKeyInternal(Uint8 source, Uint8 state, SDL_Scancode scancode, SD (keyboard->focus->flags & SDL_WINDOW_KEYBOARD_GRABBED) && (keyboard->focus->flags & SDL_WINDOW_FULLSCREEN) && SDL_GetHintBoolean(SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED, SDL_TRUE)) { - /* We will temporarily forfeit our grab by minimizing our window, + /* We will temporarily forfeit our grab by minimizing our window, allowing the user to escape the application */ SDL_MinimizeWindow(keyboard->focus); } @@ -942,8 +934,7 @@ SDL_SendKeyboardKeyInternal(Uint8 source, Uint8 state, SDL_Scancode scancode, SD return posted; } -int -SDL_SendKeyboardUnicodeKey(Uint32 ch) +int SDL_SendKeyboardUnicodeKey(Uint32 ch) { SDL_Scancode code = SDL_SCANCODE_UNKNOWN; uint16_t mod = 0; @@ -969,26 +960,22 @@ SDL_SendKeyboardUnicodeKey(Uint32 ch) return 0; } -int -SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode) +int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode) { return SDL_SendKeyboardKeyInternal(KEYBOARD_HARDWARE, state, scancode, SDLK_UNKNOWN); } -int -SDL_SendKeyboardKeyAndKeycode(Uint8 state, SDL_Scancode scancode, SDL_Keycode keycode) +int SDL_SendKeyboardKeyAndKeycode(Uint8 state, SDL_Scancode scancode, SDL_Keycode keycode) { return SDL_SendKeyboardKeyInternal(KEYBOARD_HARDWARE, state, scancode, keycode); } -int -SDL_SendKeyboardKeyAutoRelease(SDL_Scancode scancode) +int SDL_SendKeyboardKeyAutoRelease(SDL_Scancode scancode) { return SDL_SendKeyboardKeyInternal(KEYBOARD_AUTORELEASE, SDL_PRESSED, scancode, SDLK_UNKNOWN); } -void -SDL_ReleaseAutoReleaseKeys(void) +void SDL_ReleaseAutoReleaseKeys(void) { SDL_Keyboard *keyboard = &SDL_keyboard; SDL_Scancode scancode; @@ -1017,8 +1004,7 @@ SDL_HardwareKeyboardKeyPressed(void) return SDL_FALSE; } -int -SDL_SendKeyboardText(const char *text) +int SDL_SendKeyboardText(const char *text) { SDL_Keyboard *keyboard = &SDL_keyboard; int posted; @@ -1048,8 +1034,7 @@ SDL_SendKeyboardText(const char *text) return posted; } -int -SDL_SendEditingText(const char *text, int start, int length) +int SDL_SendEditingText(const char *text, int start, int length) { SDL_Keyboard *keyboard = &SDL_keyboard; int posted; @@ -1079,8 +1064,7 @@ SDL_SendEditingText(const char *text, int start, int length) return posted; } -void -SDL_KeyboardQuit(void) +void SDL_KeyboardQuit(void) { } @@ -1089,7 +1073,7 @@ SDL_GetKeyboardState(int *numkeys) { SDL_Keyboard *keyboard = &SDL_keyboard; - if (numkeys != (int *) 0) { + if (numkeys != (int *)0) { *numkeys = SDL_NUM_SCANCODES; } return keyboard->keystate; @@ -1103,8 +1087,7 @@ SDL_GetModState(void) return (SDL_Keymod)keyboard->modstate; } -void -SDL_SetModState(SDL_Keymod modstate) +void SDL_SetModState(SDL_Keymod modstate) { SDL_Keyboard *keyboard = &SDL_keyboard; @@ -1112,8 +1095,7 @@ SDL_SetModState(SDL_Keymod modstate) } /* Note that SDL_ToggleModState() is not a public API. SDL_SetModState() is. */ -void -SDL_ToggleModState(const SDL_Keymod modstate, const SDL_bool toggle) +void SDL_ToggleModState(const SDL_Keymod modstate, const SDL_bool toggle) { SDL_Keyboard *keyboard = &SDL_keyboard; if (toggle) { @@ -1123,15 +1105,14 @@ SDL_ToggleModState(const SDL_Keymod modstate, const SDL_bool toggle) } } - SDL_Keycode SDL_GetKeyFromScancode(SDL_Scancode scancode) { SDL_Keyboard *keyboard = &SDL_keyboard; if (((int)scancode) < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) { - SDL_InvalidParamError("scancode"); - return 0; + SDL_InvalidParamError("scancode"); + return 0; } return keyboard->keymap[scancode]; @@ -1168,8 +1149,8 @@ SDL_GetScancodeName(SDL_Scancode scancode) { const char *name; if (((int)scancode) < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) { - SDL_InvalidParamError("scancode"); - return ""; + SDL_InvalidParamError("scancode"); + return ""; } name = SDL_scancode_names[scancode]; @@ -1184,7 +1165,7 @@ SDL_Scancode SDL_GetScancodeFromName(const char *name) int i; if (name == NULL || !*name) { - SDL_InvalidParamError("name"); + SDL_InvalidParamError("name"); return SDL_SCANCODE_UNKNOWN; } @@ -1233,7 +1214,7 @@ SDL_GetKeyName(SDL_Keycode key) key -= 32; } - end = SDL_UCS4ToUTF8((Uint32) key, name); + end = SDL_UCS4ToUTF8((Uint32)key, name); *end = '\0'; return name; } @@ -1254,27 +1235,27 @@ SDL_GetKeyFromName(const char *name) if (key >= 0xF0) { if (SDL_strlen(name) == 4) { int i = 0; - key = (Uint16)(name[i]&0x07) << 18; - key |= (Uint16)(name[++i]&0x3F) << 12; - key |= (Uint16)(name[++i]&0x3F) << 6; - key |= (Uint16)(name[++i]&0x3F); + key = (Uint16)(name[i] & 0x07) << 18; + key |= (Uint16)(name[++i] & 0x3F) << 12; + key |= (Uint16)(name[++i] & 0x3F) << 6; + key |= (Uint16)(name[++i] & 0x3F); return key; } return SDLK_UNKNOWN; } else if (key >= 0xE0) { if (SDL_strlen(name) == 3) { int i = 0; - key = (Uint16)(name[i]&0x0F) << 12; - key |= (Uint16)(name[++i]&0x3F) << 6; - key |= (Uint16)(name[++i]&0x3F); + key = (Uint16)(name[i] & 0x0F) << 12; + key |= (Uint16)(name[++i] & 0x3F) << 6; + key |= (Uint16)(name[++i] & 0x3F); return key; } return SDLK_UNKNOWN; } else if (key >= 0xC0) { if (SDL_strlen(name) == 2) { int i = 0; - key = (Uint16)(name[i]&0x1F) << 6; - key |= (Uint16)(name[++i]&0x3F); + key = (Uint16)(name[i] & 0x1F) << 6; + key |= (Uint16)(name[++i] & 0x3F); return key; } return SDLK_UNKNOWN; diff --git a/src/events/SDL_keyboard_c.h b/src/events/SDL_keyboard_c.h index 3ace4af64..d81571210 100644 --- a/src/events/SDL_keyboard_c.h +++ b/src/events/SDL_keyboard_c.h @@ -30,13 +30,13 @@ extern int SDL_KeyboardInit(void); /* Get the default keymap */ -extern void SDL_GetDefaultKeymap(SDL_Keycode * keymap); +extern void SDL_GetDefaultKeymap(SDL_Keycode *keymap); /* Get the default key code for a scancode */ extern SDL_Keycode SDL_GetDefaultKeyFromScancode(SDL_Scancode scancode); /* Set the mapping of scancode to key codes */ -extern void SDL_SetKeymap(int start, const SDL_Keycode * keys, int length, SDL_bool send_event); +extern void SDL_SetKeymap(int start, const SDL_Keycode *keys, int length, SDL_bool send_event); /* Set a platform-dependent key name, overriding the default platform-agnostic name. Encoded as UTF-8. The string is not copied, thus the pointer given to @@ -45,7 +45,7 @@ extern void SDL_SetKeymap(int start, const SDL_Keycode * keys, int length, SDL_b extern void SDL_SetScancodeName(SDL_Scancode scancode, const char *name); /* Set the keyboard focus window */ -extern void SDL_SetKeyboardFocus(SDL_Window * window); +extern void SDL_SetKeyboardFocus(SDL_Window *window); /* Send a character from an on-screen keyboard as scancode and modifier key events, currently assuming ASCII characters on a US keyboard layout diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index 9cc692d72..e6b54d2fa 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -29,7 +29,7 @@ #include "../SDL_hints_c.h" #include "../video/SDL_sysvideo.h" #if defined(__WIN32__) || defined(__GDK__) -#include "../core/windows/SDL_windows.h" // For GetDoubleClickTime() +#include "../core/windows/SDL_windows.h" // For GetDoubleClickTime() #endif #if defined(__OS2__) #define INCL_WIN @@ -44,11 +44,9 @@ static SDL_Mouse SDL_mouse; /* for mapping mouse events to touch */ static SDL_bool track_mouse_down = SDL_FALSE; -static int -SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y); +static int SDL_PrivateSendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y); -static void SDLCALL -SDL_MouseDoubleClickTimeChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_MouseDoubleClickTimeChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; @@ -65,20 +63,18 @@ SDL_MouseDoubleClickTimeChanged(void *userdata, const char *name, const char *ol } } -static void SDLCALL -SDL_MouseDoubleClickRadiusChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_MouseDoubleClickRadiusChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; if (hint && *hint) { mouse->double_click_radius = SDL_atoi(hint); } else { - mouse->double_click_radius = 32; /* 32 pixels seems about right for touch interfaces */ + mouse->double_click_radius = 32; /* 32 pixels seems about right for touch interfaces */ } } -static void SDLCALL -SDL_MouseNormalSpeedScaleChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_MouseNormalSpeedScaleChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; @@ -91,8 +87,7 @@ SDL_MouseNormalSpeedScaleChanged(void *userdata, const char *name, const char *o } } -static void SDLCALL -SDL_MouseRelativeSpeedScaleChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_MouseRelativeSpeedScaleChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; @@ -105,16 +100,14 @@ SDL_MouseRelativeSpeedScaleChanged(void *userdata, const char *name, const char } } -static void SDLCALL -SDL_MouseRelativeSystemScaleChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_MouseRelativeSystemScaleChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; mouse->enable_relative_system_scale = SDL_GetStringBoolean(hint, SDL_FALSE); } -static void SDLCALL -SDL_TouchMouseEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_TouchMouseEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; @@ -122,12 +115,11 @@ SDL_TouchMouseEventsChanged(void *userdata, const char *name, const char *oldVal } #if defined(__vita__) -static void SDLCALL -SDL_VitaTouchMouseDeviceChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_VitaTouchMouseDeviceChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; if (hint) { - switch(*hint) { + switch (*hint) { default: case '0': mouse->vita_touch_mouse_device = 0; @@ -143,8 +135,7 @@ SDL_VitaTouchMouseDeviceChanged(void *userdata, const char *name, const char *ol } #endif -static void SDLCALL -SDL_MouseTouchEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_MouseTouchEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; SDL_bool default_value; @@ -161,8 +152,7 @@ SDL_MouseTouchEventsChanged(void *userdata, const char *name, const char *oldVal } } -static void SDLCALL -SDL_MouseAutoCaptureChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_MouseAutoCaptureChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; SDL_bool auto_capture = SDL_GetStringBoolean(hint, SDL_TRUE); @@ -173,8 +163,7 @@ SDL_MouseAutoCaptureChanged(void *userdata, const char *name, const char *oldVal } } -static void SDLCALL -SDL_MouseRelativeWarpMotionChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_MouseRelativeWarpMotionChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; @@ -182,8 +171,7 @@ SDL_MouseRelativeWarpMotionChanged(void *userdata, const char *name, const char } /* Public functions */ -int -SDL_MouseInit(void) +int SDL_MouseInit(void) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -228,8 +216,7 @@ SDL_MouseInit(void) return 0; } -void -SDL_SetDefaultCursor(SDL_Cursor * cursor) +void SDL_SetDefaultCursor(SDL_Cursor *cursor) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -290,8 +277,7 @@ SDL_ResetMouse(void) } #endif /* 0 */ -void -SDL_SetMouseFocus(SDL_Window * window) +void SDL_SetMouseFocus(SDL_Window *window) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -328,8 +314,7 @@ SDL_SetMouseFocus(SDL_Window * window) } /* Check to see if we need to synthesize focus events */ -static SDL_bool -SDL_UpdateMouseFocus(SDL_Window * window, int x, int y, Uint32 buttonstate, SDL_bool send_mouse_motion) +static SDL_bool SDL_UpdateMouseFocus(SDL_Window *window, int x, int y, Uint32 buttonstate, SDL_bool send_mouse_motion) { SDL_Mouse *mouse = SDL_GetMouse(); SDL_bool inWindow = SDL_TRUE; @@ -367,8 +352,7 @@ SDL_UpdateMouseFocus(SDL_Window * window, int x, int y, Uint32 buttonstate, SDL_ return SDL_TRUE; } -int -SDL_SendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y) +int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y) { if (window && !relative) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -380,8 +364,7 @@ SDL_SendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int return SDL_PrivateSendMouseMotion(window, mouseID, relative, x, y); } -static int -GetScaledMouseDelta(float scale, int value, float *accum) +static int GetScaledMouseDelta(float scale, int value, float *accum) { if (value && scale != 1.0f) { if ((value > 0) != (*accum > 0)) { @@ -398,8 +381,7 @@ GetScaledMouseDelta(float scale, int value, float *accum) return value; } -static float -CalculateSystemScale(SDL_Mouse *mouse, int *x, int *y) +static float CalculateSystemScale(SDL_Mouse *mouse, int *x, int *y) { int i; int n = mouse->num_system_scale_values; @@ -430,8 +412,7 @@ CalculateSystemScale(SDL_Mouse *mouse, int *x, int *y) } /* You can set either a single scale, or a set of {speed, scale} values in ascending order */ -int -SDL_SetMouseSystemScale(int num_values, const float *values) +int SDL_SetMouseSystemScale(int num_values, const float *values) { SDL_Mouse *mouse = SDL_GetMouse(); float *v; @@ -472,8 +453,7 @@ SDL_SetMouseSystemScale(int num_values, const float *values) return 0; } -static void -GetScaledMouseDeltas(SDL_Mouse *mouse, int *x, int *y) +static void GetScaledMouseDeltas(SDL_Mouse *mouse, int *x, int *y) { if (mouse->relative_mode) { if (mouse->enable_relative_speed_scale) { @@ -492,8 +472,7 @@ GetScaledMouseDeltas(SDL_Mouse *mouse, int *x, int *y) } } -static int -SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y) +static int SDL_PrivateSendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y) { SDL_Mouse *mouse = SDL_GetMouse(); int posted; @@ -556,7 +535,7 @@ SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relativ mouse->x = x; mouse->y = y; mouse->has_position = SDL_TRUE; - } else if (!xrel && !yrel) { /* Drop events that don't change state */ + } else if (!xrel && !yrel) { /* Drop events that don't change state */ #ifdef DEBUG_MOUSE SDL_Log("Mouse event didn't change state - dropped!\n"); #endif @@ -637,7 +616,7 @@ SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relativ event.motion.windowID = mouse->focus ? mouse->focus->id : 0; event.motion.which = mouseID; /* Set us pending (or clear during a normal mouse movement event) as having triggered */ - mouse->was_touch_mouse_events = (mouseID == SDL_TOUCH_MOUSEID)? SDL_TRUE : SDL_FALSE; + mouse->was_touch_mouse_events = (mouseID == SDL_TOUCH_MOUSEID) ? SDL_TRUE : SDL_FALSE; event.motion.state = GetButtonState(mouse, SDL_TRUE); event.motion.x = mouse->x; event.motion.y = mouse->y; @@ -668,7 +647,7 @@ static SDL_MouseInputSource *GetMouseInputSource(SDL_Mouse *mouse, SDL_MouseID m } } - sources = (SDL_MouseInputSource *)SDL_realloc(mouse->sources, (mouse->num_sources + 1)*sizeof(*mouse->sources)); + sources = (SDL_MouseInputSource *)SDL_realloc(mouse->sources, (mouse->num_sources + 1) * sizeof(*mouse->sources)); if (sources) { mouse->sources = sources; ++mouse->num_sources; @@ -698,8 +677,7 @@ static SDL_MouseClickState *GetMouseClickState(SDL_Mouse *mouse, Uint8 button) return &mouse->clickstate[button]; } -static int -SDL_PrivateSendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button, int clicks) +static int SDL_PrivateSendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button, int clicks) { SDL_Mouse *mouse = SDL_GetMouse(); int posted; @@ -795,7 +773,7 @@ SDL_PrivateSendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state event.button.which = mouseID; event.button.state = state; event.button.button = button; - event.button.clicks = (Uint8) SDL_min(clicks, 255); + event.button.clicks = (Uint8)SDL_min(clicks, 255); event.button.x = mouse->x; event.button.y = mouse->y; posted = (SDL_PushEvent(&event) > 0); @@ -814,21 +792,18 @@ SDL_PrivateSendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state return posted; } -int -SDL_SendMouseButtonClicks(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button, int clicks) +int SDL_SendMouseButtonClicks(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button, int clicks) { clicks = SDL_max(clicks, 0); return SDL_PrivateSendMouseButton(window, mouseID, state, button, clicks); } -int -SDL_SendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button) +int SDL_SendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button) { return SDL_PrivateSendMouseButton(window, mouseID, state, button, -1); } -int -SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction) +int SDL_SendMouseWheel(SDL_Window *window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction) { SDL_Mouse *mouse = SDL_GetMouse(); int posted; @@ -899,8 +874,7 @@ SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, S return posted; } -void -SDL_MouseQuit(void) +void SDL_MouseQuit(void) { SDL_Cursor *cursor, *next; SDL_Mouse *mouse = SDL_GetMouse(); @@ -1020,8 +994,7 @@ SDL_GetGlobalMouseState(int *x, int *y) } } -void -SDL_PerformWarpMouseInWindow(SDL_Window *window, int x, int y, SDL_bool ignore_relative_mode) +void SDL_PerformWarpMouseInWindow(SDL_Window *window, int x, int y, SDL_bool ignore_relative_mode) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -1066,14 +1039,12 @@ SDL_PerformWarpMouseInWindow(SDL_Window *window, int x, int y, SDL_bool ignore_r } } -void -SDL_WarpMouseInWindow(SDL_Window * window, int x, int y) +void SDL_WarpMouseInWindow(SDL_Window *window, int x, int y) { SDL_PerformWarpMouseInWindow(window, x, y, SDL_FALSE); } -int -SDL_WarpMouseGlobal(int x, int y) +int SDL_WarpMouseGlobal(int x, int y) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -1084,8 +1055,7 @@ SDL_WarpMouseGlobal(int x, int y) return SDL_Unsupported(); } -static SDL_bool -ShouldUseRelativeModeWarp(SDL_Mouse *mouse) +static SDL_bool ShouldUseRelativeModeWarp(SDL_Mouse *mouse) { if (!mouse->WarpMouse) { /* Need this functionality for relative mode warp implementation */ @@ -1095,8 +1065,7 @@ ShouldUseRelativeModeWarp(SDL_Mouse *mouse) return SDL_GetHintBoolean(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, SDL_FALSE); } -int -SDL_SetRelativeMouseMode(SDL_bool enabled) +int SDL_SetRelativeMouseMode(SDL_bool enabled) { SDL_Mouse *mouse = SDL_GetMouse(); SDL_Window *focusWindow = SDL_GetKeyboardFocus(); @@ -1132,7 +1101,7 @@ SDL_SetRelativeMouseMode(SDL_bool enabled) SDL_SetMouseFocus(focusWindow); if (mouse->relative_mode_warp) { - SDL_PerformWarpMouseInWindow(focusWindow, focusWindow->w/2, focusWindow->h/2, SDL_TRUE); + SDL_PerformWarpMouseInWindow(focusWindow, focusWindow->w / 2, focusWindow->h / 2, SDL_TRUE); } } @@ -1166,8 +1135,7 @@ SDL_GetRelativeMouseMode() return mouse->relative_mode; } -int -SDL_UpdateMouseCapture(SDL_bool force_release) +int SDL_UpdateMouseCapture(SDL_bool force_release) { SDL_Mouse *mouse = SDL_GetMouse(); SDL_Window *capture_window = NULL; @@ -1218,8 +1186,7 @@ SDL_UpdateMouseCapture(SDL_bool force_release) return 0; } -int -SDL_CaptureMouse(SDL_bool enabled) +int SDL_CaptureMouse(SDL_bool enabled) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -1247,7 +1214,7 @@ SDL_CaptureMouse(SDL_bool enabled) } SDL_Cursor * -SDL_CreateCursor(const Uint8 * data, const Uint8 * mask, +SDL_CreateCursor(const Uint8 *data, const Uint8 *mask, int w, int h, int hot_x, int hot_y) { SDL_Surface *surface; @@ -1272,7 +1239,7 @@ SDL_CreateCursor(const Uint8 * data, const Uint8 * mask, return NULL; } for (y = 0; y < h; ++y) { - pixel = (Uint32 *) ((Uint8 *) surface->pixels + y * surface->pitch); + pixel = (Uint32 *)((Uint8 *)surface->pixels + y * surface->pitch); for (x = 0; x < w; ++x) { if ((x % 8) == 0) { datab = *data++; @@ -1362,8 +1329,7 @@ SDL_CreateSystemCursor(SDL_SystemCursor id) if this is desired for any reason. This is used when setting the video mode and when the SDL window gains the mouse focus. */ -void -SDL_SetCursor(SDL_Cursor * cursor) +void SDL_SetCursor(SDL_Cursor *cursor) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -1424,8 +1390,7 @@ SDL_GetDefaultCursor(void) return mouse->def_cursor; } -void -SDL_FreeCursor(SDL_Cursor * cursor) +void SDL_FreeCursor(SDL_Cursor *cursor) { SDL_Mouse *mouse = SDL_GetMouse(); SDL_Cursor *curr, *prev; @@ -1458,8 +1423,7 @@ SDL_FreeCursor(SDL_Cursor * cursor) } } -int -SDL_ShowCursor(int toggle) +int SDL_ShowCursor(int toggle) { SDL_Mouse *mouse = SDL_GetMouse(); SDL_bool shown; diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h index 6dd023041..ec0c8f5e5 100644 --- a/src/events/SDL_mouse_c.h +++ b/src/events/SDL_mouse_c.h @@ -49,34 +49,34 @@ typedef struct typedef struct { /* Create a cursor from a surface */ - SDL_Cursor *(*CreateCursor) (SDL_Surface * surface, int hot_x, int hot_y); + SDL_Cursor *(*CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y); /* Create a system cursor */ - SDL_Cursor *(*CreateSystemCursor) (SDL_SystemCursor id); + SDL_Cursor *(*CreateSystemCursor)(SDL_SystemCursor id); /* Show the specified cursor, or hide if cursor is NULL */ - int (*ShowCursor) (SDL_Cursor * cursor); + int (*ShowCursor)(SDL_Cursor *cursor); /* This is called when a mouse motion event occurs */ - void (*MoveCursor) (SDL_Cursor * cursor); + void (*MoveCursor)(SDL_Cursor *cursor); /* Free a window manager cursor */ - void (*FreeCursor) (SDL_Cursor * cursor); + void (*FreeCursor)(SDL_Cursor *cursor); /* Warp the mouse to (x,y) within a window */ - void (*WarpMouse) (SDL_Window * window, int x, int y); + void (*WarpMouse)(SDL_Window *window, int x, int y); /* Warp the mouse to (x,y) in screen space */ - int (*WarpMouseGlobal) (int x, int y); + int (*WarpMouseGlobal)(int x, int y); /* Set relative mode */ - int (*SetRelativeMouseMode) (SDL_bool enabled); + int (*SetRelativeMouseMode)(SDL_bool enabled); /* Set mouse capture */ - int (*CaptureMouse) (SDL_Window * window); + int (*CaptureMouse)(SDL_Window *window); /* Get absolute mouse coordinates. (x) and (y) are never NULL and set to zero before call. */ - Uint32 (*GetGlobalMouseState) (int *x, int *y); + Uint32 (*GetGlobalMouseState)(int *x, int *y); /* Data common to all mice */ SDL_MouseID mouseID; @@ -85,7 +85,7 @@ typedef struct int y; int xdelta; int ydelta; - int last_x, last_y; /* the last reported x and y coordinates */ + int last_x, last_y; /* the last reported x and y coordinates */ float accumulated_wheel_x; float accumulated_wheel_y; SDL_bool has_position; @@ -130,7 +130,6 @@ typedef struct void *driverdata; } SDL_Mouse; - /* Initialize the mouse subsystem */ extern int SDL_MouseInit(void); @@ -138,10 +137,10 @@ extern int SDL_MouseInit(void); SDL_Mouse *SDL_GetMouse(void); /* Set the default mouse cursor */ -extern void SDL_SetDefaultCursor(SDL_Cursor * cursor); +extern void SDL_SetDefaultCursor(SDL_Cursor *cursor); /* Set the mouse focus window */ -extern void SDL_SetMouseFocus(SDL_Window * window); +extern void SDL_SetMouseFocus(SDL_Window *window); /* Update the mouse capture window */ extern int SDL_UpdateMouseCapture(SDL_bool force_release); @@ -150,16 +149,16 @@ extern int SDL_UpdateMouseCapture(SDL_bool force_release); extern int SDL_SetMouseSystemScale(int num_values, const float *values); /* Send a mouse motion event */ -extern int SDL_SendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y); +extern int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y); /* Send a mouse button event */ -extern int SDL_SendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button); +extern int SDL_SendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button); /* Send a mouse button event with a click count */ -extern int SDL_SendMouseButtonClicks(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button, int clicks); +extern int SDL_SendMouseButtonClicks(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button, int clicks); /* Send a mouse wheel event */ -extern int SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction); +extern int SDL_SendMouseWheel(SDL_Window *window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction); /* Warp the mouse within the window, potentially overriding relative mode */ extern void SDL_PerformWarpMouseInWindow(SDL_Window *window, int x, int y, SDL_bool ignore_relative_mode); diff --git a/src/events/SDL_quit.c b/src/events/SDL_quit.c index ca583ea9c..a56f7e909 100644 --- a/src/events/SDL_quit.c +++ b/src/events/SDL_quit.c @@ -47,8 +47,7 @@ static SDL_bool send_backgrounding_pending = SDL_FALSE; static SDL_bool send_foregrounding_pending = SDL_FALSE; #endif -static void -SDL_HandleSIG(int sig) +static void SDL_HandleSIG(int sig) { /* Reset the signal handler */ signal(sig, SDL_HandleSIG); @@ -59,54 +58,52 @@ SDL_HandleSIG(int sig) send_quit_pending = SDL_TRUE; } - #ifdef SDL_BACKGROUNDING_SIGNAL +#ifdef SDL_BACKGROUNDING_SIGNAL else if (sig == SDL_BACKGROUNDING_SIGNAL) { send_backgrounding_pending = SDL_TRUE; } - #endif +#endif - #ifdef SDL_FOREGROUNDING_SIGNAL +#ifdef SDL_FOREGROUNDING_SIGNAL else if (sig == SDL_FOREGROUNDING_SIGNAL) { send_foregrounding_pending = SDL_TRUE; } - #endif +#endif } -static void -SDL_EventSignal_Init(const int sig) +static void SDL_EventSignal_Init(const int sig) { #ifdef HAVE_SIGACTION struct sigaction action; sigaction(sig, NULL, &action); #ifdef HAVE_SA_SIGACTION - if ( action.sa_handler == SIG_DFL && (void (*)(int))action.sa_sigaction == SIG_DFL ) { + if (action.sa_handler == SIG_DFL && (void (*)(int))action.sa_sigaction == SIG_DFL) { #else - if ( action.sa_handler == SIG_DFL ) { + if (action.sa_handler == SIG_DFL) { #endif action.sa_handler = SDL_HandleSIG; sigaction(sig, &action, NULL); } #elif HAVE_SIGNAL_H - void (*ohandler) (int) = signal(sig, SDL_HandleSIG); + void (*ohandler)(int) = signal(sig, SDL_HandleSIG); if (ohandler != SIG_DFL) { signal(sig, ohandler); } #endif } -static void -SDL_EventSignal_Quit(const int sig) +static void SDL_EventSignal_Quit(const int sig) { #ifdef HAVE_SIGACTION struct sigaction action; sigaction(sig, NULL, &action); - if ( action.sa_handler == SDL_HandleSIG ) { + if (action.sa_handler == SDL_HandleSIG) { action.sa_handler = SIG_DFL; sigaction(sig, &action, NULL); } #elif HAVE_SIGNAL_H - void (*ohandler) (int) = signal(sig, SIG_DFL); + void (*ohandler)(int) = signal(sig, SIG_DFL); if (ohandler != SDL_HandleSIG) { signal(sig, ohandler); } @@ -114,44 +111,41 @@ SDL_EventSignal_Quit(const int sig) } /* Public functions */ -static int -SDL_QuitInit_Internal(void) +static int SDL_QuitInit_Internal(void) { /* Both SIGINT and SIGTERM are translated into quit interrupts */ /* and SDL can be built to simulate iOS/Android semantics with arbitrary signals. */ SDL_EventSignal_Init(SIGINT); SDL_EventSignal_Init(SIGTERM); - #ifdef SDL_BACKGROUNDING_SIGNAL +#ifdef SDL_BACKGROUNDING_SIGNAL SDL_EventSignal_Init(SDL_BACKGROUNDING_SIGNAL); - #endif +#endif - #ifdef SDL_FOREGROUNDING_SIGNAL +#ifdef SDL_FOREGROUNDING_SIGNAL SDL_EventSignal_Init(SDL_FOREGROUNDING_SIGNAL); - #endif +#endif /* That's it! */ return 0; } -static void -SDL_QuitQuit_Internal(void) +static void SDL_QuitQuit_Internal(void) { SDL_EventSignal_Quit(SIGINT); SDL_EventSignal_Quit(SIGTERM); - #ifdef SDL_BACKGROUNDING_SIGNAL +#ifdef SDL_BACKGROUNDING_SIGNAL SDL_EventSignal_Quit(SDL_BACKGROUNDING_SIGNAL); - #endif +#endif - #ifdef SDL_FOREGROUNDING_SIGNAL +#ifdef SDL_FOREGROUNDING_SIGNAL SDL_EventSignal_Quit(SDL_FOREGROUNDING_SIGNAL); - #endif +#endif } #endif -int -SDL_QuitInit(void) +int SDL_QuitInit(void) { #ifdef HAVE_SIGNAL_SUPPORT if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) { @@ -161,8 +155,7 @@ SDL_QuitInit(void) return 0; } -void -SDL_QuitQuit(void) +void SDL_QuitQuit(void) { #ifdef HAVE_SIGNAL_SUPPORT if (!disable_signals) { @@ -171,8 +164,7 @@ SDL_QuitQuit(void) #endif } -void -SDL_SendPendingSignalEvents(void) +void SDL_SendPendingSignalEvents(void) { #ifdef HAVE_SIGNAL_SUPPORT if (send_quit_pending) { @@ -180,25 +172,24 @@ SDL_SendPendingSignalEvents(void) SDL_assert(!send_quit_pending); } - #ifdef SDL_BACKGROUNDING_SIGNAL +#ifdef SDL_BACKGROUNDING_SIGNAL if (send_backgrounding_pending) { send_backgrounding_pending = SDL_FALSE; SDL_OnApplicationWillResignActive(); } - #endif +#endif - #ifdef SDL_FOREGROUNDING_SIGNAL +#ifdef SDL_FOREGROUNDING_SIGNAL if (send_foregrounding_pending) { send_foregrounding_pending = SDL_FALSE; SDL_OnApplicationDidBecomeActive(); } - #endif +#endif #endif } /* This function returns 1 if it's okay to close the application window */ -int -SDL_SendQuit(void) +int SDL_SendQuit(void) { #ifdef HAVE_SIGNAL_SUPPORT send_quit_pending = SDL_FALSE; diff --git a/src/events/SDL_touch.c b/src/events/SDL_touch.c index 3a724799b..117ff2484 100644 --- a/src/events/SDL_touch.c +++ b/src/events/SDL_touch.c @@ -26,7 +26,6 @@ #include "SDL_events_c.h" #include "../video/SDL_sysvideo.h" - static int SDL_num_touch = 0; static SDL_Touch **SDL_touchDevices = NULL; @@ -37,18 +36,16 @@ static SDL_Touch **SDL_touchDevices = NULL; #if SYNTHESIZE_TOUCH_TO_MOUSE static SDL_bool finger_touching = SDL_FALSE; static SDL_FingerID track_fingerid; -static SDL_TouchID track_touchid; +static SDL_TouchID track_touchid; #endif /* Public functions */ -int -SDL_TouchInit(void) +int SDL_TouchInit(void) { return 0; } -int -SDL_GetNumTouchDevices(void) +int SDL_GetNumTouchDevices(void) { return SDL_num_touch; } @@ -63,7 +60,7 @@ SDL_GetTouchDevice(int index) return SDL_touchDevices[index]->id; } -const char* +const char * SDL_GetTouchName(int index) { if (index < 0 || index >= SDL_num_touch) { @@ -73,8 +70,7 @@ SDL_GetTouchName(int index) return SDL_touchDevices[index]->name; } -static int -SDL_GetTouchIndex(SDL_TouchID id) +static int SDL_GetTouchIndex(SDL_TouchID id) { int index; SDL_Touch *touch; @@ -94,10 +90,10 @@ SDL_GetTouch(SDL_TouchID id) int index = SDL_GetTouchIndex(id); if (index < 0 || index >= SDL_num_touch) { if (SDL_GetVideoDevice()->ResetTouch != NULL) { - SDL_SetError("Unknown touch id %d, resetting", (int) id); + SDL_SetError("Unknown touch id %d, resetting", (int)id); (SDL_GetVideoDevice()->ResetTouch)(SDL_GetVideoDevice()); } else { - SDL_SetError("Unknown touch device id %d, cannot reset", (int) id); + SDL_SetError("Unknown touch device id %d, cannot reset", (int)id); } return NULL; } @@ -114,8 +110,7 @@ SDL_GetTouchDeviceType(SDL_TouchID id) return SDL_TOUCH_DEVICE_INVALID; } -static int -SDL_GetFingerIndex(const SDL_Touch * touch, SDL_FingerID fingerid) +static int SDL_GetFingerIndex(const SDL_Touch *touch, SDL_FingerID fingerid) { int index; for (index = 0; index < touch->num_fingers; ++index) { @@ -126,8 +121,7 @@ SDL_GetFingerIndex(const SDL_Touch * touch, SDL_FingerID fingerid) return -1; } -static SDL_Finger * -SDL_GetFinger(const SDL_Touch * touch, SDL_FingerID id) +static SDL_Finger *SDL_GetFinger(const SDL_Touch *touch, SDL_FingerID id) { int index = SDL_GetFingerIndex(touch, id); if (index < 0 || index >= touch->num_fingers) { @@ -136,8 +130,7 @@ SDL_GetFinger(const SDL_Touch * touch, SDL_FingerID id) return touch->fingers[index]; } -int -SDL_GetNumTouchFingers(SDL_TouchID touchID) +int SDL_GetNumTouchFingers(SDL_TouchID touchID) { SDL_Touch *touch = SDL_GetTouch(touchID); if (touch) { @@ -160,8 +153,7 @@ SDL_GetTouchFinger(SDL_TouchID touchID, int index) return touch->fingers[index]; } -int -SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name) +int SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name) { SDL_Touch **touchDevices; int index; @@ -172,8 +164,8 @@ SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name) } /* Add the touch to the list of touch */ - touchDevices = (SDL_Touch **) SDL_realloc(SDL_touchDevices, - (SDL_num_touch + 1) * sizeof(*touchDevices)); + touchDevices = (SDL_Touch **)SDL_realloc(SDL_touchDevices, + (SDL_num_touch + 1) * sizeof(*touchDevices)); if (touchDevices == NULL) { return SDL_OutOfMemory(); } @@ -181,7 +173,7 @@ SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name) SDL_touchDevices = touchDevices; index = SDL_num_touch; - SDL_touchDevices[index] = (SDL_Touch *) SDL_malloc(sizeof(*SDL_touchDevices[index])); + SDL_touchDevices[index] = (SDL_Touch *)SDL_malloc(sizeof(*SDL_touchDevices[index])); if (!SDL_touchDevices[index]) { return SDL_OutOfMemory(); } @@ -204,14 +196,13 @@ SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name) return index; } -static int -SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float y, float pressure) +static int SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float y, float pressure) { SDL_Finger *finger; if (touch->num_fingers == touch->max_fingers) { SDL_Finger **new_fingers; - new_fingers = (SDL_Finger **)SDL_realloc(touch->fingers, (touch->max_fingers+1)*sizeof(*touch->fingers)); + new_fingers = (SDL_Finger **)SDL_realloc(touch->fingers, (touch->max_fingers + 1) * sizeof(*touch->fingers)); if (new_fingers == NULL) { return SDL_OutOfMemory(); } @@ -231,8 +222,7 @@ SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float y, float p return 0; } -static int -SDL_DelFinger(SDL_Touch* touch, SDL_FingerID fingerid) +static int SDL_DelFinger(SDL_Touch *touch, SDL_FingerID fingerid) { SDL_Finger *temp; @@ -248,15 +238,14 @@ SDL_DelFinger(SDL_Touch* touch, SDL_FingerID fingerid) return 0; } -int -SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window * window, - SDL_bool down, float x, float y, float pressure) +int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, + SDL_bool down, float x, float y, float pressure) { int posted; SDL_Finger *finger; SDL_Mouse *mouse; - SDL_Touch* touch = SDL_GetTouch(id); + SDL_Touch *touch = SDL_GetTouch(id); if (touch == NULL) { return -1; } @@ -268,7 +257,7 @@ SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window * window, /* SDL_HINT_VITA_TOUCH_MOUSE_DEVICE: controlling which touchpad should generate synthetic mouse events, PSVita-only */ { #if defined(__vita__) - if (mouse->touch_mouse_events && ((mouse->vita_touch_mouse_device == id) || (mouse->vita_touch_mouse_device == 2)) ) { + if (mouse->touch_mouse_events && ((mouse->vita_touch_mouse_device == id) || (mouse->vita_touch_mouse_device == 2))) { #else if (mouse->touch_mouse_events) { #endif @@ -376,9 +365,8 @@ SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window * window, return posted; } -int -SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window * window, - float x, float y, float pressure) +int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, + float x, float y, float pressure) { SDL_Touch *touch; SDL_Finger *finger; @@ -429,7 +417,7 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window * window, } } - finger = SDL_GetFinger(touch,fingerid); + finger = SDL_GetFinger(touch, fingerid); if (finger == NULL) { return SDL_SendTouch(id, fingerid, window, SDL_TRUE, x, y, pressure); } @@ -469,8 +457,7 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window * window, return posted; } -void -SDL_DelTouch(SDL_TouchID id) +void SDL_DelTouch(SDL_TouchID id) { int i, index; SDL_Touch *touch; @@ -500,12 +487,11 @@ SDL_DelTouch(SDL_TouchID id) SDL_GestureDelTouch(id); } -void -SDL_TouchQuit(void) +void SDL_TouchQuit(void) { int i; - for (i = SDL_num_touch; i--; ) { + for (i = SDL_num_touch; i--;) { SDL_DelTouch(SDL_touchDevices[i]->id); } SDL_assert(SDL_num_touch == 0); diff --git a/src/events/SDL_touch_c.h b/src/events/SDL_touch_c.h index 4d5caf134..88eacbaeb 100644 --- a/src/events/SDL_touch_c.h +++ b/src/events/SDL_touch_c.h @@ -30,11 +30,10 @@ typedef struct SDL_Touch SDL_TouchDeviceType type; int num_fingers; int max_fingers; - SDL_Finger** fingers; + SDL_Finger **fingers; char *name; } SDL_Touch; - /* Initialize the touch subsystem */ extern int SDL_TouchInit(void); @@ -45,11 +44,11 @@ extern int SDL_AddTouch(SDL_TouchID id, SDL_TouchDeviceType type, const char *na extern SDL_Touch *SDL_GetTouch(SDL_TouchID id); /* Send a touch down/up event for a touch */ -extern int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window * window, +extern int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, SDL_bool down, float x, float y, float pressure); /* Send a touch motion event for a touch */ -extern int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window * window, +extern int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, float x, float y, float pressure); /* Remove a touch */ diff --git a/src/events/SDL_windowevents.c b/src/events/SDL_windowevents.c index e87f758c8..ffcfd78dd 100644 --- a/src/events/SDL_windowevents.c +++ b/src/events/SDL_windowevents.c @@ -33,10 +33,9 @@ typedef struct RemovePendingSizeChangedAndResizedEvents_Data SDL_bool saw_resized; } RemovePendingSizeChangedAndResizedEvents_Data; -static int SDLCALL -RemovePendingSizeChangedAndResizedEvents(void *_userdata, SDL_Event *event) +static int SDLCALL RemovePendingSizeChangedAndResizedEvents(void *_userdata, SDL_Event *event) { - RemovePendingSizeChangedAndResizedEvents_Data *userdata = (RemovePendingSizeChangedAndResizedEvents_Data *) _userdata; + RemovePendingSizeChangedAndResizedEvents_Data *userdata = (RemovePendingSizeChangedAndResizedEvents_Data *)_userdata; const SDL_Event *new_event = userdata->new_event; if (event->type == SDL_WINDOWEVENT && @@ -54,8 +53,7 @@ RemovePendingSizeChangedAndResizedEvents(void *_userdata, SDL_Event *event) return 1; } -static int SDLCALL -RemovePendingMoveEvents(void * userdata, SDL_Event *event) +static int SDLCALL RemovePendingMoveEvents(void *userdata, SDL_Event *event) { SDL_Event *new_event = (SDL_Event *)userdata; @@ -68,8 +66,7 @@ RemovePendingMoveEvents(void * userdata, SDL_Event *event) return 1; } -static int SDLCALL -RemovePendingExposedEvents(void * userdata, SDL_Event *event) +static int SDLCALL RemovePendingExposedEvents(void *userdata, SDL_Event *event) { SDL_Event *new_event = (SDL_Event *)userdata; @@ -82,9 +79,8 @@ RemovePendingExposedEvents(void * userdata, SDL_Event *event) return 1; } -int -SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, - int data2) +int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, + int data2) { int posted; @@ -205,12 +201,12 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, userdata.new_event = &event; userdata.saw_resized = SDL_FALSE; SDL_FilterEvents(RemovePendingSizeChangedAndResizedEvents, &userdata); - if (userdata.saw_resized) { /* if there was a pending resize, make sure one at the new dimensions remains. */ + if (userdata.saw_resized) { /* if there was a pending resize, make sure one at the new dimensions remains. */ event.window.event = SDL_WINDOWEVENT_RESIZED; if (SDL_PushEvent(&event) <= 0) { - return 0; /* oh well. */ + return 0; /* oh well. */ } - event.window.event = SDL_WINDOWEVENT_SIZE_CHANGED; /* then push the actual event next. */ + event.window.event = SDL_WINDOWEVENT_SIZE_CHANGED; /* then push the actual event next. */ } } if (windowevent == SDL_WINDOWEVENT_MOVED) { @@ -223,9 +219,9 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, } if (windowevent == SDL_WINDOWEVENT_CLOSE) { - if ( !window->prev && !window->next ) { + if (!window->prev && !window->next) { if (SDL_GetHintBoolean(SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE, SDL_TRUE)) { - SDL_SendQuit(); /* This is the last window in the list so send the SDL_QUIT event */ + SDL_SendQuit(); /* This is the last window in the list so send the SDL_QUIT event */ } } } diff --git a/src/events/SDL_windowevents_c.h b/src/events/SDL_windowevents_c.h index f8042ee9e..a8ea32568 100644 --- a/src/events/SDL_windowevents_c.h +++ b/src/events/SDL_windowevents_c.h @@ -23,7 +23,7 @@ #ifndef SDL_windowevents_c_h_ #define SDL_windowevents_c_h_ -extern int SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, +extern int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2); #endif /* SDL_windowevents_c_h_ */ diff --git a/src/events/blank_cursor.h b/src/events/blank_cursor.h index 35b47d375..9bc0e23b4 100644 --- a/src/events/blank_cursor.h +++ b/src/events/blank_cursor.h @@ -22,10 +22,10 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * A default blank 8x8 cursor */ -#define BLANK_CWIDTH 8 -#define BLANK_CHEIGHT 8 -#define BLANK_CHOTX 0 -#define BLANK_CHOTY 0 +#define BLANK_CWIDTH 8 +#define BLANK_CHEIGHT 8 +#define BLANK_CHOTX 0 +#define BLANK_CHOTY 0 static const unsigned char blank_cdata[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; static const unsigned char blank_cmask[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; diff --git a/src/events/scancodes_ascii.h b/src/events/scancodes_ascii.h index c30cddca0..ef58872ca 100644 --- a/src/events/scancodes_ascii.h +++ b/src/events/scancodes_ascii.h @@ -37,134 +37,134 @@ typedef struct } ASCIIKeyInfo; static ASCIIKeyInfo SDL_ASCIIKeyInfoTable[] = { -/* 0 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 1 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 2 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 3 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 4 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 5 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 6 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 7 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 8 */ { SDL_SCANCODE_BACKSPACE, 0 }, -/* 9 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 10 */ { SDL_SCANCODE_RETURN, 0 }, -/* 11 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 12 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 13 */ { SDL_SCANCODE_RETURN, 0 }, -/* 14 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 15 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 16 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 17 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 18 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 19 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 20 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 21 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 22 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 23 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 24 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 25 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 26 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 27 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 28 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 29 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 30 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 31 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 32 */ { SDL_SCANCODE_SPACE, 0 }, -/* 33 */ { SDL_SCANCODE_1, KMOD_SHIFT }, /* plus shift modifier '!' */ -/* 34 */ { SDL_SCANCODE_APOSTROPHE, KMOD_SHIFT }, /* plus shift modifier '"' */ -/* 35 */ { SDL_SCANCODE_3, KMOD_SHIFT }, /* plus shift modifier '#' */ -/* 36 */ { SDL_SCANCODE_4, KMOD_SHIFT }, /* plus shift modifier '$' */ -/* 37 */ { SDL_SCANCODE_5, KMOD_SHIFT }, /* plus shift modifier '%' */ -/* 38 */ { SDL_SCANCODE_7, KMOD_SHIFT }, /* plus shift modifier '&' */ -/* 39 */ { SDL_SCANCODE_APOSTROPHE, 0 }, /* ''' */ -/* 40 */ { SDL_SCANCODE_9, KMOD_SHIFT }, /* plus shift modifier '(' */ -/* 41 */ { SDL_SCANCODE_0, KMOD_SHIFT }, /* plus shift modifier ')' */ -/* 42 */ { SDL_SCANCODE_8, KMOD_SHIFT }, /* '*' */ -/* 43 */ { SDL_SCANCODE_EQUALS, KMOD_SHIFT }, /* plus shift modifier '+' */ -/* 44 */ { SDL_SCANCODE_COMMA, 0 }, /* ',' */ -/* 45 */ { SDL_SCANCODE_MINUS, 0 }, /* '-' */ -/* 46 */ { SDL_SCANCODE_PERIOD, 0 }, /* '.' */ -/* 47 */ { SDL_SCANCODE_SLASH, 0 }, /* '/' */ -/* 48 */ { SDL_SCANCODE_0, 0 }, -/* 49 */ { SDL_SCANCODE_1, 0 }, -/* 50 */ { SDL_SCANCODE_2, 0 }, -/* 51 */ { SDL_SCANCODE_3, 0 }, -/* 52 */ { SDL_SCANCODE_4, 0 }, -/* 53 */ { SDL_SCANCODE_5, 0 }, -/* 54 */ { SDL_SCANCODE_6, 0 }, -/* 55 */ { SDL_SCANCODE_7, 0 }, -/* 56 */ { SDL_SCANCODE_8, 0 }, -/* 57 */ { SDL_SCANCODE_9, 0 }, -/* 58 */ { SDL_SCANCODE_SEMICOLON, KMOD_SHIFT }, /* plus shift modifier ';' */ -/* 59 */ { SDL_SCANCODE_SEMICOLON, 0 }, -/* 60 */ { SDL_SCANCODE_COMMA, KMOD_SHIFT }, /* plus shift modifier '<' */ -/* 61 */ { SDL_SCANCODE_EQUALS, 0 }, -/* 62 */ { SDL_SCANCODE_PERIOD, KMOD_SHIFT }, /* plus shift modifier '>' */ -/* 63 */ { SDL_SCANCODE_SLASH, KMOD_SHIFT }, /* plus shift modifier '?' */ -/* 64 */ { SDL_SCANCODE_2, KMOD_SHIFT }, /* plus shift modifier '@' */ -/* 65 */ { SDL_SCANCODE_A, KMOD_SHIFT }, /* all the following need shift modifiers */ -/* 66 */ { SDL_SCANCODE_B, KMOD_SHIFT }, -/* 67 */ { SDL_SCANCODE_C, KMOD_SHIFT }, -/* 68 */ { SDL_SCANCODE_D, KMOD_SHIFT }, -/* 69 */ { SDL_SCANCODE_E, KMOD_SHIFT }, -/* 70 */ { SDL_SCANCODE_F, KMOD_SHIFT }, -/* 71 */ { SDL_SCANCODE_G, KMOD_SHIFT }, -/* 72 */ { SDL_SCANCODE_H, KMOD_SHIFT }, -/* 73 */ { SDL_SCANCODE_I, KMOD_SHIFT }, -/* 74 */ { SDL_SCANCODE_J, KMOD_SHIFT }, -/* 75 */ { SDL_SCANCODE_K, KMOD_SHIFT }, -/* 76 */ { SDL_SCANCODE_L, KMOD_SHIFT }, -/* 77 */ { SDL_SCANCODE_M, KMOD_SHIFT }, -/* 78 */ { SDL_SCANCODE_N, KMOD_SHIFT }, -/* 79 */ { SDL_SCANCODE_O, KMOD_SHIFT }, -/* 80 */ { SDL_SCANCODE_P, KMOD_SHIFT }, -/* 81 */ { SDL_SCANCODE_Q, KMOD_SHIFT }, -/* 82 */ { SDL_SCANCODE_R, KMOD_SHIFT }, -/* 83 */ { SDL_SCANCODE_S, KMOD_SHIFT }, -/* 84 */ { SDL_SCANCODE_T, KMOD_SHIFT }, -/* 85 */ { SDL_SCANCODE_U, KMOD_SHIFT }, -/* 86 */ { SDL_SCANCODE_V, KMOD_SHIFT }, -/* 87 */ { SDL_SCANCODE_W, KMOD_SHIFT }, -/* 88 */ { SDL_SCANCODE_X, KMOD_SHIFT }, -/* 89 */ { SDL_SCANCODE_Y, KMOD_SHIFT }, -/* 90 */ { SDL_SCANCODE_Z, KMOD_SHIFT }, -/* 91 */ { SDL_SCANCODE_LEFTBRACKET, 0 }, -/* 92 */ { SDL_SCANCODE_BACKSLASH, 0 }, -/* 93 */ { SDL_SCANCODE_RIGHTBRACKET, 0 }, -/* 94 */ { SDL_SCANCODE_6, KMOD_SHIFT }, /* plus shift modifier '^' */ -/* 95 */ { SDL_SCANCODE_MINUS, KMOD_SHIFT }, /* plus shift modifier '_' */ -/* 96 */ { SDL_SCANCODE_GRAVE, KMOD_SHIFT }, /* '`' */ -/* 97 */ { SDL_SCANCODE_A, 0 }, -/* 98 */ { SDL_SCANCODE_B, 0 }, -/* 99 */ { SDL_SCANCODE_C, 0 }, -/* 100 */ { SDL_SCANCODE_D, 0 }, -/* 101 */ { SDL_SCANCODE_E, 0 }, -/* 102 */ { SDL_SCANCODE_F, 0 }, -/* 103 */ { SDL_SCANCODE_G, 0 }, -/* 104 */ { SDL_SCANCODE_H, 0 }, -/* 105 */ { SDL_SCANCODE_I, 0 }, -/* 106 */ { SDL_SCANCODE_J, 0 }, -/* 107 */ { SDL_SCANCODE_K, 0 }, -/* 108 */ { SDL_SCANCODE_L, 0 }, -/* 109 */ { SDL_SCANCODE_M, 0 }, -/* 110 */ { SDL_SCANCODE_N, 0 }, -/* 111 */ { SDL_SCANCODE_O, 0 }, -/* 112 */ { SDL_SCANCODE_P, 0 }, -/* 113 */ { SDL_SCANCODE_Q, 0 }, -/* 114 */ { SDL_SCANCODE_R, 0 }, -/* 115 */ { SDL_SCANCODE_S, 0 }, -/* 116 */ { SDL_SCANCODE_T, 0 }, -/* 117 */ { SDL_SCANCODE_U, 0 }, -/* 118 */ { SDL_SCANCODE_V, 0 }, -/* 119 */ { SDL_SCANCODE_W, 0 }, -/* 120 */ { SDL_SCANCODE_X, 0 }, -/* 121 */ { SDL_SCANCODE_Y, 0 }, -/* 122 */ { SDL_SCANCODE_Z, 0 }, -/* 123 */ { SDL_SCANCODE_LEFTBRACKET, KMOD_SHIFT }, /* plus shift modifier '{' */ -/* 124 */ { SDL_SCANCODE_BACKSLASH, KMOD_SHIFT }, /* plus shift modifier '|' */ -/* 125 */ { SDL_SCANCODE_RIGHTBRACKET, KMOD_SHIFT }, /* plus shift modifier '}' */ -/* 126 */ { SDL_SCANCODE_GRAVE, KMOD_SHIFT }, /* plus shift modifier '~' */ -/* 127 */ { SDL_SCANCODE_BACKSPACE, KMOD_SHIFT } + /* 0 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 1 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 2 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 3 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 4 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 5 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 6 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 7 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 8 */ { SDL_SCANCODE_BACKSPACE, 0 }, + /* 9 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 10 */ { SDL_SCANCODE_RETURN, 0 }, + /* 11 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 12 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 13 */ { SDL_SCANCODE_RETURN, 0 }, + /* 14 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 15 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 16 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 17 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 18 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 19 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 20 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 21 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 22 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 23 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 24 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 25 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 26 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 27 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 28 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 29 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 30 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 31 */ { SDL_SCANCODE_UNKNOWN, 0 }, + /* 32 */ { SDL_SCANCODE_SPACE, 0 }, + /* 33 */ { SDL_SCANCODE_1, KMOD_SHIFT }, /* plus shift modifier '!' */ + /* 34 */ { SDL_SCANCODE_APOSTROPHE, KMOD_SHIFT }, /* plus shift modifier '"' */ + /* 35 */ { SDL_SCANCODE_3, KMOD_SHIFT }, /* plus shift modifier '#' */ + /* 36 */ { SDL_SCANCODE_4, KMOD_SHIFT }, /* plus shift modifier '$' */ + /* 37 */ { SDL_SCANCODE_5, KMOD_SHIFT }, /* plus shift modifier '%' */ + /* 38 */ { SDL_SCANCODE_7, KMOD_SHIFT }, /* plus shift modifier '&' */ + /* 39 */ { SDL_SCANCODE_APOSTROPHE, 0 }, /* ''' */ + /* 40 */ { SDL_SCANCODE_9, KMOD_SHIFT }, /* plus shift modifier '(' */ + /* 41 */ { SDL_SCANCODE_0, KMOD_SHIFT }, /* plus shift modifier ')' */ + /* 42 */ { SDL_SCANCODE_8, KMOD_SHIFT }, /* '*' */ + /* 43 */ { SDL_SCANCODE_EQUALS, KMOD_SHIFT }, /* plus shift modifier '+' */ + /* 44 */ { SDL_SCANCODE_COMMA, 0 }, /* ',' */ + /* 45 */ { SDL_SCANCODE_MINUS, 0 }, /* '-' */ + /* 46 */ { SDL_SCANCODE_PERIOD, 0 }, /* '.' */ + /* 47 */ { SDL_SCANCODE_SLASH, 0 }, /* '/' */ + /* 48 */ { SDL_SCANCODE_0, 0 }, + /* 49 */ { SDL_SCANCODE_1, 0 }, + /* 50 */ { SDL_SCANCODE_2, 0 }, + /* 51 */ { SDL_SCANCODE_3, 0 }, + /* 52 */ { SDL_SCANCODE_4, 0 }, + /* 53 */ { SDL_SCANCODE_5, 0 }, + /* 54 */ { SDL_SCANCODE_6, 0 }, + /* 55 */ { SDL_SCANCODE_7, 0 }, + /* 56 */ { SDL_SCANCODE_8, 0 }, + /* 57 */ { SDL_SCANCODE_9, 0 }, + /* 58 */ { SDL_SCANCODE_SEMICOLON, KMOD_SHIFT }, /* plus shift modifier ';' */ + /* 59 */ { SDL_SCANCODE_SEMICOLON, 0 }, + /* 60 */ { SDL_SCANCODE_COMMA, KMOD_SHIFT }, /* plus shift modifier '<' */ + /* 61 */ { SDL_SCANCODE_EQUALS, 0 }, + /* 62 */ { SDL_SCANCODE_PERIOD, KMOD_SHIFT }, /* plus shift modifier '>' */ + /* 63 */ { SDL_SCANCODE_SLASH, KMOD_SHIFT }, /* plus shift modifier '?' */ + /* 64 */ { SDL_SCANCODE_2, KMOD_SHIFT }, /* plus shift modifier '@' */ + /* 65 */ { SDL_SCANCODE_A, KMOD_SHIFT }, /* all the following need shift modifiers */ + /* 66 */ { SDL_SCANCODE_B, KMOD_SHIFT }, + /* 67 */ { SDL_SCANCODE_C, KMOD_SHIFT }, + /* 68 */ { SDL_SCANCODE_D, KMOD_SHIFT }, + /* 69 */ { SDL_SCANCODE_E, KMOD_SHIFT }, + /* 70 */ { SDL_SCANCODE_F, KMOD_SHIFT }, + /* 71 */ { SDL_SCANCODE_G, KMOD_SHIFT }, + /* 72 */ { SDL_SCANCODE_H, KMOD_SHIFT }, + /* 73 */ { SDL_SCANCODE_I, KMOD_SHIFT }, + /* 74 */ { SDL_SCANCODE_J, KMOD_SHIFT }, + /* 75 */ { SDL_SCANCODE_K, KMOD_SHIFT }, + /* 76 */ { SDL_SCANCODE_L, KMOD_SHIFT }, + /* 77 */ { SDL_SCANCODE_M, KMOD_SHIFT }, + /* 78 */ { SDL_SCANCODE_N, KMOD_SHIFT }, + /* 79 */ { SDL_SCANCODE_O, KMOD_SHIFT }, + /* 80 */ { SDL_SCANCODE_P, KMOD_SHIFT }, + /* 81 */ { SDL_SCANCODE_Q, KMOD_SHIFT }, + /* 82 */ { SDL_SCANCODE_R, KMOD_SHIFT }, + /* 83 */ { SDL_SCANCODE_S, KMOD_SHIFT }, + /* 84 */ { SDL_SCANCODE_T, KMOD_SHIFT }, + /* 85 */ { SDL_SCANCODE_U, KMOD_SHIFT }, + /* 86 */ { SDL_SCANCODE_V, KMOD_SHIFT }, + /* 87 */ { SDL_SCANCODE_W, KMOD_SHIFT }, + /* 88 */ { SDL_SCANCODE_X, KMOD_SHIFT }, + /* 89 */ { SDL_SCANCODE_Y, KMOD_SHIFT }, + /* 90 */ { SDL_SCANCODE_Z, KMOD_SHIFT }, + /* 91 */ { SDL_SCANCODE_LEFTBRACKET, 0 }, + /* 92 */ { SDL_SCANCODE_BACKSLASH, 0 }, + /* 93 */ { SDL_SCANCODE_RIGHTBRACKET, 0 }, + /* 94 */ { SDL_SCANCODE_6, KMOD_SHIFT }, /* plus shift modifier '^' */ + /* 95 */ { SDL_SCANCODE_MINUS, KMOD_SHIFT }, /* plus shift modifier '_' */ + /* 96 */ { SDL_SCANCODE_GRAVE, KMOD_SHIFT }, /* '`' */ + /* 97 */ { SDL_SCANCODE_A, 0 }, + /* 98 */ { SDL_SCANCODE_B, 0 }, + /* 99 */ { SDL_SCANCODE_C, 0 }, + /* 100 */ { SDL_SCANCODE_D, 0 }, + /* 101 */ { SDL_SCANCODE_E, 0 }, + /* 102 */ { SDL_SCANCODE_F, 0 }, + /* 103 */ { SDL_SCANCODE_G, 0 }, + /* 104 */ { SDL_SCANCODE_H, 0 }, + /* 105 */ { SDL_SCANCODE_I, 0 }, + /* 106 */ { SDL_SCANCODE_J, 0 }, + /* 107 */ { SDL_SCANCODE_K, 0 }, + /* 108 */ { SDL_SCANCODE_L, 0 }, + /* 109 */ { SDL_SCANCODE_M, 0 }, + /* 110 */ { SDL_SCANCODE_N, 0 }, + /* 111 */ { SDL_SCANCODE_O, 0 }, + /* 112 */ { SDL_SCANCODE_P, 0 }, + /* 113 */ { SDL_SCANCODE_Q, 0 }, + /* 114 */ { SDL_SCANCODE_R, 0 }, + /* 115 */ { SDL_SCANCODE_S, 0 }, + /* 116 */ { SDL_SCANCODE_T, 0 }, + /* 117 */ { SDL_SCANCODE_U, 0 }, + /* 118 */ { SDL_SCANCODE_V, 0 }, + /* 119 */ { SDL_SCANCODE_W, 0 }, + /* 120 */ { SDL_SCANCODE_X, 0 }, + /* 121 */ { SDL_SCANCODE_Y, 0 }, + /* 122 */ { SDL_SCANCODE_Z, 0 }, + /* 123 */ { SDL_SCANCODE_LEFTBRACKET, KMOD_SHIFT }, /* plus shift modifier '{' */ + /* 124 */ { SDL_SCANCODE_BACKSLASH, KMOD_SHIFT }, /* plus shift modifier '|' */ + /* 125 */ { SDL_SCANCODE_RIGHTBRACKET, KMOD_SHIFT }, /* plus shift modifier '}' */ + /* 126 */ { SDL_SCANCODE_GRAVE, KMOD_SHIFT }, /* plus shift modifier '~' */ + /* 127 */ { SDL_SCANCODE_BACKSPACE, KMOD_SHIFT } }; /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c index 7c4d683b0..6f95881e6 100644 --- a/src/file/SDL_rwops.c +++ b/src/file/SDL_rwops.c @@ -74,10 +74,9 @@ #define INVALID_SET_FILE_POINTER 0xFFFFFFFF #endif -#define READAHEAD_BUFFER_SIZE 1024 +#define READAHEAD_BUFFER_SIZE 1024 -static int SDLCALL -windows_file_open(SDL_RWops * context, const char *filename, const char *mode) +static int SDLCALL windows_file_open(SDL_RWops *context, const char *filename, const char *mode) { #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) UINT old_error_mode; @@ -91,7 +90,7 @@ windows_file_open(SDL_RWops * context, const char *filename, const char *mode) return -1; /* failed (invalid call) */ } - context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* mark this as unusable */ + context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* mark this as unusable */ context->hidden.windowsio.buffer.data = NULL; context->hidden.windowsio.buffer.size = 0; context->hidden.windowsio.buffer.left = 0; @@ -105,19 +104,17 @@ windows_file_open(SDL_RWops * context, const char *filename, const char *mode) must_exist = (SDL_strchr(mode, 'r') != NULL) ? OPEN_EXISTING : 0; truncate = (SDL_strchr(mode, 'w') != NULL) ? CREATE_ALWAYS : 0; - r_right = (SDL_strchr(mode, '+') != NULL - || must_exist) ? GENERIC_READ : 0; + r_right = (SDL_strchr(mode, '+') != NULL || must_exist) ? GENERIC_READ : 0; a_mode = (SDL_strchr(mode, 'a') != NULL) ? OPEN_ALWAYS : 0; - w_right = (a_mode || SDL_strchr(mode, '+') - || truncate) ? GENERIC_WRITE : 0; + w_right = (a_mode || SDL_strchr(mode, '+') || truncate) ? GENERIC_WRITE : 0; if (!r_right && !w_right) { return -1; /* inconsistent mode */ } - /* failed (invalid call) */ + /* failed (invalid call) */ context->hidden.windowsio.buffer.data = - (char *) SDL_malloc(READAHEAD_BUFFER_SIZE); + (char *)SDL_malloc(READAHEAD_BUFFER_SIZE); if (!context->hidden.windowsio.buffer.data) { return SDL_OutOfMemory(); } @@ -145,16 +142,15 @@ windows_file_open(SDL_RWops * context, const char *filename, const char *mode) SDL_free(context->hidden.windowsio.buffer.data); context->hidden.windowsio.buffer.data = NULL; SDL_SetError("Couldn't open %s", filename); - return -2; /* failed (CreateFile) */ + return -2; /* failed (CreateFile) */ } context->hidden.windowsio.h = h; context->hidden.windowsio.append = a_mode ? SDL_TRUE : SDL_FALSE; - return 0; /* ok */ + return 0; /* ok */ } -static Sint64 SDLCALL -windows_file_size(SDL_RWops * context) +static Sint64 SDLCALL windows_file_size(SDL_RWops *context) { LARGE_INTEGER size; @@ -169,8 +165,7 @@ windows_file_size(SDL_RWops * context) return size.QuadPart; } -static Sint64 SDLCALL -windows_file_seek(SDL_RWops * context, Sint64 offset, int whence) +static Sint64 SDLCALL windows_file_seek(SDL_RWops *context, Sint64 offset, int whence) { DWORD windowswhence; LARGE_INTEGER windowsoffset; @@ -207,7 +202,7 @@ windows_file_seek(SDL_RWops * context, Sint64 offset, int whence) } static size_t SDLCALL -windows_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) +windows_file_read(SDL_RWops *context, void *ptr, size_t size, size_t maxnum) { size_t total_need; size_t total_read = 0; @@ -221,9 +216,9 @@ windows_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) } if (context->hidden.windowsio.buffer.left > 0) { - void *data = (char *) context->hidden.windowsio.buffer.data + - context->hidden.windowsio.buffer.size - - context->hidden.windowsio.buffer.left; + void *data = (char *)context->hidden.windowsio.buffer.data + + context->hidden.windowsio.buffer.size - + context->hidden.windowsio.buffer.left; read_ahead = SDL_min(total_need, context->hidden.windowsio.buffer.left); SDL_memcpy(ptr, data, read_ahead); @@ -232,26 +227,24 @@ windows_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) if (read_ahead == total_need) { return maxnum; } - ptr = (char *) ptr + read_ahead; + ptr = (char *)ptr + read_ahead; total_need -= read_ahead; total_read += read_ahead; } if (total_need < READAHEAD_BUFFER_SIZE) { - if (!ReadFile - (context->hidden.windowsio.h, context->hidden.windowsio.buffer.data, - READAHEAD_BUFFER_SIZE, &byte_read, NULL)) { + if (!ReadFile(context->hidden.windowsio.h, context->hidden.windowsio.buffer.data, + READAHEAD_BUFFER_SIZE, &byte_read, NULL)) { SDL_Error(SDL_EFREAD); return 0; } - read_ahead = SDL_min(total_need, (int) byte_read); + read_ahead = SDL_min(total_need, (int)byte_read); SDL_memcpy(ptr, context->hidden.windowsio.buffer.data, read_ahead); context->hidden.windowsio.buffer.size = byte_read; context->hidden.windowsio.buffer.left = byte_read - read_ahead; total_read += read_ahead; } else { - if (!ReadFile - (context->hidden.windowsio.h, ptr, (DWORD)total_need, &byte_read, NULL)) { + if (!ReadFile(context->hidden.windowsio.h, ptr, (DWORD)total_need, &byte_read, NULL)) { SDL_Error(SDL_EFREAD); return 0; } @@ -261,8 +254,8 @@ windows_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) } static size_t SDLCALL -windows_file_write(SDL_RWops * context, const void *ptr, size_t size, - size_t num) +windows_file_write(SDL_RWops *context, const void *ptr, size_t size, + size_t num) { size_t total_bytes; @@ -291,8 +284,7 @@ windows_file_write(SDL_RWops * context, const void *ptr, size_t size, } } - if (!WriteFile - (context->hidden.windowsio.h, ptr, (DWORD)total_bytes, &byte_written, NULL)) { + if (!WriteFile(context->hidden.windowsio.h, ptr, (DWORD)total_bytes, &byte_written, NULL)) { SDL_Error(SDL_EFWRITE); return 0; } @@ -301,14 +293,13 @@ windows_file_write(SDL_RWops * context, const void *ptr, size_t size, return nwritten; } -static int SDLCALL -windows_file_close(SDL_RWops * context) +static int SDLCALL windows_file_close(SDL_RWops *context) { if (context) { if (context->hidden.windowsio.h != INVALID_HANDLE_VALUE) { CloseHandle(context->hidden.windowsio.h); - context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* to be sure */ + context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* to be sure */ } SDL_free(context->hidden.windowsio.buffer.data); context->hidden.windowsio.buffer.data = NULL; @@ -321,12 +312,12 @@ windows_file_close(SDL_RWops * context) #ifdef HAVE_STDIO_H #ifdef HAVE_FOPEN64 -#define fopen fopen64 +#define fopen fopen64 #endif #ifdef HAVE_FSEEKO64 #define fseek_off_t off64_t -#define fseek fseeko64 -#define ftell ftello64 +#define fseek fseeko64 +#define ftell ftello64 #elif defined(HAVE_FSEEKO) #if defined(OFF_MIN) && defined(OFF_MAX) #define FSEEK_OFF_MIN OFF_MIN @@ -339,15 +330,15 @@ windows_file_close(SDL_RWops * context) * and eliminate the dead code if off_t has 64 bits. */ #define FSEEK_OFF_MAX (((((off_t)1 << (sizeof(off_t) * CHAR_BIT - 2)) - 1) << 1) + 1) -#define FSEEK_OFF_MIN (-(FSEEK_OFF_MAX) - 1) +#define FSEEK_OFF_MIN (-(FSEEK_OFF_MAX)-1) #endif #define fseek_off_t off_t -#define fseek fseeko -#define ftell ftello +#define fseek fseeko +#define ftell ftello #elif defined(HAVE__FSEEKI64) #define fseek_off_t __int64 -#define fseek _fseeki64 -#define ftell _ftelli64 +#define fseek _fseeki64 +#define ftell _ftelli64 #else #ifdef HAVE_LIMITS_H #define FSEEK_OFF_MIN LONG_MIN @@ -373,8 +364,7 @@ stdio_size(SDL_RWops * context) return size; } -static Sint64 SDLCALL -stdio_seek(SDL_RWops * context, Sint64 offset, int whence) +static Sint64 SDLCALL stdio_seek(SDL_RWops *context, Sint64 offset, int whence) { int stdiowhence; @@ -409,7 +399,7 @@ stdio_seek(SDL_RWops * context, Sint64 offset, int whence) } static size_t SDLCALL -stdio_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) +stdio_read(SDL_RWops *context, void *ptr, size_t size, size_t maxnum) { size_t nread; @@ -421,7 +411,7 @@ stdio_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) } static size_t SDLCALL -stdio_write(SDL_RWops * context, const void *ptr, size_t size, size_t num) +stdio_write(SDL_RWops *context, const void *ptr, size_t size, size_t num) { size_t nwrote; @@ -432,8 +422,7 @@ stdio_write(SDL_RWops * context, const void *ptr, size_t size, size_t num) return nwrote; } -static int SDLCALL -stdio_close(SDL_RWops * context) +static int SDLCALL stdio_close(SDL_RWops *context) { int status = 0; if (context) { @@ -451,14 +440,12 @@ stdio_close(SDL_RWops * context) /* Functions to read/write memory pointers */ -static Sint64 SDLCALL -mem_size(SDL_RWops * context) +static Sint64 SDLCALL mem_size(SDL_RWops *context) { return (Sint64)(context->hidden.mem.stop - context->hidden.mem.base); } -static Sint64 SDLCALL -mem_seek(SDL_RWops * context, Sint64 offset, int whence) +static Sint64 SDLCALL mem_seek(SDL_RWops *context, Sint64 offset, int whence) { Uint8 *newpos; @@ -486,7 +473,7 @@ mem_seek(SDL_RWops * context, Sint64 offset, int whence) } static size_t SDLCALL -mem_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) +mem_read(SDL_RWops *context, void *ptr, size_t size, size_t maxnum) { size_t total_bytes; size_t mem_available; @@ -508,7 +495,7 @@ mem_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) } static size_t SDLCALL -mem_write(SDL_RWops * context, const void *ptr, size_t size, size_t num) +mem_write(SDL_RWops *context, const void *ptr, size_t size, size_t num) { if ((context->hidden.mem.here + (num * size)) > context->hidden.mem.stop) { num = (context->hidden.mem.stop - context->hidden.mem.here) / size; @@ -519,14 +506,13 @@ mem_write(SDL_RWops * context, const void *ptr, size_t size, size_t num) } static size_t SDLCALL -mem_writeconst(SDL_RWops * context, const void *ptr, size_t size, size_t num) +mem_writeconst(SDL_RWops *context, const void *ptr, size_t size, size_t num) { SDL_SetError("Can't write to read-only memory"); return 0; } -static int SDLCALL -mem_close(SDL_RWops * context) +static int SDLCALL mem_close(SDL_RWops *context) { if (context) { SDL_FreeRW(context); @@ -534,7 +520,6 @@ mem_close(SDL_RWops * context) return 0; } - /* Functions to create SDL_RWops structures from various data sources */ SDL_RWops * @@ -607,16 +592,16 @@ SDL_RWFromFile(const char *file, const char *mode) rwops->type = SDL_RWOPS_WINFILE; #elif HAVE_STDIO_H { - #if __APPLE__ && !SDL_FILE_DISABLED // TODO: add dummy? +#if __APPLE__ && !SDL_FILE_DISABLED // TODO: add dummy? FILE *fp = SDL_OpenFPFromBundleOrFallback(file, mode); - #elif __WINRT__ +#elif __WINRT__ FILE *fp = NULL; fopen_s(&fp, file, mode); - #elif __3DS__ +#elif __3DS__ FILE *fp = N3DS_FileOpen(file, mode); - #else +#else FILE *fp = fopen(file, mode); - #endif +#endif if (fp == NULL) { SDL_SetError("Couldn't open %s", file); } else { @@ -663,12 +648,12 @@ SDL_RWFromMem(void *mem, int size) { SDL_RWops *rwops = NULL; if (mem == NULL) { - SDL_InvalidParamError("mem"); - return rwops; + SDL_InvalidParamError("mem"); + return rwops; } if (!size) { - SDL_InvalidParamError("size"); - return rwops; + SDL_InvalidParamError("size"); + return rwops; } rwops = SDL_AllocRW(); @@ -678,7 +663,7 @@ SDL_RWFromMem(void *mem, int size) rwops->read = mem_read; rwops->write = mem_write; rwops->close = mem_close; - rwops->hidden.mem.base = (Uint8 *) mem; + rwops->hidden.mem.base = (Uint8 *)mem; rwops->hidden.mem.here = rwops->hidden.mem.base; rwops->hidden.mem.stop = rwops->hidden.mem.base + size; rwops->type = SDL_RWOPS_MEMORY; @@ -691,12 +676,12 @@ SDL_RWFromConstMem(const void *mem, int size) { SDL_RWops *rwops = NULL; if (mem == NULL) { - SDL_InvalidParamError("mem"); - return rwops; + SDL_InvalidParamError("mem"); + return rwops; } if (!size) { - SDL_InvalidParamError("size"); - return rwops; + SDL_InvalidParamError("size"); + return rwops; } rwops = SDL_AllocRW(); @@ -706,7 +691,7 @@ SDL_RWFromConstMem(const void *mem, int size) rwops->read = mem_read; rwops->write = mem_writeconst; rwops->close = mem_close; - rwops->hidden.mem.base = (Uint8 *) mem; + rwops->hidden.mem.base = (Uint8 *)mem; rwops->hidden.mem.here = rwops->hidden.mem.base; rwops->hidden.mem.stop = rwops->hidden.mem.base + size; rwops->type = SDL_RWOPS_MEMORY_RO; @@ -719,7 +704,7 @@ SDL_AllocRW(void) { SDL_RWops *area; - area = (SDL_RWops *) SDL_malloc(sizeof *area); + area = (SDL_RWops *)SDL_malloc(sizeof *area); if (area == NULL) { SDL_OutOfMemory(); } else { @@ -728,15 +713,14 @@ SDL_AllocRW(void) return area; } -void -SDL_FreeRW(SDL_RWops * area) +void SDL_FreeRW(SDL_RWops *area) { SDL_free(area); } /* Load all the data from an SDL data stream */ void * -SDL_LoadFile_RW(SDL_RWops * src, size_t *datasize, int freesrc) +SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, int freesrc) { const int FILE_CHUNK_SIZE = 1024; Sint64 size; @@ -768,7 +752,7 @@ SDL_LoadFile_RW(SDL_RWops * src, size_t *datasize, int freesrc) data = newdata; } - size_read = SDL_RWread(src, (char *)data+size_total, 1, (size_t)(size-size_total)); + size_read = SDL_RWread(src, (char *)data + size_total, 1, (size_t)(size - size_total)); if (size_read == 0) { break; } @@ -790,7 +774,7 @@ done: void * SDL_LoadFile(const char *file, size_t *datasize) { - return SDL_LoadFile_RW(SDL_RWFromFile(file, "rb"), datasize, 1); + return SDL_LoadFile_RW(SDL_RWFromFile(file, "rb"), datasize, 1); } Sint64 @@ -823,120 +807,118 @@ SDL_RWwrite(SDL_RWops *context, const void *ptr, size_t size, size_t num) return context->write(context, ptr, size, num); } -int -SDL_RWclose(SDL_RWops *context) +int SDL_RWclose(SDL_RWops *context) { return context->close(context); } /* Functions for dynamically reading and writing endian-specific values */ -Uint8 -SDL_ReadU8(SDL_RWops * src) +Uint8 SDL_ReadU8(SDL_RWops *src) { Uint8 value = 0; - SDL_RWread(src, &value, sizeof (value), 1); + SDL_RWread(src, &value, sizeof(value), 1); return value; } Uint16 -SDL_ReadLE16(SDL_RWops * src) +SDL_ReadLE16(SDL_RWops *src) { Uint16 value = 0; - SDL_RWread(src, &value, sizeof (value), 1); + SDL_RWread(src, &value, sizeof(value), 1); return SDL_SwapLE16(value); } Uint16 -SDL_ReadBE16(SDL_RWops * src) +SDL_ReadBE16(SDL_RWops *src) { Uint16 value = 0; - SDL_RWread(src, &value, sizeof (value), 1); + SDL_RWread(src, &value, sizeof(value), 1); return SDL_SwapBE16(value); } Uint32 -SDL_ReadLE32(SDL_RWops * src) +SDL_ReadLE32(SDL_RWops *src) { Uint32 value = 0; - SDL_RWread(src, &value, sizeof (value), 1); + SDL_RWread(src, &value, sizeof(value), 1); return SDL_SwapLE32(value); } Uint32 -SDL_ReadBE32(SDL_RWops * src) +SDL_ReadBE32(SDL_RWops *src) { Uint32 value = 0; - SDL_RWread(src, &value, sizeof (value), 1); + SDL_RWread(src, &value, sizeof(value), 1); return SDL_SwapBE32(value); } Uint64 -SDL_ReadLE64(SDL_RWops * src) +SDL_ReadLE64(SDL_RWops *src) { Uint64 value = 0; - SDL_RWread(src, &value, sizeof (value), 1); + SDL_RWread(src, &value, sizeof(value), 1); return SDL_SwapLE64(value); } Uint64 -SDL_ReadBE64(SDL_RWops * src) +SDL_ReadBE64(SDL_RWops *src) { Uint64 value = 0; - SDL_RWread(src, &value, sizeof (value), 1); + SDL_RWread(src, &value, sizeof(value), 1); return SDL_SwapBE64(value); } size_t -SDL_WriteU8(SDL_RWops * dst, Uint8 value) +SDL_WriteU8(SDL_RWops *dst, Uint8 value) { return SDL_RWwrite(dst, &value, sizeof(value), 1); } size_t -SDL_WriteLE16(SDL_RWops * dst, Uint16 value) +SDL_WriteLE16(SDL_RWops *dst, Uint16 value) { const Uint16 swapped = SDL_SwapLE16(value); return SDL_RWwrite(dst, &swapped, sizeof(swapped), 1); } size_t -SDL_WriteBE16(SDL_RWops * dst, Uint16 value) +SDL_WriteBE16(SDL_RWops *dst, Uint16 value) { const Uint16 swapped = SDL_SwapBE16(value); return SDL_RWwrite(dst, &swapped, sizeof(swapped), 1); } size_t -SDL_WriteLE32(SDL_RWops * dst, Uint32 value) +SDL_WriteLE32(SDL_RWops *dst, Uint32 value) { const Uint32 swapped = SDL_SwapLE32(value); return SDL_RWwrite(dst, &swapped, sizeof(swapped), 1); } size_t -SDL_WriteBE32(SDL_RWops * dst, Uint32 value) +SDL_WriteBE32(SDL_RWops *dst, Uint32 value) { const Uint32 swapped = SDL_SwapBE32(value); return SDL_RWwrite(dst, &swapped, sizeof(swapped), 1); } size_t -SDL_WriteLE64(SDL_RWops * dst, Uint64 value) +SDL_WriteLE64(SDL_RWops *dst, Uint64 value) { const Uint64 swapped = SDL_SwapLE64(value); return SDL_RWwrite(dst, &swapped, sizeof(swapped), 1); } size_t -SDL_WriteBE64(SDL_RWops * dst, Uint64 value) +SDL_WriteBE64(SDL_RWops *dst, Uint64 value) { const Uint64 swapped = SDL_SwapBE64(value); return SDL_RWwrite(dst, &swapped, sizeof(swapped), 1); diff --git a/src/file/cocoa/SDL_rwopsbundlesupport.h b/src/file/cocoa/SDL_rwopsbundlesupport.h index b77b53e80..722611843 100644 --- a/src/file/cocoa/SDL_rwopsbundlesupport.h +++ b/src/file/cocoa/SDL_rwopsbundlesupport.h @@ -25,6 +25,6 @@ #ifndef SDL_rwopsbundlesupport_h #define SDL_rwopsbundlesupport_h -FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode); +FILE *SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode); #endif #endif diff --git a/src/file/cocoa/SDL_rwopsbundlesupport.m b/src/file/cocoa/SDL_rwopsbundlesupport.m index 55e104a95..55104a47b 100644 --- a/src/file/cocoa/SDL_rwopsbundlesupport.m +++ b/src/file/cocoa/SDL_rwopsbundlesupport.m @@ -32,34 +32,35 @@ but we would somehow need to know what the bundle identifiers we need to search are. Also, note the bundle layouts are different for iPhone and Mac. */ -FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode) -{ @autoreleasepool +FILE *SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode) { - FILE* fp = NULL; - NSFileManager* file_manager; - NSString* resource_path; - NSString* ns_string_file_component; - NSString* full_path_with_file_to_try; + @autoreleasepool { + FILE *fp = NULL; + NSFileManager *file_manager; + NSString *resource_path; + NSString *ns_string_file_component; + NSString *full_path_with_file_to_try; - /* If the file mode is writable, skip all the bundle stuff because generally the bundle is read-only. */ - if(strcmp("r", mode) && strcmp("rb", mode)) { - return fopen(file, mode); + /* If the file mode is writable, skip all the bundle stuff because generally the bundle is read-only. */ + if (strcmp("r", mode) && strcmp("rb", mode)) { + return fopen(file, mode); + } + + file_manager = [NSFileManager defaultManager]; + resource_path = [[NSBundle mainBundle] resourcePath]; + + ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)]; + + full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component]; + if ([file_manager fileExistsAtPath:full_path_with_file_to_try]) { + fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode); + } else { + fp = fopen(file, mode); + } + + return fp; } - - file_manager = [NSFileManager defaultManager]; - resource_path = [[NSBundle mainBundle] resourcePath]; - - ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)]; - - full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component]; - if([file_manager fileExistsAtPath:full_path_with_file_to_try]) { - fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode); - } else { - fp = fopen(file, mode); - } - - return fp; -}} +} #endif /* __APPLE__ */ diff --git a/src/filesystem/android/SDL_sysfilesystem.c b/src/filesystem/android/SDL_sysfilesystem.c index 3214b689f..97213c219 100644 --- a/src/filesystem/android/SDL_sysfilesystem.c +++ b/src/filesystem/android/SDL_sysfilesystem.c @@ -45,7 +45,7 @@ SDL_GetPrefPath(const char *org, const char *app) { const char *path = SDL_AndroidGetInternalStoragePath(); if (path) { - size_t pathlen = SDL_strlen(path)+2; + size_t pathlen = SDL_strlen(path) + 2; char *fullpath = (char *)SDL_malloc(pathlen); if (fullpath == NULL) { SDL_OutOfMemory(); diff --git a/src/filesystem/cocoa/SDL_sysfilesystem.m b/src/filesystem/cocoa/SDL_sysfilesystem.m index a1506d3b8..c25fcef1f 100644 --- a/src/filesystem/cocoa/SDL_sysfilesystem.m +++ b/src/filesystem/cocoa/SDL_sysfilesystem.m @@ -35,105 +35,106 @@ char * SDL_GetBasePath(void) -{ @autoreleasepool { - NSBundle *bundle = [NSBundle mainBundle]; - const char* baseType = [[[bundle infoDictionary] objectForKey:@"SDL_FILESYSTEM_BASE_DIR_TYPE"] UTF8String]; - const char *base = NULL; - char *retval = NULL; + @autoreleasepool { + NSBundle *bundle = [NSBundle mainBundle]; + const char *baseType = [[[bundle infoDictionary] objectForKey:@"SDL_FILESYSTEM_BASE_DIR_TYPE"] UTF8String]; + const char *base = NULL; + char *retval = NULL; - if (baseType == NULL) { - baseType = "resource"; - } - if (SDL_strcasecmp(baseType, "bundle")==0) { - base = [[bundle bundlePath] fileSystemRepresentation]; - } else if (SDL_strcasecmp(baseType, "parent")==0) { - base = [[[bundle bundlePath] stringByDeletingLastPathComponent] fileSystemRepresentation]; - } else { - /* this returns the exedir for non-bundled and the resourceDir for bundled apps */ - base = [[bundle resourcePath] fileSystemRepresentation]; - } - - if (base) { - const size_t len = SDL_strlen(base) + 2; - retval = (char *) SDL_malloc(len); - if (retval == NULL) { - SDL_OutOfMemory(); + if (baseType == NULL) { + baseType = "resource"; + } + if (SDL_strcasecmp(baseType, "bundle") == 0) { + base = [[bundle bundlePath] fileSystemRepresentation]; + } else if (SDL_strcasecmp(baseType, "parent") == 0) { + base = [[[bundle bundlePath] stringByDeletingLastPathComponent] fileSystemRepresentation]; } else { - SDL_snprintf(retval, len, "%s/", base); + /* this returns the exedir for non-bundled and the resourceDir for bundled apps */ + base = [[bundle resourcePath] fileSystemRepresentation]; } - } - return retval; -}} - -char * -SDL_GetPrefPath(const char *org, const char *app) -{ @autoreleasepool -{ - char *retval = NULL; - NSArray *array; - - if (!app) { - SDL_InvalidParamError("app"); - return NULL; - } - if (!org) { - org = ""; - } - -#if !TARGET_OS_TV - array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); -#else - /* tvOS does not have persistent local storage! - * The only place on-device where we can store data is - * a cache directory that the OS can empty at any time. - * - * It's therefore very likely that save data will be erased - * between sessions. If you want your app's save data to - * actually stick around, you'll need to use iCloud storage. - */ - { - static SDL_bool shown = SDL_FALSE; - if (!shown) - { - shown = SDL_TRUE; - SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "tvOS does not have persistent local storage! Use iCloud storage if you want your data to persist between sessions.\n"); - } - } - - array = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); -#endif /* !TARGET_OS_TV */ - - if ([array count] > 0) { /* we only want the first item in the list. */ - NSString *str = [array objectAtIndex:0]; - const char *base = [str fileSystemRepresentation]; if (base) { - const size_t len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4; - retval = (char *) SDL_malloc(len); + const size_t len = SDL_strlen(base) + 2; + retval = (char *)SDL_malloc(len); if (retval == NULL) { SDL_OutOfMemory(); } else { - char *ptr; - if (*org) { - SDL_snprintf(retval, len, "%s/%s/%s/", base, org, app); - } else { - SDL_snprintf(retval, len, "%s/%s/", base, app); - } - for (ptr = retval+1; *ptr; ptr++) { - if (*ptr == '/') { - *ptr = '\0'; - mkdir(retval, 0700); - *ptr = '/'; - } - } - mkdir(retval, 0700); + SDL_snprintf(retval, len, "%s/", base); } } - } - return retval; -}} + return retval; + } +} + +char * +SDL_GetPrefPath(const char *org, const char *app) +{ + @autoreleasepool { + char *retval = NULL; + NSArray *array; + + if (!app) { + SDL_InvalidParamError("app"); + return NULL; + } + if (!org) { + org = ""; + } + +#if !TARGET_OS_TV + array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); +#else + /* tvOS does not have persistent local storage! + * The only place on-device where we can store data is + * a cache directory that the OS can empty at any time. + * + * It's therefore very likely that save data will be erased + * between sessions. If you want your app's save data to + * actually stick around, you'll need to use iCloud storage. + */ + { + static SDL_bool shown = SDL_FALSE; + if (!shown) { + shown = SDL_TRUE; + SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "tvOS does not have persistent local storage! Use iCloud storage if you want your data to persist between sessions.\n"); + } + } + + array = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); +#endif /* !TARGET_OS_TV */ + + if ([array count] > 0) { /* we only want the first item in the list. */ + NSString *str = [array objectAtIndex:0]; + const char *base = [str fileSystemRepresentation]; + if (base) { + const size_t len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4; + retval = (char *)SDL_malloc(len); + if (retval == NULL) { + SDL_OutOfMemory(); + } else { + char *ptr; + if (*org) { + SDL_snprintf(retval, len, "%s/%s/%s/", base, org, app); + } else { + SDL_snprintf(retval, len, "%s/%s/", base, app); + } + for (ptr = retval + 1; *ptr; ptr++) { + if (*ptr == '/') { + *ptr = '\0'; + mkdir(retval, 0700); + *ptr = '/'; + } + } + mkdir(retval, 0700); + } + } + } + + return retval; + } +} #endif /* SDL_FILESYSTEM_COCOA */ diff --git a/src/filesystem/emscripten/SDL_sysfilesystem.c b/src/filesystem/emscripten/SDL_sysfilesystem.c index 955e8bfd3..28c3b6870 100644 --- a/src/filesystem/emscripten/SDL_sysfilesystem.c +++ b/src/filesystem/emscripten/SDL_sysfilesystem.c @@ -56,7 +56,7 @@ SDL_GetPrefPath(const char *org, const char *app) } len = SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3; - retval = (char *) SDL_malloc(len); + retval = (char *)SDL_malloc(len); if (retval == NULL) { SDL_OutOfMemory(); return NULL; @@ -68,7 +68,7 @@ SDL_GetPrefPath(const char *org, const char *app) SDL_snprintf(retval, len, "%s%s/", append, app); } - for (ptr = retval+1; *ptr; ptr++) { + for (ptr = retval + 1; *ptr; ptr++) { if (*ptr == '/') { *ptr = '\0'; if (mkdir(retval, 0700) != 0 && errno != EEXIST) { @@ -79,7 +79,7 @@ SDL_GetPrefPath(const char *org, const char *app) } if (mkdir(retval, 0700) != 0 && errno != EEXIST) { -error: + error: SDL_SetError("Couldn't create directory '%s': '%s'", retval, strerror(errno)); SDL_free(retval); return NULL; diff --git a/src/filesystem/ps2/SDL_sysfilesystem.c b/src/filesystem/ps2/SDL_sysfilesystem.c index f2272c044..48f72ad89 100644 --- a/src/filesystem/ps2/SDL_sysfilesystem.c +++ b/src/filesystem/ps2/SDL_sysfilesystem.c @@ -34,76 +34,77 @@ char * SDL_GetBasePath(void) { - char *retval; - size_t len; - char cwd[FILENAME_MAX]; + char *retval; + size_t len; + char cwd[FILENAME_MAX]; - getcwd(cwd, sizeof(cwd)); - len = SDL_strlen(cwd) + 1; - retval = (char *) SDL_malloc(len); - if (retval) { - SDL_memcpy(retval, cwd, len); - } + getcwd(cwd, sizeof(cwd)); + len = SDL_strlen(cwd) + 1; + retval = (char *)SDL_malloc(len); + if (retval) { + SDL_memcpy(retval, cwd, len); + } - return retval; + return retval; } /* Do a recursive mkdir of parents folders */ -static void recursive_mkdir(const char *dir) { - char tmp[FILENAME_MAX]; - char *base = SDL_GetBasePath(); - char *p = NULL; - size_t len; +static void recursive_mkdir(const char *dir) +{ + char tmp[FILENAME_MAX]; + char *base = SDL_GetBasePath(); + char *p = NULL; + size_t len; - snprintf(tmp, sizeof(tmp),"%s",dir); - len = strlen(tmp); - if (tmp[len - 1] == '/') { - tmp[len - 1] = 0; - } - - for (p = tmp + 1; *p; p++) { - if (*p == '/') { - *p = 0; - // Just creating subfolders from current path - if (strstr(tmp, base) != NULL) { - mkdir(tmp, S_IRWXU); - } - - *p = '/'; + snprintf(tmp, sizeof(tmp), "%s", dir); + len = strlen(tmp); + if (tmp[len - 1] == '/') { + tmp[len - 1] = 0; } - } - free(base); - mkdir(tmp, S_IRWXU); + for (p = tmp + 1; *p; p++) { + if (*p == '/') { + *p = 0; + // Just creating subfolders from current path + if (strstr(tmp, base) != NULL) { + mkdir(tmp, S_IRWXU); + } + + *p = '/'; + } + } + + free(base); + mkdir(tmp, S_IRWXU); } char * SDL_GetPrefPath(const char *org, const char *app) { - char *retval = NULL; - size_t len; - char *base = SDL_GetBasePath(); - if (app == NULL) { - SDL_InvalidParamError("app"); - return NULL; - } - if (org == NULL) { - org = ""; - } + char *retval = NULL; + size_t len; + char *base = SDL_GetBasePath(); + if (app == NULL) { + SDL_InvalidParamError("app"); + return NULL; + } + if (org == NULL) { + org = ""; + } - len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4; - retval = (char *) SDL_malloc(len); + len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4; + retval = (char *)SDL_malloc(len); - if (*org) { - SDL_snprintf(retval, len, "%s%s/%s/", base, org, app); - } else { - SDL_snprintf(retval, len, "%s%s/", base, app); - } - free(base); + if (*org) { + SDL_snprintf(retval, len, "%s%s/%s/", base, org, app); + } else { + SDL_snprintf(retval, len, "%s%s/", base, app); + } + free(base); - recursive_mkdir(retval); - - return retval; + recursive_mkdir(retval); + + return retval; } #endif /* SDL_FILESYSTEM_PS2 */ diff --git a/src/filesystem/psp/SDL_sysfilesystem.c b/src/filesystem/psp/SDL_sysfilesystem.c index cbce1a4ba..806f8efa4 100644 --- a/src/filesystem/psp/SDL_sysfilesystem.c +++ b/src/filesystem/psp/SDL_sysfilesystem.c @@ -40,7 +40,7 @@ SDL_GetBasePath(void) getcwd(cwd, sizeof(cwd)); len = SDL_strlen(cwd) + 2; - retval = (char *) SDL_malloc(len); + retval = (char *)SDL_malloc(len); SDL_snprintf(retval, len, "%s/", cwd); return retval; @@ -61,7 +61,7 @@ SDL_GetPrefPath(const char *org, const char *app) } len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4; - retval = (char *) SDL_malloc(len); + retval = (char *)SDL_malloc(len); if (*org) { SDL_snprintf(retval, len, "%s%s/%s/", base, org, app); diff --git a/src/filesystem/riscos/SDL_sysfilesystem.c b/src/filesystem/riscos/SDL_sysfilesystem.c index 8998a7d08..2cc2b01f6 100644 --- a/src/filesystem/riscos/SDL_sysfilesystem.c +++ b/src/filesystem/riscos/SDL_sysfilesystem.c @@ -34,8 +34,7 @@ #include "SDL_filesystem.h" /* Wrapper around __unixify_std that uses SDL's memory allocators */ -static char * -SDL_unixify_std(const char *ro_path, char *buffer, size_t buf_len, int filetype) +static char *SDL_unixify_std(const char *ro_path, char *buffer, size_t buf_len, int filetype) { const char *const in_buf = buffer; /* = NULL if we allocate the buffer. */ @@ -73,8 +72,7 @@ SDL_unixify_std(const char *ro_path, char *buffer, size_t buf_len, int filetype) return buffer; } -static char * -canonicalisePath(const char *path, const char *pathVar) +static char *canonicalisePath(const char *path, const char *pathVar) { _kernel_oserror *error; _kernel_swi_regs regs; @@ -109,8 +107,7 @@ canonicalisePath(const char *path, const char *pathVar) return buf; } -static _kernel_oserror * -createDirectoryRecursive(char *path) +static _kernel_oserror *createDirectoryRecursive(char *path) { char *ptr = NULL; _kernel_oserror *error; @@ -119,7 +116,7 @@ createDirectoryRecursive(char *path) regs.r[1] = (int)path; regs.r[2] = 0; - for (ptr = path+1; *ptr; ptr++) { + for (ptr = path + 1; *ptr; ptr++) { if (*ptr == '.') { *ptr = '\0'; error = _kernel_swi(OS_File, ®s, ®s); @@ -181,7 +178,7 @@ SDL_GetPrefPath(const char *org, const char *app) } len = SDL_strlen(canon) + SDL_strlen(org) + SDL_strlen(app) + 4; - dir = (char *) SDL_malloc(len); + dir = (char *)SDL_malloc(len); if (dir == NULL) { SDL_OutOfMemory(); SDL_free(canon); diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index 928d76965..d4e4ae5ff 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -53,7 +53,7 @@ readSymLink(const char *path) ssize_t rc = -1; while (1) { - char *ptr = (char *) SDL_realloc(retval, (size_t) len); + char *ptr = (char *)SDL_realloc(retval, (size_t)len); if (ptr == NULL) { SDL_OutOfMemory(); break; @@ -63,13 +63,13 @@ readSymLink(const char *path) rc = readlink(path, retval, len); if (rc == -1) { - break; /* not a symlink, i/o error, etc. */ + break; /* not a symlink, i/o error, etc. */ } else if (rc < len) { - retval[rc] = '\0'; /* readlink doesn't null-terminate. */ - return retval; /* we're good to go. */ + retval[rc] = '\0'; /* readlink doesn't null-terminate. */ + return retval; /* we're good to go. */ } - len *= 2; /* grow buffer, try again. */ + len *= 2; /* grow buffer, try again. */ } SDL_free(retval); @@ -101,10 +101,10 @@ static char *search_path_for_binary(const char *bin) SDL_assert(bin != NULL); alloc_size = SDL_strlen(bin) + SDL_strlen(envr) + 2; - exe = (char *) SDL_malloc(alloc_size); + exe = (char *)SDL_malloc(alloc_size); do { - ptr = SDL_strchr(start, ':'); /* find next $PATH separator. */ + ptr = SDL_strchr(start, ':'); /* find next $PATH separator. */ if (ptr != start) { if (ptr) { *ptr = '\0'; @@ -118,19 +118,17 @@ static char *search_path_for_binary(const char *bin) return exe; } } - start = ptr + 1; /* start points to beginning of next element. */ + start = ptr + 1; /* start points to beginning of next element. */ } while (ptr != NULL); SDL_free(envr); SDL_free(exe); SDL_SetError("Process not found in $PATH"); - return NULL; /* doesn't exist in path. */ + return NULL; /* doesn't exist in path. */ } #endif - - char * SDL_GetBasePath(void) { @@ -138,7 +136,7 @@ SDL_GetBasePath(void) #if defined(__FREEBSD__) char fullpath[PATH_MAX]; - size_t buflen = sizeof (fullpath); + size_t buflen = sizeof(fullpath); const int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; if (sysctl(mib, SDL_arraysize(mib), fullpath, &buflen, NULL, 0) != -1) { retval = SDL_strdup(fullpath); @@ -155,7 +153,7 @@ SDL_GetBasePath(void) const int mib[] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV }; if (sysctl(mib, 4, NULL, &len, NULL, 0) != -1) { char *exe, *pwddst; - char *realpathbuf = (char *) SDL_malloc(PATH_MAX + 1); + char *realpathbuf = (char *)SDL_malloc(PATH_MAX + 1); if (realpathbuf == NULL) { SDL_OutOfMemory(); return NULL; @@ -172,13 +170,13 @@ SDL_GetBasePath(void) exe = cmdline[0]; pwddst = NULL; - if (SDL_strchr(exe, '/') == NULL) { /* not a relative or absolute path, check $PATH for it */ + if (SDL_strchr(exe, '/') == NULL) { /* not a relative or absolute path, check $PATH for it */ exe = search_path_for_binary(cmdline[0]); } else { if (exe && *exe == '.') { const char *pwd = SDL_getenv("PWD"); if (pwd && *pwd) { - SDL_asprintf(&pwddst, "%s/%s", pwd, exe); + SDL_asprintf(&pwddst, "%s/%s", pwd, exe); } } } @@ -222,14 +220,14 @@ SDL_GetBasePath(void) #elif defined(__QNXNTO__) retval = SDL_LoadFile("/proc/self/exefile", NULL); #else - retval = readSymLink("/proc/self/exe"); /* linux. */ + retval = readSymLink("/proc/self/exe"); /* linux. */ if (retval == NULL) { /* older kernels don't have /proc/self ... try PID version... */ char path[64]; const int rc = SDL_snprintf(path, sizeof(path), - "/proc/%llu/exe", - (unsigned long long) getpid()); - if ( (rc > 0) && (rc < sizeof(path)) ) { + "/proc/%llu/exe", + (unsigned long long)getpid()); + if ((rc > 0) && (rc < sizeof(path))) { retval = readSymLink(path); } } @@ -255,8 +253,8 @@ SDL_GetBasePath(void) if (retval != NULL) { /* chop off filename. */ char *ptr = SDL_strrchr(retval, '/'); if (ptr != NULL) { - *(ptr+1) = '\0'; - } else { /* shouldn't happen, but just in case... */ + *(ptr + 1) = '\0'; + } else { /* shouldn't happen, but just in case... */ SDL_free(retval); retval = NULL; } @@ -264,7 +262,7 @@ SDL_GetBasePath(void) if (retval != NULL) { /* try to shrink buffer... */ - char *ptr = (char *) SDL_realloc(retval, SDL_strlen(retval) + 1); + char *ptr = (char *)SDL_realloc(retval, SDL_strlen(retval) + 1); if (ptr != NULL) { retval = ptr; /* oh well if it failed. */ } @@ -316,7 +314,7 @@ SDL_GetPrefPath(const char *org, const char *app) } len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3; - retval = (char *) SDL_malloc(len); + retval = (char *)SDL_malloc(len); if (retval == NULL) { SDL_OutOfMemory(); return NULL; @@ -328,7 +326,7 @@ SDL_GetPrefPath(const char *org, const char *app) SDL_snprintf(retval, len, "%s%s%s/", envr, append, app); } - for (ptr = retval+1; *ptr; ptr++) { + for (ptr = retval + 1; *ptr; ptr++) { if (*ptr == '/') { *ptr = '\0'; if (mkdir(retval, 0700) != 0 && errno != EEXIST) { @@ -338,7 +336,7 @@ SDL_GetPrefPath(const char *org, const char *app) } } if (mkdir(retval, 0700) != 0 && errno != EEXIST) { -error: + error: SDL_SetError("Couldn't create directory '%s': '%s'", retval, strerror(errno)); SDL_free(retval); return NULL; diff --git a/src/filesystem/vita/SDL_sysfilesystem.c b/src/filesystem/vita/SDL_sysfilesystem.c index 89304ba5b..1fa03c88c 100644 --- a/src/filesystem/vita/SDL_sysfilesystem.c +++ b/src/filesystem/vita/SDL_sysfilesystem.c @@ -66,7 +66,7 @@ SDL_GetPrefPath(const char *org, const char *app) len = SDL_strlen(envr); len += SDL_strlen(org) + SDL_strlen(app) + 3; - retval = (char *) SDL_malloc(len); + retval = (char *)SDL_malloc(len); if (retval == NULL) { SDL_OutOfMemory(); return NULL; @@ -78,7 +78,7 @@ SDL_GetPrefPath(const char *org, const char *app) SDL_snprintf(retval, len, "%s%s/", envr, app); } - for (ptr = retval+1; *ptr; ptr++) { + for (ptr = retval + 1; *ptr; ptr++) { if (*ptr == '/') { *ptr = '\0'; sceIoMkdir(retval, 0777); diff --git a/src/filesystem/windows/SDL_sysfilesystem.c b/src/filesystem/windows/SDL_sysfilesystem.c index b53731147..b8e297160 100644 --- a/src/filesystem/windows/SDL_sysfilesystem.c +++ b/src/filesystem/windows/SDL_sysfilesystem.c @@ -42,14 +42,14 @@ SDL_GetBasePath(void) int i; while (SDL_TRUE) { - void *ptr = SDL_realloc(path, buflen * sizeof (WCHAR)); + void *ptr = SDL_realloc(path, buflen * sizeof(WCHAR)); if (ptr == NULL) { SDL_free(path); SDL_OutOfMemory(); return NULL; } - path = (WCHAR *) ptr; + path = (WCHAR *)ptr; len = GetModuleFileNameW(NULL, path, buflen); /* if it truncated, then len >= buflen - 1 */ @@ -68,14 +68,14 @@ SDL_GetBasePath(void) return NULL; } - for (i = len-1; i > 0; i--) { + for (i = len - 1; i > 0; i--) { if (path[i] == '\\') { break; } } - SDL_assert(i > 0); /* Should have been an absolute path. */ - path[i+1] = '\0'; /* chop off filename. */ + SDL_assert(i > 0); /* Should have been an absolute path. */ + path[i + 1] = '\0'; /* chop off filename. */ retval = WIN_StringToUTF8W(path); SDL_free(path); @@ -96,8 +96,8 @@ SDL_GetPrefPath(const char *org, const char *app) WCHAR path[MAX_PATH]; char *retval = NULL; - WCHAR* worg = NULL; - WCHAR* wapp = NULL; + WCHAR *worg = NULL; + WCHAR *wapp = NULL; size_t new_wpath_len = 0; BOOL api_result = FALSE; @@ -190,5 +190,4 @@ SDL_GetPrefPath(const char *org, const char *app) } #endif /* SDL_FILESYSTEM_XBOX */ - /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/filesystem/winrt/SDL_sysfilesystem.cpp b/src/filesystem/winrt/SDL_sysfilesystem.cpp index 8603b26f5..bb512ce60 100644 --- a/src/filesystem/winrt/SDL_sysfilesystem.cpp +++ b/src/filesystem/winrt/SDL_sysfilesystem.cpp @@ -21,7 +21,7 @@ #include "../../SDL_internal.h" /* TODO, WinRT: remove the need to compile this with C++/CX (/ZW) extensions, and if possible, without C++ at all -*/ + */ #ifdef __WINRT__ @@ -44,55 +44,55 @@ extern "C" const wchar_t * SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType) { switch (pathType) { - case SDL_WINRT_PATH_INSTALLED_LOCATION: - { - static wstring path; - if (path.empty()) { + case SDL_WINRT_PATH_INSTALLED_LOCATION: + { + static wstring path; + if (path.empty()) { #if defined(NTDDI_WIN10_19H1) && (NTDDI_VERSION >= NTDDI_WIN10_19H1) && (WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) /* Only PC supports mods */ - /* Windows 1903 supports mods, via the EffectiveLocation API */ - if (Windows::Foundation::Metadata::ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8, 0)) { - path = Windows::ApplicationModel::Package::Current->EffectiveLocation->Path->Data(); - } else { - path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data(); - } -#else + /* Windows 1903 supports mods, via the EffectiveLocation API */ + if (Windows::Foundation::Metadata::ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8, 0)) { + path = Windows::ApplicationModel::Package::Current->EffectiveLocation->Path->Data(); + } else { path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data(); + } +#else + path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data(); #endif - } - return path.c_str(); } + return path.c_str(); + } - case SDL_WINRT_PATH_LOCAL_FOLDER: - { - static wstring path; - if (path.empty()) { - path = ApplicationData::Current->LocalFolder->Path->Data(); - } - return path.c_str(); + case SDL_WINRT_PATH_LOCAL_FOLDER: + { + static wstring path; + if (path.empty()) { + path = ApplicationData::Current->LocalFolder->Path->Data(); } + return path.c_str(); + } #if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (NTDDI_VERSION > NTDDI_WIN8) - case SDL_WINRT_PATH_ROAMING_FOLDER: - { - static wstring path; - if (path.empty()) { - path = ApplicationData::Current->RoamingFolder->Path->Data(); - } - return path.c_str(); + case SDL_WINRT_PATH_ROAMING_FOLDER: + { + static wstring path; + if (path.empty()) { + path = ApplicationData::Current->RoamingFolder->Path->Data(); } + return path.c_str(); + } - case SDL_WINRT_PATH_TEMP_FOLDER: - { - static wstring path; - if (path.empty()) { - path = ApplicationData::Current->TemporaryFolder->Path->Data(); - } - return path.c_str(); + case SDL_WINRT_PATH_TEMP_FOLDER: + { + static wstring path; + if (path.empty()) { + path = ApplicationData::Current->TemporaryFolder->Path->Data(); } + return path.c_str(); + } #endif - default: - break; + default: + break; } SDL_Unsupported(); @@ -110,12 +110,12 @@ SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType) return searchResult->second.c_str(); } - const wchar_t * ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType); + const wchar_t *ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType); if (ucs2Path == NULL) { return NULL; } - char * utf8Path = WIN_StringToUTF8(ucs2Path); + char *utf8Path = WIN_StringToUTF8(ucs2Path); utf8Paths[pathType] = utf8Path; SDL_free(utf8Path); return utf8Paths[pathType].c_str(); @@ -124,9 +124,9 @@ SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType) extern "C" char * SDL_GetBasePath(void) { - const char * srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_INSTALLED_LOCATION); + const char *srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_INSTALLED_LOCATION); size_t destPathLen; - char * destPath = NULL; + char *destPath = NULL; if (srcPath == NULL) { SDL_SetError("Couldn't locate our basepath: %s", SDL_GetError()); @@ -134,7 +134,7 @@ SDL_GetBasePath(void) } destPathLen = SDL_strlen(srcPath) + 2; - destPath = (char *) SDL_malloc(destPathLen); + destPath = (char *)SDL_malloc(destPathLen); if (destPath == NULL) { SDL_OutOfMemory(); return NULL; @@ -153,11 +153,11 @@ SDL_GetPrefPath(const char *org, const char *app) * without violating Microsoft's app-store requirements. */ - const WCHAR * srcPath = NULL; + const WCHAR *srcPath = NULL; WCHAR path[MAX_PATH]; char *retval = NULL; - WCHAR* worg = NULL; - WCHAR* wapp = NULL; + WCHAR *worg = NULL; + WCHAR *wapp = NULL; size_t new_wpath_len = 0; BOOL api_result = FALSE; diff --git a/src/haptic/SDL_haptic.c b/src/haptic/SDL_haptic.c index 3c02ae65b..604ba7cb3 100644 --- a/src/haptic/SDL_haptic.c +++ b/src/haptic/SDL_haptic.c @@ -27,15 +27,14 @@ /* Global for SDL_windowshaptic.c */ #if (defined(SDL_HAPTIC_DINPUT) && SDL_HAPTIC_DINPUT) || (defined(SDL_HAPTIC_XINPUT) && SDL_HAPTIC_XINPUT) SDL_Haptic *SDL_haptics = NULL; -#else +#else static SDL_Haptic *SDL_haptics = NULL; #endif /* * Initializes the Haptic devices. */ -int -SDL_HapticInit(void) +int SDL_HapticInit(void) { int status; @@ -47,12 +46,10 @@ SDL_HapticInit(void) return status; } - /* * Checks to see if the haptic device is valid */ -static int -ValidHaptic(SDL_Haptic * haptic) +static int ValidHaptic(SDL_Haptic *haptic) { int valid; SDL_Haptic *hapticlist; @@ -60,7 +57,7 @@ ValidHaptic(SDL_Haptic * haptic) valid = 0; if (haptic != NULL) { hapticlist = SDL_haptics; - while ( hapticlist ) { + while (hapticlist) { if (hapticlist == haptic) { valid = 1; break; @@ -77,17 +74,14 @@ ValidHaptic(SDL_Haptic * haptic) return valid; } - /* * Returns the number of available devices. */ -int -SDL_NumHaptics(void) +int SDL_NumHaptics(void) { return SDL_SYS_NumHaptics(); } - /* * Gets the name of a Haptic device by index. */ @@ -102,7 +96,6 @@ SDL_HapticName(int device_index) return SDL_SYS_HapticName(device_index); } - /* * Opens a Haptic device. */ @@ -120,9 +113,9 @@ SDL_HapticOpen(int device_index) hapticlist = SDL_haptics; /* If the haptic is already open, return it - * TODO: Should we create haptic instance IDs like the Joystick API? - */ - while ( hapticlist ) { + * TODO: Should we create haptic instance IDs like the Joystick API? + */ + while (hapticlist) { if (device_index == hapticlist->index) { haptic = hapticlist; ++haptic->ref_count; @@ -132,7 +125,7 @@ SDL_HapticOpen(int device_index) } /* Create the haptic device */ - haptic = (SDL_Haptic *) SDL_malloc((sizeof *haptic)); + haptic = (SDL_Haptic *)SDL_malloc((sizeof *haptic)); if (haptic == NULL) { SDL_OutOfMemory(); return NULL; @@ -164,12 +157,10 @@ SDL_HapticOpen(int device_index) return haptic; } - /* * Returns 1 if the device has been opened. */ -int -SDL_HapticOpened(int device_index) +int SDL_HapticOpened(int device_index) { int opened; SDL_Haptic *hapticlist; @@ -184,8 +175,8 @@ SDL_HapticOpened(int device_index) opened = 0; hapticlist = SDL_haptics; /* TODO Should this use an instance ID? */ - while ( hapticlist ) { - if (hapticlist->index == (Uint8) device_index) { + while (hapticlist) { + if (hapticlist->index == (Uint8)device_index) { opened = 1; break; } @@ -194,12 +185,10 @@ SDL_HapticOpened(int device_index) return opened; } - /* * Returns the index to a haptic device. */ -int -SDL_HapticIndex(SDL_Haptic * haptic) +int SDL_HapticIndex(SDL_Haptic *haptic) { if (!ValidHaptic(haptic)) { return -1; @@ -208,12 +197,10 @@ SDL_HapticIndex(SDL_Haptic * haptic) return haptic->index; } - /* * Returns SDL_TRUE if mouse is haptic, SDL_FALSE if it isn't. */ -int -SDL_MouseIsHaptic(void) +int SDL_MouseIsHaptic(void) { if (SDL_SYS_HapticMouse() < 0) { return SDL_FALSE; @@ -221,7 +208,6 @@ SDL_MouseIsHaptic(void) return SDL_TRUE; } - /* * Returns the haptic device if mouse is haptic or NULL elsewise. */ @@ -240,12 +226,10 @@ SDL_HapticOpenFromMouse(void) return SDL_HapticOpen(device_index); } - /* * Returns SDL_TRUE if joystick has haptic features. */ -int -SDL_JoystickIsHaptic(SDL_Joystick * joystick) +int SDL_JoystickIsHaptic(SDL_Joystick *joystick) { int ret; @@ -264,12 +248,11 @@ SDL_JoystickIsHaptic(SDL_Joystick * joystick) return -1; } - /* * Opens a haptic device from a joystick. */ SDL_Haptic * -SDL_HapticOpenFromJoystick(SDL_Joystick * joystick) +SDL_HapticOpenFromJoystick(SDL_Joystick *joystick) { SDL_Haptic *haptic; SDL_Haptic *hapticlist; @@ -295,7 +278,7 @@ SDL_HapticOpenFromJoystick(SDL_Joystick * joystick) hapticlist = SDL_haptics; /* Check to see if joystick's haptic is already open */ - while ( hapticlist ) { + while (hapticlist) { if (SDL_SYS_JoystickSameHaptic(hapticlist, joystick)) { haptic = hapticlist; ++haptic->ref_count; @@ -305,7 +288,7 @@ SDL_HapticOpenFromJoystick(SDL_Joystick * joystick) } /* Create the haptic device */ - haptic = (SDL_Haptic *) SDL_malloc((sizeof *haptic)); + haptic = (SDL_Haptic *)SDL_malloc((sizeof *haptic)); if (haptic == NULL) { SDL_OutOfMemory(); return NULL; @@ -329,12 +312,10 @@ SDL_HapticOpenFromJoystick(SDL_Joystick * joystick) return haptic; } - /* * Closes a SDL_Haptic device. */ -void -SDL_HapticClose(SDL_Haptic * haptic) +void SDL_HapticClose(SDL_Haptic *haptic) { int i; SDL_Haptic *hapticlist; @@ -361,9 +342,9 @@ SDL_HapticClose(SDL_Haptic * haptic) /* Remove from the list */ hapticlist = SDL_haptics; hapticlistprev = NULL; - while ( hapticlist ) { + while (hapticlist) { if (haptic == hapticlist) { - if ( hapticlistprev ) { + if (hapticlistprev) { /* unlink this entry */ hapticlistprev->next = hapticlist->next; } else { @@ -383,8 +364,7 @@ SDL_HapticClose(SDL_Haptic * haptic) /* * Cleans up after the subsystem. */ -void -SDL_HapticQuit(void) +void SDL_HapticQuit(void) { while (SDL_haptics) { SDL_HapticClose(SDL_haptics); @@ -396,8 +376,7 @@ SDL_HapticQuit(void) /* * Returns the number of effects a haptic device has. */ -int -SDL_HapticNumEffects(SDL_Haptic * haptic) +int SDL_HapticNumEffects(SDL_Haptic *haptic) { if (!ValidHaptic(haptic)) { return -1; @@ -406,12 +385,10 @@ SDL_HapticNumEffects(SDL_Haptic * haptic) return haptic->neffects; } - /* * Returns the number of effects a haptic device can play. */ -int -SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic) +int SDL_HapticNumEffectsPlaying(SDL_Haptic *haptic) { if (!ValidHaptic(haptic)) { return -1; @@ -420,12 +397,11 @@ SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic) return haptic->nplaying; } - /* * Returns supported effects by the device. */ unsigned int -SDL_HapticQuery(SDL_Haptic * haptic) +SDL_HapticQuery(SDL_Haptic *haptic) { if (!ValidHaptic(haptic)) { return 0; /* same as if no effects were supported */ @@ -434,12 +410,10 @@ SDL_HapticQuery(SDL_Haptic * haptic) return haptic->supported; } - /* * Returns the number of axis on the device. */ -int -SDL_HapticNumAxes(SDL_Haptic * haptic) +int SDL_HapticNumAxes(SDL_Haptic *haptic) { if (!ValidHaptic(haptic)) { return -1; @@ -451,8 +425,7 @@ SDL_HapticNumAxes(SDL_Haptic * haptic) /* * Checks to see if the device can support the effect. */ -int -SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect) +int SDL_HapticEffectSupported(SDL_Haptic *haptic, SDL_HapticEffect *effect) { if (!ValidHaptic(haptic)) { return -1; @@ -467,8 +440,7 @@ SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect) /* * Creates a new haptic effect. */ -int -SDL_HapticNewEffect(SDL_Haptic * haptic, SDL_HapticEffect * effect) +int SDL_HapticNewEffect(SDL_Haptic *haptic, SDL_HapticEffect *effect) { int i; @@ -487,9 +459,8 @@ SDL_HapticNewEffect(SDL_Haptic * haptic, SDL_HapticEffect * effect) if (haptic->effects[i].hweffect == NULL) { /* Now let the backend create the real effect */ - if (SDL_SYS_HapticNewEffect(haptic, &haptic->effects[i], effect) - != 0) { - return -1; /* Backend failed to create effect */ + if (SDL_SYS_HapticNewEffect(haptic, &haptic->effects[i], effect) != 0) { + return -1; /* Backend failed to create effect */ } SDL_memcpy(&haptic->effects[i].effect, effect, @@ -504,8 +475,7 @@ SDL_HapticNewEffect(SDL_Haptic * haptic, SDL_HapticEffect * effect) /* * Checks to see if an effect is valid. */ -static int -ValidEffect(SDL_Haptic * haptic, int effect) +static int ValidEffect(SDL_Haptic *haptic, int effect) { if ((effect < 0) || (effect >= haptic->neffects)) { SDL_SetError("Haptic: Invalid effect identifier."); @@ -517,9 +487,8 @@ ValidEffect(SDL_Haptic * haptic, int effect) /* * Updates an effect. */ -int -SDL_HapticUpdateEffect(SDL_Haptic * haptic, int effect, - SDL_HapticEffect * data) +int SDL_HapticUpdateEffect(SDL_Haptic *haptic, int effect, + SDL_HapticEffect *data) { if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) { return -1; @@ -541,20 +510,17 @@ SDL_HapticUpdateEffect(SDL_Haptic * haptic, int effect, return 0; } - /* * Runs the haptic effect on the device. */ -int -SDL_HapticRunEffect(SDL_Haptic * haptic, int effect, Uint32 iterations) +int SDL_HapticRunEffect(SDL_Haptic *haptic, int effect, Uint32 iterations) { if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) { return -1; } /* Run the effect */ - if (SDL_SYS_HapticRunEffect(haptic, &haptic->effects[effect], iterations) - < 0) { + if (SDL_SYS_HapticRunEffect(haptic, &haptic->effects[effect], iterations) < 0) { return -1; } @@ -564,8 +530,7 @@ SDL_HapticRunEffect(SDL_Haptic * haptic, int effect, Uint32 iterations) /* * Stops the haptic effect on the device. */ -int -SDL_HapticStopEffect(SDL_Haptic * haptic, int effect) +int SDL_HapticStopEffect(SDL_Haptic *haptic, int effect) { if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) { return -1; @@ -582,8 +547,7 @@ SDL_HapticStopEffect(SDL_Haptic * haptic, int effect) /* * Gets rid of a haptic effect. */ -void -SDL_HapticDestroyEffect(SDL_Haptic * haptic, int effect) +void SDL_HapticDestroyEffect(SDL_Haptic *haptic, int effect) { if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) { return; @@ -600,8 +564,7 @@ SDL_HapticDestroyEffect(SDL_Haptic * haptic, int effect) /* * Gets the status of a haptic effect. */ -int -SDL_HapticGetEffectStatus(SDL_Haptic * haptic, int effect) +int SDL_HapticGetEffectStatus(SDL_Haptic *haptic, int effect) { if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) { return -1; @@ -617,8 +580,7 @@ SDL_HapticGetEffectStatus(SDL_Haptic * haptic, int effect) /* * Sets the global gain of the device. */ -int -SDL_HapticSetGain(SDL_Haptic * haptic, int gain) +int SDL_HapticSetGain(SDL_Haptic *haptic, int gain) { const char *env; int real_gain, max_gain; @@ -663,8 +625,7 @@ SDL_HapticSetGain(SDL_Haptic * haptic, int gain) /* * Makes the device autocenter, 0 disables. */ -int -SDL_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) +int SDL_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter) { if (!ValidHaptic(haptic)) { return -1; @@ -688,8 +649,7 @@ SDL_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) /* * Pauses the haptic device. */ -int -SDL_HapticPause(SDL_Haptic * haptic) +int SDL_HapticPause(SDL_Haptic *haptic) { if (!ValidHaptic(haptic)) { return -1; @@ -705,15 +665,14 @@ SDL_HapticPause(SDL_Haptic * haptic) /* * Unpauses the haptic device. */ -int -SDL_HapticUnpause(SDL_Haptic * haptic) +int SDL_HapticUnpause(SDL_Haptic *haptic) { if (!ValidHaptic(haptic)) { return -1; } if ((haptic->supported & SDL_HAPTIC_PAUSE) == 0) { - return 0; /* Not going to be paused, so we pretend it's unpaused. */ + return 0; /* Not going to be paused, so we pretend it's unpaused. */ } return SDL_SYS_HapticUnpause(haptic); @@ -722,8 +681,7 @@ SDL_HapticUnpause(SDL_Haptic * haptic) /* * Stops all the currently playing effects. */ -int -SDL_HapticStopAll(SDL_Haptic * haptic) +int SDL_HapticStopAll(SDL_Haptic *haptic) { if (!ValidHaptic(haptic)) { return -1; @@ -735,8 +693,7 @@ SDL_HapticStopAll(SDL_Haptic * haptic) /* * Checks to see if rumble is supported. */ -int -SDL_HapticRumbleSupported(SDL_Haptic * haptic) +int SDL_HapticRumbleSupported(SDL_Haptic *haptic) { if (!ValidHaptic(haptic)) { return -1; @@ -749,8 +706,7 @@ SDL_HapticRumbleSupported(SDL_Haptic * haptic) /* * Initializes the haptic device for simple rumble playback. */ -int -SDL_HapticRumbleInit(SDL_Haptic * haptic) +int SDL_HapticRumbleInit(SDL_Haptic *haptic) { SDL_HapticEffect *efx = &haptic->rumble_effect; @@ -772,7 +728,7 @@ SDL_HapticRumbleInit(SDL_Haptic * haptic) efx->periodic.length = 5000; efx->periodic.attack_length = 0; efx->periodic.fade_length = 0; - } else if (haptic->supported & SDL_HAPTIC_LEFTRIGHT) { /* XInput? */ + } else if (haptic->supported & SDL_HAPTIC_LEFTRIGHT) { /* XInput? */ efx->type = SDL_HAPTIC_LEFTRIGHT; efx->leftright.length = 5000; efx->leftright.large_magnitude = 0x4000; @@ -791,8 +747,7 @@ SDL_HapticRumbleInit(SDL_Haptic * haptic) /* * Runs simple rumble on a haptic device */ -int -SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length) +int SDL_HapticRumblePlay(SDL_Haptic *haptic, float strength, Uint32 length) { SDL_HapticEffect *efx; Sint16 magnitude; @@ -811,7 +766,7 @@ SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length) } else if (strength < 0.0f) { strength = 0.0f; } - magnitude = (Sint16)(32767.0f*strength); + magnitude = (Sint16)(32767.0f * strength); efx = &haptic->rumble_effect; if (efx->type == SDL_HAPTIC_SINE) { @@ -834,8 +789,7 @@ SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length) /* * Stops the simple rumble on a haptic device. */ -int -SDL_HapticRumbleStop(SDL_Haptic * haptic) +int SDL_HapticRumbleStop(SDL_Haptic *haptic) { if (!ValidHaptic(haptic)) { return -1; diff --git a/src/haptic/SDL_syshaptic.h b/src/haptic/SDL_syshaptic.h index d6ee3e1ac..1b3348ad4 100644 --- a/src/haptic/SDL_syshaptic.h +++ b/src/haptic/SDL_syshaptic.h @@ -33,8 +33,8 @@ extern "C" { struct haptic_effect { - SDL_HapticEffect effect; /* The current event */ - struct haptic_hweffect *hweffect; /* The hardware behind the event */ + SDL_HapticEffect effect; /* The current event */ + struct haptic_hweffect *hweffect; /* The hardware behind the event */ }; /* @@ -42,20 +42,20 @@ struct haptic_effect */ struct _SDL_Haptic { - Uint8 index; /* Stores index it is attached to */ + Uint8 index; /* Stores index it is attached to */ - struct haptic_effect *effects; /* Allocated effects */ - int neffects; /* Maximum amount of effects */ - int nplaying; /* Maximum amount of effects to play at the same time */ - unsigned int supported; /* Supported effects */ - int naxes; /* Number of axes on the device. */ + struct haptic_effect *effects; /* Allocated effects */ + int neffects; /* Maximum amount of effects */ + int nplaying; /* Maximum amount of effects to play at the same time */ + unsigned int supported; /* Supported effects */ + int naxes; /* Number of axes on the device. */ - struct haptic_hwdata *hwdata; /* Driver dependent */ - int ref_count; /* Count for multiple opens */ + struct haptic_hwdata *hwdata; /* Driver dependent */ + int ref_count; /* Count for multiple opens */ - int rumble_id; /* ID of rumble effect for simple rumble API. */ + int rumble_id; /* ID of rumble effect for simple rumble API. */ SDL_HapticEffect rumble_effect; /* Rumble effect. */ - struct _SDL_Haptic *next; /* pointer to next haptic we have allocated */ + struct _SDL_Haptic *next; /* pointer to next haptic we have allocated */ }; /* @@ -79,7 +79,7 @@ extern const char *SDL_SYS_HapticName(int index); * * Returns 0 on success, -1 on error. */ -extern int SDL_SYS_HapticOpen(SDL_Haptic * haptic); +extern int SDL_SYS_HapticOpen(SDL_Haptic *haptic); /* * Returns the index of the haptic core pointer or -1 if none is found. @@ -92,7 +92,7 @@ int SDL_SYS_HapticMouse(void); * Returns >0 if haptic capabilities are detected, 0 if haptic * capabilities aren't detected and -1 on error. */ -extern int SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick); +extern int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick); /* * Opens the haptic device for usage using the same device as @@ -100,20 +100,20 @@ extern int SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick); * * Returns 0 on success, -1 on error. */ -extern int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, - SDL_Joystick * joystick); +extern int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, + SDL_Joystick *joystick); /* * Checks to see if haptic device and joystick device are the same. * * Returns 1 if they are the same, 0 if they aren't. */ -extern int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, - SDL_Joystick * joystick); +extern int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, + SDL_Joystick *joystick); /* * Closes a haptic device after usage. */ -extern void SDL_SYS_HapticClose(SDL_Haptic * haptic); +extern void SDL_SYS_HapticClose(SDL_Haptic *haptic); /* * Performs a cleanup on the haptic subsystem. @@ -126,9 +126,9 @@ extern void SDL_SYS_HapticQuit(void); * * Returns 0 on success, -1 on error. */ -extern int SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, +extern int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, - SDL_HapticEffect * base); + SDL_HapticEffect *base); /* * Updates the haptic effect on the haptic device using data @@ -136,16 +136,16 @@ extern int SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, * * Returns 0 on success, -1 on error. */ -extern int SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, +extern int SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic, struct haptic_effect *effect, - SDL_HapticEffect * data); + SDL_HapticEffect *data); /* * Runs the effect on the haptic device. * * Returns 0 on success, -1 on error. */ -extern int SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, +extern int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, Uint32 iterations); @@ -154,13 +154,13 @@ extern int SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, * * Returns 0 on success, -1 on error. */ -extern int SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, +extern int SDL_SYS_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect); /* * Cleanups up the effect on the haptic device. */ -extern void SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, +extern void SDL_SYS_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect); /* @@ -169,7 +169,7 @@ extern void SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, * Returns 0 if device is stopped, >0 if device is playing and * -1 on error. */ -extern int SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, +extern int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *effect); /* @@ -177,35 +177,35 @@ extern int SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, * * Returns 0 on success, -1 on error. */ -extern int SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain); +extern int SDL_SYS_HapticSetGain(SDL_Haptic *haptic, int gain); /* * Sets the autocenter feature of the haptic device. * * Returns 0 on success, -1 on error. */ -extern int SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter); +extern int SDL_SYS_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter); /* * Pauses the haptic device. * * Returns 0 on success, -1 on error. */ -extern int SDL_SYS_HapticPause(SDL_Haptic * haptic); +extern int SDL_SYS_HapticPause(SDL_Haptic *haptic); /* * Unpauses the haptic device. * * Returns 0 on success, -1 on error. */ -extern int SDL_SYS_HapticUnpause(SDL_Haptic * haptic); +extern int SDL_SYS_HapticUnpause(SDL_Haptic *haptic); /* * Stops all the currently playing haptic effects on the device. * * Returns 0 on success, -1 on error. */ -extern int SDL_SYS_HapticStopAll(SDL_Haptic * haptic); +extern int SDL_SYS_HapticStopAll(SDL_Haptic *haptic); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/src/haptic/android/SDL_syshaptic.c b/src/haptic/android/SDL_syshaptic.c index dd9ee1ebe..13a16bd9d 100644 --- a/src/haptic/android/SDL_syshaptic.c +++ b/src/haptic/android/SDL_syshaptic.c @@ -44,9 +44,7 @@ static SDL_hapticlist_item *SDL_hapticlist = NULL; static SDL_hapticlist_item *SDL_hapticlist_tail = NULL; static int numhaptics = 0; - -int -SDL_SYS_HapticInit(void) +int SDL_SYS_HapticInit(void) { /* Support for device connect/disconnect is API >= 16 only, * so we poll every three seconds @@ -60,14 +58,12 @@ SDL_SYS_HapticInit(void) return numhaptics; } -int -SDL_SYS_NumHaptics(void) +int SDL_SYS_NumHaptics(void) { return numhaptics; } -static SDL_hapticlist_item * -HapticByOrder(int index) +static SDL_hapticlist_item *HapticByOrder(int index) { SDL_hapticlist_item *item = SDL_hapticlist; if ((index < 0) || (index >= numhaptics)) { @@ -81,8 +77,7 @@ HapticByOrder(int index) return item; } -static SDL_hapticlist_item * -HapticByDevId (int device_id) +static SDL_hapticlist_item *HapticByDevId(int device_id) { SDL_hapticlist_item *item; for (item = SDL_hapticlist; item != NULL; item = item->next) { @@ -98,18 +93,16 @@ const char * SDL_SYS_HapticName(int index) { SDL_hapticlist_item *item = HapticByOrder(index); - if (item == NULL ) { + if (item == NULL) { SDL_SetError("No such device"); return NULL; } return item->name; } - -static SDL_hapticlist_item * -OpenHaptic(SDL_Haptic *haptic, SDL_hapticlist_item *item) +static SDL_hapticlist_item *OpenHaptic(SDL_Haptic *haptic, SDL_hapticlist_item *item) { - if (item == NULL ) { + if (item == NULL) { SDL_SetError("No such device"); return NULL; } @@ -124,75 +117,60 @@ OpenHaptic(SDL_Haptic *haptic, SDL_hapticlist_item *item) haptic->supported = SDL_HAPTIC_LEFTRIGHT; haptic->neffects = 1; haptic->nplaying = haptic->neffects; - haptic->effects = (struct haptic_effect *)SDL_malloc (sizeof (struct haptic_effect) * haptic->neffects); + haptic->effects = (struct haptic_effect *)SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); if (haptic->effects == NULL) { SDL_OutOfMemory(); return NULL; } - SDL_memset(haptic->effects, 0, sizeof (struct haptic_effect) * haptic->neffects); + SDL_memset(haptic->effects, 0, sizeof(struct haptic_effect) * haptic->neffects); return item; } -static SDL_hapticlist_item * -OpenHapticByOrder(SDL_Haptic *haptic, int index) +static SDL_hapticlist_item *OpenHapticByOrder(SDL_Haptic *haptic, int index) { return OpenHaptic(haptic, HapticByOrder(index)); } -static SDL_hapticlist_item * -OpenHapticByDevId(SDL_Haptic *haptic, int device_id) +static SDL_hapticlist_item *OpenHapticByDevId(SDL_Haptic *haptic, int device_id) { return OpenHaptic(haptic, HapticByDevId(device_id)); } -int -SDL_SYS_HapticOpen(SDL_Haptic *haptic) +int SDL_SYS_HapticOpen(SDL_Haptic *haptic) { return OpenHapticByOrder(haptic, haptic->index) == NULL ? -1 : 0; } - -int -SDL_SYS_HapticMouse(void) +int SDL_SYS_HapticMouse(void) { return -1; } - -int -SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) +int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) { SDL_hapticlist_item *item; item = HapticByDevId(((joystick_hwdata *)joystick->hwdata)->device_id); return (item != NULL) ? 1 : 0; } - -int -SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) +int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) { return OpenHapticByDevId(haptic, ((joystick_hwdata *)joystick->hwdata)->device_id) == NULL ? -1 : 0; } - -int -SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) +int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) { return ((SDL_hapticlist_item *)haptic->hwdata)->device_id == ((joystick_hwdata *)joystick->hwdata)->device_id ? 1 : 0; } - -void -SDL_SYS_HapticClose(SDL_Haptic * haptic) +void SDL_SYS_HapticClose(SDL_Haptic *haptic) { ((SDL_hapticlist_item *)haptic->hwdata)->haptic = NULL; haptic->hwdata = NULL; return; } - -void -SDL_SYS_HapticQuit(void) +void SDL_SYS_HapticQuit(void) { /* We don't have any way to scan for joysticks (and their vibrators) at init, so don't wipe the list * of joysticks here in case this is a reinit. @@ -212,107 +190,85 @@ SDL_SYS_HapticQuit(void) #endif } - -int -SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, - struct haptic_effect *effect, SDL_HapticEffect * base) +int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, + struct haptic_effect *effect, SDL_HapticEffect *base) { return 0; } - -int -SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, - struct haptic_effect *effect, - SDL_HapticEffect * data) +int SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic, + struct haptic_effect *effect, + SDL_HapticEffect *data) { return 0; } - -int -SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, - Uint32 iterations) +int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, + Uint32 iterations) { float large = effect->effect.leftright.large_magnitude / 32767.0f; float small = effect->effect.leftright.small_magnitude / 32767.0f; float total = (large * 0.6f) + (small * 0.4f); - Android_JNI_HapticRun (((SDL_hapticlist_item *)haptic->hwdata)->device_id, total, effect->effect.leftright.length); + Android_JNI_HapticRun(((SDL_hapticlist_item *)haptic->hwdata)->device_id, total, effect->effect.leftright.length); return 0; } - -int -SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) +int SDL_SYS_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect) { - Android_JNI_HapticStop (((SDL_hapticlist_item *)haptic->hwdata)->device_id); + Android_JNI_HapticStop(((SDL_hapticlist_item *)haptic->hwdata)->device_id); return 0; } - -void -SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) +void SDL_SYS_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect) { return; } - -int -SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, - struct haptic_effect *effect) +int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic, + struct haptic_effect *effect) { return 0; } - -int -SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain) +int SDL_SYS_HapticSetGain(SDL_Haptic *haptic, int gain) { return 0; } - -int -SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) +int SDL_SYS_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter) { return 0; } -int -SDL_SYS_HapticPause(SDL_Haptic * haptic) +int SDL_SYS_HapticPause(SDL_Haptic *haptic) { return 0; } -int -SDL_SYS_HapticUnpause(SDL_Haptic * haptic) +int SDL_SYS_HapticUnpause(SDL_Haptic *haptic) { return 0; } -int -SDL_SYS_HapticStopAll(SDL_Haptic * haptic) +int SDL_SYS_HapticStopAll(SDL_Haptic *haptic) { return 0; } - - -int -Android_AddHaptic(int device_id, const char *name) +int Android_AddHaptic(int device_id, const char *name) { SDL_hapticlist_item *item; - item = (SDL_hapticlist_item *) SDL_calloc(1, sizeof (SDL_hapticlist_item)); + item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item)); if (item == NULL) { return -1; } item->device_id = device_id; - item->name = SDL_strdup (name); + item->name = SDL_strdup(name); if (item->name == NULL) { - SDL_free (item); + SDL_free(item); return -1; } @@ -327,8 +283,7 @@ Android_AddHaptic(int device_id, const char *name) return numhaptics; } -int -Android_RemoveHaptic(int device_id) +int Android_RemoveHaptic(int device_id) { SDL_hapticlist_item *item; SDL_hapticlist_item *prev = NULL; @@ -361,7 +316,6 @@ Android_RemoveHaptic(int device_id) return -1; } - #endif /* SDL_HAPTIC_ANDROID */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/haptic/darwin/SDL_syshaptic.c b/src/haptic/darwin/SDL_syshaptic.c index 3c0ebb412..23410bac6 100644 --- a/src/haptic/darwin/SDL_syshaptic.c +++ b/src/haptic/darwin/SDL_syshaptic.c @@ -37,7 +37,7 @@ #include #ifndef IO_OBJECT_NULL -#define IO_OBJECT_NULL ((io_service_t)0) +#define IO_OBJECT_NULL ((io_service_t)0) #endif /* @@ -45,10 +45,10 @@ */ typedef struct SDL_hapticlist_item { - char name[256]; /* Name of the device. */ + char name[256]; /* Name of the device. */ - io_service_t dev; /* Node we use to create the device. */ - SDL_Haptic *haptic; /* Haptic currently associated with it. */ + io_service_t dev; /* Node we use to create the device. */ + SDL_Haptic *haptic; /* Haptic currently associated with it. */ /* Usage pages for determining if it's a mouse or not. */ long usage; @@ -57,30 +57,28 @@ typedef struct SDL_hapticlist_item struct SDL_hapticlist_item *next; } SDL_hapticlist_item; - /* * Haptic system hardware data. */ struct haptic_hwdata { - FFDeviceObjectReference device; /* Hardware device. */ + FFDeviceObjectReference device; /* Hardware device. */ UInt8 axes[3]; }; - /* * Haptic system effect data. */ struct haptic_hweffect { - FFEffectObjectReference ref; /* Reference. */ - struct FFEFFECT effect; /* Hardware effect. */ + FFEffectObjectReference ref; /* Reference. */ + struct FFEFFECT effect; /* Hardware effect. */ }; /* * Prototypes. */ -static void SDL_SYS_HapticFreeFFEFFECT(FFEFFECT * effect, int type); +static void SDL_SYS_HapticFreeFFEFFECT(FFEFFECT *effect, int type); static int HIDGetDeviceProduct(io_service_t dev, char *name); static SDL_hapticlist_item *SDL_hapticlist = NULL; @@ -90,8 +88,7 @@ static int numhaptics = -1; /* * Like strerror but for force feedback errors. */ -static const char * -FFStrError(unsigned int err) +static const char *FFStrError(unsigned int err) { switch (err) { case FFERR_DEVICEFULL: @@ -143,12 +140,10 @@ FFStrError(unsigned int err) } } - /* * Initializes the haptic subsystem. */ -int -SDL_SYS_HapticInit(void) +int SDL_SYS_HapticInit(void) { IOReturn result; io_iterator_t iter; @@ -173,7 +168,7 @@ SDL_SYS_HapticInit(void) } /* IOServiceGetMatchingServices consumes dictionary. */ - if (!IOIteratorIsValid(iter)) { /* No iterator. */ + if (!IOIteratorIsValid(iter)) { /* No iterator. */ return 0; } @@ -187,14 +182,12 @@ SDL_SYS_HapticInit(void) return numhaptics; } -int -SDL_SYS_NumHaptics(void) +int SDL_SYS_NumHaptics(void) { return numhaptics; } -static SDL_hapticlist_item * -HapticByDevIndex(int device_index) +static SDL_hapticlist_item *HapticByDevIndex(int device_index) { SDL_hapticlist_item *item = SDL_hapticlist; @@ -211,8 +204,7 @@ HapticByDevIndex(int device_index) return item; } -int -MacHaptic_MaybeAddDevice( io_object_t device ) +int MacHaptic_MaybeAddDevice(io_object_t device) { IOReturn result; CFMutableDictionaryRef hidProperties; @@ -229,8 +221,8 @@ MacHaptic_MaybeAddDevice( io_object_t device ) } /* Make sure we don't already have it */ - for (item = SDL_hapticlist; item ; item = item->next) { - if (IOObjectIsEqualTo((io_object_t) item->dev, device)) { + for (item = SDL_hapticlist; item; item = item->next) { + if (IOObjectIsEqualTo((io_object_t)item->dev, device)) { /* Already added */ return -1; } @@ -286,8 +278,7 @@ MacHaptic_MaybeAddDevice( io_object_t device ) return numhaptics; } -int -MacHaptic_MaybeRemoveDevice( io_object_t device ) +int MacHaptic_MaybeRemoveDevice(io_object_t device) { SDL_hapticlist_item *item; SDL_hapticlist_item *prev = NULL; @@ -298,7 +289,7 @@ MacHaptic_MaybeRemoveDevice( io_object_t device ) for (item = SDL_hapticlist; item != NULL; item = item->next) { /* found it, remove it. */ - if (IOObjectIsEqualTo((io_object_t) item->dev, device)) { + if (IOObjectIsEqualTo((io_object_t)item->dev, device)) { const int retval = item->haptic ? item->haptic->index : -1; if (prev != NULL) { @@ -339,8 +330,7 @@ SDL_SYS_HapticName(int index) /* * Gets the device's product name. */ -static int -HIDGetDeviceProduct(io_service_t dev, char *name) +static int HIDGetDeviceProduct(io_service_t dev, char *name) { CFMutableDictionaryRef hidProperties, usbProperties; io_registry_entry_t parent1, parent2; @@ -358,20 +348,19 @@ HIDGetDeviceProduct(io_service_t dev, char *name) * get dictionary for USB properties: step up two levels and get CF dictionary for USB properties */ if ((KERN_SUCCESS == - IORegistryEntryGetParentEntry(dev, kIOServicePlane, &parent1)) - && (KERN_SUCCESS == - IORegistryEntryGetParentEntry(parent1, kIOServicePlane, &parent2)) - && (KERN_SUCCESS == - IORegistryEntryCreateCFProperties(parent2, &usbProperties, - kCFAllocatorDefault, - kNilOptions))) { + IORegistryEntryGetParentEntry(dev, kIOServicePlane, &parent1)) && + (KERN_SUCCESS == + IORegistryEntryGetParentEntry(parent1, kIOServicePlane, &parent2)) && + (KERN_SUCCESS == + IORegistryEntryCreateCFProperties(parent2, &usbProperties, + kCFAllocatorDefault, + kNilOptions))) { if (usbProperties) { CFTypeRef refCF = 0; /* get device info * try hid dictionary first, if fail then go to USB dictionary */ - /* Get product name */ refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey)); if (!refCF) { @@ -404,14 +393,13 @@ HIDGetDeviceProduct(io_service_t dev, char *name) return 0; } - -#define FF_TEST(ff, s) \ -if (features.supportedEffects & (ff)) supported |= (s) +#define FF_TEST(ff, s) \ + if (features.supportedEffects & (ff)) \ + supported |= (s) /* * Gets supported features. */ -static unsigned int -GetSupportedFeatures(SDL_Haptic * haptic) +static unsigned int GetSupportedFeatures(SDL_Haptic *haptic) { HRESULT ret; FFDeviceObjectReference device; @@ -463,9 +451,8 @@ GetSupportedFeatures(SDL_Haptic * haptic) if (ret == FF_OK) { supported |= SDL_HAPTIC_AUTOCENTER; } else if (ret != FFERR_UNSUPPORTED) { - return SDL_SetError - ("Haptic: Unable to get if device supports autocenter: %s.", - FFStrError(ret)); + return SDL_SetError("Haptic: Unable to get if device supports autocenter: %s.", + FFStrError(ret)); } /* Check for axes, we have an artificial limit on axes */ @@ -481,12 +468,10 @@ GetSupportedFeatures(SDL_Haptic * haptic) return 0; } - /* * Opens the haptic device from the file descriptor. */ -static int -SDL_SYS_HapticOpenFromService(SDL_Haptic * haptic, io_service_t service) +static int SDL_SYS_HapticOpenFromService(SDL_Haptic *haptic, io_service_t service) { HRESULT ret; int ret2; @@ -514,7 +499,6 @@ SDL_SYS_HapticOpenFromService(SDL_Haptic * haptic, io_service_t service) goto open_err; } - /* Reset and then enable actuators. */ ret = FFDeviceSendForceFeedbackCommand(haptic->hwdata->device, FFSFFC_RESET); @@ -530,7 +514,6 @@ SDL_SYS_HapticOpenFromService(SDL_Haptic * haptic, io_service_t service) goto open_err; } - /* Allocate effects memory. */ haptic->effects = (struct haptic_effect *) SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); @@ -545,23 +528,20 @@ SDL_SYS_HapticOpenFromService(SDL_Haptic * haptic, io_service_t service) return 0; /* Error handling */ - open_err: +open_err: FFReleaseDevice(haptic->hwdata->device); - creat_err: +creat_err: if (haptic->hwdata != NULL) { SDL_free(haptic->hwdata); haptic->hwdata = NULL; } return -1; - } - /* * Opens a haptic device for usage. */ -int -SDL_SYS_HapticOpen(SDL_Haptic * haptic) +int SDL_SYS_HapticOpen(SDL_Haptic *haptic) { SDL_hapticlist_item *item; item = HapticByDevIndex(haptic->index); @@ -569,12 +549,10 @@ SDL_SYS_HapticOpen(SDL_Haptic * haptic) return SDL_SYS_HapticOpenFromService(haptic, item->dev); } - /* * Opens a haptic device from first mouse it finds for usage. */ -int -SDL_SYS_HapticMouse(void) +int SDL_SYS_HapticMouse(void) { int device_index = 0; SDL_hapticlist_item *item; @@ -590,12 +568,10 @@ SDL_SYS_HapticMouse(void) return -1; } - /* * Checks to see if a joystick has haptic features. */ -int -SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) +int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) { #ifdef SDL_JOYSTICK_IOKIT if (joystick->driver != &SDL_DARWIN_JoystickDriver) { @@ -608,18 +584,16 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) return SDL_FALSE; } - /* * Checks to see if the haptic device and joystick are in reality the same. */ -int -SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) +int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) { #ifdef SDL_JOYSTICK_IOKIT if (joystick->driver != &SDL_DARWIN_JoystickDriver) { return 0; } - if (IOObjectIsEqualTo((io_object_t) ((size_t)haptic->hwdata->device), + if (IOObjectIsEqualTo((io_object_t)((size_t)haptic->hwdata->device), joystick->hwdata->ffservice)) { return 1; } @@ -627,25 +601,23 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) return 0; } - /* * Opens a SDL_Haptic from a SDL_Joystick. */ -int -SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) +int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) { #ifdef SDL_JOYSTICK_IOKIT int device_index = 0; SDL_hapticlist_item *item; - + if (joystick->driver != &SDL_DARWIN_JoystickDriver) { return -1; } for (item = SDL_hapticlist; item; item = item->next) { - if (IOObjectIsEqualTo((io_object_t) item->dev, - joystick->hwdata->ffservice)) { - haptic->index = device_index; - break; + if (IOObjectIsEqualTo((io_object_t)item->dev, + joystick->hwdata->ffservice)) { + haptic->index = device_index; + break; } ++device_index; } @@ -656,12 +628,10 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) #endif } - /* * Closes the haptic device. */ -void -SDL_SYS_HapticClose(SDL_Haptic * haptic) +void SDL_SYS_HapticClose(SDL_Haptic *haptic) { if (haptic->hwdata) { @@ -679,12 +649,10 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic) } } - /* * Clean up after system specific haptic stuff */ -void -SDL_SYS_HapticQuit(void) +void SDL_SYS_HapticQuit(void) { SDL_hapticlist_item *item; SDL_hapticlist_item *next = NULL; @@ -704,12 +672,10 @@ SDL_SYS_HapticQuit(void) SDL_hapticlist_tail = NULL; } - /* * Converts an SDL trigger button to an FFEFFECT trigger button. */ -static DWORD -FFGetTriggerButton(Uint16 button) +static DWORD FFGetTriggerButton(Uint16 button) { DWORD dwTriggerButton; @@ -722,18 +688,16 @@ FFGetTriggerButton(Uint16 button) return dwTriggerButton; } - /* * Sets the direction. */ -static int -SDL_SYS_SetDirection(FFEFFECT * effect, SDL_HapticDirection * dir, int naxes) +static int SDL_SYS_SetDirection(FFEFFECT *effect, SDL_HapticDirection *dir, int naxes) { LONG *rglDir; /* Handle no axes a part. */ if (naxes == 0) { - effect->dwFlags |= FFEFF_SPHERICAL; /* Set as default. */ + effect->dwFlags |= FFEFF_SPHERICAL; /* Set as default. */ effect->rglDirection = NULL; return 0; } @@ -781,21 +745,19 @@ SDL_SYS_SetDirection(FFEFFECT * effect, SDL_HapticDirection * dir, int naxes) } } - /* Clamps and converts. */ -#define CCONVERT(x) (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF) +#define CCONVERT(x) (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF) /* Just converts. */ -#define CONVERT(x) (((x)*10000) / 0x7FFF) +#define CONVERT(x) (((x)*10000) / 0x7FFF) /* * Creates the FFEFFECT from a SDL_HapticEffect. */ -static int -SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src) +static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffect *src) { int i; FFCONSTANTFORCE *constant = NULL; FFPERIODIC *periodic = NULL; - FFCONDITION *condition = NULL; /* Actually an array of conditions - one per axis. */ + FFCONDITION *condition = NULL; /* Actually an array of conditions - one per axis. */ FFRAMPFORCE *ramp = NULL; FFCUSTOMFORCE *custom = NULL; FFENVELOPE *envelope = NULL; @@ -808,10 +770,10 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src) /* Set global stuff. */ SDL_memset(dest, 0, sizeof(FFEFFECT)); - dest->dwSize = sizeof(FFEFFECT); /* Set the structure size. */ - dest->dwSamplePeriod = 0; /* Not used by us. */ - dest->dwGain = 10000; /* Gain is set globally, not locally. */ - dest->dwFlags = FFEFF_OBJECTOFFSETS; /* Seems obligatory. */ + dest->dwSize = sizeof(FFEFFECT); /* Set the structure size. */ + dest->dwSamplePeriod = 0; /* Not used by us. */ + dest->dwGain = 10000; /* Gain is set globally, not locally. */ + dest->dwFlags = FFEFF_OBJECTOFFSETS; /* Seems obligatory. */ /* Envelope. */ envelope = SDL_malloc(sizeof(FFENVELOPE)); @@ -820,7 +782,7 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src) } SDL_memset(envelope, 0, sizeof(FFENVELOPE)); dest->lpEnvelope = envelope; - envelope->dwSize = sizeof(FFENVELOPE); /* Always should be this. */ + envelope->dwSize = sizeof(FFENVELOPE); /* Always should be this. */ /* Axes. */ if (src->constant.direction.type == SDL_HAPTIC_STEERING_AXIS) { @@ -833,7 +795,7 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src) if (axes == NULL) { return SDL_OutOfMemory(); } - axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */ + axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */ if (dest->cAxes > 1) { axes[1] = haptic->hwdata->axes[1]; } @@ -843,7 +805,6 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src) dest->rgdwAxes = axes; } - /* The big type handling switch, even bigger then Linux's version. */ switch (src->type) { case SDL_HAPTIC_CONSTANT: @@ -863,17 +824,15 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src) dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */ dest->dwTriggerButton = FFGetTriggerButton(hap_constant->button); dest->dwTriggerRepeatInterval = hap_constant->interval; - dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */ + dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */ /* Direction. */ - if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) - < 0) { + if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) { return -1; } /* Envelope */ - if ((hap_constant->attack_length == 0) - && (hap_constant->fade_length == 0)) { + if ((hap_constant->attack_length == 0) && (hap_constant->fade_length == 0)) { SDL_free(envelope); dest->lpEnvelope = NULL; } else { @@ -901,8 +860,8 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src) /* Specifics */ periodic->dwMagnitude = CONVERT(SDL_abs(hap_periodic->magnitude)); periodic->lOffset = CONVERT(hap_periodic->offset); - periodic->dwPhase = - (hap_periodic->phase + (hap_periodic->magnitude < 0 ? 18000 : 0)) % 36000; + periodic->dwPhase = + (hap_periodic->phase + (hap_periodic->magnitude < 0 ? 18000 : 0)) % 36000; periodic->dwPeriod = hap_periodic->period * 1000; dest->cbTypeSpecificParams = sizeof(FFPERIODIC); dest->lpvTypeSpecificParams = periodic; @@ -911,17 +870,15 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src) dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */ dest->dwTriggerButton = FFGetTriggerButton(hap_periodic->button); dest->dwTriggerRepeatInterval = hap_periodic->interval; - dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */ + dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */ /* Direction. */ - if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) - < 0) { + if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) { return -1; } /* Envelope */ - if ((hap_periodic->attack_length == 0) - && (hap_periodic->fade_length == 0)) { + if ((hap_periodic->attack_length == 0) && (hap_periodic->fade_length == 0)) { SDL_free(envelope); dest->lpEnvelope = NULL; } else { @@ -964,14 +921,13 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src) dest->lpvTypeSpecificParams = condition; /* Generics */ - dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */ + dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */ dest->dwTriggerButton = FFGetTriggerButton(hap_condition->button); dest->dwTriggerRepeatInterval = hap_condition->interval; - dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */ + dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */ /* Direction. */ - if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) - < 0) { + if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) { return -1; } @@ -996,10 +952,10 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src) dest->lpvTypeSpecificParams = ramp; /* Generics */ - dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */ + dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */ dest->dwTriggerButton = FFGetTriggerButton(hap_ramp->button); dest->dwTriggerRepeatInterval = hap_ramp->interval; - dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */ + dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */ /* Direction. */ if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) { @@ -1033,17 +989,17 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src) custom->cSamples = hap_custom->samples; custom->rglForceData = SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels); - for (i = 0; i < hap_custom->samples * hap_custom->channels; i++) { /* Copy data. */ + for (i = 0; i < hap_custom->samples * hap_custom->channels; i++) { /* Copy data. */ custom->rglForceData[i] = CCONVERT(hap_custom->data[i]); } dest->cbTypeSpecificParams = sizeof(FFCUSTOMFORCE); dest->lpvTypeSpecificParams = custom; /* Generics */ - dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */ + dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */ dest->dwTriggerButton = FFGetTriggerButton(hap_custom->button); dest->dwTriggerRepeatInterval = hap_custom->interval; - dest->dwStartDelay = hap_custom->delay * 1000; /* In microseconds. */ + dest->dwStartDelay = hap_custom->delay * 1000; /* In microseconds. */ /* Direction. */ if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < @@ -1052,8 +1008,7 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src) } /* Envelope */ - if ((hap_custom->attack_length == 0) - && (hap_custom->fade_length == 0)) { + if ((hap_custom->attack_length == 0) && (hap_custom->fade_length == 0)) { SDL_free(envelope); dest->lpEnvelope = NULL; } else { @@ -1065,7 +1020,6 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src) break; - default: return SDL_SetError("Haptic: Unknown effect type."); } @@ -1073,12 +1027,10 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src) return 0; } - /* * Frees an FFEFFECT allocated by SDL_SYS_ToFFEFFECT. */ -static void -SDL_SYS_HapticFreeFFEFFECT(FFEFFECT * effect, int type) +static void SDL_SYS_HapticFreeFFEFFECT(FFEFFECT *effect, int type) { FFCUSTOMFORCE *custom; @@ -1087,8 +1039,8 @@ SDL_SYS_HapticFreeFFEFFECT(FFEFFECT * effect, int type) SDL_free(effect->rgdwAxes); effect->rgdwAxes = NULL; if (effect->lpvTypeSpecificParams != NULL) { - if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */ - custom = (FFCUSTOMFORCE *) effect->lpvTypeSpecificParams; + if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */ + custom = (FFCUSTOMFORCE *)effect->lpvTypeSpecificParams; SDL_free(custom->rglForceData); custom->rglForceData = NULL; } @@ -1099,7 +1051,6 @@ SDL_SYS_HapticFreeFFEFFECT(FFEFFECT * effect, int type) effect->rglDirection = NULL; } - /* * Gets the effect type from the generic SDL haptic effect wrapper. */ @@ -1113,9 +1064,9 @@ SDL_SYS_HapticEffectType(Uint16 type) case SDL_HAPTIC_RAMP: return kFFEffectType_RampForce_ID; - /* !!! FIXME: put this back when we have more bits in 2.1 */ - /* case SDL_HAPTIC_SQUARE: - return kFFEffectType_Square_ID; */ + /* !!! FIXME: put this back when we have more bits in 2.1 */ + /* case SDL_HAPTIC_SQUARE: + return kFFEffectType_Square_ID; */ case SDL_HAPTIC_SINE: return kFFEffectType_Sine_ID; @@ -1150,13 +1101,11 @@ SDL_SYS_HapticEffectType(Uint16 type) } } - /* * Creates a new haptic effect. */ -int -SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, - SDL_HapticEffect * base) +int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, + SDL_HapticEffect *base) { HRESULT ret; CFUUIDRef type; @@ -1191,22 +1140,20 @@ SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, return 0; - err_effectdone: +err_effectdone: SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, base->type); - err_hweffect: +err_hweffect: SDL_free(effect->hweffect); effect->hweffect = NULL; return -1; } - /* * Updates an effect. */ -int -SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, - struct haptic_effect *effect, - SDL_HapticEffect * data) +int SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic, + struct haptic_effect *effect, + SDL_HapticEffect *data) { HRESULT ret; FFEffectParameterFlag flags; @@ -1221,11 +1168,11 @@ SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, /* Set the flags. Might be worthwhile to diff temp with loaded effect and * only change those parameters. */ flags = FFEP_DIRECTION | - FFEP_DURATION | - FFEP_ENVELOPE | - FFEP_STARTDELAY | - FFEP_TRIGGERBUTTON | - FFEP_TRIGGERREPEATINTERVAL | FFEP_TYPESPECIFICPARAMS; + FFEP_DURATION | + FFEP_ENVELOPE | + FFEP_STARTDELAY | + FFEP_TRIGGERBUTTON | + FFEP_TRIGGERREPEATINTERVAL | FFEP_TYPESPECIFICPARAMS; /* Create the actual effect. */ ret = FFEffectSetParameters(effect->hweffect->ref, &temp, flags); @@ -1240,18 +1187,16 @@ SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, return 0; - err_update: +err_update: SDL_SYS_HapticFreeFFEFFECT(&temp, data->type); return -1; } - /* * Runs an effect. */ -int -SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, - Uint32 iterations) +int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, + Uint32 iterations) { HRESULT ret; Uint32 iter; @@ -1272,12 +1217,10 @@ SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, return 0; } - /* * Stops an effect. */ -int -SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) +int SDL_SYS_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect) { HRESULT ret; @@ -1290,12 +1233,10 @@ SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) return 0; } - /* * Frees the effect. */ -void -SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) +void SDL_SYS_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect) { HRESULT ret; @@ -1310,13 +1251,11 @@ SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) effect->hweffect = NULL; } - /* * Gets the status of a haptic effect. */ -int -SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, - struct haptic_effect *effect) +int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic, + struct haptic_effect *effect) { HRESULT ret; FFEffectStatusFlag status; @@ -1331,15 +1270,13 @@ SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, if (status == 0) { return SDL_FALSE; } - return SDL_TRUE; /* Assume it's playing or emulated. */ + return SDL_TRUE; /* Assume it's playing or emulated. */ } - /* * Sets the gain. */ -int -SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain) +int SDL_SYS_HapticSetGain(SDL_Haptic *haptic, int gain) { HRESULT ret; Uint32 val; @@ -1354,12 +1291,10 @@ SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain) return 0; } - /* * Sets the autocentering. */ -int -SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) +int SDL_SYS_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter) { HRESULT ret; Uint32 val; @@ -1381,12 +1316,10 @@ SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) return 0; } - /* * Pauses the device. */ -int -SDL_SYS_HapticPause(SDL_Haptic * haptic) +int SDL_SYS_HapticPause(SDL_Haptic *haptic) { HRESULT ret; @@ -1399,12 +1332,10 @@ SDL_SYS_HapticPause(SDL_Haptic * haptic) return 0; } - /* * Unpauses the device. */ -int -SDL_SYS_HapticUnpause(SDL_Haptic * haptic) +int SDL_SYS_HapticUnpause(SDL_Haptic *haptic) { HRESULT ret; @@ -1417,12 +1348,10 @@ SDL_SYS_HapticUnpause(SDL_Haptic * haptic) return 0; } - /* * Stops all currently playing effects. */ -int -SDL_SYS_HapticStopAll(SDL_Haptic * haptic) +int SDL_SYS_HapticStopAll(SDL_Haptic *haptic) { HRESULT ret; diff --git a/src/haptic/darwin/SDL_syshaptic_c.h b/src/haptic/darwin/SDL_syshaptic_c.h index 8e3a6ca95..4a98c5a82 100644 --- a/src/haptic/darwin/SDL_syshaptic_c.h +++ b/src/haptic/darwin/SDL_syshaptic_c.h @@ -25,8 +25,7 @@ #define kIOMainPortDefault kIOMasterPortDefault #endif -extern int MacHaptic_MaybeAddDevice( io_object_t device ); -extern int MacHaptic_MaybeRemoveDevice( io_object_t device ); +extern int MacHaptic_MaybeAddDevice(io_object_t device); +extern int MacHaptic_MaybeRemoveDevice(io_object_t device); /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/haptic/dummy/SDL_syshaptic.c b/src/haptic/dummy/SDL_syshaptic.c index f356195b7..46edc767c 100644 --- a/src/haptic/dummy/SDL_syshaptic.c +++ b/src/haptic/dummy/SDL_syshaptic.c @@ -25,22 +25,17 @@ #include "SDL_haptic.h" #include "../SDL_syshaptic.h" - -static int -SDL_SYS_LogicError(void) +static int SDL_SYS_LogicError(void) { return SDL_SetError("Logic error: No haptic devices available."); } - -int -SDL_SYS_HapticInit(void) +int SDL_SYS_HapticInit(void) { return 0; } -int -SDL_SYS_NumHaptics(void) +int SDL_SYS_NumHaptics(void) { return 0; } @@ -52,131 +47,98 @@ SDL_SYS_HapticName(int index) return NULL; } - -int -SDL_SYS_HapticOpen(SDL_Haptic * haptic) +int SDL_SYS_HapticOpen(SDL_Haptic *haptic) { return SDL_SYS_LogicError(); } - -int -SDL_SYS_HapticMouse(void) +int SDL_SYS_HapticMouse(void) { return -1; } - -int -SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) +int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) { return 0; } - -int -SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) +int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) { return SDL_SYS_LogicError(); } - -int -SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) +int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) { return 0; } - -void -SDL_SYS_HapticClose(SDL_Haptic * haptic) +void SDL_SYS_HapticClose(SDL_Haptic *haptic) { return; } - -void -SDL_SYS_HapticQuit(void) +void SDL_SYS_HapticQuit(void) { return; } - -int -SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, - struct haptic_effect *effect, SDL_HapticEffect * base) +int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, + struct haptic_effect *effect, SDL_HapticEffect *base) { return SDL_SYS_LogicError(); } - -int -SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, - struct haptic_effect *effect, - SDL_HapticEffect * data) +int SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic, + struct haptic_effect *effect, + SDL_HapticEffect *data) { return SDL_SYS_LogicError(); } - -int -SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, - Uint32 iterations) +int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, + Uint32 iterations) { return SDL_SYS_LogicError(); } - -int -SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) +int SDL_SYS_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect) { return SDL_SYS_LogicError(); } - -void -SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) +void SDL_SYS_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect) { SDL_SYS_LogicError(); return; } - -int -SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, - struct haptic_effect *effect) +int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic, + struct haptic_effect *effect) { return SDL_SYS_LogicError(); } - -int -SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain) +int SDL_SYS_HapticSetGain(SDL_Haptic *haptic, int gain) { return SDL_SYS_LogicError(); } - -int -SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) +int SDL_SYS_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter) { return SDL_SYS_LogicError(); } -int -SDL_SYS_HapticPause(SDL_Haptic * haptic) +int SDL_SYS_HapticPause(SDL_Haptic *haptic) { return SDL_SYS_LogicError(); } -int -SDL_SYS_HapticUnpause(SDL_Haptic * haptic) +int SDL_SYS_HapticUnpause(SDL_Haptic *haptic) { return SDL_SYS_LogicError(); } -int -SDL_SYS_HapticStopAll(SDL_Haptic * haptic) +int SDL_SYS_HapticStopAll(SDL_Haptic *haptic) { return SDL_SYS_LogicError(); } diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index 7ae9c3ddb..6a0713d44 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -30,12 +30,12 @@ #include "../../core/linux/SDL_evdev_capabilities.h" #include "../../core/linux/SDL_udev.h" -#include /* close */ -#include /* Force feedback linux stuff. */ -#include /* O_RDWR */ -#include /* INT_MAX */ -#include /* errno, strerror */ -#include /* stat */ +#include /* close */ +#include /* Force feedback linux stuff. */ +#include /* O_RDWR */ +#include /* INT_MAX */ +#include /* errno, strerror */ +#include /* stat */ /* Just in case. */ #ifndef M_PI @@ -56,45 +56,42 @@ static void haptic_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, */ typedef struct SDL_hapticlist_item { - char *fname; /* Dev path name (like /dev/input/event1) */ - SDL_Haptic *haptic; /* Associated haptic. */ + char *fname; /* Dev path name (like /dev/input/event1) */ + SDL_Haptic *haptic; /* Associated haptic. */ dev_t dev_num; struct SDL_hapticlist_item *next; } SDL_hapticlist_item; - /* * Haptic system hardware data. */ struct haptic_hwdata { - int fd; /* File descriptor of the device. */ - char *fname; /* Points to the name in SDL_hapticlist. */ + int fd; /* File descriptor of the device. */ + char *fname; /* Points to the name in SDL_hapticlist. */ }; - /* * Haptic system effect data. */ struct haptic_hweffect { - struct ff_effect effect; /* The linux kernel effect structure. */ + struct ff_effect effect; /* The linux kernel effect structure. */ }; static SDL_hapticlist_item *SDL_hapticlist = NULL; static SDL_hapticlist_item *SDL_hapticlist_tail = NULL; static int numhaptics = 0; -#define EV_TEST(ev,f) \ - if (test_bit((ev), features)) { \ - ret |= (f); \ - } +#define EV_TEST(ev, f) \ + if (test_bit((ev), features)) { \ + ret |= (f); \ + } /* * Test whether a device has haptic properties. * Returns available properties or 0 if there are none. */ -static int -EV_IsHaptic(int fd) +static int EV_IsHaptic(int fd) { unsigned int ret; unsigned long features[1 + FF_MAX / sizeof(unsigned long)]; @@ -128,12 +125,10 @@ EV_IsHaptic(int fd) return ret; } - /* * Tests whether a device is a mouse or not. */ -static int -EV_IsMouse(int fd) +static int EV_IsMouse(int fd) { unsigned long argp[40]; @@ -153,8 +148,7 @@ EV_IsMouse(int fd) /* * Initializes the haptic subsystem by finding available devices. */ -int -SDL_SYS_HapticInit(void) +int SDL_SYS_HapticInit(void) { const char joydev_pattern[] = "/dev/input/event%d"; char path[PATH_MAX]; @@ -176,7 +170,7 @@ SDL_SYS_HapticInit(void) return SDL_SetError("Could not initialize UDEV"); } - if ( SDL_UDEV_AddCallback(haptic_udev_callback) < 0) { + if (SDL_UDEV_AddCallback(haptic_udev_callback) < 0) { SDL_UDEV_Quit(); return SDL_SetError("Could not setup haptic <-> udev callback"); } @@ -188,14 +182,12 @@ SDL_SYS_HapticInit(void) return numhaptics; } -int -SDL_SYS_NumHaptics(void) +int SDL_SYS_NumHaptics(void) { return numhaptics; } -static SDL_hapticlist_item * -HapticByDevIndex(int device_index) +static SDL_hapticlist_item *HapticByDevIndex(int device_index) { SDL_hapticlist_item *item = SDL_hapticlist; @@ -219,25 +211,22 @@ static void haptic_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, return; } - switch( udev_type ) - { - case SDL_UDEV_DEVICEADDED: - MaybeAddDevice(devpath); - break; + switch (udev_type) { + case SDL_UDEV_DEVICEADDED: + MaybeAddDevice(devpath); + break; - case SDL_UDEV_DEVICEREMOVED: - MaybeRemoveDevice(devpath); - break; + case SDL_UDEV_DEVICEREMOVED: + MaybeRemoveDevice(devpath); + break; - default: - break; + default: + break; } - } #endif /* SDL_USE_LIBUDEV */ -static int -MaybeAddDevice(const char *path) +static int MaybeAddDevice(const char *path) { struct stat sb; int fd; @@ -256,7 +245,7 @@ MaybeAddDevice(const char *path) /* check for duplicates */ for (item = SDL_hapticlist; item != NULL; item = item->next) { if (item->dev_num == sb.st_rdev) { - return -1; /* duplicate. */ + return -1; /* duplicate. */ } } @@ -277,7 +266,7 @@ MaybeAddDevice(const char *path) return -1; } - item = (SDL_hapticlist_item *) SDL_calloc(1, sizeof (SDL_hapticlist_item)); + item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item)); if (item == NULL) { return -1; } @@ -306,8 +295,7 @@ MaybeAddDevice(const char *path) } #if SDL_USE_LIBUDEV -static int -MaybeRemoveDevice(const char* path) +static int MaybeRemoveDevice(const char *path) { SDL_hapticlist_item *item; SDL_hapticlist_item *prev = NULL; @@ -349,8 +337,7 @@ MaybeRemoveDevice(const char* path) /* * Gets the name from a file descriptor. */ -static const char * -SDL_SYS_HapticNameFromFD(int fd) +static const char *SDL_SYS_HapticNameFromFD(int fd) { static char namebuf[128]; @@ -362,7 +349,6 @@ SDL_SYS_HapticNameFromFD(int fd) return namebuf; } - /* * Return the name of a haptic device, does not need to be opened. */ @@ -391,12 +377,10 @@ SDL_SYS_HapticName(int index) return name; } - /* * Opens the haptic device from the file descriptor. */ -static int -SDL_SYS_HapticOpenFromFD(SDL_Haptic * haptic, int fd) +static int SDL_SYS_HapticOpenFromFD(SDL_Haptic *haptic, int fd) { /* Allocate the hwdata */ haptic->hwdata = (struct haptic_hwdata *) @@ -410,7 +394,7 @@ SDL_SYS_HapticOpenFromFD(SDL_Haptic * haptic, int fd) /* Set the data. */ haptic->hwdata->fd = fd; haptic->supported = EV_IsHaptic(fd); - haptic->naxes = 2; /* Hardcoded for now, not sure if it's possible to find out. */ + haptic->naxes = 2; /* Hardcoded for now, not sure if it's possible to find out. */ /* Set the effects */ if (ioctl(fd, EVIOCGEFFECTS, &haptic->neffects) < 0) { @@ -418,7 +402,7 @@ SDL_SYS_HapticOpenFromFD(SDL_Haptic * haptic, int fd) strerror(errno)); goto open_err; } - haptic->nplaying = haptic->neffects; /* Linux makes no distinction. */ + haptic->nplaying = haptic->neffects; /* Linux makes no distinction. */ haptic->effects = (struct haptic_effect *) SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); if (haptic->effects == NULL) { @@ -432,7 +416,7 @@ SDL_SYS_HapticOpenFromFD(SDL_Haptic * haptic, int fd) return 0; /* Error handling */ - open_err: +open_err: close(fd); if (haptic->hwdata != NULL) { SDL_free(haptic->hwdata); @@ -441,12 +425,10 @@ SDL_SYS_HapticOpenFromFD(SDL_Haptic * haptic, int fd) return -1; } - /* * Opens a haptic device for usage. */ -int -SDL_SYS_HapticOpen(SDL_Haptic * haptic) +int SDL_SYS_HapticOpen(SDL_Haptic *haptic) { int fd; int ret; @@ -467,16 +449,14 @@ SDL_SYS_HapticOpen(SDL_Haptic * haptic) } /* Set the fname. */ - haptic->hwdata->fname = SDL_strdup( item->fname ); + haptic->hwdata->fname = SDL_strdup(item->fname); return 0; } - /* * Opens a haptic device from first mouse it finds for usage. */ -int -SDL_SYS_HapticMouse(void) +int SDL_SYS_HapticMouse(void) { int fd; int device_index = 0; @@ -504,12 +484,10 @@ SDL_SYS_HapticMouse(void) return -1; } - /* * Checks to see if a joystick has haptic features. */ -int -SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) +int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) { #ifdef SDL_JOYSTICK_LINUX if (joystick->driver != &SDL_LINUX_JoystickDriver) { @@ -522,12 +500,10 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) return SDL_FALSE; } - /* * Checks to see if the haptic device and joystick are in reality the same. */ -int -SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) +int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) { #ifdef SDL_JOYSTICK_LINUX if (joystick->driver != &SDL_LINUX_JoystickDriver) { @@ -542,19 +518,17 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) return 0; } - /* * Opens a SDL_Haptic from a SDL_Joystick. */ -int -SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) +int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) { #ifdef SDL_JOYSTICK_LINUX int device_index = 0; int fd; int ret; SDL_hapticlist_item *item; - + if (joystick->driver != &SDL_LINUX_JoystickDriver) { return -1; } @@ -581,7 +555,7 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) return -1; } - haptic->hwdata->fname = SDL_strdup( joystick->hwdata->fname ); + haptic->hwdata->fname = SDL_strdup(joystick->hwdata->fname); return 0; #else @@ -589,12 +563,10 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) #endif } - /* * Closes the haptic device. */ -void -SDL_SYS_HapticClose(SDL_Haptic * haptic) +void SDL_SYS_HapticClose(SDL_Haptic *haptic) { if (haptic->hwdata) { @@ -616,12 +588,10 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic) SDL_memset(haptic, 0, sizeof(SDL_Haptic)); } - /* * Clean up after system specific haptic stuff */ -void -SDL_SYS_HapticQuit(void) +void SDL_SYS_HapticQuit(void) { SDL_hapticlist_item *item = NULL; SDL_hapticlist_item *next = NULL; @@ -644,12 +614,10 @@ SDL_SYS_HapticQuit(void) SDL_hapticlist_tail = NULL; } - /* * Converts an SDL button to a ff_trigger button. */ -static Uint16 -SDL_SYS_ToButton(Uint16 button) +static Uint16 SDL_SYS_ToButton(Uint16 button) { Uint16 ff_button; @@ -666,12 +634,10 @@ SDL_SYS_ToButton(Uint16 button) return ff_button; } - /* * Initializes the ff_effect usable direction from a SDL_HapticDirection. */ -static int -SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src) +static int SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection *src) { Uint32 tmp; @@ -689,21 +655,21 @@ SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src) i.e. the opposite convention of SDL directions. */ tmp = ((src->dir[0] % 36000) * 0x8000) / 18000; /* convert to range [0,0xFFFF] */ - *dest = (Uint16) tmp; + *dest = (Uint16)tmp; break; case SDL_HAPTIC_SPHERICAL: - /* - We convert to polar, because that's the only supported direction on Linux. - The first value of a spherical direction is practically the same as a - Polar direction, except that we have to add 90 degrees. It is the angle - from EAST {1,0} towards SOUTH {0,1}. - --> add 9000 - --> finally convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR. - */ - tmp = ((src->dir[0]) + 9000) % 36000; /* Convert to polars */ - tmp = (tmp * 0x8000) / 18000; /* convert to range [0,0xFFFF] */ - *dest = (Uint16) tmp; + /* + We convert to polar, because that's the only supported direction on Linux. + The first value of a spherical direction is practically the same as a + Polar direction, except that we have to add 90 degrees. It is the angle + from EAST {1,0} towards SOUTH {0,1}. + --> add 9000 + --> finally convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR. + */ + tmp = ((src->dir[0]) + 9000) % 36000; /* Convert to polars */ + tmp = (tmp * 0x8000) / 18000; /* convert to range [0,0xFFFF] */ + *dest = (Uint16)tmp; break; case SDL_HAPTIC_CARTESIAN: @@ -725,7 +691,7 @@ SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src) */ tmp = (((Sint32) (f * 18000. / M_PI)) + 45000) % 36000; tmp = (tmp * 0x8000) / 18000; /* convert to range [0,0xFFFF] */ - *dest = (Uint16) tmp; + *dest = (Uint16)tmp; } break; case SDL_HAPTIC_STEERING_AXIS: @@ -738,14 +704,12 @@ SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src) return 0; } - -#define CLAMP(x) (((x) > 32767) ? 32767 : x) +#define CLAMP(x) (((x) > 32767) ? 32767 : x) /* * Initializes the Linux effect struct from a haptic_effect. * Values above 32767 (for unsigned) are unspecified so we must clamp. */ -static int -SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) +static int SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect *src) { SDL_HapticConstant *constant; SDL_HapticPeriodic *periodic; @@ -767,8 +731,7 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) } /* Replay */ - dest->replay.length = (constant->length == SDL_HAPTIC_INFINITY) ? - 0 : CLAMP(constant->length); + dest->replay.length = (constant->length == SDL_HAPTIC_INFINITY) ? 0 : CLAMP(constant->length); dest->replay.delay = CLAMP(constant->delay); /* Trigger */ @@ -803,8 +766,7 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) } /* Replay */ - dest->replay.length = (periodic->length == SDL_HAPTIC_INFINITY) ? - 0 : CLAMP(periodic->length); + dest->replay.length = (periodic->length == SDL_HAPTIC_INFINITY) ? 0 : CLAMP(periodic->length); dest->replay.delay = CLAMP(periodic->delay); /* Trigger */ @@ -814,9 +776,9 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) /* Periodic */ if (periodic->type == SDL_HAPTIC_SINE) { dest->u.periodic.waveform = FF_SINE; - /* !!! FIXME: put this back when we have more bits in 2.1 */ - /* else if (periodic->type == SDL_HAPTIC_SQUARE) - dest->u.periodic.waveform = FF_SQUARE; */ + /* !!! FIXME: put this back when we have more bits in 2.1 */ + /* else if (periodic->type == SDL_HAPTIC_SQUARE) + dest->u.periodic.waveform = FF_SQUARE; */ } else if (periodic->type == SDL_HAPTIC_TRIANGLE) { dest->u.periodic.waveform = FF_TRIANGLE; } else if (periodic->type == SDL_HAPTIC_SAWTOOTHUP) { @@ -856,12 +818,11 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) } else if (condition->type == SDL_HAPTIC_FRICTION) { dest->type = FF_FRICTION; } - - dest->direction = 0; /* Handled by the condition-specifics. */ + + dest->direction = 0; /* Handled by the condition-specifics. */ /* Replay */ - dest->replay.length = (condition->length == SDL_HAPTIC_INFINITY) ? - 0 : CLAMP(condition->length); + dest->replay.length = (condition->length == SDL_HAPTIC_INFINITY) ? 0 : CLAMP(condition->length); dest->replay.delay = CLAMP(condition->delay); /* Trigger */ @@ -900,8 +861,7 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) } /* Replay */ - dest->replay.length = (ramp->length == SDL_HAPTIC_INFINITY) ? - 0 : CLAMP(ramp->length); + dest->replay.length = (ramp->length == SDL_HAPTIC_INFINITY) ? 0 : CLAMP(ramp->length); dest->replay.delay = CLAMP(ramp->delay); /* Trigger */ @@ -928,8 +888,7 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) dest->direction = 0; /* Replay */ - dest->replay.length = (leftright->length == SDL_HAPTIC_INFINITY) ? - 0 : CLAMP(leftright->length); + dest->replay.length = (leftright->length == SDL_HAPTIC_INFINITY) ? 0 : CLAMP(leftright->length); /* Trigger */ dest->trigger.button = 0; @@ -941,7 +900,6 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) break; - default: return SDL_SetError("Haptic: Unknown effect type."); } @@ -949,13 +907,11 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) return 0; } - /* * Creates a new haptic effect. */ -int -SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, - SDL_HapticEffect * base) +int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, + SDL_HapticEffect *base) { struct ff_effect *linux_effect; @@ -971,7 +927,7 @@ SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, if (SDL_SYS_ToFFEffect(linux_effect, base) != 0) { goto new_effect_err; } - linux_effect->id = -1; /* Have the kernel give it an id */ + linux_effect->id = -1; /* Have the kernel give it an id */ /* Upload the effect */ if (ioctl(haptic->hwdata->fd, EVIOCSFF, linux_effect) < 0) { @@ -982,23 +938,21 @@ SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, return 0; - new_effect_err: +new_effect_err: SDL_free(effect->hweffect); effect->hweffect = NULL; return -1; } - /* * Updates an effect. * * Note: Dynamically updating the direction can in some cases force * the effect to restart and run once. */ -int -SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, - struct haptic_effect *effect, - SDL_HapticEffect * data) +int SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic, + struct haptic_effect *effect, + SDL_HapticEffect *data) { struct ff_effect linux_effect; @@ -1021,13 +975,11 @@ SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, return effect->hweffect->effect.id; } - /* * Runs an effect. */ -int -SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, - Uint32 iterations) +int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, + Uint32 iterations) { struct input_event run; @@ -1037,19 +989,17 @@ SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, /* We don't actually have infinity here, so we just do INT_MAX which is pretty damn close. */ run.value = (iterations > INT_MAX) ? INT_MAX : iterations; - if (write(haptic->hwdata->fd, (const void *) &run, sizeof(run)) < 0) { + if (write(haptic->hwdata->fd, (const void *)&run, sizeof(run)) < 0) { return SDL_SetError("Haptic: Unable to run the effect: %s", strerror(errno)); } return 0; } - /* * Stops an effect. */ -int -SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) +int SDL_SYS_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect) { struct input_event stop; @@ -1057,7 +1007,7 @@ SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) stop.code = effect->hweffect->effect.id; stop.value = 0; - if (write(haptic->hwdata->fd, (const void *) &stop, sizeof(stop)) < 0) { + if (write(haptic->hwdata->fd, (const void *)&stop, sizeof(stop)) < 0) { return SDL_SetError("Haptic: Unable to stop the effect: %s", strerror(errno)); } @@ -1065,12 +1015,10 @@ SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) return 0; } - /* * Frees the effect. */ -void -SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) +void SDL_SYS_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect) { if (ioctl(haptic->hwdata->fd, EVIOCRMFF, effect->hweffect->effect.id) < 0) { SDL_SetError("Haptic: Error removing the effect from the device: %s", @@ -1080,15 +1028,13 @@ SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) effect->hweffect = NULL; } - /* * Gets the status of a haptic effect. */ -int -SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, - struct haptic_effect *effect) +int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic, + struct haptic_effect *effect) { -#if 0 /* Not supported atm. */ +#if 0 /* Not supported atm. */ struct input_event ie; ie.type = EV_FF; @@ -1105,12 +1051,10 @@ SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, return -1; } - /* * Sets the gain. */ -int -SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain) +int SDL_SYS_HapticSetGain(SDL_Haptic *haptic, int gain) { struct input_event ie; @@ -1125,12 +1069,10 @@ SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain) return 0; } - /* * Sets the autocentering. */ -int -SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) +int SDL_SYS_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter) { struct input_event ie; @@ -1145,32 +1087,26 @@ SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) return 0; } - /* * Pausing is not supported atm by linux. */ -int -SDL_SYS_HapticPause(SDL_Haptic * haptic) +int SDL_SYS_HapticPause(SDL_Haptic *haptic) { return -1; } - /* * Unpausing is not supported atm by linux. */ -int -SDL_SYS_HapticUnpause(SDL_Haptic * haptic) +int SDL_SYS_HapticUnpause(SDL_Haptic *haptic) { return -1; } - /* * Stops all the currently playing effects. */ -int -SDL_SYS_HapticStopAll(SDL_Haptic * haptic) +int SDL_SYS_HapticStopAll(SDL_Haptic *haptic) { int i, ret; @@ -1179,8 +1115,7 @@ SDL_SYS_HapticStopAll(SDL_Haptic * haptic) if (haptic->effects[i].hweffect != NULL) { ret = SDL_SYS_HapticStopEffect(haptic, &haptic->effects[i]); if (ret < 0) { - return SDL_SetError - ("Haptic: Error while trying to stop all playing effects."); + return SDL_SetError("Haptic: Error while trying to stop all playing effects."); } } } diff --git a/src/haptic/windows/SDL_dinputhaptic.c b/src/haptic/windows/SDL_dinputhaptic.c index 4e06e20a0..7af3de9a1 100644 --- a/src/haptic/windows/SDL_dinputhaptic.c +++ b/src/haptic/windows/SDL_dinputhaptic.c @@ -43,19 +43,16 @@ extern HWND SDL_HelperWindow; static const HWND SDL_HelperWindow = NULL; #endif - /* * Internal stuff. */ static SDL_bool coinitialized = SDL_FALSE; static LPDIRECTINPUT8 dinput = NULL; - /* * Like SDL_SetError but for DX error codes. */ -static int -DI_SetError(const char *str, HRESULT err) +static int DI_SetError(const char *str, HRESULT err) { return SDL_SetError("Haptic error %s", str); } @@ -63,22 +60,20 @@ DI_SetError(const char *str, HRESULT err) /* * Callback to find the haptic devices. */ -static BOOL CALLBACK -EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext) +static BOOL CALLBACK EnumHapticsCallback(const DIDEVICEINSTANCE *pdidInstance, VOID *pContext) { - (void) pContext; + (void)pContext; SDL_DINPUT_HapticMaybeAddDevice(pdidInstance); - return DIENUM_CONTINUE; /* continue enumerating */ + return DIENUM_CONTINUE; /* continue enumerating */ } -int -SDL_DINPUT_HapticInit(void) +int SDL_DINPUT_HapticInit(void) { HRESULT ret; HINSTANCE instance; DWORD devClass; - if (dinput != NULL) { /* Already open. */ + if (dinput != NULL) { /* Already open. */ return SDL_SetError("Haptic: SubSystem already open."); } @@ -95,7 +90,7 @@ SDL_DINPUT_HapticInit(void) coinitialized = SDL_TRUE; ret = CoCreateInstance(&CLSID_DirectInput8, NULL, CLSCTX_INPROC_SERVER, - &IID_IDirectInput8, (LPVOID *) &dinput); + &IID_IDirectInput8, (LPVOID *)&dinput); if (FAILED(ret)) { SDL_SYS_HapticQuit(); return DI_SetError("CoCreateInstance", ret); @@ -106,7 +101,7 @@ SDL_DINPUT_HapticInit(void) if (instance == NULL) { SDL_SYS_HapticQuit(); return SDL_SetError("GetModuleHandle() failed with error code %lu.", - GetLastError()); + GetLastError()); } ret = IDirectInput8_Initialize(dinput, instance, DIRECTINPUT_VERSION); if (FAILED(ret)) { @@ -126,7 +121,7 @@ SDL_DINPUT_HapticInit(void) EnumHapticsCallback, NULL, DIEDFL_FORCEFEEDBACK | - DIEDFL_ATTACHEDONLY); + DIEDFL_ATTACHEDONLY); if (FAILED(ret)) { SDL_SYS_HapticQuit(); return DI_SetError("Enumerating DirectInput devices", ret); @@ -136,8 +131,7 @@ SDL_DINPUT_HapticInit(void) return 0; } -int -SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE * pdidInstance) +int SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE *pdidInstance) { HRESULT ret; LPDIRECTINPUTDEVICE8 device; @@ -146,13 +140,13 @@ SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE * pdidInstance) SDL_hapticlist_item *item = NULL; if (dinput == NULL) { - return -1; /* not initialized. We'll pick these up on enumeration if we init later. */ + return -1; /* not initialized. We'll pick these up on enumeration if we init later. */ } /* Make sure we don't already have it */ for (item = SDL_hapticlist; item; item = item->next) { if ((!item->bXInputHaptic) && (SDL_memcmp(&item->instance, pdidInstance, sizeof(*pdidInstance)) == 0)) { - return -1; /* Already added */ + return -1; /* Already added */ } } @@ -174,7 +168,7 @@ SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE * pdidInstance) } if ((capabilities.dwFlags & needflags) != needflags) { - return -1; /* not a device we can use. */ + return -1; /* not a device we can use. */ } item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item)); @@ -195,14 +189,13 @@ SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE * pdidInstance) return SDL_SYS_AddHapticDevice(item); } -int -SDL_DINPUT_HapticMaybeRemoveDevice(const DIDEVICEINSTANCE * pdidInstance) +int SDL_DINPUT_HapticMaybeRemoveDevice(const DIDEVICEINSTANCE *pdidInstance) { SDL_hapticlist_item *item; SDL_hapticlist_item *prev = NULL; if (dinput == NULL) { - return -1; /* not initialized, ignore this. */ + return -1; /* not initialized, ignore this. */ } for (item = SDL_hapticlist; item != NULL; item = item->next) { @@ -218,10 +211,9 @@ SDL_DINPUT_HapticMaybeRemoveDevice(const DIDEVICEINSTANCE * pdidInstance) /* * Callback to get supported axes. */ -static BOOL CALLBACK -DI_DeviceObjectCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef) +static BOOL CALLBACK DI_DeviceObjectCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef) { - SDL_Haptic *haptic = (SDL_Haptic *) pvRef; + SDL_Haptic *haptic = (SDL_Haptic *)pvRef; if ((dev->dwType & DIDFT_AXIS) && (dev->dwFlags & DIDOI_FFACTUATOR)) { const GUID *guid = &dev->guidType; @@ -239,7 +231,7 @@ DI_DeviceObjectCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef) } else if (WIN_IsEqualGUID(guid, &GUID_RzAxis)) { offset = DIJOFS_RZ; } else { - return DIENUM_CONTINUE; /* can't use this, go on. */ + return DIENUM_CONTINUE; /* can't use this, go on. */ } haptic->hwdata->axes[haptic->naxes] = offset; @@ -257,14 +249,13 @@ DI_DeviceObjectCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef) /* * Callback to get all supported effects. */ -#define EFFECT_TEST(e,s) \ -if (WIN_IsEqualGUID(&pei->guid, &(e))) \ - haptic->supported |= (s) -static BOOL CALLBACK -DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv) +#define EFFECT_TEST(e, s) \ + if (WIN_IsEqualGUID(&pei->guid, &(e))) \ + haptic->supported |= (s) +static BOOL CALLBACK DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv) { /* Prepare the haptic device. */ - SDL_Haptic *haptic = (SDL_Haptic *) pv; + SDL_Haptic *haptic = (SDL_Haptic *)pv; /* Get supported. */ EFFECT_TEST(GUID_Spring, SDL_HAPTIC_SPRING); @@ -295,8 +286,7 @@ DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv) * - Reset actuators. * - Get supported features. */ -static int -SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic * haptic, LPDIRECTINPUTDEVICE8 device8, SDL_bool is_joystick) +static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVICE8 device8, SDL_bool is_joystick) { HRESULT ret; DIPROPDWORD dipdw; @@ -319,12 +309,12 @@ SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic * haptic, LPDIRECTINPUTDEVICE8 device !!! FIXME: to work, and that's probably the common case. Still, !!! FIXME: ideally, We need to unify the opening code. */ - if (!is_joystick) { /* if is_joystick, we already set this up elsewhere. */ + if (!is_joystick) { /* if is_joystick, we already set this up elsewhere. */ /* Grab it exclusively to use force feedback stuff. */ ret = IDirectInputDevice8_SetCooperativeLevel(haptic->hwdata->device, SDL_HelperWindow, DISCL_EXCLUSIVE | - DISCL_BACKGROUND); + DISCL_BACKGROUND); if (FAILED(ret)) { DI_SetError("Setting cooperative level to exclusive", ret); goto acquire_err; @@ -338,7 +328,6 @@ SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic * haptic, LPDIRECTINPUTDEVICE8 device goto acquire_err; } - /* Acquire the device. */ ret = IDirectInputDevice8_Acquire(haptic->hwdata->device); if (FAILED(ret)) { @@ -380,7 +369,7 @@ SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic * haptic, LPDIRECTINPUTDEVICE8 device DI_SetError("Enumerating supported effects", ret); goto acquire_err; } - if (haptic->supported == 0) { /* Error since device supports nothing. */ + if (haptic->supported == 0) { /* Error since device supports nothing. */ SDL_SetError("Haptic: Internal error on finding supported effects."); goto acquire_err; } @@ -393,7 +382,7 @@ SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic * haptic, LPDIRECTINPUTDEVICE8 device dipdw.dwData = 10000; ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device, DIPROP_FFGAIN, &dipdw.diph); - if (!FAILED(ret)) { /* Gain is supported. */ + if (!FAILED(ret)) { /* Gain is supported. */ haptic->supported |= SDL_HAPTIC_GAIN; } dipdw.diph.dwObj = 0; @@ -401,7 +390,7 @@ SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic * haptic, LPDIRECTINPUTDEVICE8 device dipdw.dwData = DIPROPAUTOCENTER_OFF; ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device, DIPROP_AUTOCENTER, &dipdw.diph); - if (!FAILED(ret)) { /* Autocenter is supported. */ + if (!FAILED(ret)) { /* Autocenter is supported. */ haptic->supported |= SDL_HAPTIC_AUTOCENTER; } @@ -409,11 +398,11 @@ SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic * haptic, LPDIRECTINPUTDEVICE8 device haptic->supported |= SDL_HAPTIC_STATUS | SDL_HAPTIC_PAUSE; /* Check maximum effects. */ - haptic->neffects = 128; /* This is not actually supported as thus under windows, - there is no way to tell the number of EFFECTS that a - device can hold, so we'll just use a "random" number - instead and put warnings in SDL_haptic.h */ - haptic->nplaying = 128; /* Even more impossible to get this then neffects. */ + haptic->neffects = 128; /* This is not actually supported as thus under windows, + there is no way to tell the number of EFFECTS that a + device can hold, so we'll just use a "random" number + instead and put warnings in SDL_haptic.h */ + haptic->nplaying = 128; /* Even more impossible to get this then neffects. */ /* Prepare effects memory. */ haptic->effects = (struct haptic_effect *) @@ -429,20 +418,19 @@ SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic * haptic, LPDIRECTINPUTDEVICE8 device return 0; /* Error handling */ - acquire_err: +acquire_err: IDirectInputDevice8_Unacquire(haptic->hwdata->device); return -1; } -int -SDL_DINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item) +int SDL_DINPUT_HapticOpen(SDL_Haptic *haptic, SDL_hapticlist_item *item) { HRESULT ret; LPDIRECTINPUTDEVICE8 device; /* Open the device */ ret = IDirectInput8_CreateDevice(dinput, &item->instance.guidInstance, - &device, NULL); + &device, NULL); if (FAILED(ret)) { DI_SetError("Creating DirectInput device", ret); return -1; @@ -455,8 +443,7 @@ SDL_DINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item) return 0; } -int -SDL_DINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) +int SDL_DINPUT_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) { HRESULT ret; DIDEVICEINSTANCE hap_instance, joy_instance; @@ -466,12 +453,12 @@ SDL_DINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) /* Get the device instances. */ ret = IDirectInputDevice8_GetDeviceInfo(haptic->hwdata->device, - &hap_instance); + &hap_instance); if (FAILED(ret)) { return 0; } ret = IDirectInputDevice8_GetDeviceInfo(joystick->hwdata->InputDevice, - &joy_instance); + &joy_instance); if (FAILED(ret)) { return 0; } @@ -479,8 +466,7 @@ SDL_DINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) return WIN_IsEqualGUID(&hap_instance.guidInstance, &joy_instance.guidInstance); } -int -SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) +int SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) { SDL_hapticlist_item *item; int index = 0; @@ -505,8 +491,7 @@ SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) return SDL_SetError("Couldn't find joystick in haptic device list"); } -void -SDL_DINPUT_HapticClose(SDL_Haptic * haptic) +void SDL_DINPUT_HapticClose(SDL_Haptic *haptic) { IDirectInputDevice8_Unacquire(haptic->hwdata->device); @@ -516,8 +501,7 @@ SDL_DINPUT_HapticClose(SDL_Haptic * haptic) } } -void -SDL_DINPUT_HapticQuit(void) +void SDL_DINPUT_HapticQuit(void) { if (dinput != NULL) { IDirectInput8_Release(dinput); @@ -533,8 +517,7 @@ SDL_DINPUT_HapticQuit(void) /* * Converts an SDL trigger button to an DIEFFECT trigger button. */ -static DWORD -DIGetTriggerButton(Uint16 button) +static DWORD DIGetTriggerButton(Uint16 button) { DWORD dwTriggerButton; @@ -547,18 +530,16 @@ DIGetTriggerButton(Uint16 button) return dwTriggerButton; } - /* * Sets the direction. */ -static int -SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir, int naxes) +static int SDL_SYS_SetDirection(DIEFFECT *effect, SDL_HapticDirection *dir, int naxes) { LONG *rglDir; /* Handle no axes a part. */ if (naxes == 0) { - effect->dwFlags |= DIEFF_SPHERICAL; /* Set as default. */ + effect->dwFlags |= DIEFF_SPHERICAL; /* Set as default. */ effect->rglDirection = NULL; return 0; } @@ -607,20 +588,19 @@ SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir, int naxes) } /* Clamps and converts. */ -#define CCONVERT(x) (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF) +#define CCONVERT(x) (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF) /* Just converts. */ -#define CONVERT(x) (((x)*10000) / 0x7FFF) +#define CONVERT(x) (((x)*10000) / 0x7FFF) /* * Creates the DIEFFECT from a SDL_HapticEffect. */ -static int -SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, - SDL_HapticEffect * src) +static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, + SDL_HapticEffect *src) { int i; DICONSTANTFORCE *constant; DIPERIODIC *periodic; - DICONDITION *condition; /* Actually an array of conditions - one per axis. */ + DICONDITION *condition; /* Actually an array of conditions - one per axis. */ DIRAMPFORCE *ramp; DICUSTOMFORCE *custom; DIENVELOPE *envelope; @@ -633,10 +613,10 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, /* Set global stuff. */ SDL_memset(dest, 0, sizeof(DIEFFECT)); - dest->dwSize = sizeof(DIEFFECT); /* Set the structure size. */ - dest->dwSamplePeriod = 0; /* Not used by us. */ - dest->dwGain = 10000; /* Gain is set globally, not locally. */ - dest->dwFlags = DIEFF_OBJECTOFFSETS; /* Seems obligatory. */ + dest->dwSize = sizeof(DIEFFECT); /* Set the structure size. */ + dest->dwSamplePeriod = 0; /* Not used by us. */ + dest->dwGain = 10000; /* Gain is set globally, not locally. */ + dest->dwFlags = DIEFF_OBJECTOFFSETS; /* Seems obligatory. */ /* Envelope. */ envelope = SDL_malloc(sizeof(DIENVELOPE)); @@ -645,7 +625,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, } SDL_memset(envelope, 0, sizeof(DIENVELOPE)); dest->lpEnvelope = envelope; - envelope->dwSize = sizeof(DIENVELOPE); /* Always should be this. */ + envelope->dwSize = sizeof(DIENVELOPE); /* Always should be this. */ /* Axes. */ if (src->constant.direction.type == SDL_HAPTIC_STEERING_AXIS) { @@ -658,7 +638,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, if (axes == NULL) { return SDL_OutOfMemory(); } - axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */ + axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */ if (dest->cAxes > 1) { axes[1] = haptic->hwdata->axes[1]; } @@ -687,7 +667,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */ dest->dwTriggerButton = DIGetTriggerButton(hap_constant->button); dest->dwTriggerRepeatInterval = hap_constant->interval; - dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */ + dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */ /* Direction. */ if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) { @@ -695,8 +675,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, } /* Envelope */ - if ((hap_constant->attack_length == 0) - && (hap_constant->fade_length == 0)) { + if ((hap_constant->attack_length == 0) && (hap_constant->fade_length == 0)) { SDL_free(dest->lpEnvelope); dest->lpEnvelope = NULL; } else { @@ -725,7 +704,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, periodic->dwMagnitude = CONVERT(SDL_abs(hap_periodic->magnitude)); periodic->lOffset = CONVERT(hap_periodic->offset); periodic->dwPhase = - (hap_periodic->phase + (hap_periodic->magnitude < 0 ? 18000 : 0)) % 36000; + (hap_periodic->phase + (hap_periodic->magnitude < 0 ? 18000 : 0)) % 36000; periodic->dwPeriod = hap_periodic->period * 1000; dest->cbTypeSpecificParams = sizeof(DIPERIODIC); dest->lpvTypeSpecificParams = periodic; @@ -734,17 +713,15 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */ dest->dwTriggerButton = DIGetTriggerButton(hap_periodic->button); dest->dwTriggerRepeatInterval = hap_periodic->interval; - dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */ + dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */ /* Direction. */ - if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) - < 0) { + if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) { return -1; } /* Envelope */ - if ((hap_periodic->attack_length == 0) - && (hap_periodic->fade_length == 0)) { + if ((hap_periodic->attack_length == 0) && (hap_periodic->fade_length == 0)) { SDL_free(dest->lpEnvelope); dest->lpEnvelope = NULL; } else { @@ -768,7 +745,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, SDL_memset(condition, 0, sizeof(DICONDITION)); /* Specifics */ - for (i = 0; i < (int) dest->cAxes; i++) { + for (i = 0; i < (int)dest->cAxes; i++) { condition[i].lOffset = CONVERT(hap_condition->center[i]); condition[i].lPositiveCoefficient = CONVERT(hap_condition->right_coeff[i]); @@ -784,14 +761,13 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, dest->lpvTypeSpecificParams = condition; /* Generics */ - dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */ + dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */ dest->dwTriggerButton = DIGetTriggerButton(hap_condition->button); dest->dwTriggerRepeatInterval = hap_condition->interval; - dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */ + dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */ /* Direction. */ - if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) - < 0) { + if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) { return -1; } @@ -816,10 +792,10 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, dest->lpvTypeSpecificParams = ramp; /* Generics */ - dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */ + dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */ dest->dwTriggerButton = DIGetTriggerButton(hap_ramp->button); dest->dwTriggerRepeatInterval = hap_ramp->interval; - dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */ + dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */ /* Direction. */ if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) { @@ -853,17 +829,17 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, custom->cSamples = hap_custom->samples; custom->rglForceData = SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels); - for (i = 0; i < hap_custom->samples * hap_custom->channels; i++) { /* Copy data. */ + for (i = 0; i < hap_custom->samples * hap_custom->channels; i++) { /* Copy data. */ custom->rglForceData[i] = CCONVERT(hap_custom->data[i]); } dest->cbTypeSpecificParams = sizeof(DICUSTOMFORCE); dest->lpvTypeSpecificParams = custom; /* Generics */ - dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */ + dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */ dest->dwTriggerButton = DIGetTriggerButton(hap_custom->button); dest->dwTriggerRepeatInterval = hap_custom->interval; - dest->dwStartDelay = hap_custom->delay * 1000; /* In microseconds. */ + dest->dwStartDelay = hap_custom->delay * 1000; /* In microseconds. */ /* Direction. */ if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < 0) { @@ -871,8 +847,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, } /* Envelope */ - if ((hap_custom->attack_length == 0) - && (hap_custom->fade_length == 0)) { + if ((hap_custom->attack_length == 0) && (hap_custom->fade_length == 0)) { SDL_free(dest->lpEnvelope); dest->lpEnvelope = NULL; } else { @@ -891,12 +866,10 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, return 0; } - /* * Frees an DIEFFECT allocated by SDL_SYS_ToDIEFFECT. */ -static void -SDL_SYS_HapticFreeDIEFFECT(DIEFFECT * effect, int type) +static void SDL_SYS_HapticFreeDIEFFECT(DIEFFECT *effect, int type) { DICUSTOMFORCE *custom; @@ -905,8 +878,8 @@ SDL_SYS_HapticFreeDIEFFECT(DIEFFECT * effect, int type) SDL_free(effect->rgdwAxes); effect->rgdwAxes = NULL; if (effect->lpvTypeSpecificParams != NULL) { - if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */ - custom = (DICUSTOMFORCE *) effect->lpvTypeSpecificParams; + if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */ + custom = (DICUSTOMFORCE *)effect->lpvTypeSpecificParams; SDL_free(custom->rglForceData); custom->rglForceData = NULL; } @@ -920,8 +893,7 @@ SDL_SYS_HapticFreeDIEFFECT(DIEFFECT * effect, int type) /* * Gets the effect type from the generic SDL haptic effect wrapper. */ -static REFGUID -SDL_SYS_HapticEffectType(SDL_HapticEffect * effect) +static REFGUID SDL_SYS_HapticEffectType(SDL_HapticEffect *effect) { switch (effect->type) { case SDL_HAPTIC_CONSTANT: @@ -930,9 +902,9 @@ SDL_SYS_HapticEffectType(SDL_HapticEffect * effect) case SDL_HAPTIC_RAMP: return &GUID_RampForce; - /* !!! FIXME: put this back when we have more bits in 2.1 */ - /* case SDL_HAPTIC_SQUARE: - return &GUID_Square; */ + /* !!! FIXME: put this back when we have more bits in 2.1 */ + /* case SDL_HAPTIC_SQUARE: + return &GUID_Square; */ case SDL_HAPTIC_SINE: return &GUID_Sine; @@ -965,8 +937,7 @@ SDL_SYS_HapticEffectType(SDL_HapticEffect * effect) return NULL; } } -int -SDL_DINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base) +int SDL_DINPUT_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *base) { HRESULT ret; REFGUID type = SDL_SYS_HapticEffectType(base); @@ -982,8 +953,8 @@ SDL_DINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SD /* Create the actual effect. */ ret = IDirectInputDevice8_CreateEffect(haptic->hwdata->device, type, - &effect->hweffect->effect, - &effect->hweffect->ref, NULL); + &effect->hweffect->effect, + &effect->hweffect->ref, NULL); if (FAILED(ret)) { DI_SetError("Unable to create effect", ret); goto err_effectdone; @@ -996,8 +967,7 @@ err_effectdone: return -1; } -int -SDL_DINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data) +int SDL_DINPUT_HapticUpdateEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *data) { HRESULT ret; DWORD flags; @@ -1010,13 +980,13 @@ SDL_DINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, } /* Set the flags. Might be worthwhile to diff temp with loaded effect and - * only change those parameters. */ + * only change those parameters. */ flags = DIEP_DIRECTION | - DIEP_DURATION | - DIEP_ENVELOPE | - DIEP_STARTDELAY | - DIEP_TRIGGERBUTTON | - DIEP_TRIGGERREPEATINTERVAL | DIEP_TYPESPECIFICPARAMS; + DIEP_DURATION | + DIEP_ENVELOPE | + DIEP_STARTDELAY | + DIEP_TRIGGERBUTTON | + DIEP_TRIGGERREPEATINTERVAL | DIEP_TYPESPECIFICPARAMS; /* Create the actual effect. */ ret = @@ -1050,8 +1020,7 @@ err_update: return -1; } -int -SDL_DINPUT_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations) +int SDL_DINPUT_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, Uint32 iterations) { HRESULT ret; DWORD iter; @@ -1071,8 +1040,7 @@ SDL_DINPUT_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Ui return 0; } -int -SDL_DINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) +int SDL_DINPUT_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect) { HRESULT ret; @@ -1083,8 +1051,7 @@ SDL_DINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) return 0; } -void -SDL_DINPUT_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) +void SDL_DINPUT_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect) { HRESULT ret; @@ -1095,8 +1062,7 @@ SDL_DINPUT_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, effect->effect.type); } -int -SDL_DINPUT_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect) +int SDL_DINPUT_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *effect) { HRESULT ret; DWORD status; @@ -1112,8 +1078,7 @@ SDL_DINPUT_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effe return SDL_TRUE; } -int -SDL_DINPUT_HapticSetGain(SDL_Haptic * haptic, int gain) +int SDL_DINPUT_HapticSetGain(SDL_Haptic *haptic, int gain) { HRESULT ret; DIPROPDWORD dipdw; @@ -1123,19 +1088,18 @@ SDL_DINPUT_HapticSetGain(SDL_Haptic * haptic, int gain) dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; - dipdw.dwData = gain * 100; /* 0 to 10,000 */ + dipdw.dwData = gain * 100; /* 0 to 10,000 */ /* Try to set the autocenter. */ ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device, - DIPROP_FFGAIN, &dipdw.diph); + DIPROP_FFGAIN, &dipdw.diph); if (FAILED(ret)) { return DI_SetError("Setting gain", ret); } return 0; } -int -SDL_DINPUT_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) +int SDL_DINPUT_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter) { HRESULT ret; DIPROPDWORD dipdw; @@ -1145,54 +1109,50 @@ SDL_DINPUT_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; - dipdw.dwData = (autocenter == 0) ? DIPROPAUTOCENTER_OFF : - DIPROPAUTOCENTER_ON; + dipdw.dwData = (autocenter == 0) ? DIPROPAUTOCENTER_OFF : DIPROPAUTOCENTER_ON; /* Try to set the autocenter. */ ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device, - DIPROP_AUTOCENTER, &dipdw.diph); + DIPROP_AUTOCENTER, &dipdw.diph); if (FAILED(ret)) { return DI_SetError("Setting autocenter", ret); } return 0; } -int -SDL_DINPUT_HapticPause(SDL_Haptic * haptic) +int SDL_DINPUT_HapticPause(SDL_Haptic *haptic) { HRESULT ret; /* Pause the device. */ ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device, - DISFFC_PAUSE); + DISFFC_PAUSE); if (FAILED(ret)) { return DI_SetError("Pausing the device", ret); } return 0; } -int -SDL_DINPUT_HapticUnpause(SDL_Haptic * haptic) +int SDL_DINPUT_HapticUnpause(SDL_Haptic *haptic) { HRESULT ret; /* Unpause the device. */ ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device, - DISFFC_CONTINUE); + DISFFC_CONTINUE); if (FAILED(ret)) { return DI_SetError("Pausing the device", ret); } return 0; } -int -SDL_DINPUT_HapticStopAll(SDL_Haptic * haptic) +int SDL_DINPUT_HapticStopAll(SDL_Haptic *haptic) { HRESULT ret; /* Try to stop the effects. */ ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device, - DISFFC_STOPALL); + DISFFC_STOPALL); if (FAILED(ret)) { return DI_SetError("Stopping the device", ret); } @@ -1204,113 +1164,94 @@ SDL_DINPUT_HapticStopAll(SDL_Haptic * haptic) typedef struct DIDEVICEINSTANCE DIDEVICEINSTANCE; typedef struct SDL_hapticlist_item SDL_hapticlist_item; -int -SDL_DINPUT_HapticInit(void) +int SDL_DINPUT_HapticInit(void) { return 0; } -int -SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE * pdidInstance) +int SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE *pdidInstance) { return SDL_Unsupported(); } -int -SDL_DINPUT_HapticMaybeRemoveDevice(const DIDEVICEINSTANCE * pdidInstance) +int SDL_DINPUT_HapticMaybeRemoveDevice(const DIDEVICEINSTANCE *pdidInstance) { return SDL_Unsupported(); } -int -SDL_DINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item) +int SDL_DINPUT_HapticOpen(SDL_Haptic *haptic, SDL_hapticlist_item *item) { return SDL_Unsupported(); } -int -SDL_DINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) +int SDL_DINPUT_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) { return SDL_Unsupported(); } -int -SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) +int SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) { return SDL_Unsupported(); } -void -SDL_DINPUT_HapticClose(SDL_Haptic * haptic) +void SDL_DINPUT_HapticClose(SDL_Haptic *haptic) { } -void -SDL_DINPUT_HapticQuit(void) +void SDL_DINPUT_HapticQuit(void) { } -int -SDL_DINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base) +int SDL_DINPUT_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *base) { return SDL_Unsupported(); } -int -SDL_DINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data) +int SDL_DINPUT_HapticUpdateEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *data) { return SDL_Unsupported(); } -int -SDL_DINPUT_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations) +int SDL_DINPUT_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, Uint32 iterations) { return SDL_Unsupported(); } -int -SDL_DINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) +int SDL_DINPUT_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect) { return SDL_Unsupported(); } -void -SDL_DINPUT_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) +void SDL_DINPUT_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect) { } -int -SDL_DINPUT_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect) +int SDL_DINPUT_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *effect) { return SDL_Unsupported(); } -int -SDL_DINPUT_HapticSetGain(SDL_Haptic * haptic, int gain) +int SDL_DINPUT_HapticSetGain(SDL_Haptic *haptic, int gain) { return SDL_Unsupported(); } -int -SDL_DINPUT_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) +int SDL_DINPUT_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter) { return SDL_Unsupported(); } -int -SDL_DINPUT_HapticPause(SDL_Haptic * haptic) +int SDL_DINPUT_HapticPause(SDL_Haptic *haptic) { return SDL_Unsupported(); } -int -SDL_DINPUT_HapticUnpause(SDL_Haptic * haptic) +int SDL_DINPUT_HapticUnpause(SDL_Haptic *haptic) { return SDL_Unsupported(); } -int -SDL_DINPUT_HapticStopAll(SDL_Haptic * haptic) +int SDL_DINPUT_HapticStopAll(SDL_Haptic *haptic) { return SDL_Unsupported(); } diff --git a/src/haptic/windows/SDL_dinputhaptic_c.h b/src/haptic/windows/SDL_dinputhaptic_c.h index 60fa414cd..a9b2ca85b 100644 --- a/src/haptic/windows/SDL_dinputhaptic_c.h +++ b/src/haptic/windows/SDL_dinputhaptic_c.h @@ -31,22 +31,22 @@ extern "C" { extern int SDL_DINPUT_HapticInit(void); extern int SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE *pdidInstance); extern int SDL_DINPUT_HapticMaybeRemoveDevice(const DIDEVICEINSTANCE *pdidInstance); -extern int SDL_DINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item); -extern int SDL_DINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick); -extern int SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick); -extern void SDL_DINPUT_HapticClose(SDL_Haptic * haptic); +extern int SDL_DINPUT_HapticOpen(SDL_Haptic *haptic, SDL_hapticlist_item *item); +extern int SDL_DINPUT_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick); +extern int SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick); +extern void SDL_DINPUT_HapticClose(SDL_Haptic *haptic); extern void SDL_DINPUT_HapticQuit(void); -extern int SDL_DINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base); -extern int SDL_DINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data); -extern int SDL_DINPUT_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations); -extern int SDL_DINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect); -extern void SDL_DINPUT_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect); -extern int SDL_DINPUT_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect); -extern int SDL_DINPUT_HapticSetGain(SDL_Haptic * haptic, int gain); -extern int SDL_DINPUT_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter); -extern int SDL_DINPUT_HapticPause(SDL_Haptic * haptic); -extern int SDL_DINPUT_HapticUnpause(SDL_Haptic * haptic); -extern int SDL_DINPUT_HapticStopAll(SDL_Haptic * haptic); +extern int SDL_DINPUT_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *base); +extern int SDL_DINPUT_HapticUpdateEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *data); +extern int SDL_DINPUT_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, Uint32 iterations); +extern int SDL_DINPUT_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect); +extern void SDL_DINPUT_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect); +extern int SDL_DINPUT_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *effect); +extern int SDL_DINPUT_HapticSetGain(SDL_Haptic *haptic, int gain); +extern int SDL_DINPUT_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter); +extern int SDL_DINPUT_HapticPause(SDL_Haptic *haptic); +extern int SDL_DINPUT_HapticUnpause(SDL_Haptic *haptic); +extern int SDL_DINPUT_HapticStopAll(SDL_Haptic *haptic); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/src/haptic/windows/SDL_windowshaptic.c b/src/haptic/windows/SDL_windowshaptic.c index 475ae49c6..16b0e24d3 100644 --- a/src/haptic/windows/SDL_windowshaptic.c +++ b/src/haptic/windows/SDL_windowshaptic.c @@ -49,14 +49,12 @@ SDL_hapticlist_item *SDL_hapticlist = NULL; static SDL_hapticlist_item *SDL_hapticlist_tail = NULL; static int numhaptics = 0; - /* * Initializes the haptic subsystem. */ -int -SDL_SYS_HapticInit(void) +int SDL_SYS_HapticInit(void) { - JoyStick_DeviceData* device; + JoyStick_DeviceData *device; if (SDL_DINPUT_HapticInit() < 0) { return -1; @@ -81,8 +79,7 @@ SDL_SYS_HapticInit(void) return numhaptics; } -int -SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item) +int SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item) { if (SDL_hapticlist_tail == NULL) { SDL_hapticlist = SDL_hapticlist_tail = item; @@ -97,8 +94,7 @@ SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item) return numhaptics; } -int -SDL_SYS_RemoveHapticDevice(SDL_hapticlist_item *prev, SDL_hapticlist_item *item) +int SDL_SYS_RemoveHapticDevice(SDL_hapticlist_item *prev, SDL_hapticlist_item *item) { const int retval = item->haptic ? item->haptic->index : -1; if (prev != NULL) { @@ -116,14 +112,12 @@ SDL_SYS_RemoveHapticDevice(SDL_hapticlist_item *prev, SDL_hapticlist_item *item) return retval; } -int -SDL_SYS_NumHaptics(void) +int SDL_SYS_NumHaptics(void) { return numhaptics; } -static SDL_hapticlist_item * -HapticByDevIndex(int device_index) +static SDL_hapticlist_item *HapticByDevIndex(int device_index) { SDL_hapticlist_item *item = SDL_hapticlist; @@ -152,8 +146,7 @@ SDL_SYS_HapticName(int index) /* * Opens a haptic device for usage. */ -int -SDL_SYS_HapticOpen(SDL_Haptic * haptic) +int SDL_SYS_HapticOpen(SDL_Haptic *haptic) { SDL_hapticlist_item *item = HapticByDevIndex(haptic->index); if (item->bXInputHaptic) { @@ -163,12 +156,10 @@ SDL_SYS_HapticOpen(SDL_Haptic * haptic) } } - /* * Opens a haptic device from first mouse it finds for usage. */ -int -SDL_SYS_HapticMouse(void) +int SDL_SYS_HapticMouse(void) { #if SDL_HAPTIC_DINPUT SDL_hapticlist_item *item; @@ -185,12 +176,10 @@ SDL_SYS_HapticMouse(void) return -1; } - /* * Checks to see if a joystick has haptic features. */ -int -SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) +int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) { if (joystick->driver != &SDL_WINDOWS_JoystickDriver) { return 0; @@ -211,14 +200,13 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) /* * Checks to see if the haptic device and joystick are in reality the same. */ -int -SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) +int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) { if (joystick->driver != &SDL_WINDOWS_JoystickDriver) { return 0; } if (joystick->hwdata->bXInputHaptic != haptic->hwdata->bXInputHaptic) { - return 0; /* one is XInput, one is not; not the same device. */ + return 0; /* one is XInput, one is not; not the same device. */ } else if (joystick->hwdata->bXInputHaptic) { return SDL_XINPUT_JoystickSameHaptic(haptic, joystick); } else { @@ -229,8 +217,7 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) /* * Opens a SDL_Haptic from a SDL_Joystick. */ -int -SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) +int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) { SDL_assert(joystick->driver == &SDL_WINDOWS_JoystickDriver); @@ -244,8 +231,7 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) /* * Closes the haptic device. */ -void -SDL_SYS_HapticClose(SDL_Haptic * haptic) +void SDL_SYS_HapticClose(SDL_Haptic *haptic) { if (haptic->hwdata) { @@ -270,8 +256,7 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic) /* * Clean up after system specific haptic stuff */ -void -SDL_SYS_HapticQuit(void) +void SDL_SYS_HapticQuit(void) { SDL_hapticlist_item *item; SDL_hapticlist_item *next = NULL; @@ -307,9 +292,8 @@ SDL_SYS_HapticQuit(void) /* * Creates a new haptic effect. */ -int -SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, - SDL_HapticEffect * base) +int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, + SDL_HapticEffect *base) { int result; @@ -337,10 +321,9 @@ SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, /* * Updates an effect. */ -int -SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, - struct haptic_effect *effect, - SDL_HapticEffect * data) +int SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic, + struct haptic_effect *effect, + SDL_HapticEffect *data) { if (haptic->hwdata->bXInputHaptic) { return SDL_XINPUT_HapticUpdateEffect(haptic, effect, data); @@ -352,9 +335,8 @@ SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, /* * Runs an effect. */ -int -SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, - Uint32 iterations) +int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, + Uint32 iterations) { if (haptic->hwdata->bXInputHaptic) { return SDL_XINPUT_HapticRunEffect(haptic, effect, iterations); @@ -366,8 +348,7 @@ SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, /* * Stops an effect. */ -int -SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) +int SDL_SYS_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect) { if (haptic->hwdata->bXInputHaptic) { return SDL_XINPUT_HapticStopEffect(haptic, effect); @@ -379,8 +360,7 @@ SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) /* * Frees the effect. */ -void -SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) +void SDL_SYS_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect) { if (haptic->hwdata->bXInputHaptic) { SDL_XINPUT_HapticDestroyEffect(haptic, effect); @@ -394,9 +374,8 @@ SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) /* * Gets the status of a haptic effect. */ -int -SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, - struct haptic_effect *effect) +int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic, + struct haptic_effect *effect) { if (haptic->hwdata->bXInputHaptic) { return SDL_XINPUT_HapticGetEffectStatus(haptic, effect); @@ -408,8 +387,7 @@ SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, /* * Sets the gain. */ -int -SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain) +int SDL_SYS_HapticSetGain(SDL_Haptic *haptic, int gain) { if (haptic->hwdata->bXInputHaptic) { return SDL_XINPUT_HapticSetGain(haptic, gain); @@ -421,8 +399,7 @@ SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain) /* * Sets the autocentering. */ -int -SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) +int SDL_SYS_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter) { if (haptic->hwdata->bXInputHaptic) { return SDL_XINPUT_HapticSetAutocenter(haptic, autocenter); @@ -434,8 +411,7 @@ SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) /* * Pauses the device. */ -int -SDL_SYS_HapticPause(SDL_Haptic * haptic) +int SDL_SYS_HapticPause(SDL_Haptic *haptic) { if (haptic->hwdata->bXInputHaptic) { return SDL_XINPUT_HapticPause(haptic); @@ -447,8 +423,7 @@ SDL_SYS_HapticPause(SDL_Haptic * haptic) /* * Pauses the device. */ -int -SDL_SYS_HapticUnpause(SDL_Haptic * haptic) +int SDL_SYS_HapticUnpause(SDL_Haptic *haptic) { if (haptic->hwdata->bXInputHaptic) { return SDL_XINPUT_HapticUnpause(haptic); @@ -460,8 +435,7 @@ SDL_SYS_HapticUnpause(SDL_Haptic * haptic) /* * Stops all the playing effects on the device. */ -int -SDL_SYS_HapticStopAll(SDL_Haptic * haptic) +int SDL_SYS_HapticStopAll(SDL_Haptic *haptic) { if (haptic->hwdata->bXInputHaptic) { return SDL_XINPUT_HapticStopAll(haptic); diff --git a/src/haptic/windows/SDL_windowshaptic_c.h b/src/haptic/windows/SDL_windowshaptic_c.h index dcfb7022e..ceaf9f1d0 100644 --- a/src/haptic/windows/SDL_windowshaptic_c.h +++ b/src/haptic/windows/SDL_windowshaptic_c.h @@ -41,17 +41,16 @@ struct haptic_hwdata #if SDL_HAPTIC_DINPUT LPDIRECTINPUTDEVICE8 device; #endif - DWORD axes[3]; /* Axes to use. */ - SDL_bool is_joystick; /* Device is loaded as joystick. */ - Uint8 bXInputHaptic; /* Supports force feedback via XInput. */ - Uint8 userid; /* XInput userid index for this joystick */ + DWORD axes[3]; /* Axes to use. */ + SDL_bool is_joystick; /* Device is loaded as joystick. */ + Uint8 bXInputHaptic; /* Supports force feedback via XInput. */ + Uint8 userid; /* XInput userid index for this joystick */ SDL_Thread *thread; SDL_mutex *mutex; Uint32 stopTicks; SDL_atomic_t stopThread; }; - /* * Haptic system effect data. */ @@ -69,8 +68,8 @@ struct haptic_hweffect #endif /* -* List of available haptic devices. -*/ + * List of available haptic devices. + */ typedef struct SDL_hapticlist_item { char *name; @@ -80,7 +79,7 @@ typedef struct SDL_hapticlist_item DIDEVCAPS capabilities; #endif SDL_bool bXInputHaptic; /* Supports force feedback via XInput. */ - Uint8 userid; /* XInput userid index for this joystick */ + Uint8 userid; /* XInput userid index for this joystick */ struct SDL_hapticlist_item *next; } SDL_hapticlist_item; @@ -97,4 +96,3 @@ extern int SDL_SYS_RemoveHapticDevice(SDL_hapticlist_item *prev, SDL_hapticlist_ #endif /* SDL_windowshaptic_c_h_ */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/haptic/windows/SDL_xinputhaptic.c b/src/haptic/windows/SDL_xinputhaptic.c index b70b48278..81d8f1faf 100644 --- a/src/haptic/windows/SDL_xinputhaptic.c +++ b/src/haptic/windows/SDL_xinputhaptic.c @@ -45,9 +45,7 @@ extern "C" { */ static SDL_bool loaded_xinput = SDL_FALSE; - -int -SDL_XINPUT_HapticInit(void) +int SDL_XINPUT_HapticInit(void) { if (SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE)) { loaded_xinput = (WIN_LoadXInputDLL() == 0) ? SDL_TRUE : SDL_FALSE; @@ -63,8 +61,7 @@ SDL_XINPUT_HapticInit(void) return 0; } -int -SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid) +int SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid) { const Uint8 userid = (Uint8)dwUserid; SDL_hapticlist_item *item; @@ -77,13 +74,13 @@ SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid) /* Make sure we don't already have it */ for (item = SDL_hapticlist; item; item = item->next) { if (item->bXInputHaptic && item->userid == userid) { - return -1; /* Already added */ + return -1; /* Already added */ } } SDL_zero(state); if (XINPUTSETSTATE(dwUserid, &state) != ERROR_SUCCESS) { - return -1; /* no force feedback on this device. */ + return -1; /* no force feedback on this device. */ } item = (SDL_hapticlist_item *)SDL_malloc(sizeof(SDL_hapticlist_item)); @@ -112,8 +109,7 @@ SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid) return SDL_SYS_AddHapticDevice(item); } -int -SDL_XINPUT_HapticMaybeRemoveDevice(const DWORD dwUserid) +int SDL_XINPUT_HapticMaybeRemoveDevice(const DWORD dwUserid) { const Uint8 userid = (Uint8)dwUserid; SDL_hapticlist_item *item; @@ -147,10 +143,9 @@ SDL_XINPUT_HapticMaybeRemoveDevice(const DWORD dwUserid) * Mostly, this is here to get rumbling to work, and all the other features * are absent in the XInput path for now. :( */ -static int SDLCALL -SDL_RunXInputHaptic(void *arg) +static int SDLCALL SDL_RunXInputHaptic(void *arg) { - struct haptic_hwdata *hwdata = (struct haptic_hwdata *) arg; + struct haptic_hwdata *hwdata = (struct haptic_hwdata *)arg; while (!SDL_AtomicGet(&hwdata->stopThread)) { SDL_Delay(50); @@ -169,11 +164,10 @@ SDL_RunXInputHaptic(void *arg) return 0; } -static int -SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 userid) +static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 userid) { char threadName[32]; - XINPUT_VIBRATION vibration = { 0, 0 }; /* stop any current vibration */ + XINPUT_VIBRATION vibration = { 0, 0 }; /* stop any current vibration */ XINPUTSETSTATE(userid, &vibration); haptic->supported = SDL_HAPTIC_LEFTRIGHT; @@ -189,9 +183,9 @@ SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 userid) } /* Clear the memory */ SDL_memset(haptic->effects, 0, - sizeof(struct haptic_effect) * haptic->neffects); + sizeof(struct haptic_effect) * haptic->neffects); - haptic->hwdata = (struct haptic_hwdata *) SDL_malloc(sizeof(*haptic->hwdata)); + haptic->hwdata = (struct haptic_hwdata *)SDL_malloc(sizeof(*haptic->hwdata)); if (haptic->hwdata == NULL) { SDL_free(haptic->effects); haptic->effects = NULL; @@ -224,20 +218,17 @@ SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 userid) return 0; } -int -SDL_XINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item) +int SDL_XINPUT_HapticOpen(SDL_Haptic *haptic, SDL_hapticlist_item *item) { return SDL_XINPUT_HapticOpenFromUserIndex(haptic, item->userid); } -int -SDL_XINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) +int SDL_XINPUT_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) { return haptic->hwdata->userid == joystick->hwdata->userid; } -int -SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) +int SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) { SDL_hapticlist_item *item; int index = 0; @@ -254,16 +245,14 @@ SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) return SDL_SetError("Couldn't find joystick in haptic device list"); } -void -SDL_XINPUT_HapticClose(SDL_Haptic * haptic) +void SDL_XINPUT_HapticClose(SDL_Haptic *haptic) { SDL_AtomicSet(&haptic->hwdata->stopThread, 1); SDL_WaitThread(haptic->hwdata->thread, NULL); SDL_DestroyMutex(haptic->hwdata->mutex); } -void -SDL_XINPUT_HapticQuit(void) +void SDL_XINPUT_HapticQuit(void) { if (loaded_xinput) { WIN_UnloadXInputDLL(); @@ -271,15 +260,13 @@ SDL_XINPUT_HapticQuit(void) } } -int -SDL_XINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base) +int SDL_XINPUT_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *base) { - SDL_assert(base->type == SDL_HAPTIC_LEFTRIGHT); /* should catch this at higher level */ + SDL_assert(base->type == SDL_HAPTIC_LEFTRIGHT); /* should catch this at higher level */ return SDL_XINPUT_HapticUpdateEffect(haptic, effect, base); } -int -SDL_XINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data) +int SDL_XINPUT_HapticUpdateEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *data) { XINPUT_VIBRATION *vib = &effect->hweffect->vibration; SDL_assert(data->type == SDL_HAPTIC_LEFTRIGHT); @@ -287,18 +274,17 @@ SDL_XINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, vib->wLeftMotorSpeed = data->leftright.large_magnitude * 2; vib->wRightMotorSpeed = data->leftright.small_magnitude * 2; SDL_LockMutex(haptic->hwdata->mutex); - if (haptic->hwdata->stopTicks) { /* running right now? Update it. */ + if (haptic->hwdata->stopTicks) { /* running right now? Update it. */ XINPUTSETSTATE(haptic->hwdata->userid, vib); } SDL_UnlockMutex(haptic->hwdata->mutex); return 0; } -int -SDL_XINPUT_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations) +int SDL_XINPUT_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, Uint32 iterations) { XINPUT_VIBRATION *vib = &effect->hweffect->vibration; - SDL_assert(effect->effect.type == SDL_HAPTIC_LEFTRIGHT); /* should catch this at higher level */ + SDL_assert(effect->effect.type == SDL_HAPTIC_LEFTRIGHT); /* should catch this at higher level */ SDL_LockMutex(haptic->hwdata->mutex); if (effect->effect.leftright.length == SDL_HAPTIC_INFINITY || iterations == SDL_HAPTIC_INFINITY) { haptic->hwdata->stopTicks = SDL_HAPTIC_INFINITY; @@ -307,15 +293,14 @@ SDL_XINPUT_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Ui } else { haptic->hwdata->stopTicks = SDL_GetTicks() + (effect->effect.leftright.length * iterations); if ((haptic->hwdata->stopTicks == SDL_HAPTIC_INFINITY) || (haptic->hwdata->stopTicks == 0)) { - haptic->hwdata->stopTicks = 1; /* fix edge cases. */ + haptic->hwdata->stopTicks = 1; /* fix edge cases. */ } } SDL_UnlockMutex(haptic->hwdata->mutex); return (XINPUTSETSTATE(haptic->hwdata->userid, vib) == ERROR_SUCCESS) ? 0 : -1; } -int -SDL_XINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) +int SDL_XINPUT_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect) { XINPUT_VIBRATION vibration = { 0, 0 }; SDL_LockMutex(haptic->hwdata->mutex); @@ -324,44 +309,37 @@ SDL_XINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) return (XINPUTSETSTATE(haptic->hwdata->userid, &vibration) == ERROR_SUCCESS) ? 0 : -1; } -void -SDL_XINPUT_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) +void SDL_XINPUT_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect) { SDL_XINPUT_HapticStopEffect(haptic, effect); } -int -SDL_XINPUT_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect) +int SDL_XINPUT_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *effect) { return SDL_Unsupported(); } -int -SDL_XINPUT_HapticSetGain(SDL_Haptic * haptic, int gain) +int SDL_XINPUT_HapticSetGain(SDL_Haptic *haptic, int gain) { return SDL_Unsupported(); } -int -SDL_XINPUT_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) +int SDL_XINPUT_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter) { return SDL_Unsupported(); } -int -SDL_XINPUT_HapticPause(SDL_Haptic * haptic) +int SDL_XINPUT_HapticPause(SDL_Haptic *haptic) { return SDL_Unsupported(); } -int -SDL_XINPUT_HapticUnpause(SDL_Haptic * haptic) +int SDL_XINPUT_HapticUnpause(SDL_Haptic *haptic) { return SDL_Unsupported(); } -int -SDL_XINPUT_HapticStopAll(SDL_Haptic * haptic) +int SDL_XINPUT_HapticStopAll(SDL_Haptic *haptic) { XINPUT_VIBRATION vibration = { 0, 0 }; SDL_LockMutex(haptic->hwdata->mutex); @@ -381,113 +359,94 @@ SDL_XINPUT_HapticStopAll(SDL_Haptic * haptic) typedef struct SDL_hapticlist_item SDL_hapticlist_item; -int -SDL_XINPUT_HapticInit(void) +int SDL_XINPUT_HapticInit(void) { return 0; } -int -SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid) +int SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid) { return SDL_Unsupported(); } -int -SDL_XINPUT_HapticMaybeRemoveDevice(const DWORD dwUserid) +int SDL_XINPUT_HapticMaybeRemoveDevice(const DWORD dwUserid) { return SDL_Unsupported(); } -int -SDL_XINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item) +int SDL_XINPUT_HapticOpen(SDL_Haptic *haptic, SDL_hapticlist_item *item) { return SDL_Unsupported(); } -int -SDL_XINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) +int SDL_XINPUT_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) { return SDL_Unsupported(); } -int -SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) +int SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) { return SDL_Unsupported(); } -void -SDL_XINPUT_HapticClose(SDL_Haptic * haptic) +void SDL_XINPUT_HapticClose(SDL_Haptic *haptic) { } -void -SDL_XINPUT_HapticQuit(void) +void SDL_XINPUT_HapticQuit(void) { } -int -SDL_XINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base) +int SDL_XINPUT_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *base) { return SDL_Unsupported(); } -int -SDL_XINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data) +int SDL_XINPUT_HapticUpdateEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *data) { return SDL_Unsupported(); } -int -SDL_XINPUT_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations) +int SDL_XINPUT_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, Uint32 iterations) { return SDL_Unsupported(); } -int -SDL_XINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) +int SDL_XINPUT_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect) { return SDL_Unsupported(); } -void -SDL_XINPUT_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) +void SDL_XINPUT_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect) { } -int -SDL_XINPUT_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect) +int SDL_XINPUT_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *effect) { return SDL_Unsupported(); } -int -SDL_XINPUT_HapticSetGain(SDL_Haptic * haptic, int gain) +int SDL_XINPUT_HapticSetGain(SDL_Haptic *haptic, int gain) { return SDL_Unsupported(); } -int -SDL_XINPUT_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) +int SDL_XINPUT_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter) { return SDL_Unsupported(); } -int -SDL_XINPUT_HapticPause(SDL_Haptic * haptic) +int SDL_XINPUT_HapticPause(SDL_Haptic *haptic) { return SDL_Unsupported(); } -int -SDL_XINPUT_HapticUnpause(SDL_Haptic * haptic) +int SDL_XINPUT_HapticUnpause(SDL_Haptic *haptic) { return SDL_Unsupported(); } -int -SDL_XINPUT_HapticStopAll(SDL_Haptic * haptic) +int SDL_XINPUT_HapticStopAll(SDL_Haptic *haptic) { return SDL_Unsupported(); } diff --git a/src/haptic/windows/SDL_xinputhaptic_c.h b/src/haptic/windows/SDL_xinputhaptic_c.h index 2fb5dd861..d311b7b9a 100644 --- a/src/haptic/windows/SDL_xinputhaptic_c.h +++ b/src/haptic/windows/SDL_xinputhaptic_c.h @@ -31,22 +31,22 @@ extern "C" { extern int SDL_XINPUT_HapticInit(void); extern int SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid); extern int SDL_XINPUT_HapticMaybeRemoveDevice(const DWORD dwUserid); -extern int SDL_XINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item); -extern int SDL_XINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick); -extern int SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick); -extern void SDL_XINPUT_HapticClose(SDL_Haptic * haptic); +extern int SDL_XINPUT_HapticOpen(SDL_Haptic *haptic, SDL_hapticlist_item *item); +extern int SDL_XINPUT_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick); +extern int SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick); +extern void SDL_XINPUT_HapticClose(SDL_Haptic *haptic); extern void SDL_XINPUT_HapticQuit(void); -extern int SDL_XINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base); -extern int SDL_XINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data); -extern int SDL_XINPUT_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations); -extern int SDL_XINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect); -extern void SDL_XINPUT_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect); -extern int SDL_XINPUT_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect); -extern int SDL_XINPUT_HapticSetGain(SDL_Haptic * haptic, int gain); -extern int SDL_XINPUT_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter); -extern int SDL_XINPUT_HapticPause(SDL_Haptic * haptic); -extern int SDL_XINPUT_HapticUnpause(SDL_Haptic * haptic); -extern int SDL_XINPUT_HapticStopAll(SDL_Haptic * haptic); +extern int SDL_XINPUT_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *base); +extern int SDL_XINPUT_HapticUpdateEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *data); +extern int SDL_XINPUT_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, Uint32 iterations); +extern int SDL_XINPUT_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect); +extern void SDL_XINPUT_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect); +extern int SDL_XINPUT_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *effect); +extern int SDL_XINPUT_HapticSetGain(SDL_Haptic *haptic, int gain); +extern int SDL_XINPUT_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter); +extern int SDL_XINPUT_HapticPause(SDL_Haptic *haptic); +extern int SDL_XINPUT_HapticUnpause(SDL_Haptic *haptic); +extern int SDL_XINPUT_HapticStopAll(SDL_Haptic *haptic); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/src/hidapi/SDL_hidapi.c b/src/hidapi/SDL_hidapi.c index 1a3c4663b..dd7963009 100644 --- a/src/hidapi/SDL_hidapi.c +++ b/src/hidapi/SDL_hidapi.c @@ -65,7 +65,7 @@ #include /* just in case we didn't use that SDL_USE_LIBUDEV block... */ #include /* errno, strerror */ #include -#include /* For the definition of NAME_MAX */ +#include /* For the definition of NAME_MAX */ #include #endif @@ -85,7 +85,7 @@ static int inotify_fd = -1; #endif #if defined(SDL_USE_LIBUDEV) -static const SDL_UDEV_Symbols * usyms = NULL; +static const SDL_UDEV_Symbols *usyms = NULL; #endif static struct @@ -115,32 +115,31 @@ static struct #endif } SDL_HIDAPI_discovery; - #if defined(__WIN32__) || defined(__WINGDK__) struct _DEV_BROADCAST_HDR { - DWORD dbch_size; - DWORD dbch_devicetype; - DWORD dbch_reserved; + DWORD dbch_size; + DWORD dbch_devicetype; + DWORD dbch_reserved; }; typedef struct _DEV_BROADCAST_DEVICEINTERFACE_A { - DWORD dbcc_size; - DWORD dbcc_devicetype; - DWORD dbcc_reserved; - GUID dbcc_classguid; - char dbcc_name[ 1 ]; + DWORD dbcc_size; + DWORD dbcc_devicetype; + DWORD dbcc_reserved; + GUID dbcc_classguid; + char dbcc_name[1]; } DEV_BROADCAST_DEVICEINTERFACE_A, *PDEV_BROADCAST_DEVICEINTERFACE_A; -typedef struct _DEV_BROADCAST_HDR DEV_BROADCAST_HDR; -#define DBT_DEVICEARRIVAL 0x8000 /* system detected a new device */ -#define DBT_DEVICEREMOVECOMPLETE 0x8004 /* device was removed from the system */ -#define DBT_DEVTYP_DEVICEINTERFACE 0x00000005 /* device interface class */ -#define DBT_DEVNODES_CHANGED 0x0007 -#define DBT_CONFIGCHANGED 0x0018 -#define DBT_DEVICETYPESPECIFIC 0x8005 /* type specific event */ -#define DBT_DEVINSTSTARTED 0x8008 /* device installed and started */ +typedef struct _DEV_BROADCAST_HDR DEV_BROADCAST_HDR; +#define DBT_DEVICEARRIVAL 0x8000 /* system detected a new device */ +#define DBT_DEVICEREMOVECOMPLETE 0x8004 /* device was removed from the system */ +#define DBT_DEVTYP_DEVICEINTERFACE 0x00000005 /* device interface class */ +#define DBT_DEVNODES_CHANGED 0x0007 +#define DBT_CONFIGCHANGED 0x0018 +#define DBT_DEVICETYPESPECIFIC 0x8005 /* type specific event */ +#define DBT_DEVINSTSTARTED 0x8008 /* device installed and started */ #include DEFINE_GUID(GUID_DEVINTERFACE_USB_DEVICE, 0xA5DCBF10L, 0x6530, 0x11D2, 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED); @@ -152,7 +151,7 @@ static LRESULT CALLBACK ControllerWndProc(HWND hwnd, UINT message, WPARAM wParam switch (wParam) { case DBT_DEVICEARRIVAL: case DBT_DEVICEREMOVECOMPLETE: - if (((DEV_BROADCAST_HDR*)lParam)->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { + if (((DEV_BROADCAST_HDR *)lParam)->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { ++SDL_HIDAPI_discovery.m_unDeviceChangeCounter; } break; @@ -179,11 +178,13 @@ static void CallbackIOServiceFunc(void *context, io_iterator_t portIterator) #ifdef HAVE_INOTIFY #ifdef HAVE_INOTIFY_INIT1 -static int SDL_inotify_init1(void) { +static int SDL_inotify_init1(void) +{ return inotify_init1(IN_NONBLOCK | IN_CLOEXEC); } #else -static int SDL_inotify_init1(void) { +static int SDL_inotify_init1(void) +{ int fd = inotify_init(); if (fd < 0) { return -1; @@ -233,7 +234,7 @@ HIDAPI_InitializeDiscovery() SDL_zero(SDL_HIDAPI_discovery.m_wndClass); SDL_HIDAPI_discovery.m_wndClass.hInstance = GetModuleHandle(NULL); SDL_HIDAPI_discovery.m_wndClass.lpszClassName = "SDL_HIDAPI_DEVICE_DETECTION"; - SDL_HIDAPI_discovery.m_wndClass.lpfnWndProc = ControllerWndProc; /* This function is called by windows */ + SDL_HIDAPI_discovery.m_wndClass.lpfnWndProc = ControllerWndProc; /* This function is called by windows */ SDL_HIDAPI_discovery.m_wndClass.cbSize = sizeof(WNDCLASSEX); RegisterClassExA(&SDL_HIDAPI_discovery.m_wndClass); @@ -243,7 +244,7 @@ HIDAPI_InitializeDiscovery() DEV_BROADCAST_DEVICEINTERFACE_A devBroadcast; SDL_zero(devBroadcast); - devBroadcast.dbcc_size = sizeof( devBroadcast ); + devBroadcast.dbcc_size = sizeof(devBroadcast); devBroadcast.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; devBroadcast.dbcc_classguid = GUID_DEVINTERFACE_USB_DEVICE; @@ -251,8 +252,8 @@ HIDAPI_InitializeDiscovery() * but that seems to be necessary to get a notice after each individual usb input device actually * installs, rather than just as the composite device is seen. */ - SDL_HIDAPI_discovery.m_hNotify = RegisterDeviceNotification( SDL_HIDAPI_discovery.m_hwndMsg, &devBroadcast, DEVICE_NOTIFY_WINDOW_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES ); - SDL_HIDAPI_discovery.m_bCanGetNotifications = ( SDL_HIDAPI_discovery.m_hNotify != 0 ); + SDL_HIDAPI_discovery.m_hNotify = RegisterDeviceNotification(SDL_HIDAPI_discovery.m_hwndMsg, &devBroadcast, DEVICE_NOTIFY_WINDOW_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES); + SDL_HIDAPI_discovery.m_bCanGetNotifications = (SDL_HIDAPI_discovery.m_hNotify != 0); } #endif /* defined(__WIN32__) || defined(__WINGDK__) */ @@ -350,7 +351,7 @@ HIDAPI_InitializeDiscovery() inotify_fd = -1; SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, "Unable to add inotify watch, falling back to polling: %s", - strerror (errno)); + strerror(errno)); return; } @@ -367,7 +368,7 @@ HIDAPI_UpdateDiscovery() } if (!SDL_HIDAPI_discovery.m_bCanGetNotifications) { - const Uint32 SDL_HIDAPI_DETECT_INTERVAL_MS = 3000; /* Update every 3 seconds */ + const Uint32 SDL_HIDAPI_DETECT_INTERVAL_MS = 3000; /* Update every 3 seconds */ Uint32 now = SDL_GetTicks(); if (!SDL_HIDAPI_discovery.m_unLastDetect || SDL_TICKS_PASSED(now, SDL_HIDAPI_discovery.m_unLastDetect + SDL_HIDAPI_DETECT_INTERVAL_MS)) { ++SDL_HIDAPI_discovery.m_unDeviceChangeCounter; @@ -393,7 +394,11 @@ HIDAPI_UpdateDiscovery() #if defined(__MACOSX__) if (SDL_HIDAPI_discovery.m_notificationPort) { - struct { mach_msg_header_t hdr; char payload[ 4096 ]; } msg; + struct + { + mach_msg_header_t hdr; + char payload[4096]; + } msg; while (mach_msg(&msg.hdr, MACH_RCV_MSG | MACH_RCV_TIMEOUT, 0, sizeof(msg), SDL_HIDAPI_discovery.m_notificationMach, 0, MACH_PORT_NULL) == KERN_SUCCESS) { IODispatchCalloutFromMessage(NULL, &msg.hdr, SDL_HIDAPI_discovery.m_notificationPort); } @@ -438,22 +443,22 @@ HIDAPI_UpdateDiscovery() { struct inotify_event event; char storage[4096]; - char enough_for_inotify[sizeof (struct inotify_event) + NAME_MAX + 1]; + char enough_for_inotify[sizeof(struct inotify_event) + NAME_MAX + 1]; } buf; ssize_t bytes; size_t remain = 0; size_t len; - bytes = read(inotify_fd, &buf, sizeof (buf)); + bytes = read(inotify_fd, &buf, sizeof(buf)); if (bytes > 0) { - remain = (size_t) bytes; + remain = (size_t)bytes; } while (remain > 0) { if (buf.event.len > 0) { if (StrHasPrefix(buf.event.name, "hidraw") && - StrIsInteger(buf.event.name + SDL_strlen ("hidraw"))) { + StrIsInteger(buf.event.name + SDL_strlen("hidraw"))) { ++SDL_HIDAPI_discovery.m_unDeviceChangeCounter; /* We found an hidraw change. We still continue to * drain the inotify fd to avoid leaving old @@ -461,7 +466,7 @@ HIDAPI_UpdateDiscovery() } } - len = sizeof (struct inotify_event) + buf.event.len; + len = sizeof(struct inotify_event) + buf.event.len; remain -= len; if (remain != 0) { @@ -526,32 +531,32 @@ HIDAPI_ShutdownDiscovery() /* Platform HIDAPI Implementation */ -#define hid_device PLATFORM_hid_device -#define hid_device_ PLATFORM_hid_device_ -#define hid_init PLATFORM_hid_init -#define hid_exit PLATFORM_hid_exit -#define hid_enumerate PLATFORM_hid_enumerate -#define hid_free_enumeration PLATFORM_hid_free_enumeration -#define hid_open PLATFORM_hid_open -#define hid_open_path PLATFORM_hid_open_path -#define hid_write PLATFORM_hid_write -#define hid_read_timeout PLATFORM_hid_read_timeout -#define hid_read PLATFORM_hid_read -#define hid_set_nonblocking PLATFORM_hid_set_nonblocking -#define hid_send_feature_report PLATFORM_hid_send_feature_report -#define hid_get_feature_report PLATFORM_hid_get_feature_report -#define hid_close PLATFORM_hid_close -#define hid_get_manufacturer_string PLATFORM_hid_get_manufacturer_string -#define hid_get_product_string PLATFORM_hid_get_product_string -#define hid_get_serial_number_string PLATFORM_hid_get_serial_number_string -#define hid_get_indexed_string PLATFORM_hid_get_indexed_string -#define hid_error PLATFORM_hid_error -#define new_hid_device PLATFORM_new_hid_device -#define free_hid_device PLATFORM_free_hid_device -#define input_report PLATFORM_input_report -#define return_data PLATFORM_return_data -#define make_path PLATFORM_make_path -#define read_thread PLATFORM_read_thread +#define hid_device PLATFORM_hid_device +#define hid_device_ PLATFORM_hid_device_ +#define hid_init PLATFORM_hid_init +#define hid_exit PLATFORM_hid_exit +#define hid_enumerate PLATFORM_hid_enumerate +#define hid_free_enumeration PLATFORM_hid_free_enumeration +#define hid_open PLATFORM_hid_open +#define hid_open_path PLATFORM_hid_open_path +#define hid_write PLATFORM_hid_write +#define hid_read_timeout PLATFORM_hid_read_timeout +#define hid_read PLATFORM_hid_read +#define hid_set_nonblocking PLATFORM_hid_set_nonblocking +#define hid_send_feature_report PLATFORM_hid_send_feature_report +#define hid_get_feature_report PLATFORM_hid_get_feature_report +#define hid_close PLATFORM_hid_close +#define hid_get_manufacturer_string PLATFORM_hid_get_manufacturer_string +#define hid_get_product_string PLATFORM_hid_get_product_string +#define hid_get_serial_number_string PLATFORM_hid_get_serial_number_string +#define hid_get_indexed_string PLATFORM_hid_get_indexed_string +#define hid_error PLATFORM_hid_error +#define new_hid_device PLATFORM_new_hid_device +#define free_hid_device PLATFORM_free_hid_device +#define input_report PLATFORM_input_report +#define return_data PLATFORM_return_data +#define make_path PLATFORM_make_path +#define read_thread PLATFORM_read_thread #undef HIDAPI_H__ #if __LINUX__ @@ -559,21 +564,21 @@ HIDAPI_ShutdownDiscovery() #if SDL_USE_LIBUDEV static const SDL_UDEV_Symbols *udev_ctx = NULL; -#define udev_device_get_sysattr_value udev_ctx->udev_device_get_sysattr_value -#define udev_new udev_ctx->udev_new -#define udev_unref udev_ctx->udev_unref -#define udev_device_new_from_devnum udev_ctx->udev_device_new_from_devnum -#define udev_device_get_parent_with_subsystem_devtype udev_ctx->udev_device_get_parent_with_subsystem_devtype -#define udev_device_unref udev_ctx->udev_device_unref -#define udev_enumerate_new udev_ctx->udev_enumerate_new -#define udev_enumerate_add_match_subsystem udev_ctx->udev_enumerate_add_match_subsystem -#define udev_enumerate_scan_devices udev_ctx->udev_enumerate_scan_devices -#define udev_enumerate_get_list_entry udev_ctx->udev_enumerate_get_list_entry -#define udev_list_entry_get_name udev_ctx->udev_list_entry_get_name -#define udev_device_new_from_syspath udev_ctx->udev_device_new_from_syspath -#define udev_device_get_devnode udev_ctx->udev_device_get_devnode -#define udev_list_entry_get_next udev_ctx->udev_list_entry_get_next -#define udev_enumerate_unref udev_ctx->udev_enumerate_unref +#define udev_device_get_sysattr_value udev_ctx->udev_device_get_sysattr_value +#define udev_new udev_ctx->udev_new +#define udev_unref udev_ctx->udev_unref +#define udev_device_new_from_devnum udev_ctx->udev_device_new_from_devnum +#define udev_device_get_parent_with_subsystem_devtype udev_ctx->udev_device_get_parent_with_subsystem_devtype +#define udev_device_unref udev_ctx->udev_device_unref +#define udev_enumerate_new udev_ctx->udev_enumerate_new +#define udev_enumerate_add_match_subsystem udev_ctx->udev_enumerate_add_match_subsystem +#define udev_enumerate_scan_devices udev_ctx->udev_enumerate_scan_devices +#define udev_enumerate_get_list_entry udev_ctx->udev_enumerate_get_list_entry +#define udev_list_entry_get_name udev_ctx->udev_list_entry_get_name +#define udev_device_new_from_syspath udev_ctx->udev_device_new_from_syspath +#define udev_device_get_devnode udev_ctx->udev_device_get_devnode +#define udev_list_entry_get_next udev_ctx->udev_list_entry_get_next +#define udev_enumerate_unref udev_ctx->udev_enumerate_unref #include "linux/hid.c" #define HAVE_PLATFORM_BACKEND 1 @@ -582,11 +587,11 @@ static const SDL_UDEV_Symbols *udev_ctx = NULL; #elif __MACOSX__ #include "mac/hid.c" #define HAVE_PLATFORM_BACKEND 1 -#define udev_ctx 1 +#define udev_ctx 1 #elif __WINDOWS__ || __WINGDK__ #include "windows/hid.c" #define HAVE_PLATFORM_BACKEND 1 -#define udev_ctx 1 +#define udev_ctx 1 #elif __ANDROID__ /* The implementation for Android is in a separate .cpp file */ #include "hidapi/hidapi.h" @@ -596,7 +601,7 @@ static const SDL_UDEV_Symbols *udev_ctx = NULL; /* The implementation for iOS and tvOS is in a separate .m file */ #include "hidapi/hidapi.h" #define HAVE_PLATFORM_BACKEND 1 -#define udev_ctx 1 +#define udev_ctx 1 #endif #undef hid_device @@ -634,26 +639,26 @@ static const SDL_UDEV_Symbols *udev_ctx = NULL; /* DRIVER HIDAPI Implementation */ -#define hid_device DRIVER_hid_device -#define hid_device_ DRIVER_hid_device_ -#define hid_init DRIVER_hid_init -#define hid_exit DRIVER_hid_exit -#define hid_enumerate DRIVER_hid_enumerate -#define hid_free_enumeration DRIVER_hid_free_enumeration -#define hid_open DRIVER_hid_open -#define hid_open_path DRIVER_hid_open_path -#define hid_write DRIVER_hid_write -#define hid_read_timeout DRIVER_hid_read_timeout -#define hid_read DRIVER_hid_read -#define hid_set_nonblocking DRIVER_hid_set_nonblocking -#define hid_send_feature_report DRIVER_hid_send_feature_report -#define hid_get_feature_report DRIVER_hid_get_feature_report -#define hid_close DRIVER_hid_close -#define hid_get_manufacturer_string DRIVER_hid_get_manufacturer_string -#define hid_get_product_string DRIVER_hid_get_product_string -#define hid_get_serial_number_string DRIVER_hid_get_serial_number_string -#define hid_get_indexed_string DRIVER_hid_get_indexed_string -#define hid_error DRIVER_hid_error +#define hid_device DRIVER_hid_device +#define hid_device_ DRIVER_hid_device_ +#define hid_init DRIVER_hid_init +#define hid_exit DRIVER_hid_exit +#define hid_enumerate DRIVER_hid_enumerate +#define hid_free_enumeration DRIVER_hid_free_enumeration +#define hid_open DRIVER_hid_open +#define hid_open_path DRIVER_hid_open_path +#define hid_write DRIVER_hid_write +#define hid_read_timeout DRIVER_hid_read_timeout +#define hid_read DRIVER_hid_read +#define hid_set_nonblocking DRIVER_hid_set_nonblocking +#define hid_send_feature_report DRIVER_hid_send_feature_report +#define hid_get_feature_report DRIVER_hid_get_feature_report +#define hid_close DRIVER_hid_close +#define hid_get_manufacturer_string DRIVER_hid_get_manufacturer_string +#define hid_get_product_string DRIVER_hid_get_product_string +#define hid_get_serial_number_string DRIVER_hid_get_serial_number_string +#define hid_get_indexed_string DRIVER_hid_get_indexed_string +#define hid_error DRIVER_hid_error #ifdef SDL_JOYSTICK_HIDAPI_STEAMXBOX #undef HIDAPI_H__ @@ -685,7 +690,6 @@ static const SDL_UDEV_Symbols *udev_ctx = NULL; #endif /* HAVE_DRIVER_BACKEND */ - #ifdef HAVE_LIBUSB /* libusb HIDAPI Implementation */ @@ -694,8 +698,9 @@ static const SDL_UDEV_Symbols *udev_ctx = NULL; static struct { - void* libhandle; + void *libhandle; + /* *INDENT-OFF* */ /* clang-format off */ int (LIBUSB_CALL *init)(libusb_context **ctx); void (LIBUSB_CALL *exit)(libusb_context *ctx); ssize_t (LIBUSB_CALL *get_device_list)(libusb_context *ctx, libusb_device ***list); @@ -743,62 +748,64 @@ static struct int (LIBUSB_CALL *handle_events)(libusb_context *ctx); int (LIBUSB_CALL *handle_events_completed)(libusb_context *ctx, int *completed); const char * (LIBUSB_CALL *error_name)(int errcode); +/* *INDENT-ON* */ /* clang-format on */ + } libusb_ctx; -#define libusb_init libusb_ctx.init -#define libusb_exit libusb_ctx.exit -#define libusb_get_device_list libusb_ctx.get_device_list -#define libusb_free_device_list libusb_ctx.free_device_list -#define libusb_get_device_descriptor libusb_ctx.get_device_descriptor -#define libusb_get_active_config_descriptor libusb_ctx.get_active_config_descriptor -#define libusb_get_config_descriptor libusb_ctx.get_config_descriptor -#define libusb_free_config_descriptor libusb_ctx.free_config_descriptor -#define libusb_get_bus_number libusb_ctx.get_bus_number -#define libusb_get_device_address libusb_ctx.get_device_address -#define libusb_open libusb_ctx.open -#define libusb_close libusb_ctx.close -#define libusb_claim_interface libusb_ctx.claim_interface -#define libusb_release_interface libusb_ctx.release_interface -#define libusb_kernel_driver_active libusb_ctx.kernel_driver_active -#define libusb_detach_kernel_driver libusb_ctx.detach_kernel_driver -#define libusb_attach_kernel_driver libusb_ctx.attach_kernel_driver -#define libusb_set_interface_alt_setting libusb_ctx.set_interface_alt_setting -#define libusb_alloc_transfer libusb_ctx.alloc_transfer -#define libusb_submit_transfer libusb_ctx.submit_transfer -#define libusb_cancel_transfer libusb_ctx.cancel_transfer -#define libusb_free_transfer libusb_ctx.free_transfer -#define libusb_control_transfer libusb_ctx.control_transfer -#define libusb_interrupt_transfer libusb_ctx.interrupt_transfer -#define libusb_handle_events libusb_ctx.handle_events -#define libusb_handle_events_completed libusb_ctx.handle_events_completed -#define libusb_error_name libusb_ctx.error_name +#define libusb_init libusb_ctx.init +#define libusb_exit libusb_ctx.exit +#define libusb_get_device_list libusb_ctx.get_device_list +#define libusb_free_device_list libusb_ctx.free_device_list +#define libusb_get_device_descriptor libusb_ctx.get_device_descriptor +#define libusb_get_active_config_descriptor libusb_ctx.get_active_config_descriptor +#define libusb_get_config_descriptor libusb_ctx.get_config_descriptor +#define libusb_free_config_descriptor libusb_ctx.free_config_descriptor +#define libusb_get_bus_number libusb_ctx.get_bus_number +#define libusb_get_device_address libusb_ctx.get_device_address +#define libusb_open libusb_ctx.open +#define libusb_close libusb_ctx.close +#define libusb_claim_interface libusb_ctx.claim_interface +#define libusb_release_interface libusb_ctx.release_interface +#define libusb_kernel_driver_active libusb_ctx.kernel_driver_active +#define libusb_detach_kernel_driver libusb_ctx.detach_kernel_driver +#define libusb_attach_kernel_driver libusb_ctx.attach_kernel_driver +#define libusb_set_interface_alt_setting libusb_ctx.set_interface_alt_setting +#define libusb_alloc_transfer libusb_ctx.alloc_transfer +#define libusb_submit_transfer libusb_ctx.submit_transfer +#define libusb_cancel_transfer libusb_ctx.cancel_transfer +#define libusb_free_transfer libusb_ctx.free_transfer +#define libusb_control_transfer libusb_ctx.control_transfer +#define libusb_interrupt_transfer libusb_ctx.interrupt_transfer +#define libusb_handle_events libusb_ctx.handle_events +#define libusb_handle_events_completed libusb_ctx.handle_events_completed +#define libusb_error_name libusb_ctx.error_name -#define hid_device LIBUSB_hid_device -#define hid_device_ LIBUSB_hid_device_ -#define hid_init LIBUSB_hid_init -#define hid_exit LIBUSB_hid_exit -#define hid_enumerate LIBUSB_hid_enumerate -#define hid_free_enumeration LIBUSB_hid_free_enumeration -#define hid_open LIBUSB_hid_open -#define hid_open_path LIBUSB_hid_open_path -#define hid_write LIBUSB_hid_write -#define hid_read_timeout LIBUSB_hid_read_timeout -#define hid_read LIBUSB_hid_read -#define hid_set_nonblocking LIBUSB_hid_set_nonblocking -#define hid_send_feature_report LIBUSB_hid_send_feature_report -#define hid_get_feature_report LIBUSB_hid_get_feature_report -#define hid_close LIBUSB_hid_close -#define hid_get_manufacturer_string LIBUSB_hid_get_manufacturer_string -#define hid_get_product_string LIBUSB_hid_get_product_string -#define hid_get_serial_number_string LIBUSB_hid_get_serial_number_string -#define hid_get_indexed_string LIBUSB_hid_get_indexed_string -#define hid_error LIBUSB_hid_error -#define new_hid_device LIBUSB_new_hid_device -#define free_hid_device LIBUSB_free_hid_device -#define input_report LIBUSB_input_report -#define return_data LIBUSB_return_data -#define make_path LIBUSB_make_path -#define read_thread LIBUSB_read_thread +#define hid_device LIBUSB_hid_device +#define hid_device_ LIBUSB_hid_device_ +#define hid_init LIBUSB_hid_init +#define hid_exit LIBUSB_hid_exit +#define hid_enumerate LIBUSB_hid_enumerate +#define hid_free_enumeration LIBUSB_hid_free_enumeration +#define hid_open LIBUSB_hid_open +#define hid_open_path LIBUSB_hid_open_path +#define hid_write LIBUSB_hid_write +#define hid_read_timeout LIBUSB_hid_read_timeout +#define hid_read LIBUSB_hid_read +#define hid_set_nonblocking LIBUSB_hid_set_nonblocking +#define hid_send_feature_report LIBUSB_hid_send_feature_report +#define hid_get_feature_report LIBUSB_hid_get_feature_report +#define hid_close LIBUSB_hid_close +#define hid_get_manufacturer_string LIBUSB_hid_get_manufacturer_string +#define hid_get_product_string LIBUSB_hid_get_product_string +#define hid_get_serial_number_string LIBUSB_hid_get_serial_number_string +#define hid_get_indexed_string LIBUSB_hid_get_indexed_string +#define hid_error LIBUSB_hid_error +#define new_hid_device LIBUSB_new_hid_device +#define free_hid_device LIBUSB_free_hid_device +#define input_report LIBUSB_input_report +#define return_data LIBUSB_return_data +#define make_path LIBUSB_make_path +#define read_thread LIBUSB_read_thread #ifndef __FreeBSD__ /* this is awkwardly inlined, so we need to re-implement it here @@ -878,69 +885,70 @@ SDL_libusb_get_string_descriptor(libusb_device_handle *dev, /* Shared HIDAPI Implementation */ -struct hidapi_backend { - int (*hid_write)(void* device, const unsigned char* data, size_t length); - int (*hid_read_timeout)(void* device, unsigned char* data, size_t length, int milliseconds); - int (*hid_read)(void* device, unsigned char* data, size_t length); - int (*hid_set_nonblocking)(void* device, int nonblock); - int (*hid_send_feature_report)(void* device, const unsigned char* data, size_t length); - int (*hid_get_feature_report)(void* device, unsigned char* data, size_t length); - void (*hid_close)(void* device); - int (*hid_get_manufacturer_string)(void* device, wchar_t* string, size_t maxlen); - int (*hid_get_product_string)(void* device, wchar_t* string, size_t maxlen); - int (*hid_get_serial_number_string)(void* device, wchar_t* string, size_t maxlen); - int (*hid_get_indexed_string)(void* device, int string_index, wchar_t* string, size_t maxlen); - const wchar_t* (*hid_error)(void* device); +struct hidapi_backend +{ + int (*hid_write)(void *device, const unsigned char *data, size_t length); + int (*hid_read_timeout)(void *device, unsigned char *data, size_t length, int milliseconds); + int (*hid_read)(void *device, unsigned char *data, size_t length); + int (*hid_set_nonblocking)(void *device, int nonblock); + int (*hid_send_feature_report)(void *device, const unsigned char *data, size_t length); + int (*hid_get_feature_report)(void *device, unsigned char *data, size_t length); + void (*hid_close)(void *device); + int (*hid_get_manufacturer_string)(void *device, wchar_t *string, size_t maxlen); + int (*hid_get_product_string)(void *device, wchar_t *string, size_t maxlen); + int (*hid_get_serial_number_string)(void *device, wchar_t *string, size_t maxlen); + int (*hid_get_indexed_string)(void *device, int string_index, wchar_t *string, size_t maxlen); + const wchar_t *(*hid_error)(void *device); }; #if HAVE_PLATFORM_BACKEND static const struct hidapi_backend PLATFORM_Backend = { - (void*)PLATFORM_hid_write, - (void*)PLATFORM_hid_read_timeout, - (void*)PLATFORM_hid_read, - (void*)PLATFORM_hid_set_nonblocking, - (void*)PLATFORM_hid_send_feature_report, - (void*)PLATFORM_hid_get_feature_report, - (void*)PLATFORM_hid_close, - (void*)PLATFORM_hid_get_manufacturer_string, - (void*)PLATFORM_hid_get_product_string, - (void*)PLATFORM_hid_get_serial_number_string, - (void*)PLATFORM_hid_get_indexed_string, - (void*)PLATFORM_hid_error + (void *)PLATFORM_hid_write, + (void *)PLATFORM_hid_read_timeout, + (void *)PLATFORM_hid_read, + (void *)PLATFORM_hid_set_nonblocking, + (void *)PLATFORM_hid_send_feature_report, + (void *)PLATFORM_hid_get_feature_report, + (void *)PLATFORM_hid_close, + (void *)PLATFORM_hid_get_manufacturer_string, + (void *)PLATFORM_hid_get_product_string, + (void *)PLATFORM_hid_get_serial_number_string, + (void *)PLATFORM_hid_get_indexed_string, + (void *)PLATFORM_hid_error }; #endif /* HAVE_PLATFORM_BACKEND */ #if HAVE_DRIVER_BACKEND static const struct hidapi_backend DRIVER_Backend = { - (void*)DRIVER_hid_write, - (void*)DRIVER_hid_read_timeout, - (void*)DRIVER_hid_read, - (void*)DRIVER_hid_set_nonblocking, - (void*)DRIVER_hid_send_feature_report, - (void*)DRIVER_hid_get_feature_report, - (void*)DRIVER_hid_close, - (void*)DRIVER_hid_get_manufacturer_string, - (void*)DRIVER_hid_get_product_string, - (void*)DRIVER_hid_get_serial_number_string, - (void*)DRIVER_hid_get_indexed_string, - (void*)DRIVER_hid_error + (void *)DRIVER_hid_write, + (void *)DRIVER_hid_read_timeout, + (void *)DRIVER_hid_read, + (void *)DRIVER_hid_set_nonblocking, + (void *)DRIVER_hid_send_feature_report, + (void *)DRIVER_hid_get_feature_report, + (void *)DRIVER_hid_close, + (void *)DRIVER_hid_get_manufacturer_string, + (void *)DRIVER_hid_get_product_string, + (void *)DRIVER_hid_get_serial_number_string, + (void *)DRIVER_hid_get_indexed_string, + (void *)DRIVER_hid_error }; #endif /* HAVE_DRIVER_BACKEND */ #ifdef HAVE_LIBUSB static const struct hidapi_backend LIBUSB_Backend = { - (void*)LIBUSB_hid_write, - (void*)LIBUSB_hid_read_timeout, - (void*)LIBUSB_hid_read, - (void*)LIBUSB_hid_set_nonblocking, - (void*)LIBUSB_hid_send_feature_report, - (void*)LIBUSB_hid_get_feature_report, - (void*)LIBUSB_hid_close, - (void*)LIBUSB_hid_get_manufacturer_string, - (void*)LIBUSB_hid_get_product_string, - (void*)LIBUSB_hid_get_serial_number_string, - (void*)LIBUSB_hid_get_indexed_string, - (void*)LIBUSB_hid_error + (void *)LIBUSB_hid_write, + (void *)LIBUSB_hid_read_timeout, + (void *)LIBUSB_hid_read, + (void *)LIBUSB_hid_set_nonblocking, + (void *)LIBUSB_hid_send_feature_report, + (void *)LIBUSB_hid_get_feature_report, + (void *)LIBUSB_hid_close, + (void *)LIBUSB_hid_get_manufacturer_string, + (void *)LIBUSB_hid_get_product_string, + (void *)LIBUSB_hid_get_serial_number_string, + (void *)LIBUSB_hid_get_indexed_string, + (void *)LIBUSB_hid_error }; #endif /* HAVE_LIBUSB */ @@ -973,26 +981,26 @@ DeleteHIDDeviceWrapper(SDL_hid_device *device) SDL_free(device); } -#define CHECK_DEVICE_MAGIC(device, retval) \ +#define CHECK_DEVICE_MAGIC(device, retval) \ if (!device || device->magic != &device_magic) { \ - SDL_SetError("Invalid device"); \ - return retval; \ + SDL_SetError("Invalid device"); \ + return retval; \ } #if !SDL_HIDAPI_DISABLED #if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB) -#define COPY_IF_EXISTS(var) \ - if (pSrc->var != NULL) { \ +#define COPY_IF_EXISTS(var) \ + if (pSrc->var != NULL) { \ pDst->var = SDL_strdup(pSrc->var); \ - } else { \ - pDst->var = NULL; \ + } else { \ + pDst->var = NULL; \ } -#define WCOPY_IF_EXISTS(var) \ - if (pSrc->var != NULL) { \ +#define WCOPY_IF_EXISTS(var) \ + if (pSrc->var != NULL) { \ pDst->var = SDL_wcsdup(pSrc->var); \ - } else { \ - pDst->var = NULL; \ + } else { \ + pDst->var = NULL; \ } static void @@ -1022,7 +1030,7 @@ CopyHIDDeviceInfo(struct SDL_hid_device_info *pSrc, struct SDL_hid_device_info * static int SDL_hidapi_refcount = 0; -static void SDL_SetHIDAPIError( const wchar_t *error ) +static void SDL_SetHIDAPIError(const wchar_t *error) { if (error) { char *error_utf8 = SDL_iconv_wchar_utf8(error); @@ -1073,11 +1081,13 @@ int SDL_hid_init(void) if (libusb_ctx.libhandle != NULL) { SDL_bool loaded = SDL_TRUE; #ifdef SDL_LIBUSB_DYNAMIC - #define LOAD_LIBUSB_SYMBOL(func) \ - if (!(libusb_ctx.func = SDL_LoadFunction(libusb_ctx.libhandle, "libusb_" #func))) {loaded = SDL_FALSE;} +#define LOAD_LIBUSB_SYMBOL(func) \ + if (!(libusb_ctx.func = SDL_LoadFunction(libusb_ctx.libhandle, "libusb_" #func))) { \ + loaded = SDL_FALSE; \ + } #else - #define LOAD_LIBUSB_SYMBOL(func) \ - libusb_ctx.func = libusb_##func; +#define LOAD_LIBUSB_SYMBOL(func) \ + libusb_ctx.func = libusb_##func; #endif LOAD_LIBUSB_SYMBOL(init) LOAD_LIBUSB_SYMBOL(exit) @@ -1106,7 +1116,7 @@ int SDL_hid_init(void) LOAD_LIBUSB_SYMBOL(handle_events) LOAD_LIBUSB_SYMBOL(handle_events_completed) LOAD_LIBUSB_SYMBOL(error_name) - #undef LOAD_LIBUSB_SYMBOL +#undef LOAD_LIBUSB_SYMBOL if (!loaded) { #ifdef SDL_LIBUSB_DYNAMIC @@ -1213,8 +1223,8 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned struct SDL_hid_device_info *usb_dev; #endif #if HAVE_DRIVER_BACKEND - struct SDL_hid_device_info* driver_devs = NULL; - struct SDL_hid_device_info* driver_dev; + struct SDL_hid_device_info *driver_devs = NULL; + struct SDL_hid_device_info *driver_dev; #endif #if HAVE_PLATFORM_BACKEND struct SDL_hid_device_info *raw_devs = NULL; @@ -1233,7 +1243,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned SDL_Log("libusb devices found:"); #endif for (usb_dev = usb_devs; usb_dev; usb_dev = usb_dev->next) { - new_dev = (struct SDL_hid_device_info*) SDL_malloc(sizeof(struct SDL_hid_device_info)); + new_dev = (struct SDL_hid_device_info *)SDL_malloc(sizeof(struct SDL_hid_device_info)); if (new_dev == NULL) { LIBUSB_hid_free_enumeration(usb_devs); SDL_hid_free_enumeration(devs); @@ -1260,7 +1270,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned #ifdef HAVE_DRIVER_BACKEND driver_devs = DRIVER_hid_enumerate(vendor_id, product_id); for (driver_dev = driver_devs; driver_dev; driver_dev = driver_dev->next) { - new_dev = (struct SDL_hid_device_info*) SDL_malloc(sizeof(struct SDL_hid_device_info)); + new_dev = (struct SDL_hid_device_info *)SDL_malloc(sizeof(struct SDL_hid_device_info)); CopyHIDDeviceInfo(driver_dev, new_dev); if (last != NULL) { @@ -1306,7 +1316,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned } #endif if (!bFound) { - new_dev = (struct SDL_hid_device_info*) SDL_malloc(sizeof(struct SDL_hid_device_info)); + new_dev = (struct SDL_hid_device_info *)SDL_malloc(sizeof(struct SDL_hid_device_info)); if (new_dev == NULL) { #ifdef HAVE_LIBUSB if (libusb_ctx.libhandle) { @@ -1506,7 +1516,7 @@ int SDL_hid_get_feature_report(SDL_hid_device *device, unsigned char *data, size void SDL_hid_close(SDL_hid_device *device) { - CHECK_DEVICE_MAGIC(device,); + CHECK_DEVICE_MAGIC(device, ); device->backend->hid_close(device->device); DeleteHIDDeviceWrapper(device); diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index 46a465803..6b538c952 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -40,20 +40,19 @@ #include "SDL_system.h" #endif - /* Many controllers turn the center button into an instantaneous button press */ -#define SDL_MINIMUM_GUIDE_BUTTON_DELAY_MS 250 +#define SDL_MINIMUM_GUIDE_BUTTON_DELAY_MS 250 -#define SDL_CONTROLLER_CRC_FIELD "crc:" -#define SDL_CONTROLLER_CRC_FIELD_SIZE 4 /* hard-coded for speed */ -#define SDL_CONTROLLER_PLATFORM_FIELD "platform:" -#define SDL_CONTROLLER_PLATFORM_FIELD_SIZE SDL_strlen(SDL_CONTROLLER_PLATFORM_FIELD) -#define SDL_CONTROLLER_HINT_FIELD "hint:" -#define SDL_CONTROLLER_HINT_FIELD_SIZE SDL_strlen(SDL_CONTROLLER_HINT_FIELD) -#define SDL_CONTROLLER_SDKGE_FIELD "sdk>=:" -#define SDL_CONTROLLER_SDKGE_FIELD_SIZE SDL_strlen(SDL_CONTROLLER_SDKGE_FIELD) -#define SDL_CONTROLLER_SDKLE_FIELD "sdk<=:" -#define SDL_CONTROLLER_SDKLE_FIELD_SIZE SDL_strlen(SDL_CONTROLLER_SDKLE_FIELD) +#define SDL_CONTROLLER_CRC_FIELD "crc:" +#define SDL_CONTROLLER_CRC_FIELD_SIZE 4 /* hard-coded for speed */ +#define SDL_CONTROLLER_PLATFORM_FIELD "platform:" +#define SDL_CONTROLLER_PLATFORM_FIELD_SIZE SDL_strlen(SDL_CONTROLLER_PLATFORM_FIELD) +#define SDL_CONTROLLER_HINT_FIELD "hint:" +#define SDL_CONTROLLER_HINT_FIELD_SIZE SDL_strlen(SDL_CONTROLLER_HINT_FIELD) +#define SDL_CONTROLLER_SDKGE_FIELD "sdk>=:" +#define SDL_CONTROLLER_SDKGE_FIELD_SIZE SDL_strlen(SDL_CONTROLLER_SDKGE_FIELD) +#define SDL_CONTROLLER_SDKLE_FIELD "sdk<=:" +#define SDL_CONTROLLER_SDKLE_FIELD_SIZE SDL_strlen(SDL_CONTROLLER_SDKLE_FIELD) /* a list of currently opened game controllers */ static SDL_GameController *SDL_gamecontrollers = NULL; @@ -65,13 +64,15 @@ typedef struct { int button; - struct { + struct + { int axis; int axis_min; int axis_max; } axis; - struct { + struct + { int hat; int hat_mask; } hat; @@ -83,7 +84,8 @@ typedef struct { SDL_GameControllerButton button; - struct { + struct + { SDL_GameControllerAxis axis; int axis_min; int axis_max; @@ -135,12 +137,11 @@ struct _SDL_GameController struct _SDL_GameController *next; /* pointer to next game controller we have allocated */ }; - -#define CHECK_GAMECONTROLLER_MAGIC(gamecontroller, retval) \ +#define CHECK_GAMECONTROLLER_MAGIC(gamecontroller, retval) \ if (!gamecontroller || gamecontroller->magic != &gamecontroller_magic || \ - !SDL_PrivateJoystickValid(gamecontroller->joystick)) { \ - SDL_InvalidParamError("gamecontroller"); \ - return retval; \ + !SDL_PrivateJoystickValid(gamecontroller->joystick)) { \ + SDL_InvalidParamError("gamecontroller"); \ + return retval; \ } typedef struct @@ -153,8 +154,7 @@ typedef struct static SDL_vidpid_list SDL_allowed_controllers; static SDL_vidpid_list SDL_ignored_controllers; -static void -SDL_LoadVIDPIDListFromHint(const char *hint, SDL_vidpid_list *list) +static void SDL_LoadVIDPIDListFromHint(const char *hint, SDL_vidpid_list *list) { Uint32 entry; char *spot; @@ -163,7 +163,7 @@ SDL_LoadVIDPIDListFromHint(const char *hint, SDL_vidpid_list *list) list->num_entries = 0; if (hint && *hint == '@') { - spot = file = (char *)SDL_LoadFile(hint+1, NULL); + spot = file = (char *)SDL_LoadFile(hint + 1, NULL); } else { spot = (char *)hint; } @@ -183,7 +183,7 @@ SDL_LoadVIDPIDListFromHint(const char *hint, SDL_vidpid_list *list) if (list->num_entries == list->max_entries) { int max_entries = list->max_entries + 16; - Uint32 *entries = (Uint32 *)SDL_realloc(list->entries, max_entries*sizeof(*list->entries)); + Uint32 *entries = (Uint32 *)SDL_realloc(list->entries, max_entries * sizeof(*list->entries)); if (entries == NULL) { /* Out of memory, go with what we have already */ break; @@ -199,14 +199,12 @@ SDL_LoadVIDPIDListFromHint(const char *hint, SDL_vidpid_list *list) } } -static void SDLCALL -SDL_GameControllerIgnoreDevicesChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_GameControllerIgnoreDevicesChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_LoadVIDPIDListFromHint(hint, &SDL_ignored_controllers); } -static void SDLCALL -SDL_GameControllerIgnoreDevicesExceptChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_GameControllerIgnoreDevicesExceptChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_LoadVIDPIDListFromHint(hint, &SDL_allowed_controllers); } @@ -341,7 +339,6 @@ static void HandleJoystickHat(SDL_GameController *gamecontroller, int hat, Uint8 gamecontroller->last_hat_mask[hat] = value; } - /* The joystick layer will _also_ send events to recenter before disconnect, but it has to make (sometimes incorrect) guesses at what being "centered" is. The game controller layer, however, can set a definite logical idle @@ -355,94 +352,88 @@ static void RecenterGameController(SDL_GameController *gamecontroller) CHECK_GAMECONTROLLER_MAGIC(gamecontroller, ); - for (button = (SDL_GameControllerButton) 0; button < SDL_CONTROLLER_BUTTON_MAX; button++) { + for (button = (SDL_GameControllerButton)0; button < SDL_CONTROLLER_BUTTON_MAX; button++) { if (SDL_GameControllerGetButton(gamecontroller, button)) { SDL_PrivateGameControllerButton(gamecontroller, button, SDL_RELEASED); } } - for (axis = (SDL_GameControllerAxis) 0; axis < SDL_CONTROLLER_AXIS_MAX; axis++) { + for (axis = (SDL_GameControllerAxis)0; axis < SDL_CONTROLLER_AXIS_MAX; axis++) { if (SDL_GameControllerGetAxis(gamecontroller, axis) != 0) { SDL_PrivateGameControllerAxis(gamecontroller, axis, 0); } } } - /* * Event filter to fire controller events from joystick ones */ -static int SDLCALL SDL_GameControllerEventWatcher(void *userdata, SDL_Event * event) +static int SDLCALL SDL_GameControllerEventWatcher(void *userdata, SDL_Event *event) { - switch(event->type) { + switch (event->type) { case SDL_JOYAXISMOTION: - { - SDL_GameController *controllerlist = SDL_gamecontrollers; - while (controllerlist) { - if (controllerlist->joystick->instance_id == event->jaxis.which) { - HandleJoystickAxis(controllerlist, event->jaxis.axis, event->jaxis.value); - break; - } - controllerlist = controllerlist->next; + { + SDL_GameController *controllerlist = SDL_gamecontrollers; + while (controllerlist) { + if (controllerlist->joystick->instance_id == event->jaxis.which) { + HandleJoystickAxis(controllerlist, event->jaxis.axis, event->jaxis.value); + break; } + controllerlist = controllerlist->next; } - break; + } break; case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: - { - SDL_GameController *controllerlist = SDL_gamecontrollers; - while (controllerlist) { - if (controllerlist->joystick->instance_id == event->jbutton.which) { - HandleJoystickButton(controllerlist, event->jbutton.button, event->jbutton.state); - break; - } - controllerlist = controllerlist->next; + { + SDL_GameController *controllerlist = SDL_gamecontrollers; + while (controllerlist) { + if (controllerlist->joystick->instance_id == event->jbutton.which) { + HandleJoystickButton(controllerlist, event->jbutton.button, event->jbutton.state); + break; } + controllerlist = controllerlist->next; } - break; + } break; case SDL_JOYHATMOTION: - { - SDL_GameController *controllerlist = SDL_gamecontrollers; - while (controllerlist) { - if (controllerlist->joystick->instance_id == event->jhat.which) { - HandleJoystickHat(controllerlist, event->jhat.hat, event->jhat.value); - break; - } - controllerlist = controllerlist->next; + { + SDL_GameController *controllerlist = SDL_gamecontrollers; + while (controllerlist) { + if (controllerlist->joystick->instance_id == event->jhat.which) { + HandleJoystickHat(controllerlist, event->jhat.hat, event->jhat.value); + break; } + controllerlist = controllerlist->next; } - break; + } break; case SDL_JOYDEVICEADDED: - { - if (SDL_IsGameController(event->jdevice.which)) { - SDL_Event deviceevent; - deviceevent.type = SDL_CONTROLLERDEVICEADDED; - deviceevent.cdevice.which = event->jdevice.which; - SDL_PushEvent(&deviceevent); - } + { + if (SDL_IsGameController(event->jdevice.which)) { + SDL_Event deviceevent; + deviceevent.type = SDL_CONTROLLERDEVICEADDED; + deviceevent.cdevice.which = event->jdevice.which; + SDL_PushEvent(&deviceevent); } - break; + } break; case SDL_JOYDEVICEREMOVED: - { - SDL_GameController *controllerlist = SDL_gamecontrollers; - while (controllerlist) { - if (controllerlist->joystick->instance_id == event->jdevice.which) { - RecenterGameController(controllerlist); - break; - } - controllerlist = controllerlist->next; - } - - /* We don't know if this was a game controller, so go ahead and send an event */ - { - SDL_Event deviceevent; - - deviceevent.type = SDL_CONTROLLERDEVICEREMOVED; - deviceevent.cdevice.which = event->jdevice.which; - SDL_PushEvent(&deviceevent); + { + SDL_GameController *controllerlist = SDL_gamecontrollers; + while (controllerlist) { + if (controllerlist->joystick->instance_id == event->jdevice.which) { + RecenterGameController(controllerlist); + break; } + controllerlist = controllerlist->next; } - break; + + /* We don't know if this was a game controller, so go ahead and send an event */ + { + SDL_Event deviceevent; + + deviceevent.type = SDL_CONTROLLERDEVICEREMOVED; + deviceevent.cdevice.which = event->jdevice.which; + SDL_PushEvent(&deviceevent); + } + } break; default: break; } @@ -465,8 +456,8 @@ static ControllerMapping_t *SDL_CreateMappingForAndroidController(SDL_JoystickGU int button_mask; int axis_mask; - button_mask = SDL_SwapLE16(*(Uint16*)(&guid.data[sizeof(guid.data)-4])); - axis_mask = SDL_SwapLE16(*(Uint16*)(&guid.data[sizeof(guid.data)-2])); + button_mask = SDL_SwapLE16(*(Uint16 *)(&guid.data[sizeof(guid.data) - 4])); + axis_mask = SDL_SwapLE16(*(Uint16 *)(&guid.data[sizeof(guid.data) - 2])); if (!button_mask && !axis_mask) { /* Accelerometer, shouldn't have a game controller mapping */ return NULL; @@ -594,17 +585,16 @@ static ControllerMapping_t *SDL_CreateMappingForHIDAPIController(SDL_JoystickGUI SDL_strlcat(mapping_string, "a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,start:b6,x:b2,y:b3,", sizeof(mapping_string)); break; case k_eWiiExtensionControllerType_Nunchuk: - { - /* FIXME: Should we map this to the left or right side? */ - const SDL_bool map_nunchuck_left_side = SDL_TRUE; + { + /* FIXME: Should we map this to the left or right side? */ + const SDL_bool map_nunchuck_left_side = SDL_TRUE; - if (map_nunchuck_left_side) { - SDL_strlcat(mapping_string, "a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,lefttrigger:a4,leftx:a0,lefty:a1,start:b6,x:b2,y:b3,", sizeof(mapping_string)); - } else { - SDL_strlcat(mapping_string, "a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,rightshoulder:b9,righttrigger:a4,rightx:a0,righty:a1,start:b6,x:b2,y:b3,", sizeof(mapping_string)); - } + if (map_nunchuck_left_side) { + SDL_strlcat(mapping_string, "a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,lefttrigger:a4,leftx:a0,lefty:a1,start:b6,x:b2,y:b3,", sizeof(mapping_string)); + } else { + SDL_strlcat(mapping_string, "a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,rightshoulder:b9,righttrigger:a4,rightx:a0,righty:a1,start:b6,x:b2,y:b3,", sizeof(mapping_string)); } - break; + } break; default: if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_VERTICAL_JOY_CONS, SDL_FALSE)) { /* Vertical mode */ @@ -750,7 +740,7 @@ static ControllerMapping_t *SDL_PrivateMatchControllerMappingForGUID(SDL_Joystic Uint16 mapping_crc = 0; const char *crc_string = SDL_strstr(mapping->mapping, SDL_CONTROLLER_CRC_FIELD); if (crc_string) { - mapping_crc = (Uint16)SDL_strtol(crc_string + SDL_CONTROLLER_CRC_FIELD_SIZE, NULL, 16); + mapping_crc = (Uint16)SDL_strtol(crc_string + SDL_CONTROLLER_CRC_FIELD_SIZE, NULL, 16); } if (crc == mapping_crc) { return mapping; @@ -822,7 +812,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickG return mapping; } -static const char* map_StringForControllerAxis[] = { +static const char *map_StringForControllerAxis[] = { "leftx", "lefty", "rightx", @@ -858,7 +848,7 @@ SDL_GameControllerAxis SDL_GameControllerGetAxisFromString(const char *pchString /* * convert an enum to its string equivalent */ -const char* SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis) +const char *SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis) { if (axis > SDL_CONTROLLER_AXIS_INVALID && axis < SDL_CONTROLLER_AXIS_MAX) { return map_StringForControllerAxis[axis]; @@ -866,7 +856,7 @@ const char* SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis) return NULL; } -static const char* map_StringForControllerButton[] = { +static const char *map_StringForControllerButton[] = { "a", "b", "x", @@ -912,7 +902,7 @@ SDL_GameControllerButton SDL_GameControllerGetButtonFromString(const char *pchSt /* * convert an enum to its string equivalent */ -const char* SDL_GameControllerGetStringForButton(SDL_GameControllerButton axis) +const char *SDL_GameControllerGetStringForButton(SDL_GameControllerButton axis) { if (axis > SDL_CONTROLLER_BUTTON_INVALID && axis < SDL_CONTROLLER_BUTTON_MAX) { return map_StringForControllerButton[axis]; @@ -973,7 +963,7 @@ static void SDL_PrivateGameControllerParseElement(SDL_GameController *gamecontro invert_input = SDL_TRUE; } - if (szJoystickButton[0] == 'a' && SDL_isdigit((unsigned char) szJoystickButton[1])) { + if (szJoystickButton[0] == 'a' && SDL_isdigit((unsigned char)szJoystickButton[1])) { bind.inputType = SDL_CONTROLLER_BINDTYPE_AXIS; bind.input.axis.axis = SDL_atoi(&szJoystickButton[1]); if (half_axis_input == '+') { @@ -991,11 +981,11 @@ static void SDL_PrivateGameControllerParseElement(SDL_GameController *gamecontro bind.input.axis.axis_min = bind.input.axis.axis_max; bind.input.axis.axis_max = tmp; } - } else if (szJoystickButton[0] == 'b' && SDL_isdigit((unsigned char) szJoystickButton[1])) { + } else if (szJoystickButton[0] == 'b' && SDL_isdigit((unsigned char)szJoystickButton[1])) { bind.inputType = SDL_CONTROLLER_BINDTYPE_BUTTON; bind.input.button = SDL_atoi(&szJoystickButton[1]); - } else if (szJoystickButton[0] == 'h' && SDL_isdigit((unsigned char) szJoystickButton[1]) && - szJoystickButton[2] == '.' && SDL_isdigit((unsigned char) szJoystickButton[3])) { + } else if (szJoystickButton[0] == 'h' && SDL_isdigit((unsigned char)szJoystickButton[1]) && + szJoystickButton[2] == '.' && SDL_isdigit((unsigned char)szJoystickButton[3])) { int hat = SDL_atoi(&szJoystickButton[1]); int mask = SDL_atoi(&szJoystickButton[3]); bind.inputType = SDL_CONTROLLER_BINDTYPE_HAT; @@ -1016,12 +1006,10 @@ static void SDL_PrivateGameControllerParseElement(SDL_GameController *gamecontro gamecontroller->bindings[gamecontroller->num_bindings - 1] = bind; } - /* * given a controller mapping string update our mapping object */ -static void -SDL_PrivateGameControllerParseControllerConfigString(SDL_GameController *gamecontroller, const char *pchString) +static void SDL_PrivateGameControllerParseControllerConfigString(SDL_GameController *gamecontroller, const char *pchString) { char szGameButton[20]; char szJoystickButton[20]; @@ -1098,13 +1086,12 @@ static void SDL_PrivateLoadButtonMapping(SDL_GameController *gamecontroller, Con binding->output.axis.axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT)) { if (binding->input.axis.axis < gamecontroller->joystick->naxes) { gamecontroller->joystick->axes[binding->input.axis.axis].value = - gamecontroller->joystick->axes[binding->input.axis.axis].zero = (Sint16)binding->input.axis.axis_min; + gamecontroller->joystick->axes[binding->input.axis.axis].zero = (Sint16)binding->input.axis.axis_min; } } } } - /* * grab the guid string from a mapping string */ @@ -1143,7 +1130,6 @@ static char *SDL_PrivateGetControllerGUIDFromMappingString(const char *pMapping) return NULL; } - /* * grab the name string from a mapping string */ @@ -1172,7 +1158,6 @@ static char *SDL_PrivateGetControllerNameFromMappingString(const char *pMapping) return pchName; } - /* * grab the button mapping string from a mapping string */ @@ -1219,8 +1204,7 @@ static void SDL_PrivateGameControllerRefreshMapping(ControllerMapping_t *pContro /* * Helper function to add a mapping for a guid */ -static ControllerMapping_t * -SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, const char *mappingString, SDL_bool *existing, SDL_ControllerMappingPriority priority) +static ControllerMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, const char *mappingString, SDL_bool *existing, SDL_ControllerMappingPriority priority) { char *pchName; char *pchMapping; @@ -1311,9 +1295,9 @@ SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, const char *mappingString, /* Add the mapping to the end of the list */ ControllerMapping_t *pCurrMapping, *pPrevMapping; - for ( pPrevMapping = s_pSupportedControllers, pCurrMapping = pPrevMapping->next; - pCurrMapping; - pPrevMapping = pCurrMapping, pCurrMapping = pCurrMapping->next ) { + for (pPrevMapping = s_pSupportedControllers, pCurrMapping = pPrevMapping->next; + pCurrMapping; + pPrevMapping = pCurrMapping, pCurrMapping = pCurrMapping->next) { /* continue; */ } pPrevMapping->next = pControllerMapping; @@ -1339,8 +1323,8 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForNameAndGUID(const /* The Linux driver xpad.c maps the wireless dpad to buttons */ SDL_bool existing; mapping = SDL_PrivateAddMappingForGUID(guid, -"none,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", - &existing, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT); + "none,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", + &existing, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT); } else if (SDL_strstr(name, "Xbox") || SDL_strstr(name, "X-Box") || SDL_strstr(name, "XBOX")) { mapping = s_pXInputMapping; } @@ -1366,17 +1350,17 @@ static void SDL_PrivateAppendToMappingString(char *mapping_string, SDL_strlcat(mapping_string, input_name, mapping_string_len); SDL_strlcat(mapping_string, ":", mapping_string_len); switch (mapping->kind) { - case EMappingKind_Button: - SDL_snprintf(buffer, sizeof(buffer), "b%i", mapping->target); - break; - case EMappingKind_Axis: - SDL_snprintf(buffer, sizeof(buffer), "a%i", mapping->target); - break; - case EMappingKind_Hat: - SDL_snprintf(buffer, sizeof(buffer), "h%i.%i", mapping->target >> 4, mapping->target & 0x0F); - break; - default: - SDL_assert(SDL_FALSE); + case EMappingKind_Button: + SDL_snprintf(buffer, sizeof(buffer), "b%i", mapping->target); + break; + case EMappingKind_Axis: + SDL_snprintf(buffer, sizeof(buffer), "a%i", mapping->target); + break; + case EMappingKind_Hat: + SDL_snprintf(buffer, sizeof(buffer), "h%i.%i", mapping->target >> 4, mapping->target & 0x0F); + break; + default: + SDL_assert(SDL_FALSE); } SDL_strlcat(mapping_string, buffer, mapping_string_len); @@ -1465,19 +1449,18 @@ static ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index) /* * Add or update an entry into the Mappings Database */ -int -SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw) +int SDL_GameControllerAddMappingsFromRW(SDL_RWops *rw, int freerw) { const char *platform = SDL_GetPlatform(); int controllers = 0; char *buf, *line, *line_end, *tmp, *comma, line_platform[64]; size_t db_size, platform_len; - + if (rw == NULL) { return SDL_SetError("Invalid RWops"); } db_size = (size_t)SDL_RWsize(rw); - + buf = (char *)SDL_malloc(db_size + 1); if (buf == NULL) { if (freerw) { @@ -1485,7 +1468,7 @@ SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw) } return SDL_SetError("Could not allocate space to read DB into memory"); } - + if (SDL_RWread(rw, buf, db_size, 1) != 1) { if (freerw) { SDL_RWclose(rw); @@ -1493,14 +1476,14 @@ SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw) SDL_free(buf); return SDL_SetError("Could not read DB"); } - + if (freerw) { SDL_RWclose(rw); } - + buf[db_size] = '\0'; line = buf; - + while (line < buf + db_size) { line_end = SDL_strchr(line, '\n'); if (line_end != NULL) { @@ -1508,7 +1491,7 @@ SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw) } else { line_end = buf + db_size; } - + /* Extract and verify the platform */ tmp = SDL_strstr(line, SDL_CONTROLLER_PLATFORM_FIELD); if (tmp != NULL) { @@ -1536,8 +1519,7 @@ SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw) /* * Add or update an entry into the Mappings Database with a priority */ -static int -SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_ControllerMappingPriority priority) +static int SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_ControllerMappingPriority priority) { char *pchGUID; SDL_JoystickGUID jGUID; @@ -1644,8 +1626,7 @@ SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_ControllerMap /* * Add or update an entry into the Mappings Database */ -int -SDL_GameControllerAddMapping(const char *mappingString) +int SDL_GameControllerAddMapping(const char *mappingString) { return SDL_PrivateGameControllerAddMapping(mappingString, SDL_CONTROLLER_MAPPING_PRIORITY_API); } @@ -1653,8 +1634,7 @@ SDL_GameControllerAddMapping(const char *mappingString) /* * Get the number of mappings installed */ -int -SDL_GameControllerNumMappings(void) +int SDL_GameControllerNumMappings(void) { int num_mappings = 0; ControllerMapping_t *mapping; @@ -1671,8 +1651,7 @@ SDL_GameControllerNumMappings(void) /* * Create a mapping string for a mapping */ -static char * -CreateMappingString(ControllerMapping_t *mapping, SDL_JoystickGUID guid) +static char *CreateMappingString(ControllerMapping_t *mapping, SDL_JoystickGUID guid) { char *pMappingString, *pPlatformString; char pchGUID[33]; @@ -1766,8 +1745,7 @@ SDL_GameControllerMapping(SDL_GameController *gamecontroller) return CreateMappingString(gamecontroller->mapping, gamecontroller->joystick->guid); } -static void -SDL_GameControllerLoadHints() +static void SDL_GameControllerLoadHints() { const char *hint = SDL_GetHint(SDL_HINT_GAMECONTROLLERCONFIG); if (hint && hint[0]) { @@ -1797,7 +1775,7 @@ SDL_GameControllerLoadHints() } /* - * Fill the given buffer with the expected controller mapping filepath. + * Fill the given buffer with the expected controller mapping filepath. * Usually this will just be SDL_HINT_GAMECONTROLLERCONFIG_FILE, but for * Android, we want to get the internal storage path. */ @@ -1818,8 +1796,7 @@ static SDL_bool SDL_GetControllerMappingFilePath(char *path, size_t size) /* * Initialize the game controller system, mostly load our DB of controller config mappings */ -int -SDL_GameControllerInitMappings(void) +int SDL_GameControllerInitMappings(void) { char szControllerMapPath[1024]; int i = 0; @@ -1833,7 +1810,7 @@ SDL_GameControllerInitMappings(void) } if (SDL_GetControllerMappingFilePath(szControllerMapPath, sizeof(szControllerMapPath))) { - SDL_GameControllerAddMappingsFromFile(szControllerMapPath); + SDL_GameControllerAddMappingsFromFile(szControllerMapPath); } /* load in any user supplied config */ @@ -1847,8 +1824,7 @@ SDL_GameControllerInitMappings(void) return 0; } -int -SDL_GameControllerInit(void) +int SDL_GameControllerInit(void) { int i; @@ -1868,7 +1844,6 @@ SDL_GameControllerInit(void) return 0; } - /* * Get the implementation dependent name of a controller */ @@ -1886,7 +1861,6 @@ SDL_GameControllerNameForIndex(int device_index) return NULL; } - /* * Get the implementation dependent path of a controller */ @@ -1900,7 +1874,6 @@ SDL_GameControllerPathForIndex(int device_index) return NULL; } - /** * Get the type of a game controller. */ @@ -1910,7 +1883,6 @@ SDL_GameControllerTypeForIndex(int joystick_index) return SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGetDeviceGUID(joystick_index), SDL_JoystickNameForIndex(joystick_index)); } - /** * Get the mapping of a game controller. * This can be called before any controllers are opened. @@ -1944,7 +1916,6 @@ SDL_GameControllerMappingForDeviceIndex(int joystick_index) return pMappingString; } - /* * Return 1 if the joystick with this name and GUID is a supported controller */ @@ -2085,16 +2056,16 @@ SDL_GameControllerOpen(int device_index) instance_id = SDL_JoystickGetDeviceInstanceID(device_index); while (gamecontrollerlist) { if (instance_id == gamecontrollerlist->joystick->instance_id) { - gamecontroller = gamecontrollerlist; - ++gamecontroller->ref_count; - SDL_UnlockJoysticks(); - return gamecontroller; + gamecontroller = gamecontrollerlist; + ++gamecontroller->ref_count; + SDL_UnlockJoysticks(); + return gamecontroller; } gamecontrollerlist = gamecontrollerlist->next; } /* Find a controller mapping */ - pSupportedController = SDL_PrivateGetControllerMapping(device_index); + pSupportedController = SDL_PrivateGetControllerMapping(device_index); if (pSupportedController == NULL) { SDL_SetError("Couldn't find mapping for device (%d)", device_index); SDL_UnlockJoysticks(); @@ -2102,7 +2073,7 @@ SDL_GameControllerOpen(int device_index) } /* Create and initialize the controller */ - gamecontroller = (SDL_GameController *) SDL_calloc(1, sizeof(*gamecontroller)); + gamecontroller = (SDL_GameController *)SDL_calloc(1, sizeof(*gamecontroller)); if (gamecontroller == NULL) { SDL_OutOfMemory(); SDL_UnlockJoysticks(); @@ -2155,8 +2126,7 @@ SDL_GameControllerOpen(int device_index) /* * Manually pump for controller updates. */ -void -SDL_GameControllerUpdate(void) +void SDL_GameControllerUpdate(void) { /* Just for API completeness; the joystick API does all the work. */ SDL_JoystickUpdate(); @@ -2251,8 +2221,7 @@ SDL_GameControllerHasButton(SDL_GameController *gamecontroller, SDL_GameControll /* * Get the current state of a button on a controller */ -Uint8 -SDL_GameControllerGetButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button) +Uint8 SDL_GameControllerGetButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button) { int i; @@ -2291,8 +2260,7 @@ SDL_GameControllerGetButton(SDL_GameController *gamecontroller, SDL_GameControll /** * Get the number of touchpads on a game controller. */ -int -SDL_GameControllerGetNumTouchpads(SDL_GameController *gamecontroller) +int SDL_GameControllerGetNumTouchpads(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); @@ -2318,12 +2286,11 @@ int SDL_GameControllerGetNumTouchpadFingers(SDL_GameController *gamecontroller, /** * Get the current state of a finger on a touchpad on a game controller. */ -int -SDL_GameControllerGetTouchpadFinger(SDL_GameController *gamecontroller, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure) +int SDL_GameControllerGetTouchpadFinger(SDL_GameController *gamecontroller, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick ) { + if (joystick) { if (touchpad >= 0 && touchpad < joystick->ntouchpads) { SDL_JoystickTouchpadInfo *touchpad_info = &joystick->touchpads[touchpad]; if (finger >= 0 && finger < touchpad_info->nfingers) { @@ -2436,8 +2403,7 @@ SDL_bool SDL_GameControllerIsSensorEnabled(SDL_GameController *gamecontroller, S /* * Get the data rate of a game controller sensor. */ -float -SDL_GameControllerGetSensorDataRate(SDL_GameController *gamecontroller, SDL_SensorType type) +float SDL_GameControllerGetSensorDataRate(SDL_GameController *gamecontroller, SDL_SensorType type) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); int i; @@ -2459,8 +2425,7 @@ SDL_GameControllerGetSensorDataRate(SDL_GameController *gamecontroller, SDL_Sens /* * Get the current state of a game controller sensor. */ -int -SDL_GameControllerGetSensorData(SDL_GameController *gamecontroller, SDL_SensorType type, float *data, int num_values) +int SDL_GameControllerGetSensorData(SDL_GameController *gamecontroller, SDL_SensorType type, float *data, int num_values) { return SDL_GameControllerGetSensorDataWithTimestamp(gamecontroller, type, NULL, data, num_values); } @@ -2468,8 +2433,7 @@ SDL_GameControllerGetSensorData(SDL_GameController *gamecontroller, SDL_SensorTy /* * Get the current state of a game controller sensor. */ -int -SDL_GameControllerGetSensorDataWithTimestamp(SDL_GameController *gamecontroller, SDL_SensorType type, Uint64 *timestamp, float *data, int num_values) +int SDL_GameControllerGetSensorDataWithTimestamp(SDL_GameController *gamecontroller, SDL_SensorType type, Uint64 *timestamp, float *data, int num_values) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); int i; @@ -2483,7 +2447,7 @@ SDL_GameControllerGetSensorDataWithTimestamp(SDL_GameController *gamecontroller, if (sensor->type == type) { num_values = SDL_min(num_values, SDL_arraysize(sensor->data)); - SDL_memcpy(data, sensor->data, num_values*sizeof(*data)); + SDL_memcpy(data, sensor->data, num_values * sizeof(*data)); if (timestamp) { *timestamp = sensor->timestamp_us; } @@ -2527,8 +2491,7 @@ SDL_GameControllerGetType(SDL_GameController *gamecontroller) return SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGetGUID(joystick), SDL_JoystickName(joystick)); } -int -SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller) +int SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); @@ -2541,8 +2504,7 @@ SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller) /** * Set the player index of an opened game controller */ -void -SDL_GameControllerSetPlayerIndex(SDL_GameController *gamecontroller, int player_index) +void SDL_GameControllerSetPlayerIndex(SDL_GameController *gamecontroller, int player_index) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); @@ -2630,7 +2592,6 @@ SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller) return gamecontroller->joystick; } - /* * Return the SDL_GameController associated with an instance id. */ @@ -2652,7 +2613,6 @@ SDL_GameControllerFromInstanceID(SDL_JoystickID joyid) return NULL; } - /** * Return the SDL_GameController associated with a player index. */ @@ -2665,7 +2625,6 @@ SDL_GameController *SDL_GameControllerFromPlayerIndex(int player_index) return NULL; } - /* * Get the SDL joystick layer binding for this controller axis mapping */ @@ -2700,7 +2659,6 @@ SDL_GameControllerButtonBind SDL_GameControllerGetBindForAxis(SDL_GameController return bind; } - /* * Get the SDL joystick layer binding for this controller button mapping */ @@ -2734,9 +2692,7 @@ SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton(SDL_GameControll return bind; } - -int -SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms) +int SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); @@ -2746,8 +2702,7 @@ SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequenc return SDL_JoystickRumble(joystick, low_frequency_rumble, high_frequency_rumble, duration_ms); } -int -SDL_GameControllerRumbleTriggers(SDL_GameController *gamecontroller, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms) +int SDL_GameControllerRumbleTriggers(SDL_GameController *gamecontroller, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); @@ -2790,8 +2745,7 @@ SDL_GameControllerHasRumbleTriggers(SDL_GameController *gamecontroller) return SDL_JoystickHasRumbleTriggers(joystick); } -int -SDL_GameControllerSetLED(SDL_GameController *gamecontroller, Uint8 red, Uint8 green, Uint8 blue) +int SDL_GameControllerSetLED(SDL_GameController *gamecontroller, Uint8 red, Uint8 green, Uint8 blue) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); @@ -2801,8 +2755,7 @@ SDL_GameControllerSetLED(SDL_GameController *gamecontroller, Uint8 red, Uint8 gr return SDL_JoystickSetLED(joystick, red, green, blue); } -int -SDL_GameControllerSendEffect(SDL_GameController *gamecontroller, const void *data, int size) +int SDL_GameControllerSendEffect(SDL_GameController *gamecontroller, const void *data, int size) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); @@ -2812,8 +2765,7 @@ SDL_GameControllerSendEffect(SDL_GameController *gamecontroller, const void *dat return SDL_JoystickSendEffect(joystick, data, size); } -void -SDL_GameControllerClose(SDL_GameController *gamecontroller) +void SDL_GameControllerClose(SDL_GameController *gamecontroller) { SDL_GameController *gamecontrollerlist, *gamecontrollerlistprev; @@ -2856,12 +2808,10 @@ SDL_GameControllerClose(SDL_GameController *gamecontroller) SDL_UnlockJoysticks(); } - /* * Quit the controller subsystem */ -void -SDL_GameControllerQuit(void) +void SDL_GameControllerQuit(void) { SDL_LockJoysticks(); while (SDL_gamecontrollers) { @@ -2871,8 +2821,7 @@ SDL_GameControllerQuit(void) SDL_UnlockJoysticks(); } -void -SDL_GameControllerQuitMappings(void) +void SDL_GameControllerQuitMappings(void) { ControllerMapping_t *pControllerMap; @@ -2904,8 +2853,7 @@ SDL_GameControllerQuitMappings(void) /* * Event filter to transform joystick events into appropriate game controller ones */ -static int -SDL_PrivateGameControllerAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis, Sint16 value) +static int SDL_PrivateGameControllerAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis, Sint16 value) { int posted; @@ -2926,12 +2874,10 @@ SDL_PrivateGameControllerAxis(SDL_GameController *gamecontroller, SDL_GameContro return posted; } - /* * Event filter to transform joystick events into appropriate game controller ones */ -static int -SDL_PrivateGameControllerButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button, Uint8 state) +static int SDL_PrivateGameControllerButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button, Uint8 state) { int posted; #if !SDL_EVENTS_DISABLED @@ -2966,7 +2912,7 @@ SDL_PrivateGameControllerButton(SDL_GameController *gamecontroller, SDL_GameCont return 0; } } else { - if (!SDL_TICKS_PASSED(now, gamecontroller->guide_button_down+SDL_MINIMUM_GUIDE_BUTTON_DELAY_MS)) { + if (!SDL_TICKS_PASSED(now, gamecontroller->guide_button_down + SDL_MINIMUM_GUIDE_BUTTON_DELAY_MS)) { gamecontroller->joystick->delayed_guide_button = SDL_TRUE; return 0; } @@ -2990,16 +2936,22 @@ SDL_PrivateGameControllerButton(SDL_GameController *gamecontroller, SDL_GameCont /* * Turn off controller events */ -int -SDL_GameControllerEventState(int state) +int SDL_GameControllerEventState(int state) { #if SDL_EVENTS_DISABLED return SDL_IGNORE; #else const Uint32 event_list[] = { - SDL_CONTROLLERAXISMOTION, SDL_CONTROLLERBUTTONDOWN, SDL_CONTROLLERBUTTONUP, - SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEREMOVED, SDL_CONTROLLERDEVICEREMAPPED, - SDL_CONTROLLERTOUCHPADDOWN, SDL_CONTROLLERTOUCHPADMOTION, SDL_CONTROLLERTOUCHPADUP, SDL_CONTROLLERSENSORUPDATE, + SDL_CONTROLLERAXISMOTION, + SDL_CONTROLLERBUTTONDOWN, + SDL_CONTROLLERBUTTONUP, + SDL_CONTROLLERDEVICEADDED, + SDL_CONTROLLERDEVICEREMOVED, + SDL_CONTROLLERDEVICEREMAPPED, + SDL_CONTROLLERTOUCHPADDOWN, + SDL_CONTROLLERTOUCHPADMOTION, + SDL_CONTROLLERTOUCHPADUP, + SDL_CONTROLLERSENSORUPDATE, }; unsigned int i; @@ -3023,8 +2975,7 @@ SDL_GameControllerEventState(int state) #endif /* SDL_EVENTS_DISABLED */ } -void -SDL_GameControllerHandleDelayedGuideButton(SDL_Joystick *joystick) +void SDL_GameControllerHandleDelayedGuideButton(SDL_Joystick *joystick) { SDL_GameController *controllerlist = SDL_gamecontrollers; while (controllerlist) { @@ -3040,7 +2991,7 @@ const char * SDL_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button) { #if defined(SDL_JOYSTICK_MFI) - const char *IOS_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button); + const char *IOS_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button); CHECK_GAMECONTROLLER_MAGIC(gamecontroller, NULL); @@ -3054,7 +3005,7 @@ const char * SDL_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis) { #if defined(SDL_JOYSTICK_MFI) - const char *IOS_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis); + const char *IOS_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis); CHECK_GAMECONTROLLER_MAGIC(gamecontroller, NULL); diff --git a/src/joystick/SDL_gamecontrollerdb.h b/src/joystick/SDL_gamecontrollerdb.h index f74dcabd5..abd5f1b8d 100644 --- a/src/joystick/SDL_gamecontrollerdb.h +++ b/src/joystick/SDL_gamecontrollerdb.h @@ -20,7 +20,6 @@ */ #include "../SDL_internal.h" - /* Default mappings we support The easiest way to generate a new mapping is to start Steam in Big Picture @@ -29,8 +28,7 @@ Alternatively, you can use the app located in test/controllermap */ -static const char *s_ControllerMappings [] = -{ +static const char *s_ControllerMappings[] = { #if SDL_JOYSTICK_XINPUT "xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", #endif @@ -917,7 +915,7 @@ static const char *s_ControllerMappings [] = "050000005509000014720000df7f3f00,NVIDIA Controller v01.04,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,", "050000007e05000009200000ffff0f00,Nintendo Switch Pro Controller,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:b15,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:b16,rightx:a2,righty:a3,start:b6,x:b3,y:b2,sdk>=:29,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "050000007e05000009200000ffff0f00,Nintendo Switch Pro Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:b15,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:b16,rightx:a2,righty:a3,start:b6,x:b2,y:b3,sdk>=:29,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", - "050000007e05000009200000ffff0f00,Nintendo Switch Pro Controller,a:b0,b:b1,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:b10,rightx:a2,righty:a3,start:b16,x:b17,y:b2,sdk<=:28,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", /* Extremely slow in Bluetooth mode on Android */ + "050000007e05000009200000ffff0f00,Nintendo Switch Pro Controller,a:b0,b:b1,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:b10,rightx:a2,righty:a3,start:b16,x:b17,y:b2,sdk<=:28,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", /* Extremely slow in Bluetooth mode on Android */ "050000007e05000009200000ffff0f00,Nintendo Switch Pro Controller,a:b1,b:b0,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:b10,rightx:a2,righty:a3,start:b16,x:b2,y:b17,sdk<=:28,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", /* Extremely slow in Bluetooth mode on Android */ "050000004c05000068020000dfff3f00,PS3 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "030000004c050000cc09000000006800,PS4 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 0ac702164..9e1b43700 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -42,7 +42,7 @@ /* Needed for checking for input remapping programs */ #include "../core/windows/SDL_windows.h" -#undef UNICODE /* We want ASCII functions */ +#undef UNICODE /* We want ASCII functions */ #include #endif @@ -84,7 +84,7 @@ static SDL_JoystickDriver *SDL_joystick_drivers[] = { #ifdef SDL_JOYSTICK_HAIKU &SDL_HAIKU_JoystickDriver, #endif -#ifdef SDL_JOYSTICK_USBHID /* !!! FIXME: "USBHID" is a generic name, and doubly-confusing with HIDAPI next to it. This is the *BSD interface, rename this. */ +#ifdef SDL_JOYSTICK_USBHID /* !!! FIXME: "USBHID" is a generic name, and doubly-confusing with HIDAPI next to it. This is the *BSD interface, rename this. */ &SDL_BSD_JoystickDriver, #endif #ifdef SDL_JOYSTICK_OS2 @@ -106,7 +106,7 @@ static SDL_JoystickDriver *SDL_joystick_drivers[] = { &SDL_N3DS_JoystickDriver #endif #if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED) - &SDL_DUMMY_JoystickDriver + &SDL_DUMMY_JoystickDriver #endif }; static SDL_bool SDL_joysticks_initialized; @@ -120,11 +120,10 @@ static SDL_JoystickID *SDL_joystick_players = NULL; static SDL_bool SDL_joystick_allows_background_events = SDL_FALSE; static char joystick_magic; - -#define CHECK_JOYSTICK_MAGIC(joystick, retval) \ +#define CHECK_JOYSTICK_MAGIC(joystick, retval) \ if (!joystick || joystick->magic != &joystick_magic) { \ - SDL_InvalidParamError("joystick"); \ - return retval; \ + SDL_InvalidParamError("joystick"); \ + return retval; \ } SDL_bool @@ -139,8 +138,7 @@ SDL_JoysticksQuitting(void) return SDL_joysticks_quitting; } -void -SDL_LockJoysticks(void) +void SDL_LockJoysticks(void) { if (SDL_joystick_lock) { SDL_LockMutex(SDL_joystick_lock); @@ -149,8 +147,7 @@ SDL_LockJoysticks(void) ++SDL_joysticks_locked; } -void -SDL_UnlockJoysticks(void) +void SDL_UnlockJoysticks(void) { --SDL_joysticks_locked; @@ -174,8 +171,7 @@ SDL_JoysticksLocked(void) return (SDL_joysticks_locked > 0) ? SDL_TRUE : SDL_FALSE; } -void -SDL_AssertJoysticksLocked(void) +void SDL_AssertJoysticksLocked(void) { SDL_assert(SDL_JoysticksLocked()); } @@ -184,8 +180,7 @@ SDL_AssertJoysticksLocked(void) * Get the driver and device index for an API device index * This should be called while the joystick lock is held, to prevent another thread from updating the list */ -static SDL_bool -SDL_GetDriverAndJoystickIndex(int device_index, SDL_JoystickDriver **driver, int *driver_index) +static SDL_bool SDL_GetDriverAndJoystickIndex(int device_index, SDL_JoystickDriver **driver, int *driver_index) { int i, num_joysticks, total_joysticks = 0; @@ -208,8 +203,7 @@ SDL_GetDriverAndJoystickIndex(int device_index, SDL_JoystickDriver **driver, int return SDL_FALSE; } -static int -SDL_FindFreePlayerIndex() +static int SDL_FindFreePlayerIndex() { int player_index; @@ -223,8 +217,7 @@ SDL_FindFreePlayerIndex() return player_index; } -static int -SDL_GetPlayerIndexForJoystickID(SDL_JoystickID instance_id) +static int SDL_GetPlayerIndexForJoystickID(SDL_JoystickID instance_id) { int player_index; @@ -241,8 +234,7 @@ SDL_GetPlayerIndexForJoystickID(SDL_JoystickID instance_id) return player_index; } -static SDL_JoystickID -SDL_GetJoystickIDForPlayerIndex(int player_index) +static SDL_JoystickID SDL_GetJoystickIDForPlayerIndex(int player_index) { SDL_AssertJoysticksLocked(); @@ -252,8 +244,7 @@ SDL_GetJoystickIDForPlayerIndex(int player_index) return SDL_joystick_players[player_index]; } -static SDL_bool -SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID instance_id) +static SDL_bool SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID instance_id) { SDL_JoystickID existing_instance = SDL_GetJoystickIDForPlayerIndex(player_index); SDL_JoystickDriver *driver; @@ -263,7 +254,7 @@ SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID instance_id) SDL_AssertJoysticksLocked(); if (player_index >= SDL_joystick_player_count) { - SDL_JoystickID *new_players = (SDL_JoystickID *)SDL_realloc(SDL_joystick_players, (player_index + 1)*sizeof(*SDL_joystick_players)); + SDL_JoystickID *new_players = (SDL_JoystickID *)SDL_realloc(SDL_joystick_players, (player_index + 1) * sizeof(*SDL_joystick_players)); if (new_players == NULL) { SDL_OutOfMemory(); return SDL_FALSE; @@ -300,8 +291,7 @@ SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID instance_id) return SDL_TRUE; } -static void SDLCALL -SDL_JoystickAllowBackgroundEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_JoystickAllowBackgroundEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { if (SDL_GetStringBoolean(hint, SDL_FALSE)) { SDL_joystick_allows_background_events = SDL_TRUE; @@ -310,8 +300,7 @@ SDL_JoystickAllowBackgroundEventsChanged(void *userdata, const char *name, const } } -int -SDL_JoystickInit(void) +int SDL_JoystickInit(void) { int i, status; @@ -354,8 +343,7 @@ SDL_JoystickInit(void) /* * Count the number of joysticks attached to the system */ -int -SDL_NumJoysticks(void) +int SDL_NumJoysticks(void) { int i, total_joysticks = 0; SDL_LockJoysticks(); @@ -419,8 +407,7 @@ SDL_JoystickPathForIndex(int device_index) /* * Get the player index of a joystick, or -1 if it's not available */ -int -SDL_JoystickGetDevicePlayerIndex(int device_index) +int SDL_JoystickGetDevicePlayerIndex(int device_index) { int player_index; @@ -436,15 +423,14 @@ SDL_JoystickGetDevicePlayerIndex(int device_index) * This isn't generally needed unless the joystick never generates an initial axis value near zero, * e.g. it's emulating axes with digital buttons */ -static SDL_bool -SDL_JoystickAxesCenteredAtZero(SDL_Joystick *joystick) +static SDL_bool SDL_JoystickAxesCenteredAtZero(SDL_Joystick *joystick) { #ifdef __WINRT__ return SDL_TRUE; #else static Uint32 zero_centered_joysticks[] = { - MAKE_VIDPID(0x0e8f, 0x3013), /* HuiJia SNES USB adapter */ - MAKE_VIDPID(0x05a0, 0x3232), /* 8Bitdo Zero Gamepad */ + MAKE_VIDPID(0x0e8f, 0x3013), /* HuiJia SNES USB adapter */ + MAKE_VIDPID(0x05a0, 0x3232), /* 8Bitdo Zero Gamepad */ }; int i; @@ -499,16 +485,16 @@ SDL_JoystickOpen(int device_index) instance_id = driver->GetDeviceInstanceID(device_index); while (joysticklist) { if (instance_id == joysticklist->instance_id) { - joystick = joysticklist; - ++joystick->ref_count; - SDL_UnlockJoysticks(); - return joystick; + joystick = joysticklist; + ++joystick->ref_count; + SDL_UnlockJoysticks(); + return joystick; } joysticklist = joysticklist->next; } /* Create and initialize the joystick */ - joystick = (SDL_Joystick *) SDL_calloc(sizeof(*joystick), 1); + joystick = (SDL_Joystick *)SDL_calloc(sizeof(*joystick), 1); if (joystick == NULL) { SDL_OutOfMemory(); SDL_UnlockJoysticks(); @@ -544,21 +530,18 @@ SDL_JoystickOpen(int device_index) joystick->guid = driver->GetDeviceGUID(device_index); if (joystick->naxes > 0) { - joystick->axes = (SDL_JoystickAxisInfo *) SDL_calloc(joystick->naxes, sizeof(SDL_JoystickAxisInfo)); + joystick->axes = (SDL_JoystickAxisInfo *)SDL_calloc(joystick->naxes, sizeof(SDL_JoystickAxisInfo)); } if (joystick->nhats > 0) { - joystick->hats = (Uint8 *) SDL_calloc(joystick->nhats, sizeof(Uint8)); + joystick->hats = (Uint8 *)SDL_calloc(joystick->nhats, sizeof(Uint8)); } if (joystick->nballs > 0) { - joystick->balls = (struct balldelta *) SDL_calloc(joystick->nballs, sizeof(*joystick->balls)); + joystick->balls = (struct balldelta *)SDL_calloc(joystick->nballs, sizeof(*joystick->balls)); } if (joystick->nbuttons > 0) { - joystick->buttons = (Uint8 *) SDL_calloc(joystick->nbuttons, sizeof(Uint8)); + joystick->buttons = (Uint8 *)SDL_calloc(joystick->nbuttons, sizeof(Uint8)); } - if (((joystick->naxes > 0) && !joystick->axes) - || ((joystick->nhats > 0) && !joystick->hats) - || ((joystick->nballs > 0) && !joystick->balls) - || ((joystick->nbuttons > 0) && !joystick->buttons)) { + if (((joystick->naxes > 0) && !joystick->axes) || ((joystick->nhats > 0) && !joystick->hats) || ((joystick->nballs > 0) && !joystick->balls) || ((joystick->nbuttons > 0) && !joystick->buttons)) { SDL_OutOfMemory(); SDL_JoystickClose(joystick); SDL_UnlockJoysticks(); @@ -594,9 +577,8 @@ SDL_JoystickOpen(int device_index) return joystick; } -int -SDL_JoystickAttachVirtual(SDL_JoystickType type, - int naxes, int nbuttons, int nhats) +int SDL_JoystickAttachVirtual(SDL_JoystickType type, + int naxes, int nbuttons, int nhats) { SDL_VirtualJoystickDesc desc; @@ -609,8 +591,7 @@ SDL_JoystickAttachVirtual(SDL_JoystickType type, return SDL_JoystickAttachVirtualEx(&desc); } -int -SDL_JoystickAttachVirtualEx(const SDL_VirtualJoystickDesc *desc) +int SDL_JoystickAttachVirtualEx(const SDL_VirtualJoystickDesc *desc) { #if SDL_JOYSTICK_VIRTUAL int result; @@ -624,8 +605,7 @@ SDL_JoystickAttachVirtualEx(const SDL_VirtualJoystickDesc *desc) #endif } -int -SDL_JoystickDetachVirtual(int device_index) +int SDL_JoystickDetachVirtual(int device_index) { #if SDL_JOYSTICK_VIRTUAL SDL_JoystickDriver *driver; @@ -668,8 +648,7 @@ SDL_JoystickIsVirtual(int device_index) #endif } -int -SDL_JoystickSetVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value) +int SDL_JoystickSetVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value) { CHECK_JOYSTICK_MAGIC(joystick, -1); @@ -680,8 +659,7 @@ SDL_JoystickSetVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value) #endif } -int -SDL_JoystickSetVirtualButton(SDL_Joystick *joystick, int button, Uint8 value) +int SDL_JoystickSetVirtualButton(SDL_Joystick *joystick, int button, Uint8 value) { CHECK_JOYSTICK_MAGIC(joystick, -1); @@ -692,8 +670,7 @@ SDL_JoystickSetVirtualButton(SDL_Joystick *joystick, int button, Uint8 value) #endif } -int -SDL_JoystickSetVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value) +int SDL_JoystickSetVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value) { CHECK_JOYSTICK_MAGIC(joystick, -1); @@ -715,7 +692,7 @@ SDL_PrivateJoystickValid(SDL_Joystick *joystick) } SDL_bool -SDL_PrivateJoystickGetAutoGamepadMapping(int device_index, SDL_GamepadMapping * out) +SDL_PrivateJoystickGetAutoGamepadMapping(int device_index, SDL_GamepadMapping *out) { SDL_JoystickDriver *driver; SDL_bool is_ok = SDL_FALSE; @@ -732,8 +709,7 @@ SDL_PrivateJoystickGetAutoGamepadMapping(int device_index, SDL_GamepadMapping * /* * Get the number of multi-dimensional axis controls on a joystick */ -int -SDL_JoystickNumAxes(SDL_Joystick *joystick) +int SDL_JoystickNumAxes(SDL_Joystick *joystick) { CHECK_JOYSTICK_MAGIC(joystick, -1); @@ -743,8 +719,7 @@ SDL_JoystickNumAxes(SDL_Joystick *joystick) /* * Get the number of hats on a joystick */ -int -SDL_JoystickNumHats(SDL_Joystick *joystick) +int SDL_JoystickNumHats(SDL_Joystick *joystick) { CHECK_JOYSTICK_MAGIC(joystick, -1); @@ -754,8 +729,7 @@ SDL_JoystickNumHats(SDL_Joystick *joystick) /* * Get the number of trackballs on a joystick */ -int -SDL_JoystickNumBalls(SDL_Joystick *joystick) +int SDL_JoystickNumBalls(SDL_Joystick *joystick) { CHECK_JOYSTICK_MAGIC(joystick, -1); @@ -765,8 +739,7 @@ SDL_JoystickNumBalls(SDL_Joystick *joystick) /* * Get the number of buttons on a joystick */ -int -SDL_JoystickNumButtons(SDL_Joystick *joystick) +int SDL_JoystickNumButtons(SDL_Joystick *joystick) { CHECK_JOYSTICK_MAGIC(joystick, -1); @@ -813,8 +786,7 @@ SDL_JoystickGetAxisInitialState(SDL_Joystick *joystick, int axis, Sint16 *state) /* * Get the current state of a hat on a joystick */ -Uint8 -SDL_JoystickGetHat(SDL_Joystick *joystick, int hat) +Uint8 SDL_JoystickGetHat(SDL_Joystick *joystick, int hat) { Uint8 state; @@ -832,8 +804,7 @@ SDL_JoystickGetHat(SDL_Joystick *joystick, int hat) /* * Get the ball axis change since the last poll */ -int -SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy) +int SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy) { int retval; @@ -858,8 +829,7 @@ SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy) /* * Get the current state of a button on a joystick */ -Uint8 -SDL_JoystickGetButton(SDL_Joystick *joystick, int button) +Uint8 SDL_JoystickGetButton(SDL_Joystick *joystick, int button) { Uint8 state; @@ -964,8 +934,7 @@ SDL_JoystickPath(SDL_Joystick *joystick) /** * Get the player index of an opened joystick, or -1 if it's not available */ -int -SDL_JoystickGetPlayerIndex(SDL_Joystick *joystick) +int SDL_JoystickGetPlayerIndex(SDL_Joystick *joystick) { int player_index; @@ -981,8 +950,7 @@ SDL_JoystickGetPlayerIndex(SDL_Joystick *joystick) /** * Set the player index of an opened joystick */ -void -SDL_JoystickSetPlayerIndex(SDL_Joystick *joystick, int player_index) +void SDL_JoystickSetPlayerIndex(SDL_Joystick *joystick, int player_index) { CHECK_JOYSTICK_MAGIC(joystick, ); @@ -991,8 +959,7 @@ SDL_JoystickSetPlayerIndex(SDL_Joystick *joystick, int player_index) SDL_UnlockJoysticks(); } -int -SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms) +int SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms) { int result; @@ -1030,8 +997,7 @@ SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 h return result; } -int -SDL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms) +int SDL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms) { int result; @@ -1111,8 +1077,7 @@ SDL_JoystickHasRumbleTriggers(SDL_Joystick *joystick) return result; } -int -SDL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +int SDL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { int result; SDL_bool isfreshvalue; @@ -1143,8 +1108,7 @@ SDL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) return result; } -int -SDL_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) +int SDL_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) { int result; @@ -1162,8 +1126,7 @@ SDL_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) /* * Close a joystick previously opened with SDL_JoystickOpen() */ -void -SDL_JoystickClose(SDL_Joystick *joystick) +void SDL_JoystickClose(SDL_Joystick *joystick) { SDL_Joystick *joysticklist; SDL_Joystick *joysticklistprev; @@ -1226,8 +1189,7 @@ SDL_JoystickClose(SDL_Joystick *joystick) SDL_UnlockJoysticks(); } -void -SDL_JoystickQuit(void) +void SDL_JoystickQuit(void) { int i; @@ -1243,7 +1205,7 @@ SDL_JoystickQuit(void) /* Quit drivers in reverse order to avoid breaking dependencies between drivers */ for (i = SDL_arraysize(SDL_joystick_drivers) - 1; i >= 0; --i) { - SDL_joystick_drivers[i]->Quit(); + SDL_joystick_drivers[i]->Quit(); } if (SDL_joystick_players) { @@ -1267,9 +1229,7 @@ SDL_JoystickQuit(void) SDL_UnlockJoysticks(); } - -static SDL_bool -SDL_PrivateJoystickShouldIgnoreEvent() +static SDL_bool SDL_PrivateJoystickShouldIgnoreEvent() { if (SDL_joystick_allows_background_events) { return SDL_FALSE; @@ -1432,8 +1392,7 @@ static void UpdateEventsForDeviceRemoval(int device_index, Uint32 type) SDL_small_free(events, isstack); } -void -SDL_PrivateJoystickForceRecentering(SDL_Joystick *joystick) +void SDL_PrivateJoystickForceRecentering(SDL_Joystick *joystick) { int i, j; @@ -1505,8 +1464,7 @@ void SDL_PrivateJoystickRemoved(SDL_JoystickID device_instance) } } -int -SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value) +int SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value) { int posted; SDL_JoystickAxisInfo *info; @@ -1534,7 +1492,7 @@ SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value) } if (!info->sent_initial_value) { /* Make sure we don't send motion until there's real activity on this axis */ - const int MAX_ALLOWED_JITTER = SDL_JOYSTICK_AXIS_MAX / 80; /* ShanWan PS3 controller needed 96 */ + const int MAX_ALLOWED_JITTER = SDL_JOYSTICK_AXIS_MAX / 80; /* ShanWan PS3 controller needed 96 */ if (SDL_abs(value - info->value) <= MAX_ALLOWED_JITTER && !SDL_IsJoystickVirtual(joystick->guid)) { return 0; @@ -1574,8 +1532,7 @@ SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value) return posted; } -int -SDL_PrivateJoystickHat(SDL_Joystick *joystick, Uint8 hat, Uint8 value) +int SDL_PrivateJoystickHat(SDL_Joystick *joystick, Uint8 hat, Uint8 value) { int posted; @@ -1618,9 +1575,8 @@ SDL_PrivateJoystickHat(SDL_Joystick *joystick, Uint8 hat, Uint8 value) return posted; } -int -SDL_PrivateJoystickBall(SDL_Joystick *joystick, Uint8 ball, - Sint16 xrel, Sint16 yrel) +int SDL_PrivateJoystickBall(SDL_Joystick *joystick, Uint8 ball, + Sint16 xrel, Sint16 yrel) { int posted; @@ -1658,8 +1614,7 @@ SDL_PrivateJoystickBall(SDL_Joystick *joystick, Uint8 ball, return posted; } -int -SDL_PrivateJoystickButton(SDL_Joystick *joystick, Uint8 button, Uint8 state) +int SDL_PrivateJoystickButton(SDL_Joystick *joystick, Uint8 button, Uint8 state) { int posted; #if !SDL_EVENTS_DISABLED @@ -1714,8 +1669,7 @@ SDL_PrivateJoystickButton(SDL_Joystick *joystick, Uint8 button, Uint8 state) return posted; } -void -SDL_JoystickUpdate(void) +void SDL_JoystickUpdate(void) { int i; Uint32 now; @@ -1773,8 +1727,7 @@ SDL_JoystickUpdate(void) SDL_UnlockJoysticks(); } -int -SDL_JoystickEventState(int state) +int SDL_JoystickEventState(int state) { #if SDL_EVENTS_DISABLED return SDL_DISABLE; @@ -1869,12 +1822,11 @@ void SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *prod } } -static int -PrefixMatch(const char *a, const char *b) +static int PrefixMatch(const char *a, const char *b) { int matchlen = 0; while (*a && *b) { - if (SDL_tolower((unsigned char) *a++) == SDL_tolower((unsigned char) *b++)) { + if (SDL_tolower((unsigned char)*a++) == SDL_tolower((unsigned char)*b++)) { ++matchlen; } else { break; @@ -1886,7 +1838,8 @@ PrefixMatch(const char *a, const char *b) char * SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_name, const char *product_name) { - static struct { + static struct + { const char *prefix; const char *replacement; } replacements[] = { @@ -1976,9 +1929,9 @@ SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_name, c name[len] = '\0'; /* Compress duplicate spaces */ - for (i = 0; i < (len - 1); ) { - if (name[i] == ' ' && name[i+1] == ' ') { - SDL_memmove(&name[i], &name[i+1], (len - i)); + for (i = 0; i < (len - 1);) { + if (name[i] == ' ' && name[i + 1] == ' ') { + SDL_memmove(&name[i], &name[i + 1], (len - i)); --len; } else { ++i; @@ -1992,7 +1945,7 @@ SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_name, c size_t replacementlen = SDL_strlen(replacements[i].replacement); if (replacementlen <= prefixlen) { SDL_memcpy(name, replacements[i].replacement, replacementlen); - SDL_memmove(name+replacementlen, name+prefixlen, (len-prefixlen)+1); + SDL_memmove(name + replacementlen, name + prefixlen, (len - prefixlen) + 1); len -= (prefixlen - replacementlen); } else { /* FIXME: Need to handle the expand case by reallocating the string */ @@ -2055,7 +2008,7 @@ SDL_CreateJoystickGUID(Uint16 bus, Uint16 vendor, Uint16 product, Uint16 version guid.data[14] = driver_signature; guid.data[15] = driver_data; } - SDL_strlcpy((char*)guid16, name, available_space); + SDL_strlcpy((char *)guid16, name, available_space); } return guid; } @@ -2087,8 +2040,7 @@ void SDL_SetJoystickGUIDVersion(SDL_JoystickGUID *guid, Uint16 version) guid16[6] = SDL_SwapLE16(version); } -void -SDL_SetJoystickGUIDCRC(SDL_JoystickGUID *guid, Uint16 crc) +void SDL_SetJoystickGUIDCRC(SDL_JoystickGUID *guid, Uint16 crc) { Uint16 *guid16 = (Uint16 *)guid->data; @@ -2392,28 +2344,28 @@ SDL_IsJoystickVirtual(SDL_JoystickGUID guid) static SDL_bool SDL_IsJoystickProductWheel(Uint32 vidpid) { static Uint32 wheel_joysticks[] = { - MAKE_VIDPID(0x046d, 0xc294), /* Logitech generic wheel */ - MAKE_VIDPID(0x046d, 0xc295), /* Logitech Momo Force */ - MAKE_VIDPID(0x046d, 0xc298), /* Logitech Driving Force Pro */ - MAKE_VIDPID(0x046d, 0xc299), /* Logitech G25 */ - MAKE_VIDPID(0x046d, 0xc29a), /* Logitech Driving Force GT */ - MAKE_VIDPID(0x046d, 0xc29b), /* Logitech G27 */ - MAKE_VIDPID(0x046d, 0xc24f), /* Logitech G29 (PS3) */ - MAKE_VIDPID(0x046d, 0xc260), /* Logitech G29 (PS4) */ - MAKE_VIDPID(0x046d, 0xc261), /* Logitech G920 (initial mode) */ - MAKE_VIDPID(0x046d, 0xc262), /* Logitech G920 (active mode) */ - MAKE_VIDPID(0x046d, 0xc26e), /* Logitech G923 */ - MAKE_VIDPID(0x046d, 0xca03), /* Logitech Momo Racing */ - MAKE_VIDPID(0x044f, 0xb65d), /* Thrustmaster Wheel FFB */ - MAKE_VIDPID(0x044f, 0xb66d), /* Thrustmaster Wheel FFB */ - MAKE_VIDPID(0x044f, 0xb677), /* Thrustmaster T150 */ - MAKE_VIDPID(0x044f, 0xb696), /* Thrustmaster T248 */ - MAKE_VIDPID(0x044f, 0xb66e), /* Thrustmaster T300RS (normal mode) */ - MAKE_VIDPID(0x044f, 0xb66f), /* Thrustmaster T300RS (advanced mode) */ - MAKE_VIDPID(0x044f, 0xb66d), /* Thrustmaster T300RS (PS4 mode) */ - MAKE_VIDPID(0x044f, 0xb65e), /* Thrustmaster T500RS */ - MAKE_VIDPID(0x044f, 0xb664), /* Thrustmaster TX (initial mode) */ - MAKE_VIDPID(0x044f, 0xb669), /* Thrustmaster TX (active mode) */ + MAKE_VIDPID(0x046d, 0xc294), /* Logitech generic wheel */ + MAKE_VIDPID(0x046d, 0xc295), /* Logitech Momo Force */ + MAKE_VIDPID(0x046d, 0xc298), /* Logitech Driving Force Pro */ + MAKE_VIDPID(0x046d, 0xc299), /* Logitech G25 */ + MAKE_VIDPID(0x046d, 0xc29a), /* Logitech Driving Force GT */ + MAKE_VIDPID(0x046d, 0xc29b), /* Logitech G27 */ + MAKE_VIDPID(0x046d, 0xc24f), /* Logitech G29 (PS3) */ + MAKE_VIDPID(0x046d, 0xc260), /* Logitech G29 (PS4) */ + MAKE_VIDPID(0x046d, 0xc261), /* Logitech G920 (initial mode) */ + MAKE_VIDPID(0x046d, 0xc262), /* Logitech G920 (active mode) */ + MAKE_VIDPID(0x046d, 0xc26e), /* Logitech G923 */ + MAKE_VIDPID(0x046d, 0xca03), /* Logitech Momo Racing */ + MAKE_VIDPID(0x044f, 0xb65d), /* Thrustmaster Wheel FFB */ + MAKE_VIDPID(0x044f, 0xb66d), /* Thrustmaster Wheel FFB */ + MAKE_VIDPID(0x044f, 0xb677), /* Thrustmaster T150 */ + MAKE_VIDPID(0x044f, 0xb696), /* Thrustmaster T248 */ + MAKE_VIDPID(0x044f, 0xb66e), /* Thrustmaster T300RS (normal mode) */ + MAKE_VIDPID(0x044f, 0xb66f), /* Thrustmaster T300RS (advanced mode) */ + MAKE_VIDPID(0x044f, 0xb66d), /* Thrustmaster T300RS (PS4 mode) */ + MAKE_VIDPID(0x044f, 0xb65e), /* Thrustmaster T500RS */ + MAKE_VIDPID(0x044f, 0xb664), /* Thrustmaster TX (initial mode) */ + MAKE_VIDPID(0x044f, 0xb669), /* Thrustmaster TX (active mode) */ }; int i; @@ -2428,37 +2380,37 @@ static SDL_bool SDL_IsJoystickProductWheel(Uint32 vidpid) static SDL_bool SDL_IsJoystickProductArcadeStick(Uint32 vidpid) { static Uint32 arcadestick_joysticks[] = { - MAKE_VIDPID(0x0079, 0x181a), /* Venom Arcade Stick */ - MAKE_VIDPID(0x0079, 0x181b), /* Venom Arcade Stick */ - MAKE_VIDPID(0x0c12, 0x0ef6), /* Hitbox Arcade Stick */ - MAKE_VIDPID(0x0e6f, 0x0109), /* PDP Versus Fighting Pad */ - MAKE_VIDPID(0x0f0d, 0x0016), /* Hori Real Arcade Pro.EX */ - MAKE_VIDPID(0x0f0d, 0x001b), /* Hori Real Arcade Pro VX */ - MAKE_VIDPID(0x0f0d, 0x0063), /* Hori Real Arcade Pro Hayabusa (USA) Xbox One */ - MAKE_VIDPID(0x0f0d, 0x006a), /* Real Arcade Pro 4 */ - MAKE_VIDPID(0x0f0d, 0x0078), /* Hori Real Arcade Pro V Kai Xbox One */ - MAKE_VIDPID(0x0f0d, 0x008a), /* HORI Real Arcade Pro 4 */ - MAKE_VIDPID(0x0f0d, 0x008c), /* Hori Real Arcade Pro 4 */ - MAKE_VIDPID(0x0f0d, 0x00aa), /* HORI Real Arcade Pro V Hayabusa in Switch Mode */ - MAKE_VIDPID(0x0f0d, 0x00ed), /* Hori Fighting Stick mini 4 kai */ - MAKE_VIDPID(0x0f0d, 0x011c), /* Hori Fighting Stick α in PS4 Mode */ - MAKE_VIDPID(0x0f0d, 0x011e), /* Hori Fighting Stick α in PC Mode */ - MAKE_VIDPID(0x0f0d, 0x0184), /* Hori Fighting Stick α in PS5 Mode */ - MAKE_VIDPID(0x1532, 0x0a00), /* Razer Atrox Arcade Stick */ - MAKE_VIDPID(0x1bad, 0xf03d), /* Street Fighter IV Arcade Stick TE - Chun Li */ - MAKE_VIDPID(0x1bad, 0xf502), /* Hori Real Arcade Pro.VX SA */ - MAKE_VIDPID(0x1bad, 0xf504), /* Hori Real Arcade Pro. EX */ - MAKE_VIDPID(0x1bad, 0xf506), /* Hori Real Arcade Pro.EX Premium VLX */ - MAKE_VIDPID(0x20d6, 0xa715), /* PowerA Nintendo Switch Fusion Arcade Stick */ - MAKE_VIDPID(0x24c6, 0x5000), /* Razer Atrox Arcade Stick */ - MAKE_VIDPID(0x24c6, 0x5501), /* Hori Real Arcade Pro VX-SA */ - MAKE_VIDPID(0x24c6, 0x550e), /* Hori Real Arcade Pro V Kai 360 */ - MAKE_VIDPID(0x2c22, 0x2300), /* Qanba Obsidian Arcade Joystick in PS4 Mode */ - MAKE_VIDPID(0x2c22, 0x2302), /* Qanba Obsidian Arcade Joystick in PS3 Mode */ - MAKE_VIDPID(0x2c22, 0x2303), /* Qanba Obsidian Arcade Joystick in PC Mode */ - MAKE_VIDPID(0x2c22, 0x2500), /* Qanba Dragon Arcade Joystick in PS4 Mode */ - MAKE_VIDPID(0x2c22, 0x2502), /* Qanba Dragon Arcade Joystick in PS3 Mode */ - MAKE_VIDPID(0x2c22, 0x2503), /* Qanba Dragon Arcade Joystick in PC Mode */ + MAKE_VIDPID(0x0079, 0x181a), /* Venom Arcade Stick */ + MAKE_VIDPID(0x0079, 0x181b), /* Venom Arcade Stick */ + MAKE_VIDPID(0x0c12, 0x0ef6), /* Hitbox Arcade Stick */ + MAKE_VIDPID(0x0e6f, 0x0109), /* PDP Versus Fighting Pad */ + MAKE_VIDPID(0x0f0d, 0x0016), /* Hori Real Arcade Pro.EX */ + MAKE_VIDPID(0x0f0d, 0x001b), /* Hori Real Arcade Pro VX */ + MAKE_VIDPID(0x0f0d, 0x0063), /* Hori Real Arcade Pro Hayabusa (USA) Xbox One */ + MAKE_VIDPID(0x0f0d, 0x006a), /* Real Arcade Pro 4 */ + MAKE_VIDPID(0x0f0d, 0x0078), /* Hori Real Arcade Pro V Kai Xbox One */ + MAKE_VIDPID(0x0f0d, 0x008a), /* HORI Real Arcade Pro 4 */ + MAKE_VIDPID(0x0f0d, 0x008c), /* Hori Real Arcade Pro 4 */ + MAKE_VIDPID(0x0f0d, 0x00aa), /* HORI Real Arcade Pro V Hayabusa in Switch Mode */ + MAKE_VIDPID(0x0f0d, 0x00ed), /* Hori Fighting Stick mini 4 kai */ + MAKE_VIDPID(0x0f0d, 0x011c), /* Hori Fighting Stick α in PS4 Mode */ + MAKE_VIDPID(0x0f0d, 0x011e), /* Hori Fighting Stick α in PC Mode */ + MAKE_VIDPID(0x0f0d, 0x0184), /* Hori Fighting Stick α in PS5 Mode */ + MAKE_VIDPID(0x1532, 0x0a00), /* Razer Atrox Arcade Stick */ + MAKE_VIDPID(0x1bad, 0xf03d), /* Street Fighter IV Arcade Stick TE - Chun Li */ + MAKE_VIDPID(0x1bad, 0xf502), /* Hori Real Arcade Pro.VX SA */ + MAKE_VIDPID(0x1bad, 0xf504), /* Hori Real Arcade Pro. EX */ + MAKE_VIDPID(0x1bad, 0xf506), /* Hori Real Arcade Pro.EX Premium VLX */ + MAKE_VIDPID(0x20d6, 0xa715), /* PowerA Nintendo Switch Fusion Arcade Stick */ + MAKE_VIDPID(0x24c6, 0x5000), /* Razer Atrox Arcade Stick */ + MAKE_VIDPID(0x24c6, 0x5501), /* Hori Real Arcade Pro VX-SA */ + MAKE_VIDPID(0x24c6, 0x550e), /* Hori Real Arcade Pro V Kai 360 */ + MAKE_VIDPID(0x2c22, 0x2300), /* Qanba Obsidian Arcade Joystick in PS4 Mode */ + MAKE_VIDPID(0x2c22, 0x2302), /* Qanba Obsidian Arcade Joystick in PS3 Mode */ + MAKE_VIDPID(0x2c22, 0x2303), /* Qanba Obsidian Arcade Joystick in PC Mode */ + MAKE_VIDPID(0x2c22, 0x2500), /* Qanba Dragon Arcade Joystick in PS4 Mode */ + MAKE_VIDPID(0x2c22, 0x2502), /* Qanba Dragon Arcade Joystick in PS3 Mode */ + MAKE_VIDPID(0x2c22, 0x2503), /* Qanba Dragon Arcade Joystick in PC Mode */ }; int i; @@ -2473,12 +2425,12 @@ static SDL_bool SDL_IsJoystickProductArcadeStick(Uint32 vidpid) static SDL_bool SDL_IsJoystickProductFlightStick(Uint32 vidpid) { static Uint32 flightstick_joysticks[] = { - MAKE_VIDPID(0x044f, 0x0402), /* HOTAS Warthog Joystick */ - MAKE_VIDPID(0x0738, 0x2221), /* Saitek Pro Flight X-56 Rhino Stick */ - MAKE_VIDPID(0x044f, 0xb10a), /* ThrustMaster, Inc. T.16000M Joystick */ - MAKE_VIDPID(0x046d, 0xc215), /* Logitech Extreme 3D */ - MAKE_VIDPID(0x231d, 0x0126), /* Gunfighter Mk.III ‘Space Combat Edition’ (right) */ - MAKE_VIDPID(0x231d, 0x0127), /* Gunfighter Mk.III ‘Space Combat Edition’ (left) */ + MAKE_VIDPID(0x044f, 0x0402), /* HOTAS Warthog Joystick */ + MAKE_VIDPID(0x0738, 0x2221), /* Saitek Pro Flight X-56 Rhino Stick */ + MAKE_VIDPID(0x044f, 0xb10a), /* ThrustMaster, Inc. T.16000M Joystick */ + MAKE_VIDPID(0x046d, 0xc215), /* Logitech Extreme 3D */ + MAKE_VIDPID(0x231d, 0x0126), /* Gunfighter Mk.III ‘Space Combat Edition’ (right) */ + MAKE_VIDPID(0x231d, 0x0127), /* Gunfighter Mk.III ‘Space Combat Edition’ (left) */ }; int i; @@ -2493,8 +2445,8 @@ static SDL_bool SDL_IsJoystickProductFlightStick(Uint32 vidpid) static SDL_bool SDL_IsJoystickProductThrottle(Uint32 vidpid) { static Uint32 throttle_joysticks[] = { - MAKE_VIDPID(0x044f, 0x0404), /* HOTAS Warthog Throttle */ - MAKE_VIDPID(0x0738, 0xa221), /* Saitek Pro Flight X-56 Rhino Throttle */ + MAKE_VIDPID(0x044f, 0x0404), /* HOTAS Warthog Throttle */ + MAKE_VIDPID(0x0738, 0xa221), /* Saitek Pro Flight X-56 Rhino Throttle */ }; int i; @@ -2515,23 +2467,23 @@ static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_JoystickGUID guid) if (SDL_IsJoystickXInput(guid)) { /* XInput GUID, get the type based on the XInput device subtype */ switch (guid.data[15]) { - case 0x01: /* XINPUT_DEVSUBTYPE_GAMEPAD */ + case 0x01: /* XINPUT_DEVSUBTYPE_GAMEPAD */ return SDL_JOYSTICK_TYPE_GAMECONTROLLER; - case 0x02: /* XINPUT_DEVSUBTYPE_WHEEL */ + case 0x02: /* XINPUT_DEVSUBTYPE_WHEEL */ return SDL_JOYSTICK_TYPE_WHEEL; - case 0x03: /* XINPUT_DEVSUBTYPE_ARCADE_STICK */ + case 0x03: /* XINPUT_DEVSUBTYPE_ARCADE_STICK */ return SDL_JOYSTICK_TYPE_ARCADE_STICK; - case 0x04: /* XINPUT_DEVSUBTYPE_FLIGHT_STICK */ + case 0x04: /* XINPUT_DEVSUBTYPE_FLIGHT_STICK */ return SDL_JOYSTICK_TYPE_FLIGHT_STICK; - case 0x05: /* XINPUT_DEVSUBTYPE_DANCE_PAD */ + case 0x05: /* XINPUT_DEVSUBTYPE_DANCE_PAD */ return SDL_JOYSTICK_TYPE_DANCE_PAD; - case 0x06: /* XINPUT_DEVSUBTYPE_GUITAR */ - case 0x07: /* XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE */ - case 0x0B: /* XINPUT_DEVSUBTYPE_GUITAR_BASS */ + case 0x06: /* XINPUT_DEVSUBTYPE_GUITAR */ + case 0x07: /* XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE */ + case 0x0B: /* XINPUT_DEVSUBTYPE_GUITAR_BASS */ return SDL_JOYSTICK_TYPE_GUITAR; - case 0x08: /* XINPUT_DEVSUBTYPE_DRUM_KIT */ + case 0x08: /* XINPUT_DEVSUBTYPE_DRUM_KIT */ return SDL_JOYSTICK_TYPE_DRUM_KIT; - case 0x13: /* XINPUT_DEVSUBTYPE_ARCADE_PAD */ + case 0x13: /* XINPUT_DEVSUBTYPE_ARCADE_PAD */ return SDL_JOYSTICK_TYPE_ARCADE_PAD; default: return SDL_JOYSTICK_TYPE_UNKNOWN; @@ -2630,76 +2582,76 @@ SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_JoystickGUID guid) /* Microsoft Nano Transceiver v2.0 */ MAKE_VIDPID(0x045e, 0x0800), - MAKE_VIDPID(0x046d, 0xc30a), /* Logitech, Inc. iTouch Composite keboard */ + MAKE_VIDPID(0x046d, 0xc30a), /* Logitech, Inc. iTouch Composite keboard */ - MAKE_VIDPID(0x04d9, 0xa0df), /* Tek Syndicate Mouse (E-Signal USB Gaming Mouse) */ + MAKE_VIDPID(0x04d9, 0xa0df), /* Tek Syndicate Mouse (E-Signal USB Gaming Mouse) */ /* List of Wacom devices at: http://linuxwacom.sourceforge.net/wiki/index.php/Device_IDs */ - MAKE_VIDPID(0x056a, 0x0010), /* Wacom ET-0405 Graphire */ - MAKE_VIDPID(0x056a, 0x0011), /* Wacom ET-0405A Graphire2 (4x5) */ - MAKE_VIDPID(0x056a, 0x0012), /* Wacom ET-0507A Graphire2 (5x7) */ - MAKE_VIDPID(0x056a, 0x0013), /* Wacom CTE-430 Graphire3 (4x5) */ - MAKE_VIDPID(0x056a, 0x0014), /* Wacom CTE-630 Graphire3 (6x8) */ - MAKE_VIDPID(0x056a, 0x0015), /* Wacom CTE-440 Graphire4 (4x5) */ - MAKE_VIDPID(0x056a, 0x0016), /* Wacom CTE-640 Graphire4 (6x8) */ - MAKE_VIDPID(0x056a, 0x0017), /* Wacom CTE-450 Bamboo Fun (4x5) */ - MAKE_VIDPID(0x056a, 0x0018), /* Wacom CTE-650 Bamboo Fun 6x8 */ - MAKE_VIDPID(0x056a, 0x0019), /* Wacom CTE-631 Bamboo One */ - MAKE_VIDPID(0x056a, 0x00d1), /* Wacom Bamboo Pen and Touch CTH-460 */ - MAKE_VIDPID(0x056a, 0x030e), /* Wacom Intuos Pen (S) CTL-480 */ + MAKE_VIDPID(0x056a, 0x0010), /* Wacom ET-0405 Graphire */ + MAKE_VIDPID(0x056a, 0x0011), /* Wacom ET-0405A Graphire2 (4x5) */ + MAKE_VIDPID(0x056a, 0x0012), /* Wacom ET-0507A Graphire2 (5x7) */ + MAKE_VIDPID(0x056a, 0x0013), /* Wacom CTE-430 Graphire3 (4x5) */ + MAKE_VIDPID(0x056a, 0x0014), /* Wacom CTE-630 Graphire3 (6x8) */ + MAKE_VIDPID(0x056a, 0x0015), /* Wacom CTE-440 Graphire4 (4x5) */ + MAKE_VIDPID(0x056a, 0x0016), /* Wacom CTE-640 Graphire4 (6x8) */ + MAKE_VIDPID(0x056a, 0x0017), /* Wacom CTE-450 Bamboo Fun (4x5) */ + MAKE_VIDPID(0x056a, 0x0018), /* Wacom CTE-650 Bamboo Fun 6x8 */ + MAKE_VIDPID(0x056a, 0x0019), /* Wacom CTE-631 Bamboo One */ + MAKE_VIDPID(0x056a, 0x00d1), /* Wacom Bamboo Pen and Touch CTH-460 */ + MAKE_VIDPID(0x056a, 0x030e), /* Wacom Intuos Pen (S) CTL-480 */ - MAKE_VIDPID(0x09da, 0x054f), /* A4 Tech Co., G7 750 mouse */ - MAKE_VIDPID(0x09da, 0x1410), /* A4 Tech Co., Ltd Bloody AL9 mouse */ - MAKE_VIDPID(0x09da, 0x3043), /* A4 Tech Co., Ltd Bloody R8A Gaming Mouse */ - MAKE_VIDPID(0x09da, 0x31b5), /* A4 Tech Co., Ltd Bloody TL80 Terminator Laser Gaming Mouse */ - MAKE_VIDPID(0x09da, 0x3997), /* A4 Tech Co., Ltd Bloody RT7 Terminator Wireless */ - MAKE_VIDPID(0x09da, 0x3f8b), /* A4 Tech Co., Ltd Bloody V8 mouse */ - MAKE_VIDPID(0x09da, 0x51f4), /* Modecom MC-5006 Keyboard */ - MAKE_VIDPID(0x09da, 0x5589), /* A4 Tech Co., Ltd Terminator TL9 Laser Gaming Mouse */ - MAKE_VIDPID(0x09da, 0x7b22), /* A4 Tech Co., Ltd Bloody V5 */ - MAKE_VIDPID(0x09da, 0x7f2d), /* A4 Tech Co., Ltd Bloody R3 mouse */ - MAKE_VIDPID(0x09da, 0x8090), /* A4 Tech Co., Ltd X-718BK Oscar Optical Gaming Mouse */ - MAKE_VIDPID(0x09da, 0x9033), /* A4 Tech Co., X7 X-705K */ - MAKE_VIDPID(0x09da, 0x9066), /* A4 Tech Co., Sharkoon Fireglider Optical */ - MAKE_VIDPID(0x09da, 0x9090), /* A4 Tech Co., Ltd XL-730K / XL-750BK / XL-755BK Laser Mouse */ - MAKE_VIDPID(0x09da, 0x90c0), /* A4 Tech Co., Ltd X7 G800V keyboard */ - MAKE_VIDPID(0x09da, 0xf012), /* A4 Tech Co., Ltd Bloody V7 mouse */ - MAKE_VIDPID(0x09da, 0xf32a), /* A4 Tech Co., Ltd Bloody B540 keyboard */ - MAKE_VIDPID(0x09da, 0xf613), /* A4 Tech Co., Ltd Bloody V2 mouse */ - MAKE_VIDPID(0x09da, 0xf624), /* A4 Tech Co., Ltd Bloody B120 Keyboard */ + MAKE_VIDPID(0x09da, 0x054f), /* A4 Tech Co., G7 750 mouse */ + MAKE_VIDPID(0x09da, 0x1410), /* A4 Tech Co., Ltd Bloody AL9 mouse */ + MAKE_VIDPID(0x09da, 0x3043), /* A4 Tech Co., Ltd Bloody R8A Gaming Mouse */ + MAKE_VIDPID(0x09da, 0x31b5), /* A4 Tech Co., Ltd Bloody TL80 Terminator Laser Gaming Mouse */ + MAKE_VIDPID(0x09da, 0x3997), /* A4 Tech Co., Ltd Bloody RT7 Terminator Wireless */ + MAKE_VIDPID(0x09da, 0x3f8b), /* A4 Tech Co., Ltd Bloody V8 mouse */ + MAKE_VIDPID(0x09da, 0x51f4), /* Modecom MC-5006 Keyboard */ + MAKE_VIDPID(0x09da, 0x5589), /* A4 Tech Co., Ltd Terminator TL9 Laser Gaming Mouse */ + MAKE_VIDPID(0x09da, 0x7b22), /* A4 Tech Co., Ltd Bloody V5 */ + MAKE_VIDPID(0x09da, 0x7f2d), /* A4 Tech Co., Ltd Bloody R3 mouse */ + MAKE_VIDPID(0x09da, 0x8090), /* A4 Tech Co., Ltd X-718BK Oscar Optical Gaming Mouse */ + MAKE_VIDPID(0x09da, 0x9033), /* A4 Tech Co., X7 X-705K */ + MAKE_VIDPID(0x09da, 0x9066), /* A4 Tech Co., Sharkoon Fireglider Optical */ + MAKE_VIDPID(0x09da, 0x9090), /* A4 Tech Co., Ltd XL-730K / XL-750BK / XL-755BK Laser Mouse */ + MAKE_VIDPID(0x09da, 0x90c0), /* A4 Tech Co., Ltd X7 G800V keyboard */ + MAKE_VIDPID(0x09da, 0xf012), /* A4 Tech Co., Ltd Bloody V7 mouse */ + MAKE_VIDPID(0x09da, 0xf32a), /* A4 Tech Co., Ltd Bloody B540 keyboard */ + MAKE_VIDPID(0x09da, 0xf613), /* A4 Tech Co., Ltd Bloody V2 mouse */ + MAKE_VIDPID(0x09da, 0xf624), /* A4 Tech Co., Ltd Bloody B120 Keyboard */ - MAKE_VIDPID(0x1b1c, 0x1b3c), /* Corsair Harpoon RGB gaming mouse */ + MAKE_VIDPID(0x1b1c, 0x1b3c), /* Corsair Harpoon RGB gaming mouse */ - MAKE_VIDPID(0x1d57, 0xad03), /* [T3] 2.4GHz and IR Air Mouse Remote Control */ + MAKE_VIDPID(0x1d57, 0xad03), /* [T3] 2.4GHz and IR Air Mouse Remote Control */ - MAKE_VIDPID(0x1e7d, 0x2e4a), /* Roccat Tyon Mouse */ + MAKE_VIDPID(0x1e7d, 0x2e4a), /* Roccat Tyon Mouse */ - MAKE_VIDPID(0x20a0, 0x422d), /* Winkeyless.kr Keyboards */ + MAKE_VIDPID(0x20a0, 0x422d), /* Winkeyless.kr Keyboards */ - MAKE_VIDPID(0x2516, 0x001f), /* Cooler Master Storm Mizar Mouse */ - MAKE_VIDPID(0x2516, 0x0028), /* Cooler Master Storm Alcor Mouse */ + MAKE_VIDPID(0x2516, 0x001f), /* Cooler Master Storm Mizar Mouse */ + MAKE_VIDPID(0x2516, 0x0028), /* Cooler Master Storm Alcor Mouse */ /*****************************************************************/ /* Additional entries */ /*****************************************************************/ - MAKE_VIDPID(0x04d9, 0x8008), /* OBINLB USB-HID Keyboard (Anne Pro II) */ - MAKE_VIDPID(0x04d9, 0x8009), /* OBINLB USB-HID Keyboard (Anne Pro II) */ - MAKE_VIDPID(0x04d9, 0xa292), /* OBINLB USB-HID Keyboard (Anne Pro II) */ - MAKE_VIDPID(0x04d9, 0xa293), /* OBINLB USB-HID Keyboard (Anne Pro II) */ - MAKE_VIDPID(0x1532, 0x0266), /* Razer Huntman V2 Analog, non-functional DInput device */ - MAKE_VIDPID(0x1532, 0x0282), /* Razer Huntman Mini Analog, non-functional DInput device */ - MAKE_VIDPID(0x26ce, 0x01a2), /* ASRock LED Controller */ - MAKE_VIDPID(0x20d6, 0x0002), /* PowerA Enhanced Wireless Controller for Nintendo Switch (charging port only) */ + MAKE_VIDPID(0x04d9, 0x8008), /* OBINLB USB-HID Keyboard (Anne Pro II) */ + MAKE_VIDPID(0x04d9, 0x8009), /* OBINLB USB-HID Keyboard (Anne Pro II) */ + MAKE_VIDPID(0x04d9, 0xa292), /* OBINLB USB-HID Keyboard (Anne Pro II) */ + MAKE_VIDPID(0x04d9, 0xa293), /* OBINLB USB-HID Keyboard (Anne Pro II) */ + MAKE_VIDPID(0x1532, 0x0266), /* Razer Huntman V2 Analog, non-functional DInput device */ + MAKE_VIDPID(0x1532, 0x0282), /* Razer Huntman Mini Analog, non-functional DInput device */ + MAKE_VIDPID(0x26ce, 0x01a2), /* ASRock LED Controller */ + MAKE_VIDPID(0x20d6, 0x0002), /* PowerA Enhanced Wireless Controller for Nintendo Switch (charging port only) */ }; static Uint32 rog_chakram_list[] = { - MAKE_VIDPID(0x0b05, 0x1958), /* ROG Chakram Core Mouse */ - MAKE_VIDPID(0x0b05, 0x18e3), /* ROG Chakram (wired) Mouse */ - MAKE_VIDPID(0x0b05, 0x18e5), /* ROG Chakram (wireless) Mouse */ - MAKE_VIDPID(0x0b05, 0x1a18), /* ROG Chakram X (wired) Mouse */ - MAKE_VIDPID(0x0b05, 0x1a1a), /* ROG Chakram X (wireless) Mouse */ - MAKE_VIDPID(0x0b05, 0x1a1c), /* ROG Chakram X (Bluetooth) Mouse */ + MAKE_VIDPID(0x0b05, 0x1958), /* ROG Chakram Core Mouse */ + MAKE_VIDPID(0x0b05, 0x18e3), /* ROG Chakram (wired) Mouse */ + MAKE_VIDPID(0x0b05, 0x18e5), /* ROG Chakram (wireless) Mouse */ + MAKE_VIDPID(0x0b05, 0x1a18), /* ROG Chakram X (wired) Mouse */ + MAKE_VIDPID(0x0b05, 0x1a1a), /* ROG Chakram X (wireless) Mouse */ + MAKE_VIDPID(0x0b05, 0x1a1c), /* ROG Chakram X (Bluetooth) Mouse */ }; unsigned int i; @@ -3034,7 +2986,7 @@ int SDL_PrivateJoystickSensor(SDL_Joystick *joystick, SDL_SensorType type, Uint6 num_values = SDL_min(num_values, SDL_arraysize(sensor->data)); /* Update internal sensor state */ - SDL_memcpy(sensor->data, data, num_values*sizeof(*data)); + SDL_memcpy(sensor->data, data, num_values * sizeof(*data)); sensor->timestamp_us = timestamp_us; /* Post the event, if desired */ @@ -3046,7 +2998,7 @@ int SDL_PrivateJoystickSensor(SDL_Joystick *joystick, SDL_SensorType type, Uint6 event.csensor.sensor = type; num_values = SDL_min(num_values, SDL_arraysize(event.csensor.data)); SDL_memset(event.csensor.data, 0, sizeof(event.csensor.data)); - SDL_memcpy(event.csensor.data, data, num_values*sizeof(*data)); + SDL_memcpy(event.csensor.data, data, num_values * sizeof(*data)); event.csensor.timestamp_us = timestamp_us; posted = SDL_PushEvent(&event) == 1; } diff --git a/src/joystick/SDL_sysjoystick.h b/src/joystick/SDL_sysjoystick.h index 015007c59..fbe8b60ef 100644 --- a/src/joystick/SDL_sysjoystick.h +++ b/src/joystick/SDL_sysjoystick.h @@ -35,12 +35,12 @@ extern "C" { /* The SDL joystick structure */ typedef struct _SDL_JoystickAxisInfo { - Sint16 initial_value; /* Initial axis state */ - Sint16 value; /* Current axis state */ - Sint16 zero; /* Zero point on the axis (-32768 for triggers) */ - SDL_bool has_initial_value; /* Whether we've seen a value on the axis yet */ - SDL_bool has_second_value; /* Whether we've seen a second value on the axis yet */ - SDL_bool sent_initial_value; /* Whether we've sent the initial axis value */ + Sint16 initial_value; /* Initial axis state */ + Sint16 value; /* Current axis state */ + Sint16 zero; /* Zero point on the axis (-32768 for triggers) */ + SDL_bool has_initial_value; /* Whether we've seen a value on the axis yet */ + SDL_bool has_second_value; /* Whether we've seen a second value on the axis yet */ + SDL_bool sent_initial_value; /* Whether we've sent the initial axis value */ SDL_bool sending_initial_value; /* Whether we are sending the initial axis value */ } SDL_JoystickAxisInfo; @@ -63,7 +63,7 @@ typedef struct _SDL_JoystickSensorInfo SDL_SensorType type; SDL_bool enabled; float rate; - float data[3]; /* If this needs to expand, update SDL_ControllerSensorEvent */ + float data[3]; /* If this needs to expand, update SDL_ControllerSensorEvent */ Uint64 timestamp_us; } SDL_JoystickSensorInfo; @@ -78,25 +78,26 @@ struct _SDL_Joystick SDL_JoystickGUID guid; /* Joystick guid */ Uint16 firmware_version; /* Firmware version, if available */ - int naxes; /* Number of axis controls on the joystick */ + int naxes; /* Number of axis controls on the joystick */ SDL_JoystickAxisInfo *axes; - int nhats; /* Number of hats on the joystick */ - Uint8 *hats; /* Current hat states */ + int nhats; /* Number of hats on the joystick */ + Uint8 *hats; /* Current hat states */ - int nballs; /* Number of trackballs on the joystick */ - struct balldelta { + int nballs; /* Number of trackballs on the joystick */ + struct balldelta + { int dx; int dy; - } *balls; /* Current ball motion deltas */ + } * balls; /* Current ball motion deltas */ - int nbuttons; /* Number of buttons on the joystick */ - Uint8 *buttons; /* Current button states */ + int nbuttons; /* Number of buttons on the joystick */ + Uint8 *buttons; /* Current button states */ - int ntouchpads; /* Number of touchpads on the joystick */ - SDL_JoystickTouchpadInfo *touchpads; /* Current touchpad states */ + int ntouchpads; /* Number of touchpads on the joystick */ + SDL_JoystickTouchpadInfo *touchpads; /* Current touchpad states */ - int nsensors; /* Number of sensors on the joystick */ + int nsensors; /* Number of sensors on the joystick */ int nsensors_enabled; SDL_JoystickSensorInfo *sensors; @@ -116,31 +117,31 @@ struct _SDL_Joystick SDL_bool attached; SDL_bool is_game_controller; - SDL_bool delayed_guide_button; /* SDL_TRUE if this device has the guide button event delayed */ + SDL_bool delayed_guide_button; /* SDL_TRUE if this device has the guide button event delayed */ SDL_JoystickPowerLevel epowerlevel; /* power level of this joystick, SDL_JOYSTICK_POWER_UNKNOWN if not supported */ struct _SDL_JoystickDriver *driver; - struct joystick_hwdata *hwdata; /* Driver dependent information */ + struct joystick_hwdata *hwdata; /* Driver dependent information */ - int ref_count; /* Reference count for multiple opens */ + int ref_count; /* Reference count for multiple opens */ struct _SDL_Joystick *next; /* pointer to next joystick we have allocated */ }; /* Device bus definitions */ -#define SDL_HARDWARE_BUS_UNKNOWN 0x00 -#define SDL_HARDWARE_BUS_USB 0x03 -#define SDL_HARDWARE_BUS_BLUETOOTH 0x05 -#define SDL_HARDWARE_BUS_VIRTUAL 0xFF +#define SDL_HARDWARE_BUS_UNKNOWN 0x00 +#define SDL_HARDWARE_BUS_USB 0x03 +#define SDL_HARDWARE_BUS_BLUETOOTH 0x05 +#define SDL_HARDWARE_BUS_VIRTUAL 0xFF /* Joystick capability flags for GetCapabilities() */ -#define SDL_JOYCAP_LED 0x01 -#define SDL_JOYCAP_RUMBLE 0x02 -#define SDL_JOYCAP_RUMBLE_TRIGGERS 0x04 +#define SDL_JOYCAP_LED 0x01 +#define SDL_JOYCAP_RUMBLE 0x02 +#define SDL_JOYCAP_RUMBLE_TRIGGERS 0x04 /* Macro to combine a USB vendor ID and product ID into a single Uint32 value */ -#define MAKE_VIDPID(VID, PID) (((Uint32)(VID))<<16|(PID)) +#define MAKE_VIDPID(VID, PID) (((Uint32)(VID)) << 16 | (PID)) typedef struct _SDL_JoystickDriver { @@ -211,18 +212,18 @@ typedef struct _SDL_JoystickDriver void (*Quit)(void); /* Function to get the autodetected controller mapping; returns false if there isn't any. */ - SDL_bool (*GetGamepadMapping)(int device_index, SDL_GamepadMapping * out); + SDL_bool (*GetGamepadMapping)(int device_index, SDL_GamepadMapping *out); } SDL_JoystickDriver; /* Windows and Mac OSX has a limit of MAX_DWORD / 1000, Linux kernel has a limit of 0xFFFF */ -#define SDL_MAX_RUMBLE_DURATION_MS 0xFFFF +#define SDL_MAX_RUMBLE_DURATION_MS 0xFFFF -/* Dualshock4 only rumbles for about 5 seconds max, resend rumble command every 2 seconds +/* Dualshock4 only rumbles for about 5 seconds max, resend rumble command every 2 seconds * to make long rumble work. */ -#define SDL_RUMBLE_RESEND_MS 2000 +#define SDL_RUMBLE_RESEND_MS 2000 -#define SDL_LED_MIN_REPEAT_MS 5000 +#define SDL_LED_MIN_REPEAT_MS 5000 /* The available joystick drivers */ extern SDL_JoystickDriver SDL_ANDROID_JoystickDriver; diff --git a/src/joystick/android/SDL_sysjoystick.c b/src/joystick/android/SDL_sysjoystick.c index fdf5f16fe..5407afe66 100644 --- a/src/joystick/android/SDL_sysjoystick.c +++ b/src/joystick/android/SDL_sysjoystick.c @@ -39,15 +39,15 @@ /* As of platform android-14, android/keycodes.h is missing these defines */ #ifndef AKEYCODE_BUTTON_1 -#define AKEYCODE_BUTTON_1 188 -#define AKEYCODE_BUTTON_2 189 -#define AKEYCODE_BUTTON_3 190 -#define AKEYCODE_BUTTON_4 191 -#define AKEYCODE_BUTTON_5 192 -#define AKEYCODE_BUTTON_6 193 -#define AKEYCODE_BUTTON_7 194 -#define AKEYCODE_BUTTON_8 195 -#define AKEYCODE_BUTTON_9 196 +#define AKEYCODE_BUTTON_1 188 +#define AKEYCODE_BUTTON_2 189 +#define AKEYCODE_BUTTON_3 190 +#define AKEYCODE_BUTTON_4 191 +#define AKEYCODE_BUTTON_5 192 +#define AKEYCODE_BUTTON_6 193 +#define AKEYCODE_BUTTON_7 194 +#define AKEYCODE_BUTTON_8 195 +#define AKEYCODE_BUTTON_9 196 #define AKEYCODE_BUTTON_10 197 #define AKEYCODE_BUTTON_11 198 #define AKEYCODE_BUTTON_12 199 @@ -57,129 +57,126 @@ #define AKEYCODE_BUTTON_16 203 #endif -#define ANDROID_ACCELEROMETER_NAME "Android Accelerometer" +#define ANDROID_ACCELEROMETER_NAME "Android Accelerometer" #define ANDROID_ACCELEROMETER_DEVICE_ID INT_MIN -#define ANDROID_MAX_NBUTTONS 36 +#define ANDROID_MAX_NBUTTONS 36 -static SDL_joylist_item * JoystickByDeviceId(int device_id); +static SDL_joylist_item *JoystickByDeviceId(int device_id); static SDL_joylist_item *SDL_joylist = NULL; static SDL_joylist_item *SDL_joylist_tail = NULL; static int numjoysticks = 0; - /* Function to convert Android keyCodes into SDL ones. * This code manipulation is done to get a sequential list of codes. * FIXME: This is only suited for the case where we use a fixed number of buttons determined by ANDROID_MAX_NBUTTONS */ -static int -keycode_to_SDL(int keycode) +static int keycode_to_SDL(int keycode) { /* FIXME: If this function gets too unwieldy in the future, replace with a lookup table */ int button = 0; switch (keycode) { - /* Some gamepad buttons (API 9) */ - case AKEYCODE_BUTTON_A: - button = SDL_CONTROLLER_BUTTON_A; - break; - case AKEYCODE_BUTTON_B: - button = SDL_CONTROLLER_BUTTON_B; - break; - case AKEYCODE_BUTTON_X: - button = SDL_CONTROLLER_BUTTON_X; - break; - case AKEYCODE_BUTTON_Y: - button = SDL_CONTROLLER_BUTTON_Y; - break; - case AKEYCODE_BUTTON_L1: - button = SDL_CONTROLLER_BUTTON_LEFTSHOULDER; - break; - case AKEYCODE_BUTTON_R1: - button = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER; - break; - case AKEYCODE_BUTTON_THUMBL: - button = SDL_CONTROLLER_BUTTON_LEFTSTICK; - break; - case AKEYCODE_BUTTON_THUMBR: - button = SDL_CONTROLLER_BUTTON_RIGHTSTICK; - break; - case AKEYCODE_MENU: - case AKEYCODE_BUTTON_START: - button = SDL_CONTROLLER_BUTTON_START; - break; - case AKEYCODE_BACK: - case AKEYCODE_BUTTON_SELECT: - button = SDL_CONTROLLER_BUTTON_BACK; - break; - case AKEYCODE_BUTTON_MODE: - button = SDL_CONTROLLER_BUTTON_GUIDE; - break; - case AKEYCODE_BUTTON_L2: - button = 15; - break; - case AKEYCODE_BUTTON_R2: - button = 16; - break; - case AKEYCODE_BUTTON_C: - button = 17; - break; - case AKEYCODE_BUTTON_Z: - button = 18; - break; - - /* D-Pad key codes (API 1) */ - case AKEYCODE_DPAD_UP: - button = SDL_CONTROLLER_BUTTON_DPAD_UP; - break; - case AKEYCODE_DPAD_DOWN: - button = SDL_CONTROLLER_BUTTON_DPAD_DOWN; - break; - case AKEYCODE_DPAD_LEFT: - button = SDL_CONTROLLER_BUTTON_DPAD_LEFT; - break; - case AKEYCODE_DPAD_RIGHT: - button = SDL_CONTROLLER_BUTTON_DPAD_RIGHT; - break; - case AKEYCODE_DPAD_CENTER: - /* This is handled better by applications as the A button */ - /*button = 19;*/ - button = SDL_CONTROLLER_BUTTON_A; - break; + /* Some gamepad buttons (API 9) */ + case AKEYCODE_BUTTON_A: + button = SDL_CONTROLLER_BUTTON_A; + break; + case AKEYCODE_BUTTON_B: + button = SDL_CONTROLLER_BUTTON_B; + break; + case AKEYCODE_BUTTON_X: + button = SDL_CONTROLLER_BUTTON_X; + break; + case AKEYCODE_BUTTON_Y: + button = SDL_CONTROLLER_BUTTON_Y; + break; + case AKEYCODE_BUTTON_L1: + button = SDL_CONTROLLER_BUTTON_LEFTSHOULDER; + break; + case AKEYCODE_BUTTON_R1: + button = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER; + break; + case AKEYCODE_BUTTON_THUMBL: + button = SDL_CONTROLLER_BUTTON_LEFTSTICK; + break; + case AKEYCODE_BUTTON_THUMBR: + button = SDL_CONTROLLER_BUTTON_RIGHTSTICK; + break; + case AKEYCODE_MENU: + case AKEYCODE_BUTTON_START: + button = SDL_CONTROLLER_BUTTON_START; + break; + case AKEYCODE_BACK: + case AKEYCODE_BUTTON_SELECT: + button = SDL_CONTROLLER_BUTTON_BACK; + break; + case AKEYCODE_BUTTON_MODE: + button = SDL_CONTROLLER_BUTTON_GUIDE; + break; + case AKEYCODE_BUTTON_L2: + button = 15; + break; + case AKEYCODE_BUTTON_R2: + button = 16; + break; + case AKEYCODE_BUTTON_C: + button = 17; + break; + case AKEYCODE_BUTTON_Z: + button = 18; + break; - /* More gamepad buttons (API 12), these get mapped to 20...35*/ - case AKEYCODE_BUTTON_1: - case AKEYCODE_BUTTON_2: - case AKEYCODE_BUTTON_3: - case AKEYCODE_BUTTON_4: - case AKEYCODE_BUTTON_5: - case AKEYCODE_BUTTON_6: - case AKEYCODE_BUTTON_7: - case AKEYCODE_BUTTON_8: - case AKEYCODE_BUTTON_9: - case AKEYCODE_BUTTON_10: - case AKEYCODE_BUTTON_11: - case AKEYCODE_BUTTON_12: - case AKEYCODE_BUTTON_13: - case AKEYCODE_BUTTON_14: - case AKEYCODE_BUTTON_15: - case AKEYCODE_BUTTON_16: - button = 20 + (keycode - AKEYCODE_BUTTON_1); - break; - - default: - return -1; - /* break; -Wunreachable-code-break */ + /* D-Pad key codes (API 1) */ + case AKEYCODE_DPAD_UP: + button = SDL_CONTROLLER_BUTTON_DPAD_UP; + break; + case AKEYCODE_DPAD_DOWN: + button = SDL_CONTROLLER_BUTTON_DPAD_DOWN; + break; + case AKEYCODE_DPAD_LEFT: + button = SDL_CONTROLLER_BUTTON_DPAD_LEFT; + break; + case AKEYCODE_DPAD_RIGHT: + button = SDL_CONTROLLER_BUTTON_DPAD_RIGHT; + break; + case AKEYCODE_DPAD_CENTER: + /* This is handled better by applications as the A button */ + /*button = 19;*/ + button = SDL_CONTROLLER_BUTTON_A; + break; + + /* More gamepad buttons (API 12), these get mapped to 20...35*/ + case AKEYCODE_BUTTON_1: + case AKEYCODE_BUTTON_2: + case AKEYCODE_BUTTON_3: + case AKEYCODE_BUTTON_4: + case AKEYCODE_BUTTON_5: + case AKEYCODE_BUTTON_6: + case AKEYCODE_BUTTON_7: + case AKEYCODE_BUTTON_8: + case AKEYCODE_BUTTON_9: + case AKEYCODE_BUTTON_10: + case AKEYCODE_BUTTON_11: + case AKEYCODE_BUTTON_12: + case AKEYCODE_BUTTON_13: + case AKEYCODE_BUTTON_14: + case AKEYCODE_BUTTON_15: + case AKEYCODE_BUTTON_16: + button = 20 + (keycode - AKEYCODE_BUTTON_1); + break; + + default: + return -1; + /* break; -Wunreachable-code-break */ } - - /* This is here in case future generations, probably with six fingers per hand, - * happily add new cases up above and forget to update the max number of buttons. + + /* This is here in case future generations, probably with six fingers per hand, + * happily add new cases up above and forget to update the max number of buttons. */ SDL_assert(button < ANDROID_MAX_NBUTTONS); return button; } -static SDL_Scancode -button_to_scancode(int button) +static SDL_Scancode button_to_scancode(int button) { switch (button) { case SDL_CONTROLLER_BUTTON_A: @@ -202,8 +199,7 @@ button_to_scancode(int button) return SDL_SCANCODE_UNKNOWN; } -int -Android_OnPadDown(int device_id, int keycode) +int Android_OnPadDown(int device_id, int keycode) { SDL_joylist_item *item; int button = keycode_to_SDL(keycode); @@ -218,12 +214,11 @@ Android_OnPadDown(int device_id, int keycode) SDL_UnlockJoysticks(); return 0; } - + return -1; } -int -Android_OnPadUp(int device_id, int keycode) +int Android_OnPadUp(int device_id, int keycode) { SDL_joylist_item *item; int button = keycode_to_SDL(keycode); @@ -238,12 +233,11 @@ Android_OnPadUp(int device_id, int keycode) SDL_UnlockJoysticks(); return 0; } - + return -1; } -int -Android_OnJoy(int device_id, int axis, float value) +int Android_OnJoy(int device_id, int axis, float value) { /* Android gives joy info normalized as [-1.0, 1.0] or [0.0, 1.0] */ SDL_joylist_item *item; @@ -251,15 +245,14 @@ Android_OnJoy(int device_id, int axis, float value) SDL_LockJoysticks(); item = JoystickByDeviceId(device_id); if (item && item->joystick) { - SDL_PrivateJoystickAxis(item->joystick, axis, (Sint16) (32767.*value)); + SDL_PrivateJoystickAxis(item->joystick, axis, (Sint16)(32767. * value)); } SDL_UnlockJoysticks(); - + return 0; } -int -Android_OnHat(int device_id, int hat_id, int x, int y) +int Android_OnHat(int device_id, int hat_id, int x, int y) { const int DPAD_UP_MASK = (1 << SDL_CONTROLLER_BUTTON_DPAD_UP); const int DPAD_DOWN_MASK = (1 << SDL_CONTROLLER_BUTTON_DPAD_DOWN); @@ -309,9 +302,7 @@ Android_OnHat(int device_id, int hat_id, int x, int y) return -1; } - -int -Android_AddJoystick(int device_id, const char *name, const char *desc, int vendor_id, int product_id, SDL_bool is_accelerometer, int button_mask, int naxes, int nhats, int nballs) +int Android_AddJoystick(int device_id, const char *name, const char *desc, int vendor_id, int product_id, SDL_bool is_accelerometer, int button_mask, int naxes, int nhats, int nballs) { SDL_joylist_item *item; SDL_JoystickGUID guid; @@ -377,7 +368,7 @@ Android_AddJoystick(int device_id, const char *name, const char *desc, int vendo guid16[7] = SDL_SwapLE16(axis_mask); } - item = (SDL_joylist_item *) SDL_malloc(sizeof (SDL_joylist_item)); + item = (SDL_joylist_item *)SDL_malloc(sizeof(SDL_joylist_item)); if (item == NULL) { goto done; } @@ -390,14 +381,14 @@ Android_AddJoystick(int device_id, const char *name, const char *desc, int vendo SDL_free(item); goto done; } - + item->is_accelerometer = is_accelerometer; if (button_mask == 0xFFFFFFFF) { item->nbuttons = ANDROID_MAX_NBUTTONS; } else { - for (i = 0; i < sizeof(button_mask)*8; ++i) { + for (i = 0; i < sizeof(button_mask) * 8; ++i) { if (button_mask & (1 << i)) { - item->nbuttons = i+1; + item->nbuttons = i + 1; } } } @@ -429,13 +420,12 @@ done: return result; } -int -Android_RemoveJoystick(int device_id) +int Android_RemoveJoystick(int device_id) { SDL_joylist_item *item = SDL_joylist; SDL_joylist_item *prev = NULL; int result = -1; - + SDL_LockJoysticks(); /* Don't call JoystickByDeviceId here or there'll be an infinite loop! */ @@ -446,7 +436,7 @@ Android_RemoveJoystick(int device_id) prev = item; item = item->next; } - + if (item == NULL) { goto done; } @@ -454,7 +444,7 @@ Android_RemoveJoystick(int device_id) if (item->joystick) { item->joystick->hwdata = NULL; } - + if (prev != NULL) { prev->next = item->next; } else { @@ -485,30 +475,25 @@ done: return result; } - static void ANDROID_JoystickDetect(void); -static int -ANDROID_JoystickInit(void) +static int ANDROID_JoystickInit(void) { ANDROID_JoystickDetect(); - + if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE)) { /* Default behavior, accelerometer as joystick */ Android_AddJoystick(ANDROID_ACCELEROMETER_DEVICE_ID, ANDROID_ACCELEROMETER_NAME, ANDROID_ACCELEROMETER_NAME, 0, 0, SDL_TRUE, 0, 3, 0, 0); } return 0; - } -static int -ANDROID_JoystickGetCount(void) +static int ANDROID_JoystickGetCount(void) { return numjoysticks; } -static void -ANDROID_JoystickDetect(void) +static void ANDROID_JoystickDetect(void) { /* Support for device connect/disconnect is API >= 16 only, * so we poll every three seconds @@ -521,8 +506,7 @@ ANDROID_JoystickDetect(void) } } -static SDL_joylist_item * -JoystickByDevIndex(int device_index) +static SDL_joylist_item *JoystickByDevIndex(int device_index) { SDL_joylist_item *item = SDL_joylist; @@ -539,8 +523,7 @@ JoystickByDevIndex(int device_index) return item; } -static SDL_joylist_item * -JoystickByDeviceId(int device_id) +static SDL_joylist_item *JoystickByDeviceId(int device_id) { SDL_joylist_item *item = SDL_joylist; @@ -550,10 +533,10 @@ JoystickByDeviceId(int device_id) } item = item->next; } - + /* Joystick not found, try adding it */ ANDROID_JoystickDetect(); - + while (item != NULL) { if (item->device_id == device_id) { return item; @@ -564,56 +547,49 @@ JoystickByDeviceId(int device_id) return NULL; } -static const char * -ANDROID_JoystickGetDeviceName(int device_index) +static const char *ANDROID_JoystickGetDeviceName(int device_index) { return JoystickByDevIndex(device_index)->name; } -static const char * -ANDROID_JoystickGetDevicePath(int device_index) +static const char *ANDROID_JoystickGetDevicePath(int device_index) { return NULL; } -static int -ANDROID_JoystickGetDevicePlayerIndex(int device_index) +static int ANDROID_JoystickGetDevicePlayerIndex(int device_index) { return -1; } -static void -ANDROID_JoystickSetDevicePlayerIndex(int device_index, int player_index) +static void ANDROID_JoystickSetDevicePlayerIndex(int device_index, int player_index) { } -static SDL_JoystickGUID -ANDROID_JoystickGetDeviceGUID(int device_index) +static SDL_JoystickGUID ANDROID_JoystickGetDeviceGUID(int device_index) { return JoystickByDevIndex(device_index)->guid; } -static SDL_JoystickID -ANDROID_JoystickGetDeviceInstanceID(int device_index) +static SDL_JoystickID ANDROID_JoystickGetDeviceInstanceID(int device_index) { return JoystickByDevIndex(device_index)->device_instance; } -static int -ANDROID_JoystickOpen(SDL_Joystick *joystick, int device_index) +static int ANDROID_JoystickOpen(SDL_Joystick *joystick, int device_index) { SDL_joylist_item *item = JoystickByDevIndex(device_index); if (item == NULL) { return SDL_SetError("No such device"); } - + if (item->joystick != NULL) { return SDL_SetError("Joystick already opened"); } joystick->instance_id = item->device_instance; - joystick->hwdata = (struct joystick_hwdata *) item; + joystick->hwdata = (struct joystick_hwdata *)item; item->joystick = joystick; joystick->nhats = item->nhats; joystick->nballs = item->nballs; @@ -623,51 +599,44 @@ ANDROID_JoystickOpen(SDL_Joystick *joystick, int device_index) return 0; } -static int -ANDROID_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int ANDROID_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { return SDL_Unsupported(); } -static int -ANDROID_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int ANDROID_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static Uint32 -ANDROID_JoystickGetCapabilities(SDL_Joystick *joystick) +static Uint32 ANDROID_JoystickGetCapabilities(SDL_Joystick *joystick) { return 0; } -static int -ANDROID_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int ANDROID_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -ANDROID_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) +static int ANDROID_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -ANDROID_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int ANDROID_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } -static void -ANDROID_JoystickUpdate(SDL_Joystick *joystick) +static void ANDROID_JoystickUpdate(SDL_Joystick *joystick) { - SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata; + SDL_joylist_item *item = (SDL_joylist_item *)joystick->hwdata; if (item == NULL) { return; } - + if (item->is_accelerometer) { int i; Sint16 value; @@ -688,17 +657,15 @@ ANDROID_JoystickUpdate(SDL_Joystick *joystick) } } -static void -ANDROID_JoystickClose(SDL_Joystick *joystick) +static void ANDROID_JoystickClose(SDL_Joystick *joystick) { - SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata; + SDL_joylist_item *item = (SDL_joylist_item *)joystick->hwdata; if (item) { item->joystick = NULL; } } -static void -ANDROID_JoystickQuit(void) +static void ANDROID_JoystickQuit(void) { /* We don't have any way to scan for joysticks at init, so don't wipe the list * of joysticks here in case this is a reinit. @@ -719,14 +686,12 @@ ANDROID_JoystickQuit(void) #endif /* 0 */ } -static SDL_bool -ANDROID_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static SDL_bool ANDROID_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { return SDL_FALSE; } -SDL_JoystickDriver SDL_ANDROID_JoystickDriver = -{ +SDL_JoystickDriver SDL_ANDROID_JoystickDriver = { ANDROID_JoystickInit, ANDROID_JoystickGetCount, ANDROID_JoystickDetect, diff --git a/src/joystick/android/SDL_sysjoystick_c.h b/src/joystick/android/SDL_sysjoystick_c.h index 881c8aa41..d7a879784 100644 --- a/src/joystick/android/SDL_sysjoystick_c.h +++ b/src/joystick/android/SDL_sysjoystick_c.h @@ -40,13 +40,13 @@ typedef struct SDL_joylist_item { int device_instance; int device_id; /* Android's device id */ - char *name; /* "SideWinder 3D Pro" or whatever */ + char *name; /* "SideWinder 3D Pro" or whatever */ SDL_JoystickGUID guid; SDL_bool is_accelerometer; SDL_Joystick *joystick; int nbuttons, naxes, nhats, nballs; int dpad_state; - + struct SDL_joylist_item *next; } SDL_joylist_item; diff --git a/src/joystick/bsd/SDL_bsdjoystick.c b/src/joystick/bsd/SDL_bsdjoystick.c index 7049062d5..8b0590ecc 100644 --- a/src/joystick/bsd/SDL_bsdjoystick.c +++ b/src/joystick/bsd/SDL_bsdjoystick.c @@ -82,30 +82,29 @@ #define SUPPORT_JOY_GAMEPORT #endif -#define MAX_UHID_JOYS 64 -#define MAX_JOY_JOYS 2 -#define MAX_JOYS (MAX_UHID_JOYS + MAX_JOY_JOYS) +#define MAX_UHID_JOYS 64 +#define MAX_JOY_JOYS 2 +#define MAX_JOYS (MAX_UHID_JOYS + MAX_JOY_JOYS) #ifdef __OpenBSD__ -#define HUG_DPAD_UP 0x90 -#define HUG_DPAD_DOWN 0x91 -#define HUG_DPAD_RIGHT 0x92 -#define HUG_DPAD_LEFT 0x93 +#define HUG_DPAD_UP 0x90 +#define HUG_DPAD_DOWN 0x91 +#define HUG_DPAD_RIGHT 0x92 +#define HUG_DPAD_LEFT 0x93 -#define HAT_CENTERED 0x00 -#define HAT_UP 0x01 -#define HAT_RIGHT 0x02 -#define HAT_DOWN 0x04 -#define HAT_LEFT 0x08 -#define HAT_RIGHTUP (HAT_RIGHT|HAT_UP) -#define HAT_RIGHTDOWN (HAT_RIGHT|HAT_DOWN) -#define HAT_LEFTUP (HAT_LEFT|HAT_UP) -#define HAT_LEFTDOWN (HAT_LEFT|HAT_DOWN) +#define HAT_CENTERED 0x00 +#define HAT_UP 0x01 +#define HAT_RIGHT 0x02 +#define HAT_DOWN 0x04 +#define HAT_LEFT 0x08 +#define HAT_RIGHTUP (HAT_RIGHT | HAT_UP) +#define HAT_RIGHTDOWN (HAT_RIGHT | HAT_DOWN) +#define HAT_LEFTUP (HAT_LEFT | HAT_UP) +#define HAT_LEFTDOWN (HAT_LEFT | HAT_DOWN) /* calculate the value from the state of the dpad */ -int -dpad_to_sdl(Sint32 *dpad) +int dpad_to_sdl(Sint32 *dpad) { if (dpad[2]) { if (dpad[0]) @@ -140,8 +139,8 @@ struct report #else struct usb_ctl_report *buf; /* Buffer */ #endif - size_t size; /* Buffer size */ - int rid; /* Report ID */ + size_t size; /* Buffer size */ + int rid; /* Report ID */ enum { SREPORT_UNINIT, @@ -156,9 +155,9 @@ static struct hid_kind_t kind; const char *name; } const repinfo[] = { - {UHID_INPUT_REPORT, hid_input, "input"}, - {UHID_OUTPUT_REPORT, hid_output, "output"}, - {UHID_FEATURE_REPORT, hid_feature, "feature"} + { UHID_INPUT_REPORT, hid_input, "input" }, + { UHID_OUTPUT_REPORT, hid_output, "output" }, + { UHID_FEATURE_REPORT, hid_feature, "feature" } }; enum @@ -186,8 +185,8 @@ struct joystick_hwdata int fd; enum { - BSDJOY_UHID, /* uhid(4) */ - BSDJOY_JOY /* joy(4) */ + BSDJOY_UHID, /* uhid(4) */ + BSDJOY_JOY /* joy(4) */ } type; int naxes; @@ -202,8 +201,8 @@ struct joystick_hwdata typedef struct SDL_joylist_item { SDL_JoystickID device_instance; - char *path; /* "/dev/uhid0" or whatever */ - char *name; /* "SideWinder 3D Pro" or whatever */ + char *path; /* "/dev/uhid0" or whatever */ + char *name; /* "SideWinder 3D Pro" or whatever */ SDL_JoystickGUID guid; dev_t devnum; struct SDL_joylist_item *next; @@ -227,9 +226,7 @@ static void report_free(struct report *); #define REP_BUF_DATA(rep) ((rep)->buf->data) #endif - -static int -usage_to_joyaxe(int usage) +static int usage_to_joyaxe(int usage) { int joyaxe; switch (usage) { @@ -263,16 +260,14 @@ usage_to_joyaxe(int usage) return joyaxe; } -static void -FreeJoylistItem(SDL_joylist_item *item) +static void FreeJoylistItem(SDL_joylist_item *item) { SDL_free(item->path); SDL_free(item->name); SDL_free(item); } -static void -FreeHwData(struct joystick_hwdata *hw) +static void FreeHwData(struct joystick_hwdata *hw) { if (hw->type == BSDJOY_UHID) { report_free(&hw->inreport); @@ -338,7 +333,7 @@ CreateHwData(const char *path) #else if (ioctl(fd, USB_GET_REPORT_ID, &rep->rid) < 0) { #endif - rep->rid = -1; /* XXX */ + rep->rid = -1; /* XXX */ } if (report_alloc(rep, hw->repdesc, REPORT_INPUT) < 0) { goto usberr; @@ -366,28 +361,27 @@ CreateHwData(const char *path) case hid_input: switch (HID_PAGE(hitem.usage)) { case HUP_GENERIC_DESKTOP: - { - int usage = HID_USAGE(hitem.usage); - int joyaxe = usage_to_joyaxe(usage); - if (joyaxe >= 0) { - hw->axis_map[joyaxe] = 1; - } else if (usage == HUG_HAT_SWITCH + { + int usage = HID_USAGE(hitem.usage); + int joyaxe = usage_to_joyaxe(usage); + if (joyaxe >= 0) { + hw->axis_map[joyaxe] = 1; + } else if (usage == HUG_HAT_SWITCH #ifdef __OpenBSD__ - || usage == HUG_DPAD_UP + || usage == HUG_DPAD_UP #endif - ) { - hw->nhats++; - } - break; - } - case HUP_BUTTON: - { - int usage = HID_USAGE(hitem.usage); - if (usage > hw->nbuttons) { - hw->nbuttons = usage; - } + ) { + hw->nhats++; } break; + } + case HUP_BUTTON: + { + int usage = HID_USAGE(hitem.usage); + if (usage > hw->nbuttons) { + hw->nbuttons = usage; + } + } break; default: break; } @@ -426,8 +420,7 @@ usberr: return NULL; } -static int -MaybeAddDevice(const char *path) +static int MaybeAddDevice(const char *path) { struct stat sb; char *name = NULL; @@ -446,7 +439,7 @@ MaybeAddDevice(const char *path) /* Check to make sure it's not already in list. */ for (item = SDL_joylist; item != NULL; item = item->next) { if (sb.st_rdev == item->devnum) { - return -1; /* already have this one */ + return -1; /* already have this one */ } } @@ -487,7 +480,7 @@ MaybeAddDevice(const char *path) } FreeHwData(hw); - item = (SDL_joylist_item *) SDL_calloc(1, sizeof (SDL_joylist_item)); + item = (SDL_joylist_item *)SDL_calloc(1, sizeof(SDL_joylist_item)); if (item == NULL) { SDL_free(name); return -1; @@ -499,8 +492,8 @@ MaybeAddDevice(const char *path) item->guid = guid; if ((item->path == NULL) || (item->name == NULL)) { - FreeJoylistItem(item); - return -1; + FreeJoylistItem(item); + return -1; } item->device_instance = SDL_GetNextJoystickInstanceID(); @@ -519,8 +512,7 @@ MaybeAddDevice(const char *path) return numjoysticks; } -static int -BSD_JoystickInit(void) +static int BSD_JoystickInit(void) { char s[16]; int i; @@ -546,19 +538,16 @@ BSD_JoystickInit(void) return numjoysticks; } -static int -BSD_JoystickGetCount(void) +static int BSD_JoystickGetCount(void) { return numjoysticks; } -static void -BSD_JoystickDetect(void) +static void BSD_JoystickDetect(void) { } -static SDL_joylist_item * -JoystickByDevIndex(int device_index) +static SDL_joylist_item *JoystickByDevIndex(int device_index) { SDL_joylist_item *item = SDL_joylist; @@ -575,44 +564,37 @@ JoystickByDevIndex(int device_index) return item; } -static const char * -BSD_JoystickGetDeviceName(int device_index) +static const char *BSD_JoystickGetDeviceName(int device_index) { return JoystickByDevIndex(device_index)->name; } -static const char * -BSD_JoystickGetDevicePath(int device_index) +static const char *BSD_JoystickGetDevicePath(int device_index) { return JoystickByDevIndex(device_index)->path; } -static int -BSD_JoystickGetDevicePlayerIndex(int device_index) +static int BSD_JoystickGetDevicePlayerIndex(int device_index) { return -1; } -static void -BSD_JoystickSetDevicePlayerIndex(int device_index, int player_index) +static void BSD_JoystickSetDevicePlayerIndex(int device_index, int player_index) { } -static SDL_JoystickGUID -BSD_JoystickGetDeviceGUID(int device_index) +static SDL_JoystickGUID BSD_JoystickGetDeviceGUID(int device_index) { return JoystickByDevIndex(device_index)->guid; } /* Function to perform the mapping from device index to the instance id for this index */ -static SDL_JoystickID -BSD_JoystickGetDeviceInstanceID(int device_index) +static SDL_JoystickID BSD_JoystickGetDeviceInstanceID(int device_index) { return JoystickByDevIndex(device_index)->device_instance; } -static unsigned -hatval_to_sdl(Sint32 hatval) +static unsigned hatval_to_sdl(Sint32 hatval) { static const unsigned hat_dir_map[8] = { SDL_HAT_UP, SDL_HAT_RIGHTUP, SDL_HAT_RIGHT, SDL_HAT_RIGHTDOWN, @@ -626,9 +608,7 @@ hatval_to_sdl(Sint32 hatval) return result; } - -static int -BSD_JoystickOpen(SDL_Joystick *joy, int device_index) +static int BSD_JoystickOpen(SDL_Joystick *joy, int device_index) { SDL_joylist_item *item = JoystickByDevIndex(device_index); struct joystick_hwdata *hw; @@ -651,8 +631,7 @@ BSD_JoystickOpen(SDL_Joystick *joy, int device_index) return 0; } -static void -BSD_JoystickUpdate(SDL_Joystick *joy) +static void BSD_JoystickUpdate(SDL_Joystick *joy) { struct hid_item hitem; struct hid_data *hdata; @@ -660,7 +639,7 @@ BSD_JoystickUpdate(SDL_Joystick *joy) int nbutton, naxe = -1; Sint32 v; #ifdef __OpenBSD__ - Sint32 dpad[4] = {0, 0, 0, 0}; + Sint32 dpad[4] = { 0, 0, 0, 0 }; #endif #ifdef SUPPORT_JOY_GAMEPORT @@ -681,7 +660,7 @@ BSD_JoystickUpdate(SDL_Joystick *joy) xmin--; xmax++; } - v = (((SDL_JOYSTICK_AXIS_MAX - SDL_JOYSTICK_AXIS_MIN) * ((Sint32)x - xmin) ) / (xmax - xmin)) + SDL_JOYSTICK_AXIS_MIN; + v = (((SDL_JOYSTICK_AXIS_MAX - SDL_JOYSTICK_AXIS_MIN) * ((Sint32)x - xmin)) / (xmax - xmin)) + SDL_JOYSTICK_AXIS_MIN; SDL_PrivateJoystickAxis(joy, 0, v); } if (SDL_abs(y - gameport.y) > 8) { @@ -696,7 +675,7 @@ BSD_JoystickUpdate(SDL_Joystick *joy) ymin--; ymax++; } - v = (((SDL_JOYSTICK_AXIS_MAX - SDL_JOYSTICK_AXIS_MIN) * ((Sint32)y - ymin) ) / (ymax - ymin)) + SDL_JOYSTICK_AXIS_MIN; + v = (((SDL_JOYSTICK_AXIS_MAX - SDL_JOYSTICK_AXIS_MIN) * ((Sint32)y - ymin)) / (ymax - ymin)) + SDL_JOYSTICK_AXIS_MIN; SDL_PrivateJoystickAxis(joy, 1, v); } SDL_PrivateJoystickButton(joy, 0, gameport.b1); @@ -724,41 +703,41 @@ BSD_JoystickUpdate(SDL_Joystick *joy) case hid_input: switch (HID_PAGE(hitem.usage)) { case HUP_GENERIC_DESKTOP: - { - int usage = HID_USAGE(hitem.usage); - int joyaxe = usage_to_joyaxe(usage); - if (joyaxe >= 0) { - naxe = joy->hwdata->axis_map[joyaxe]; - /* scaleaxe */ - v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); - v = (((SDL_JOYSTICK_AXIS_MAX - SDL_JOYSTICK_AXIS_MIN) * (v - hitem.logical_minimum) ) / (hitem.logical_maximum - hitem.logical_minimum)) + SDL_JOYSTICK_AXIS_MIN; - SDL_PrivateJoystickAxis(joy, naxe, v); - } else if (usage == HUG_HAT_SWITCH) { - v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); - SDL_PrivateJoystickHat(joy, 0, - hatval_to_sdl(v) - + { + int usage = HID_USAGE(hitem.usage); + int joyaxe = usage_to_joyaxe(usage); + if (joyaxe >= 0) { + naxe = joy->hwdata->axis_map[joyaxe]; + /* scaleaxe */ + v = (Sint32)hid_get_data(REP_BUF_DATA(rep), &hitem); + v = (((SDL_JOYSTICK_AXIS_MAX - SDL_JOYSTICK_AXIS_MIN) * (v - hitem.logical_minimum)) / (hitem.logical_maximum - hitem.logical_minimum)) + SDL_JOYSTICK_AXIS_MIN; + SDL_PrivateJoystickAxis(joy, naxe, v); + } else if (usage == HUG_HAT_SWITCH) { + v = (Sint32)hid_get_data(REP_BUF_DATA(rep), &hitem); + SDL_PrivateJoystickHat(joy, 0, + hatval_to_sdl(v) - hitem.logical_minimum); - } -#ifdef __OpenBSD__ - else if (usage == HUG_DPAD_UP) { - dpad[0] = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); - SDL_PrivateJoystickHat(joy, 0, dpad_to_sdl(dpad)); - } else if (usage == HUG_DPAD_DOWN) { - dpad[1] = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); - SDL_PrivateJoystickHat(joy, 0, dpad_to_sdl(dpad)); - } else if (usage == HUG_DPAD_RIGHT) { - dpad[2] = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); - SDL_PrivateJoystickHat(joy, 0, dpad_to_sdl(dpad)); - } else if (usage == HUG_DPAD_LEFT) { - dpad[3] = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); - SDL_PrivateJoystickHat(joy, 0, dpad_to_sdl(dpad)); - } -#endif - break; } +#ifdef __OpenBSD__ + else if (usage == HUG_DPAD_UP) { + dpad[0] = (Sint32)hid_get_data(REP_BUF_DATA(rep), &hitem); + SDL_PrivateJoystickHat(joy, 0, dpad_to_sdl(dpad)); + } else if (usage == HUG_DPAD_DOWN) { + dpad[1] = (Sint32)hid_get_data(REP_BUF_DATA(rep), &hitem); + SDL_PrivateJoystickHat(joy, 0, dpad_to_sdl(dpad)); + } else if (usage == HUG_DPAD_RIGHT) { + dpad[2] = (Sint32)hid_get_data(REP_BUF_DATA(rep), &hitem); + SDL_PrivateJoystickHat(joy, 0, dpad_to_sdl(dpad)); + } else if (usage == HUG_DPAD_LEFT) { + dpad[3] = (Sint32)hid_get_data(REP_BUF_DATA(rep), &hitem); + SDL_PrivateJoystickHat(joy, 0, dpad_to_sdl(dpad)); + } +#endif + break; + } case HUP_BUTTON: - v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); - nbutton = HID_USAGE(hitem.usage) - 1; /* SDL buttons are zero-based */ + v = (Sint32)hid_get_data(REP_BUF_DATA(rep), &hitem); + nbutton = HID_USAGE(hitem.usage) - 1; /* SDL buttons are zero-based */ SDL_PrivateJoystickButton(joy, nbutton, v); break; default: @@ -774,8 +753,7 @@ BSD_JoystickUpdate(SDL_Joystick *joy) } /* Function to close a joystick after use */ -static void -BSD_JoystickClose(SDL_Joystick *joy) +static void BSD_JoystickClose(SDL_Joystick *joy) { if (joy->hwdata) { FreeHwData(joy->hwdata); @@ -783,8 +761,7 @@ BSD_JoystickClose(SDL_Joystick *joy) } } -static void -BSD_JoystickQuit(void) +static void BSD_JoystickQuit(void) { SDL_joylist_item *item = NULL; SDL_joylist_item *next = NULL; @@ -799,29 +776,28 @@ BSD_JoystickQuit(void) numjoysticks = 0; } -static int -report_alloc(struct report *r, struct report_desc *rd, int repind) +static int report_alloc(struct report *r, struct report_desc *rd, int repind) { int len; #ifdef __DragonFly__ len = hid_report_size(rd, repinfo[repind].kind, r->rid); #elif __FREEBSD__ -# if (__FreeBSD_kernel_version >= 460000) || defined(__FreeBSD_kernel__) -# if (__FreeBSD_kernel_version <= 500111) +#if (__FreeBSD_kernel_version >= 460000) || defined(__FreeBSD_kernel__) +#if (__FreeBSD_kernel_version <= 500111) len = hid_report_size(rd, r->rid, repinfo[repind].kind); -# else - len = hid_report_size(rd, repinfo[repind].kind, r->rid); -# endif -# else - len = hid_report_size(rd, repinfo[repind].kind, &r->rid); -# endif #else -# ifdef USBHID_NEW len = hid_report_size(rd, repinfo[repind].kind, r->rid); -# else +#endif +#else len = hid_report_size(rd, repinfo[repind].kind, &r->rid); -# endif +#endif +#else +#ifdef USBHID_NEW + len = hid_report_size(rd, repinfo[repind].kind, r->rid); +#else + len = hid_report_size(rd, repinfo[repind].kind, &r->rid); +#endif #endif if (len < 0) { @@ -847,57 +823,48 @@ report_alloc(struct report *r, struct report_desc *rd, int repind) return 0; } -static void -report_free(struct report *r) +static void report_free(struct report *r) { SDL_free(r->buf); r->status = SREPORT_UNINIT; } -static int -BSD_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int BSD_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { return SDL_Unsupported(); } -static int -BSD_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int BSD_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static SDL_bool -BSD_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static SDL_bool BSD_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { return SDL_FALSE; } -static Uint32 -BSD_JoystickGetCapabilities(SDL_Joystick *joystick) +static Uint32 BSD_JoystickGetCapabilities(SDL_Joystick *joystick) { return 0; } -static int -BSD_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int BSD_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -BSD_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) +static int BSD_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -BSD_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int BSD_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } -SDL_JoystickDriver SDL_BSD_JoystickDriver = -{ +SDL_JoystickDriver SDL_BSD_JoystickDriver = { BSD_JoystickInit, BSD_JoystickGetCount, BSD_JoystickDetect, diff --git a/src/joystick/darwin/SDL_iokitjoystick.c b/src/joystick/darwin/SDL_iokitjoystick.c index 7b7f9c7ef..5d5d70211 100644 --- a/src/joystick/darwin/SDL_iokitjoystick.c +++ b/src/joystick/darwin/SDL_iokitjoystick.c @@ -28,12 +28,11 @@ #include "../SDL_joystick_c.h" #include "SDL_iokitjoystick_c.h" #include "../hidapi/SDL_hidapijoystick_c.h" -#include "../../haptic/darwin/SDL_syshaptic_c.h" /* For haptic hot plugging */ - +#include "../../haptic/darwin/SDL_syshaptic_c.h" /* For haptic hot plugging */ #define SDL_JOYSTICK_RUNLOOP_MODE CFSTR("SDLJoystick") -#define CONVERT_MAGNITUDE(x) (((x)*10000) / 0x7FFF) +#define CONVERT_MAGNITUDE(x) (((x)*10000) / 0x7FFF) /* The base object of the HID Manager API */ static IOHIDManagerRef hidman = NULL; @@ -112,8 +111,7 @@ static recDevice *GetDeviceForIndex(int device_index) return device; } -static void -FreeElementList(recElement *pElement) +static void FreeElementList(recElement *pElement) { while (pElement) { recElement *pElementNext = pElement->pNext; @@ -122,8 +120,7 @@ FreeElementList(recElement *pElement) } } -static recDevice * -FreeDevice(recDevice *removeDevice) +static recDevice *FreeDevice(recDevice *removeDevice) { recDevice *pDeviceNext = NULL; if (removeDevice) { @@ -177,8 +174,7 @@ FreeDevice(recDevice *removeDevice) return pDeviceNext; } -static SDL_bool -GetHIDElementState(recDevice *pDevice, recElement *pElement, SInt32 *pValue) +static SDL_bool GetHIDElementState(recDevice *pDevice, recElement *pElement, SInt32 *pValue) { SInt32 value = 0; int returnValue = SDL_FALSE; @@ -186,7 +182,7 @@ GetHIDElementState(recDevice *pDevice, recElement *pElement, SInt32 *pValue) if (pDevice && pDevice->deviceRef && pElement) { IOHIDValueRef valueRef; if (IOHIDDeviceGetValue(pDevice->deviceRef, pElement->elementRef, &valueRef) == kIOReturnSuccess) { - value = (SInt32) IOHIDValueGetIntegerValue(valueRef); + value = (SInt32)IOHIDValueGetIntegerValue(valueRef); /* record min and max for auto calibration */ if (value < pElement->minReport) { @@ -203,27 +199,25 @@ GetHIDElementState(recDevice *pDevice, recElement *pElement, SInt32 *pValue) return returnValue; } -static SDL_bool -GetHIDScaledCalibratedState(recDevice * pDevice, recElement * pElement, SInt32 min, SInt32 max, SInt32 *pValue) +static SDL_bool GetHIDScaledCalibratedState(recDevice *pDevice, recElement *pElement, SInt32 min, SInt32 max, SInt32 *pValue) { const float deviceScale = max - min; const float readScale = pElement->maxReport - pElement->minReport; int returnValue = SDL_FALSE; if (GetHIDElementState(pDevice, pElement, pValue)) { if (readScale == 0) { - returnValue = SDL_TRUE; /* no scaling at all */ + returnValue = SDL_TRUE; /* no scaling at all */ } else { *pValue = ((*pValue - pElement->minReport) * deviceScale / readScale) + min; returnValue = SDL_TRUE; } - } + } return returnValue; } -static void -JoystickDeviceWasRemovedCallback(void *ctx, IOReturn result, void *sender) +static void JoystickDeviceWasRemovedCallback(void *ctx, IOReturn result, void *sender) { - recDevice *device = (recDevice *) ctx; + recDevice *device = (recDevice *)ctx; device->removed = SDL_TRUE; if (device->deviceRef) { // deviceRef was invalidated due to the remove @@ -250,19 +244,17 @@ JoystickDeviceWasRemovedCallback(void *ctx, IOReturn result, void *sender) SDL_PrivateJoystickRemoved(device->instance_id); } - static void AddHIDElement(const void *value, void *parameter); /* Call AddHIDElement() on all elements in an array of IOHIDElementRefs */ -static void -AddHIDElements(CFArrayRef array, recDevice *pDevice) +static void AddHIDElements(CFArrayRef array, recDevice *pDevice) { const CFRange range = { 0, CFArrayGetCount(array) }; CFArrayApplyFunction(array, range, AddHIDElement, pDevice); } -static SDL_bool -ElementAlreadyAdded(const IOHIDElementCookie cookie, const recElement *listitem) { +static SDL_bool ElementAlreadyAdded(const IOHIDElementCookie cookie, const recElement *listitem) +{ while (listitem) { if (listitem->cookie == cookie) { return SDL_TRUE; @@ -273,11 +265,10 @@ ElementAlreadyAdded(const IOHIDElementCookie cookie, const recElement *listitem) } /* See if we care about this HID element, and if so, note it in our recDevice. */ -static void -AddHIDElement(const void *value, void *parameter) +static void AddHIDElement(const void *value, void *parameter) { - recDevice *pDevice = (recDevice *) parameter; - IOHIDElementRef refElement = (IOHIDElementRef) value; + recDevice *pDevice = (recDevice *)parameter; + IOHIDElementRef refElement = (IOHIDElementRef)value; const CFTypeID elementTypeID = refElement ? CFGetTypeID(refElement) : 0; if (refElement && (elementTypeID == IOHIDElementGetTypeID())) { @@ -289,107 +280,107 @@ AddHIDElement(const void *value, void *parameter) /* look at types of interest */ switch (IOHIDElementGetType(refElement)) { - case kIOHIDElementTypeInput_Misc: - case kIOHIDElementTypeInput_Button: - case kIOHIDElementTypeInput_Axis: { - switch (usagePage) { /* only interested in kHIDPage_GenericDesktop and kHIDPage_Button */ - case kHIDPage_GenericDesktop: - switch (usage) { - case kHIDUsage_GD_X: - case kHIDUsage_GD_Y: - case kHIDUsage_GD_Z: - case kHIDUsage_GD_Rx: - case kHIDUsage_GD_Ry: - case kHIDUsage_GD_Rz: - case kHIDUsage_GD_Slider: - case kHIDUsage_GD_Dial: - case kHIDUsage_GD_Wheel: - if (!ElementAlreadyAdded(cookie, pDevice->firstAxis)) { - element = (recElement *) SDL_calloc(1, sizeof (recElement)); - if (element) { - pDevice->axes++; - headElement = &(pDevice->firstAxis); - } - } - break; - - case kHIDUsage_GD_Hatswitch: - if (!ElementAlreadyAdded(cookie, pDevice->firstHat)) { - element = (recElement *) SDL_calloc(1, sizeof (recElement)); - if (element) { - pDevice->hats++; - headElement = &(pDevice->firstHat); - } - } - break; - case kHIDUsage_GD_DPadUp: - case kHIDUsage_GD_DPadDown: - case kHIDUsage_GD_DPadRight: - case kHIDUsage_GD_DPadLeft: - case kHIDUsage_GD_Start: - case kHIDUsage_GD_Select: - case kHIDUsage_GD_SystemMainMenu: - if (!ElementAlreadyAdded(cookie, pDevice->firstButton)) { - element = (recElement *) SDL_calloc(1, sizeof (recElement)); - if (element) { - pDevice->buttons++; - headElement = &(pDevice->firstButton); - } - } - break; + case kIOHIDElementTypeInput_Misc: + case kIOHIDElementTypeInput_Button: + case kIOHIDElementTypeInput_Axis: + { + switch (usagePage) { /* only interested in kHIDPage_GenericDesktop and kHIDPage_Button */ + case kHIDPage_GenericDesktop: + switch (usage) { + case kHIDUsage_GD_X: + case kHIDUsage_GD_Y: + case kHIDUsage_GD_Z: + case kHIDUsage_GD_Rx: + case kHIDUsage_GD_Ry: + case kHIDUsage_GD_Rz: + case kHIDUsage_GD_Slider: + case kHIDUsage_GD_Dial: + case kHIDUsage_GD_Wheel: + if (!ElementAlreadyAdded(cookie, pDevice->firstAxis)) { + element = (recElement *)SDL_calloc(1, sizeof(recElement)); + if (element) { + pDevice->axes++; + headElement = &(pDevice->firstAxis); } - break; + } + break; - case kHIDPage_Simulation: - switch (usage) { - case kHIDUsage_Sim_Rudder: - case kHIDUsage_Sim_Throttle: - case kHIDUsage_Sim_Accelerator: - case kHIDUsage_Sim_Brake: - if (!ElementAlreadyAdded(cookie, pDevice->firstAxis)) { - element = (recElement *) SDL_calloc(1, sizeof (recElement)); - if (element) { - pDevice->axes++; - headElement = &(pDevice->firstAxis); - } - } - break; - - default: - break; + case kHIDUsage_GD_Hatswitch: + if (!ElementAlreadyAdded(cookie, pDevice->firstHat)) { + element = (recElement *)SDL_calloc(1, sizeof(recElement)); + if (element) { + pDevice->hats++; + headElement = &(pDevice->firstHat); } - break; - - case kHIDPage_Button: - case kHIDPage_Consumer: /* e.g. 'pause' button on Steelseries MFi gamepads. */ - if (!ElementAlreadyAdded(cookie, pDevice->firstButton)) { - element = (recElement *) SDL_calloc(1, sizeof (recElement)); - if (element) { - pDevice->buttons++; - headElement = &(pDevice->firstButton); - } + } + break; + case kHIDUsage_GD_DPadUp: + case kHIDUsage_GD_DPadDown: + case kHIDUsage_GD_DPadRight: + case kHIDUsage_GD_DPadLeft: + case kHIDUsage_GD_Start: + case kHIDUsage_GD_Select: + case kHIDUsage_GD_SystemMainMenu: + if (!ElementAlreadyAdded(cookie, pDevice->firstButton)) { + element = (recElement *)SDL_calloc(1, sizeof(recElement)); + if (element) { + pDevice->buttons++; + headElement = &(pDevice->firstButton); } - break; - - default: - break; + } + break; } - } - break; + break; - case kIOHIDElementTypeCollection: { - CFArrayRef array = IOHIDElementGetChildren(refElement); - if (array) { - AddHIDElements(array, pDevice); + case kHIDPage_Simulation: + switch (usage) { + case kHIDUsage_Sim_Rudder: + case kHIDUsage_Sim_Throttle: + case kHIDUsage_Sim_Accelerator: + case kHIDUsage_Sim_Brake: + if (!ElementAlreadyAdded(cookie, pDevice->firstAxis)) { + element = (recElement *)SDL_calloc(1, sizeof(recElement)); + if (element) { + pDevice->axes++; + headElement = &(pDevice->firstAxis); + } + } + break; + + default: + break; } - } - break; + break; + + case kHIDPage_Button: + case kHIDPage_Consumer: /* e.g. 'pause' button on Steelseries MFi gamepads. */ + if (!ElementAlreadyAdded(cookie, pDevice->firstButton)) { + element = (recElement *)SDL_calloc(1, sizeof(recElement)); + if (element) { + pDevice->buttons++; + headElement = &(pDevice->firstButton); + } + } + break; default: break; + } + } break; + + case kIOHIDElementTypeCollection: + { + CFArrayRef array = IOHIDElementGetChildren(refElement); + if (array) { + AddHIDElements(array, pDevice); + } + } break; + + default: + break; } - if (element && headElement) { /* add to list */ + if (element && headElement) { /* add to list */ recElement *elementPrevious = NULL; recElement *elementCurrent = *headElement; while (elementCurrent && usage >= elementCurrent->usage) { @@ -407,8 +398,8 @@ AddHIDElement(const void *value, void *parameter) element->usage = usage; element->pNext = elementCurrent; - element->minReport = element->min = (SInt32) IOHIDElementGetLogicalMin(refElement); - element->maxReport = element->max = (SInt32) IOHIDElementGetLogicalMax(refElement); + element->minReport = element->min = (SInt32)IOHIDElementGetLogicalMin(refElement); + element->maxReport = element->max = (SInt32)IOHIDElementGetLogicalMax(refElement); element->cookie = IOHIDElementGetCookie(refElement); pDevice->elements++; @@ -416,9 +407,7 @@ AddHIDElement(const void *value, void *parameter) } } - -static SDL_bool -GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice) +static SDL_bool GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice) { Sint32 vendor = 0; Sint32 product = 0; @@ -508,8 +497,7 @@ GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice) return SDL_TRUE; } -static SDL_bool -JoystickAlreadyKnown(IOHIDDeviceRef ioHIDDeviceObject) +static SDL_bool JoystickAlreadyKnown(IOHIDDeviceRef ioHIDDeviceObject) { recDevice *i; @@ -528,9 +516,7 @@ JoystickAlreadyKnown(IOHIDDeviceRef ioHIDDeviceObject) return SDL_FALSE; } - -static void -JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDeviceRef ioHIDDeviceObject) +static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDeviceRef ioHIDDeviceObject) { recDevice *device; int device_index = 0; @@ -541,10 +527,10 @@ JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDevic } if (JoystickAlreadyKnown(ioHIDDeviceObject)) { - return; /* IOKit sent us a duplicate. */ + return; /* IOKit sent us a duplicate. */ } - device = (recDevice *) SDL_calloc(1, sizeof(recDevice)); + device = (recDevice *)SDL_calloc(1, sizeof(recDevice)); if (device == NULL) { SDL_OutOfMemory(); return; @@ -552,7 +538,7 @@ JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDevic if (!GetDeviceInfo(ioHIDDeviceObject, device)) { FreeDevice(device); - return; /* not a device we care about, probably. */ + return; /* not a device we care about, probably. */ } if (SDL_ShouldIgnoreJoystick(device->product, device->guid)) { @@ -584,19 +570,18 @@ JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDevic recDevice *curdevice; curdevice = gpDeviceList; - while ( curdevice->pNext ) { + while (curdevice->pNext) { ++device_index; curdevice = curdevice->pNext; } curdevice->pNext = device; - ++device_index; /* bump by one since we counted by pNext. */ + ++device_index; /* bump by one since we counted by pNext. */ } SDL_PrivateJoystickAdded(device->instance_id); } -static SDL_bool -ConfigHIDManager(CFArrayRef matchingArray) +static SDL_bool ConfigHIDManager(CFArrayRef matchingArray) { CFRunLoopRef runloop = CFRunLoopGetCurrent(); @@ -608,24 +593,22 @@ ConfigHIDManager(CFArrayRef matchingArray) IOHIDManagerRegisterDeviceMatchingCallback(hidman, JoystickDeviceWasAddedCallback, NULL); IOHIDManagerScheduleWithRunLoop(hidman, runloop, SDL_JOYSTICK_RUNLOOP_MODE); - while (CFRunLoopRunInMode(SDL_JOYSTICK_RUNLOOP_MODE,0,TRUE) == kCFRunLoopRunHandledSource) { + while (CFRunLoopRunInMode(SDL_JOYSTICK_RUNLOOP_MODE, 0, TRUE) == kCFRunLoopRunHandledSource) { /* no-op. Callback fires once per existing device. */ } /* future hotplug events will come through SDL_JOYSTICK_RUNLOOP_MODE now. */ - return SDL_TRUE; /* good to go. */ + return SDL_TRUE; /* good to go. */ } - -static CFDictionaryRef -CreateHIDDeviceMatchDictionary(const UInt32 page, const UInt32 usage, int *okay) +static CFDictionaryRef CreateHIDDeviceMatchDictionary(const UInt32 page, const UInt32 usage, int *okay) { CFDictionaryRef retval = NULL; CFNumberRef pageNumRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page); CFNumberRef usageNumRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage); - const void *keys[2] = { (void *) CFSTR(kIOHIDDeviceUsagePageKey), (void *) CFSTR(kIOHIDDeviceUsageKey) }; - const void *vals[2] = { (void *) pageNumRef, (void *) usageNumRef }; + const void *keys[2] = { (void *)CFSTR(kIOHIDDeviceUsagePageKey), (void *)CFSTR(kIOHIDDeviceUsageKey) }; + const void *vals[2] = { (void *)pageNumRef, (void *)usageNumRef }; if (pageNumRef && usageNumRef) { retval = CFDictionaryCreate(kCFAllocatorDefault, keys, vals, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); @@ -645,15 +628,14 @@ CreateHIDDeviceMatchDictionary(const UInt32 page, const UInt32 usage, int *okay) return retval; } -static SDL_bool -CreateHIDManager(void) +static SDL_bool CreateHIDManager(void) { SDL_bool retval = SDL_FALSE; int okay = 1; const void *vals[] = { - (void *) CreateHIDDeviceMatchDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick, &okay), - (void *) CreateHIDDeviceMatchDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad, &okay), - (void *) CreateHIDDeviceMatchDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_MultiAxisController, &okay), + (void *)CreateHIDDeviceMatchDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick, &okay), + (void *)CreateHIDDeviceMatchDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad, &okay), + (void *)CreateHIDDeviceMatchDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_MultiAxisController, &okay), }; const size_t numElements = SDL_arraysize(vals); CFArrayRef array = okay ? CFArrayCreate(kCFAllocatorDefault, vals, numElements, &kCFTypeArrayCallBacks) : NULL; @@ -661,7 +643,7 @@ CreateHIDManager(void) for (i = 0; i < numElements; i++) { if (vals[i]) { - CFRelease((CFTypeRef) vals[i]); + CFRelease((CFTypeRef)vals[i]); } } @@ -676,9 +658,7 @@ CreateHIDManager(void) return retval; } - -static int -DARWIN_JoystickInit(void) +static int DARWIN_JoystickInit(void) { if (gpDeviceList) { return SDL_SetError("Joystick: Device list already inited."); @@ -691,8 +671,7 @@ DARWIN_JoystickInit(void) return 0; } -static int -DARWIN_JoystickGetCount(void) +static int DARWIN_JoystickGetCount(void) { recDevice *device = gpDeviceList; int nJoySticks = 0; @@ -707,8 +686,7 @@ DARWIN_JoystickGetCount(void) return nJoySticks; } -static void -DARWIN_JoystickDetect(void) +static void DARWIN_JoystickDetect(void) { recDevice *device = gpDeviceList; while (device) { @@ -721,7 +699,7 @@ DARWIN_JoystickDetect(void) /* run this after the checks above so we don't set device->removed and delete the device before DARWIN_JoystickUpdate can run to clean up the SDL_Joystick object that owns this device */ - while (CFRunLoopRunInMode(SDL_JOYSTICK_RUNLOOP_MODE,0,TRUE) == kCFRunLoopRunHandledSource) { + while (CFRunLoopRunInMode(SDL_JOYSTICK_RUNLOOP_MODE, 0, TRUE) == kCFRunLoopRunHandledSource) { /* no-op. Pending callbacks will fire in CFRunLoopRunInMode(). */ } } @@ -739,19 +717,16 @@ DARWIN_JoystickGetDevicePath(int device_index) return NULL; } -static int -DARWIN_JoystickGetDevicePlayerIndex(int device_index) +static int DARWIN_JoystickGetDevicePlayerIndex(int device_index) { return -1; } -static void -DARWIN_JoystickSetDevicePlayerIndex(int device_index, int player_index) +static void DARWIN_JoystickSetDevicePlayerIndex(int device_index, int player_index) { } -static SDL_JoystickGUID -DARWIN_JoystickGetDeviceGUID( int device_index ) +static SDL_JoystickGUID DARWIN_JoystickGetDeviceGUID(int device_index) { recDevice *device = GetDeviceForIndex(device_index); SDL_JoystickGUID guid; @@ -763,15 +738,13 @@ DARWIN_JoystickGetDeviceGUID( int device_index ) return guid; } -static SDL_JoystickID -DARWIN_JoystickGetDeviceInstanceID(int device_index) +static SDL_JoystickID DARWIN_JoystickGetDeviceInstanceID(int device_index) { recDevice *device = GetDeviceForIndex(device_index); return device ? device->instance_id : 0; } -static int -DARWIN_JoystickOpen(SDL_Joystick *joystick, int device_index) +static int DARWIN_JoystickOpen(SDL_Joystick *joystick, int device_index) { recDevice *device = GetDeviceForIndex(device_index); @@ -790,8 +763,7 @@ DARWIN_JoystickOpen(SDL_Joystick *joystick, int device_index) /* * Like strerror but for force feedback errors. */ -static const char * -FFStrError(unsigned int err) +static const char *FFStrError(unsigned int err) { switch (err) { case FFERR_DEVICEFULL: @@ -843,8 +815,7 @@ FFStrError(unsigned int err) } } -static int -DARWIN_JoystickInitRumble(recDevice *device, Sint16 magnitude) +static int DARWIN_JoystickInitRumble(recDevice *device, Sint16 magnitude) { HRESULT result; @@ -873,22 +844,21 @@ DARWIN_JoystickInitRumble(recDevice *device, Sint16 magnitude) } result = FFDeviceCreateEffect(device->ffdevice, kFFEffectType_Sine_ID, - device->ffeffect, &device->ffeffect_ref); + device->ffeffect, &device->ffeffect_ref); if (result != FF_OK) { return SDL_SetError("Haptic: Unable to create effect: %s", FFStrError(result)); } return 0; } -static int -DARWIN_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int DARWIN_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { HRESULT result; recDevice *device = joystick->hwdata; /* Scale and average the two rumble strengths */ Sint16 magnitude = (Sint16)(((low_frequency_rumble / 2) + (high_frequency_rumble / 2)) / 2); - + if (device == NULL) { return SDL_SetError("Rumble failed, device disconnected"); } @@ -902,7 +872,7 @@ DARWIN_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint1 periodic->dwMagnitude = CONVERT_MAGNITUDE(magnitude); result = FFEffectSetParameters(device->ffeffect_ref, device->ffeffect, - (FFEP_DURATION | FFEP_TYPESPECIFICPARAMS)); + (FFEP_DURATION | FFEP_TYPESPECIFICPARAMS)); if (result != FF_OK) { return SDL_SetError("Unable to update rumble effect: %s", FFStrError(result)); } @@ -920,14 +890,12 @@ DARWIN_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint1 return 0; } -static int -DARWIN_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int DARWIN_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static Uint32 -DARWIN_JoystickGetCapabilities(SDL_Joystick *joystick) +static Uint32 DARWIN_JoystickGetCapabilities(SDL_Joystick *joystick) { recDevice *device = joystick->hwdata; Uint32 result = 0; @@ -943,26 +911,22 @@ DARWIN_JoystickGetCapabilities(SDL_Joystick *joystick) return result; } -static int -DARWIN_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int DARWIN_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -DARWIN_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) +static int DARWIN_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -DARWIN_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int DARWIN_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } -static void -DARWIN_JoystickUpdate(SDL_Joystick *joystick) +static void DARWIN_JoystickUpdate(SDL_Joystick *joystick) { recDevice *device = joystick->hwdata; recElement *element; @@ -973,7 +937,7 @@ DARWIN_JoystickUpdate(SDL_Joystick *joystick) return; } - if (device->removed) { /* device was unplugged; ignore it. */ + if (device->removed) { /* device was unplugged; ignore it. */ if (joystick->hwdata) { joystick->hwdata = NULL; } @@ -998,7 +962,7 @@ DARWIN_JoystickUpdate(SDL_Joystick *joystick) while (element) { goodRead = GetHIDElementState(device, element, &value); if (goodRead) { - if (value > 1) { /* handle pressure-sensitive buttons */ + if (value > 1) { /* handle pressure-sensitive buttons */ value = 1; } SDL_PrivateJoystickButton(joystick, i, value); @@ -1010,7 +974,7 @@ DARWIN_JoystickUpdate(SDL_Joystick *joystick) element = device->firstHat; i = 0; - + while (element) { Uint8 pos = 0; @@ -1018,9 +982,9 @@ DARWIN_JoystickUpdate(SDL_Joystick *joystick) goodRead = GetHIDElementState(device, element, &value); if (goodRead) { value -= element->min; - if (range == 4) { /* 4 position hatswitch - scale up value */ + if (range == 4) { /* 4 position hatswitch - scale up value */ value *= 2; - } else if (range != 8) { /* Neither a 4 nor 8 positions - fall back to default position (centered) */ + } else if (range != 8) { /* Neither a 4 nor 8 positions - fall back to default position (centered) */ value = -1; } switch (value) { @@ -1059,14 +1023,13 @@ DARWIN_JoystickUpdate(SDL_Joystick *joystick) SDL_PrivateJoystickHat(joystick, i, pos); } - + element = element->pNext; ++i; } } -static void -DARWIN_JoystickClose(SDL_Joystick *joystick) +static void DARWIN_JoystickClose(SDL_Joystick *joystick) { recDevice *device = joystick->hwdata; if (device) { @@ -1074,8 +1037,7 @@ DARWIN_JoystickClose(SDL_Joystick *joystick) } } -static void -DARWIN_JoystickQuit(void) +static void DARWIN_JoystickQuit(void) { while (FreeDevice(gpDeviceList)) { /* spin */ @@ -1089,14 +1051,12 @@ DARWIN_JoystickQuit(void) } } -static SDL_bool -DARWIN_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static SDL_bool DARWIN_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { return SDL_FALSE; } -SDL_JoystickDriver SDL_DARWIN_JoystickDriver = -{ +SDL_JoystickDriver SDL_DARWIN_JoystickDriver = { DARWIN_JoystickInit, DARWIN_JoystickGetCount, DARWIN_JoystickDetect, diff --git a/src/joystick/darwin/SDL_iokitjoystick_c.h b/src/joystick/darwin/SDL_iokitjoystick_c.h index 369edd130..f0d6f1166 100644 --- a/src/joystick/darwin/SDL_iokitjoystick_c.h +++ b/src/joystick/darwin/SDL_iokitjoystick_c.h @@ -31,35 +31,35 @@ struct recElement { IOHIDElementRef elementRef; IOHIDElementCookie cookie; - uint32_t usagePage, usage; /* HID usage */ - SInt32 min; /* reported min value possible */ - SInt32 max; /* reported max value possible */ + uint32_t usagePage, usage; /* HID usage */ + SInt32 min; /* reported min value possible */ + SInt32 max; /* reported max value possible */ /* runtime variables used for auto-calibration */ - SInt32 minReport; /* min returned value */ - SInt32 maxReport; /* max returned value */ + SInt32 minReport; /* min returned value */ + SInt32 maxReport; /* max returned value */ - struct recElement *pNext; /* next element in list */ + struct recElement *pNext; /* next element in list */ }; typedef struct recElement recElement; struct joystick_hwdata { - IOHIDDeviceRef deviceRef; /* HIDManager device handle */ - io_service_t ffservice; /* Interface for force feedback, 0 = no ff */ + IOHIDDeviceRef deviceRef; /* HIDManager device handle */ + io_service_t ffservice; /* Interface for force feedback, 0 = no ff */ FFDeviceObjectReference ffdevice; FFEFFECT *ffeffect; FFEffectObjectReference ffeffect_ref; SDL_bool ff_initialized; - char product[256]; /* name of product */ - uint32_t usage; /* usage page from IOUSBHID Parser.h which defines general usage */ - uint32_t usagePage; /* usage within above page from IOUSBHID Parser.h which defines specific usage */ + char product[256]; /* name of product */ + uint32_t usage; /* usage page from IOUSBHID Parser.h which defines general usage */ + uint32_t usagePage; /* usage within above page from IOUSBHID Parser.h which defines specific usage */ - int axes; /* number of axis (calculated, not reported by device) */ - int buttons; /* number of buttons (calculated, not reported by device) */ - int hats; /* number of hat switches (calculated, not reported by device) */ - int elements; /* number of total elements (should be total of above) (calculated, not reported by device) */ + int axes; /* number of axis (calculated, not reported by device) */ + int buttons; /* number of buttons (calculated, not reported by device) */ + int hats; /* number of hat switches (calculated, not reported by device) */ + int elements; /* number of total elements (should be total of above) (calculated, not reported by device) */ recElement *firstAxis; recElement *firstButton; @@ -67,12 +67,12 @@ struct joystick_hwdata SDL_bool removed; SDL_Joystick *joystick; - SDL_bool runLoopAttached; /* is 'deviceRef' attached to a CFRunLoop? */ + SDL_bool runLoopAttached; /* is 'deviceRef' attached to a CFRunLoop? */ int instance_id; SDL_JoystickGUID guid; - struct joystick_hwdata *pNext; /* next device */ + struct joystick_hwdata *pNext; /* next device */ }; typedef struct joystick_hwdata recDevice; diff --git a/src/joystick/dummy/SDL_sysjoystick.c b/src/joystick/dummy/SDL_sysjoystick.c index 3cf8da5f9..77feda539 100644 --- a/src/joystick/dummy/SDL_sysjoystick.c +++ b/src/joystick/dummy/SDL_sysjoystick.c @@ -28,126 +28,104 @@ #include "../SDL_sysjoystick.h" #include "../SDL_joystick_c.h" - -static int -DUMMY_JoystickInit(void) +static int DUMMY_JoystickInit(void) { return 0; } -static int -DUMMY_JoystickGetCount(void) +static int DUMMY_JoystickGetCount(void) { return 0; } -static void -DUMMY_JoystickDetect(void) +static void DUMMY_JoystickDetect(void) { } -static const char * -DUMMY_JoystickGetDeviceName(int device_index) +static const char *DUMMY_JoystickGetDeviceName(int device_index) { return NULL; } -static const char * -DUMMY_JoystickGetDevicePath(int device_index) +static const char *DUMMY_JoystickGetDevicePath(int device_index) { return NULL; } -static int -DUMMY_JoystickGetDevicePlayerIndex(int device_index) +static int DUMMY_JoystickGetDevicePlayerIndex(int device_index) { return -1; } -static void -DUMMY_JoystickSetDevicePlayerIndex(int device_index, int player_index) +static void DUMMY_JoystickSetDevicePlayerIndex(int device_index, int player_index) { } -static SDL_JoystickGUID -DUMMY_JoystickGetDeviceGUID(int device_index) +static SDL_JoystickGUID DUMMY_JoystickGetDeviceGUID(int device_index) { SDL_JoystickGUID guid; SDL_zero(guid); return guid; } -static SDL_JoystickID -DUMMY_JoystickGetDeviceInstanceID(int device_index) +static SDL_JoystickID DUMMY_JoystickGetDeviceInstanceID(int device_index) { return -1; } -static int -DUMMY_JoystickOpen(SDL_Joystick *joystick, int device_index) +static int DUMMY_JoystickOpen(SDL_Joystick *joystick, int device_index) { return SDL_SetError("Logic error: No joysticks available"); } -static int -DUMMY_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int DUMMY_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { return SDL_Unsupported(); } -static int -DUMMY_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int DUMMY_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static Uint32 -DUMMY_JoystickGetCapabilities(SDL_Joystick *joystick) +static Uint32 DUMMY_JoystickGetCapabilities(SDL_Joystick *joystick) { return 0; } -static int -DUMMY_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int DUMMY_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -DUMMY_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) +static int DUMMY_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -DUMMY_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int DUMMY_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } -static void -DUMMY_JoystickUpdate(SDL_Joystick *joystick) +static void DUMMY_JoystickUpdate(SDL_Joystick *joystick) { } -static void -DUMMY_JoystickClose(SDL_Joystick *joystick) +static void DUMMY_JoystickClose(SDL_Joystick *joystick) { } -static void -DUMMY_JoystickQuit(void) +static void DUMMY_JoystickQuit(void) { } -static SDL_bool -DUMMY_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static SDL_bool DUMMY_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { return SDL_FALSE; } -SDL_JoystickDriver SDL_DUMMY_JoystickDriver = -{ +SDL_JoystickDriver SDL_DUMMY_JoystickDriver = { DUMMY_JoystickInit, DUMMY_JoystickGetCount, DUMMY_JoystickDetect, diff --git a/src/joystick/emscripten/SDL_sysjoystick.c b/src/joystick/emscripten/SDL_sysjoystick.c index 389f2f466..090eb4f3e 100644 --- a/src/joystick/emscripten/SDL_sysjoystick.c +++ b/src/joystick/emscripten/SDL_sysjoystick.c @@ -32,25 +32,24 @@ #include "SDL_sysjoystick_c.h" #include "../SDL_joystick_c.h" -static SDL_joylist_item * JoystickByIndex(int index); +static SDL_joylist_item *JoystickByIndex(int index); static SDL_joylist_item *SDL_joylist = NULL; static SDL_joylist_item *SDL_joylist_tail = NULL; static int numjoysticks = 0; static int instance_counter = 0; -static EM_BOOL -Emscripten_JoyStickConnected(int eventType, const EmscriptenGamepadEvent *gamepadEvent, void *userData) +static EM_BOOL Emscripten_JoyStickConnected(int eventType, const EmscriptenGamepadEvent *gamepadEvent, void *userData) { int i; SDL_joylist_item *item; if (JoystickByIndex(gamepadEvent->index) != NULL) { - return 1; + return 1; } - item = (SDL_joylist_item *) SDL_malloc(sizeof (SDL_joylist_item)); + item = (SDL_joylist_item *)SDL_malloc(sizeof(SDL_joylist_item)); if (item == NULL) { return 1; } @@ -59,13 +58,13 @@ Emscripten_JoyStickConnected(int eventType, const EmscriptenGamepadEvent *gamepa item->index = gamepadEvent->index; item->name = SDL_CreateJoystickName(0, 0, NULL, gamepadEvent->id); - if ( item->name == NULL ) { + if (item->name == NULL) { SDL_free(item); return 1; } item->mapping = SDL_strdup(gamepadEvent->mapping); - if ( item->mapping == NULL ) { + if (item->mapping == NULL) { SDL_free(item->name); SDL_free(item); return 1; @@ -77,11 +76,11 @@ Emscripten_JoyStickConnected(int eventType, const EmscriptenGamepadEvent *gamepa item->timestamp = gamepadEvent->timestamp; - for ( i = 0; i < item->naxes; i++) { + for (i = 0; i < item->naxes; i++) { item->axis[i] = gamepadEvent->axis[i]; } - for ( i = 0; i < item->nbuttons; i++) { + for (i = 0; i < item->nbuttons; i++) { item->analogButton[i] = gamepadEvent->analogButton[i]; item->digitalButton[i] = gamepadEvent->digitalButton[i]; } @@ -108,8 +107,7 @@ Emscripten_JoyStickConnected(int eventType, const EmscriptenGamepadEvent *gamepa return 1; } -static EM_BOOL -Emscripten_JoyStickDisconnected(int eventType, const EmscriptenGamepadEvent *gamepadEvent, void *userData) +static EM_BOOL Emscripten_JoyStickDisconnected(int eventType, const EmscriptenGamepadEvent *gamepadEvent, void *userData) { SDL_joylist_item *item = SDL_joylist; SDL_joylist_item *prev = NULL; @@ -155,8 +153,7 @@ Emscripten_JoyStickDisconnected(int eventType, const EmscriptenGamepadEvent *gam } /* Function to perform any system-specific joystick related cleanup */ -static void -EMSCRIPTEN_JoystickQuit(void) +static void EMSCRIPTEN_JoystickQuit(void) { SDL_joylist_item *item = NULL; SDL_joylist_item *next = NULL; @@ -180,8 +177,7 @@ EMSCRIPTEN_JoystickQuit(void) /* Function to scan the system for joysticks. * It should return 0, or -1 on an unrecoverable fatal error. */ -static int -EMSCRIPTEN_JoystickInit(void) +static int EMSCRIPTEN_JoystickInit(void) { int retval, i, numjs; EmscriptenGamepadEvent gamepadState; @@ -230,8 +226,7 @@ EMSCRIPTEN_JoystickInit(void) } /* Returns item matching given SDL device index. */ -static SDL_joylist_item * -JoystickByDeviceIndex(int device_index) +static SDL_joylist_item *JoystickByDeviceIndex(int device_index) { SDL_joylist_item *item = SDL_joylist; @@ -244,8 +239,7 @@ JoystickByDeviceIndex(int device_index) } /* Returns item matching given HTML gamepad index. */ -static SDL_joylist_item * -JoystickByIndex(int index) +static SDL_joylist_item *JoystickByIndex(int index) { SDL_joylist_item *item = SDL_joylist; @@ -263,42 +257,35 @@ JoystickByIndex(int index) return item; } -static int -EMSCRIPTEN_JoystickGetCount(void) +static int EMSCRIPTEN_JoystickGetCount(void) { return numjoysticks; } -static void -EMSCRIPTEN_JoystickDetect(void) +static void EMSCRIPTEN_JoystickDetect(void) { } -static const char * -EMSCRIPTEN_JoystickGetDeviceName(int device_index) +static const char *EMSCRIPTEN_JoystickGetDeviceName(int device_index) { return JoystickByDeviceIndex(device_index)->name; } -static const char * -EMSCRIPTEN_JoystickGetDevicePath(int device_index) +static const char *EMSCRIPTEN_JoystickGetDevicePath(int device_index) { return NULL; } -static int -EMSCRIPTEN_JoystickGetDevicePlayerIndex(int device_index) +static int EMSCRIPTEN_JoystickGetDevicePlayerIndex(int device_index) { return -1; } -static void -EMSCRIPTEN_JoystickSetDevicePlayerIndex(int device_index, int player_index) +static void EMSCRIPTEN_JoystickSetDevicePlayerIndex(int device_index, int player_index) { } -static SDL_JoystickID -EMSCRIPTEN_JoystickGetDeviceInstanceID(int device_index) +static SDL_JoystickID EMSCRIPTEN_JoystickGetDeviceInstanceID(int device_index) { return JoystickByDeviceIndex(device_index)->device_instance; } @@ -308,12 +295,11 @@ EMSCRIPTEN_JoystickGetDeviceInstanceID(int device_index) This should fill the nbuttons and naxes fields of the joystick structure. It returns 0, or -1 if there is an error. */ -static int -EMSCRIPTEN_JoystickOpen(SDL_Joystick *joystick, int device_index) +static int EMSCRIPTEN_JoystickOpen(SDL_Joystick *joystick, int device_index) { SDL_joylist_item *item = JoystickByDeviceIndex(device_index); - if (item == NULL ) { + if (item == NULL) { return SDL_SetError("No such device"); } @@ -322,7 +308,7 @@ EMSCRIPTEN_JoystickOpen(SDL_Joystick *joystick, int device_index) } joystick->instance_id = item->device_instance; - joystick->hwdata = (struct joystick_hwdata *) item; + joystick->hwdata = (struct joystick_hwdata *)item; item->joystick = joystick; /* HTML5 Gamepad API doesn't say anything about these */ @@ -340,22 +326,21 @@ EMSCRIPTEN_JoystickOpen(SDL_Joystick *joystick, int device_index) * but instead should call SDL_PrivateJoystick*() to deliver events * and update joystick device state. */ -static void -EMSCRIPTEN_JoystickUpdate(SDL_Joystick *joystick) +static void EMSCRIPTEN_JoystickUpdate(SDL_Joystick *joystick) { EmscriptenGamepadEvent gamepadState; - SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata; + SDL_joylist_item *item = (SDL_joylist_item *)joystick->hwdata; int i, result, buttonState; emscripten_sample_gamepad_data(); if (item) { result = emscripten_get_gamepad_status(item->index, &gamepadState); - if ( result == EMSCRIPTEN_RESULT_SUCCESS) { + if (result == EMSCRIPTEN_RESULT_SUCCESS) { if (gamepadState.timestamp == 0 || gamepadState.timestamp != item->timestamp) { for (i = 0; i < item->nbuttons; i++) { if (item->digitalButton[i] != gamepadState.digitalButton[i]) { - buttonState = gamepadState.digitalButton[i]? SDL_PRESSED: SDL_RELEASED; + buttonState = gamepadState.digitalButton[i] ? SDL_PRESSED : SDL_RELEASED; SDL_PrivateJoystickButton(item->joystick, i, buttonState); } @@ -368,7 +353,7 @@ EMSCRIPTEN_JoystickUpdate(SDL_Joystick *joystick) if (item->axis[i] != gamepadState.axis[i]) { /* do we need to do conversion? */ SDL_PrivateJoystickAxis(item->joystick, i, - (Sint16) (32767.*gamepadState.axis[i])); + (Sint16)(32767. * gamepadState.axis[i])); } /* store to compare in next update */ @@ -382,67 +367,57 @@ EMSCRIPTEN_JoystickUpdate(SDL_Joystick *joystick) } /* Function to close a joystick after use */ -static void -EMSCRIPTEN_JoystickClose(SDL_Joystick *joystick) +static void EMSCRIPTEN_JoystickClose(SDL_Joystick *joystick) { - SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata; + SDL_joylist_item *item = (SDL_joylist_item *)joystick->hwdata; if (item) { item->joystick = NULL; } } -static SDL_JoystickGUID -EMSCRIPTEN_JoystickGetDeviceGUID(int device_index) +static SDL_JoystickGUID EMSCRIPTEN_JoystickGetDeviceGUID(int device_index) { /* the GUID is just the name for now */ const char *name = EMSCRIPTEN_JoystickGetDeviceName(device_index); return SDL_CreateJoystickGUIDForName(name); } -static int -EMSCRIPTEN_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int EMSCRIPTEN_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { return SDL_Unsupported(); } -static int -EMSCRIPTEN_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int EMSCRIPTEN_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static SDL_bool -EMSCRIPTEN_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static SDL_bool EMSCRIPTEN_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { return SDL_FALSE; } -static Uint32 -EMSCRIPTEN_JoystickGetCapabilities(SDL_Joystick *joystick) +static Uint32 EMSCRIPTEN_JoystickGetCapabilities(SDL_Joystick *joystick) { return 0; } -static int -EMSCRIPTEN_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int EMSCRIPTEN_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -EMSCRIPTEN_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) +static int EMSCRIPTEN_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -EMSCRIPTEN_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int EMSCRIPTEN_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } -SDL_JoystickDriver SDL_EMSCRIPTEN_JoystickDriver = -{ +SDL_JoystickDriver SDL_EMSCRIPTEN_JoystickDriver = { EMSCRIPTEN_JoystickInit, EMSCRIPTEN_JoystickGetCount, EMSCRIPTEN_JoystickDetect, diff --git a/src/joystick/emscripten/SDL_sysjoystick_c.h b/src/joystick/emscripten/SDL_sysjoystick_c.h index 815b53aaf..98e1331cb 100644 --- a/src/joystick/emscripten/SDL_sysjoystick_c.h +++ b/src/joystick/emscripten/SDL_sysjoystick_c.h @@ -24,25 +24,24 @@ #ifdef SDL_JOYSTICK_EMSCRIPTEN #include "../SDL_sysjoystick.h" - #include /* A linked list of available joysticks */ typedef struct SDL_joylist_item { - int index; - char *name; - char *mapping; - SDL_JoystickID device_instance; - SDL_Joystick *joystick; - int nbuttons; - int naxes; - double timestamp; - double axis[64]; - double analogButton[64]; - EM_BOOL digitalButton[64]; + int index; + char *name; + char *mapping; + SDL_JoystickID device_instance; + SDL_Joystick *joystick; + int nbuttons; + int naxes; + double timestamp; + double axis[64]; + double analogButton[64]; + EM_BOOL digitalButton[64]; - struct SDL_joylist_item *next; + struct SDL_joylist_item *next; } SDL_joylist_item; typedef SDL_joylist_item joystick_hwdata; diff --git a/src/joystick/hidapi/SDL_hidapi_combined.c b/src/joystick/hidapi/SDL_hidapi_combined.c index df092404c..a8dbe931e 100644 --- a/src/joystick/hidapi/SDL_hidapi_combined.c +++ b/src/joystick/hidapi/SDL_hidapi_combined.c @@ -28,49 +28,40 @@ #include "SDL_hidapijoystick_c.h" #include "../SDL_sysjoystick.h" - -static void -HIDAPI_DriverCombined_RegisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverCombined_RegisterHints(SDL_HintCallback callback, void *userdata) { } -static void -HIDAPI_DriverCombined_UnregisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverCombined_UnregisterHints(SDL_HintCallback callback, void *userdata) { } -static SDL_bool -HIDAPI_DriverCombined_IsEnabled(void) +static SDL_bool HIDAPI_DriverCombined_IsEnabled(void) { return SDL_TRUE; } -static SDL_bool -HIDAPI_DriverCombined_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static SDL_bool HIDAPI_DriverCombined_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { /* This is always explicitly created for combined devices */ return SDL_FALSE; } -static SDL_bool -HIDAPI_DriverCombined_InitDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverCombined_InitDevice(SDL_HIDAPI_Device *device) { return HIDAPI_JoystickConnected(device, NULL); } -static int -HIDAPI_DriverCombined_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) +static int HIDAPI_DriverCombined_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) { return -1; } -static void -HIDAPI_DriverCombined_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) +static void HIDAPI_DriverCombined_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) { } -static SDL_bool -HIDAPI_DriverCombined_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static SDL_bool HIDAPI_DriverCombined_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { int i; char *serial = NULL, *new_serial; @@ -117,8 +108,7 @@ HIDAPI_DriverCombined_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joys return SDL_TRUE; } -static int -HIDAPI_DriverCombined_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int HIDAPI_DriverCombined_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { int i; int result = -1; @@ -132,8 +122,7 @@ HIDAPI_DriverCombined_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *jo return result; } -static int -HIDAPI_DriverCombined_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int HIDAPI_DriverCombined_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { int i; int result = -1; @@ -147,8 +136,7 @@ HIDAPI_DriverCombined_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joys return result; } -static Uint32 -HIDAPI_DriverCombined_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static Uint32 HIDAPI_DriverCombined_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { int i; Uint32 caps = 0; @@ -160,8 +148,7 @@ HIDAPI_DriverCombined_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joy return caps; } -static int -HIDAPI_DriverCombined_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int HIDAPI_DriverCombined_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { int i; int result = -1; @@ -175,14 +162,12 @@ HIDAPI_DriverCombined_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *jo return result; } -static int -HIDAPI_DriverCombined_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) +static int HIDAPI_DriverCombined_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -HIDAPI_DriverCombined_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverCombined_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) { int i; int result = -1; @@ -196,8 +181,7 @@ HIDAPI_DriverCombined_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_J return result; } -static SDL_bool -HIDAPI_DriverCombined_UpdateDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverCombined_UpdateDevice(SDL_HIDAPI_Device *device) { int i; int result = SDL_TRUE; @@ -211,8 +195,7 @@ HIDAPI_DriverCombined_UpdateDevice(SDL_HIDAPI_Device *device) return result; } -static void -HIDAPI_DriverCombined_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static void HIDAPI_DriverCombined_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { int i; @@ -222,13 +205,11 @@ HIDAPI_DriverCombined_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joy } } -static void -HIDAPI_DriverCombined_FreeDevice(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverCombined_FreeDevice(SDL_HIDAPI_Device *device) { } -SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverCombined = -{ +SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverCombined = { "SDL_JOYSTICK_HIDAPI_COMBINED", SDL_TRUE, HIDAPI_DriverCombined_RegisterHints, diff --git a/src/joystick/hidapi/SDL_hidapi_gamecube.c b/src/joystick/hidapi/SDL_hidapi_gamecube.c index 421932836..56ddaa9dd 100644 --- a/src/joystick/hidapi/SDL_hidapi_gamecube.c +++ b/src/joystick/hidapi/SDL_hidapi_gamecube.c @@ -33,7 +33,6 @@ #include "SDL_hidapi_rumble.h" #include "../../hidapi/SDL_hidapi_c.h" - #ifdef SDL_JOYSTICK_HIDAPI_GAMECUBE /* Define this if you want to log all packets from the controller */ @@ -41,42 +40,39 @@ #define MAX_CONTROLLERS 4 -typedef struct { +typedef struct +{ SDL_bool pc_mode; SDL_JoystickID joysticks[MAX_CONTROLLERS]; Uint8 wireless[MAX_CONTROLLERS]; - Uint8 min_axis[MAX_CONTROLLERS*SDL_CONTROLLER_AXIS_MAX]; - Uint8 max_axis[MAX_CONTROLLERS*SDL_CONTROLLER_AXIS_MAX]; + Uint8 min_axis[MAX_CONTROLLERS * SDL_CONTROLLER_AXIS_MAX]; + Uint8 max_axis[MAX_CONTROLLERS * SDL_CONTROLLER_AXIS_MAX]; Uint8 rumbleAllowed[MAX_CONTROLLERS]; - Uint8 rumble[1+MAX_CONTROLLERS]; + Uint8 rumble[1 + MAX_CONTROLLERS]; /* Without this variable, hid_write starts to lag a TON */ SDL_bool rumbleUpdate; SDL_bool m_bUseButtonLabels; SDL_bool useRumbleBrake; } SDL_DriverGameCube_Context; -static void -HIDAPI_DriverGameCube_RegisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverGameCube_RegisterHints(SDL_HintCallback callback, void *userdata) { SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE, callback, userdata); } -static void -HIDAPI_DriverGameCube_UnregisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverGameCube_UnregisterHints(SDL_HintCallback callback, void *userdata) { SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE, callback, userdata); } -static SDL_bool -HIDAPI_DriverGameCube_IsEnabled(void) +static SDL_bool HIDAPI_DriverGameCube_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE, - SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, - SDL_HIDAPI_DEFAULT)); + SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, + SDL_HIDAPI_DEFAULT)); } -static SDL_bool -HIDAPI_DriverGameCube_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static SDL_bool HIDAPI_DriverGameCube_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { if (vendor_id == USB_VENDOR_NINTENDO && product_id == USB_PRODUCT_NINTENDO_GAMECUBE_ADAPTER) { /* Nintendo Co., Ltd. Wii U GameCube Controller Adapter */ @@ -89,15 +85,14 @@ HIDAPI_DriverGameCube_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *n return SDL_FALSE; } -static void -ResetAxisRange(SDL_DriverGameCube_Context *ctx, int joystick_index) +static void ResetAxisRange(SDL_DriverGameCube_Context *ctx, int joystick_index) { - SDL_memset(&ctx->min_axis[joystick_index*SDL_CONTROLLER_AXIS_MAX], 128-88, SDL_CONTROLLER_AXIS_MAX); - SDL_memset(&ctx->max_axis[joystick_index*SDL_CONTROLLER_AXIS_MAX], 128+88, SDL_CONTROLLER_AXIS_MAX); + SDL_memset(&ctx->min_axis[joystick_index * SDL_CONTROLLER_AXIS_MAX], 128 - 88, SDL_CONTROLLER_AXIS_MAX); + SDL_memset(&ctx->max_axis[joystick_index * SDL_CONTROLLER_AXIS_MAX], 128 + 88, SDL_CONTROLLER_AXIS_MAX); /* Trigger axes may have a higher resting value */ - ctx->min_axis[joystick_index*SDL_CONTROLLER_AXIS_MAX+SDL_CONTROLLER_AXIS_TRIGGERLEFT] = 40; - ctx->min_axis[joystick_index*SDL_CONTROLLER_AXIS_MAX+SDL_CONTROLLER_AXIS_TRIGGERRIGHT] = 40; + ctx->min_axis[joystick_index * SDL_CONTROLLER_AXIS_MAX + SDL_CONTROLLER_AXIS_TRIGGERLEFT] = 40; + ctx->min_axis[joystick_index * SDL_CONTROLLER_AXIS_MAX + SDL_CONTROLLER_AXIS_TRIGGERRIGHT] = 40; } static void SDLCALL SDL_GameControllerButtonReportingHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) @@ -130,8 +125,7 @@ static Uint8 RemapButton(SDL_DriverGameCube_Context *ctx, Uint8 button) return button; } -static SDL_bool -HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverGameCube_Context *ctx; Uint8 packet[37]; @@ -222,8 +216,7 @@ HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device) return SDL_TRUE; } -static int -HIDAPI_DriverGameCube_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) +static int HIDAPI_DriverGameCube_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) { SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)device->context; Uint8 i; @@ -236,13 +229,11 @@ HIDAPI_DriverGameCube_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_Joysti return -1; } -static void -HIDAPI_DriverGameCube_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) +static void HIDAPI_DriverGameCube_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) { } -static void -HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device, SDL_DriverGameCube_Context *ctx, Uint8 *packet, int size) +static void HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device, SDL_DriverGameCube_Context *ctx, Uint8 *packet, int size) { SDL_Joystick *joystick; Uint8 i, v; @@ -263,12 +254,11 @@ HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device, SDL_Driver return; } - #define READ_BUTTON(off, flag, button) \ - SDL_PrivateJoystickButton( \ - joystick, \ - RemapButton(ctx, button), \ - (packet[off] & flag) ? SDL_PRESSED : SDL_RELEASED \ - ); +#define READ_BUTTON(off, flag, button) \ + SDL_PrivateJoystickButton( \ + joystick, \ + RemapButton(ctx, button), \ + (packet[off] & flag) ? SDL_PRESSED : SDL_RELEASED); READ_BUTTON(1, 0x02, 0) /* A */ READ_BUTTON(1, 0x04, 1) /* B */ READ_BUTTON(1, 0x01, 2) /* X */ @@ -285,28 +275,28 @@ HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device, SDL_Driver */ READ_BUTTON(1, 0x20, 10) /* TRIGGERRIGHT */ READ_BUTTON(1, 0x10, 11) /* TRIGGERLEFT */ - #undef READ_BUTTON +#undef READ_BUTTON - #define READ_AXIS(off, axis, invert) \ - v = invert ? (0xff - packet[off]) : packet[off]; \ - if (v < ctx->min_axis[i*SDL_CONTROLLER_AXIS_MAX+axis]) ctx->min_axis[i*SDL_CONTROLLER_AXIS_MAX+axis] = v; \ - if (v > ctx->max_axis[i*SDL_CONTROLLER_AXIS_MAX+axis]) ctx->max_axis[i*SDL_CONTROLLER_AXIS_MAX+axis] = v; \ - axis_value = (Sint16)HIDAPI_RemapVal(v, ctx->min_axis[i*SDL_CONTROLLER_AXIS_MAX+axis], ctx->max_axis[i*SDL_CONTROLLER_AXIS_MAX+axis], SDL_MIN_SINT16, SDL_MAX_SINT16); \ - SDL_PrivateJoystickAxis( \ - joystick, \ - axis, axis_value \ - ); +#define READ_AXIS(off, axis, invert) \ + v = invert ? (0xff - packet[off]) : packet[off]; \ + if (v < ctx->min_axis[i * SDL_CONTROLLER_AXIS_MAX + axis]) \ + ctx->min_axis[i * SDL_CONTROLLER_AXIS_MAX + axis] = v; \ + if (v > ctx->max_axis[i * SDL_CONTROLLER_AXIS_MAX + axis]) \ + ctx->max_axis[i * SDL_CONTROLLER_AXIS_MAX + axis] = v; \ + axis_value = (Sint16)HIDAPI_RemapVal(v, ctx->min_axis[i * SDL_CONTROLLER_AXIS_MAX + axis], ctx->max_axis[i * SDL_CONTROLLER_AXIS_MAX + axis], SDL_MIN_SINT16, SDL_MAX_SINT16); \ + SDL_PrivateJoystickAxis( \ + joystick, \ + axis, axis_value); READ_AXIS(3, SDL_CONTROLLER_AXIS_LEFTX, 0) READ_AXIS(4, SDL_CONTROLLER_AXIS_LEFTY, 0) READ_AXIS(6, SDL_CONTROLLER_AXIS_RIGHTX, 1) READ_AXIS(5, SDL_CONTROLLER_AXIS_RIGHTY, 1) READ_AXIS(7, SDL_CONTROLLER_AXIS_TRIGGERLEFT, 0) READ_AXIS(8, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, 0) - #undef READ_AXIS +#undef READ_AXIS } -static void -HIDAPI_DriverGameCube_HandleNintendoPacket(SDL_HIDAPI_Device *device, SDL_DriverGameCube_Context *ctx, Uint8 *packet, int size) +static void HIDAPI_DriverGameCube_HandleNintendoPacket(SDL_HIDAPI_Device *device, SDL_DriverGameCube_Context *ctx, Uint8 *packet, int size) { SDL_Joystick *joystick; Uint8 *curSlot; @@ -344,12 +334,11 @@ HIDAPI_DriverGameCube_HandleNintendoPacket(SDL_HIDAPI_Device *device, SDL_Driver continue; } - #define READ_BUTTON(off, flag, button) \ - SDL_PrivateJoystickButton( \ - joystick, \ - RemapButton(ctx, button), \ - (curSlot[off] & flag) ? SDL_PRESSED : SDL_RELEASED \ - ); +#define READ_BUTTON(off, flag, button) \ + SDL_PrivateJoystickButton( \ + joystick, \ + RemapButton(ctx, button), \ + (curSlot[off] & flag) ? SDL_PRESSED : SDL_RELEASED); READ_BUTTON(1, 0x01, 0) /* A */ READ_BUTTON(1, 0x04, 1) /* B */ READ_BUTTON(1, 0x02, 2) /* X */ @@ -366,28 +355,28 @@ HIDAPI_DriverGameCube_HandleNintendoPacket(SDL_HIDAPI_Device *device, SDL_Driver */ READ_BUTTON(2, 0x04, 10) /* TRIGGERRIGHT */ READ_BUTTON(2, 0x08, 11) /* TRIGGERLEFT */ - #undef READ_BUTTON +#undef READ_BUTTON - #define READ_AXIS(off, axis) \ - if (curSlot[off] < ctx->min_axis[i*SDL_CONTROLLER_AXIS_MAX+axis]) ctx->min_axis[i*SDL_CONTROLLER_AXIS_MAX+axis] = curSlot[off]; \ - if (curSlot[off] > ctx->max_axis[i*SDL_CONTROLLER_AXIS_MAX+axis]) ctx->max_axis[i*SDL_CONTROLLER_AXIS_MAX+axis] = curSlot[off]; \ - axis_value = (Sint16)HIDAPI_RemapVal(curSlot[off], ctx->min_axis[i*SDL_CONTROLLER_AXIS_MAX+axis], ctx->max_axis[i*SDL_CONTROLLER_AXIS_MAX+axis], SDL_MIN_SINT16, SDL_MAX_SINT16); \ - SDL_PrivateJoystickAxis( \ - joystick, \ - axis, axis_value \ - ); +#define READ_AXIS(off, axis) \ + if (curSlot[off] < ctx->min_axis[i * SDL_CONTROLLER_AXIS_MAX + axis]) \ + ctx->min_axis[i * SDL_CONTROLLER_AXIS_MAX + axis] = curSlot[off]; \ + if (curSlot[off] > ctx->max_axis[i * SDL_CONTROLLER_AXIS_MAX + axis]) \ + ctx->max_axis[i * SDL_CONTROLLER_AXIS_MAX + axis] = curSlot[off]; \ + axis_value = (Sint16)HIDAPI_RemapVal(curSlot[off], ctx->min_axis[i * SDL_CONTROLLER_AXIS_MAX + axis], ctx->max_axis[i * SDL_CONTROLLER_AXIS_MAX + axis], SDL_MIN_SINT16, SDL_MAX_SINT16); \ + SDL_PrivateJoystickAxis( \ + joystick, \ + axis, axis_value); READ_AXIS(3, SDL_CONTROLLER_AXIS_LEFTX) READ_AXIS(4, SDL_CONTROLLER_AXIS_LEFTY) READ_AXIS(5, SDL_CONTROLLER_AXIS_RIGHTX) READ_AXIS(6, SDL_CONTROLLER_AXIS_RIGHTY) READ_AXIS(7, SDL_CONTROLLER_AXIS_TRIGGERLEFT) READ_AXIS(8, SDL_CONTROLLER_AXIS_TRIGGERRIGHT) - #undef READ_AXIS +#undef READ_AXIS } } -static SDL_bool -HIDAPI_DriverGameCube_UpdateDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverGameCube_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)device->context; Uint8 packet[USB_PACKET_LENGTH]; @@ -396,7 +385,7 @@ HIDAPI_DriverGameCube_UpdateDevice(SDL_HIDAPI_Device *device) /* Read input packet */ while ((size = SDL_hid_read_timeout(device->dev, packet, sizeof(packet), 0)) > 0) { #ifdef DEBUG_GAMECUBE_PROTOCOL - //HIDAPI_DumpPacket("Nintendo GameCube packet: size = %d", packet, size); + // HIDAPI_DumpPacket("Nintendo GameCube packet: size = %d", packet, size); #endif if (ctx->pc_mode) { HIDAPI_DriverGameCube_HandleJoystickPacket(device, ctx, packet, size); @@ -415,8 +404,7 @@ HIDAPI_DriverGameCube_UpdateDevice(SDL_HIDAPI_Device *device) return SDL_TRUE; } -static SDL_bool -HIDAPI_DriverGameCube_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static SDL_bool HIDAPI_DriverGameCube_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)device->context; Uint8 i; @@ -431,8 +419,7 @@ HIDAPI_DriverGameCube_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joys return SDL_FALSE; /* Should never get here! */ } -static int -HIDAPI_DriverGameCube_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int HIDAPI_DriverGameCube_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)device->context; Uint8 i, val; @@ -472,14 +459,12 @@ HIDAPI_DriverGameCube_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *jo return SDL_SetError("Couldn't find joystick"); } -static int -HIDAPI_DriverGameCube_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int HIDAPI_DriverGameCube_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static Uint32 -HIDAPI_DriverGameCube_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static Uint32 HIDAPI_DriverGameCube_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)device->context; Uint32 result = 0; @@ -500,26 +485,22 @@ HIDAPI_DriverGameCube_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joy return result; } -static int -HIDAPI_DriverGameCube_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int HIDAPI_DriverGameCube_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -HIDAPI_DriverGameCube_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) +static int HIDAPI_DriverGameCube_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -HIDAPI_DriverGameCube_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverGameCube_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } -static void -HIDAPI_DriverGameCube_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static void HIDAPI_DriverGameCube_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)device->context; @@ -530,8 +511,7 @@ HIDAPI_DriverGameCube_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joy } } -static void -HIDAPI_DriverGameCube_FreeDevice(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverGameCube_FreeDevice(SDL_HIDAPI_Device *device) { SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)device->context; @@ -541,8 +521,7 @@ HIDAPI_DriverGameCube_FreeDevice(SDL_HIDAPI_Device *device) SDL_JoystickGameCubeRumbleBrakeHintChanged, ctx); } -SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverGameCube = -{ +SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverGameCube = { SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE, SDL_TRUE, HIDAPI_DriverGameCube_RegisterHints, diff --git a/src/joystick/hidapi/SDL_hidapi_luna.c b/src/joystick/hidapi/SDL_hidapi_luna.c index 173e0a02d..5c2a7f426 100644 --- a/src/joystick/hidapi/SDL_hidapi_luna.c +++ b/src/joystick/hidapi/SDL_hidapi_luna.c @@ -29,7 +29,6 @@ #include "SDL_hidapijoystick_c.h" #include "SDL_hidapi_rumble.h" - #ifdef SDL_JOYSTICK_HIDAPI_LUNA /* Define this if you want to log all packets from the controller */ @@ -46,37 +45,32 @@ enum SDL_CONTROLLER_NUM_LUNA_BUTTONS, }; -typedef struct { +typedef struct +{ Uint8 last_state[USB_PACKET_LENGTH]; } SDL_DriverLuna_Context; - -static void -HIDAPI_DriverLuna_RegisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverLuna_RegisterHints(SDL_HintCallback callback, void *userdata) { SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_LUNA, callback, userdata); } -static void -HIDAPI_DriverLuna_UnregisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverLuna_UnregisterHints(SDL_HintCallback callback, void *userdata) { SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_LUNA, callback, userdata); } -static SDL_bool -HIDAPI_DriverLuna_IsEnabled(void) +static SDL_bool HIDAPI_DriverLuna_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_LUNA, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); } -static SDL_bool -HIDAPI_DriverLuna_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static SDL_bool HIDAPI_DriverLuna_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { return (type == SDL_CONTROLLER_TYPE_AMAZON_LUNA) ? SDL_TRUE : SDL_FALSE; } -static SDL_bool -HIDAPI_DriverLuna_InitDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverLuna_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverLuna_Context *ctx; @@ -93,19 +87,16 @@ HIDAPI_DriverLuna_InitDevice(SDL_HIDAPI_Device *device) return HIDAPI_JoystickConnected(device, NULL); } -static int -HIDAPI_DriverLuna_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) +static int HIDAPI_DriverLuna_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) { return -1; } -static void -HIDAPI_DriverLuna_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) +static void HIDAPI_DriverLuna_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) { } -static SDL_bool -HIDAPI_DriverLuna_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static SDL_bool HIDAPI_DriverLuna_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverLuna_Context *ctx = (SDL_DriverLuna_Context *)device->context; @@ -119,8 +110,7 @@ HIDAPI_DriverLuna_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick return SDL_TRUE; } -static int -HIDAPI_DriverLuna_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int HIDAPI_DriverLuna_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { #ifdef ENABLE_LUNA_BLUETOOTH_RUMBLE if (device->product_id == BLUETOOTH_PRODUCT_LUNA_CONTROLLER) { @@ -139,18 +129,16 @@ HIDAPI_DriverLuna_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joysti } #endif /* ENABLE_LUNA_BLUETOOTH_RUMBLE */ - /* There is currently no rumble packet over USB */ - return SDL_Unsupported(); + /* There is currently no rumble packet over USB */ + return SDL_Unsupported(); } -static int -HIDAPI_DriverLuna_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int HIDAPI_DriverLuna_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static Uint32 -HIDAPI_DriverLuna_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static Uint32 HIDAPI_DriverLuna_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { Uint32 result = 0; @@ -163,26 +151,22 @@ HIDAPI_DriverLuna_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystic return result; } -static int -HIDAPI_DriverLuna_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int HIDAPI_DriverLuna_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -HIDAPI_DriverLuna_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) +static int HIDAPI_DriverLuna_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -HIDAPI_DriverLuna_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverLuna_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } -static void -HIDAPI_DriverLuna_HandleUSBStatePacket(SDL_Joystick *joystick, SDL_DriverLuna_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverLuna_HandleUSBStatePacket(SDL_Joystick *joystick, SDL_DriverLuna_Context *ctx, Uint8 *data, int size) { if (ctx->last_state[1] != data[1]) { SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_A, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED); @@ -246,8 +230,7 @@ HIDAPI_DriverLuna_HandleUSBStatePacket(SDL_Joystick *joystick, SDL_DriverLuna_Co } #define READ_STICK_AXIS(offset) \ - (data[offset] == 0x7f ? 0 : \ - (Sint16)HIDAPI_RemapVal((float)data[offset], 0x00, 0xff, SDL_MIN_SINT16, SDL_MAX_SINT16)) + (data[offset] == 0x7f ? 0 : (Sint16)HIDAPI_RemapVal((float)data[offset], 0x00, 0xff, SDL_MIN_SINT16, SDL_MAX_SINT16)) { Sint16 axis = READ_STICK_AXIS(4); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis); @@ -261,7 +244,7 @@ HIDAPI_DriverLuna_HandleUSBStatePacket(SDL_Joystick *joystick, SDL_DriverLuna_Co #undef READ_STICK_AXIS #define READ_TRIGGER_AXIS(offset) \ - (Sint16)HIDAPI_RemapVal((float)data[offset], 0x00, 0xff, SDL_MIN_SINT16, SDL_MAX_SINT16) + (Sint16) HIDAPI_RemapVal((float)data[offset], 0x00, 0xff, SDL_MIN_SINT16, SDL_MAX_SINT16) { Sint16 axis = READ_TRIGGER_AXIS(8); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis); @@ -273,8 +256,7 @@ HIDAPI_DriverLuna_HandleUSBStatePacket(SDL_Joystick *joystick, SDL_DriverLuna_Co SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); } -static void -HIDAPI_DriverLuna_HandleBluetoothStatePacket(SDL_Joystick *joystick, SDL_DriverLuna_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverLuna_HandleBluetoothStatePacket(SDL_Joystick *joystick, SDL_DriverLuna_Context *ctx, Uint8 *data, int size) { if (size >= 2 && data[0] == 0x02) { /* Home button has dedicated report */ @@ -366,8 +348,7 @@ HIDAPI_DriverLuna_HandleBluetoothStatePacket(SDL_Joystick *joystick, SDL_DriverL } #define READ_STICK_AXIS(offset) \ - (data[offset] == 0x7f ? 0 : \ - (Sint16)HIDAPI_RemapVal((float)data[offset], 0x00, 0xff, SDL_MIN_SINT16, SDL_MAX_SINT16)) + (data[offset] == 0x7f ? 0 : (Sint16)HIDAPI_RemapVal((float)data[offset], 0x00, 0xff, SDL_MIN_SINT16, SDL_MAX_SINT16)) { Sint16 axis = READ_STICK_AXIS(2); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis); @@ -381,7 +362,7 @@ HIDAPI_DriverLuna_HandleBluetoothStatePacket(SDL_Joystick *joystick, SDL_DriverL #undef READ_STICK_AXIS #define READ_TRIGGER_AXIS(offset) \ - (Sint16)HIDAPI_RemapVal((float)((int)(((data[offset] | (data[offset + 1] << 8)) & 0x3ff) - 0x200)), 0x00 - 0x200, 0x3ff - 0x200, SDL_MIN_SINT16, SDL_MAX_SINT16) + (Sint16) HIDAPI_RemapVal((float)((int)(((data[offset] | (data[offset + 1] << 8)) & 0x3ff) - 0x200)), 0x00 - 0x200, 0x3ff - 0x200, SDL_MIN_SINT16, SDL_MAX_SINT16) { Sint16 axis = READ_TRIGGER_AXIS(9); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis); @@ -393,8 +374,7 @@ HIDAPI_DriverLuna_HandleBluetoothStatePacket(SDL_Joystick *joystick, SDL_DriverL SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); } -static SDL_bool -HIDAPI_DriverLuna_UpdateDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverLuna_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverLuna_Context *ctx = (SDL_DriverLuna_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -432,18 +412,15 @@ HIDAPI_DriverLuna_UpdateDevice(SDL_HIDAPI_Device *device) return size >= 0; } -static void -HIDAPI_DriverLuna_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static void HIDAPI_DriverLuna_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { } -static void -HIDAPI_DriverLuna_FreeDevice(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverLuna_FreeDevice(SDL_HIDAPI_Device *device) { } -SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverLuna = -{ +SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverLuna = { SDL_HINT_JOYSTICK_HIDAPI_LUNA, SDL_TRUE, HIDAPI_DriverLuna_RegisterHints, diff --git a/src/joystick/hidapi/SDL_hidapi_nintendo.h b/src/joystick/hidapi/SDL_hidapi_nintendo.h index e95d5b4af..6ca33ad3d 100644 --- a/src/joystick/hidapi/SDL_hidapi_nintendo.h +++ b/src/joystick/hidapi/SDL_hidapi_nintendo.h @@ -22,25 +22,27 @@ /* These are values used in the controller type byte of the controller GUID */ /* These values come directly out of the hardware, so don't change them */ -typedef enum { - k_eSwitchDeviceInfoControllerType_Unknown = 0, - k_eSwitchDeviceInfoControllerType_JoyConLeft = 1, - k_eSwitchDeviceInfoControllerType_JoyConRight = 2, - k_eSwitchDeviceInfoControllerType_ProController = 3, - k_eSwitchDeviceInfoControllerType_NESLeft = 9, - k_eSwitchDeviceInfoControllerType_NESRight = 10, - k_eSwitchDeviceInfoControllerType_SNES = 11, - k_eSwitchDeviceInfoControllerType_N64 = 12, - k_eSwitchDeviceInfoControllerType_SEGA_Genesis = 13, +typedef enum +{ + k_eSwitchDeviceInfoControllerType_Unknown = 0, + k_eSwitchDeviceInfoControllerType_JoyConLeft = 1, + k_eSwitchDeviceInfoControllerType_JoyConRight = 2, + k_eSwitchDeviceInfoControllerType_ProController = 3, + k_eSwitchDeviceInfoControllerType_NESLeft = 9, + k_eSwitchDeviceInfoControllerType_NESRight = 10, + k_eSwitchDeviceInfoControllerType_SNES = 11, + k_eSwitchDeviceInfoControllerType_N64 = 12, + k_eSwitchDeviceInfoControllerType_SEGA_Genesis = 13, } ESwitchDeviceInfoControllerType; /* These values are used internally but can be updated as needed */ -typedef enum { - k_eWiiExtensionControllerType_Unknown = 0, - k_eWiiExtensionControllerType_None = 128, - k_eWiiExtensionControllerType_Nunchuk = 129, - k_eWiiExtensionControllerType_Gamepad = 130, - k_eWiiExtensionControllerType_WiiUPro = 131, +typedef enum +{ + k_eWiiExtensionControllerType_Unknown = 0, + k_eWiiExtensionControllerType_None = 128, + k_eWiiExtensionControllerType_Nunchuk = 129, + k_eWiiExtensionControllerType_Gamepad = 130, + k_eWiiExtensionControllerType_WiiUPro = 131, } EWiiExtensionControllerType; /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/joystick/hidapi/SDL_hidapi_ps3.c b/src/joystick/hidapi/SDL_hidapi_ps3.c index f77f91e16..ba775276b 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps3.c +++ b/src/joystick/hidapi/SDL_hidapi_ps3.c @@ -32,13 +32,12 @@ #include "SDL_hidapijoystick_c.h" #include "SDL_hidapi_rumble.h" - #ifdef SDL_JOYSTICK_HIDAPI_PS3 /* Define this if you want to log all packets from the controller */ /*#define DEBUG_PS3_PROTOCOL*/ -#define LOAD16(A, B) (Sint16)((Uint16)(A) | (((Uint16)(B)) << 8)) +#define LOAD16(A, B) (Sint16)((Uint16)(A) | (((Uint16)(B)) << 8)) typedef enum { @@ -46,7 +45,8 @@ typedef enum k_EPS3ReportIdEffects = 1, } EPS3ReportId; -typedef struct { +typedef struct +{ SDL_HIDAPI_Device *device; SDL_Joystick *joystick; SDL_bool is_shanwan; @@ -58,23 +58,19 @@ typedef struct { Uint8 last_state[USB_PACKET_LENGTH]; } SDL_DriverPS3_Context; - static int HIDAPI_DriverPS3_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *effect, int size); -static void -HIDAPI_DriverPS3_RegisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverPS3_RegisterHints(SDL_HintCallback callback, void *userdata) { SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS3, callback, userdata); } -static void -HIDAPI_DriverPS3_UnregisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverPS3_UnregisterHints(SDL_HintCallback callback, void *userdata) { SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS3, callback, userdata); } -static SDL_bool -HIDAPI_DriverPS3_IsEnabled(void) +static SDL_bool HIDAPI_DriverPS3_IsEnabled(void) { SDL_bool default_value; @@ -105,8 +101,7 @@ HIDAPI_DriverPS3_IsEnabled(void) return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS3, default_value); } -static SDL_bool -HIDAPI_DriverPS3_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static SDL_bool HIDAPI_DriverPS3_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { if (vendor_id == USB_VENDOR_SONY && product_id == USB_PRODUCT_SONY_DS3) { return SDL_TRUE; @@ -129,8 +124,7 @@ static int SendFeatureReport(SDL_hid_device *dev, Uint8 *report, size_t length) return SDL_hid_send_feature_report(dev, report, length); } -static SDL_bool -HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverPS3_Context *ctx; SDL_bool is_shanwan = SDL_FALSE; @@ -194,14 +188,12 @@ HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device) return HIDAPI_JoystickConnected(device, NULL); } -static int -HIDAPI_DriverPS3_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) +static int HIDAPI_DriverPS3_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) { return -1; } -static int -HIDAPI_DriverPS3_UpdateEffects(SDL_HIDAPI_Device *device) +static int HIDAPI_DriverPS3_UpdateEffects(SDL_HIDAPI_Device *device) { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; @@ -218,13 +210,12 @@ HIDAPI_DriverPS3_UpdateEffects(SDL_HIDAPI_Device *device) effects[2] = ctx->rumble_right ? 1 : 0; effects[4] = ctx->rumble_left; - effects[9] = (0x01 << (1+(ctx->player_index % 4))); + effects[9] = (0x01 << (1 + (ctx->player_index % 4))); return HIDAPI_DriverPS3_SendJoystickEffect(device, ctx->joystick, effects, sizeof(effects)); } -static void -HIDAPI_DriverPS3_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) +static void HIDAPI_DriverPS3_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; @@ -238,8 +229,7 @@ HIDAPI_DriverPS3_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID HIDAPI_DriverPS3_UpdateEffects(device); } -static SDL_bool -HIDAPI_DriverPS3_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static SDL_bool HIDAPI_DriverPS3_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; @@ -262,8 +252,7 @@ HIDAPI_DriverPS3_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) return SDL_TRUE; } -static int -HIDAPI_DriverPS3_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int HIDAPI_DriverPS3_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; @@ -273,26 +262,22 @@ HIDAPI_DriverPS3_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystic return HIDAPI_DriverPS3_UpdateEffects(device); } -static int -HIDAPI_DriverPS3_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int HIDAPI_DriverPS3_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static Uint32 -HIDAPI_DriverPS3_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static Uint32 HIDAPI_DriverPS3_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { return SDL_JOYCAP_RUMBLE; } -static int -HIDAPI_DriverPS3_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int HIDAPI_DriverPS3_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -HIDAPI_DriverPS3_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *effect, int size) +static int HIDAPI_DriverPS3_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *effect, int size) { Uint8 data[49]; int report_size, offset; @@ -310,8 +295,7 @@ HIDAPI_DriverPS3_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joy return 0; } -static int -HIDAPI_DriverPS3_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverPS3_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; @@ -320,16 +304,14 @@ HIDAPI_DriverPS3_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joysti return 0; } -static float -HIDAPI_DriverPS3_ScaleAccel(Sint16 value) +static float HIDAPI_DriverPS3_ScaleAccel(Sint16 value) { /* Accelerometer values are in big endian order */ value = SDL_SwapBE16(value); return (float)(value - 511) / 113.0f; } -static void -HIDAPI_DriverPS3_HandleMiniStatePacket(SDL_Joystick *joystick, SDL_DriverPS3_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverPS3_HandleMiniStatePacket(SDL_Joystick *joystick, SDL_DriverPS3_Context *ctx, Uint8 *data, int size) { Sint16 axis; @@ -405,8 +387,7 @@ HIDAPI_DriverPS3_HandleMiniStatePacket(SDL_Joystick *joystick, SDL_DriverPS3_Con SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); } -static void -HIDAPI_DriverPS3_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverPS3_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverPS3_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverPS3_Context *ctx, Uint8 *data, int size) { Sint16 axis; @@ -493,8 +474,7 @@ HIDAPI_DriverPS3_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverPS3_Context SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); } -static SDL_bool -HIDAPI_DriverPS3_UpdateDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverPS3_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -556,21 +536,18 @@ HIDAPI_DriverPS3_UpdateDevice(SDL_HIDAPI_Device *device) return size >= 0; } -static void -HIDAPI_DriverPS3_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static void HIDAPI_DriverPS3_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; ctx->joystick = NULL; } -static void -HIDAPI_DriverPS3_FreeDevice(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverPS3_FreeDevice(SDL_HIDAPI_Device *device) { } -SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS3 = -{ +SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS3 = { SDL_HINT_JOYSTICK_HIDAPI_PS3, SDL_TRUE, HIDAPI_DriverPS3_RegisterHints, @@ -592,21 +569,18 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS3 = HIDAPI_DriverPS3_FreeDevice, }; - -static SDL_bool -HIDAPI_DriverPS3ThirdParty_IsEnabled(void) +static SDL_bool HIDAPI_DriverPS3ThirdParty_IsEnabled(void) { #if 1 /* Not enabled by default, we don't know what the L3/R3 buttons are */ return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS3, SDL_FALSE); #else return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS3, - SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, - SDL_HIDAPI_DEFAULT)); + SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, + SDL_HIDAPI_DEFAULT)); #endif } -static SDL_bool -HIDAPI_DriverPS3ThirdParty_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static SDL_bool HIDAPI_DriverPS3ThirdParty_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { Uint8 data[USB_PACKET_LENGTH]; int size; @@ -628,8 +602,7 @@ HIDAPI_DriverPS3ThirdParty_IsSupportedDevice(SDL_HIDAPI_Device *device, const ch return SDL_FALSE; } -static SDL_bool -HIDAPI_DriverPS3ThirdParty_InitDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverPS3ThirdParty_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverPS3_Context *ctx; @@ -647,19 +620,16 @@ HIDAPI_DriverPS3ThirdParty_InitDevice(SDL_HIDAPI_Device *device) return HIDAPI_JoystickConnected(device, NULL); } -static int -HIDAPI_DriverPS3ThirdParty_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) +static int HIDAPI_DriverPS3ThirdParty_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) { return -1; } -static void -HIDAPI_DriverPS3ThirdParty_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) +static void HIDAPI_DriverPS3ThirdParty_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) { } -static SDL_bool -HIDAPI_DriverPS3ThirdParty_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static SDL_bool HIDAPI_DriverPS3ThirdParty_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; @@ -674,44 +644,37 @@ HIDAPI_DriverPS3ThirdParty_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick return SDL_TRUE; } -static int -HIDAPI_DriverPS3ThirdParty_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int HIDAPI_DriverPS3ThirdParty_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { return SDL_Unsupported(); } -static int -HIDAPI_DriverPS3ThirdParty_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int HIDAPI_DriverPS3ThirdParty_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static Uint32 -HIDAPI_DriverPS3ThirdParty_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static Uint32 HIDAPI_DriverPS3ThirdParty_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { return 0; } -static int -HIDAPI_DriverPS3ThirdParty_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int HIDAPI_DriverPS3ThirdParty_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -HIDAPI_DriverPS3ThirdParty_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *effect, int size) +static int HIDAPI_DriverPS3ThirdParty_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *effect, int size) { return SDL_Unsupported(); } -static int -HIDAPI_DriverPS3ThirdParty_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverPS3ThirdParty_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } -static void -HIDAPI_DriverPS3ThirdParty_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverPS3_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverPS3_Context *ctx, Uint8 *data, int size) { Sint16 axis; @@ -824,8 +787,7 @@ HIDAPI_DriverPS3ThirdParty_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverP SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); } -static SDL_bool -HIDAPI_DriverPS3ThirdParty_UpdateDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverPS3ThirdParty_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -862,21 +824,18 @@ HIDAPI_DriverPS3ThirdParty_UpdateDevice(SDL_HIDAPI_Device *device) return size >= 0; } -static void -HIDAPI_DriverPS3ThirdParty_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static void HIDAPI_DriverPS3ThirdParty_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; ctx->joystick = NULL; } -static void -HIDAPI_DriverPS3ThirdParty_FreeDevice(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverPS3ThirdParty_FreeDevice(SDL_HIDAPI_Device *device) { } -SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS3ThirdParty = -{ +SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS3ThirdParty = { SDL_HINT_JOYSTICK_HIDAPI_PS3, SDL_TRUE, HIDAPI_DriverPS3_RegisterHints, diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c index ee04a9588..e17e5002f 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps4.c +++ b/src/joystick/hidapi/SDL_hidapi_ps4.c @@ -34,7 +34,6 @@ #include "SDL_hidapijoystick_c.h" #include "SDL_hidapi_rumble.h" - #ifdef SDL_JOYSTICK_HIDAPI_PS4 /* Define this if you want to log all packets from the controller */ @@ -43,14 +42,14 @@ /* Define this if you want to log calibration data */ /*#define DEBUG_PS4_CALIBRATION*/ -#define GYRO_RES_PER_DEGREE 1024.0f -#define ACCEL_RES_PER_G 8192.0f +#define GYRO_RES_PER_DEGREE 1024.0f +#define ACCEL_RES_PER_G 8192.0f #define BLUETOOTH_DISCONNECT_TIMEOUT_MS 500 -#define LOAD16(A, B) (Sint16)((Uint16)(A) | (((Uint16)(B)) << 8)) -#define LOAD32(A, B, C, D) ((((Uint32)(A)) << 0) | \ - (((Uint32)(B)) << 8) | \ - (((Uint32)(C)) << 16) | \ +#define LOAD16(A, B) (Sint16)((Uint16)(A) | (((Uint16)(B)) << 8)) +#define LOAD32(A, B, C, D) ((((Uint32)(A)) << 0) | \ + (((Uint32)(B)) << 8) | \ + (((Uint32)(C)) << 16) | \ (((Uint32)(D)) << 24)) typedef enum @@ -70,7 +69,7 @@ typedef enum k_EPS4ReportIdDisconnectMessage = 226, } EPS4ReportId; -typedef enum +typedef enum { k_ePS4FeatureReportIdGyroCalibration_USB = 0x02, k_ePS4FeatureReportIdCapabilities = 0x03, @@ -113,19 +112,21 @@ typedef struct Uint8 ucLedBlue; Uint8 ucLedDelayOn; Uint8 ucLedDelayOff; - Uint8 _rgucPad0[ 8 ]; + Uint8 _rgucPad0[8]; Uint8 ucVolumeLeft; Uint8 ucVolumeRight; Uint8 ucVolumeMic; Uint8 ucVolumeSpeaker; } DS4EffectsState_t; -typedef struct { +typedef struct +{ Sint16 bias; float sensitivity; } IMUCalibrationData; -typedef struct { +typedef struct +{ SDL_HIDAPI_Device *device; SDL_Joystick *joystick; SDL_bool is_dongle; @@ -153,23 +154,19 @@ typedef struct { PS4StatePacket_t last_state; } SDL_DriverPS4_Context; - static int HIDAPI_DriverPS4_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *effect, int size); -static void -HIDAPI_DriverPS4_RegisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverPS4_RegisterHints(SDL_HintCallback callback, void *userdata) { SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS4, callback, userdata); } -static void -HIDAPI_DriverPS4_UnregisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverPS4_UnregisterHints(SDL_HintCallback callback, void *userdata) { SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS4, callback, userdata); } -static SDL_bool -HIDAPI_DriverPS4_IsEnabled(void) +static SDL_bool HIDAPI_DriverPS4_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS4, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); } @@ -181,8 +178,7 @@ static int ReadFeatureReport(SDL_hid_device *dev, Uint8 report_id, Uint8 *report return SDL_hid_get_feature_report(dev, report, length); } -static SDL_bool -HIDAPI_DriverPS4_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static SDL_bool HIDAPI_DriverPS4_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { Uint8 data[USB_PACKET_LENGTH]; int size; @@ -209,8 +205,7 @@ HIDAPI_DriverPS4_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, return SDL_FALSE; } -static void -SetLedsForPlayerIndex(DS4EffectsState_t *effects, int player_index) +static void SetLedsForPlayerIndex(DS4EffectsState_t *effects, int player_index) { /* This list is the same as what hid-sony.c uses in the Linux kernel. The first 4 values correspond to what the PS4 assigns. @@ -236,8 +231,7 @@ SetLedsForPlayerIndex(DS4EffectsState_t *effects, int player_index) effects->ucLedBlue = colors[player_index][2]; } -static SDL_bool -HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverPS4_Context *ctx; Uint8 data[USB_PACKET_LENGTH]; @@ -284,7 +278,7 @@ HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdSerialNumber, data, sizeof(data)); if (size >= 7 && (data[1] || data[2] || data[3] || data[4] || data[5] || data[6])) { SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x", - data[6], data[5], data[4], data[3], data[2], data[1]); + data[6], data[5], data[4], data[3], data[2], data[1]); device->is_bluetooth = SDL_FALSE; ctx->enhanced_mode = SDL_TRUE; } else { @@ -402,14 +396,12 @@ HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) return HIDAPI_JoystickConnected(device, NULL); } -static int -HIDAPI_DriverPS4_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) +static int HIDAPI_DriverPS4_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) { return -1; } -static void -HIDAPI_DriverPS4_LoadCalibrationData(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverPS4_LoadCalibrationData(SDL_HIDAPI_Device *device) { SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; int i, tries, size; @@ -423,7 +415,7 @@ HIDAPI_DriverPS4_LoadCalibrationData(SDL_HIDAPI_Device *device) return; } - for ( tries = 0; tries < 5; ++tries ) { + for (tries = 0; tries < 5; ++tries) { /* For Bluetooth controllers, this report switches them into advanced report mode */ size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdGyroCalibration_USB, data, sizeof(data)); if (size < 35) { @@ -548,8 +540,7 @@ HIDAPI_DriverPS4_LoadCalibrationData(SDL_HIDAPI_Device *device) } } -static float -HIDAPI_DriverPS4_ApplyCalibrationData(SDL_DriverPS4_Context *ctx, int index, Sint16 value) +static float HIDAPI_DriverPS4_ApplyCalibrationData(SDL_DriverPS4_Context *ctx, int index, Sint16 value) { float result; @@ -572,8 +563,7 @@ HIDAPI_DriverPS4_ApplyCalibrationData(SDL_DriverPS4_Context *ctx, int index, Sin return result; } -static int -HIDAPI_DriverPS4_UpdateEffects(SDL_HIDAPI_Device *device) +static int HIDAPI_DriverPS4_UpdateEffects(SDL_HIDAPI_Device *device) { SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; DS4EffectsState_t effects; @@ -602,8 +592,7 @@ HIDAPI_DriverPS4_UpdateEffects(SDL_HIDAPI_Device *device) return HIDAPI_DriverPS4_SendJoystickEffect(device, ctx->joystick, &effects, sizeof(effects)); } -static void -HIDAPI_DriverPS4_TickleBluetooth(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverPS4_TickleBluetooth(SDL_HIDAPI_Device *device) { /* This is just a dummy packet that should have no effect, since we don't set the CRC */ Uint8 data[78]; @@ -611,15 +600,14 @@ HIDAPI_DriverPS4_TickleBluetooth(SDL_HIDAPI_Device *device) SDL_zeroa(data); data[0] = k_EPS4ReportIdBluetoothEffects; - data[1] = 0xC0; /* Magic value HID + CRC */ + data[1] = 0xC0; /* Magic value HID + CRC */ if (SDL_HIDAPI_LockRumble() == 0) { SDL_HIDAPI_SendRumbleAndUnlock(device, data, sizeof(data)); } } -static void -HIDAPI_DriverPS4_SetEnhancedMode(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static void HIDAPI_DriverPS4_SetEnhancedMode(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; @@ -649,8 +637,7 @@ static void SDLCALL SDL_PS4RumbleHintChanged(void *userdata, const char *name, c } } -static void -HIDAPI_DriverPS4_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) +static void HIDAPI_DriverPS4_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) { SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; @@ -664,10 +651,9 @@ HIDAPI_DriverPS4_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID HIDAPI_DriverPS4_UpdateEffects(device); } -static SDL_bool -HIDAPI_DriverPS4_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static SDL_bool HIDAPI_DriverPS4_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { - SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *) device->context; + SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; ctx->joystick = joystick; ctx->last_packet = SDL_GetTicks(); @@ -704,8 +690,7 @@ HIDAPI_DriverPS4_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) return SDL_TRUE; } -static int -HIDAPI_DriverPS4_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int HIDAPI_DriverPS4_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; @@ -719,14 +704,12 @@ HIDAPI_DriverPS4_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystic return HIDAPI_DriverPS4_UpdateEffects(device); } -static int -HIDAPI_DriverPS4_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int HIDAPI_DriverPS4_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static Uint32 -HIDAPI_DriverPS4_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static Uint32 HIDAPI_DriverPS4_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; Uint32 result = 0; @@ -743,8 +726,7 @@ HIDAPI_DriverPS4_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick return result; } -static int -HIDAPI_DriverPS4_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int HIDAPI_DriverPS4_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; @@ -760,8 +742,7 @@ HIDAPI_DriverPS4_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystic return HIDAPI_DriverPS4_UpdateEffects(device); } -static int -HIDAPI_DriverPS4_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *effect, int size) +static int HIDAPI_DriverPS4_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *effect, int size) { SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; Uint8 data[78]; @@ -779,14 +760,14 @@ HIDAPI_DriverPS4_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joy if (device->is_bluetooth && ctx->official_controller) { data[0] = k_EPS4ReportIdBluetoothEffects; - data[1] = 0xC0 | 0x04; /* Magic value HID + CRC, also sets interval to 4ms for samples */ - data[3] = 0x03; /* 0x1 is rumble, 0x2 is lightbar, 0x4 is the blink interval */ + data[1] = 0xC0 | 0x04; /* Magic value HID + CRC, also sets interval to 4ms for samples */ + data[3] = 0x03; /* 0x1 is rumble, 0x2 is lightbar, 0x4 is the blink interval */ report_size = 78; offset = 6; } else { data[0] = k_EPS4ReportIdUsbEffects; - data[1] = 0x07; /* Magic value */ + data[1] = 0x07; /* Magic value */ report_size = 32; offset = 4; @@ -809,8 +790,7 @@ HIDAPI_DriverPS4_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joy return 0; } -static int -HIDAPI_DriverPS4_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverPS4_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) { SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; @@ -827,11 +807,10 @@ HIDAPI_DriverPS4_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joysti return 0; } -static void -HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_device *dev, SDL_DriverPS4_Context *ctx, PS4StatePacket_t *packet) +static void HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_device *dev, SDL_DriverPS4_Context *ctx, PS4StatePacket_t *packet) { static const float TOUCHPAD_SCALEX = 1.0f / 1920; - static const float TOUCHPAD_SCALEY = 1.0f / 920; /* This is noted as being 944 resolution, but 920 feels better */ + static const float TOUCHPAD_SCALEY = 1.0f / 920; /* This is noted as being 944 resolution, but 920 feels better */ Sint16 axis; Uint8 touchpad_state; int touchpad_x, touchpad_y; @@ -984,7 +963,6 @@ HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_device *dev, /* Sensor timestamp is in 5.33us units */ timestamp_us = (ctx->timestamp * 16) / 3; - data[0] = HIDAPI_DriverPS4_ApplyCalibrationData(ctx, 0, LOAD16(packet->rgucGyroX[0], packet->rgucGyroX[1])); data[1] = HIDAPI_DriverPS4_ApplyCalibrationData(ctx, 1, LOAD16(packet->rgucGyroY[0], packet->rgucGyroY[1])); data[2] = HIDAPI_DriverPS4_ApplyCalibrationData(ctx, 2, LOAD16(packet->rgucGyroZ[0], packet->rgucGyroZ[1])); @@ -999,8 +977,7 @@ HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_device *dev, SDL_memcpy(&ctx->last_state, packet, sizeof(ctx->last_state)); } -static SDL_bool -VerifyCRC(Uint8 *data, int size) +static SDL_bool VerifyCRC(Uint8 *data, int size) { Uint8 ubHdr = 0xA1; /* hidp header is part of the CRC calculation */ Uint32 unCRC, unPacketCRC; @@ -1015,15 +992,14 @@ VerifyCRC(Uint8 *data, int size) return (unCRC == unPacketCRC) ? SDL_TRUE : SDL_FALSE; } -static SDL_bool -HIDAPI_DriverPS4_IsPacketValid(SDL_DriverPS4_Context *ctx, Uint8 *data, int size) +static SDL_bool HIDAPI_DriverPS4_IsPacketValid(SDL_DriverPS4_Context *ctx, Uint8 *data, int size) { switch (data[0]) { case k_EPS4ReportIdUsbState: /* In the case of a DS4 USB dongle, bit[2] of byte 31 indicates if a DS4 is actually connected (indicated by '0'). * For non-dongle, this bit is always 0 (connected). - * This is usually the ID over USB, but the DS4v2 that started shipping with the PS4 Slim will also send this - * packet over BT with a size of 128 + * This is usually the ID over USB, but the DS4v2 that started shipping with the PS4 Slim will also send this + * packet over BT with a size of 128 */ if (size >= 64 && (data[31] & 0x04) == 0) { return SDL_TRUE; @@ -1049,12 +1025,11 @@ HIDAPI_DriverPS4_IsPacketValid(SDL_DriverPS4_Context *ctx, Uint8 *data, int size return SDL_FALSE; } -static SDL_bool -HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; SDL_Joystick *joystick = NULL; - Uint8 data[USB_PACKET_LENGTH*2]; + Uint8 data[USB_PACKET_LENGTH * 2]; int size; int packet_count = 0; Uint32 now = SDL_GetTicks(); @@ -1096,7 +1071,7 @@ HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) HIDAPI_DriverPS4_SetEnhancedMode(device, joystick); } /* Bluetooth state packets have two additional bytes at the beginning, the first notes if HID is present */ - HIDAPI_DriverPS4_HandleStatePacket(joystick, device->dev, ctx, (PS4StatePacket_t*)&data[3]); + HIDAPI_DriverPS4_HandleStatePacket(joystick, device->dev, ctx, (PS4StatePacket_t *)&data[3]); break; default: #ifdef DEBUG_JOYSTICK @@ -1151,8 +1126,7 @@ HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) return size >= 0; } -static void -HIDAPI_DriverPS4_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static void HIDAPI_DriverPS4_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; @@ -1162,13 +1136,11 @@ HIDAPI_DriverPS4_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick ctx->joystick = NULL; } -static void -HIDAPI_DriverPS4_FreeDevice(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverPS4_FreeDevice(SDL_HIDAPI_Device *device) { } -SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS4 = -{ +SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS4 = { SDL_HINT_JOYSTICK_HIDAPI_PS4, SDL_TRUE, HIDAPI_DriverPS4_RegisterHints, diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c index 69535fd5c..807ebab60 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps5.c +++ b/src/joystick/hidapi/SDL_hidapi_ps5.c @@ -31,7 +31,6 @@ #include "SDL_hidapijoystick_c.h" #include "SDL_hidapi_rumble.h" - #ifdef SDL_JOYSTICK_HIDAPI_PS5 /* Define this if you want to log all packets from the controller */ @@ -40,14 +39,14 @@ /* Define this if you want to log calibration data */ /*#define DEBUG_PS5_CALIBRATION*/ -#define GYRO_RES_PER_DEGREE 1024.0f -#define ACCEL_RES_PER_G 8192.0f +#define GYRO_RES_PER_DEGREE 1024.0f +#define ACCEL_RES_PER_G 8192.0f #define BLUETOOTH_DISCONNECT_TIMEOUT_MS 500 -#define LOAD16(A, B) (Sint16)((Uint16)(A) | (((Uint16)(B)) << 8)) -#define LOAD32(A, B, C, D) ((((Uint32)(A)) << 0) | \ - (((Uint32)(B)) << 8) | \ - (((Uint32)(C)) << 16) | \ +#define LOAD16(A, B) (Sint16)((Uint16)(A) | (((Uint16)(B)) << 8)) +#define LOAD32(A, B, C, D) ((((Uint32)(A)) << 0) | \ + (((Uint32)(B)) << 8) | \ + (((Uint32)(C)) << 16) | \ (((Uint32)(D)) << 24)) typedef enum @@ -79,128 +78,132 @@ typedef struct typedef struct { - Uint8 ucLeftJoystickX; /* 0 */ - Uint8 ucLeftJoystickY; /* 1 */ - Uint8 ucRightJoystickX; /* 2 */ - Uint8 ucRightJoystickY; /* 3 */ - Uint8 ucTriggerLeft; /* 4 */ - Uint8 ucTriggerRight; /* 5 */ - Uint8 ucCounter; /* 6 */ - Uint8 rgucButtonsAndHat[4]; /* 7 */ - Uint8 rgucPacketSequence[4]; /* 11 - 32 bit little endian */ - Uint8 rgucGyroX[2]; /* 15 */ - Uint8 rgucGyroY[2]; /* 17 */ - Uint8 rgucGyroZ[2]; /* 19 */ - Uint8 rgucAccelX[2]; /* 21 */ - Uint8 rgucAccelY[2]; /* 23 */ - Uint8 rgucAccelZ[2]; /* 25 */ - Uint8 rgucSensorTimestamp[4]; /* 27 - 32 bit little endian */ + Uint8 ucLeftJoystickX; /* 0 */ + Uint8 ucLeftJoystickY; /* 1 */ + Uint8 ucRightJoystickX; /* 2 */ + Uint8 ucRightJoystickY; /* 3 */ + Uint8 ucTriggerLeft; /* 4 */ + Uint8 ucTriggerRight; /* 5 */ + Uint8 ucCounter; /* 6 */ + Uint8 rgucButtonsAndHat[4]; /* 7 */ + Uint8 rgucPacketSequence[4]; /* 11 - 32 bit little endian */ + Uint8 rgucGyroX[2]; /* 15 */ + Uint8 rgucGyroY[2]; /* 17 */ + Uint8 rgucGyroZ[2]; /* 19 */ + Uint8 rgucAccelX[2]; /* 21 */ + Uint8 rgucAccelY[2]; /* 23 */ + Uint8 rgucAccelZ[2]; /* 25 */ + Uint8 rgucSensorTimestamp[4]; /* 27 - 32 bit little endian */ } PS5StatePacketCommon_t; typedef struct { - Uint8 ucLeftJoystickX; /* 0 */ - Uint8 ucLeftJoystickY; /* 1 */ - Uint8 ucRightJoystickX; /* 2 */ - Uint8 ucRightJoystickY; /* 3 */ - Uint8 ucTriggerLeft; /* 4 */ - Uint8 ucTriggerRight; /* 5 */ - Uint8 ucCounter; /* 6 */ - Uint8 rgucButtonsAndHat[4]; /* 7 */ - Uint8 rgucPacketSequence[4]; /* 11 - 32 bit little endian */ - Uint8 rgucGyroX[2]; /* 15 */ - Uint8 rgucGyroY[2]; /* 17 */ - Uint8 rgucGyroZ[2]; /* 19 */ - Uint8 rgucAccelX[2]; /* 21 */ - Uint8 rgucAccelY[2]; /* 23 */ - Uint8 rgucAccelZ[2]; /* 25 */ - Uint8 rgucSensorTimestamp[4]; /* 27 - 32 bit little endian */ - Uint8 ucSensorTemp; /* 31 */ - Uint8 ucTouchpadCounter1; /* 32 - high bit clear + counter */ - Uint8 rgucTouchpadData1[3]; /* 33 - X/Y, 12 bits per axis */ - Uint8 ucTouchpadCounter2; /* 36 - high bit clear + counter */ - Uint8 rgucTouchpadData2[3]; /* 37 - X/Y, 12 bits per axis */ - Uint8 rgucUnknown1[8]; /* 40 */ - Uint8 rgucTimer2[4]; /* 48 - 32 bit little endian */ - Uint8 ucBatteryLevel; /* 52 */ - Uint8 ucConnectState; /* 53 - 0x08 = USB, 0x01 = headphone */ + Uint8 ucLeftJoystickX; /* 0 */ + Uint8 ucLeftJoystickY; /* 1 */ + Uint8 ucRightJoystickX; /* 2 */ + Uint8 ucRightJoystickY; /* 3 */ + Uint8 ucTriggerLeft; /* 4 */ + Uint8 ucTriggerRight; /* 5 */ + Uint8 ucCounter; /* 6 */ + Uint8 rgucButtonsAndHat[4]; /* 7 */ + Uint8 rgucPacketSequence[4]; /* 11 - 32 bit little endian */ + Uint8 rgucGyroX[2]; /* 15 */ + Uint8 rgucGyroY[2]; /* 17 */ + Uint8 rgucGyroZ[2]; /* 19 */ + Uint8 rgucAccelX[2]; /* 21 */ + Uint8 rgucAccelY[2]; /* 23 */ + Uint8 rgucAccelZ[2]; /* 25 */ + Uint8 rgucSensorTimestamp[4]; /* 27 - 32 bit little endian */ + Uint8 ucSensorTemp; /* 31 */ + Uint8 ucTouchpadCounter1; /* 32 - high bit clear + counter */ + Uint8 rgucTouchpadData1[3]; /* 33 - X/Y, 12 bits per axis */ + Uint8 ucTouchpadCounter2; /* 36 - high bit clear + counter */ + Uint8 rgucTouchpadData2[3]; /* 37 - X/Y, 12 bits per axis */ + Uint8 rgucUnknown1[8]; /* 40 */ + Uint8 rgucTimer2[4]; /* 48 - 32 bit little endian */ + Uint8 ucBatteryLevel; /* 52 */ + Uint8 ucConnectState; /* 53 - 0x08 = USB, 0x01 = headphone */ /* There's more unknown data at the end, and a 32-bit CRC on Bluetooth */ } PS5StatePacket_t; typedef struct { - Uint8 ucLeftJoystickX; /* 0 */ - Uint8 ucLeftJoystickY; /* 1 */ - Uint8 ucRightJoystickX; /* 2 */ - Uint8 ucRightJoystickY; /* 3 */ - Uint8 ucTriggerLeft; /* 4 */ - Uint8 ucTriggerRight; /* 5 */ - Uint8 ucCounter; /* 6 */ - Uint8 rgucButtonsAndHat[4]; /* 7 */ - Uint8 rgucPacketSequence[4]; /* 11 - 32 bit little endian */ - Uint8 rgucGyroX[2]; /* 15 */ - Uint8 rgucGyroY[2]; /* 17 */ - Uint8 rgucGyroZ[2]; /* 19 */ - Uint8 rgucAccelX[2]; /* 21 */ - Uint8 rgucAccelY[2]; /* 23 */ - Uint8 rgucAccelZ[2]; /* 25 */ - Uint8 rgucSensorTimestamp[4]; /* 27 - 32 bit little endian */ - Uint8 ucTouchpadCounter1; /* 31 - high bit clear + counter */ - Uint8 rgucTouchpadData1[3]; /* 32 - X/Y, 12 bits per axis */ - Uint8 ucTouchpadCounter2; /* 35 - high bit clear + counter */ - Uint8 rgucTouchpadData2[3]; /* 36 - X/Y, 12 bits per axis */ + Uint8 ucLeftJoystickX; /* 0 */ + Uint8 ucLeftJoystickY; /* 1 */ + Uint8 ucRightJoystickX; /* 2 */ + Uint8 ucRightJoystickY; /* 3 */ + Uint8 ucTriggerLeft; /* 4 */ + Uint8 ucTriggerRight; /* 5 */ + Uint8 ucCounter; /* 6 */ + Uint8 rgucButtonsAndHat[4]; /* 7 */ + Uint8 rgucPacketSequence[4]; /* 11 - 32 bit little endian */ + Uint8 rgucGyroX[2]; /* 15 */ + Uint8 rgucGyroY[2]; /* 17 */ + Uint8 rgucGyroZ[2]; /* 19 */ + Uint8 rgucAccelX[2]; /* 21 */ + Uint8 rgucAccelY[2]; /* 23 */ + Uint8 rgucAccelZ[2]; /* 25 */ + Uint8 rgucSensorTimestamp[4]; /* 27 - 32 bit little endian */ + Uint8 ucTouchpadCounter1; /* 31 - high bit clear + counter */ + Uint8 rgucTouchpadData1[3]; /* 32 - X/Y, 12 bits per axis */ + Uint8 ucTouchpadCounter2; /* 35 - high bit clear + counter */ + Uint8 rgucTouchpadData2[3]; /* 36 - X/Y, 12 bits per axis */ /* There's more unknown data at the end, and a 32-bit CRC on Bluetooth */ } PS5StatePacketAlt_t; typedef struct { - Uint8 ucEnableBits1; /* 0 */ - Uint8 ucEnableBits2; /* 1 */ - Uint8 ucRumbleRight; /* 2 */ - Uint8 ucRumbleLeft; /* 3 */ - Uint8 ucHeadphoneVolume; /* 4 */ - Uint8 ucSpeakerVolume; /* 5 */ - Uint8 ucMicrophoneVolume; /* 6 */ - Uint8 ucAudioEnableBits; /* 7 */ - Uint8 ucMicLightMode; /* 8 */ - Uint8 ucAudioMuteBits; /* 9 */ - Uint8 rgucRightTriggerEffect[11]; /* 10 */ - Uint8 rgucLeftTriggerEffect[11]; /* 21 */ - Uint8 rgucUnknown1[6]; /* 32 */ - Uint8 ucEnableBits3; /* 38 */ - Uint8 rgucUnknown2[2]; /* 39 */ - Uint8 ucLedAnim; /* 41 */ - Uint8 ucLedBrightness; /* 42 */ - Uint8 ucPadLights; /* 43 */ - Uint8 ucLedRed; /* 44 */ - Uint8 ucLedGreen; /* 45 */ - Uint8 ucLedBlue; /* 46 */ + Uint8 ucEnableBits1; /* 0 */ + Uint8 ucEnableBits2; /* 1 */ + Uint8 ucRumbleRight; /* 2 */ + Uint8 ucRumbleLeft; /* 3 */ + Uint8 ucHeadphoneVolume; /* 4 */ + Uint8 ucSpeakerVolume; /* 5 */ + Uint8 ucMicrophoneVolume; /* 6 */ + Uint8 ucAudioEnableBits; /* 7 */ + Uint8 ucMicLightMode; /* 8 */ + Uint8 ucAudioMuteBits; /* 9 */ + Uint8 rgucRightTriggerEffect[11]; /* 10 */ + Uint8 rgucLeftTriggerEffect[11]; /* 21 */ + Uint8 rgucUnknown1[6]; /* 32 */ + Uint8 ucEnableBits3; /* 38 */ + Uint8 rgucUnknown2[2]; /* 39 */ + Uint8 ucLedAnim; /* 41 */ + Uint8 ucLedBrightness; /* 42 */ + Uint8 ucPadLights; /* 43 */ + Uint8 ucLedRed; /* 44 */ + Uint8 ucLedGreen; /* 45 */ + Uint8 ucLedBlue; /* 46 */ } DS5EffectsState_t; -typedef enum { - k_EDS5EffectRumbleStart = (1 << 0), - k_EDS5EffectRumble = (1 << 1), - k_EDS5EffectLEDReset = (1 << 2), - k_EDS5EffectLED = (1 << 3), - k_EDS5EffectPadLights = (1 << 4), - k_EDS5EffectMicLight = (1 << 5) +typedef enum +{ + k_EDS5EffectRumbleStart = (1 << 0), + k_EDS5EffectRumble = (1 << 1), + k_EDS5EffectLEDReset = (1 << 2), + k_EDS5EffectLED = (1 << 3), + k_EDS5EffectPadLights = (1 << 4), + k_EDS5EffectMicLight = (1 << 5) } EDS5Effect; -typedef enum { +typedef enum +{ k_EDS5LEDResetStateNone, k_EDS5LEDResetStatePending, k_EDS5LEDResetStateComplete, } EDS5LEDResetState; -typedef struct { +typedef struct +{ Sint16 bias; float sensitivity; } IMUCalibrationData; -typedef struct { +typedef struct +{ SDL_HIDAPI_Device *device; SDL_Joystick *joystick; SDL_bool use_alternate_report; @@ -239,20 +242,17 @@ typedef struct { static int HIDAPI_DriverPS5_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *effect, int size); -static void -HIDAPI_DriverPS5_RegisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverPS5_RegisterHints(SDL_HintCallback callback, void *userdata) { SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS5, callback, userdata); } -static void -HIDAPI_DriverPS5_UnregisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverPS5_UnregisterHints(SDL_HintCallback callback, void *userdata) { SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS5, callback, userdata); } -static SDL_bool -HIDAPI_DriverPS5_IsEnabled(void) +static SDL_bool HIDAPI_DriverPS5_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS5, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); } @@ -264,8 +264,7 @@ static int ReadFeatureReport(SDL_hid_device *dev, Uint8 report_id, Uint8 *report return SDL_hid_get_feature_report(dev, report, length); } -static SDL_bool -HIDAPI_DriverPS5_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static SDL_bool HIDAPI_DriverPS5_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { Uint8 data[USB_PACKET_LENGTH]; int size; @@ -291,8 +290,7 @@ HIDAPI_DriverPS5_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, return SDL_FALSE; } -static void -SetLedsForPlayerIndex(DS5EffectsState_t *effects, int player_index) +static void SetLedsForPlayerIndex(DS5EffectsState_t *effects, int player_index) { /* This list is the same as what hid-sony.c uses in the Linux kernel. The first 4 values correspond to what the PS4 assigns. @@ -318,8 +316,7 @@ SetLedsForPlayerIndex(DS5EffectsState_t *effects, int player_index) effects->ucLedBlue = colors[player_index][2]; } -static void -SetLightsForPlayerIndex(DS5EffectsState_t *effects, int player_index) +static void SetLightsForPlayerIndex(DS5EffectsState_t *effects, int player_index) { static const Uint8 lights[] = { 0x04, @@ -337,11 +334,10 @@ SetLightsForPlayerIndex(DS5EffectsState_t *effects, int player_index) } } -static SDL_bool -HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverPS5_Context *ctx; - Uint8 data[USB_PACKET_LENGTH*2]; + Uint8 data[USB_PACKET_LENGTH * 2]; int size; char serial[18]; SDL_JoystickType joystick_type = SDL_JOYSTICK_TYPE_GAMECONTROLLER; @@ -405,7 +401,7 @@ HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) */ if (ReadFeatureReport(device->dev, k_EPS5FeatureReportIdSerialNumber, data, sizeof(data)) >= 7) { SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x", - data[6], data[5], data[4], data[3], data[2], data[1]); + data[6], data[5], data[4], data[3], data[2], data[1]); } /* Read the firmware version @@ -494,14 +490,12 @@ HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) return HIDAPI_JoystickConnected(device, NULL); } -static int -HIDAPI_DriverPS5_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) +static int HIDAPI_DriverPS5_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) { return -1; } -static void -HIDAPI_DriverPS5_LoadCalibrationData(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverPS5_LoadCalibrationData(SDL_HIDAPI_Device *device) { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; int i, size; @@ -593,8 +587,7 @@ HIDAPI_DriverPS5_LoadCalibrationData(SDL_HIDAPI_Device *device) } } -static float -HIDAPI_DriverPS5_ApplyCalibrationData(SDL_DriverPS5_Context *ctx, int index, Sint16 value) +static float HIDAPI_DriverPS5_ApplyCalibrationData(SDL_DriverPS5_Context *ctx, int index, Sint16 value) { float result; @@ -617,8 +610,7 @@ HIDAPI_DriverPS5_ApplyCalibrationData(SDL_DriverPS5_Context *ctx, int index, Sin return result; } -static int -HIDAPI_DriverPS5_UpdateEffects(SDL_HIDAPI_Device *device, int effect_mask) +static int HIDAPI_DriverPS5_UpdateEffects(SDL_HIDAPI_Device *device, int effect_mask) { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; DS5EffectsState_t effects; @@ -630,7 +622,7 @@ HIDAPI_DriverPS5_UpdateEffects(SDL_HIDAPI_Device *device, int effect_mask) SDL_zero(effects); /* Make sure the Bluetooth connection sequence has completed before sending LED color change */ - if (device->is_bluetooth && + if (device->is_bluetooth && (effect_mask & (k_EDS5EffectLED | k_EDS5EffectPadLights)) != 0) { if (ctx->led_reset_state != k_EDS5LEDResetStateComplete) { ctx->led_reset_state = k_EDS5LEDResetStatePending; @@ -695,14 +687,13 @@ HIDAPI_DriverPS5_UpdateEffects(SDL_HIDAPI_Device *device, int effect_mask) if ((effect_mask & k_EDS5EffectMicLight) != 0) { effects.ucEnableBits2 |= 0x01; /* Enable microphone light */ - effects.ucMicLightMode = 0; /* Bitmask, 0x00 = off, 0x01 = solid, 0x02 = pulse */ + effects.ucMicLightMode = 0; /* Bitmask, 0x00 = off, 0x01 = solid, 0x02 = pulse */ } return HIDAPI_DriverPS5_SendJoystickEffect(device, ctx->joystick, &effects, sizeof(effects)); } -static void -HIDAPI_DriverPS5_CheckPendingLEDReset(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverPS5_CheckPendingLEDReset(SDL_HIDAPI_Device *device) { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; SDL_bool led_reset_complete = SDL_FALSE; @@ -733,8 +724,7 @@ HIDAPI_DriverPS5_CheckPendingLEDReset(SDL_HIDAPI_Device *device) } } -static void -HIDAPI_DriverPS5_TickleBluetooth(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverPS5_TickleBluetooth(SDL_HIDAPI_Device *device) { /* This is just a dummy packet that should have no effect, since we don't set the CRC */ Uint8 data[78]; @@ -742,15 +732,14 @@ HIDAPI_DriverPS5_TickleBluetooth(SDL_HIDAPI_Device *device) SDL_zeroa(data); data[0] = k_EPS5ReportIdBluetoothEffects; - data[1] = 0x02; /* Magic value */ + data[1] = 0x02; /* Magic value */ if (SDL_HIDAPI_LockRumble() == 0) { SDL_HIDAPI_SendRumbleAndUnlock(device, data, sizeof(data)); } } -static void -HIDAPI_DriverPS5_SetEnhancedMode(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static void HIDAPI_DriverPS5_SetEnhancedMode(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; @@ -802,8 +791,7 @@ static void SDLCALL SDL_PS5PlayerLEDHintChanged(void *userdata, const char *name } } -static void -HIDAPI_DriverPS5_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) +static void HIDAPI_DriverPS5_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; @@ -817,8 +805,7 @@ HIDAPI_DriverPS5_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID HIDAPI_DriverPS5_UpdateEffects(device, (k_EDS5EffectLED | k_EDS5EffectPadLights)); } -static SDL_bool -HIDAPI_DriverPS5_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static SDL_bool HIDAPI_DriverPS5_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; @@ -856,8 +843,7 @@ HIDAPI_DriverPS5_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) return SDL_TRUE; } -static int -HIDAPI_DriverPS5_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int HIDAPI_DriverPS5_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; @@ -875,14 +861,12 @@ HIDAPI_DriverPS5_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystic return HIDAPI_DriverPS5_UpdateEffects(device, k_EDS5EffectRumble); } -static int -HIDAPI_DriverPS5_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int HIDAPI_DriverPS5_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static Uint32 -HIDAPI_DriverPS5_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static Uint32 HIDAPI_DriverPS5_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; Uint32 result = 0; @@ -899,8 +883,7 @@ HIDAPI_DriverPS5_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick return result; } -static int -HIDAPI_DriverPS5_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int HIDAPI_DriverPS5_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; @@ -916,8 +899,7 @@ HIDAPI_DriverPS5_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystic return HIDAPI_DriverPS5_UpdateEffects(device, k_EDS5EffectLED); } -static int -HIDAPI_DriverPS5_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *effect, int size) +static int HIDAPI_DriverPS5_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *effect, int size) { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; Uint8 data[78]; @@ -938,7 +920,7 @@ HIDAPI_DriverPS5_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joy if (device->is_bluetooth) { data[0] = k_EPS5ReportIdBluetoothEffects; - data[1] = 0x02; /* Magic value */ + data[1] = 0x02; /* Magic value */ report_size = 78; offset = 2; @@ -985,8 +967,7 @@ HIDAPI_DriverPS5_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joy return 0; } -static int -HIDAPI_DriverPS5_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverPS5_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; @@ -1003,8 +984,7 @@ HIDAPI_DriverPS5_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joysti return 0; } -static void -HIDAPI_DriverPS5_HandleSimpleStatePacket(SDL_Joystick *joystick, SDL_hid_device *dev, SDL_DriverPS5_Context *ctx, PS5SimpleStatePacket_t *packet) +static void HIDAPI_DriverPS5_HandleSimpleStatePacket(SDL_Joystick *joystick, SDL_hid_device *dev, SDL_DriverPS5_Context *ctx, PS5SimpleStatePacket_t *packet) { Sint16 axis; @@ -1097,8 +1077,7 @@ HIDAPI_DriverPS5_HandleSimpleStatePacket(SDL_Joystick *joystick, SDL_hid_device SDL_memcpy(&ctx->last_state.simple, packet, sizeof(ctx->last_state.simple)); } -static void -HIDAPI_DriverPS5_HandleStatePacketCommon(SDL_Joystick *joystick, SDL_hid_device *dev, SDL_DriverPS5_Context *ctx, PS5StatePacketCommon_t *packet) +static void HIDAPI_DriverPS5_HandleStatePacketCommon(SDL_Joystick *joystick, SDL_hid_device *dev, SDL_DriverPS5_Context *ctx, PS5StatePacketCommon_t *packet) { Sint16 axis; @@ -1227,8 +1206,7 @@ HIDAPI_DriverPS5_HandleStatePacketCommon(SDL_Joystick *joystick, SDL_hid_device } } -static void -HIDAPI_DriverPS5_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_device *dev, SDL_DriverPS5_Context *ctx, PS5StatePacket_t *packet) +static void HIDAPI_DriverPS5_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_device *dev, SDL_DriverPS5_Context *ctx, PS5StatePacket_t *packet) { static const float TOUCHPAD_SCALEX = 1.0f / 1920; static const float TOUCHPAD_SCALEY = 1.0f / 1070; @@ -1270,8 +1248,7 @@ HIDAPI_DriverPS5_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_device *dev, SDL_memcpy(&ctx->last_state, packet, sizeof(ctx->last_state)); } -static void -HIDAPI_DriverPS5_HandleStatePacketAlt(SDL_Joystick *joystick, SDL_hid_device *dev, SDL_DriverPS5_Context *ctx, PS5StatePacketAlt_t *packet) +static void HIDAPI_DriverPS5_HandleStatePacketAlt(SDL_Joystick *joystick, SDL_hid_device *dev, SDL_DriverPS5_Context *ctx, PS5StatePacketAlt_t *packet) { static const float TOUCHPAD_SCALEX = 1.0f / 1920; static const float TOUCHPAD_SCALEY = 1.0f / 1070; @@ -1280,21 +1257,20 @@ HIDAPI_DriverPS5_HandleStatePacketAlt(SDL_Joystick *joystick, SDL_hid_device *de if (ctx->report_touchpad) { touchpad_state = ((packet->ucTouchpadCounter1 & 0x80) == 0) ? SDL_PRESSED : SDL_RELEASED; - touchpad_x = packet->rgucTouchpadData1[0] | (((int) packet->rgucTouchpadData1[1] & 0x0F) << 8); - touchpad_y = (packet->rgucTouchpadData1[1] >> 4) | ((int) packet->rgucTouchpadData1[2] << 4); + touchpad_x = packet->rgucTouchpadData1[0] | (((int)packet->rgucTouchpadData1[1] & 0x0F) << 8); + touchpad_y = (packet->rgucTouchpadData1[1] >> 4) | ((int)packet->rgucTouchpadData1[2] << 4); SDL_PrivateJoystickTouchpad(joystick, 0, 0, touchpad_state, touchpad_x * TOUCHPAD_SCALEX, touchpad_y * TOUCHPAD_SCALEY, touchpad_state ? 1.0f : 0.0f); touchpad_state = ((packet->ucTouchpadCounter2 & 0x80) == 0) ? SDL_PRESSED : SDL_RELEASED; - touchpad_x = packet->rgucTouchpadData2[0] | (((int) packet->rgucTouchpadData2[1] & 0x0F) << 8); - touchpad_y = (packet->rgucTouchpadData2[1] >> 4) | ((int) packet->rgucTouchpadData2[2] << 4); + touchpad_x = packet->rgucTouchpadData2[0] | (((int)packet->rgucTouchpadData2[1] & 0x0F) << 8); + touchpad_y = (packet->rgucTouchpadData2[1] >> 4) | ((int)packet->rgucTouchpadData2[2] << 4); SDL_PrivateJoystickTouchpad(joystick, 0, 1, touchpad_state, touchpad_x * TOUCHPAD_SCALEX, touchpad_y * TOUCHPAD_SCALEY, touchpad_state ? 1.0f : 0.0f); } SDL_memcpy(&ctx->last_state, packet, sizeof(ctx->last_state)); } -static SDL_bool -VerifyCRC(Uint8 *data, int size) +static SDL_bool VerifyCRC(Uint8 *data, int size) { Uint8 ubHdr = 0xA1; /* hidp header is part of the CRC calculation */ Uint32 unCRC, unPacketCRC; @@ -1309,8 +1285,7 @@ VerifyCRC(Uint8 *data, int size) return (unCRC == unPacketCRC) ? SDL_TRUE : SDL_FALSE; } -static SDL_bool -HIDAPI_DriverPS5_IsPacketValid(SDL_DriverPS5_Context *ctx, Uint8 *data, int size) +static SDL_bool HIDAPI_DriverPS5_IsPacketValid(SDL_DriverPS5_Context *ctx, Uint8 *data, int size) { switch (data[0]) { case k_EPS5ReportIdState: @@ -1327,12 +1302,11 @@ HIDAPI_DriverPS5_IsPacketValid(SDL_DriverPS5_Context *ctx, Uint8 *data, int size return SDL_FALSE; } -static SDL_bool -HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; SDL_Joystick *joystick = NULL; - Uint8 data[USB_PACKET_LENGTH*2]; + Uint8 data[USB_PACKET_LENGTH * 2]; int size; int packet_count = 0; Uint32 now = SDL_GetTicks(); @@ -1415,8 +1389,7 @@ HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device) return size >= 0; } -static void -HIDAPI_DriverPS5_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static void HIDAPI_DriverPS5_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; @@ -1429,13 +1402,11 @@ HIDAPI_DriverPS5_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick ctx->joystick = NULL; } -static void -HIDAPI_DriverPS5_FreeDevice(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverPS5_FreeDevice(SDL_HIDAPI_Device *device) { } -SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS5 = -{ +SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS5 = { SDL_HINT_JOYSTICK_HIDAPI_PS5, SDL_TRUE, HIDAPI_DriverPS5_RegisterHints, diff --git a/src/joystick/hidapi/SDL_hidapi_rumble.c b/src/joystick/hidapi/SDL_hidapi_rumble.c index c4112459e..d109b0e3c 100644 --- a/src/joystick/hidapi/SDL_hidapi_rumble.c +++ b/src/joystick/hidapi/SDL_hidapi_rumble.c @@ -30,11 +30,10 @@ #include "SDL_hidapi_rumble.h" #include "../../thread/SDL_systhread.h" - typedef struct SDL_HIDAPI_RumbleRequest { SDL_HIDAPI_Device *device; - Uint8 data[2*USB_PACKET_LENGTH]; /* need enough space for the biggest report: dualshock4 is 78 bytes */ + Uint8 data[2 * USB_PACKET_LENGTH]; /* need enough space for the biggest report: dualshock4 is 78 bytes */ int size; SDL_HIDAPI_RumbleSentCallback callback; void *userdata; @@ -98,8 +97,7 @@ static int SDLCALL SDL_HIDAPI_RumbleThread(void *data) return 0; } -static void -SDL_HIDAPI_StopRumbleThread(SDL_HIDAPI_RumbleContext *ctx) +static void SDL_HIDAPI_StopRumbleThread(SDL_HIDAPI_RumbleContext *ctx) { SDL_HIDAPI_RumbleRequest *request; @@ -142,8 +140,7 @@ SDL_HIDAPI_StopRumbleThread(SDL_HIDAPI_RumbleContext *ctx) SDL_AtomicSet(&ctx->initialized, SDL_FALSE); } -static int -SDL_HIDAPI_StartRumbleThread(SDL_HIDAPI_RumbleContext *ctx) +static int SDL_HIDAPI_StartRumbleThread(SDL_HIDAPI_RumbleContext *ctx) { ctx->lock = SDL_CreateMutex(); if (!ctx->lock) { @@ -226,7 +223,7 @@ int SDL_HIDAPI_SendRumbleWithCallbackAndUnlock(SDL_HIDAPI_Device *device, const request->userdata = userdata; SDL_AtomicIncRef(&device->rumble_pending); - + if (ctx->requests_head) { ctx->requests_head->prev = request; } else { diff --git a/src/joystick/hidapi/SDL_hidapi_shield.c b/src/joystick/hidapi/SDL_hidapi_shield.c index a4dcdbd01..e3fc9686b 100644 --- a/src/joystick/hidapi/SDL_hidapi_shield.c +++ b/src/joystick/hidapi/SDL_hidapi_shield.c @@ -30,15 +30,14 @@ #include "SDL_hidapijoystick_c.h" #include "SDL_hidapi_rumble.h" - #ifdef SDL_JOYSTICK_HIDAPI_SHIELD /* Define this if you want to log all packets from the controller */ /*#define DEBUG_SHIELD_PROTOCOL*/ #define CMD_BATTERY_STATE 0x07 -#define CMD_RUMBLE 0x39 -#define CMD_CHARGE_STATE 0x3A +#define CMD_RUMBLE 0x39 +#define CMD_CHARGE_STATE 0x3A /* Milliseconds between polls of battery state */ #define BATTERY_POLL_INTERVAL_MS 60000 @@ -59,7 +58,8 @@ enum SDL_CONTROLLER_NUM_SHIELD_V104_BUTTONS = SDL_CONTROLLER_BUTTON_MISC1 + 1, }; -typedef enum { +typedef enum +{ k_ShieldReportIdControllerState = 0x01, k_ShieldReportIdControllerTouch = 0x02, k_ShieldReportIdCommandResponse = 0x03, @@ -67,7 +67,8 @@ typedef enum { } EShieldReportId; /* This same report structure is used for both requests and responses */ -typedef struct { +typedef struct +{ Uint8 report_id; Uint8 cmd; Uint8 seq_num; @@ -75,7 +76,8 @@ typedef struct { } ShieldCommandReport_t; SDL_COMPILE_TIME_ASSERT(ShieldCommandReport_t, sizeof(ShieldCommandReport_t) == HID_REPORT_SIZE); -typedef struct { +typedef struct +{ Uint8 seq_num; SDL_JoystickPowerLevel battery_level; @@ -91,33 +93,27 @@ typedef struct { Uint8 last_state[USB_PACKET_LENGTH]; } SDL_DriverShield_Context; - -static void -HIDAPI_DriverShield_RegisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverShield_RegisterHints(SDL_HintCallback callback, void *userdata) { SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_SHIELD, callback, userdata); } -static void -HIDAPI_DriverShield_UnregisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverShield_UnregisterHints(SDL_HintCallback callback, void *userdata) { SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_SHIELD, callback, userdata); } -static SDL_bool -HIDAPI_DriverShield_IsEnabled(void) +static SDL_bool HIDAPI_DriverShield_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_SHIELD, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); } -static SDL_bool -HIDAPI_DriverShield_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static SDL_bool HIDAPI_DriverShield_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { return (type == SDL_CONTROLLER_TYPE_NVIDIA_SHIELD) ? SDL_TRUE : SDL_FALSE; } -static SDL_bool -HIDAPI_DriverShield_InitDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverShield_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverShield_Context *ctx; @@ -134,19 +130,16 @@ HIDAPI_DriverShield_InitDevice(SDL_HIDAPI_Device *device) return HIDAPI_JoystickConnected(device, NULL); } -static int -HIDAPI_DriverShield_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) +static int HIDAPI_DriverShield_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) { return -1; } -static void -HIDAPI_DriverShield_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) +static void HIDAPI_DriverShield_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) { } -static int -HIDAPI_DriverShield_SendCommand(SDL_HIDAPI_Device *device, Uint8 cmd, const void *data, int size) +static int HIDAPI_DriverShield_SendCommand(SDL_HIDAPI_Device *device, Uint8 cmd, const void *data, int size) { SDL_DriverShield_Context *ctx = (SDL_DriverShield_Context *)device->context; ShieldCommandReport_t cmd_pkt; @@ -171,15 +164,14 @@ HIDAPI_DriverShield_SendCommand(SDL_HIDAPI_Device *device, Uint8 cmd, const void SDL_memset(&cmd_pkt.payload[size], 0, sizeof(cmd_pkt.payload) - size); } - if (SDL_HIDAPI_SendRumbleAndUnlock(device, (Uint8*)&cmd_pkt, sizeof(cmd_pkt)) != sizeof(cmd_pkt)) { + if (SDL_HIDAPI_SendRumbleAndUnlock(device, (Uint8 *)&cmd_pkt, sizeof(cmd_pkt)) != sizeof(cmd_pkt)) { return SDL_SetError("Couldn't send command packet"); } return 0; } -static SDL_bool -HIDAPI_DriverShield_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static SDL_bool HIDAPI_DriverShield_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverShield_Context *ctx = (SDL_DriverShield_Context *)device->context; @@ -211,8 +203,7 @@ HIDAPI_DriverShield_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joysti return SDL_TRUE; } -static int -HIDAPI_DriverShield_SendNextRumble(SDL_HIDAPI_Device *device) +static int HIDAPI_DriverShield_SendNextRumble(SDL_HIDAPI_Device *device) { SDL_DriverShield_Context *ctx = device->context; Uint8 rumble_data[3]; @@ -231,8 +222,7 @@ HIDAPI_DriverShield_SendNextRumble(SDL_HIDAPI_Device *device) return HIDAPI_DriverShield_SendCommand(device, CMD_RUMBLE, rumble_data, sizeof(rumble_data)); } -static int -HIDAPI_DriverShield_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int HIDAPI_DriverShield_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { if (device->product_id == USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V103) { Uint8 rumble_packet[] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; @@ -262,26 +252,22 @@ HIDAPI_DriverShield_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joys } } -static int -HIDAPI_DriverShield_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int HIDAPI_DriverShield_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static Uint32 -HIDAPI_DriverShield_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static Uint32 HIDAPI_DriverShield_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { return SDL_JOYCAP_RUMBLE; } -static int -HIDAPI_DriverShield_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int HIDAPI_DriverShield_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -HIDAPI_DriverShield_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) +static int HIDAPI_DriverShield_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) { const Uint8 *data_bytes = data; @@ -296,14 +282,12 @@ HIDAPI_DriverShield_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick * } } -static int -HIDAPI_DriverShield_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverShield_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } -static void -HIDAPI_DriverShield_HandleStatePacketV103(SDL_Joystick *joystick, SDL_DriverShield_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverShield_HandleStatePacketV103(SDL_Joystick *joystick, SDL_DriverShield_Context *ctx, Uint8 *data, int size) { if (ctx->last_state[3] != data[3]) { SDL_bool dpad_up = SDL_FALSE; @@ -369,14 +353,14 @@ HIDAPI_DriverShield_HandleStatePacketV103(SDL_Joystick *joystick, SDL_DriverShie SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, (data[2] & 0x80) ? SDL_PRESSED : SDL_RELEASED); } - SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, SDL_SwapLE16(*(Sint16*)&data[4]) - 0x8000); - SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY, SDL_SwapLE16(*(Sint16*)&data[6]) - 0x8000); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, SDL_SwapLE16(*(Sint16 *)&data[4]) - 0x8000); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY, SDL_SwapLE16(*(Sint16 *)&data[6]) - 0x8000); - SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTX, SDL_SwapLE16(*(Sint16*)&data[8]) - 0x8000); - SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, SDL_SwapLE16(*(Sint16*)&data[10]) - 0x8000); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTX, SDL_SwapLE16(*(Sint16 *)&data[8]) - 0x8000); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, SDL_SwapLE16(*(Sint16 *)&data[10]) - 0x8000); - SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, SDL_SwapLE16(*(Sint16*)&data[12]) - 0x8000); - SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, SDL_SwapLE16(*(Sint16*)&data[14]) - 0x8000); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, SDL_SwapLE16(*(Sint16 *)&data[12]) - 0x8000); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, SDL_SwapLE16(*(Sint16 *)&data[14]) - 0x8000); SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); } @@ -384,8 +368,7 @@ HIDAPI_DriverShield_HandleStatePacketV103(SDL_Joystick *joystick, SDL_DriverShie #undef clamp #define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val))) -static void -HIDAPI_DriverShield_HandleTouchPacketV103(SDL_Joystick *joystick, SDL_DriverShield_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverShield_HandleTouchPacketV103(SDL_Joystick *joystick, SDL_DriverShield_Context *ctx, Uint8 *data, int size) { Uint8 touchpad_state; float touchpad_x, touchpad_y; @@ -399,8 +382,7 @@ HIDAPI_DriverShield_HandleTouchPacketV103(SDL_Joystick *joystick, SDL_DriverShie SDL_PrivateJoystickTouchpad(joystick, 0, 0, touchpad_state, touchpad_x, touchpad_y, touchpad_state ? 1.0f : 0.0f); } -static void -HIDAPI_DriverShield_HandleStatePacketV104(SDL_Joystick *joystick, SDL_DriverShield_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverShield_HandleStatePacketV104(SDL_Joystick *joystick, SDL_DriverShield_Context *ctx, Uint8 *data, int size) { if (size < 23) { return; @@ -465,14 +447,14 @@ HIDAPI_DriverShield_HandleStatePacketV104(SDL_Joystick *joystick, SDL_DriverShie SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_START, (data[4] & 0x01) ? SDL_PRESSED : SDL_RELEASED); } - SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, SDL_SwapLE16(*(Sint16*)&data[9]) - 0x8000); - SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY, SDL_SwapLE16(*(Sint16*)&data[11]) - 0x8000); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, SDL_SwapLE16(*(Sint16 *)&data[9]) - 0x8000); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY, SDL_SwapLE16(*(Sint16 *)&data[11]) - 0x8000); - SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTX, SDL_SwapLE16(*(Sint16*)&data[13]) - 0x8000); - SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, SDL_SwapLE16(*(Sint16*)&data[15]) - 0x8000); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTX, SDL_SwapLE16(*(Sint16 *)&data[13]) - 0x8000); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, SDL_SwapLE16(*(Sint16 *)&data[15]) - 0x8000); - SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, SDL_SwapLE16(*(Sint16*)&data[19]) - 0x8000); - SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, SDL_SwapLE16(*(Sint16*)&data[21]) - 0x8000); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, SDL_SwapLE16(*(Sint16 *)&data[19]) - 0x8000); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, SDL_SwapLE16(*(Sint16 *)&data[21]) - 0x8000); if (ctx->last_state[17] != data[17]) { SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, (data[17] & 0x01) ? SDL_PRESSED : SDL_RELEASED); @@ -483,8 +465,7 @@ HIDAPI_DriverShield_HandleStatePacketV104(SDL_Joystick *joystick, SDL_DriverShie SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); } -static SDL_bool -HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverShield_Context *ctx = (SDL_DriverShield_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -505,61 +486,61 @@ HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device) /* Byte 0 is HID report ID */ switch (data[0]) { - case k_ShieldReportIdControllerState: - if (joystick == NULL) { + case k_ShieldReportIdControllerState: + if (joystick == NULL) { + break; + } + if (size == 16) { + HIDAPI_DriverShield_HandleStatePacketV103(joystick, ctx, data, size); + } else { + HIDAPI_DriverShield_HandleStatePacketV104(joystick, ctx, data, size); + } + break; + case k_ShieldReportIdControllerTouch: + if (joystick == NULL) { + break; + } + HIDAPI_DriverShield_HandleTouchPacketV103(joystick, ctx, data, size); + break; + case k_ShieldReportIdCommandResponse: + cmd_resp_report = (ShieldCommandReport_t *)data; + switch (cmd_resp_report->cmd) { + case CMD_RUMBLE: + ctx->rumble_report_pending = SDL_FALSE; + HIDAPI_DriverShield_SendNextRumble(device); + break; + case CMD_CHARGE_STATE: + ctx->charging = cmd_resp_report->payload[0] != 0; + if (joystick) { + SDL_PrivateJoystickBatteryLevel(joystick, ctx->charging ? SDL_JOYSTICK_POWER_WIRED : ctx->battery_level); + } + break; + case CMD_BATTERY_STATE: + switch (cmd_resp_report->payload[2]) { + case 0: + ctx->battery_level = SDL_JOYSTICK_POWER_EMPTY; + break; + case 1: + ctx->battery_level = SDL_JOYSTICK_POWER_LOW; + break; + case 2: /* 40% */ + case 3: /* 60% */ + case 4: /* 80% */ + ctx->battery_level = SDL_JOYSTICK_POWER_MEDIUM; + break; + case 5: + ctx->battery_level = SDL_JOYSTICK_POWER_FULL; + break; + default: + ctx->battery_level = SDL_JOYSTICK_POWER_UNKNOWN; break; } - if (size == 16) { - HIDAPI_DriverShield_HandleStatePacketV103(joystick, ctx, data, size); - } else { - HIDAPI_DriverShield_HandleStatePacketV104(joystick, ctx, data, size); - } - break; - case k_ShieldReportIdControllerTouch: - if (joystick == NULL) { - break; - } - HIDAPI_DriverShield_HandleTouchPacketV103(joystick, ctx, data, size); - break; - case k_ShieldReportIdCommandResponse: - cmd_resp_report = (ShieldCommandReport_t*)data; - switch (cmd_resp_report->cmd) { - case CMD_RUMBLE: - ctx->rumble_report_pending = SDL_FALSE; - HIDAPI_DriverShield_SendNextRumble(device); - break; - case CMD_CHARGE_STATE: - ctx->charging = cmd_resp_report->payload[0] != 0; - if (joystick) { - SDL_PrivateJoystickBatteryLevel(joystick, ctx->charging ? SDL_JOYSTICK_POWER_WIRED : ctx->battery_level); - } - break; - case CMD_BATTERY_STATE: - switch (cmd_resp_report->payload[2]) { - case 0: - ctx->battery_level = SDL_JOYSTICK_POWER_EMPTY; - break; - case 1: - ctx->battery_level = SDL_JOYSTICK_POWER_LOW; - break; - case 2: /* 40% */ - case 3: /* 60% */ - case 4: /* 80% */ - ctx->battery_level = SDL_JOYSTICK_POWER_MEDIUM; - break; - case 5: - ctx->battery_level = SDL_JOYSTICK_POWER_FULL; - break; - default: - ctx->battery_level = SDL_JOYSTICK_POWER_UNKNOWN; - break; - } - if (joystick) { - SDL_PrivateJoystickBatteryLevel(joystick, ctx->charging ? SDL_JOYSTICK_POWER_WIRED : ctx->battery_level); - } - break; + if (joystick) { + SDL_PrivateJoystickBatteryLevel(joystick, ctx->charging ? SDL_JOYSTICK_POWER_WIRED : ctx->battery_level); } break; + } + break; } } @@ -583,18 +564,15 @@ HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device) return size >= 0; } -static void -HIDAPI_DriverShield_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static void HIDAPI_DriverShield_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { } -static void -HIDAPI_DriverShield_FreeDevice(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverShield_FreeDevice(SDL_HIDAPI_Device *device) { } -SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverShield = -{ +SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverShield = { SDL_HINT_JOYSTICK_HIDAPI_SHIELD, SDL_TRUE, HIDAPI_DriverShield_RegisterHints, diff --git a/src/joystick/hidapi/SDL_hidapi_stadia.c b/src/joystick/hidapi/SDL_hidapi_stadia.c index 6c6d0d5cc..15542a0f2 100644 --- a/src/joystick/hidapi/SDL_hidapi_stadia.c +++ b/src/joystick/hidapi/SDL_hidapi_stadia.c @@ -29,7 +29,6 @@ #include "SDL_hidapijoystick_c.h" #include "SDL_hidapi_rumble.h" - #ifdef SDL_JOYSTICK_HIDAPI_STADIA /* Define this if you want to log all packets from the controller */ @@ -42,37 +41,32 @@ enum SDL_CONTROLLER_NUM_STADIA_BUTTONS, }; -typedef struct { +typedef struct +{ Uint8 last_state[USB_PACKET_LENGTH]; } SDL_DriverStadia_Context; - -static void -HIDAPI_DriverStadia_RegisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverStadia_RegisterHints(SDL_HintCallback callback, void *userdata) { SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_STADIA, callback, userdata); } -static void -HIDAPI_DriverStadia_UnregisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverStadia_UnregisterHints(SDL_HintCallback callback, void *userdata) { SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_STADIA, callback, userdata); } -static SDL_bool -HIDAPI_DriverStadia_IsEnabled(void) +static SDL_bool HIDAPI_DriverStadia_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_STADIA, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); } -static SDL_bool -HIDAPI_DriverStadia_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static SDL_bool HIDAPI_DriverStadia_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { return (type == SDL_CONTROLLER_TYPE_GOOGLE_STADIA) ? SDL_TRUE : SDL_FALSE; } -static SDL_bool -HIDAPI_DriverStadia_InitDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverStadia_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverStadia_Context *ctx; @@ -89,19 +83,16 @@ HIDAPI_DriverStadia_InitDevice(SDL_HIDAPI_Device *device) return HIDAPI_JoystickConnected(device, NULL); } -static int -HIDAPI_DriverStadia_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) +static int HIDAPI_DriverStadia_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) { return -1; } -static void -HIDAPI_DriverStadia_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) +static void HIDAPI_DriverStadia_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) { } -static SDL_bool -HIDAPI_DriverStadia_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static SDL_bool HIDAPI_DriverStadia_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverStadia_Context *ctx = (SDL_DriverStadia_Context *)device->context; @@ -115,8 +106,7 @@ HIDAPI_DriverStadia_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joysti return SDL_TRUE; } -static int -HIDAPI_DriverStadia_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int HIDAPI_DriverStadia_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { Uint8 rumble_packet[] = { 0x05, 0x00, 0x00, 0x00, 0x00 }; @@ -131,42 +121,36 @@ HIDAPI_DriverStadia_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joys return 0; } -static int -HIDAPI_DriverStadia_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int HIDAPI_DriverStadia_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static Uint32 -HIDAPI_DriverStadia_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static Uint32 HIDAPI_DriverStadia_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { return SDL_JOYCAP_RUMBLE; } -static int -HIDAPI_DriverStadia_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int HIDAPI_DriverStadia_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -HIDAPI_DriverStadia_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) +static int HIDAPI_DriverStadia_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -HIDAPI_DriverStadia_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverStadia_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } -static void -HIDAPI_DriverStadia_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverStadia_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverStadia_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverStadia_Context *ctx, Uint8 *data, int size) { Sint16 axis; - // The format is the same but the original FW will send 10 bytes and January '21 FW update will send 11 + // The format is the same but the original FW will send 10 bytes and January '21 FW update will send 11 if (size < 10 || data[0] != 0x03) { /* We don't know how to handle this report */ return; @@ -236,8 +220,7 @@ HIDAPI_DriverStadia_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverStadia_C } #define READ_STICK_AXIS(offset) \ - (data[offset] == 0x80 ? 0 : \ - (Sint16)HIDAPI_RemapVal((float)((int)data[offset] - 0x80), 0x01 - 0x80, 0xff - 0x80, SDL_MIN_SINT16, SDL_MAX_SINT16)) + (data[offset] == 0x80 ? 0 : (Sint16)HIDAPI_RemapVal((float)((int)data[offset] - 0x80), 0x01 - 0x80, 0xff - 0x80, SDL_MIN_SINT16, SDL_MAX_SINT16)) { axis = READ_STICK_AXIS(4); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis); @@ -263,8 +246,7 @@ HIDAPI_DriverStadia_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverStadia_C SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); } -static SDL_bool -HIDAPI_DriverStadia_UpdateDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverStadia_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverStadia_Context *ctx = (SDL_DriverStadia_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -295,18 +277,15 @@ HIDAPI_DriverStadia_UpdateDevice(SDL_HIDAPI_Device *device) return size >= 0; } -static void -HIDAPI_DriverStadia_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static void HIDAPI_DriverStadia_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { } -static void -HIDAPI_DriverStadia_FreeDevice(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverStadia_FreeDevice(SDL_HIDAPI_Device *device) { } -SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverStadia = -{ +SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverStadia = { SDL_HINT_JOYSTICK_HIDAPI_STADIA, SDL_TRUE, HIDAPI_DriverStadia_RegisterHints, diff --git a/src/joystick/hidapi/SDL_hidapi_steam.c b/src/joystick/hidapi/SDL_hidapi_steam.c index 23d3b8c43..433c7ca72 100644 --- a/src/joystick/hidapi/SDL_hidapi_steam.c +++ b/src/joystick/hidapi/SDL_hidapi_steam.c @@ -29,8 +29,6 @@ #include "../SDL_sysjoystick.h" #include "SDL_hidapijoystick_c.h" - - #ifdef SDL_JOYSTICK_HIDAPI_STEAM /*****************************************************************************************************/ @@ -45,7 +43,7 @@ typedef enum typedef uint32_t uint32; typedef uint64_t uint64; - + #include "steam/controller_constants.h" #include "steam/controller_structs.h" @@ -54,17 +52,17 @@ typedef struct SteamControllerStateInternal_t // Controller Type for this Controller State uint32 eControllerType; - // If packet num matches that on your prior call, then the controller state hasn't been changed since + // If packet num matches that on your prior call, then the controller state hasn't been changed since // your last call and there is no need to process it uint32 unPacketNum; - + // bit flags for each of the buttons uint64 ulButtons; - + // Left pad coordinates short sLeftPadX; short sLeftPadY; - + // Right pad coordinates short sRightPadX; short sRightPadY; @@ -72,7 +70,7 @@ typedef struct SteamControllerStateInternal_t // Center pad coordinates short sCenterPadX; short sCenterPadY; - + // Left analog stick coordinates short sLeftStickX; short sLeftStickY; @@ -80,137 +78,133 @@ typedef struct SteamControllerStateInternal_t // Right analog stick coordinates short sRightStickX; short sRightStickY; - + unsigned short sTriggerL; unsigned short sTriggerR; - + short sAccelX; short sAccelY; short sAccelZ; - + short sGyroX; short sGyroY; short sGyroZ; - + float sGyroQuatW; float sGyroQuatX; float sGyroQuatY; float sGyroQuatZ; - + short sGyroSteeringAngle; - + unsigned short sBatteryLevel; // Pressure sensor data. unsigned short sPressurePadLeft; unsigned short sPressurePadRight; - + unsigned short sPressureBumperLeft; unsigned short sPressureBumperRight; - + // Internal state data short sPrevLeftPad[2]; short sPrevLeftStick[2]; } SteamControllerStateInternal_t; - /* Defines for ulButtons in SteamControllerStateInternal_t */ -#define STEAM_RIGHT_TRIGGER_MASK 0x00000001 -#define STEAM_LEFT_TRIGGER_MASK 0x00000002 -#define STEAM_RIGHT_BUMPER_MASK 0x00000004 -#define STEAM_LEFT_BUMPER_MASK 0x00000008 -#define STEAM_BUTTON_0_MASK 0x00000010 /* Y */ -#define STEAM_BUTTON_1_MASK 0x00000020 /* B */ -#define STEAM_BUTTON_2_MASK 0x00000040 /* X */ -#define STEAM_BUTTON_3_MASK 0x00000080 /* A */ -#define STEAM_TOUCH_0_MASK 0x00000100 /* DPAD UP */ -#define STEAM_TOUCH_1_MASK 0x00000200 /* DPAD RIGHT */ -#define STEAM_TOUCH_2_MASK 0x00000400 /* DPAD LEFT */ -#define STEAM_TOUCH_3_MASK 0x00000800 /* DPAD DOWN */ -#define STEAM_BUTTON_MENU_MASK 0x00001000 /* SELECT */ -#define STEAM_BUTTON_STEAM_MASK 0x00002000 /* GUIDE */ -#define STEAM_BUTTON_ESCAPE_MASK 0x00004000 /* START */ -#define STEAM_BUTTON_BACK_LEFT_MASK 0x00008000 -#define STEAM_BUTTON_BACK_RIGHT_MASK 0x00010000 -#define STEAM_BUTTON_LEFTPAD_CLICKED_MASK 0x00020000 -#define STEAM_BUTTON_RIGHTPAD_CLICKED_MASK 0x00040000 -#define STEAM_LEFTPAD_FINGERDOWN_MASK 0x00080000 -#define STEAM_RIGHTPAD_FINGERDOWN_MASK 0x00100000 -#define STEAM_JOYSTICK_BUTTON_MASK 0x00400000 -#define STEAM_LEFTPAD_AND_JOYSTICK_MASK 0x00800000 - +#define STEAM_RIGHT_TRIGGER_MASK 0x00000001 +#define STEAM_LEFT_TRIGGER_MASK 0x00000002 +#define STEAM_RIGHT_BUMPER_MASK 0x00000004 +#define STEAM_LEFT_BUMPER_MASK 0x00000008 +#define STEAM_BUTTON_0_MASK 0x00000010 /* Y */ +#define STEAM_BUTTON_1_MASK 0x00000020 /* B */ +#define STEAM_BUTTON_2_MASK 0x00000040 /* X */ +#define STEAM_BUTTON_3_MASK 0x00000080 /* A */ +#define STEAM_TOUCH_0_MASK 0x00000100 /* DPAD UP */ +#define STEAM_TOUCH_1_MASK 0x00000200 /* DPAD RIGHT */ +#define STEAM_TOUCH_2_MASK 0x00000400 /* DPAD LEFT */ +#define STEAM_TOUCH_3_MASK 0x00000800 /* DPAD DOWN */ +#define STEAM_BUTTON_MENU_MASK 0x00001000 /* SELECT */ +#define STEAM_BUTTON_STEAM_MASK 0x00002000 /* GUIDE */ +#define STEAM_BUTTON_ESCAPE_MASK 0x00004000 /* START */ +#define STEAM_BUTTON_BACK_LEFT_MASK 0x00008000 +#define STEAM_BUTTON_BACK_RIGHT_MASK 0x00010000 +#define STEAM_BUTTON_LEFTPAD_CLICKED_MASK 0x00020000 +#define STEAM_BUTTON_RIGHTPAD_CLICKED_MASK 0x00040000 +#define STEAM_LEFTPAD_FINGERDOWN_MASK 0x00080000 +#define STEAM_RIGHTPAD_FINGERDOWN_MASK 0x00100000 +#define STEAM_JOYSTICK_BUTTON_MASK 0x00400000 +#define STEAM_LEFTPAD_AND_JOYSTICK_MASK 0x00800000 // Look for report version 0x0001, type WIRELESS (3), length >= 1 byte -#define D0G_IS_VALID_WIRELESS_EVENT(data, len) ((len) >= 5 && (data)[0] == 1 && (data)[1] == 0 && (data)[2] == 3 && (data)[3] >= 1) -#define D0G_GET_WIRELESS_EVENT_TYPE(data) ((data)[4]) -#define D0G_WIRELESS_DISCONNECTED 1 -#define D0G_WIRELESS_ESTABLISHED 2 -#define D0G_WIRELESS_NEWLYPAIRED 3 +#define D0G_IS_VALID_WIRELESS_EVENT(data, len) ((len) >= 5 && (data)[0] == 1 && (data)[1] == 0 && (data)[2] == 3 && (data)[3] >= 1) +#define D0G_GET_WIRELESS_EVENT_TYPE(data) ((data)[4]) +#define D0G_WIRELESS_DISCONNECTED 1 +#define D0G_WIRELESS_ESTABLISHED 2 +#define D0G_WIRELESS_NEWLYPAIRED 3 -#define D0G_IS_WIRELESS_DISCONNECT(data, len) ( D0G_IS_VALID_WIRELESS_EVENT(data,len) && D0G_GET_WIRELESS_EVENT_TYPE(data) == D0G_WIRELESS_DISCONNECTED ) +#define D0G_IS_WIRELESS_DISCONNECT(data, len) (D0G_IS_VALID_WIRELESS_EVENT(data, len) && D0G_GET_WIRELESS_EVENT_TYPE(data) == D0G_WIRELESS_DISCONNECTED) -#define MAX_REPORT_SEGMENT_PAYLOAD_SIZE 18 +#define MAX_REPORT_SEGMENT_PAYLOAD_SIZE 18 /* * SteamControllerPacketAssembler has to be used when reading output repots from controllers. */ typedef struct { - uint8_t uBuffer[ MAX_REPORT_SEGMENT_PAYLOAD_SIZE * 8 + 1 ]; + uint8_t uBuffer[MAX_REPORT_SEGMENT_PAYLOAD_SIZE * 8 + 1]; int nExpectedSegmentNumber; bool bIsBle; } SteamControllerPacketAssembler; - #undef clamp #define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val))) #undef offsetof -#define offsetof(s,m) (size_t)&(((s *)0)->m) +#define offsetof(s, m) (size_t) & (((s *)0)->m) #ifdef DEBUG_STEAM_CONTROLLER #define DPRINTF(format, ...) printf(format, ##__VA_ARGS__) -#define HEXDUMP(ptr, len) hexdump(ptr, len) +#define HEXDUMP(ptr, len) hexdump(ptr, len) #else #define DPRINTF(format, ...) #define HEXDUMP(ptr, len) #endif -#define printf SDL_Log +#define printf SDL_Log -#define MAX_REPORT_SEGMENT_SIZE ( MAX_REPORT_SEGMENT_PAYLOAD_SIZE + 2 ) -#define CALC_REPORT_SEGMENT_NUM(index) ( ( index / MAX_REPORT_SEGMENT_PAYLOAD_SIZE ) & 0x07 ) -#define REPORT_SEGMENT_DATA_FLAG 0x80 -#define REPORT_SEGMENT_LAST_FLAG 0x40 -#define BLE_REPORT_NUMBER 0x03 +#define MAX_REPORT_SEGMENT_SIZE (MAX_REPORT_SEGMENT_PAYLOAD_SIZE + 2) +#define CALC_REPORT_SEGMENT_NUM(index) ((index / MAX_REPORT_SEGMENT_PAYLOAD_SIZE) & 0x07) +#define REPORT_SEGMENT_DATA_FLAG 0x80 +#define REPORT_SEGMENT_LAST_FLAG 0x40 +#define BLE_REPORT_NUMBER 0x03 #define STEAMCONTROLLER_TRIGGER_MAX_ANALOG 26000 // Enable mouse mode when using the Steam Controller locally #undef ENABLE_MOUSE_MODE - // Wireless firmware quirk: the firmware intentionally signals "failure" when performing // SET_FEATURE / GET_FEATURE when it actually means "pending radio roundtrip". The only // way to make SET_FEATURE / GET_FEATURE work is to loop several times with a sleep. If // it takes more than 50ms to get the response for SET_FEATURE / GET_FEATURE, we assume // that the controller has failed. -#define RADIO_WORKAROUND_SLEEP_ATTEMPTS 50 +#define RADIO_WORKAROUND_SLEEP_ATTEMPTS 50 #define RADIO_WORKAROUND_SLEEP_DURATION_US 500 // This was defined by experimentation. 2000 seemed to work but to give that extra bit of margin, set to 3ms. #define CONTROLLER_CONFIGURATION_DELAY_US 3000 -static uint8_t GetSegmentHeader( int nSegmentNumber, bool bLastPacket ) +static uint8_t GetSegmentHeader(int nSegmentNumber, bool bLastPacket) { uint8_t header = REPORT_SEGMENT_DATA_FLAG; header |= nSegmentNumber; if (bLastPacket) { header |= REPORT_SEGMENT_LAST_FLAG; } - + return header; } -static void hexdump( const uint8_t *ptr, int len ) +static void hexdump(const uint8_t *ptr, int len) { int i; for (i = 0; i < len; ++i) { @@ -219,141 +213,141 @@ static void hexdump( const uint8_t *ptr, int len ) printf("\n"); } -static void ResetSteamControllerPacketAssembler( SteamControllerPacketAssembler *pAssembler ) +static void ResetSteamControllerPacketAssembler(SteamControllerPacketAssembler *pAssembler) { - SDL_memset( pAssembler->uBuffer, 0, sizeof( pAssembler->uBuffer ) ); + SDL_memset(pAssembler->uBuffer, 0, sizeof(pAssembler->uBuffer)); pAssembler->nExpectedSegmentNumber = 0; } -static void InitializeSteamControllerPacketAssembler( SteamControllerPacketAssembler *pAssembler ) +static void InitializeSteamControllerPacketAssembler(SteamControllerPacketAssembler *pAssembler) { /* We only support BLE devices right now */ pAssembler->bIsBle = true; - ResetSteamControllerPacketAssembler( pAssembler ); + ResetSteamControllerPacketAssembler(pAssembler); } // Returns: // <0 on error // 0 on not ready // Complete packet size on completion -static int WriteSegmentToSteamControllerPacketAssembler( SteamControllerPacketAssembler *pAssembler, const uint8_t *pSegment, int nSegmentLength ) +static int WriteSegmentToSteamControllerPacketAssembler(SteamControllerPacketAssembler *pAssembler, const uint8_t *pSegment, int nSegmentLength) { - if ( pAssembler->bIsBle ) { - uint8_t uSegmentHeader = pSegment[ 1 ]; + if (pAssembler->bIsBle) { + uint8_t uSegmentHeader = pSegment[1]; int nSegmentNumber = uSegmentHeader & 0x07; - HEXDUMP( pSegment, nSegmentLength ); + HEXDUMP(pSegment, nSegmentLength); - if ( pSegment[ 0 ] != BLE_REPORT_NUMBER ) { + if (pSegment[0] != BLE_REPORT_NUMBER) { // We may get keyboard/mouse input events until controller stops sending them return 0; } - - if ( nSegmentLength != MAX_REPORT_SEGMENT_SIZE ) { - printf( "Bad segment size! %d\n", (int)nSegmentLength ); - hexdump( pSegment, nSegmentLength ); - ResetSteamControllerPacketAssembler( pAssembler ); + + if (nSegmentLength != MAX_REPORT_SEGMENT_SIZE) { + printf("Bad segment size! %d\n", (int)nSegmentLength); + hexdump(pSegment, nSegmentLength); + ResetSteamControllerPacketAssembler(pAssembler); return -1; } - + DPRINTF("GOT PACKET HEADER = 0x%x\n", uSegmentHeader); - - if ( ( uSegmentHeader & REPORT_SEGMENT_DATA_FLAG ) == 0 ) { + + if ((uSegmentHeader & REPORT_SEGMENT_DATA_FLAG) == 0) { // We get empty segments, just ignore them return 0; } - - if ( nSegmentNumber != pAssembler->nExpectedSegmentNumber ) { - ResetSteamControllerPacketAssembler( pAssembler ); - - if ( nSegmentNumber ) { + + if (nSegmentNumber != pAssembler->nExpectedSegmentNumber) { + ResetSteamControllerPacketAssembler(pAssembler); + + if (nSegmentNumber) { // This happens occasionally DPRINTF("Bad segment number, got %d, expected %d\n", - nSegmentNumber, pAssembler->nExpectedSegmentNumber ); + nSegmentNumber, pAssembler->nExpectedSegmentNumber); return -1; } } - - SDL_memcpy( pAssembler->uBuffer + nSegmentNumber * MAX_REPORT_SEGMENT_PAYLOAD_SIZE, - pSegment + 2, // ignore header and report number - MAX_REPORT_SEGMENT_PAYLOAD_SIZE ); - - if ( uSegmentHeader & REPORT_SEGMENT_LAST_FLAG ) { + + SDL_memcpy(pAssembler->uBuffer + nSegmentNumber * MAX_REPORT_SEGMENT_PAYLOAD_SIZE, + pSegment + 2, // ignore header and report number + MAX_REPORT_SEGMENT_PAYLOAD_SIZE); + + if (uSegmentHeader & REPORT_SEGMENT_LAST_FLAG) { pAssembler->nExpectedSegmentNumber = 0; - return ( nSegmentNumber + 1 ) * MAX_REPORT_SEGMENT_PAYLOAD_SIZE; + return (nSegmentNumber + 1) * MAX_REPORT_SEGMENT_PAYLOAD_SIZE; } - + pAssembler->nExpectedSegmentNumber++; } else { // Just pass through - SDL_memcpy( pAssembler->uBuffer, - pSegment, - nSegmentLength ); + SDL_memcpy(pAssembler->uBuffer, + pSegment, + nSegmentLength); return nSegmentLength; } - + return 0; } -#define BLE_MAX_READ_RETRIES 8 +#define BLE_MAX_READ_RETRIES 8 -static int SetFeatureReport( SDL_hid_device *dev, unsigned char uBuffer[65], int nActualDataLen ) +static int SetFeatureReport(SDL_hid_device *dev, unsigned char uBuffer[65], int nActualDataLen) { int nRet = -1; bool bBle = true; // only wireless/BLE for now, though macOS could do wired in the future - + DPRINTF("SetFeatureReport %p %p %d\n", dev, uBuffer, nActualDataLen); - if ( bBle ) { + if (bBle) { int nSegmentNumber = 0; - uint8_t uPacketBuffer[ MAX_REPORT_SEGMENT_SIZE ]; + uint8_t uPacketBuffer[MAX_REPORT_SEGMENT_SIZE]; unsigned char *pBufferPtr = uBuffer + 1; if (nActualDataLen < 1) { return -1; } - + // Skip report number in data nActualDataLen--; - - while ( nActualDataLen > 0 ) { + + while (nActualDataLen > 0) { int nBytesInPacket = nActualDataLen > MAX_REPORT_SEGMENT_PAYLOAD_SIZE ? MAX_REPORT_SEGMENT_PAYLOAD_SIZE : nActualDataLen; - + nActualDataLen -= nBytesInPacket; // Construct packet - SDL_memset( uPacketBuffer, 0, sizeof( uPacketBuffer ) ); - uPacketBuffer[ 0 ] = BLE_REPORT_NUMBER; - uPacketBuffer[ 1 ] = GetSegmentHeader( nSegmentNumber, nActualDataLen == 0 ); - SDL_memcpy( &uPacketBuffer[ 2 ], pBufferPtr, nBytesInPacket ); - + SDL_memset(uPacketBuffer, 0, sizeof(uPacketBuffer)); + uPacketBuffer[0] = BLE_REPORT_NUMBER; + uPacketBuffer[1] = GetSegmentHeader(nSegmentNumber, nActualDataLen == 0); + SDL_memcpy(&uPacketBuffer[2], pBufferPtr, nBytesInPacket); + pBufferPtr += nBytesInPacket; nSegmentNumber++; - - nRet = SDL_hid_send_feature_report( dev, uPacketBuffer, sizeof( uPacketBuffer ) ); + + nRet = SDL_hid_send_feature_report(dev, uPacketBuffer, sizeof(uPacketBuffer)); DPRINTF("SetFeatureReport() ret = %d\n", nRet); } } - + return nRet; } -static int GetFeatureReport( SDL_hid_device *dev, unsigned char uBuffer[65] ) +static int GetFeatureReport(SDL_hid_device *dev, unsigned char uBuffer[65]) { int nRet = -1; bool bBle = true; - DPRINTF("GetFeatureReport( %p %p )\n", dev, uBuffer ); + DPRINTF("GetFeatureReport( %p %p )\n", dev, uBuffer); - if ( bBle ) { + if (bBle) { int nRetries = 0; - uint8_t uSegmentBuffer[ MAX_REPORT_SEGMENT_SIZE + 1 ]; + uint8_t uSegmentBuffer[MAX_REPORT_SEGMENT_SIZE + 1]; uint8_t ucBytesToRead = MAX_REPORT_SEGMENT_SIZE; uint8_t ucDataStartOffset = 0; SteamControllerPacketAssembler assembler; - InitializeSteamControllerPacketAssembler( &assembler ); - + InitializeSteamControllerPacketAssembler(&assembler); + // On Windows and macOS, BLE devices get 2 copies of the feature report ID, one that is removed by ReadFeatureReport, // and one that's included in the buffer we receive. We pad the bytes to read and skip over the report ID // if necessary. @@ -362,66 +356,64 @@ static int GetFeatureReport( SDL_hid_device *dev, unsigned char uBuffer[65] ) ++ucDataStartOffset; #endif - while ( nRetries < BLE_MAX_READ_RETRIES ) { - SDL_memset( uSegmentBuffer, 0, sizeof( uSegmentBuffer ) ); - uSegmentBuffer[ 0 ] = BLE_REPORT_NUMBER; - nRet = SDL_hid_get_feature_report( dev, uSegmentBuffer, ucBytesToRead ); + while (nRetries < BLE_MAX_READ_RETRIES) { + SDL_memset(uSegmentBuffer, 0, sizeof(uSegmentBuffer)); + uSegmentBuffer[0] = BLE_REPORT_NUMBER; + nRet = SDL_hid_get_feature_report(dev, uSegmentBuffer, ucBytesToRead); + + DPRINTF("GetFeatureReport ble ret=%d\n", nRet); + HEXDUMP(uSegmentBuffer, nRet); - DPRINTF( "GetFeatureReport ble ret=%d\n", nRet ); - HEXDUMP( uSegmentBuffer, nRet ); - // Zero retry counter if we got data - if ( nRet > 2 && ( uSegmentBuffer[ ucDataStartOffset + 1 ] & REPORT_SEGMENT_DATA_FLAG ) ) + if (nRet > 2 && (uSegmentBuffer[ucDataStartOffset + 1] & REPORT_SEGMENT_DATA_FLAG)) nRetries = 0; else nRetries++; - if ( nRet > 0 ) { - int nPacketLength = WriteSegmentToSteamControllerPacketAssembler( &assembler, + if (nRet > 0) { + int nPacketLength = WriteSegmentToSteamControllerPacketAssembler(&assembler, uSegmentBuffer + ucDataStartOffset, - nRet - ucDataStartOffset ); - - if ( nPacketLength > 0 && nPacketLength < 65 ) { + nRet - ucDataStartOffset); + + if (nPacketLength > 0 && nPacketLength < 65) { // Leave space for "report number" - uBuffer[ 0 ] = 0; - SDL_memcpy( uBuffer + 1, assembler.uBuffer, nPacketLength ); + uBuffer[0] = 0; + SDL_memcpy(uBuffer + 1, assembler.uBuffer, nPacketLength); return nPacketLength; } } - - } - printf("Could not get a full ble packet after %d retries\n", nRetries ); + printf("Could not get a full ble packet after %d retries\n", nRetries); return -1; } - + return nRet; } -static int ReadResponse( SDL_hid_device *dev, uint8_t uBuffer[65], int nExpectedResponse ) +static int ReadResponse(SDL_hid_device *dev, uint8_t uBuffer[65], int nExpectedResponse) { - int nRet = GetFeatureReport( dev, uBuffer ); + int nRet = GetFeatureReport(dev, uBuffer); - DPRINTF("ReadResponse( %p %p %d )\n", dev, uBuffer, nExpectedResponse ); + DPRINTF("ReadResponse( %p %p %d )\n", dev, uBuffer, nExpectedResponse); if (nRet < 0) { return nRet; } - - DPRINTF("ReadResponse got %d bytes of data: ", nRet ); - HEXDUMP( uBuffer, nRet ); - + + DPRINTF("ReadResponse got %d bytes of data: ", nRet); + HEXDUMP(uBuffer, nRet); + if (uBuffer[1] != nExpectedResponse) { return -1; } - + return nRet; } //--------------------------------------------------------------------------- // Reset steam controller (unmap buttons and pads) and re-fetch capability bits //--------------------------------------------------------------------------- -static bool ResetSteamController( SDL_hid_device *dev, bool bSuppressErrorSpew, uint32_t *punUpdateRateUS ) +static bool ResetSteamController(SDL_hid_device *dev, bool bSuppressErrorSpew, uint32_t *punUpdateRateUS) { // Firmware quirk: Set Feature and Get Feature requests always require a 65-byte buffer. unsigned char buf[65]; @@ -431,32 +423,32 @@ static bool ResetSteamController( SDL_hid_device *dev, bool bSuppressErrorSpew, int nAttributesLength; FeatureReportMsg *msg; uint32_t unUpdateRateUS = 9000; // Good default rate - - DPRINTF( "ResetSteamController hid=%p\n", dev ); + + DPRINTF("ResetSteamController hid=%p\n", dev); buf[0] = 0; buf[1] = ID_GET_ATTRIBUTES_VALUES; - res = SetFeatureReport( dev, buf, 2 ); - if ( res < 0 ) { + res = SetFeatureReport(dev, buf, 2); + if (res < 0) { if (!bSuppressErrorSpew) { printf("GET_ATTRIBUTES_VALUES failed for controller %p\n", dev); } return false; } - + // Retrieve GET_ATTRIBUTES_VALUES result // Wireless controller endpoints without a connected controller will return nAttrs == 0 - res = ReadResponse( dev, buf, ID_GET_ATTRIBUTES_VALUES ); - if ( res < 0 || buf[1] != ID_GET_ATTRIBUTES_VALUES ) { + res = ReadResponse(dev, buf, ID_GET_ATTRIBUTES_VALUES); + if (res < 0 || buf[1] != ID_GET_ATTRIBUTES_VALUES) { HEXDUMP(buf, res); if (!bSuppressErrorSpew) { printf("Bad GET_ATTRIBUTES_VALUES response for controller %p\n", dev); } return false; } - - nAttributesLength = buf[ 2 ]; - if ( nAttributesLength > res ) { + + nAttributesLength = buf[2]; + if (nAttributesLength > res) { if (!bSuppressErrorSpew) { printf("Bad GET_ATTRIBUTES_VALUES response for controller %p\n", dev); } @@ -464,12 +456,11 @@ static bool ResetSteamController( SDL_hid_device *dev, bool bSuppressErrorSpew, } msg = (FeatureReportMsg *)&buf[1]; - for ( i = 0; i < (int)msg->header.length / sizeof( ControllerAttribute ); ++i ) { + for (i = 0; i < (int)msg->header.length / sizeof(ControllerAttribute); ++i) { uint8_t unAttribute = msg->payload.getAttributes.attributes[i].attributeTag; uint32_t unValue = msg->payload.getAttributes.attributes[i].attributeValue; - switch ( unAttribute ) - { + switch (unAttribute) { case ATTRIB_UNIQUE_ID: break; case ATTRIB_PRODUCT_ID: @@ -483,98 +474,98 @@ static bool ResetSteamController( SDL_hid_device *dev, bool bSuppressErrorSpew, break; } } - if ( punUpdateRateUS ) { + if (punUpdateRateUS) { *punUpdateRateUS = unUpdateRateUS; } // Clear digital button mappings buf[0] = 0; buf[1] = ID_CLEAR_DIGITAL_MAPPINGS; - res = SetFeatureReport( dev, buf, 2 ); - if ( res < 0 ) { + res = SetFeatureReport(dev, buf, 2); + if (res < 0) { if (!bSuppressErrorSpew) { printf("CLEAR_DIGITAL_MAPPINGS failed for controller %p\n", dev); } return false; } - + // Reset the default settings - SDL_memset( buf, 0, 65 ); + SDL_memset(buf, 0, 65); buf[1] = ID_LOAD_DEFAULT_SETTINGS; buf[2] = 0; - res = SetFeatureReport( dev, buf, 3 ); - if ( res < 0 ) { + res = SetFeatureReport(dev, buf, 3); + if (res < 0) { if (!bSuppressErrorSpew) { printf("LOAD_DEFAULT_SETTINGS failed for controller %p\n", dev); } return false; } - + // Apply custom settings - clear trackpad modes (cancel mouse emulation), etc -#define ADD_SETTING(SETTING, VALUE) \ -buf[3+nSettings*3] = SETTING; \ -buf[3+nSettings*3+1] = ((uint16_t)VALUE)&0xFF; \ -buf[3+nSettings*3+2] = ((uint16_t)VALUE)>>8; \ -++nSettings; - - SDL_memset( buf, 0, 65 ); +#define ADD_SETTING(SETTING, VALUE) \ + buf[3 + nSettings * 3] = SETTING; \ + buf[3 + nSettings * 3 + 1] = ((uint16_t)VALUE) & 0xFF; \ + buf[3 + nSettings * 3 + 2] = ((uint16_t)VALUE) >> 8; \ + ++nSettings; + + SDL_memset(buf, 0, 65); buf[1] = ID_SET_SETTINGS_VALUES; - ADD_SETTING( SETTING_WIRELESS_PACKET_VERSION, 2 ); - ADD_SETTING( SETTING_LEFT_TRACKPAD_MODE, TRACKPAD_NONE ); + ADD_SETTING(SETTING_WIRELESS_PACKET_VERSION, 2); + ADD_SETTING(SETTING_LEFT_TRACKPAD_MODE, TRACKPAD_NONE); #ifdef ENABLE_MOUSE_MODE - ADD_SETTING( SETTING_RIGHT_TRACKPAD_MODE, TRACKPAD_ABSOLUTE_MOUSE ); - ADD_SETTING( SETTING_SMOOTH_ABSOLUTE_MOUSE, 1 ); - ADD_SETTING( SETTING_MOMENTUM_MAXIMUM_VELOCITY, 20000 ); // [0-20000] default 8000 - ADD_SETTING( SETTING_MOMENTUM_DECAY_AMMOUNT, 50 ); // [0-50] default 5 + ADD_SETTING(SETTING_RIGHT_TRACKPAD_MODE, TRACKPAD_ABSOLUTE_MOUSE); + ADD_SETTING(SETTING_SMOOTH_ABSOLUTE_MOUSE, 1); + ADD_SETTING(SETTING_MOMENTUM_MAXIMUM_VELOCITY, 20000); // [0-20000] default 8000 + ADD_SETTING(SETTING_MOMENTUM_DECAY_AMMOUNT, 50); // [0-50] default 5 #else - ADD_SETTING( SETTING_RIGHT_TRACKPAD_MODE, TRACKPAD_NONE ); - ADD_SETTING( SETTING_SMOOTH_ABSOLUTE_MOUSE, 0 ); + ADD_SETTING(SETTING_RIGHT_TRACKPAD_MODE, TRACKPAD_NONE); + ADD_SETTING(SETTING_SMOOTH_ABSOLUTE_MOUSE, 0); #endif - buf[2] = nSettings*3; - - res = SetFeatureReport( dev, buf, 3+nSettings*3 ); - if ( res < 0 ) { + buf[2] = nSettings * 3; + + res = SetFeatureReport(dev, buf, 3 + nSettings * 3); + if (res < 0) { if (!bSuppressErrorSpew) { printf("SET_SETTINGS failed for controller %p\n", dev); } return false; } - + #ifdef ENABLE_MOUSE_MODE // Wait for ID_CLEAR_DIGITAL_MAPPINGS to be processed on the controller bool bMappingsCleared = false; int iRetry; - for ( iRetry = 0; iRetry < 2; ++iRetry ) { - SDL_memset( buf, 0, 65 ); + for (iRetry = 0; iRetry < 2; ++iRetry) { + SDL_memset(buf, 0, 65); buf[1] = ID_GET_DIGITAL_MAPPINGS; buf[2] = 1; // one byte - requesting from index 0 buf[3] = 0; - res = SetFeatureReport( dev, buf, 4 ); - if ( res < 0 ) { - printf( "GET_DIGITAL_MAPPINGS failed for controller %p\n", dev ); + res = SetFeatureReport(dev, buf, 4); + if (res < 0) { + printf("GET_DIGITAL_MAPPINGS failed for controller %p\n", dev); return false; } - - res = ReadResponse( dev, buf, ID_GET_DIGITAL_MAPPINGS ); - if ( res < 0 || buf[1] != ID_GET_DIGITAL_MAPPINGS ) { - printf( "Bad GET_DIGITAL_MAPPINGS response for controller %p\n", dev ); + + res = ReadResponse(dev, buf, ID_GET_DIGITAL_MAPPINGS); + if (res < 0 || buf[1] != ID_GET_DIGITAL_MAPPINGS) { + printf("Bad GET_DIGITAL_MAPPINGS response for controller %p\n", dev); return false; } - + // If the length of the digital mappings result is not 1 (index byte, no mappings) then clearing hasn't executed - if ( buf[2] == 1 && buf[3] == 0xFF ) { + if (buf[2] == 1 && buf[3] == 0xFF) { bMappingsCleared = true; break; } - usleep( CONTROLLER_CONFIGURATION_DELAY_US ); + usleep(CONTROLLER_CONFIGURATION_DELAY_US); } - - if ( !bMappingsCleared && !bSuppressErrorSpew ) { - printf( "Warning: CLEAR_DIGITAL_MAPPINGS never completed for controller %p\n", dev ); + + if (!bMappingsCleared && !bSuppressErrorSpew) { + printf("Warning: CLEAR_DIGITAL_MAPPINGS never completed for controller %p\n", dev); } - + // Set our new mappings - SDL_memset( buf, 0, 65 ); + SDL_memset(buf, 0, 65); buf[1] = ID_SET_DIGITAL_MAPPINGS; buf[2] = 6; // 2 settings x 3 bytes buf[3] = IO_DIGITAL_BUTTON_RIGHT_TRIGGER; @@ -583,99 +574,94 @@ buf[3+nSettings*3+2] = ((uint16_t)VALUE)>>8; \ buf[6] = IO_DIGITAL_BUTTON_LEFT_TRIGGER; buf[7] = DEVICE_MOUSE; buf[8] = MOUSE_BTN_RIGHT; - - res = SetFeatureReport( dev, buf, 9 ); - if ( res < 0 ) { + + res = SetFeatureReport(dev, buf, 9); + if (res < 0) { if (!bSuppressErrorSpew) { printf("SET_DIGITAL_MAPPINGS failed for controller %p\n", dev); } return false; } #endif // ENABLE_MOUSE_MODE - + return true; } - //--------------------------------------------------------------------------- // Read from a Steam Controller //--------------------------------------------------------------------------- -static int ReadSteamController( SDL_hid_device *dev, uint8_t *pData, int nDataSize ) +static int ReadSteamController(SDL_hid_device *dev, uint8_t *pData, int nDataSize) { - SDL_memset( pData, 0, nDataSize ); - pData[ 0 ] = BLE_REPORT_NUMBER; // hid_read will also overwrite this with the same value, 0x03 - return SDL_hid_read( dev, pData, nDataSize ); + SDL_memset(pData, 0, nDataSize); + pData[0] = BLE_REPORT_NUMBER; // hid_read will also overwrite this with the same value, 0x03 + return SDL_hid_read(dev, pData, nDataSize); } - //--------------------------------------------------------------------------- // Close a Steam Controller //--------------------------------------------------------------------------- -static void CloseSteamController( SDL_hid_device *dev ) +static void CloseSteamController(SDL_hid_device *dev) { // Switch the Steam Controller back to lizard mode so it works with the OS unsigned char buf[65]; int nSettings = 0; - + // Reset digital button mappings - SDL_memset( buf, 0, 65 ); + SDL_memset(buf, 0, 65); buf[1] = ID_SET_DEFAULT_DIGITAL_MAPPINGS; - SetFeatureReport( dev, buf, 2 ); + SetFeatureReport(dev, buf, 2); // Reset the default settings - SDL_memset( buf, 0, 65 ); + SDL_memset(buf, 0, 65); buf[1] = ID_LOAD_DEFAULT_SETTINGS; buf[2] = 0; - SetFeatureReport( dev, buf, 3 ); + SetFeatureReport(dev, buf, 3); // Reset mouse mode for lizard mode - SDL_memset( buf, 0, 65 ); + SDL_memset(buf, 0, 65); buf[1] = ID_SET_SETTINGS_VALUES; - ADD_SETTING( SETTING_RIGHT_TRACKPAD_MODE, TRACKPAD_ABSOLUTE_MOUSE ); - buf[2] = nSettings*3; - SetFeatureReport( dev, buf, 3+nSettings*3 ); + ADD_SETTING(SETTING_RIGHT_TRACKPAD_MODE, TRACKPAD_ABSOLUTE_MOUSE); + buf[2] = nSettings * 3; + SetFeatureReport(dev, buf, 3 + nSettings * 3); } - //--------------------------------------------------------------------------- // Scale and clamp values to a range //--------------------------------------------------------------------------- -static float RemapValClamped( float val, float A, float B, float C, float D) +static float RemapValClamped(float val, float A, float B, float C, float D) { - if ( A == B ) { - return ( val - B ) >= 0.0f ? D : C; + if (A == B) { + return (val - B) >= 0.0f ? D : C; } else { float cVal = (val - A) / (B - A); - cVal = clamp( cVal, 0.0f, 1.0f ); + cVal = clamp(cVal, 0.0f, 1.0f); return C + (D - C) * cVal; } } - //--------------------------------------------------------------------------- // Rotate the pad coordinates //--------------------------------------------------------------------------- -static void RotatePad( int *pX, int *pY, float flAngleInRad ) +static void RotatePad(int *pX, int *pY, float flAngleInRad) { short int origX = *pX, origY = *pY; - *pX = (int)( SDL_cosf( flAngleInRad ) * origX - SDL_sinf( flAngleInRad ) * origY ); - *pY = (int)( SDL_sinf( flAngleInRad ) * origX + SDL_cosf( flAngleInRad ) * origY ); + *pX = (int)(SDL_cosf(flAngleInRad) * origX - SDL_sinf(flAngleInRad) * origY); + *pY = (int)(SDL_sinf(flAngleInRad) * origX + SDL_cosf(flAngleInRad) * origY); } -static void RotatePadShort( short *pX, short *pY, float flAngleInRad ) +static void RotatePadShort(short *pX, short *pY, float flAngleInRad) { short int origX = *pX, origY = *pY; - *pX = (short)( SDL_cosf( flAngleInRad ) * origX - SDL_sinf( flAngleInRad ) * origY ); - *pY = (short)( SDL_sinf( flAngleInRad ) * origX + SDL_cosf( flAngleInRad ) * origY ); + *pX = (short)(SDL_cosf(flAngleInRad) * origX - SDL_sinf(flAngleInRad) * origY); + *pY = (short)(SDL_sinf(flAngleInRad) * origX + SDL_cosf(flAngleInRad) * origY); } - //--------------------------------------------------------------------------- // Format the first part of the state packet //--------------------------------------------------------------------------- -static void FormatStatePacketUntilGyro( SteamControllerStateInternal_t *pState, ValveControllerStatePacket_t *pStatePacket ) +static void FormatStatePacketUntilGyro(SteamControllerStateInternal_t *pState, ValveControllerStatePacket_t *pStatePacket) { int nLeftPadX; int nLeftPadY; @@ -688,7 +674,7 @@ static void FormatStatePacketUntilGyro( SteamControllerStateInternal_t *pState, SDL_memset(pState, 0, offsetof(SteamControllerStateInternal_t, sBatteryLevel)); - //pState->eControllerType = m_eControllerType; + // pState->eControllerType = m_eControllerType; pState->eControllerType = 2; // k_eControllerType_SteamController; pState->unPacketNum = pStatePacket->unPacketNum; @@ -716,21 +702,21 @@ static void FormatStatePacketUntilGyro( SteamControllerStateInternal_t *pState, // XXX there's a firmware bug where sometimes padX is 0 and padY is a large number (acutally the battery voltage) // If that happens skip this packet and report last frames stick -/* - if ( m_eControllerType == k_eControllerType_SteamControllerV2 && pStatePacket->sLeftPadY > 900 ) { - pState->sLeftStickX = pState->sPrevLeftStick[0]; - pState->sLeftStickY = pState->sPrevLeftStick[1]; - } else -*/ + /* + if ( m_eControllerType == k_eControllerType_SteamControllerV2 && pStatePacket->sLeftPadY > 900 ) { + pState->sLeftStickX = pState->sPrevLeftStick[0]; + pState->sLeftStickY = pState->sPrevLeftStick[1]; + } else + */ { pState->sPrevLeftStick[0] = pState->sLeftStickX = pStatePacket->sLeftPadX; pState->sPrevLeftStick[1] = pState->sLeftStickY = pStatePacket->sLeftPadY; } -/* - if (m_eControllerType == k_eControllerType_SteamControllerV2) { - UpdateV2JoystickCap(&state); - } -*/ + /* + if (m_eControllerType == k_eControllerType_SteamControllerV2) { + UpdateV2JoystickCap(&state); + } + */ if (pStatePacket->ButtonTriggerData.ulButtons & STEAM_LEFTPAD_AND_JOYSTICK_MASK) { // The controller is interleaving both stick and pad data, both are active @@ -783,115 +769,112 @@ static void FormatStatePacketUntilGyro( SteamControllerStateInternal_t *pState, pState->sRightPadX = clamp(nRightPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16); pState->sRightPadY = clamp(nRightPadY + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16); - pState->sTriggerL = (unsigned short)RemapValClamped( (float)((pStatePacket->ButtonTriggerData.Triggers.nLeft << 7) | pStatePacket->ButtonTriggerData.Triggers.nLeft), 0, STEAMCONTROLLER_TRIGGER_MAX_ANALOG, 0, SDL_MAX_SINT16 ); - pState->sTriggerR = (unsigned short)RemapValClamped( (float)((pStatePacket->ButtonTriggerData.Triggers.nRight << 7) | pStatePacket->ButtonTriggerData.Triggers.nRight), 0, STEAMCONTROLLER_TRIGGER_MAX_ANALOG, 0, SDL_MAX_SINT16 ); + pState->sTriggerL = (unsigned short)RemapValClamped((float)((pStatePacket->ButtonTriggerData.Triggers.nLeft << 7) | pStatePacket->ButtonTriggerData.Triggers.nLeft), 0, STEAMCONTROLLER_TRIGGER_MAX_ANALOG, 0, SDL_MAX_SINT16); + pState->sTriggerR = (unsigned short)RemapValClamped((float)((pStatePacket->ButtonTriggerData.Triggers.nRight << 7) | pStatePacket->ButtonTriggerData.Triggers.nRight), 0, STEAMCONTROLLER_TRIGGER_MAX_ANALOG, 0, SDL_MAX_SINT16); } - //--------------------------------------------------------------------------- // Update Steam Controller state from a BLE data packet, returns true if it parsed data //--------------------------------------------------------------------------- -static bool UpdateBLESteamControllerState( const uint8_t *pData, int nDataSize, SteamControllerStateInternal_t *pState ) +static bool UpdateBLESteamControllerState(const uint8_t *pData, int nDataSize, SteamControllerStateInternal_t *pState) { const float flRotationAngle = 0.261799f; uint32_t ucOptionDataMask; pState->unPacketNum++; - ucOptionDataMask = ( *pData++ & 0xF0 ); + ucOptionDataMask = (*pData++ & 0xF0); ucOptionDataMask |= (uint32_t)(*pData++) << 8; - if ( ucOptionDataMask & k_EBLEButtonChunk1 ) { - SDL_memcpy( &pState->ulButtons, pData, 3 ); + if (ucOptionDataMask & k_EBLEButtonChunk1) { + SDL_memcpy(&pState->ulButtons, pData, 3); pData += 3; } - if ( ucOptionDataMask & k_EBLEButtonChunk2 ) { + if (ucOptionDataMask & k_EBLEButtonChunk2) { // The middle 2 bytes of the button bits over the wire are triggers when over the wire and non-SC buttons in the internal controller state packet - pState->sTriggerL = (unsigned short)RemapValClamped( (float)(( pData[ 0 ] << 7 ) | pData[ 0 ]), 0, STEAMCONTROLLER_TRIGGER_MAX_ANALOG, 0, SDL_MAX_SINT16 ); - pState->sTriggerR = (unsigned short)RemapValClamped( (float)(( pData[ 1 ] << 7 ) | pData[ 1 ]), 0, STEAMCONTROLLER_TRIGGER_MAX_ANALOG, 0, SDL_MAX_SINT16 ); + pState->sTriggerL = (unsigned short)RemapValClamped((float)((pData[0] << 7) | pData[0]), 0, STEAMCONTROLLER_TRIGGER_MAX_ANALOG, 0, SDL_MAX_SINT16); + pState->sTriggerR = (unsigned short)RemapValClamped((float)((pData[1] << 7) | pData[1]), 0, STEAMCONTROLLER_TRIGGER_MAX_ANALOG, 0, SDL_MAX_SINT16); pData += 2; } - if ( ucOptionDataMask & k_EBLEButtonChunk3 ) { + if (ucOptionDataMask & k_EBLEButtonChunk3) { uint8_t *pButtonByte = (uint8_t *)&pState->ulButtons; - pButtonByte[ 5 ] = *pData++; - pButtonByte[ 6 ] = *pData++; - pButtonByte[ 7 ] = *pData++; + pButtonByte[5] = *pData++; + pButtonByte[6] = *pData++; + pButtonByte[7] = *pData++; } - if ( ucOptionDataMask & k_EBLELeftJoystickChunk ) { + if (ucOptionDataMask & k_EBLELeftJoystickChunk) { // This doesn't handle any of the special headcrab stuff for raw joystick which is OK for now since that FW doesn't support // this protocol yet either - int nLength = sizeof( pState->sLeftStickX ) + sizeof( pState->sLeftStickY ); - SDL_memcpy( &pState->sLeftStickX, pData, nLength ); + int nLength = sizeof(pState->sLeftStickX) + sizeof(pState->sLeftStickY); + SDL_memcpy(&pState->sLeftStickX, pData, nLength); pData += nLength; } - if ( ucOptionDataMask & k_EBLELeftTrackpadChunk ) { - int nLength = sizeof( pState->sLeftPadX ) + sizeof( pState->sLeftPadY ); + if (ucOptionDataMask & k_EBLELeftTrackpadChunk) { + int nLength = sizeof(pState->sLeftPadX) + sizeof(pState->sLeftPadY); int nPadOffset; - SDL_memcpy( &pState->sLeftPadX, pData, nLength ); - if ( pState->ulButtons & STEAM_LEFTPAD_FINGERDOWN_MASK ) + SDL_memcpy(&pState->sLeftPadX, pData, nLength); + if (pState->ulButtons & STEAM_LEFTPAD_FINGERDOWN_MASK) nPadOffset = 1000; else nPadOffset = 0; - RotatePadShort( &pState->sLeftPadX, &pState->sLeftPadY, -flRotationAngle ); - pState->sLeftPadX = clamp( pState->sLeftPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16 ); - pState->sLeftPadY = clamp( pState->sLeftPadY + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16 ); + RotatePadShort(&pState->sLeftPadX, &pState->sLeftPadY, -flRotationAngle); + pState->sLeftPadX = clamp(pState->sLeftPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16); + pState->sLeftPadY = clamp(pState->sLeftPadY + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16); pData += nLength; } - if ( ucOptionDataMask & k_EBLERightTrackpadChunk ) { - int nLength = sizeof( pState->sRightPadX ) + sizeof( pState->sRightPadY ); + if (ucOptionDataMask & k_EBLERightTrackpadChunk) { + int nLength = sizeof(pState->sRightPadX) + sizeof(pState->sRightPadY); int nPadOffset = 0; - SDL_memcpy( &pState->sRightPadX, pData, nLength ); + SDL_memcpy(&pState->sRightPadX, pData, nLength); - if ( pState->ulButtons & STEAM_RIGHTPAD_FINGERDOWN_MASK ) + if (pState->ulButtons & STEAM_RIGHTPAD_FINGERDOWN_MASK) nPadOffset = 1000; else nPadOffset = 0; - RotatePadShort( &pState->sRightPadX, &pState->sRightPadY, flRotationAngle ); - pState->sRightPadX = clamp( pState->sRightPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16 ); - pState->sRightPadY = clamp( pState->sRightPadY + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16 ); + RotatePadShort(&pState->sRightPadX, &pState->sRightPadY, flRotationAngle); + pState->sRightPadX = clamp(pState->sRightPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16); + pState->sRightPadY = clamp(pState->sRightPadY + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16); pData += nLength; } - if ( ucOptionDataMask & k_EBLEIMUAccelChunk ) { - int nLength = sizeof( pState->sAccelX ) + sizeof( pState->sAccelY ) + sizeof( pState->sAccelZ ); - SDL_memcpy( &pState->sAccelX, pData, nLength ); + if (ucOptionDataMask & k_EBLEIMUAccelChunk) { + int nLength = sizeof(pState->sAccelX) + sizeof(pState->sAccelY) + sizeof(pState->sAccelZ); + SDL_memcpy(&pState->sAccelX, pData, nLength); pData += nLength; } - if ( ucOptionDataMask & k_EBLEIMUGyroChunk ) { - int nLength = sizeof( pState->sAccelX ) + sizeof( pState->sAccelY ) + sizeof( pState->sAccelZ ); - SDL_memcpy( &pState->sGyroX, pData, nLength ); + if (ucOptionDataMask & k_EBLEIMUGyroChunk) { + int nLength = sizeof(pState->sAccelX) + sizeof(pState->sAccelY) + sizeof(pState->sAccelZ); + SDL_memcpy(&pState->sGyroX, pData, nLength); pData += nLength; } - if ( ucOptionDataMask & k_EBLEIMUQuatChunk ) { - int nLength = sizeof( pState->sGyroQuatW ) + sizeof( pState->sGyroQuatX ) + sizeof( pState->sGyroQuatY ) + sizeof( pState->sGyroQuatZ ); - SDL_memcpy( &pState->sGyroQuatW, pData, nLength ); + if (ucOptionDataMask & k_EBLEIMUQuatChunk) { + int nLength = sizeof(pState->sGyroQuatW) + sizeof(pState->sGyroQuatX) + sizeof(pState->sGyroQuatY) + sizeof(pState->sGyroQuatZ); + SDL_memcpy(&pState->sGyroQuatW, pData, nLength); pData += nLength; } return true; } - //--------------------------------------------------------------------------- // Update Steam Controller state from a data packet, returns true if it parsed data //--------------------------------------------------------------------------- -static bool UpdateSteamControllerState( const uint8_t *pData, int nDataSize, SteamControllerStateInternal_t *pState ) +static bool UpdateSteamControllerState(const uint8_t *pData, int nDataSize, SteamControllerStateInternal_t *pState) { - ValveInReport_t *pInReport = (ValveInReport_t*)pData; + ValveInReport_t *pInReport = (ValveInReport_t *)pData; - if ( pInReport->header.unReportVersion != k_ValveInReportMsgVersion ) { - if ( ( pData[ 0 ] & 0x0F ) == k_EBLEReportState ) { - return UpdateBLESteamControllerState( pData, nDataSize, pState ); + if (pInReport->header.unReportVersion != k_ValveInReportMsgVersion) { + if ((pData[0] & 0x0F) == k_EBLEReportState) { + return UpdateBLESteamControllerState(pData, nDataSize, pState); } return false; } - if ( ( pInReport->header.ucType != ID_CONTROLLER_STATE ) && - ( pInReport->header.ucType != ID_CONTROLLER_BLE_STATE ) ) - { + if ((pInReport->header.ucType != ID_CONTROLLER_STATE) && + (pInReport->header.ucType != ID_CONTROLLER_BLE_STATE)) { return false; } - if ( pInReport->header.ucType == ID_CONTROLLER_STATE ) { + if (pInReport->header.ucType == ID_CONTROLLER_STATE) { ValveControllerStatePacket_t *pStatePacket = &pInReport->payload.controllerState; // No new data to process; indicate that we received a state packet, but otherwise do nothing. @@ -899,7 +882,7 @@ static bool UpdateSteamControllerState( const uint8_t *pData, int nDataSize, Ste return true; } - FormatStatePacketUntilGyro( pState, pStatePacket ); + FormatStatePacketUntilGyro(pState, pStatePacket); pState->sAccelX = pStatePacket->sAccelX; pState->sAccelY = pStatePacket->sAccelY; @@ -914,7 +897,7 @@ static bool UpdateSteamControllerState( const uint8_t *pData, int nDataSize, Ste pState->sGyroY = pStatePacket->sGyroY; pState->sGyroZ = pStatePacket->sGyroZ; - } else if ( pInReport->header.ucType == ID_CONTROLLER_BLE_STATE ) { + } else if (pInReport->header.ucType == ID_CONTROLLER_BLE_STATE) { ValveControllerBLEStatePacket_t *pBLEStatePacket = &pInReport->payload.controllerBLEState; ValveControllerStatePacket_t *pStatePacket = &pInReport->payload.controllerState; @@ -923,15 +906,14 @@ static bool UpdateSteamControllerState( const uint8_t *pData, int nDataSize, Ste return true; } - FormatStatePacketUntilGyro( pState, pStatePacket ); + FormatStatePacketUntilGyro(pState, pStatePacket); - switch ( pBLEStatePacket->ucGyroDataType ) - { + switch (pBLEStatePacket->ucGyroDataType) { case 1: - pState->sGyroQuatW = (( float ) pBLEStatePacket->sGyro[0]); - pState->sGyroQuatX = (( float ) pBLEStatePacket->sGyro[1]); - pState->sGyroQuatY = (( float ) pBLEStatePacket->sGyro[2]); - pState->sGyroQuatZ = (( float ) pBLEStatePacket->sGyro[3]); + pState->sGyroQuatW = ((float)pBLEStatePacket->sGyro[0]); + pState->sGyroQuatX = ((float)pBLEStatePacket->sGyro[1]); + pState->sGyroQuatY = ((float)pBLEStatePacket->sGyro[2]); + pState->sGyroQuatZ = ((float)pBLEStatePacket->sGyro[3]); break; case 2: @@ -956,7 +938,8 @@ static bool UpdateSteamControllerState( const uint8_t *pData, int nDataSize, Ste /*****************************************************************************************************/ -typedef struct { +typedef struct +{ SDL_bool report_sensors; uint32_t update_rate_in_us; Uint32 timestamp_us; @@ -966,33 +949,27 @@ typedef struct { SteamControllerStateInternal_t m_last_state; } SDL_DriverSteam_Context; - -static void -HIDAPI_DriverSteam_RegisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverSteam_RegisterHints(SDL_HintCallback callback, void *userdata) { SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_STEAM, callback, userdata); } -static void -HIDAPI_DriverSteam_UnregisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverSteam_UnregisterHints(SDL_HintCallback callback, void *userdata) { SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_STEAM, callback, userdata); } -static SDL_bool -HIDAPI_DriverSteam_IsEnabled(void) +static SDL_bool HIDAPI_DriverSteam_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_STEAM, SDL_FALSE); } -static SDL_bool -HIDAPI_DriverSteam_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static SDL_bool HIDAPI_DriverSteam_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { return SDL_IsJoystickSteamController(vendor_id, product_id); } -static SDL_bool -HIDAPI_DriverSteam_InitDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverSteam_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverSteam_Context *ctx; @@ -1016,19 +993,16 @@ HIDAPI_DriverSteam_InitDevice(SDL_HIDAPI_Device *device) return HIDAPI_JoystickConnected(device, NULL); } -static int -HIDAPI_DriverSteam_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) +static int HIDAPI_DriverSteam_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) { return -1; } -static void -HIDAPI_DriverSteam_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) +static void HIDAPI_DriverSteam_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) { } -static SDL_bool -HIDAPI_DriverSteam_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static SDL_bool HIDAPI_DriverSteam_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverSteam_Context *ctx = (SDL_DriverSteam_Context *)device->context; float update_rate_in_hz = 0.0f; @@ -1058,55 +1032,49 @@ HIDAPI_DriverSteam_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystic return SDL_TRUE; } -static int -HIDAPI_DriverSteam_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int HIDAPI_DriverSteam_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { /* You should use the full Steam Input API for rumble support */ return SDL_Unsupported(); } -static int -HIDAPI_DriverSteam_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int HIDAPI_DriverSteam_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static Uint32 -HIDAPI_DriverSteam_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static Uint32 HIDAPI_DriverSteam_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { /* You should use the full Steam Input API for extended capabilities */ return 0; } -static int -HIDAPI_DriverSteam_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int HIDAPI_DriverSteam_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { /* You should use the full Steam Input API for LED support */ return SDL_Unsupported(); } -static int -HIDAPI_DriverSteam_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) +static int HIDAPI_DriverSteam_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -HIDAPI_DriverSteam_SetSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverSteam_SetSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) { SDL_DriverSteam_Context *ctx = (SDL_DriverSteam_Context *)device->context; unsigned char buf[65]; int nSettings = 0; - SDL_memset( buf, 0, 65 ); + SDL_memset(buf, 0, 65); buf[1] = ID_SET_SETTINGS_VALUES; if (enabled) { - ADD_SETTING( SETTING_GYRO_MODE, 0x18 /* SETTING_GYRO_SEND_RAW_ACCEL | SETTING_GYRO_MODE_SEND_RAW_GYRO */ ); + ADD_SETTING(SETTING_GYRO_MODE, 0x18 /* SETTING_GYRO_SEND_RAW_ACCEL | SETTING_GYRO_MODE_SEND_RAW_GYRO */); } else { - ADD_SETTING( SETTING_GYRO_MODE, 0x00 /* SETTING_GYRO_MODE_OFF */ ); + ADD_SETTING(SETTING_GYRO_MODE, 0x00 /* SETTING_GYRO_MODE_OFF */); } - buf[2] = nSettings*3; - if (SetFeatureReport( device->dev, buf, 3+nSettings*3 ) < 0) { + buf[2] = nSettings * 3; + if (SetFeatureReport(device->dev, buf, 3 + nSettings * 3) < 0) { return SDL_SetError("Couldn't write feature report"); } @@ -1115,8 +1083,7 @@ HIDAPI_DriverSteam_SetSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *jo return 0; } -static SDL_bool -HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverSteam_Context *ctx = (SDL_DriverSteam_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -1151,38 +1118,38 @@ HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device) if (nPacketLength > 0 && UpdateSteamControllerState(pPacket, nPacketLength, &ctx->m_state)) { if (ctx->m_state.ulButtons != ctx->m_last_state.ulButtons) { SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_A, - (ctx->m_state.ulButtons & STEAM_BUTTON_3_MASK) ? SDL_PRESSED : SDL_RELEASED); + (ctx->m_state.ulButtons & STEAM_BUTTON_3_MASK) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_B, - (ctx->m_state.ulButtons & STEAM_BUTTON_1_MASK) ? SDL_PRESSED : SDL_RELEASED); + (ctx->m_state.ulButtons & STEAM_BUTTON_1_MASK) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_X, - (ctx->m_state.ulButtons & STEAM_BUTTON_2_MASK) ? SDL_PRESSED : SDL_RELEASED); + (ctx->m_state.ulButtons & STEAM_BUTTON_2_MASK) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_Y, - (ctx->m_state.ulButtons & STEAM_BUTTON_0_MASK) ? SDL_PRESSED : SDL_RELEASED); + (ctx->m_state.ulButtons & STEAM_BUTTON_0_MASK) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSHOULDER, - (ctx->m_state.ulButtons & STEAM_LEFT_BUMPER_MASK) ? SDL_PRESSED : SDL_RELEASED); + (ctx->m_state.ulButtons & STEAM_LEFT_BUMPER_MASK) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, - (ctx->m_state.ulButtons & STEAM_RIGHT_BUMPER_MASK) ? SDL_PRESSED : SDL_RELEASED); + (ctx->m_state.ulButtons & STEAM_RIGHT_BUMPER_MASK) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_BACK, - (ctx->m_state.ulButtons & STEAM_BUTTON_MENU_MASK) ? SDL_PRESSED : SDL_RELEASED); + (ctx->m_state.ulButtons & STEAM_BUTTON_MENU_MASK) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_START, - (ctx->m_state.ulButtons & STEAM_BUTTON_ESCAPE_MASK) ? SDL_PRESSED : SDL_RELEASED); + (ctx->m_state.ulButtons & STEAM_BUTTON_ESCAPE_MASK) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, - (ctx->m_state.ulButtons & STEAM_BUTTON_STEAM_MASK) ? SDL_PRESSED : SDL_RELEASED); + (ctx->m_state.ulButtons & STEAM_BUTTON_STEAM_MASK) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSTICK, - (ctx->m_state.ulButtons & STEAM_JOYSTICK_BUTTON_MASK) ? SDL_PRESSED : SDL_RELEASED); + (ctx->m_state.ulButtons & STEAM_JOYSTICK_BUTTON_MASK) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1 + 0, - (ctx->m_state.ulButtons & STEAM_BUTTON_BACK_LEFT_MASK) ? SDL_PRESSED : SDL_RELEASED); + (ctx->m_state.ulButtons & STEAM_BUTTON_BACK_LEFT_MASK) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1 + 1, - (ctx->m_state.ulButtons & STEAM_BUTTON_BACK_RIGHT_MASK) ? SDL_PRESSED : SDL_RELEASED); + (ctx->m_state.ulButtons & STEAM_BUTTON_BACK_RIGHT_MASK) ? SDL_PRESSED : SDL_RELEASED); } { /* Minimum distance from center of pad to register a direction */ @@ -1190,16 +1157,16 @@ HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device) /* Pad coordinates are like math grid coordinates: negative is bottom left */ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, - (ctx->m_state.sLeftPadY > kPadDeadZone) ? SDL_PRESSED : SDL_RELEASED); + (ctx->m_state.sLeftPadY > kPadDeadZone) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, - (ctx->m_state.sLeftPadY < -kPadDeadZone) ? SDL_PRESSED : SDL_RELEASED); + (ctx->m_state.sLeftPadY < -kPadDeadZone) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, - (ctx->m_state.sLeftPadX < -kPadDeadZone) ? SDL_PRESSED : SDL_RELEASED); + (ctx->m_state.sLeftPadX < -kPadDeadZone) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, - (ctx->m_state.sLeftPadX > kPadDeadZone) ? SDL_PRESSED : SDL_RELEASED); + (ctx->m_state.sLeftPadX > kPadDeadZone) ? SDL_PRESSED : SDL_RELEASED); } SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, (int)ctx->m_state.sTriggerL * 2 - 32768); @@ -1238,19 +1205,16 @@ HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device) return SDL_TRUE; } -static void -HIDAPI_DriverSteam_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static void HIDAPI_DriverSteam_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { CloseSteamController(device->dev); } -static void -HIDAPI_DriverSteam_FreeDevice(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverSteam_FreeDevice(SDL_HIDAPI_Device *device) { } -SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSteam = -{ +SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSteam = { SDL_HINT_JOYSTICK_HIDAPI_STEAM, SDL_TRUE, HIDAPI_DriverSteam_RegisterHints, diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c index aedb66a4a..e66bd73e8 100644 --- a/src/joystick/hidapi/SDL_hidapi_switch.c +++ b/src/joystick/hidapi/SDL_hidapi_switch.c @@ -35,7 +35,6 @@ #include "SDL_hidapi_rumble.h" #include "SDL_hidapi_nintendo.h" - #ifdef SDL_JOYSTICK_HIDAPI_SWITCH /* Define this if you want to log all packets from the controller */ @@ -55,52 +54,56 @@ If you send commands more frequently than this, you can turn off the controller in Bluetooth mode, or the motors can miss the command in USB mode. */ -#define RUMBLE_WRITE_FREQUENCY_MS 30 +#define RUMBLE_WRITE_FREQUENCY_MS 30 /* How often you have to refresh a long duration rumble to keep the motors running */ #define RUMBLE_REFRESH_FREQUENCY_MS 50 -#define SWITCH_GYRO_SCALE 14.2842f -#define SWITCH_ACCEL_SCALE 4096.f +#define SWITCH_GYRO_SCALE 14.2842f +#define SWITCH_ACCEL_SCALE 4096.f -#define SWITCH_GYRO_SCALE_OFFSET 13371.0f -#define SWITCH_GYRO_SCALE_MULT 936.0f -#define SWITCH_ACCEL_SCALE_OFFSET 16384.0f -#define SWITCH_ACCEL_SCALE_MULT 4.0f +#define SWITCH_GYRO_SCALE_OFFSET 13371.0f +#define SWITCH_GYRO_SCALE_MULT 936.0f +#define SWITCH_ACCEL_SCALE_OFFSET 16384.0f +#define SWITCH_ACCEL_SCALE_MULT 4.0f -typedef enum { - k_eSwitchInputReportIDs_SubcommandReply = 0x21, - k_eSwitchInputReportIDs_FullControllerState = 0x30, +typedef enum +{ + k_eSwitchInputReportIDs_SubcommandReply = 0x21, + k_eSwitchInputReportIDs_FullControllerState = 0x30, k_eSwitchInputReportIDs_SimpleControllerState = 0x3F, - k_eSwitchInputReportIDs_CommandAck = 0x81, + k_eSwitchInputReportIDs_CommandAck = 0x81, } ESwitchInputReportIDs; -typedef enum { +typedef enum +{ k_eSwitchOutputReportIDs_RumbleAndSubcommand = 0x01, - k_eSwitchOutputReportIDs_Rumble = 0x10, - k_eSwitchOutputReportIDs_Proprietary = 0x80, + k_eSwitchOutputReportIDs_Rumble = 0x10, + k_eSwitchOutputReportIDs_Proprietary = 0x80, } ESwitchOutputReportIDs; -typedef enum { +typedef enum +{ k_eSwitchSubcommandIDs_BluetoothManualPair = 0x01, - k_eSwitchSubcommandIDs_RequestDeviceInfo = 0x02, - k_eSwitchSubcommandIDs_SetInputReportMode = 0x03, - k_eSwitchSubcommandIDs_SetHCIState = 0x06, - k_eSwitchSubcommandIDs_SPIFlashRead = 0x10, - k_eSwitchSubcommandIDs_SetPlayerLights = 0x30, - k_eSwitchSubcommandIDs_SetHomeLight = 0x38, - k_eSwitchSubcommandIDs_EnableIMU = 0x40, - k_eSwitchSubcommandIDs_SetIMUSensitivity = 0x41, - k_eSwitchSubcommandIDs_EnableVibration = 0x48, + k_eSwitchSubcommandIDs_RequestDeviceInfo = 0x02, + k_eSwitchSubcommandIDs_SetInputReportMode = 0x03, + k_eSwitchSubcommandIDs_SetHCIState = 0x06, + k_eSwitchSubcommandIDs_SPIFlashRead = 0x10, + k_eSwitchSubcommandIDs_SetPlayerLights = 0x30, + k_eSwitchSubcommandIDs_SetHomeLight = 0x38, + k_eSwitchSubcommandIDs_EnableIMU = 0x40, + k_eSwitchSubcommandIDs_SetIMUSensitivity = 0x41, + k_eSwitchSubcommandIDs_EnableVibration = 0x48, } ESwitchSubcommandIDs; -typedef enum { - k_eSwitchProprietaryCommandIDs_Status = 0x01, +typedef enum +{ + k_eSwitchProprietaryCommandIDs_Status = 0x01, k_eSwitchProprietaryCommandIDs_Handshake = 0x02, k_eSwitchProprietaryCommandIDs_HighSpeed = 0x03, - k_eSwitchProprietaryCommandIDs_ForceUSB = 0x04, - k_eSwitchProprietaryCommandIDs_ClearUSB = 0x05, - k_eSwitchProprietaryCommandIDs_ResetMCU = 0x06, + k_eSwitchProprietaryCommandIDs_ForceUSB = 0x04, + k_eSwitchProprietaryCommandIDs_ClearUSB = 0x05, + k_eSwitchProprietaryCommandIDs_ResetMCU = 0x06, } ESwitchProprietaryCommandIDs; #define k_unSwitchOutputPacketDataLength 49 @@ -108,17 +111,17 @@ typedef enum { #define k_unSwitchBluetoothPacketLength k_unSwitchOutputPacketDataLength #define k_unSwitchUSBPacketLength k_unSwitchMaxOutputPacketLength -#define k_unSPIStickCalibrationStartOffset 0x603D -#define k_unSPIStickCalibrationEndOffset 0x604E -#define k_unSPIStickCalibrationLength (k_unSPIStickCalibrationEndOffset - k_unSPIStickCalibrationStartOffset + 1) +#define k_unSPIStickCalibrationStartOffset 0x603D +#define k_unSPIStickCalibrationEndOffset 0x604E +#define k_unSPIStickCalibrationLength (k_unSPIStickCalibrationEndOffset - k_unSPIStickCalibrationStartOffset + 1) -#define k_unSPIIMUScaleStartOffset 0x6020 -#define k_unSPIIMUScaleEndOffset 0x6037 -#define k_unSPIIMUScaleLength (k_unSPIIMUScaleEndOffset - k_unSPIIMUScaleStartOffset + 1) +#define k_unSPIIMUScaleStartOffset 0x6020 +#define k_unSPIIMUScaleEndOffset 0x6037 +#define k_unSPIIMUScaleLength (k_unSPIIMUScaleEndOffset - k_unSPIIMUScaleStartOffset + 1) -#define k_unSPIIMUUserScaleStartOffset 0x8026 -#define k_unSPIIMUUserScaleEndOffset 0x8039 -#define k_unSPIIMUUserScaleLength (k_unSPIIMUUserScaleEndOffset - k_unSPIIMUUserScaleStartOffset + 1) +#define k_unSPIIMUUserScaleStartOffset 0x8026 +#define k_unSPIIMUUserScaleEndOffset 0x8039 +#define k_unSPIIMUUserScaleLength (k_unSPIIMUUserScaleEndOffset - k_unSPIIMUUserScaleStartOffset + 1) #pragma pack(1) typedef struct @@ -151,7 +154,8 @@ typedef struct { SwitchControllerStatePacket_t controllerState; - struct { + struct + { Sint16 sAccelX; Sint16 sAccelY; Sint16 sAccelZ; @@ -175,16 +179,19 @@ typedef struct Uint8 ucSubcommandAck; Uint8 ucSubcommandID; - #define k_unSubcommandDataBytes 35 - union { +#define k_unSubcommandDataBytes 35 + union + { Uint8 rgucSubcommandData[k_unSubcommandDataBytes]; - struct { + struct + { SwitchSPIOpData_t opData; Uint8 rgucReadData[k_unSubcommandDataBytes - sizeof(SwitchSPIOpData_t)]; } spiReadData; - struct { + struct + { Uint8 rgucFirmwareVersion[2]; Uint8 ucDeviceType; Uint8 ucFiller1; @@ -234,16 +241,17 @@ typedef struct } SwitchProprietaryOutputPacket_t; #pragma pack() -typedef struct { +typedef struct +{ SDL_HIDAPI_Device *device; SDL_Joystick *joystick; SDL_bool m_bInputOnly; SDL_bool m_bIsGameCube; SDL_bool m_bUseButtonLabels; SDL_bool m_bPlayerLights; - int m_nPlayerIndex; + int m_nPlayerIndex; SDL_bool m_bSyncWrite; - int m_nMaxWriteAttempts; + int m_nMaxWriteAttempts; ESwitchDeviceInfoControllerType m_eControllerType; Uint8 m_rgucMACAddress[6]; Uint8 m_nCommandNumber; @@ -268,22 +276,27 @@ typedef struct { SwitchSimpleStatePacket_t m_lastSimpleState; SwitchStatePacket_t m_lastFullState; - struct StickCalibrationData { - struct { + struct StickCalibrationData + { + struct + { Sint16 sCenter; Sint16 sMin; Sint16 sMax; } axis[2]; } m_StickCalData[2]; - struct StickExtents { - struct { + struct StickExtents + { + struct + { Sint16 sMin; Sint16 sMax; } axis[2]; } m_StickExtents[2], m_SimpleStickExtents[2]; - struct IMUScaleData { + struct IMUScaleData + { float fAccelScaleX; float fAccelScaleY; float fAccelScaleZ; @@ -294,7 +307,6 @@ typedef struct { } m_IMUScaleData; } SDL_DriverSwitch_Context; - static int ReadInput(SDL_DriverSwitch_Context *ctx) { /* Make sure we don't try to read at the same time a write is happening */ @@ -395,7 +407,7 @@ static SDL_bool WritePacket(SDL_DriverSwitch_Context *ctx, void *pBuf, Uint8 ucL if (ucLen < unWriteSize) { SDL_memcpy(rgucBuf, pBuf, ucLen); - SDL_memset(rgucBuf+ucLen, 0, unWriteSize-ucLen); + SDL_memset(rgucBuf + ucLen, 0, unWriteSize - ucLen); pBuf = rgucBuf; ucLen = (Uint8)unWriteSize; } @@ -451,35 +463,22 @@ static SDL_bool WriteProprietary(SDL_DriverSwitch_Context *ctx, ESwitchProprieta } if (!waitForReply || ReadProprietaryReply(ctx, ucCommand)) { -//SDL_Log("Succeeded%s after %d tries\n", ctx->m_bSyncWrite ? " (sync)" : "", nTries); + // SDL_Log("Succeeded%s after %d tries\n", ctx->m_bSyncWrite ? " (sync)" : "", nTries); return SDL_TRUE; } } -//SDL_Log("Failed%s after %d tries\n", ctx->m_bSyncWrite ? " (sync)" : "", nTries); + // SDL_Log("Failed%s after %d tries\n", ctx->m_bSyncWrite ? " (sync)" : "", nTries); return SDL_FALSE; } -static Uint8 EncodeRumbleHighAmplitude(Uint16 amplitude) { +static Uint8 EncodeRumbleHighAmplitude(Uint16 amplitude) +{ /* More information about these values can be found here: * https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md */ - Uint16 hfa[101][2] = { {0, 0x0},{514, 0x2},{775, 0x4},{921, 0x6},{1096, 0x8},{1303, 0x0a},{1550, 0x0c}, - {1843, 0x0e},{2192, 0x10},{2606, 0x12},{3100, 0x14},{3686, 0x16},{4383, 0x18},{5213, 0x1a}, - {6199, 0x1c},{7372, 0x1e},{7698, 0x20},{8039, 0x22},{8395, 0x24},{8767, 0x26},{9155, 0x28}, - {9560, 0x2a},{9984, 0x2c},{10426, 0x2e},{10887, 0x30},{11369, 0x32},{11873, 0x34},{12398, 0x36}, - {12947, 0x38},{13520, 0x3a},{14119, 0x3c},{14744, 0x3e},{15067, 0x40},{15397, 0x42},{15734, 0x44}, - {16079, 0x46},{16431, 0x48},{16790, 0x4a},{17158, 0x4c},{17534, 0x4e},{17918, 0x50},{18310, 0x52}, - {18711, 0x54},{19121, 0x56},{19540, 0x58},{19967, 0x5a},{20405, 0x5c},{20851, 0x5e},{21308, 0x60}, - {21775, 0x62},{22251, 0x64},{22739, 0x66},{23236, 0x68},{23745, 0x6a},{24265, 0x6c},{24797, 0x6e}, - {25340, 0x70},{25894, 0x72},{26462, 0x74},{27041, 0x76},{27633, 0x78},{28238, 0x7a},{28856, 0x7c}, - {29488, 0x7e},{30134, 0x80},{30794, 0x82},{31468, 0x84},{32157, 0x86},{32861, 0x88},{33581, 0x8a}, - {34316, 0x8c},{35068, 0x8e},{35836, 0x90},{36620, 0x92},{37422, 0x94},{38242, 0x96},{39079, 0x98}, - {39935, 0x9a},{40809, 0x9c},{41703, 0x9e},{42616, 0xa0},{43549, 0xa2},{44503, 0xa4},{45477, 0xa6}, - {46473, 0xa8},{47491, 0xaa},{48531, 0xac},{49593, 0xae},{50679, 0xb0},{51789, 0xb2},{52923, 0xb4}, - {54082, 0xb6},{55266, 0xb8},{56476, 0xba},{57713, 0xbc},{58977, 0xbe},{60268, 0xc0},{61588, 0xc2}, - {62936, 0xc4},{64315, 0xc6},{65535, 0xc8} }; + Uint16 hfa[101][2] = { { 0, 0x0 }, { 514, 0x2 }, { 775, 0x4 }, { 921, 0x6 }, { 1096, 0x8 }, { 1303, 0x0a }, { 1550, 0x0c }, { 1843, 0x0e }, { 2192, 0x10 }, { 2606, 0x12 }, { 3100, 0x14 }, { 3686, 0x16 }, { 4383, 0x18 }, { 5213, 0x1a }, { 6199, 0x1c }, { 7372, 0x1e }, { 7698, 0x20 }, { 8039, 0x22 }, { 8395, 0x24 }, { 8767, 0x26 }, { 9155, 0x28 }, { 9560, 0x2a }, { 9984, 0x2c }, { 10426, 0x2e }, { 10887, 0x30 }, { 11369, 0x32 }, { 11873, 0x34 }, { 12398, 0x36 }, { 12947, 0x38 }, { 13520, 0x3a }, { 14119, 0x3c }, { 14744, 0x3e }, { 15067, 0x40 }, { 15397, 0x42 }, { 15734, 0x44 }, { 16079, 0x46 }, { 16431, 0x48 }, { 16790, 0x4a }, { 17158, 0x4c }, { 17534, 0x4e }, { 17918, 0x50 }, { 18310, 0x52 }, { 18711, 0x54 }, { 19121, 0x56 }, { 19540, 0x58 }, { 19967, 0x5a }, { 20405, 0x5c }, { 20851, 0x5e }, { 21308, 0x60 }, { 21775, 0x62 }, { 22251, 0x64 }, { 22739, 0x66 }, { 23236, 0x68 }, { 23745, 0x6a }, { 24265, 0x6c }, { 24797, 0x6e }, { 25340, 0x70 }, { 25894, 0x72 }, { 26462, 0x74 }, { 27041, 0x76 }, { 27633, 0x78 }, { 28238, 0x7a }, { 28856, 0x7c }, { 29488, 0x7e }, { 30134, 0x80 }, { 30794, 0x82 }, { 31468, 0x84 }, { 32157, 0x86 }, { 32861, 0x88 }, { 33581, 0x8a }, { 34316, 0x8c }, { 35068, 0x8e }, { 35836, 0x90 }, { 36620, 0x92 }, { 37422, 0x94 }, { 38242, 0x96 }, { 39079, 0x98 }, { 39935, 0x9a }, { 40809, 0x9c }, { 41703, 0x9e }, { 42616, 0xa0 }, { 43549, 0xa2 }, { 44503, 0xa4 }, { 45477, 0xa6 }, { 46473, 0xa8 }, { 47491, 0xaa }, { 48531, 0xac }, { 49593, 0xae }, { 50679, 0xb0 }, { 51789, 0xb2 }, { 52923, 0xb4 }, { 54082, 0xb6 }, { 55266, 0xb8 }, { 56476, 0xba }, { 57713, 0xbc }, { 58977, 0xbe }, { 60268, 0xc0 }, { 61588, 0xc2 }, { 62936, 0xc4 }, { 64315, 0xc6 }, { 65535, 0xc8 } }; int index = 0; - for ( ; index < 101; index++) { + for (; index < 101; index++) { if (amplitude <= hfa[index][0]) { return (Uint8)hfa[index][1]; } @@ -487,27 +486,12 @@ static Uint8 EncodeRumbleHighAmplitude(Uint16 amplitude) { return (Uint8)hfa[100][1]; } -static Uint16 EncodeRumbleLowAmplitude(Uint16 amplitude) { +static Uint16 EncodeRumbleLowAmplitude(Uint16 amplitude) +{ /* More information about these values can be found here: * https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md */ - Uint16 lfa[101][2] = { {0, 0x0040},{514, 0x8040},{775, 0x0041},{921, 0x8041},{1096, 0x0042}, - {1303, 0x8042},{1550, 0x0043},{1843, 0x8043},{2192, 0x0044},{2606, 0x8044},{3100, 0x0045}, - {3686, 0x8045},{4383, 0x0046},{5213, 0x8046},{6199, 0x0047},{7372, 0x8047},{7698, 0x0048}, - {8039, 0x8048},{8395, 0x0049},{8767, 0x8049},{9155, 0x004a},{9560, 0x804a},{9984, 0x004b}, - {10426, 0x804b},{10887, 0x004c},{11369, 0x804c},{11873, 0x004d},{12398, 0x804d},{12947, 0x004e}, - {13520, 0x804e},{14119, 0x004f},{14744, 0x804f},{15067, 0x0050},{15397, 0x8050},{15734, 0x0051}, - {16079, 0x8051},{16431, 0x0052},{16790, 0x8052},{17158, 0x0053},{17534, 0x8053},{17918, 0x0054}, - {18310, 0x8054},{18711, 0x0055},{19121, 0x8055},{19540, 0x0056},{19967, 0x8056},{20405, 0x0057}, - {20851, 0x8057},{21308, 0x0058},{21775, 0x8058},{22251, 0x0059},{22739, 0x8059},{23236, 0x005a}, - {23745, 0x805a},{24265, 0x005b},{24797, 0x805b},{25340, 0x005c},{25894, 0x805c},{26462, 0x005d}, - {27041, 0x805d},{27633, 0x005e},{28238, 0x805e},{28856, 0x005f},{29488, 0x805f},{30134, 0x0060}, - {30794, 0x8060},{31468, 0x0061},{32157, 0x8061},{32861, 0x0062},{33581, 0x8062},{34316, 0x0063}, - {35068, 0x8063},{35836, 0x0064},{36620, 0x8064},{37422, 0x0065},{38242, 0x8065},{39079, 0x0066}, - {39935, 0x8066},{40809, 0x0067},{41703, 0x8067},{42616, 0x0068},{43549, 0x8068},{44503, 0x0069}, - {45477, 0x8069},{46473, 0x006a},{47491, 0x806a},{48531, 0x006b},{49593, 0x806b},{50679, 0x006c}, - {51789, 0x806c},{52923, 0x006d},{54082, 0x806d},{55266, 0x006e},{56476, 0x806e},{57713, 0x006f}, - {58977, 0x806f},{60268, 0x0070},{61588, 0x8070},{62936, 0x0071},{64315, 0x8071},{65535, 0x0072} }; + Uint16 lfa[101][2] = { { 0, 0x0040 }, { 514, 0x8040 }, { 775, 0x0041 }, { 921, 0x8041 }, { 1096, 0x0042 }, { 1303, 0x8042 }, { 1550, 0x0043 }, { 1843, 0x8043 }, { 2192, 0x0044 }, { 2606, 0x8044 }, { 3100, 0x0045 }, { 3686, 0x8045 }, { 4383, 0x0046 }, { 5213, 0x8046 }, { 6199, 0x0047 }, { 7372, 0x8047 }, { 7698, 0x0048 }, { 8039, 0x8048 }, { 8395, 0x0049 }, { 8767, 0x8049 }, { 9155, 0x004a }, { 9560, 0x804a }, { 9984, 0x004b }, { 10426, 0x804b }, { 10887, 0x004c }, { 11369, 0x804c }, { 11873, 0x004d }, { 12398, 0x804d }, { 12947, 0x004e }, { 13520, 0x804e }, { 14119, 0x004f }, { 14744, 0x804f }, { 15067, 0x0050 }, { 15397, 0x8050 }, { 15734, 0x0051 }, { 16079, 0x8051 }, { 16431, 0x0052 }, { 16790, 0x8052 }, { 17158, 0x0053 }, { 17534, 0x8053 }, { 17918, 0x0054 }, { 18310, 0x8054 }, { 18711, 0x0055 }, { 19121, 0x8055 }, { 19540, 0x0056 }, { 19967, 0x8056 }, { 20405, 0x0057 }, { 20851, 0x8057 }, { 21308, 0x0058 }, { 21775, 0x8058 }, { 22251, 0x0059 }, { 22739, 0x8059 }, { 23236, 0x005a }, { 23745, 0x805a }, { 24265, 0x005b }, { 24797, 0x805b }, { 25340, 0x005c }, { 25894, 0x805c }, { 26462, 0x005d }, { 27041, 0x805d }, { 27633, 0x005e }, { 28238, 0x805e }, { 28856, 0x005f }, { 29488, 0x805f }, { 30134, 0x0060 }, { 30794, 0x8060 }, { 31468, 0x0061 }, { 32157, 0x8061 }, { 32861, 0x0062 }, { 33581, 0x8062 }, { 34316, 0x0063 }, { 35068, 0x8063 }, { 35836, 0x0064 }, { 36620, 0x8064 }, { 37422, 0x0065 }, { 38242, 0x8065 }, { 39079, 0x0066 }, { 39935, 0x8066 }, { 40809, 0x0067 }, { 41703, 0x8067 }, { 42616, 0x0068 }, { 43549, 0x8068 }, { 44503, 0x0069 }, { 45477, 0x8069 }, { 46473, 0x006a }, { 47491, 0x806a }, { 48531, 0x006b }, { 49593, 0x806b }, { 50679, 0x006c }, { 51789, 0x806c }, { 52923, 0x006d }, { 54082, 0x806d }, { 55266, 0x006e }, { 56476, 0x806e }, { 57713, 0x006f }, { 58977, 0x806f }, { 60268, 0x0070 }, { 61588, 0x8070 }, { 62936, 0x0071 }, { 64315, 0x8071 }, { 65535, 0x0072 } }; int index = 0; for (; index < 101; index++) { if (amplitude <= lfa[index][0]) { @@ -533,13 +517,13 @@ static void EncodeRumble(SwitchRumbleData_t *pRumble, Uint16 usHighFreq, Uint8 u pRumble->rgucData[0] = usHighFreq & 0xFF; pRumble->rgucData[1] = ucHighFreqAmp | ((usHighFreq >> 8) & 0x01); - pRumble->rgucData[2] = ucLowFreq | ((usLowFreqAmp >> 8) & 0x80); - pRumble->rgucData[3] = usLowFreqAmp & 0xFF; + pRumble->rgucData[2] = ucLowFreq | ((usLowFreqAmp >> 8) & 0x80); + pRumble->rgucData[3] = usLowFreqAmp & 0xFF; #ifdef DEBUG_RUMBLE SDL_Log("Freq: %.2X %.2X %.2X, Amp: %.2X %.2X %.2X\n", - usHighFreq & 0xFF, ((usHighFreq >> 8) & 0x01), ucLowFreq, - ucHighFreqAmp, ((usLowFreqAmp >> 8) & 0x80), usLowFreqAmp & 0xFF); + usHighFreq & 0xFF, ((usHighFreq >> 8) & 0x01), ucLowFreq, + ucHighFreqAmp, ((usLowFreqAmp >> 8) & 0x80), usLowFreqAmp & 0xFF); #endif } else { SetNeutralRumble(pRumble); @@ -647,7 +631,6 @@ static SDL_bool BTrySetupUSB(SDL_DriverSwitch_Context *ctx) static SDL_bool SetVibrationEnabled(SDL_DriverSwitch_Context *ctx, Uint8 enabled) { return WriteSubcommand(ctx, k_eSwitchSubcommandIDs_EnableVibration, &enabled, sizeof(enabled), NULL); - } static SDL_bool SetInputMode(SDL_DriverSwitch_Context *ctx, Uint8 input_mode) { @@ -667,10 +650,10 @@ static SDL_bool SetHomeLED(SDL_DriverSwitch_Context *ctx, Uint8 brightness) } } - rgucBuffer[0] = (0x0 << 4) | 0x1; /* 0 mini cycles (besides first), cycle duration 8ms */ - rgucBuffer[1] = ((ucLedIntensity & 0xF) << 4) | 0x0; /* LED start intensity (0x0-0xF), 0 cycles (LED stays on at start intensity after first cycle) */ - rgucBuffer[2] = ((ucLedIntensity & 0xF) << 4) | 0x0; /* First cycle LED intensity, 0x0 intensity for second cycle */ - rgucBuffer[3] = (0x0 << 4) | 0x0; /* 8ms fade transition to first cycle, 8ms first cycle LED duration */ + rgucBuffer[0] = (0x0 << 4) | 0x1; /* 0 mini cycles (besides first), cycle duration 8ms */ + rgucBuffer[1] = ((ucLedIntensity & 0xF) << 4) | 0x0; /* LED start intensity (0x0-0xF), 0 cycles (LED stays on at start intensity after first cycle) */ + rgucBuffer[2] = ((ucLedIntensity & 0xF) << 4) | 0x0; /* First cycle LED intensity, 0x0 intensity for second cycle */ + rgucBuffer[3] = (0x0 << 4) | 0x0; /* 8ms fade transition to first cycle, 8ms first cycle LED duration */ return WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SetHomeLight, rgucBuffer, sizeof(rgucBuffer), NULL); } @@ -697,7 +680,7 @@ static void UpdateSlotLED(SDL_DriverSwitch_Context *ctx) { if (!ctx->m_bInputOnly) { Uint8 led_data = 0; - + if (ctx->m_bPlayerLights && ctx->m_nPlayerIndex >= 0) { led_data = (1 << (ctx->m_nPlayerIndex % 4)); } @@ -717,7 +700,7 @@ static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, c } } -static SDL_bool SetIMUEnabled(SDL_DriverSwitch_Context* ctx, SDL_bool enabled) +static SDL_bool SetIMUEnabled(SDL_DriverSwitch_Context *ctx, SDL_bool enabled) { Uint8 imu_data = enabled ? 1 : 0; return WriteSubcommand(ctx, k_eSwitchSubcommandIDs_EnableIMU, &imu_data, sizeof(imu_data), NULL); @@ -746,20 +729,20 @@ static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx, Uint8 input_ pStickCal = reply->spiReadData.rgucReadData; /* Left stick */ - ctx->m_StickCalData[0].axis[0].sMax = ((pStickCal[1] << 8) & 0xF00) | pStickCal[0]; /* X Axis max above center */ - ctx->m_StickCalData[0].axis[1].sMax = (pStickCal[2] << 4) | (pStickCal[1] >> 4); /* Y Axis max above center */ - ctx->m_StickCalData[0].axis[0].sCenter = ((pStickCal[4] << 8) & 0xF00) | pStickCal[3]; /* X Axis center */ - ctx->m_StickCalData[0].axis[1].sCenter = (pStickCal[5] << 4) | (pStickCal[4] >> 4); /* Y Axis center */ - ctx->m_StickCalData[0].axis[0].sMin = ((pStickCal[7] << 8) & 0xF00) | pStickCal[6]; /* X Axis min below center */ - ctx->m_StickCalData[0].axis[1].sMin = (pStickCal[8] << 4) | (pStickCal[7] >> 4); /* Y Axis min below center */ + ctx->m_StickCalData[0].axis[0].sMax = ((pStickCal[1] << 8) & 0xF00) | pStickCal[0]; /* X Axis max above center */ + ctx->m_StickCalData[0].axis[1].sMax = (pStickCal[2] << 4) | (pStickCal[1] >> 4); /* Y Axis max above center */ + ctx->m_StickCalData[0].axis[0].sCenter = ((pStickCal[4] << 8) & 0xF00) | pStickCal[3]; /* X Axis center */ + ctx->m_StickCalData[0].axis[1].sCenter = (pStickCal[5] << 4) | (pStickCal[4] >> 4); /* Y Axis center */ + ctx->m_StickCalData[0].axis[0].sMin = ((pStickCal[7] << 8) & 0xF00) | pStickCal[6]; /* X Axis min below center */ + ctx->m_StickCalData[0].axis[1].sMin = (pStickCal[8] << 4) | (pStickCal[7] >> 4); /* Y Axis min below center */ /* Right stick */ - ctx->m_StickCalData[1].axis[0].sCenter = ((pStickCal[10] << 8) & 0xF00) | pStickCal[9]; /* X Axis center */ - ctx->m_StickCalData[1].axis[1].sCenter = (pStickCal[11] << 4) | (pStickCal[10] >> 4); /* Y Axis center */ - ctx->m_StickCalData[1].axis[0].sMin = ((pStickCal[13] << 8) & 0xF00) | pStickCal[12]; /* X Axis min below center */ - ctx->m_StickCalData[1].axis[1].sMin = (pStickCal[14] << 4) | (pStickCal[13] >> 4); /* Y Axis min below center */ - ctx->m_StickCalData[1].axis[0].sMax = ((pStickCal[16] << 8) & 0xF00) | pStickCal[15]; /* X Axis max above center */ - ctx->m_StickCalData[1].axis[1].sMax = (pStickCal[17] << 4) | (pStickCal[16] >> 4); /* Y Axis max above center */ + ctx->m_StickCalData[1].axis[0].sCenter = ((pStickCal[10] << 8) & 0xF00) | pStickCal[9]; /* X Axis center */ + ctx->m_StickCalData[1].axis[1].sCenter = (pStickCal[11] << 4) | (pStickCal[10] >> 4); /* Y Axis center */ + ctx->m_StickCalData[1].axis[0].sMin = ((pStickCal[13] << 8) & 0xF00) | pStickCal[12]; /* X Axis min below center */ + ctx->m_StickCalData[1].axis[1].sMin = (pStickCal[14] << 4) | (pStickCal[13] >> 4); /* Y Axis min below center */ + ctx->m_StickCalData[1].axis[0].sMax = ((pStickCal[16] << 8) & 0xF00) | pStickCal[15]; /* X Axis max above center */ + ctx->m_StickCalData[1].axis[1].sMax = (pStickCal[17] << 4) | (pStickCal[16] >> 4); /* Y Axis max above center */ /* Filter out any values that were uninitialized (0xFFF) in the SPI read */ for (stick = 0; stick < 2; ++stick) { @@ -793,10 +776,10 @@ static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx, Uint8 input_ return SDL_TRUE; } -static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context* ctx) +static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context *ctx) { - Uint8* pIMUScale; - SwitchSubcommandInputPacket_t* reply = NULL; + Uint8 *pIMUScale; + SwitchSubcommandInputPacket_t *reply = NULL; Sint16 sAccelRawX, sAccelRawY, sAccelRawZ, sGyroRawX, sGyroRawY, sGyroRawZ; /* Read Calibration Info */ @@ -804,7 +787,7 @@ static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context* ctx) readParams.unAddress = k_unSPIIMUScaleStartOffset; readParams.ucLength = k_unSPIIMUScaleLength; - if (!WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t*)&readParams, sizeof(readParams), &reply)) { + if (!WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t *)&readParams, sizeof(readParams), &reply)) { const float accelScale = SDL_STANDARD_GRAVITY / SWITCH_ACCEL_SCALE; const float gyroScale = (float)M_PI / 180.0f / SWITCH_GYRO_SCALE; @@ -833,9 +816,9 @@ static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context* ctx) /* Check for user calibration data. If it's present and set, it'll override the factory settings */ readParams.unAddress = k_unSPIIMUUserScaleStartOffset; readParams.ucLength = k_unSPIIMUUserScaleLength; - if (WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t*)&readParams, sizeof(readParams), &reply) && (pIMUScale[0] | pIMUScale[1] << 8) == 0xA1B2) { + if (WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t *)&readParams, sizeof(readParams), &reply) && (pIMUScale[0] | pIMUScale[1] << 8) == 0xA1B2) { pIMUScale = reply->spiReadData.rgucReadData; - + sAccelRawX = (pIMUScale[3] << 8) | pIMUScale[2]; sAccelRawY = (pIMUScale[5] << 8) | pIMUScale[4]; sAccelRawZ = (pIMUScale[7] << 8) | pIMUScale[6]; @@ -858,7 +841,6 @@ static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context* ctx) return SDL_TRUE; } - static Sint16 ApplyStickCalibration(SDL_DriverSwitch_Context *ctx, int nStick, int nAxis, Sint16 sRawValue) { sRawValue -= ctx->m_StickCalData[nStick].axis[nAxis].sCenter; @@ -928,9 +910,8 @@ static Uint8 RemapButton(SDL_DriverSwitch_Context *ctx, Uint8 button) } return button; } - -static int -GetMaxWriteAttempts(SDL_HIDAPI_Device *device) + +static int GetMaxWriteAttempts(SDL_HIDAPI_Device *device) { if (device->vendor_id == USB_VENDOR_NINTENDO && device->product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_GRIP) { @@ -941,8 +922,7 @@ GetMaxWriteAttempts(SDL_HIDAPI_Device *device) } } -static ESwitchDeviceInfoControllerType -ReadJoyConControllerType(SDL_HIDAPI_Device *device) +static ESwitchDeviceInfoControllerType ReadJoyConControllerType(SDL_HIDAPI_Device *device) { ESwitchDeviceInfoControllerType eControllerType = k_eSwitchDeviceInfoControllerType_Unknown; const int MAX_ATTEMPTS = 1; /* Don't try too long, in case this is a zombie Bluetooth controller */ @@ -981,8 +961,7 @@ ReadJoyConControllerType(SDL_HIDAPI_Device *device) return eControllerType; } -static SDL_bool -HasHomeLED(SDL_DriverSwitch_Context *ctx) +static SDL_bool HasHomeLED(SDL_DriverSwitch_Context *ctx) { Uint16 vendor_id = ctx->device->vendor_id; Uint16 product_id = ctx->device->product_id; @@ -1006,8 +985,7 @@ HasHomeLED(SDL_DriverSwitch_Context *ctx) return SDL_TRUE; } -static SDL_bool -AlwaysUsesLabels(int vendor_id, int product_id, ESwitchDeviceInfoControllerType eControllerType) +static SDL_bool AlwaysUsesLabels(int vendor_id, int product_id, ESwitchDeviceInfoControllerType eControllerType) { /* These controllers don't have a diamond button configuration, so always use labels */ switch (eControllerType) { @@ -1021,12 +999,11 @@ AlwaysUsesLabels(int vendor_id, int product_id, ESwitchDeviceInfoControllerType } } -static SDL_bool -IsGameCubeFormFactor(int vendor_id, int product_id) +static SDL_bool IsGameCubeFormFactor(int vendor_id, int product_id) { static Uint32 gamecube_formfactor[] = { - MAKE_VIDPID(0x0e6f, 0x0185), /* PDP Wired Fight Pad Pro for Nintendo Switch */ - MAKE_VIDPID(0x20d6, 0xa711), /* Core (Plus) Wired Controller */ + MAKE_VIDPID(0x0e6f, 0x0185), /* PDP Wired Fight Pad Pro for Nintendo Switch */ + MAKE_VIDPID(0x20d6, 0xa711), /* Core (Plus) Wired Controller */ }; Uint32 id = MAKE_VIDPID(vendor_id, product_id); int i; @@ -1039,26 +1016,22 @@ IsGameCubeFormFactor(int vendor_id, int product_id) return SDL_FALSE; } -static void -HIDAPI_DriverNintendoClassic_RegisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverNintendoClassic_RegisterHints(SDL_HintCallback callback, void *userdata) { SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_NINTENDO_CLASSIC, callback, userdata); } -static void -HIDAPI_DriverNintendoClassic_UnregisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverNintendoClassic_UnregisterHints(SDL_HintCallback callback, void *userdata) { SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_NINTENDO_CLASSIC, callback, userdata); } -static SDL_bool -HIDAPI_DriverNintendoClassic_IsEnabled(void) +static SDL_bool HIDAPI_DriverNintendoClassic_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_NINTENDO_CLASSIC, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); } -static SDL_bool -HIDAPI_DriverNintendoClassic_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static SDL_bool HIDAPI_DriverNintendoClassic_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { if (vendor_id == USB_VENDOR_NINTENDO) { if (product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT) { @@ -1083,26 +1056,22 @@ HIDAPI_DriverNintendoClassic_IsSupportedDevice(SDL_HIDAPI_Device *device, const return SDL_FALSE; } -static void -HIDAPI_DriverJoyCons_RegisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverJoyCons_RegisterHints(SDL_HintCallback callback, void *userdata) { SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, callback, userdata); } -static void -HIDAPI_DriverJoyCons_UnregisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverJoyCons_UnregisterHints(SDL_HintCallback callback, void *userdata) { SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, callback, userdata); } -static SDL_bool -HIDAPI_DriverJoyCons_IsEnabled(void) +static SDL_bool HIDAPI_DriverJoyCons_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); } -static SDL_bool -HIDAPI_DriverJoyCons_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static SDL_bool HIDAPI_DriverJoyCons_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { if (vendor_id == USB_VENDOR_NINTENDO) { if (product_id == USB_PRODUCT_NINTENDO_SWITCH_PRO && device && device->dev) { @@ -1123,26 +1092,22 @@ HIDAPI_DriverJoyCons_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *na return SDL_FALSE; } -static void -HIDAPI_DriverSwitch_RegisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverSwitch_RegisterHints(SDL_HintCallback callback, void *userdata) { SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, callback, userdata); } -static void -HIDAPI_DriverSwitch_UnregisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverSwitch_UnregisterHints(SDL_HintCallback callback, void *userdata) { SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, callback, userdata); } -static SDL_bool -HIDAPI_DriverSwitch_IsEnabled(void) +static SDL_bool HIDAPI_DriverSwitch_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); } -static SDL_bool -HIDAPI_DriverSwitch_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static SDL_bool HIDAPI_DriverSwitch_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { /* The HORI Wireless Switch Pad enumerates as a HID device when connected via USB with the same VID/PID as when connected over Bluetooth but doesn't actually @@ -1163,8 +1128,7 @@ HIDAPI_DriverSwitch_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *nam return (type == SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO) ? SDL_TRUE : SDL_FALSE; } -static void -UpdateDeviceIdentity(SDL_HIDAPI_Device *device) +static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device) { SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)device->context; char serial[18]; @@ -1223,8 +1187,7 @@ UpdateDeviceIdentity(SDL_HIDAPI_Device *device) HIDAPI_SetDeviceSerial(device, serial); } -static SDL_bool -HIDAPI_DriverSwitch_InitDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverSwitch_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverSwitch_Context *ctx; @@ -1267,14 +1230,12 @@ HIDAPI_DriverSwitch_InitDevice(SDL_HIDAPI_Device *device) return HIDAPI_JoystickConnected(device, NULL); } -static int -HIDAPI_DriverSwitch_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) +static int HIDAPI_DriverSwitch_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) { return -1; } -static void -HIDAPI_DriverSwitch_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) +static void HIDAPI_DriverSwitch_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) { SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)device->context; @@ -1287,8 +1248,7 @@ HIDAPI_DriverSwitch_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_Joystick UpdateSlotLED(ctx); } -static SDL_bool -HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)device->context; Uint8 input_mode; @@ -1324,7 +1284,7 @@ HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joysti if (device->vendor_id == USB_VENDOR_NINTENDO) { input_mode = k_eSwitchInputReportIDs_FullControllerState; } - + if (input_mode == k_eSwitchInputReportIDs_FullControllerState && ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_NESLeft && ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_NESRight && @@ -1423,8 +1383,7 @@ HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joysti return SDL_TRUE; } -static int -HIDAPI_DriverSwitch_ActuallyRumbleJoystick(SDL_DriverSwitch_Context *ctx, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int HIDAPI_DriverSwitch_ActuallyRumbleJoystick(SDL_DriverSwitch_Context *ctx, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { /* Experimentally determined rumble values. These will only matter on some controllers as tested ones * seem to disregard these and just use any non-zero rumble values as a binary flag for constant rumble @@ -1433,8 +1392,8 @@ HIDAPI_DriverSwitch_ActuallyRumbleJoystick(SDL_DriverSwitch_Context *ctx, Uint16 * https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md */ const Uint16 k_usHighFreq = 0x0074; - const Uint8 k_ucHighFreqAmp = EncodeRumbleHighAmplitude(high_frequency_rumble); - const Uint8 k_ucLowFreq = 0x3D; + const Uint8 k_ucHighFreqAmp = EncodeRumbleHighAmplitude(high_frequency_rumble); + const Uint8 k_ucLowFreq = 0x3D; const Uint16 k_usLowFreqAmp = EncodeRumbleLowAmplitude(low_frequency_rumble); if (low_frequency_rumble || high_frequency_rumble) { @@ -1453,8 +1412,7 @@ HIDAPI_DriverSwitch_ActuallyRumbleJoystick(SDL_DriverSwitch_Context *ctx, Uint16 return 0; } -static int -HIDAPI_DriverSwitch_SendPendingRumble(SDL_DriverSwitch_Context *ctx) +static int HIDAPI_DriverSwitch_SendPendingRumble(SDL_DriverSwitch_Context *ctx) { if (!SDL_TICKS_PASSED(SDL_GetTicks(), ctx->m_unRumbleSent + RUMBLE_WRITE_FREQUENCY_MS)) { return 0; @@ -1485,8 +1443,7 @@ HIDAPI_DriverSwitch_SendPendingRumble(SDL_DriverSwitch_Context *ctx) return 0; } -static int -HIDAPI_DriverSwitch_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int HIDAPI_DriverSwitch_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)device->context; @@ -1534,14 +1491,12 @@ HIDAPI_DriverSwitch_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joys return HIDAPI_DriverSwitch_ActuallyRumbleJoystick(ctx, low_frequency_rumble, high_frequency_rumble); } -static int -HIDAPI_DriverSwitch_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int HIDAPI_DriverSwitch_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static Uint32 -HIDAPI_DriverSwitch_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static Uint32 HIDAPI_DriverSwitch_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)device->context; Uint32 result = 0; @@ -1554,23 +1509,20 @@ HIDAPI_DriverSwitch_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joyst return result; } -static int -HIDAPI_DriverSwitch_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int HIDAPI_DriverSwitch_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -HIDAPI_DriverSwitch_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) +static int HIDAPI_DriverSwitch_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -HIDAPI_DriverSwitch_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverSwitch_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) { - SDL_DriverSwitch_Context* ctx = (SDL_DriverSwitch_Context*)device->context; - + SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)device->context; + SetIMUEnabled(ctx, enabled); ctx->m_bReportSensors = enabled; ctx->m_unIMUSamples = 0; @@ -1773,7 +1725,7 @@ static void SendSensorUpdate(SDL_Joystick *joystick, SDL_DriverSwitch_Context *c * since that's our de facto standard from already supporting those controllers, and * users will want consistent axis mappings across devices. */ - if (type == SDL_SENSOR_GYRO || type == SDL_SENSOR_GYRO_L || type == SDL_SENSOR_GYRO_R ) { + if (type == SDL_SENSOR_GYRO || type == SDL_SENSOR_GYRO_L || type == SDL_SENSOR_GYRO_R) { data[0] = -(ctx->m_IMUScaleData.fGyroScaleY * (float)values[1]); data[1] = ctx->m_IMUScaleData.fGyroScaleZ * (float)values[2]; data[2] = -(ctx->m_IMUScaleData.fGyroScaleX * (float)values[0]); @@ -2119,8 +2071,7 @@ static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_C ctx->m_lastFullState = *packet; } -static SDL_bool -HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -2201,8 +2152,7 @@ HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device) return size >= 0; } -static void -HIDAPI_DriverSwitch_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static void HIDAPI_DriverSwitch_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)device->context; @@ -2229,13 +2179,11 @@ HIDAPI_DriverSwitch_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joyst ctx->joystick = NULL; } -static void -HIDAPI_DriverSwitch_FreeDevice(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverSwitch_FreeDevice(SDL_HIDAPI_Device *device) { } -SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverNintendoClassic = -{ +SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverNintendoClassic = { SDL_HINT_JOYSTICK_HIDAPI_NINTENDO_CLASSIC, SDL_TRUE, HIDAPI_DriverNintendoClassic_RegisterHints, @@ -2257,8 +2205,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverNintendoClassic = HIDAPI_DriverSwitch_FreeDevice, }; -SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverJoyCons = -{ +SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverJoyCons = { SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, SDL_TRUE, HIDAPI_DriverJoyCons_RegisterHints, @@ -2280,8 +2227,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverJoyCons = HIDAPI_DriverSwitch_FreeDevice, }; -SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSwitch = -{ +SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSwitch = { SDL_HINT_JOYSTICK_HIDAPI_SWITCH, SDL_TRUE, HIDAPI_DriverSwitch_RegisterHints, diff --git a/src/joystick/hidapi/SDL_hidapi_wii.c b/src/joystick/hidapi/SDL_hidapi_wii.c index 3149f2766..3ec2ec65c 100644 --- a/src/joystick/hidapi/SDL_hidapi_wii.c +++ b/src/joystick/hidapi/SDL_hidapi_wii.c @@ -33,7 +33,6 @@ #include "SDL_hidapi_rumble.h" #include "SDL_hidapi_nintendo.h" - #ifdef SDL_JOYSTICK_HIDAPI_WII /* Define this if you want to log all packets from the controller */ @@ -41,27 +40,27 @@ #define ENABLE_CONTINUOUS_REPORTING SDL_TRUE -#define INPUT_WAIT_TIMEOUT_MS (3 * 1000) -#define MOTION_PLUS_UPDATE_TIME_MS (8 * 1000) -#define STATUS_UPDATE_TIME_MS (15 * 60 * 1000) +#define INPUT_WAIT_TIMEOUT_MS (3 * 1000) +#define MOTION_PLUS_UPDATE_TIME_MS (8 * 1000) +#define STATUS_UPDATE_TIME_MS (15 * 60 * 1000) -#define WII_EXTENSION_NONE 0x2E2E -#define WII_EXTENSION_UNINITIALIZED 0xFFFF -#define WII_EXTENSION_NUNCHUK 0x0000 -#define WII_EXTENSION_GAMEPAD 0x0101 -#define WII_EXTENSION_WIIUPRO 0x0120 -#define WII_EXTENSION_MOTIONPLUS_MASK 0xF0FF -#define WII_EXTENSION_MOTIONPLUS_ID 0x0005 +#define WII_EXTENSION_NONE 0x2E2E +#define WII_EXTENSION_UNINITIALIZED 0xFFFF +#define WII_EXTENSION_NUNCHUK 0x0000 +#define WII_EXTENSION_GAMEPAD 0x0101 +#define WII_EXTENSION_WIIUPRO 0x0120 +#define WII_EXTENSION_MOTIONPLUS_MASK 0xF0FF +#define WII_EXTENSION_MOTIONPLUS_ID 0x0005 -#define WII_MOTIONPLUS_MODE_NONE 0x00 -#define WII_MOTIONPLUS_MODE_STANDARD 0x04 -#define WII_MOTIONPLUS_MODE_NUNCHUK 0x05 -#define WII_MOTIONPLUS_MODE_GAMEPAD 0x07 +#define WII_MOTIONPLUS_MODE_NONE 0x00 +#define WII_MOTIONPLUS_MODE_STANDARD 0x04 +#define WII_MOTIONPLUS_MODE_NUNCHUK 0x05 +#define WII_MOTIONPLUS_MODE_GAMEPAD 0x07 - -typedef enum { - k_eWiiInputReportIDs_Status = 0x20, - k_eWiiInputReportIDs_ReadMemory = 0x21, +typedef enum +{ + k_eWiiInputReportIDs_Status = 0x20, + k_eWiiInputReportIDs_ReadMemory = 0x21, k_eWiiInputReportIDs_Acknowledge = 0x22, k_eWiiInputReportIDs_ButtonData0 = 0x30, k_eWiiInputReportIDs_ButtonData1 = 0x31, @@ -76,34 +75,38 @@ typedef enum { k_eWiiInputReportIDs_ButtonDataF = 0x3F, } EWiiInputReportIDs; -typedef enum { - k_eWiiOutputReportIDs_Rumble = 0x10, - k_eWiiOutputReportIDs_LEDs = 0x11, +typedef enum +{ + k_eWiiOutputReportIDs_Rumble = 0x10, + k_eWiiOutputReportIDs_LEDs = 0x11, k_eWiiOutputReportIDs_DataReportingMode = 0x12, - k_eWiiOutputReportIDs_IRCameraEnable = 0x13, - k_eWiiOutputReportIDs_SpeakerEnable = 0x14, - k_eWiiOutputReportIDs_StatusRequest = 0x15, - k_eWiiOutputReportIDs_WriteMemory = 0x16, - k_eWiiOutputReportIDs_ReadMemory = 0x17, - k_eWiiOutputReportIDs_SpeakerData = 0x18, - k_eWiiOutputReportIDs_SpeakerMute = 0x19, - k_eWiiOutputReportIDs_IRCameraEnable2 = 0x1a, + k_eWiiOutputReportIDs_IRCameraEnable = 0x13, + k_eWiiOutputReportIDs_SpeakerEnable = 0x14, + k_eWiiOutputReportIDs_StatusRequest = 0x15, + k_eWiiOutputReportIDs_WriteMemory = 0x16, + k_eWiiOutputReportIDs_ReadMemory = 0x17, + k_eWiiOutputReportIDs_SpeakerData = 0x18, + k_eWiiOutputReportIDs_SpeakerMute = 0x19, + k_eWiiOutputReportIDs_IRCameraEnable2 = 0x1a, } EWiiOutputReportIDs; -typedef enum { +typedef enum +{ k_eWiiPlayerLEDs_P1 = 0x10, k_eWiiPlayerLEDs_P2 = 0x20, k_eWiiPlayerLEDs_P3 = 0x40, k_eWiiPlayerLEDs_P4 = 0x80, } EWiiPlayerLEDs; -typedef enum { +typedef enum +{ k_eWiiCommunicationState_None, /* No special communications happening */ k_eWiiCommunicationState_CheckMotionPlusStage1, /* Sent standard extension identify request */ k_eWiiCommunicationState_CheckMotionPlusStage2, /* Sent Motion Plus extension identify request */ } EWiiCommunicationState; -typedef enum { +typedef enum +{ k_eWiiButtons_A = SDL_CONTROLLER_BUTTON_MISC1, k_eWiiButtons_B, k_eWiiButtons_One, @@ -120,7 +123,8 @@ typedef enum { #define k_unWiiPacketDataLength 22 -typedef struct { +typedef struct +{ Uint8 rgucBaseButtons[2]; Uint8 rgucAccelerometer[3]; Uint8 rgucExtension[21]; @@ -129,7 +133,8 @@ typedef struct { Uint8 ucNExtensionBytes; } WiiButtonData; -typedef struct { +typedef struct +{ SDL_HIDAPI_Device *device; SDL_Joystick *joystick; EWiiCommunicationState m_eCommState; @@ -139,7 +144,7 @@ typedef struct { int m_nPlayerIndex; SDL_bool m_bRumbleActive; SDL_bool m_bMotionPlusPresent; - Uint8 m_ucMotionPlusMode; + Uint8 m_ucMotionPlusMode; SDL_bool m_bReportSensors; Uint8 m_rgucReadBuffer[k_unWiiPacketDataLength]; Uint32 m_unLastInput; @@ -147,7 +152,8 @@ typedef struct { Uint32 m_unNextMotionPlusCheck; SDL_bool m_bDisconnected; - struct StickCalibrationData { + struct StickCalibrationData + { Uint16 min; Uint16 max; Uint16 center; @@ -155,32 +161,28 @@ typedef struct { } m_StickCalibrationData[6]; } SDL_DriverWii_Context; -static void -HIDAPI_DriverWii_RegisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverWii_RegisterHints(SDL_HintCallback callback, void *userdata) { SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_WII, callback, userdata); } -static void -HIDAPI_DriverWii_UnregisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverWii_UnregisterHints(SDL_HintCallback callback, void *userdata) { SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_WII, callback, userdata); } -static SDL_bool -HIDAPI_DriverWii_IsEnabled(void) +static SDL_bool HIDAPI_DriverWii_IsEnabled(void) { #if 1 /* This doesn't work with the dolphinbar, so don't enable by default right now */ return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_WII, SDL_FALSE); #else return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_WII, - SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, - SDL_HIDAPI_DEFAULT)); + SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, + SDL_HIDAPI_DEFAULT)); #endif } -static SDL_bool -HIDAPI_DriverWii_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static SDL_bool HIDAPI_DriverWii_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { if (vendor_id == USB_VENDOR_NINTENDO && (product_id == USB_PRODUCT_NINTENDO_WII_REMOTE || @@ -226,7 +228,7 @@ static SDL_bool WriteOutput(SDL_DriverWii_Context *ctx, const Uint8 *data, int s } } -static SDL_bool ReadInputSync(SDL_DriverWii_Context *ctx, EWiiInputReportIDs expectedID, SDL_bool(*isMine)(const Uint8 *)) +static SDL_bool ReadInputSync(SDL_DriverWii_Context *ctx, EWiiInputReportIDs expectedID, SDL_bool (*isMine)(const Uint8 *)) { Uint32 TimeoutMs = 250; /* Seeing successful reads after about 200 ms */ Uint32 startTicks = SDL_GetTicks(); @@ -511,7 +513,7 @@ static void UpdatePowerLevelWii(SDL_Joystick *joystick, Uint8 batteryLevelByte) static void UpdatePowerLevelWiiU(SDL_Joystick *joystick, Uint8 extensionBatteryByte) { - SDL_bool charging = extensionBatteryByte & 0x08 ? SDL_FALSE : SDL_TRUE; + SDL_bool charging = extensionBatteryByte & 0x08 ? SDL_FALSE : SDL_TRUE; SDL_bool pluggedIn = extensionBatteryByte & 0x04 ? SDL_FALSE : SDL_TRUE; Uint8 batteryLevel = extensionBatteryByte >> 4; @@ -580,32 +582,32 @@ static void InitStickCalibrationData(SDL_DriverWii_Context *ctx) { int i; switch (ctx->m_eExtensionControllerType) { - case k_eWiiExtensionControllerType_WiiUPro: - for (i = 0; i < 4; i++) { - ctx->m_StickCalibrationData[i].min = 1000; - ctx->m_StickCalibrationData[i].max = 3000; - ctx->m_StickCalibrationData[i].center = 0; - ctx->m_StickCalibrationData[i].deadzone = 100; - } - break; - case k_eWiiExtensionControllerType_Gamepad: - for (i = 0; i < 4; i++) { - ctx->m_StickCalibrationData[i].min = i < 2 ? 9 : 5; - ctx->m_StickCalibrationData[i].max = i < 2 ? 54 : 26; - ctx->m_StickCalibrationData[i].center = 0; - ctx->m_StickCalibrationData[i].deadzone = i < 2 ? 4 : 2; - } - break; - case k_eWiiExtensionControllerType_Nunchuk: - for (i = 0; i < 2; i++) { - ctx->m_StickCalibrationData[i].min = 40; - ctx->m_StickCalibrationData[i].max = 215; - ctx->m_StickCalibrationData[i].center = 0; - ctx->m_StickCalibrationData[i].deadzone = 10; - } - break; - default: - break; + case k_eWiiExtensionControllerType_WiiUPro: + for (i = 0; i < 4; i++) { + ctx->m_StickCalibrationData[i].min = 1000; + ctx->m_StickCalibrationData[i].max = 3000; + ctx->m_StickCalibrationData[i].center = 0; + ctx->m_StickCalibrationData[i].deadzone = 100; + } + break; + case k_eWiiExtensionControllerType_Gamepad: + for (i = 0; i < 4; i++) { + ctx->m_StickCalibrationData[i].min = i < 2 ? 9 : 5; + ctx->m_StickCalibrationData[i].max = i < 2 ? 54 : 26; + ctx->m_StickCalibrationData[i].center = 0; + ctx->m_StickCalibrationData[i].deadzone = i < 2 ? 4 : 2; + } + break; + case k_eWiiExtensionControllerType_Nunchuk: + for (i = 0; i < 2; i++) { + ctx->m_StickCalibrationData[i].min = 40; + ctx->m_StickCalibrationData[i].max = 215; + ctx->m_StickCalibrationData[i].center = 0; + ctx->m_StickCalibrationData[i].deadzone = 10; + } + break; + default: + break; } } @@ -667,8 +669,7 @@ static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, c } } -static EWiiExtensionControllerType -ReadExtensionControllerType(SDL_HIDAPI_Device *device) +static EWiiExtensionControllerType ReadExtensionControllerType(SDL_HIDAPI_Device *device) { SDL_DriverWii_Context *ctx = (SDL_DriverWii_Context *)device->context; EWiiExtensionControllerType eExtensionControllerType = k_eWiiExtensionControllerType_Unknown; @@ -703,8 +704,7 @@ ReadExtensionControllerType(SDL_HIDAPI_Device *device) return eExtensionControllerType; } -static void -UpdateDeviceIdentity(SDL_HIDAPI_Device *device) +static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device) { SDL_DriverWii_Context *ctx = (SDL_DriverWii_Context *)device->context; @@ -728,8 +728,7 @@ UpdateDeviceIdentity(SDL_HIDAPI_Device *device) device->guid.data[15] = ctx->m_eExtensionControllerType; } -static SDL_bool -HIDAPI_DriverWii_InitDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverWii_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverWii_Context *ctx; @@ -749,14 +748,12 @@ HIDAPI_DriverWii_InitDevice(SDL_HIDAPI_Device *device) return HIDAPI_JoystickConnected(device, NULL); } -static int -HIDAPI_DriverWii_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) +static int HIDAPI_DriverWii_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) { return -1; } -static void -HIDAPI_DriverWii_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) +static void HIDAPI_DriverWii_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) { SDL_DriverWii_Context *ctx = (SDL_DriverWii_Context *)device->context; @@ -769,8 +766,7 @@ HIDAPI_DriverWii_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID UpdateSlotLED(ctx); } -static SDL_bool -HIDAPI_DriverWii_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static SDL_bool HIDAPI_DriverWii_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverWii_Context *ctx = (SDL_DriverWii_Context *)device->context; @@ -821,8 +817,7 @@ HIDAPI_DriverWii_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) return SDL_TRUE; } -static int -HIDAPI_DriverWii_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int HIDAPI_DriverWii_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { SDL_DriverWii_Context *ctx = (SDL_DriverWii_Context *)device->context; SDL_bool active = (low_frequency_rumble || high_frequency_rumble) ? SDL_TRUE : SDL_FALSE; @@ -839,32 +834,27 @@ HIDAPI_DriverWii_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystic return 0; } -static int -HIDAPI_DriverWii_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int HIDAPI_DriverWii_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static Uint32 -HIDAPI_DriverWii_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static Uint32 HIDAPI_DriverWii_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { return SDL_JOYCAP_RUMBLE; } -static int -HIDAPI_DriverWii_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int HIDAPI_DriverWii_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -HIDAPI_DriverWii_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) +static int HIDAPI_DriverWii_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -HIDAPI_DriverWii_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverWii_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) { SDL_DriverWii_Context *ctx = (SDL_DriverWii_Context *)device->context; @@ -926,7 +916,7 @@ static void PostStickCalibrated(SDL_Joystick *joystick, struct StickCalibrationD *`on` is the joystick value to be sent if a bit is on *`off` is the joystick value to be sent if a bit is off */ -static void PostPackedButtonData(SDL_Joystick *joystick, const Uint8 defs[][8], const Uint8* data, int size, Uint8 on, Uint8 off) +static void PostPackedButtonData(SDL_Joystick *joystick, const Uint8 defs[][8], const Uint8 *data, int size, Uint8 on, Uint8 off) { int i, j; @@ -943,70 +933,163 @@ static void PostPackedButtonData(SDL_Joystick *joystick, const Uint8 defs[][8], static const Uint8 GAMEPAD_BUTTON_DEFS[3][8] = { { - 0xFF /* Unused */, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, SDL_CONTROLLER_BUTTON_START, SDL_CONTROLLER_BUTTON_GUIDE, - SDL_CONTROLLER_BUTTON_BACK, SDL_CONTROLLER_BUTTON_LEFTSHOULDER, SDL_CONTROLLER_BUTTON_DPAD_DOWN, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, - }, { - SDL_CONTROLLER_BUTTON_DPAD_UP, SDL_CONTROLLER_BUTTON_DPAD_LEFT, 0xFF /* ZR */, SDL_CONTROLLER_BUTTON_X, - SDL_CONTROLLER_BUTTON_A, SDL_CONTROLLER_BUTTON_Y, SDL_CONTROLLER_BUTTON_B, 0xFF /*ZL*/, - }, { - SDL_CONTROLLER_BUTTON_RIGHTSTICK, SDL_CONTROLLER_BUTTON_LEFTSTICK, 0xFF /* Charging */, 0xFF /* Plugged In */, - 0xFF /* Unused */, 0xFF /* Unused */, 0xFF /* Unused */, 0xFF /* Unused */, + 0xFF /* Unused */, + SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, + SDL_CONTROLLER_BUTTON_START, + SDL_CONTROLLER_BUTTON_GUIDE, + SDL_CONTROLLER_BUTTON_BACK, + SDL_CONTROLLER_BUTTON_LEFTSHOULDER, + SDL_CONTROLLER_BUTTON_DPAD_DOWN, + SDL_CONTROLLER_BUTTON_DPAD_RIGHT, + }, + { + SDL_CONTROLLER_BUTTON_DPAD_UP, + SDL_CONTROLLER_BUTTON_DPAD_LEFT, + 0xFF /* ZR */, + SDL_CONTROLLER_BUTTON_X, + SDL_CONTROLLER_BUTTON_A, + SDL_CONTROLLER_BUTTON_Y, + SDL_CONTROLLER_BUTTON_B, + 0xFF /*ZL*/, + }, + { + SDL_CONTROLLER_BUTTON_RIGHTSTICK, + SDL_CONTROLLER_BUTTON_LEFTSTICK, + 0xFF /* Charging */, + 0xFF /* Plugged In */, + 0xFF /* Unused */, + 0xFF /* Unused */, + 0xFF /* Unused */, + 0xFF /* Unused */, } }; static const Uint8 GAMEPAD_BUTTON_DEFS_POSITIONAL[3][8] = { { - 0xFF /* Unused */, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, SDL_CONTROLLER_BUTTON_START, SDL_CONTROLLER_BUTTON_GUIDE, - SDL_CONTROLLER_BUTTON_BACK, SDL_CONTROLLER_BUTTON_LEFTSHOULDER, SDL_CONTROLLER_BUTTON_DPAD_DOWN, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, - }, { - SDL_CONTROLLER_BUTTON_DPAD_UP, SDL_CONTROLLER_BUTTON_DPAD_LEFT, 0xFF /* ZR */, SDL_CONTROLLER_BUTTON_Y, - SDL_CONTROLLER_BUTTON_B, SDL_CONTROLLER_BUTTON_X, SDL_CONTROLLER_BUTTON_A, 0xFF /*ZL*/, - }, { - SDL_CONTROLLER_BUTTON_RIGHTSTICK, SDL_CONTROLLER_BUTTON_LEFTSTICK, 0xFF /* Charging */, 0xFF /* Plugged In */, - 0xFF /* Unused */, 0xFF /* Unused */, 0xFF /* Unused */, 0xFF /* Unused */, + 0xFF /* Unused */, + SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, + SDL_CONTROLLER_BUTTON_START, + SDL_CONTROLLER_BUTTON_GUIDE, + SDL_CONTROLLER_BUTTON_BACK, + SDL_CONTROLLER_BUTTON_LEFTSHOULDER, + SDL_CONTROLLER_BUTTON_DPAD_DOWN, + SDL_CONTROLLER_BUTTON_DPAD_RIGHT, + }, + { + SDL_CONTROLLER_BUTTON_DPAD_UP, + SDL_CONTROLLER_BUTTON_DPAD_LEFT, + 0xFF /* ZR */, + SDL_CONTROLLER_BUTTON_Y, + SDL_CONTROLLER_BUTTON_B, + SDL_CONTROLLER_BUTTON_X, + SDL_CONTROLLER_BUTTON_A, + 0xFF /*ZL*/, + }, + { + SDL_CONTROLLER_BUTTON_RIGHTSTICK, + SDL_CONTROLLER_BUTTON_LEFTSTICK, + 0xFF /* Charging */, + 0xFF /* Plugged In */, + 0xFF /* Unused */, + 0xFF /* Unused */, + 0xFF /* Unused */, + 0xFF /* Unused */, } }; static const Uint8 MP_GAMEPAD_BUTTON_DEFS[3][8] = { { - 0xFF /* Unused */, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, SDL_CONTROLLER_BUTTON_START, SDL_CONTROLLER_BUTTON_GUIDE, - SDL_CONTROLLER_BUTTON_BACK, SDL_CONTROLLER_BUTTON_LEFTSHOULDER, SDL_CONTROLLER_BUTTON_DPAD_DOWN, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, - }, { - 0xFF /* Motion Plus data */, 0xFF /* Motion Plus data */, 0xFF /* ZR */, SDL_CONTROLLER_BUTTON_X, - SDL_CONTROLLER_BUTTON_A, SDL_CONTROLLER_BUTTON_Y, SDL_CONTROLLER_BUTTON_B, 0xFF /*ZL*/, - }, { - SDL_CONTROLLER_BUTTON_RIGHTSTICK, SDL_CONTROLLER_BUTTON_LEFTSTICK, 0xFF /* Charging */, 0xFF /* Plugged In */, - 0xFF /* Unused */, 0xFF /* Unused */, 0xFF /* Unused */, 0xFF /* Unused */, + 0xFF /* Unused */, + SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, + SDL_CONTROLLER_BUTTON_START, + SDL_CONTROLLER_BUTTON_GUIDE, + SDL_CONTROLLER_BUTTON_BACK, + SDL_CONTROLLER_BUTTON_LEFTSHOULDER, + SDL_CONTROLLER_BUTTON_DPAD_DOWN, + SDL_CONTROLLER_BUTTON_DPAD_RIGHT, + }, + { + 0xFF /* Motion Plus data */, + 0xFF /* Motion Plus data */, + 0xFF /* ZR */, + SDL_CONTROLLER_BUTTON_X, + SDL_CONTROLLER_BUTTON_A, + SDL_CONTROLLER_BUTTON_Y, + SDL_CONTROLLER_BUTTON_B, + 0xFF /*ZL*/, + }, + { + SDL_CONTROLLER_BUTTON_RIGHTSTICK, + SDL_CONTROLLER_BUTTON_LEFTSTICK, + 0xFF /* Charging */, + 0xFF /* Plugged In */, + 0xFF /* Unused */, + 0xFF /* Unused */, + 0xFF /* Unused */, + 0xFF /* Unused */, } }; static const Uint8 MP_GAMEPAD_BUTTON_DEFS_POSITIONAL[3][8] = { { - 0xFF /* Unused */, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, SDL_CONTROLLER_BUTTON_START, SDL_CONTROLLER_BUTTON_GUIDE, - SDL_CONTROLLER_BUTTON_BACK, SDL_CONTROLLER_BUTTON_LEFTSHOULDER, SDL_CONTROLLER_BUTTON_DPAD_DOWN, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, - }, { - 0xFF /* Motion Plus data */, 0xFF /* Motion Plus data */, 0xFF /* ZR */, SDL_CONTROLLER_BUTTON_Y, - SDL_CONTROLLER_BUTTON_B, SDL_CONTROLLER_BUTTON_X, SDL_CONTROLLER_BUTTON_A, 0xFF /*ZL*/, - }, { - SDL_CONTROLLER_BUTTON_RIGHTSTICK, SDL_CONTROLLER_BUTTON_LEFTSTICK, 0xFF /* Charging */, 0xFF /* Plugged In */, - 0xFF /* Unused */, 0xFF /* Unused */, 0xFF /* Unused */, 0xFF /* Unused */, + 0xFF /* Unused */, + SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, + SDL_CONTROLLER_BUTTON_START, + SDL_CONTROLLER_BUTTON_GUIDE, + SDL_CONTROLLER_BUTTON_BACK, + SDL_CONTROLLER_BUTTON_LEFTSHOULDER, + SDL_CONTROLLER_BUTTON_DPAD_DOWN, + SDL_CONTROLLER_BUTTON_DPAD_RIGHT, + }, + { + 0xFF /* Motion Plus data */, + 0xFF /* Motion Plus data */, + 0xFF /* ZR */, + SDL_CONTROLLER_BUTTON_Y, + SDL_CONTROLLER_BUTTON_B, + SDL_CONTROLLER_BUTTON_X, + SDL_CONTROLLER_BUTTON_A, + 0xFF /*ZL*/, + }, + { + SDL_CONTROLLER_BUTTON_RIGHTSTICK, + SDL_CONTROLLER_BUTTON_LEFTSTICK, + 0xFF /* Charging */, + 0xFF /* Plugged In */, + 0xFF /* Unused */, + 0xFF /* Unused */, + 0xFF /* Unused */, + 0xFF /* Unused */, } }; static const Uint8 MP_FIXUP_DPAD_BUTTON_DEFS[2][8] = { { - SDL_CONTROLLER_BUTTON_DPAD_UP, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - }, { - SDL_CONTROLLER_BUTTON_DPAD_LEFT, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, + SDL_CONTROLLER_BUTTON_DPAD_UP, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + }, + { + SDL_CONTROLLER_BUTTON_DPAD_LEFT, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, } }; static void HandleWiiUProButtonData(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick, const WiiButtonData *data) { static const Uint8 axes[] = { SDL_CONTROLLER_AXIS_LEFTX, SDL_CONTROLLER_AXIS_RIGHTX, SDL_CONTROLLER_AXIS_LEFTY, SDL_CONTROLLER_AXIS_RIGHTY }; - const Uint8 (*buttons)[8] = ctx->m_bUseButtonLabels ? GAMEPAD_BUTTON_DEFS : GAMEPAD_BUTTON_DEFS_POSITIONAL; + const Uint8(*buttons)[8] = ctx->m_bUseButtonLabels ? GAMEPAD_BUTTON_DEFS : GAMEPAD_BUTTON_DEFS_POSITIONAL; Uint8 zl, zr; int i; @@ -1020,7 +1103,7 @@ static void HandleWiiUProButtonData(SDL_DriverWii_Context *ctx, SDL_Joystick *jo /* Triggers */ zl = data->rgucExtension[9] & 0x80; zr = data->rgucExtension[9] & 0x04; - SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, zl ? SDL_JOYSTICK_AXIS_MIN : SDL_JOYSTICK_AXIS_MAX); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, zl ? SDL_JOYSTICK_AXIS_MIN : SDL_JOYSTICK_AXIS_MAX); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, zr ? SDL_JOYSTICK_AXIS_MIN : SDL_JOYSTICK_AXIS_MAX); /* Sticks */ @@ -1035,9 +1118,7 @@ static void HandleWiiUProButtonData(SDL_DriverWii_Context *ctx, SDL_Joystick *jo static void HandleGamepadControllerButtonData(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick, const WiiButtonData *data) { - const Uint8 (*buttons)[8] = ctx->m_bUseButtonLabels ? - ((ctx->m_ucMotionPlusMode == WII_MOTIONPLUS_MODE_GAMEPAD) ? MP_GAMEPAD_BUTTON_DEFS : GAMEPAD_BUTTON_DEFS) : - ((ctx->m_ucMotionPlusMode == WII_MOTIONPLUS_MODE_GAMEPAD) ? MP_GAMEPAD_BUTTON_DEFS_POSITIONAL : GAMEPAD_BUTTON_DEFS_POSITIONAL); + const Uint8(*buttons)[8] = ctx->m_bUseButtonLabels ? ((ctx->m_ucMotionPlusMode == WII_MOTIONPLUS_MODE_GAMEPAD) ? MP_GAMEPAD_BUTTON_DEFS : GAMEPAD_BUTTON_DEFS) : ((ctx->m_ucMotionPlusMode == WII_MOTIONPLUS_MODE_GAMEPAD) ? MP_GAMEPAD_BUTTON_DEFS_POSITIONAL : GAMEPAD_BUTTON_DEFS_POSITIONAL); Uint8 lx, ly, rx, ry, zl, zr; if (data->ucNExtensionBytes < 6) { @@ -1053,7 +1134,7 @@ static void HandleGamepadControllerButtonData(SDL_DriverWii_Context *ctx, SDL_Jo /* Triggers */ zl = data->rgucExtension[5] & 0x80; zr = data->rgucExtension[5] & 0x04; - SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, zl ? SDL_JOYSTICK_AXIS_MIN : SDL_JOYSTICK_AXIS_MAX); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, zl ? SDL_JOYSTICK_AXIS_MIN : SDL_JOYSTICK_AXIS_MAX); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, zr ? SDL_JOYSTICK_AXIS_MIN : SDL_JOYSTICK_AXIS_MAX); /* Sticks */ @@ -1076,11 +1157,24 @@ static void HandleWiiRemoteButtonData(SDL_DriverWii_Context *ctx, SDL_Joystick * { static const Uint8 buttons[2][8] = { { - k_eWiiButtons_DPad_Left, k_eWiiButtons_DPad_Right, k_eWiiButtons_DPad_Down, k_eWiiButtons_DPad_Up, - k_eWiiButtons_Plus, 0xFF /* Unused */, 0xFF /* Unused */, 0xFF /* Unused */, - }, { - k_eWiiButtons_Two, k_eWiiButtons_One, k_eWiiButtons_B, k_eWiiButtons_A, - k_eWiiButtons_Minus, 0xFF /* Unused */, 0xFF /* Unused */, k_eWiiButtons_Home, + k_eWiiButtons_DPad_Left, + k_eWiiButtons_DPad_Right, + k_eWiiButtons_DPad_Down, + k_eWiiButtons_DPad_Up, + k_eWiiButtons_Plus, + 0xFF /* Unused */, + 0xFF /* Unused */, + 0xFF /* Unused */, + }, + { + k_eWiiButtons_Two, + k_eWiiButtons_One, + k_eWiiButtons_B, + k_eWiiButtons_A, + k_eWiiButtons_Minus, + 0xFF /* Unused */, + 0xFF /* Unused */, + k_eWiiButtons_Home, } }; if (data->hasBaseButtons) { @@ -1096,11 +1190,24 @@ static void HandleWiiRemoteButtonDataAsMainController(SDL_DriverWii_Context *ctx */ static const Uint8 buttons[2][8] = { { - SDL_CONTROLLER_BUTTON_DPAD_LEFT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_DOWN, SDL_CONTROLLER_BUTTON_DPAD_UP, - SDL_CONTROLLER_BUTTON_START, 0xFF /* Unused */, 0xFF /* Unused */, 0xFF /* Unused */, - }, { - SDL_CONTROLLER_BUTTON_Y, SDL_CONTROLLER_BUTTON_X, SDL_CONTROLLER_BUTTON_A, SDL_CONTROLLER_BUTTON_B, - SDL_CONTROLLER_BUTTON_BACK, 0xFF /* Unused */, 0xFF /* Unused */, SDL_CONTROLLER_BUTTON_GUIDE, + SDL_CONTROLLER_BUTTON_DPAD_LEFT, + SDL_CONTROLLER_BUTTON_DPAD_RIGHT, + SDL_CONTROLLER_BUTTON_DPAD_DOWN, + SDL_CONTROLLER_BUTTON_DPAD_UP, + SDL_CONTROLLER_BUTTON_START, + 0xFF /* Unused */, + 0xFF /* Unused */, + 0xFF /* Unused */, + }, + { + SDL_CONTROLLER_BUTTON_Y, + SDL_CONTROLLER_BUTTON_X, + SDL_CONTROLLER_BUTTON_A, + SDL_CONTROLLER_BUTTON_B, + SDL_CONTROLLER_BUTTON_BACK, + 0xFF /* Unused */, + 0xFF /* Unused */, + SDL_CONTROLLER_BUTTON_GUIDE, } }; if (data->hasBaseButtons) { @@ -1355,38 +1462,37 @@ static void HandleResponse(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick) case k_eWiiCommunicationState_CheckMotionPlusStage1: case k_eWiiCommunicationState_CheckMotionPlusStage2: - { - Uint16 extension = 0; - if (ParseExtensionIdentifyResponse(ctx, &extension)) { - if ((extension & WII_EXTENSION_MOTIONPLUS_MASK) == WII_EXTENSION_MOTIONPLUS_ID) { - /* Motion Plus is currently active */ - SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "HIDAPI Wii: Motion Plus CONNECTED (stage %d)\n", ctx->m_eCommState == k_eWiiCommunicationState_CheckMotionPlusStage1 ? 1 : 2); + { + Uint16 extension = 0; + if (ParseExtensionIdentifyResponse(ctx, &extension)) { + if ((extension & WII_EXTENSION_MOTIONPLUS_MASK) == WII_EXTENSION_MOTIONPLUS_ID) { + /* Motion Plus is currently active */ + SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "HIDAPI Wii: Motion Plus CONNECTED (stage %d)\n", ctx->m_eCommState == k_eWiiCommunicationState_CheckMotionPlusStage1 ? 1 : 2); - if (!ctx->m_bMotionPlusPresent) { - /* Reinitialize to get new sensor availability */ - ctx->m_bDisconnected = SDL_TRUE; - } - ctx->m_eCommState = k_eWiiCommunicationState_None; - - } else if (ctx->m_eCommState == k_eWiiCommunicationState_CheckMotionPlusStage1) { - /* Check to see if Motion Plus is present */ - ReadRegister(ctx, 0xA600FE, 2, SDL_FALSE); - - ctx->m_eCommState = k_eWiiCommunicationState_CheckMotionPlusStage2; - - } else { - /* Motion Plus is not present */ - SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "HIDAPI Wii: Motion Plus DISCONNECTED (stage %d)\n", ctx->m_eCommState == k_eWiiCommunicationState_CheckMotionPlusStage1 ? 1 : 2); - - if (ctx->m_bMotionPlusPresent) { - /* Reinitialize to get new sensor availability */ - ctx->m_bDisconnected = SDL_TRUE; - } - ctx->m_eCommState = k_eWiiCommunicationState_None; + if (!ctx->m_bMotionPlusPresent) { + /* Reinitialize to get new sensor availability */ + ctx->m_bDisconnected = SDL_TRUE; } + ctx->m_eCommState = k_eWiiCommunicationState_None; + + } else if (ctx->m_eCommState == k_eWiiCommunicationState_CheckMotionPlusStage1) { + /* Check to see if Motion Plus is present */ + ReadRegister(ctx, 0xA600FE, 2, SDL_FALSE); + + ctx->m_eCommState = k_eWiiCommunicationState_CheckMotionPlusStage2; + + } else { + /* Motion Plus is not present */ + SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "HIDAPI Wii: Motion Plus DISCONNECTED (stage %d)\n", ctx->m_eCommState == k_eWiiCommunicationState_CheckMotionPlusStage1 ? 1 : 2); + + if (ctx->m_bMotionPlusPresent) { + /* Reinitialize to get new sensor availability */ + ctx->m_bDisconnected = SDL_TRUE; + } + ctx->m_eCommState = k_eWiiCommunicationState_None; } } - break; + } break; default: /* Should never happen */ break; @@ -1407,43 +1513,43 @@ static void HandleButtonPacket(SDL_DriverWii_Context *ctx, SDL_Joystick *joystic /* IR camera data is not supported */ SDL_zero(data); switch (ctx->m_rgucReadBuffer[0]) { - case k_eWiiInputReportIDs_ButtonData0: /* 30 BB BB */ - GetBaseButtons(&data, ctx->m_rgucReadBuffer + 1); - break; - case k_eWiiInputReportIDs_ButtonData1: /* 31 BB BB AA AA AA */ - case k_eWiiInputReportIDs_ButtonData3: /* 33 BB BB AA AA AA II II II II II II II II II II II II */ - GetBaseButtons (&data, ctx->m_rgucReadBuffer + 1); - GetAccelerometer(&data, ctx->m_rgucReadBuffer + 3); - break; - case k_eWiiInputReportIDs_ButtonData2: /* 32 BB BB EE EE EE EE EE EE EE EE */ - GetBaseButtons (&data, ctx->m_rgucReadBuffer + 1); - GetExtensionData(&data, ctx->m_rgucReadBuffer + 3, 8); - break; - case k_eWiiInputReportIDs_ButtonData4: /* 34 BB BB EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE */ - GetBaseButtons (&data, ctx->m_rgucReadBuffer + 1); - GetExtensionData(&data, ctx->m_rgucReadBuffer + 3, 19); - break; - case k_eWiiInputReportIDs_ButtonData5: /* 35 BB BB AA AA AA EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE */ - GetBaseButtons (&data, ctx->m_rgucReadBuffer + 1); - GetAccelerometer(&data, ctx->m_rgucReadBuffer + 3); - GetExtensionData(&data, ctx->m_rgucReadBuffer + 6, 16); - break; - case k_eWiiInputReportIDs_ButtonData6: /* 36 BB BB II II II II II II II II II II EE EE EE EE EE EE EE EE EE */ - GetBaseButtons (&data, ctx->m_rgucReadBuffer + 1); - GetExtensionData(&data, ctx->m_rgucReadBuffer + 13, 9); - break; - case k_eWiiInputReportIDs_ButtonData7: /* 37 BB BB AA AA AA II II II II II II II II II II EE EE EE EE EE EE */ - GetBaseButtons (&data, ctx->m_rgucReadBuffer + 1); - GetExtensionData(&data, ctx->m_rgucReadBuffer + 16, 6); - break; - case k_eWiiInputReportIDs_ButtonDataD: /* 3d EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE */ - GetExtensionData(&data, ctx->m_rgucReadBuffer + 1, 21); - break; - case k_eWiiInputReportIDs_ButtonDataE: - case k_eWiiInputReportIDs_ButtonDataF: - default: - SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "HIDAPI Wii: Unsupported button data type %02x", ctx->m_rgucReadBuffer[0]); - return; + case k_eWiiInputReportIDs_ButtonData0: /* 30 BB BB */ + GetBaseButtons(&data, ctx->m_rgucReadBuffer + 1); + break; + case k_eWiiInputReportIDs_ButtonData1: /* 31 BB BB AA AA AA */ + case k_eWiiInputReportIDs_ButtonData3: /* 33 BB BB AA AA AA II II II II II II II II II II II II */ + GetBaseButtons(&data, ctx->m_rgucReadBuffer + 1); + GetAccelerometer(&data, ctx->m_rgucReadBuffer + 3); + break; + case k_eWiiInputReportIDs_ButtonData2: /* 32 BB BB EE EE EE EE EE EE EE EE */ + GetBaseButtons(&data, ctx->m_rgucReadBuffer + 1); + GetExtensionData(&data, ctx->m_rgucReadBuffer + 3, 8); + break; + case k_eWiiInputReportIDs_ButtonData4: /* 34 BB BB EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE */ + GetBaseButtons(&data, ctx->m_rgucReadBuffer + 1); + GetExtensionData(&data, ctx->m_rgucReadBuffer + 3, 19); + break; + case k_eWiiInputReportIDs_ButtonData5: /* 35 BB BB AA AA AA EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE */ + GetBaseButtons(&data, ctx->m_rgucReadBuffer + 1); + GetAccelerometer(&data, ctx->m_rgucReadBuffer + 3); + GetExtensionData(&data, ctx->m_rgucReadBuffer + 6, 16); + break; + case k_eWiiInputReportIDs_ButtonData6: /* 36 BB BB II II II II II II II II II II EE EE EE EE EE EE EE EE EE */ + GetBaseButtons(&data, ctx->m_rgucReadBuffer + 1); + GetExtensionData(&data, ctx->m_rgucReadBuffer + 13, 9); + break; + case k_eWiiInputReportIDs_ButtonData7: /* 37 BB BB AA AA AA II II II II II II II II II II EE EE EE EE EE EE */ + GetBaseButtons(&data, ctx->m_rgucReadBuffer + 1); + GetExtensionData(&data, ctx->m_rgucReadBuffer + 16, 6); + break; + case k_eWiiInputReportIDs_ButtonDataD: /* 3d EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE */ + GetExtensionData(&data, ctx->m_rgucReadBuffer + 1, 21); + break; + case k_eWiiInputReportIDs_ButtonDataE: + case k_eWiiInputReportIDs_ButtonDataF: + default: + SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "HIDAPI Wii: Unsupported button data type %02x", ctx->m_rgucReadBuffer[0]); + return; } HandleButtonData(ctx, joystick, &data); } @@ -1462,8 +1568,7 @@ static void HandleInput(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick) } } -static SDL_bool -HIDAPI_DriverWii_UpdateDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverWii_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverWii_Context *ctx = (SDL_DriverWii_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -1532,8 +1637,7 @@ HIDAPI_DriverWii_UpdateDevice(SDL_HIDAPI_Device *device) return size >= 0; } -static void -HIDAPI_DriverWii_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static void HIDAPI_DriverWii_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverWii_Context *ctx = (SDL_DriverWii_Context *)device->context; @@ -1546,13 +1650,11 @@ HIDAPI_DriverWii_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick ctx->joystick = NULL; } -static void -HIDAPI_DriverWii_FreeDevice(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverWii_FreeDevice(SDL_HIDAPI_Device *device) { } -SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverWii = -{ +SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverWii = { SDL_HINT_JOYSTICK_HIDAPI_WII, SDL_TRUE, HIDAPI_DriverWii_RegisterHints, diff --git a/src/joystick/hidapi/SDL_hidapi_xbox360.c b/src/joystick/hidapi/SDL_hidapi_xbox360.c index ddc53a3bb..df618df96 100644 --- a/src/joystick/hidapi/SDL_hidapi_xbox360.c +++ b/src/joystick/hidapi/SDL_hidapi_xbox360.c @@ -31,14 +31,13 @@ #include "SDL_hidapijoystick_c.h" #include "SDL_hidapi_rumble.h" - #ifdef SDL_JOYSTICK_HIDAPI_XBOX360 /* Define this if you want to log all packets from the controller */ /*#define DEBUG_XBOX_PROTOCOL*/ - -typedef struct { +typedef struct +{ SDL_HIDAPI_Device *device; SDL_Joystick *joystick; int player_index; @@ -46,29 +45,25 @@ typedef struct { Uint8 last_state[USB_PACKET_LENGTH]; } SDL_DriverXbox360_Context; -static void -HIDAPI_DriverXbox360_RegisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverXbox360_RegisterHints(SDL_HintCallback callback, void *userdata) { SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX, callback, userdata); SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360, callback, userdata); } -static void -HIDAPI_DriverXbox360_UnregisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverXbox360_UnregisterHints(SDL_HintCallback callback, void *userdata) { SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX, callback, userdata); SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360, callback, userdata); } -static SDL_bool -HIDAPI_DriverXbox360_IsEnabled(void) +static SDL_bool HIDAPI_DriverXbox360_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT))); } -static SDL_bool -HIDAPI_DriverXbox360_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static SDL_bool HIDAPI_DriverXbox360_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { const int XB360W_IFACE_PROTOCOL = 129; /* Wireless */ @@ -141,8 +136,7 @@ static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, c } } -static SDL_bool -HIDAPI_DriverXbox360_InitDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverXbox360_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverXbox360_Context *ctx; @@ -160,14 +154,12 @@ HIDAPI_DriverXbox360_InitDevice(SDL_HIDAPI_Device *device) return HIDAPI_JoystickConnected(device, NULL); } -static int -HIDAPI_DriverXbox360_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) +static int HIDAPI_DriverXbox360_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) { return -1; } -static void -HIDAPI_DriverXbox360_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) +static void HIDAPI_DriverXbox360_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) { SDL_DriverXbox360_Context *ctx = (SDL_DriverXbox360_Context *)device->context; @@ -180,8 +172,7 @@ HIDAPI_DriverXbox360_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_Joystic UpdateSlotLED(ctx); } -static SDL_bool -HIDAPI_DriverXbox360_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static SDL_bool HIDAPI_DriverXbox360_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverXbox360_Context *ctx = (SDL_DriverXbox360_Context *)device->context; @@ -204,8 +195,7 @@ HIDAPI_DriverXbox360_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joyst return SDL_TRUE; } -static int -HIDAPI_DriverXbox360_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int HIDAPI_DriverXbox360_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { #ifdef __MACOSX__ if (SDL_IsJoystickBluetoothXboxOne(device->vendor_id, device->product_id)) { @@ -223,8 +213,8 @@ HIDAPI_DriverXbox360_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joy */ Uint8 rumble_packet[] = { 'M', 'A', 'G', 'I', 'C', '0', 0x00, 0x04, 0x00, 0x00 }; - rumble_packet[6+2] = (low_frequency_rumble >> 8); - rumble_packet[6+3] = (high_frequency_rumble >> 8); + rumble_packet[6 + 2] = (low_frequency_rumble >> 8); + rumble_packet[6 + 3] = (high_frequency_rumble >> 8); if (SDL_HIDAPI_SendRumble(device, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) { return SDL_SetError("Couldn't send rumble packet"); @@ -243,39 +233,33 @@ HIDAPI_DriverXbox360_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joy return 0; } -static int -HIDAPI_DriverXbox360_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int HIDAPI_DriverXbox360_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static Uint32 -HIDAPI_DriverXbox360_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static Uint32 HIDAPI_DriverXbox360_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { /* Doesn't have an RGB LED, so don't return SDL_JOYCAP_LED here */ return SDL_JOYCAP_RUMBLE; } -static int -HIDAPI_DriverXbox360_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int HIDAPI_DriverXbox360_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -HIDAPI_DriverXbox360_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) +static int HIDAPI_DriverXbox360_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -HIDAPI_DriverXbox360_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverXbox360_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } -static void -HIDAPI_DriverXbox360_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXbox360_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverXbox360_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXbox360_Context *ctx, Uint8 *data, int size) { Sint16 axis; #ifdef __MACOSX__ @@ -309,16 +293,16 @@ HIDAPI_DriverXbox360_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXbox360 SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis); axis = ((int)data[5] * 257) - 32768; SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, axis); - axis = SDL_SwapLE16(*(Sint16*)(&data[6])); + axis = SDL_SwapLE16(*(Sint16 *)(&data[6])); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis); - axis = SDL_SwapLE16(*(Sint16*)(&data[8])); + axis = SDL_SwapLE16(*(Sint16 *)(&data[8])); if (invert_y_axes) { axis = ~axis; } SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY, axis); - axis = SDL_SwapLE16(*(Sint16*)(&data[10])); + axis = SDL_SwapLE16(*(Sint16 *)(&data[10])); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTX, axis); - axis = SDL_SwapLE16(*(Sint16*)(&data[12])); + axis = SDL_SwapLE16(*(Sint16 *)(&data[12])); if (invert_y_axes) { axis = ~axis; } @@ -327,8 +311,7 @@ HIDAPI_DriverXbox360_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXbox360 SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); } -static SDL_bool -HIDAPI_DriverXbox360_UpdateDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverXbox360_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverXbox360_Context *ctx = (SDL_DriverXbox360_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -361,8 +344,7 @@ HIDAPI_DriverXbox360_UpdateDevice(SDL_HIDAPI_Device *device) return size >= 0; } -static void -HIDAPI_DriverXbox360_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static void HIDAPI_DriverXbox360_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverXbox360_Context *ctx = (SDL_DriverXbox360_Context *)device->context; @@ -372,13 +354,11 @@ HIDAPI_DriverXbox360_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joys ctx->joystick = NULL; } -static void -HIDAPI_DriverXbox360_FreeDevice(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverXbox360_FreeDevice(SDL_HIDAPI_Device *device) { } -SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360 = -{ +SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360 = { SDL_HINT_JOYSTICK_HIDAPI_XBOX_360, SDL_TRUE, HIDAPI_DriverXbox360_RegisterHints, diff --git a/src/joystick/hidapi/SDL_hidapi_xbox360w.c b/src/joystick/hidapi/SDL_hidapi_xbox360w.c index 5c1d8bd7f..10309f09c 100644 --- a/src/joystick/hidapi/SDL_hidapi_xbox360w.c +++ b/src/joystick/hidapi/SDL_hidapi_xbox360w.c @@ -31,14 +31,13 @@ #include "SDL_hidapijoystick_c.h" #include "SDL_hidapi_rumble.h" - #ifdef SDL_JOYSTICK_HIDAPI_XBOX360 /* Define this if you want to log all packets from the controller */ /*#define DEBUG_XBOX_PROTOCOL*/ - -typedef struct { +typedef struct +{ SDL_HIDAPI_Device *device; SDL_bool connected; int player_index; @@ -46,32 +45,27 @@ typedef struct { Uint8 last_state[USB_PACKET_LENGTH]; } SDL_DriverXbox360W_Context; - -static void -HIDAPI_DriverXbox360W_RegisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverXbox360W_RegisterHints(SDL_HintCallback callback, void *userdata) { SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX, callback, userdata); SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360, callback, userdata); SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_WIRELESS, callback, userdata); } -static void -HIDAPI_DriverXbox360W_UnregisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverXbox360W_UnregisterHints(SDL_HintCallback callback, void *userdata) { SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX, callback, userdata); SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360, callback, userdata); SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_WIRELESS, callback, userdata); } -static SDL_bool -HIDAPI_DriverXbox360W_IsEnabled(void) +static SDL_bool HIDAPI_DriverXbox360W_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_WIRELESS, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)))); } -static SDL_bool -HIDAPI_DriverXbox360W_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static SDL_bool HIDAPI_DriverXbox360W_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { const int XB360W_IFACE_PROTOCOL = 129; /* Wireless */ @@ -116,8 +110,7 @@ static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, c } } -static void -UpdatePowerLevel(SDL_Joystick *joystick, Uint8 level) +static void UpdatePowerLevel(SDL_Joystick *joystick, Uint8 level) { float normalized_level = (float)level / 255.0f; @@ -132,8 +125,7 @@ UpdatePowerLevel(SDL_Joystick *joystick, Uint8 level) } } -static SDL_bool -HIDAPI_DriverXbox360W_InitDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverXbox360W_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverXbox360W_Context *ctx; @@ -161,14 +153,12 @@ HIDAPI_DriverXbox360W_InitDevice(SDL_HIDAPI_Device *device) return SDL_TRUE; } -static int -HIDAPI_DriverXbox360W_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) +static int HIDAPI_DriverXbox360W_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) { return -1; } -static void -HIDAPI_DriverXbox360W_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) +static void HIDAPI_DriverXbox360W_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) { SDL_DriverXbox360W_Context *ctx = (SDL_DriverXbox360W_Context *)device->context; @@ -181,8 +171,7 @@ HIDAPI_DriverXbox360W_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_Joysti UpdateSlotLED(ctx); } -static SDL_bool -HIDAPI_DriverXbox360W_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static SDL_bool HIDAPI_DriverXbox360W_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverXbox360W_Context *ctx = (SDL_DriverXbox360W_Context *)device->context; @@ -204,8 +193,7 @@ HIDAPI_DriverXbox360W_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joys return SDL_TRUE; } -static int -HIDAPI_DriverXbox360W_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int HIDAPI_DriverXbox360W_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { Uint8 rumble_packet[] = { 0x00, 0x01, 0x0f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; @@ -218,39 +206,33 @@ HIDAPI_DriverXbox360W_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *jo return 0; } -static int -HIDAPI_DriverXbox360W_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int HIDAPI_DriverXbox360W_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static Uint32 -HIDAPI_DriverXbox360W_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static Uint32 HIDAPI_DriverXbox360W_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { /* Doesn't have an RGB LED, so don't return SDL_JOYCAP_LED here */ return SDL_JOYCAP_RUMBLE; } -static int -HIDAPI_DriverXbox360W_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int HIDAPI_DriverXbox360W_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -HIDAPI_DriverXbox360W_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) +static int HIDAPI_DriverXbox360W_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -HIDAPI_DriverXbox360W_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverXbox360W_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } -static void -HIDAPI_DriverXbox360W_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_device *dev, SDL_DriverXbox360W_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverXbox360W_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_device *dev, SDL_DriverXbox360W_Context *ctx, Uint8 *data, int size) { Sint16 axis; const SDL_bool invert_y_axes = SDL_TRUE; @@ -280,16 +262,16 @@ HIDAPI_DriverXbox360W_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_device * SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis); axis = ((int)data[5] * 257) - 32768; SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, axis); - axis = SDL_SwapLE16(*(Sint16*)(&data[6])); + axis = SDL_SwapLE16(*(Sint16 *)(&data[6])); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis); - axis = SDL_SwapLE16(*(Sint16*)(&data[8])); + axis = SDL_SwapLE16(*(Sint16 *)(&data[8])); if (invert_y_axes) { axis = ~axis; } SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY, axis); - axis = SDL_SwapLE16(*(Sint16*)(&data[10])); + axis = SDL_SwapLE16(*(Sint16 *)(&data[10])); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTX, axis); - axis = SDL_SwapLE16(*(Sint16*)(&data[12])); + axis = SDL_SwapLE16(*(Sint16 *)(&data[12])); if (invert_y_axes) { axis = ~axis; } @@ -298,8 +280,7 @@ HIDAPI_DriverXbox360W_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_device * SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); } -static SDL_bool -HIDAPI_DriverXbox360W_UpdateDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverXbox360W_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverXbox360W_Context *ctx = (SDL_DriverXbox360W_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -348,7 +329,7 @@ HIDAPI_DriverXbox360W_UpdateDevice(SDL_HIDAPI_Device *device) } } else if (size == 29 && data[0] == 0x00 && (data[1] & 0x01) == 0x01) { if (joystick) { - HIDAPI_DriverXbox360W_HandleStatePacket(joystick, device->dev, ctx, data+4, size-4); + HIDAPI_DriverXbox360W_HandleStatePacket(joystick, device->dev, ctx, data + 4, size - 4); } } } @@ -360,8 +341,7 @@ HIDAPI_DriverXbox360W_UpdateDevice(SDL_HIDAPI_Device *device) return size >= 0; } -static void -HIDAPI_DriverXbox360W_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static void HIDAPI_DriverXbox360W_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverXbox360W_Context *ctx = (SDL_DriverXbox360W_Context *)device->context; @@ -369,13 +349,11 @@ HIDAPI_DriverXbox360W_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joy SDL_PlayerLEDHintChanged, ctx); } -static void -HIDAPI_DriverXbox360W_FreeDevice(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverXbox360W_FreeDevice(SDL_HIDAPI_Device *device) { } -SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360W = -{ +SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360W = { SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_WIRELESS, SDL_TRUE, HIDAPI_DriverXbox360W_RegisterHints, diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c index 6e58fe975..7e19417d2 100644 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c @@ -31,7 +31,6 @@ #include "SDL_hidapijoystick_c.h" #include "SDL_hidapi_rumble.h" - #ifdef SDL_JOYSTICK_HIDAPI_XBOXONE /* Define this if you want verbose logging of the init sequence */ @@ -77,7 +76,8 @@ static const Uint8 security_passed_packet[] = { * sent. The correct sequence number will be added when the * packet is going to be sent. */ -typedef struct { +typedef struct +{ Uint16 vendor_id; Uint16 product_id; Uint16 exclude_vendor_id; @@ -87,7 +87,6 @@ typedef struct { const Uint8 response[2]; } SDL_DriverXboxOne_InitPacket; - static const SDL_DriverXboxOne_InitPacket xboxone_init_packets[] = { { 0x0000, 0x0000, 0x0000, 0x0000, xboxone_init0, sizeof(xboxone_init0), { 0x00, 0x00 } }, { 0x0000, 0x0000, 0x0000, 0x0000, xboxone_init1, sizeof(xboxone_init1), { 0x00, 0x00 } }, @@ -99,20 +98,23 @@ static const SDL_DriverXboxOne_InitPacket xboxone_init_packets[] = { { 0x0000, 0x0000, 0x0000, 0x0000, xboxone_init2, sizeof(xboxone_init2), { 0x00, 0x00 } }, }; -typedef enum { +typedef enum +{ XBOX_ONE_INIT_STATE_START_NEGOTIATING, XBOX_ONE_INIT_STATE_NEGOTIATING, XBOX_ONE_INIT_STATE_PREPARE_INPUT, XBOX_ONE_INIT_STATE_COMPLETE, } SDL_XboxOneInitState; -typedef enum { +typedef enum +{ XBOX_ONE_RUMBLE_STATE_IDLE, XBOX_ONE_RUMBLE_STATE_QUEUED, XBOX_ONE_RUMBLE_STATE_BUSY } SDL_XboxOneRumbleState; -typedef struct { +typedef struct +{ SDL_HIDAPI_Device *device; Uint16 vendor_id; Uint16 product_id; @@ -139,20 +141,17 @@ typedef struct { Uint8 last_state[USB_PACKET_LENGTH]; } SDL_DriverXboxOne_Context; -static SDL_bool -ControllerHasColorLED(Uint16 vendor_id, Uint16 product_id) +static SDL_bool ControllerHasColorLED(Uint16 vendor_id, Uint16 product_id) { return vendor_id == USB_VENDOR_MICROSOFT && product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2; } -static SDL_bool -ControllerHasPaddles(Uint16 vendor_id, Uint16 product_id) +static SDL_bool ControllerHasPaddles(Uint16 vendor_id, Uint16 product_id) { return SDL_IsJoystickXboxOneElite(vendor_id, product_id); } -static SDL_bool -ControllerHasTriggerRumble(Uint16 vendor_id, Uint16 product_id) +static SDL_bool ControllerHasTriggerRumble(Uint16 vendor_id, Uint16 product_id) { /* All the Microsoft Xbox One controllers have trigger rumble */ if (vendor_id == USB_VENDOR_MICROSOFT) { @@ -167,8 +166,7 @@ ControllerHasTriggerRumble(Uint16 vendor_id, Uint16 product_id) return SDL_FALSE; } -static SDL_bool -ControllerHasShareButton(Uint16 vendor_id, Uint16 product_id) +static SDL_bool ControllerHasShareButton(Uint16 vendor_id, Uint16 product_id) { return SDL_IsJoystickXboxSeriesX(vendor_id, product_id); } @@ -208,8 +206,7 @@ static void SDLCALL SDL_HomeLEDHintChanged(void *userdata, const char *name, con } } -static void -SetInitState(SDL_DriverXboxOne_Context *ctx, SDL_XboxOneInitState state) +static void SetInitState(SDL_DriverXboxOne_Context *ctx, SDL_XboxOneInitState state) { #ifdef DEBUG_JOYSTICK SDL_Log("Setting init state %d\n", state); @@ -217,8 +214,7 @@ SetInitState(SDL_DriverXboxOne_Context *ctx, SDL_XboxOneInitState state) ctx->init_state = state; } -static void -SendAckIfNeeded(SDL_HIDAPI_Device *device, Uint8 *data, int size) +static void SendAckIfNeeded(SDL_HIDAPI_Device *device, Uint8 *data, int size) { #if defined(__WIN32__) || defined(__WINGDK__) /* The Windows driver is taking care of acks */ @@ -247,8 +243,7 @@ SendAckIfNeeded(SDL_HIDAPI_Device *device, Uint8 *data, int size) } #if 0 -static SDL_bool -SendSerialRequest(SDL_HIDAPI_Device *device, SDL_DriverXboxOne_Context *ctx) +static SDL_bool SendSerialRequest(SDL_HIDAPI_Device *device, SDL_DriverXboxOne_Context *ctx) { Uint8 serial_packet[] = { 0x1E, 0x30, 0x07, 0x01, 0x04 }; @@ -268,8 +263,7 @@ SendSerialRequest(SDL_HIDAPI_Device *device, SDL_DriverXboxOne_Context *ctx) } #endif -static SDL_bool -ControllerNeedsNegotiation(SDL_DriverXboxOne_Context *ctx) +static SDL_bool ControllerNeedsNegotiation(SDL_DriverXboxOne_Context *ctx) { if (ctx->vendor_id == USB_VENDOR_PDP && ctx->product_id == 0x0246) { /* The PDP Rock Candy (PID 0x0246) doesn't send the announce packet on Linux for some reason */ @@ -278,14 +272,13 @@ ControllerNeedsNegotiation(SDL_DriverXboxOne_Context *ctx) return SDL_FALSE; } -static SDL_bool -SendControllerInit(SDL_HIDAPI_Device *device, SDL_DriverXboxOne_Context *ctx) +static SDL_bool SendControllerInit(SDL_HIDAPI_Device *device, SDL_DriverXboxOne_Context *ctx) { Uint16 vendor_id = ctx->vendor_id; Uint16 product_id = ctx->product_id; Uint8 init_packet[USB_PACKET_LENGTH]; - for ( ; ctx->init_packet < SDL_arraysize(xboxone_init_packets); ++ctx->init_packet) { + for (; ctx->init_packet < SDL_arraysize(xboxone_init_packets); ++ctx->init_packet) { const SDL_DriverXboxOne_InitPacket *packet = &xboxone_init_packets[ctx->init_packet]; if (packet->vendor_id && (vendor_id != packet->vendor_id)) { @@ -341,29 +334,25 @@ SendControllerInit(SDL_HIDAPI_Device *device, SDL_DriverXboxOne_Context *ctx) return SDL_TRUE; } -static void -HIDAPI_DriverXboxOne_RegisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverXboxOne_RegisterHints(SDL_HintCallback callback, void *userdata) { SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX, callback, userdata); SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE, callback, userdata); } -static void -HIDAPI_DriverXboxOne_UnregisterHints(SDL_HintCallback callback, void *userdata) +static void HIDAPI_DriverXboxOne_UnregisterHints(SDL_HintCallback callback, void *userdata) { SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX, callback, userdata); SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE, callback, userdata); } -static SDL_bool -HIDAPI_DriverXboxOne_IsEnabled(void) +static SDL_bool HIDAPI_DriverXboxOne_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT))); } -static SDL_bool -HIDAPI_DriverXboxOne_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static SDL_bool HIDAPI_DriverXboxOne_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { #ifdef __MACOSX__ /* Wired Xbox One controllers are handled by the 360Controller driver */ @@ -374,8 +363,7 @@ HIDAPI_DriverXboxOne_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *na return (type == SDL_CONTROLLER_TYPE_XBOXONE) ? SDL_TRUE : SDL_FALSE; } -static SDL_bool -HIDAPI_DriverXboxOne_InitDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverXboxOne_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverXboxOne_Context *ctx; @@ -414,19 +402,16 @@ HIDAPI_DriverXboxOne_InitDevice(SDL_HIDAPI_Device *device) return HIDAPI_JoystickConnected(device, NULL); } -static int -HIDAPI_DriverXboxOne_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) +static int HIDAPI_DriverXboxOne_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) { return -1; } -static void -HIDAPI_DriverXboxOne_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) +static void HIDAPI_DriverXboxOne_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) { } -static SDL_bool -HIDAPI_DriverXboxOne_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static SDL_bool HIDAPI_DriverXboxOne_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)device->context; @@ -458,15 +443,13 @@ HIDAPI_DriverXboxOne_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joyst return SDL_TRUE; } -static void -HIDAPI_DriverXboxOne_RumbleSent(void *userdata) +static void HIDAPI_DriverXboxOne_RumbleSent(void *userdata) { SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)userdata; ctx->rumble_time = SDL_GetTicks(); } -static int -HIDAPI_DriverXboxOne_UpdateRumble(SDL_HIDAPI_Device *device) +static int HIDAPI_DriverXboxOne_UpdateRumble(SDL_HIDAPI_Device *device) { SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)device->context; @@ -528,8 +511,7 @@ HIDAPI_DriverXboxOne_UpdateRumble(SDL_HIDAPI_Device *device) return 0; } -static int -HIDAPI_DriverXboxOne_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int HIDAPI_DriverXboxOne_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)device->context; @@ -541,8 +523,7 @@ HIDAPI_DriverXboxOne_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joy return HIDAPI_DriverXboxOne_UpdateRumble(device); } -static int -HIDAPI_DriverXboxOne_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int HIDAPI_DriverXboxOne_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)device->context; @@ -558,8 +539,7 @@ HIDAPI_DriverXboxOne_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joyst return HIDAPI_DriverXboxOne_UpdateRumble(device); } -static Uint32 -HIDAPI_DriverXboxOne_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static Uint32 HIDAPI_DriverXboxOne_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)device->context; Uint32 result = 0; @@ -576,8 +556,7 @@ HIDAPI_DriverXboxOne_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joys return result; } -static int -HIDAPI_DriverXboxOne_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int HIDAPI_DriverXboxOne_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)device->context; @@ -598,14 +577,12 @@ HIDAPI_DriverXboxOne_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joy } } -static int -HIDAPI_DriverXboxOne_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) +static int HIDAPI_DriverXboxOne_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -HIDAPI_DriverXboxOne_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverXboxOne_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } @@ -614,8 +591,7 @@ HIDAPI_DriverXboxOne_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Jo * The Xbox One Elite controller with 5.13+ firmware sends the unmapped state in a separate packet. * We can use this to send the paddle state when they aren't mapped */ -static void -HIDAPI_DriverXboxOne_HandleUnmappedStatePacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverXboxOne_HandleUnmappedStatePacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) { Uint8 profile; int paddle_index; @@ -650,12 +626,11 @@ HIDAPI_DriverXboxOne_HandleUnmappedStatePacket(SDL_Joystick *joystick, SDL_Drive } #ifdef DEBUG_XBOX_PROTOCOL SDL_Log(">>> Paddles: %d,%d,%d,%d mapped = %s\n", - (data[paddle_index] & button1_bit) ? 1 : 0, - (data[paddle_index] & button2_bit) ? 1 : 0, - (data[paddle_index] & button3_bit) ? 1 : 0, - (data[paddle_index] & button4_bit) ? 1 : 0, - paddles_mapped ? "TRUE" : "FALSE" - ); + (data[paddle_index] & button1_bit) ? 1 : 0, + (data[paddle_index] & button2_bit) ? 1 : 0, + (data[paddle_index] & button3_bit) ? 1 : 0, + (data[paddle_index] & button4_bit) ? 1 : 0, + paddles_mapped ? "TRUE" : "FALSE"); #endif if (paddles_mapped) { @@ -674,8 +649,7 @@ HIDAPI_DriverXboxOne_HandleUnmappedStatePacket(SDL_Joystick *joystick, SDL_Drive ctx->has_unmapped_state = SDL_TRUE; } -static void -HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) { Sint16 axis; @@ -768,7 +742,7 @@ HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXboxOne button4_bit = 0x08; paddles_mapped = (data[19] != 0); - } else /* if (size == 50) */{ + } else /* if (size == 50) */ { /* XBox One Elite Series 2 */ paddle_index = 22; button1_bit = 0x01; @@ -779,12 +753,11 @@ HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXboxOne } #ifdef DEBUG_XBOX_PROTOCOL SDL_Log(">>> Paddles: %d,%d,%d,%d mapped = %s\n", - (data[paddle_index] & button1_bit) ? 1 : 0, - (data[paddle_index] & button2_bit) ? 1 : 0, - (data[paddle_index] & button3_bit) ? 1 : 0, - (data[paddle_index] & button4_bit) ? 1 : 0, - paddles_mapped ? "TRUE" : "FALSE" - ); + (data[paddle_index] & button1_bit) ? 1 : 0, + (data[paddle_index] & button2_bit) ? 1 : 0, + (data[paddle_index] & button3_bit) ? 1 : 0, + (data[paddle_index] & button4_bit) ? 1 : 0, + paddles_mapped ? "TRUE" : "FALSE"); #endif if (paddles_mapped) { @@ -802,7 +775,7 @@ HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXboxOne } } - axis = ((int)SDL_SwapLE16(*(Sint16*)(&data[6])) * 64) - 32768; + axis = ((int)SDL_SwapLE16(*(Sint16 *)(&data[6])) * 64) - 32768; if (axis == 32704) { axis = 32767; } @@ -811,7 +784,7 @@ HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXboxOne } SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis); - axis = ((int)SDL_SwapLE16(*(Sint16*)(&data[8])) * 64) - 32768; + axis = ((int)SDL_SwapLE16(*(Sint16 *)(&data[8])) * 64) - 32768; if (axis == -32768 && size == 30 && (data[22] & 0x40) != 0) { axis = 32767; } @@ -820,28 +793,26 @@ HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXboxOne } SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, axis); - axis = SDL_SwapLE16(*(Sint16*)(&data[10])); + axis = SDL_SwapLE16(*(Sint16 *)(&data[10])); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis); - axis = SDL_SwapLE16(*(Sint16*)(&data[12])); + axis = SDL_SwapLE16(*(Sint16 *)(&data[12])); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY, ~axis); - axis = SDL_SwapLE16(*(Sint16*)(&data[14])); + axis = SDL_SwapLE16(*(Sint16 *)(&data[14])); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTX, axis); - axis = SDL_SwapLE16(*(Sint16*)(&data[16])); + axis = SDL_SwapLE16(*(Sint16 *)(&data[16])); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, ~axis); SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); } -static void -HIDAPI_DriverXboxOne_HandleStatusPacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverXboxOne_HandleStatusPacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) { if (ctx->init_state < XBOX_ONE_INIT_STATE_COMPLETE) { SetInitState(ctx, XBOX_ONE_INIT_STATE_COMPLETE); } } -static void -HIDAPI_DriverXboxOne_HandleModePacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverXboxOne_HandleModePacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) { SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[4] & 0x01) ? SDL_PRESSED : SDL_RELEASED); } @@ -849,8 +820,7 @@ HIDAPI_DriverXboxOne_HandleModePacket(SDL_Joystick *joystick, SDL_DriverXboxOne_ /* * Xbox One S with firmware 3.1.1221 uses a 16 byte packet and the GUIDE button in a separate packet */ -static void -HIDAPI_DriverXboxOneBluetooth_HandleButtons16(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverXboxOneBluetooth_HandleButtons16(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) { if (ctx->last_state[14] != data[14]) { SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_A, (data[14] & 0x01) ? SDL_PRESSED : SDL_RELEASED); @@ -867,7 +837,6 @@ HIDAPI_DriverXboxOneBluetooth_HandleButtons16(SDL_Joystick *joystick, SDL_Driver SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSTICK, (data[15] & 0x01) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSTICK, (data[15] & 0x02) ? SDL_PRESSED : SDL_RELEASED); } - } /* @@ -878,8 +847,7 @@ HIDAPI_DriverXboxOneBluetooth_HandleButtons16(SDL_Joystick *joystick, SDL_Driver * Xbox One Elite Series 2 with firmware 5.11.3112 uses a 19 byte packet with BACK and GUIDE buttons in byte 15 * Xbox Series X with firmware 5.5.2641 uses a 17 byte packet with BACK and GUIDE buttons in byte 15, and SHARE button in byte 17 */ -static void -HIDAPI_DriverXboxOneBluetooth_HandleButtons(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverXboxOneBluetooth_HandleButtons(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) { if (ctx->last_state[14] != data[14]) { SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_A, (data[14] & 0x01) ? SDL_PRESSED : SDL_RELEASED); @@ -947,12 +915,11 @@ HIDAPI_DriverXboxOneBluetooth_HandleButtons(SDL_Joystick *joystick, SDL_DriverXb #ifdef DEBUG_XBOX_PROTOCOL SDL_Log(">>> Paddles: %d,%d,%d,%d mapped = %s\n", - (data[paddle_index] & button1_bit) ? 1 : 0, - (data[paddle_index] & button2_bit) ? 1 : 0, - (data[paddle_index] & button3_bit) ? 1 : 0, - (data[paddle_index] & button4_bit) ? 1 : 0, - paddles_mapped ? "TRUE" : "FALSE" - ); + (data[paddle_index] & button1_bit) ? 1 : 0, + (data[paddle_index] & button2_bit) ? 1 : 0, + (data[paddle_index] & button3_bit) ? 1 : 0, + (data[paddle_index] & button4_bit) ? 1 : 0, + paddles_mapped ? "TRUE" : "FALSE"); #endif if (paddles_mapped) { @@ -971,8 +938,7 @@ HIDAPI_DriverXboxOneBluetooth_HandleButtons(SDL_Joystick *joystick, SDL_DriverXb } } -static void -HIDAPI_DriverXboxOneBluetooth_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverXboxOneBluetooth_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) { Sint16 axis; @@ -1032,39 +998,37 @@ HIDAPI_DriverXboxOneBluetooth_HandleStatePacket(SDL_Joystick *joystick, SDL_Driv SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, dpad_left); } - axis = ((int)SDL_SwapLE16(*(Sint16*)(&data[9])) * 64) - 32768; + axis = ((int)SDL_SwapLE16(*(Sint16 *)(&data[9])) * 64) - 32768; if (axis == 32704) { axis = 32767; } SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis); - axis = ((int)SDL_SwapLE16(*(Sint16*)(&data[11])) * 64) - 32768; + axis = ((int)SDL_SwapLE16(*(Sint16 *)(&data[11])) * 64) - 32768; if (axis == 32704) { axis = 32767; } SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, axis); - axis = (int)SDL_SwapLE16(*(Uint16*)(&data[1])) - 0x8000; + axis = (int)SDL_SwapLE16(*(Uint16 *)(&data[1])) - 0x8000; SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis); - axis = (int)SDL_SwapLE16(*(Uint16*)(&data[3])) - 0x8000; + axis = (int)SDL_SwapLE16(*(Uint16 *)(&data[3])) - 0x8000; SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY, axis); - axis = (int)SDL_SwapLE16(*(Uint16*)(&data[5])) - 0x8000; + axis = (int)SDL_SwapLE16(*(Uint16 *)(&data[5])) - 0x8000; SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTX, axis); - axis = (int)SDL_SwapLE16(*(Uint16*)(&data[7])) - 0x8000; + axis = (int)SDL_SwapLE16(*(Uint16 *)(&data[7])) - 0x8000; SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, axis); SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); } -static void -HIDAPI_DriverXboxOneBluetooth_HandleGuidePacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverXboxOneBluetooth_HandleGuidePacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) { ctx->has_guide_packet = SDL_TRUE; SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED); } -static void -HIDAPI_DriverXboxOneBluetooth_HandleBatteryPacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverXboxOneBluetooth_HandleBatteryPacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) { Uint8 flags = data[1]; SDL_bool on_usb = (((flags & 0x0C) >> 2) == 0); @@ -1088,14 +1052,13 @@ HIDAPI_DriverXboxOneBluetooth_HandleBatteryPacket(SDL_Joystick *joystick, SDL_Dr } #ifdef SET_SERIAL_AFTER_OPEN -static void -HIDAPI_DriverXboxOne_HandleSerialIDPacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) +static void HIDAPI_DriverXboxOne_HandleSerialIDPacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) { - char serial[ 29 ]; + char serial[29]; int i; for (i = 0; i < 14; ++i) { - SDL_uitoa( data[6 + i], &serial[i * 2], 16 ); + SDL_uitoa(data[6 + i], &serial[i * 2], 16); } serial[i * 2] = '\0'; @@ -1108,12 +1071,10 @@ HIDAPI_DriverXboxOne_HandleSerialIDPacket(SDL_Joystick *joystick, SDL_DriverXbox } #endif /* SET_SERIAL_AFTER_OPEN */ -static SDL_bool -HIDAPI_DriverXboxOne_UpdateInitState(SDL_HIDAPI_Device *device, SDL_DriverXboxOne_Context *ctx) +static SDL_bool HIDAPI_DriverXboxOne_UpdateInitState(SDL_HIDAPI_Device *device, SDL_DriverXboxOne_Context *ctx) { SDL_XboxOneInitState prev_state; - do - { + do { prev_state = ctx->init_state; switch (ctx->init_state) { @@ -1158,8 +1119,7 @@ HIDAPI_DriverXboxOne_UpdateInitState(SDL_HIDAPI_Device *device, SDL_DriverXboxOn return SDL_TRUE; } -static SDL_bool -HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -1336,8 +1296,7 @@ HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) return size >= 0; } -static void -HIDAPI_DriverXboxOne_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static void HIDAPI_DriverXboxOne_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)device->context; @@ -1345,13 +1304,11 @@ HIDAPI_DriverXboxOne_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joys SDL_HomeLEDHintChanged, ctx); } -static void -HIDAPI_DriverXboxOne_FreeDevice(SDL_HIDAPI_Device *device) +static void HIDAPI_DriverXboxOne_FreeDevice(SDL_HIDAPI_Device *device) { } -SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXboxOne = -{ +SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXboxOne = { SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE, SDL_TRUE, HIDAPI_DriverXboxOne_RegisterHints, diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c index 94124b70c..d0f7595bf 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/src/joystick/hidapi/SDL_hidapijoystick.c @@ -97,17 +97,16 @@ static SDL_bool SDL_HIDAPI_combine_joycons = SDL_TRUE; static SDL_bool initialized = SDL_FALSE; static SDL_bool shutting_down = SDL_FALSE; -void -HIDAPI_DumpPacket(const char *prefix, const Uint8 *data, int size) +void HIDAPI_DumpPacket(const char *prefix, const Uint8 *data, int size) { int i; char *buffer; - size_t length = SDL_strlen(prefix) + 11*(USB_PACKET_LENGTH/8) + (5*USB_PACKET_LENGTH*2) + 1 + 1; + size_t length = SDL_strlen(prefix) + 11 * (USB_PACKET_LENGTH / 8) + (5 * USB_PACKET_LENGTH * 2) + 1 + 1; int start = 0, amount = size; buffer = (char *)SDL_malloc(length); SDL_snprintf(buffer, length, prefix, size); - for (i = start; i < start+amount; ++i) { + for (i = start; i < start + amount; ++i) { if ((i % 8) == 0) { SDL_snprintf(&buffer[SDL_strlen(buffer)], length - SDL_strlen(buffer), "\n%.2d: ", i); } @@ -118,8 +117,7 @@ HIDAPI_DumpPacket(const char *prefix, const Uint8 *data, int size) SDL_free(buffer); } -float -HIDAPI_RemapVal(float val, float val_min, float val_max, float output_min, float output_max) +float HIDAPI_RemapVal(float val, float val_min, float val_max, float output_min, float output_max) { return output_min + (output_max - output_min) * (val - val_min) / (val_max - val_min); } @@ -127,12 +125,11 @@ HIDAPI_RemapVal(float val, float val_min, float val_max, float output_min, float static void HIDAPI_UpdateDeviceList(void); static void HIDAPI_JoystickClose(SDL_Joystick *joystick); -static SDL_GameControllerType -SDL_GetJoystickGameControllerProtocol(const char *name, Uint16 vendor, Uint16 product, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static SDL_GameControllerType SDL_GetJoystickGameControllerProtocol(const char *name, Uint16 vendor, Uint16 product, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { static const int LIBUSB_CLASS_VENDOR_SPEC = 0xFF; static const int XB360_IFACE_SUBCLASS = 93; - static const int XB360_IFACE_PROTOCOL = 1; /* Wired */ + static const int XB360_IFACE_PROTOCOL = 1; /* Wired */ static const int XB360W_IFACE_PROTOCOL = 129; /* Wireless */ static const int XBONE_IFACE_SUBCLASS = 71; static const int XBONE_IFACE_PROTOCOL = 208; @@ -214,8 +211,7 @@ SDL_GetJoystickGameControllerProtocol(const char *name, Uint16 vendor, Uint16 pr return type; } -static SDL_bool -HIDAPI_IsDeviceSupported(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +static SDL_bool HIDAPI_IsDeviceSupported(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { int i; SDL_GameControllerType type = SDL_GetJoystickGameControllerProtocol(name, vendor_id, product_id, -1, 0, 0, 0); @@ -229,8 +225,7 @@ HIDAPI_IsDeviceSupported(Uint16 vendor_id, Uint16 product_id, Uint16 version, co return SDL_FALSE; } -static SDL_HIDAPI_DeviceDriver * -HIDAPI_GetDeviceDriver(SDL_HIDAPI_Device *device) +static SDL_HIDAPI_DeviceDriver *HIDAPI_GetDeviceDriver(SDL_HIDAPI_Device *device) { const Uint16 USAGE_PAGE_GENERIC_DESKTOP = 0x0001; const Uint16 USAGE_JOYSTICK = 0x0004; @@ -264,8 +259,7 @@ HIDAPI_GetDeviceDriver(SDL_HIDAPI_Device *device) return NULL; } -static SDL_HIDAPI_Device * -HIDAPI_GetDeviceByIndex(int device_index, SDL_JoystickID *pJoystickID) +static SDL_HIDAPI_Device *HIDAPI_GetDeviceByIndex(int device_index, SDL_JoystickID *pJoystickID) { SDL_HIDAPI_Device *device; @@ -286,8 +280,7 @@ HIDAPI_GetDeviceByIndex(int device_index, SDL_JoystickID *pJoystickID) return NULL; } -static SDL_HIDAPI_Device * -HIDAPI_GetJoystickByInfo(const char *path, Uint16 vendor_id, Uint16 product_id) +static SDL_HIDAPI_Device *HIDAPI_GetJoystickByInfo(const char *path, Uint16 vendor_id, Uint16 product_id) { SDL_HIDAPI_Device *device; @@ -300,8 +293,7 @@ HIDAPI_GetJoystickByInfo(const char *path, Uint16 vendor_id, Uint16 product_id) return device; } -static void -HIDAPI_CleanupDeviceDriver(SDL_HIDAPI_Device *device) +static void HIDAPI_CleanupDeviceDriver(SDL_HIDAPI_Device *device) { if (!device->driver) { return; /* Already cleaned up */ @@ -330,8 +322,7 @@ HIDAPI_CleanupDeviceDriver(SDL_HIDAPI_Device *device) SDL_UnlockMutex(device->dev_lock); } -static void -HIDAPI_SetupDeviceDriver(SDL_HIDAPI_Device *device, SDL_bool *removed) +static void HIDAPI_SetupDeviceDriver(SDL_HIDAPI_Device *device, SDL_bool *removed) { *removed = SDL_FALSE; @@ -429,8 +420,7 @@ HIDAPI_SetupDeviceDriver(SDL_HIDAPI_Device *device, SDL_bool *removed) } } -static void -SDL_HIDAPI_UpdateDrivers(void) +static void SDL_HIDAPI_UpdateDrivers(void) { int i; SDL_HIDAPI_Device *device; @@ -456,8 +446,7 @@ SDL_HIDAPI_UpdateDrivers(void) } while (removed); } -static void SDLCALL -SDL_HIDAPIDriverHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_HIDAPIDriverHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { if (SDL_strcmp(name, SDL_HINT_JOYSTICK_HIDAPI_COMBINE_JOY_CONS) == 0) { SDL_HIDAPI_combine_joycons = SDL_GetStringBoolean(hint, SDL_TRUE); @@ -466,8 +455,7 @@ SDL_HIDAPIDriverHintChanged(void *userdata, const char *name, const char *oldVal SDL_HIDAPI_change_count = 0; } -static int -HIDAPI_JoystickInit(void) +static int HIDAPI_JoystickInit(void) { int i; @@ -515,10 +503,9 @@ HIDAPI_JoystickInit(void) return 0; } -static SDL_bool -HIDAPI_AddJoystickInstanceToDevice(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID) +static SDL_bool HIDAPI_AddJoystickInstanceToDevice(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID) { - SDL_JoystickID *joysticks = (SDL_JoystickID *)SDL_realloc(device->joysticks, (device->num_joysticks + 1)*sizeof(*device->joysticks)); + SDL_JoystickID *joysticks = (SDL_JoystickID *)SDL_realloc(device->joysticks, (device->num_joysticks + 1) * sizeof(*device->joysticks)); if (joysticks == NULL) { return SDL_FALSE; } @@ -528,15 +515,14 @@ HIDAPI_AddJoystickInstanceToDevice(SDL_HIDAPI_Device *device, SDL_JoystickID joy return SDL_TRUE; } -static SDL_bool -HIDAPI_DelJoystickInstanceFromDevice(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID) +static SDL_bool HIDAPI_DelJoystickInstanceFromDevice(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID) { int i, size; for (i = 0; i < device->num_joysticks; ++i) { if (device->joysticks[i] == joystickID) { size = (device->num_joysticks - i - 1) * sizeof(SDL_JoystickID); - SDL_memmove(&device->joysticks[i], &device->joysticks[i+1], size); + SDL_memmove(&device->joysticks[i], &device->joysticks[i + 1], size); --device->num_joysticks; if (device->num_joysticks == 0) { SDL_free(device->joysticks); @@ -548,8 +534,7 @@ HIDAPI_DelJoystickInstanceFromDevice(SDL_HIDAPI_Device *device, SDL_JoystickID j return SDL_FALSE; } -static SDL_bool -HIDAPI_JoystickInstanceIsUnique(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID) +static SDL_bool HIDAPI_JoystickInstanceIsUnique(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID) { if (device->parent && device->num_joysticks == 1 && device->parent->num_joysticks == 1 && device->joysticks[0] == device->parent->joysticks[0]) { @@ -558,8 +543,7 @@ HIDAPI_JoystickInstanceIsUnique(SDL_HIDAPI_Device *device, SDL_JoystickID joysti return SDL_TRUE; } -void -HIDAPI_SetDeviceName(SDL_HIDAPI_Device *device, const char *name) +void HIDAPI_SetDeviceName(SDL_HIDAPI_Device *device, const char *name) { if (name && *name && SDL_strcmp(name, device->name) != 0) { SDL_free(device->name); @@ -568,15 +552,13 @@ HIDAPI_SetDeviceName(SDL_HIDAPI_Device *device, const char *name) } } -void -HIDAPI_SetDeviceProduct(SDL_HIDAPI_Device *device, Uint16 product_id) +void HIDAPI_SetDeviceProduct(SDL_HIDAPI_Device *device, Uint16 product_id) { /* Don't set the device product ID directly, or we'll constantly re-enumerate this device */ SDL_SetJoystickGUIDProduct(&device->guid, product_id); } -void -HIDAPI_SetDeviceSerial(SDL_HIDAPI_Device *device, const char *serial) +void HIDAPI_SetDeviceSerial(SDL_HIDAPI_Device *device, const char *serial) { if (serial && *serial && (!device->serial || SDL_strcmp(serial, device->serial) != 0)) { SDL_free(device->serial); @@ -609,8 +591,7 @@ HIDAPI_HasConnectedUSBDevice(const char *serial) return SDL_FALSE; } -void -HIDAPI_DisconnectBluetoothDevice(const char *serial) +void HIDAPI_DisconnectBluetoothDevice(const char *serial) { SDL_HIDAPI_Device *device; @@ -643,7 +624,7 @@ HIDAPI_JoystickConnected(SDL_HIDAPI_Device *device, SDL_JoystickID *pJoystickID) for (i = 0; i < device->num_children; ++i) { SDL_HIDAPI_Device *child = device->children[i]; - for (j = child->num_joysticks; j--; ) { + for (j = child->num_joysticks; j--;) { HIDAPI_JoystickDisconnected(child, child->joysticks[j]); } } @@ -666,11 +647,10 @@ HIDAPI_JoystickConnected(SDL_HIDAPI_Device *device, SDL_JoystickID *pJoystickID) return SDL_TRUE; } -void -HIDAPI_JoystickDisconnected(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID) +void HIDAPI_JoystickDisconnected(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID) { int i, j; - + SDL_LockJoysticks(); if (!HIDAPI_JoystickInstanceIsUnique(device, joystickID)) { @@ -706,26 +686,24 @@ HIDAPI_JoystickDisconnected(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID SDL_UnlockJoysticks(); } -static int -HIDAPI_JoystickGetCount(void) +static int HIDAPI_JoystickGetCount(void) { return SDL_HIDAPI_numjoysticks; } -static char * -HIDAPI_ConvertString(const wchar_t *wide_string) +static char *HIDAPI_ConvertString(const wchar_t *wide_string) { char *string = NULL; if (wide_string) { - string = SDL_iconv_string("UTF-8", "WCHAR_T", (char*)wide_string, (SDL_wcslen(wide_string)+1)*sizeof(wchar_t)); + string = SDL_iconv_string("UTF-8", "WCHAR_T", (char *)wide_string, (SDL_wcslen(wide_string) + 1) * sizeof(wchar_t)); if (string == NULL) { switch (sizeof(wchar_t)) { case 2: - string = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char*)wide_string, (SDL_wcslen(wide_string)+1)*sizeof(wchar_t)); + string = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)wide_string, (SDL_wcslen(wide_string) + 1) * sizeof(wchar_t)); break; case 4: - string = SDL_iconv_string("UTF-8", "UCS-4-INTERNAL", (char*)wide_string, (SDL_wcslen(wide_string)+1)*sizeof(wchar_t)); + string = SDL_iconv_string("UTF-8", "UCS-4-INTERNAL", (char *)wide_string, (SDL_wcslen(wide_string) + 1) * sizeof(wchar_t)); break; } } @@ -733,8 +711,7 @@ HIDAPI_ConvertString(const wchar_t *wide_string) return string; } -static SDL_HIDAPI_Device * -HIDAPI_AddDevice(const struct SDL_hid_device_info *info, int num_children, SDL_HIDAPI_Device **children) +static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *info, int num_children, SDL_HIDAPI_Device **children) { SDL_HIDAPI_Device *device; SDL_HIDAPI_Device *curr, *last = NULL; @@ -829,9 +806,7 @@ HIDAPI_AddDevice(const struct SDL_hid_device_info *info, int num_children, SDL_H return device; } - -static void -HIDAPI_DelDevice(SDL_HIDAPI_Device *device) +static void HIDAPI_DelDevice(SDL_HIDAPI_Device *device) { SDL_HIDAPI_Device *curr, *last; int i; @@ -870,8 +845,7 @@ HIDAPI_DelDevice(SDL_HIDAPI_Device *device) } } -static SDL_bool -HIDAPI_CreateCombinedJoyCons() +static SDL_bool HIDAPI_CreateCombinedJoyCons() { SDL_HIDAPI_Device *device, *combined; SDL_HIDAPI_Device *joycons[2] = { NULL, NULL }; @@ -941,8 +915,7 @@ HIDAPI_CreateCombinedJoyCons() return SDL_FALSE; } -static void -HIDAPI_UpdateDeviceList(void) +static void HIDAPI_UpdateDeviceList(void) { SDL_HIDAPI_Device *device; struct SDL_hid_device_info *devs, *info; @@ -1018,8 +991,7 @@ check_removed: SDL_UnlockJoysticks(); } -static SDL_bool -HIDAPI_IsEquivalentToDevice(Uint16 vendor_id, Uint16 product_id, SDL_HIDAPI_Device *device) +static SDL_bool HIDAPI_IsEquivalentToDevice(Uint16 vendor_id, Uint16 product_id, SDL_HIDAPI_Device *device) { if (vendor_id == device->vendor_id && product_id == device->product_id) { return SDL_TRUE; @@ -1099,8 +1071,8 @@ HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, cons } /* Only update the device list for devices we know might be supported. - If we did this for every device, it would hit the USB driver too hard and potentially - lock up the system. This won't catch devices that we support but can only detect using + If we did this for every device, it would hit the USB driver too hard and potentially + lock up the system. This won't catch devices that we support but can only detect using USB interface details, like Xbox controllers, but hopefully the device list update is responsive enough to catch those. */ @@ -1174,8 +1146,7 @@ HIDAPI_GetGameControllerTypeFromGUID(SDL_JoystickGUID guid) return type; } -static void -HIDAPI_JoystickDetect(void) +static void HIDAPI_JoystickDetect(void) { if (SDL_AtomicTryLock(&SDL_HIDAPI_spinlock)) { Uint32 count = SDL_hid_device_change_count(); @@ -1187,8 +1158,7 @@ HIDAPI_JoystickDetect(void) } } -void -HIDAPI_UpdateDevices(void) +void HIDAPI_UpdateDevices(void) { SDL_HIDAPI_Device *device; @@ -1213,8 +1183,7 @@ HIDAPI_UpdateDevices(void) } } -static const char * -HIDAPI_JoystickGetDeviceName(int device_index) +static const char *HIDAPI_JoystickGetDeviceName(int device_index) { SDL_HIDAPI_Device *device; const char *name = NULL; @@ -1228,8 +1197,7 @@ HIDAPI_JoystickGetDeviceName(int device_index) return name; } -static const char * -HIDAPI_JoystickGetDevicePath(int device_index) +static const char *HIDAPI_JoystickGetDevicePath(int device_index) { SDL_HIDAPI_Device *device; const char *path = NULL; @@ -1243,8 +1211,7 @@ HIDAPI_JoystickGetDevicePath(int device_index) return path; } -static int -HIDAPI_JoystickGetDevicePlayerIndex(int device_index) +static int HIDAPI_JoystickGetDevicePlayerIndex(int device_index) { SDL_HIDAPI_Device *device; SDL_JoystickID instance_id; @@ -1258,8 +1225,7 @@ HIDAPI_JoystickGetDevicePlayerIndex(int device_index) return player_index; } -static void -HIDAPI_JoystickSetDevicePlayerIndex(int device_index, int player_index) +static void HIDAPI_JoystickSetDevicePlayerIndex(int device_index, int player_index) { SDL_HIDAPI_Device *device; SDL_JoystickID instance_id; @@ -1270,8 +1236,7 @@ HIDAPI_JoystickSetDevicePlayerIndex(int device_index, int player_index) } } -static SDL_JoystickGUID -HIDAPI_JoystickGetDeviceGUID(int device_index) +static SDL_JoystickGUID HIDAPI_JoystickGetDeviceGUID(int device_index) { SDL_HIDAPI_Device *device; SDL_JoystickGUID guid; @@ -1286,16 +1251,14 @@ HIDAPI_JoystickGetDeviceGUID(int device_index) return guid; } -static SDL_JoystickID -HIDAPI_JoystickGetDeviceInstanceID(int device_index) +static SDL_JoystickID HIDAPI_JoystickGetDeviceInstanceID(int device_index) { SDL_JoystickID joystickID = -1; HIDAPI_GetDeviceByIndex(device_index, &joystickID); return joystickID; } -static int -HIDAPI_JoystickOpen(SDL_Joystick *joystick, int device_index) +static int HIDAPI_JoystickOpen(SDL_Joystick *joystick, int device_index) { SDL_JoystickID joystickID = -1; SDL_HIDAPI_Device *device = HIDAPI_GetDeviceByIndex(device_index, &joystickID); @@ -1334,8 +1297,7 @@ HIDAPI_JoystickOpen(SDL_Joystick *joystick, int device_index) return 0; } -static int -HIDAPI_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int HIDAPI_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { int result; @@ -1350,8 +1312,7 @@ HIDAPI_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint1 return result; } -static int -HIDAPI_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int HIDAPI_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { int result; @@ -1366,8 +1327,7 @@ HIDAPI_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 return result; } -static Uint32 -HIDAPI_JoystickGetCapabilities(SDL_Joystick *joystick) +static Uint32 HIDAPI_JoystickGetCapabilities(SDL_Joystick *joystick) { Uint32 result = 0; @@ -1380,8 +1340,7 @@ HIDAPI_JoystickGetCapabilities(SDL_Joystick *joystick) return result; } -static int -HIDAPI_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int HIDAPI_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { int result; @@ -1396,8 +1355,7 @@ HIDAPI_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue return result; } -static int -HIDAPI_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) +static int HIDAPI_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) { int result; @@ -1412,8 +1370,7 @@ HIDAPI_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) return result; } -static int -HIDAPI_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) { int result; @@ -1428,14 +1385,12 @@ HIDAPI_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) return result; } -static void -HIDAPI_JoystickUpdate(SDL_Joystick *joystick) +static void HIDAPI_JoystickUpdate(SDL_Joystick *joystick) { /* This is handled in SDL_HIDAPI_UpdateDevices() */ } -static void -HIDAPI_JoystickClose(SDL_Joystick *joystick) +static void HIDAPI_JoystickClose(SDL_Joystick *joystick) { if (joystick->hwdata) { SDL_HIDAPI_Device *device = joystick->hwdata->device; @@ -1463,8 +1418,7 @@ HIDAPI_JoystickClose(SDL_Joystick *joystick) } } -static void -HIDAPI_JoystickQuit(void) +static void HIDAPI_JoystickQuit(void) { int i; @@ -1505,14 +1459,12 @@ HIDAPI_JoystickQuit(void) initialized = SDL_FALSE; } -static SDL_bool -HIDAPI_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static SDL_bool HIDAPI_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { return SDL_FALSE; } -SDL_JoystickDriver SDL_HIDAPI_JoystickDriver = -{ +SDL_JoystickDriver SDL_HIDAPI_JoystickDriver = { HIDAPI_JoystickInit, HIDAPI_JoystickGetCount, HIDAPI_JoystickDetect, diff --git a/src/joystick/hidapi/SDL_hidapijoystick_c.h b/src/joystick/hidapi/SDL_hidapijoystick_c.h index 4ebadede9..4cd542661 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick_c.h +++ b/src/joystick/hidapi/SDL_hidapijoystick_c.h @@ -38,7 +38,7 @@ #define SDL_JOYSTICK_HIDAPI_PS4 #define SDL_JOYSTICK_HIDAPI_PS5 #define SDL_JOYSTICK_HIDAPI_STADIA -#define SDL_JOYSTICK_HIDAPI_STEAM /* Simple support for BLE Steam Controller, hint is disabled by default */ +#define SDL_JOYSTICK_HIDAPI_STEAM /* Simple support for BLE Steam Controller, hint is disabled by default */ #define SDL_JOYSTICK_HIDAPI_SWITCH #define SDL_JOYSTICK_HIDAPI_WII #define SDL_JOYSTICK_HIDAPI_XBOX360 @@ -46,10 +46,10 @@ #define SDL_JOYSTICK_HIDAPI_SHIELD /* Whether HIDAPI is enabled by default */ -#define SDL_HIDAPI_DEFAULT SDL_TRUE +#define SDL_HIDAPI_DEFAULT SDL_TRUE /* The maximum size of a USB packet for HID devices */ -#define USB_PACKET_LENGTH 64 +#define USB_PACKET_LENGTH 64 /* Forward declaration */ struct _SDL_HIDAPI_DeviceDriver; @@ -63,7 +63,7 @@ typedef struct _SDL_HIDAPI_Device Uint16 version; char *serial; SDL_JoystickGUID guid; - int interface_number; /* Available on Windows and Linux */ + int interface_number; /* Available on Windows and Linux */ int interface_class; int interface_subclass; int interface_protocol; @@ -118,7 +118,6 @@ typedef struct _SDL_HIDAPI_DeviceDriver } SDL_HIDAPI_DeviceDriver; - /* HIDAPI device support */ extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverCombined; extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverGameCube; diff --git a/src/joystick/iphoneos/SDL_mfijoystick.m b/src/joystick/iphoneos/SDL_mfijoystick.m index 2ffdab5f5..a8a74b04f 100644 --- a/src/joystick/iphoneos/SDL_mfijoystick.m +++ b/src/joystick/iphoneos/SDL_mfijoystick.m @@ -75,20 +75,20 @@ static NSString *GCInputXboxShareButton = @"Button Share"; @end @interface GCExtendedGamepad (SDL) #if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 121000) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 121000) || (__MAC_OS_VERSION_MAX_ALLOWED >= 1401000)) -@property (nonatomic, readonly, nullable) GCControllerButtonInput *leftThumbstickButton; -@property (nonatomic, readonly, nullable) GCControllerButtonInput *rightThumbstickButton; +@property(nonatomic, readonly, nullable) GCControllerButtonInput *leftThumbstickButton; +@property(nonatomic, readonly, nullable) GCControllerButtonInput *rightThumbstickButton; #endif #if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 130000) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 130000) || (__MAC_OS_VERSION_MAX_ALLOWED >= 1500000)) -@property (nonatomic, readonly) GCControllerButtonInput *buttonMenu; -@property (nonatomic, readonly, nullable) GCControllerButtonInput *buttonOptions; +@property(nonatomic, readonly) GCControllerButtonInput *buttonMenu; +@property(nonatomic, readonly, nullable) GCControllerButtonInput *buttonOptions; #endif #if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 140000) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 140000) || (__MAC_OS_VERSION_MAX_ALLOWED > 1500000)) -@property (nonatomic, readonly, nullable) GCControllerButtonInput *buttonHome; +@property(nonatomic, readonly, nullable) GCControllerButtonInput *buttonHome; #endif @end @interface GCMicroGamepad (SDL) #if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 130000) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 130000) || (__MAC_OS_VERSION_MAX_ALLOWED >= 1500000)) -@property (nonatomic, readonly) GCControllerButtonInput *buttonMenu; +@property(nonatomic, readonly) GCControllerButtonInput *buttonMenu; #endif @end @@ -117,8 +117,7 @@ static SDL_JoystickDeviceItem *deviceList = NULL; static int numjoysticks = 0; int SDL_AppleTVRemoteOpenedAsJoystick = 0; -static SDL_JoystickDeviceItem * -GetDeviceForIndex(int device_index) +static SDL_JoystickDeviceItem *GetDeviceForIndex(int device_index) { SDL_JoystickDeviceItem *device = deviceList; int i = 0; @@ -135,50 +134,46 @@ GetDeviceForIndex(int device_index) } #ifdef SDL_JOYSTICK_MFI -static BOOL -IsControllerPS4(GCController *controller) +static BOOL IsControllerPS4(GCController *controller) { if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) { if ([controller.productCategory isEqualToString:@"DualShock 4"]) { return TRUE; } } else { - if ([controller.vendorName containsString: @"DUALSHOCK"]) { + if ([controller.vendorName containsString:@"DUALSHOCK"]) { return TRUE; } } return FALSE; } -static BOOL -IsControllerPS5(GCController *controller) +static BOOL IsControllerPS5(GCController *controller) { if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) { if ([controller.productCategory isEqualToString:@"DualSense"]) { return TRUE; } } else { - if ([controller.vendorName containsString: @"DualSense"]) { + if ([controller.vendorName containsString:@"DualSense"]) { return TRUE; } } return FALSE; } -static BOOL -IsControllerXbox(GCController *controller) +static BOOL IsControllerXbox(GCController *controller) { if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) { if ([controller.productCategory isEqualToString:@"Xbox One"]) { return TRUE; } } else { - if ([controller.vendorName containsString: @"Xbox"]) { + if ([controller.vendorName containsString:@"Xbox"]) { return TRUE; } } return FALSE; } -static BOOL -IsControllerSwitchPro(GCController *controller) +static BOOL IsControllerSwitchPro(GCController *controller) { if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) { if ([controller.productCategory isEqualToString:@"Switch Pro Controller"]) { @@ -187,8 +182,7 @@ IsControllerSwitchPro(GCController *controller) } return FALSE; } -static BOOL -IsControllerSwitchJoyConL(GCController *controller) +static BOOL IsControllerSwitchJoyConL(GCController *controller) { if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) { if ([controller.productCategory isEqualToString:@"Nintendo Switch Joy-Con (L)"]) { @@ -197,8 +191,7 @@ IsControllerSwitchJoyConL(GCController *controller) } return FALSE; } -static BOOL -IsControllerSwitchJoyConR(GCController *controller) +static BOOL IsControllerSwitchJoyConR(GCController *controller) { if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) { if ([controller.productCategory isEqualToString:@"Nintendo Switch Joy-Con (R)"]) { @@ -207,8 +200,7 @@ IsControllerSwitchJoyConR(GCController *controller) } return FALSE; } -static BOOL -IsControllerSwitchJoyConPair(GCController *controller) +static BOOL IsControllerSwitchJoyConPair(GCController *controller) { if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) { if ([controller.productCategory isEqualToString:@"Nintendo Switch Joy-Con (L/R)"]) { @@ -217,8 +209,7 @@ IsControllerSwitchJoyConPair(GCController *controller) } return FALSE; } -static BOOL -IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *controller) +static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *controller) { Uint16 vendor = 0; Uint16 product = 0; @@ -233,7 +224,7 @@ IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *controlle /* Explicitly retain the controller because SDL_JoystickDeviceItem is a * struct, and ARC doesn't work with structs. */ - device->controller = (__bridge GCController *) CFBridgingRetain(controller); + device->controller = (__bridge GCController *)CFBridgingRetain(controller); if (controller.vendorName) { name = controller.vendorName.UTF8String; @@ -495,8 +486,7 @@ IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *controlle #endif /* SDL_JOYSTICK_MFI */ #if defined(SDL_JOYSTICK_iOS_ACCELEROMETER) || defined(SDL_JOYSTICK_MFI) -static void -IOS_AddJoystickDevice(GCController *controller, SDL_bool accelerometer) +static void IOS_AddJoystickDevice(GCController *controller, SDL_bool accelerometer) { SDL_JoystickDeviceItem *device = deviceList; @@ -516,7 +506,7 @@ IOS_AddJoystickDevice(GCController *controller, SDL_bool accelerometer) device = device->next; } - device = (SDL_JoystickDeviceItem *) SDL_calloc(1, sizeof(SDL_JoystickDeviceItem)); + device = (SDL_JoystickDeviceItem *)SDL_calloc(1, sizeof(SDL_JoystickDeviceItem)); if (device == NULL) { return; } @@ -565,8 +555,7 @@ IOS_AddJoystickDevice(GCController *controller, SDL_bool accelerometer) } #endif /* SDL_JOYSTICK_iOS_ACCELEROMETER || SDL_JOYSTICK_MFI */ -static SDL_JoystickDeviceItem * -IOS_RemoveJoystickDevice(SDL_JoystickDeviceItem *device) +static SDL_JoystickDeviceItem *IOS_RemoveJoystickDevice(SDL_JoystickDeviceItem *device) { SDL_JoystickDeviceItem *prev = NULL; SDL_JoystickDeviceItem *next = NULL; @@ -620,8 +609,7 @@ IOS_RemoveJoystickDevice(SDL_JoystickDeviceItem *device) } #if TARGET_OS_TV -static void SDLCALL -SDL_AppleTVRemoteRotationHintChanged(void *udata, const char *name, const char *oldValue, const char *newValue) +static void SDLCALL SDL_AppleTVRemoteRotationHintChanged(void *udata, const char *name, const char *oldValue, const char *newValue) { BOOL allowRotation = newValue != NULL && *newValue != '0'; @@ -635,8 +623,7 @@ SDL_AppleTVRemoteRotationHintChanged(void *udata, const char *name, const char * } #endif /* TARGET_OS_TV */ -static int -IOS_JoystickInit(void) +static int IOS_JoystickInit(void) { #if defined(__MACOSX__) #if _SDL_HAS_BUILTIN(__builtin_available) @@ -685,26 +672,26 @@ IOS_JoystickInit(void) object:nil queue:nil usingBlock:^(NSNotification *note) { - GCController *controller = note.object; - SDL_LockJoysticks(); - IOS_AddJoystickDevice(controller, SDL_FALSE); - SDL_UnlockJoysticks(); + GCController *controller = note.object; + SDL_LockJoysticks(); + IOS_AddJoystickDevice(controller, SDL_FALSE); + SDL_UnlockJoysticks(); }]; disconnectObserver = [center addObserverForName:GCControllerDidDisconnectNotification object:nil queue:nil usingBlock:^(NSNotification *note) { - GCController *controller = note.object; - SDL_JoystickDeviceItem *device; - SDL_LockJoysticks(); - for (device = deviceList; device != NULL; device = device->next) { - if (device->controller == controller) { - IOS_RemoveJoystickDevice(device); - break; - } - } - SDL_UnlockJoysticks(); + GCController *controller = note.object; + SDL_JoystickDeviceItem *device; + SDL_LockJoysticks(); + for (device = deviceList; device != NULL; device = device->next) { + if (device->controller == controller) { + IOS_RemoveJoystickDevice(device); + break; + } + } + SDL_UnlockJoysticks(); }]; #endif /* SDL_JOYSTICK_MFI */ } @@ -712,32 +699,27 @@ IOS_JoystickInit(void) return 0; } -static int -IOS_JoystickGetCount(void) +static int IOS_JoystickGetCount(void) { return numjoysticks; } -static void -IOS_JoystickDetect(void) +static void IOS_JoystickDetect(void) { } -static const char * -IOS_JoystickGetDeviceName(int device_index) +static const char *IOS_JoystickGetDeviceName(int device_index) { SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index); return device ? device->name : "Unknown"; } -static const char * -IOS_JoystickGetDevicePath(int device_index) +static const char *IOS_JoystickGetDevicePath(int device_index) { return NULL; } -static int -IOS_JoystickGetDevicePlayerIndex(int device_index) +static int IOS_JoystickGetDevicePlayerIndex(int device_index) { #ifdef SDL_JOYSTICK_MFI SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index); @@ -748,8 +730,7 @@ IOS_JoystickGetDevicePlayerIndex(int device_index) return -1; } -static void -IOS_JoystickSetDevicePlayerIndex(int device_index, int player_index) +static void IOS_JoystickSetDevicePlayerIndex(int device_index, int player_index) { #ifdef SDL_JOYSTICK_MFI SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index); @@ -759,8 +740,7 @@ IOS_JoystickSetDevicePlayerIndex(int device_index, int player_index) #endif } -static SDL_JoystickGUID -IOS_JoystickGetDeviceGUID(int device_index) +static SDL_JoystickGUID IOS_JoystickGetDeviceGUID(int device_index) { SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index); SDL_JoystickGUID guid; @@ -772,15 +752,13 @@ IOS_JoystickGetDeviceGUID(int device_index) return guid; } -static SDL_JoystickID -IOS_JoystickGetDeviceInstanceID(int device_index) +static SDL_JoystickID IOS_JoystickGetDeviceInstanceID(int device_index) { SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index); return device ? device->instance_id : -1; } -static int -IOS_JoystickOpen(SDL_Joystick *joystick, int device_index) +static int IOS_JoystickOpen(SDL_Joystick *joystick, int device_index) { SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index); if (device == NULL) { @@ -817,9 +795,9 @@ IOS_JoystickOpen(SDL_Joystick *joystick, int device_index) if (device->uses_pause_handler) { GCController *controller = device->controller; controller.controllerPausedHandler = ^(GCController *c) { - if (joystick->hwdata) { - ++joystick->hwdata->num_pause_presses; - } + if (joystick->hwdata) { + ++joystick->hwdata->num_pause_presses; + } }; } @@ -858,8 +836,7 @@ IOS_JoystickOpen(SDL_Joystick *joystick, int device_index) return 0; } -static void -IOS_AccelerometerUpdate(SDL_Joystick *joystick) +static void IOS_AccelerometerUpdate(SDL_Joystick *joystick) { #ifdef SDL_JOYSTICK_iOS_ACCELEROMETER const float maxgforce = SDL_IPHONE_MAX_GFORCE; @@ -896,15 +873,14 @@ IOS_AccelerometerUpdate(SDL_Joystick *joystick) accel.z = SDL_clamp(accel.z, -maxgforce, maxgforce); /* pass in data mapped to range of SInt16 */ - SDL_PrivateJoystickAxis(joystick, 0, (accel.x / maxgforce) * maxsint16); + SDL_PrivateJoystickAxis(joystick, 0, (accel.x / maxgforce) * maxsint16); SDL_PrivateJoystickAxis(joystick, 1, -(accel.y / maxgforce) * maxsint16); - SDL_PrivateJoystickAxis(joystick, 2, (accel.z / maxgforce) * maxsint16); + SDL_PrivateJoystickAxis(joystick, 2, (accel.z / maxgforce) * maxsint16); #endif /* SDL_JOYSTICK_iOS_ACCELEROMETER */ } #ifdef SDL_JOYSTICK_MFI -static Uint8 -IOS_MFIJoystickHatStateForDPad(GCControllerDirectionPad *dpad) +static Uint8 IOS_MFIJoystickHatStateForDPad(GCControllerDirectionPad *dpad) { Uint8 hat = 0; @@ -928,8 +904,7 @@ IOS_MFIJoystickHatStateForDPad(GCControllerDirectionPad *dpad) } #endif -static void -IOS_MFIJoystickUpdate(SDL_Joystick *joystick) +static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) { #if SDL_JOYSTICK_MFI @autoreleasepool { @@ -961,12 +936,12 @@ IOS_MFIJoystickUpdate(SDL_Joystick *joystick) /* Axis order matches the XInput Windows mappings. */ Sint16 axes[] = { - (Sint16) (gamepad.leftThumbstick.xAxis.value * 32767), - (Sint16) (gamepad.leftThumbstick.yAxis.value * -32767), - (Sint16) ((gamepad.leftTrigger.value * 65535) - 32768), - (Sint16) (gamepad.rightThumbstick.xAxis.value * 32767), - (Sint16) (gamepad.rightThumbstick.yAxis.value * -32767), - (Sint16) ((gamepad.rightTrigger.value * 65535) - 32768), + (Sint16)(gamepad.leftThumbstick.xAxis.value * 32767), + (Sint16)(gamepad.leftThumbstick.yAxis.value * -32767), + (Sint16)((gamepad.leftTrigger.value * 65535) - 32768), + (Sint16)(gamepad.rightThumbstick.xAxis.value * 32767), + (Sint16)(gamepad.rightThumbstick.yAxis.value * -32767), + (Sint16)((gamepad.rightTrigger.value * 65535) - 32768), }; /* Button order matches the XInput Windows mappings. */ @@ -1130,8 +1105,8 @@ IOS_MFIJoystickUpdate(SDL_Joystick *joystick) GCMicroGamepad *gamepad = controller.microGamepad; Sint16 axes[] = { - (Sint16) (gamepad.dpad.xAxis.value * 32767), - (Sint16) (gamepad.dpad.yAxis.value * -32767), + (Sint16)(gamepad.dpad.xAxis.value * 32767), + (Sint16)(gamepad.dpad.yAxis.value * -32767), }; for (i = 0; i < SDL_arraysize(axes); i++) { @@ -1181,19 +1156,18 @@ IOS_MFIJoystickUpdate(SDL_Joystick *joystick) switch (battery.batteryState) { case GCDeviceBatteryStateDischarging: - { - float power_level = battery.batteryLevel; - if (power_level <= 0.05f) { - ePowerLevel = SDL_JOYSTICK_POWER_EMPTY; - } else if (power_level <= 0.20f) { - ePowerLevel = SDL_JOYSTICK_POWER_LOW; - } else if (power_level <= 0.70f) { - ePowerLevel = SDL_JOYSTICK_POWER_MEDIUM; - } else { - ePowerLevel = SDL_JOYSTICK_POWER_FULL; - } + { + float power_level = battery.batteryLevel; + if (power_level <= 0.05f) { + ePowerLevel = SDL_JOYSTICK_POWER_EMPTY; + } else if (power_level <= 0.20f) { + ePowerLevel = SDL_JOYSTICK_POWER_LOW; + } else if (power_level <= 0.70f) { + ePowerLevel = SDL_JOYSTICK_POWER_MEDIUM; + } else { + ePowerLevel = SDL_JOYSTICK_POWER_FULL; } - break; + } break; case GCDeviceBatteryStateCharging: ePowerLevel = SDL_JOYSTICK_POWER_WIRED; break; @@ -1215,15 +1189,16 @@ IOS_MFIJoystickUpdate(SDL_Joystick *joystick) #ifdef ENABLE_MFI_RUMBLE @interface SDL_RumbleMotor : NSObject - @property(nonatomic,strong) CHHapticEngine *engine API_AVAILABLE(macos(10.16), ios(13.0), tvos(14.0)); - @property(nonatomic,strong) id player API_AVAILABLE(macos(10.16), ios(13.0), tvos(14.0)); - @property bool active; +@property(nonatomic, strong) CHHapticEngine *engine API_AVAILABLE(macos(10.16), ios(13.0), tvos(14.0)); +@property(nonatomic, strong) id player API_AVAILABLE(macos(10.16), ios(13.0), tvos(14.0)); +@property bool active; @end -@implementation SDL_RumbleMotor { +@implementation SDL_RumbleMotor +{ } --(void)cleanup +- (void)cleanup { @autoreleasepool { if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { @@ -1239,7 +1214,7 @@ IOS_MFIJoystickUpdate(SDL_Joystick *joystick) } } --(int)setIntensity:(float)intensity +- (int)setIntensity:(float)intensity { @autoreleasepool { if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { @@ -1289,7 +1264,7 @@ IOS_MFIJoystickUpdate(SDL_Joystick *joystick) } } --(id) initWithController:(GCController*)controller locality:(GCHapticsLocality)locality API_AVAILABLE(macos(10.16), ios(14.0), tvos(14.0)) +- (id)initWithController:(GCController *)controller locality:(GCHapticsLocality)locality API_AVAILABLE(macos(10.16), ios(14.0), tvos(14.0)) { @autoreleasepool { NSError *error; @@ -1310,22 +1285,22 @@ IOS_MFIJoystickUpdate(SDL_Joystick *joystick) } self.engine.stoppedHandler = ^(CHHapticEngineStoppedReason stoppedReason) { - SDL_RumbleMotor *_this = weakSelf; - if (_this == nil) { - return; - } + SDL_RumbleMotor *_this = weakSelf; + if (_this == nil) { + return; + } - _this.player = nil; - _this.engine = nil; + _this.player = nil; + _this.engine = nil; }; self.engine.resetHandler = ^{ - SDL_RumbleMotor *_this = weakSelf; - if (_this == nil) { - return; - } + SDL_RumbleMotor *_this = weakSelf; + if (_this == nil) { + return; + } - _this.player = nil; - [_this.engine startAndReturnError:nil]; + _this.player = nil; + [_this.engine startAndReturnError:nil]; }; return self; @@ -1335,19 +1310,20 @@ IOS_MFIJoystickUpdate(SDL_Joystick *joystick) @end @interface SDL_RumbleContext : NSObject - @property(nonatomic,strong) SDL_RumbleMotor *m_low_frequency_motor; - @property(nonatomic,strong) SDL_RumbleMotor *m_high_frequency_motor; - @property(nonatomic,strong) SDL_RumbleMotor *m_left_trigger_motor; - @property(nonatomic,strong) SDL_RumbleMotor *m_right_trigger_motor; +@property(nonatomic, strong) SDL_RumbleMotor *m_low_frequency_motor; +@property(nonatomic, strong) SDL_RumbleMotor *m_high_frequency_motor; +@property(nonatomic, strong) SDL_RumbleMotor *m_left_trigger_motor; +@property(nonatomic, strong) SDL_RumbleMotor *m_right_trigger_motor; @end -@implementation SDL_RumbleContext { +@implementation SDL_RumbleContext +{ } --(id) initWithLowFrequencyMotor:(SDL_RumbleMotor*)low_frequency_motor - HighFrequencyMotor:(SDL_RumbleMotor*)high_frequency_motor - LeftTriggerMotor:(SDL_RumbleMotor*)left_trigger_motor - RightTriggerMotor:(SDL_RumbleMotor*)right_trigger_motor +- (id)initWithLowFrequencyMotor:(SDL_RumbleMotor *)low_frequency_motor + HighFrequencyMotor:(SDL_RumbleMotor *)high_frequency_motor + LeftTriggerMotor:(SDL_RumbleMotor *)left_trigger_motor + RightTriggerMotor:(SDL_RumbleMotor *)right_trigger_motor { self = [super init]; self.m_low_frequency_motor = low_frequency_motor; @@ -1357,7 +1333,7 @@ IOS_MFIJoystickUpdate(SDL_Joystick *joystick) return self; } --(int) rumbleWithLowFrequency:(Uint16)low_frequency_rumble andHighFrequency:(Uint16)high_frequency_rumble +- (int)rumbleWithLowFrequency:(Uint16)low_frequency_rumble andHighFrequency:(Uint16)high_frequency_rumble { int result = 0; @@ -1366,7 +1342,7 @@ IOS_MFIJoystickUpdate(SDL_Joystick *joystick) return ((result < 0) ? -1 : 0); } --(int) rumbleLeftTrigger:(Uint16)left_rumble andRightTrigger:(Uint16)right_rumble +- (int)rumbleLeftTrigger:(Uint16)left_rumble andRightTrigger:(Uint16)right_rumble { int result = 0; @@ -1379,7 +1355,7 @@ IOS_MFIJoystickUpdate(SDL_Joystick *joystick) return ((result < 0) ? -1 : 0); } --(void)cleanup +- (void)cleanup { [self.m_low_frequency_motor cleanup]; [self.m_high_frequency_motor cleanup]; @@ -1408,8 +1384,7 @@ static SDL_RumbleContext *IOS_JoystickInitRumble(GCController *controller) #endif /* ENABLE_MFI_RUMBLE */ -static int -IOS_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int IOS_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { #ifdef ENABLE_MFI_RUMBLE SDL_JoystickDeviceItem *device = joystick->hwdata; @@ -1438,8 +1413,7 @@ IOS_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 h #endif } -static int -IOS_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int IOS_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { #ifdef ENABLE_MFI_RUMBLE SDL_JoystickDeviceItem *device = joystick->hwdata; @@ -1468,8 +1442,7 @@ IOS_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 ri #endif } -static Uint32 -IOS_JoystickGetCapabilities(SDL_Joystick *joystick) +static Uint32 IOS_JoystickGetCapabilities(SDL_Joystick *joystick) { Uint32 result = 0; @@ -1483,13 +1456,13 @@ IOS_JoystickGetCapabilities(SDL_Joystick *joystick) if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { GCController *controller = device->controller; - #ifdef ENABLE_MFI_LIGHT +#ifdef ENABLE_MFI_LIGHT if (controller.light) { result |= SDL_JOYCAP_LED; } - #endif +#endif - #ifdef ENABLE_MFI_RUMBLE +#ifdef ENABLE_MFI_RUMBLE if (controller.haptics) { for (GCHapticsLocality locality in controller.haptics.supportedLocalities) { if ([locality isEqualToString:GCHapticsLocalityHandles]) { @@ -1499,7 +1472,7 @@ IOS_JoystickGetCapabilities(SDL_Joystick *joystick) } } } - #endif +#endif } } #endif /* ENABLE_MFI_LIGHT || ENABLE_MFI_RUMBLE */ @@ -1507,8 +1480,7 @@ IOS_JoystickGetCapabilities(SDL_Joystick *joystick) return result; } -static int -IOS_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int IOS_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { #ifdef ENABLE_MFI_LIGHT @autoreleasepool { @@ -1534,14 +1506,12 @@ IOS_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) return SDL_Unsupported(); } -static int -IOS_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) +static int IOS_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -IOS_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int IOS_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) { #ifdef ENABLE_MFI_SENSORS @autoreleasepool { @@ -1565,8 +1535,7 @@ IOS_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) return SDL_Unsupported(); } -static void -IOS_JoystickUpdate(SDL_Joystick *joystick) +static void IOS_JoystickUpdate(SDL_Joystick *joystick) { SDL_JoystickDeviceItem *device = joystick->hwdata; @@ -1581,8 +1550,7 @@ IOS_JoystickUpdate(SDL_Joystick *joystick) } } -static void -IOS_JoystickClose(SDL_Joystick *joystick) +static void IOS_JoystickClose(SDL_Joystick *joystick) { SDL_JoystickDeviceItem *device = joystick->hwdata; @@ -1632,8 +1600,7 @@ IOS_JoystickClose(SDL_Joystick *joystick) } } -static void -IOS_JoystickQuit(void) +static void IOS_JoystickQuit(void) { @autoreleasepool { #ifdef SDL_JOYSTICK_MFI @@ -1667,8 +1634,7 @@ IOS_JoystickQuit(void) numjoysticks = 0; } -static SDL_bool -IOS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static SDL_bool IOS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { return SDL_FALSE; } @@ -1709,18 +1675,16 @@ SDL_bool IOS_SupportedHIDDevice(IOHIDDeviceRef device) #endif #if defined(SDL_JOYSTICK_MFI) && defined(ENABLE_PHYSICAL_INPUT_PROFILE) -static void -GetAppleSFSymbolsNameForElement(GCControllerElement *element, char *name) +static void GetAppleSFSymbolsNameForElement(GCControllerElement *element, char *name) { if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { if (element) { - [element.sfSymbolsName getCString: name maxLength: 255 encoding: NSASCIIStringEncoding]; + [element.sfSymbolsName getCString:name maxLength:255 encoding:NSASCIIStringEncoding]; } } } -static GCControllerDirectionPad * -GetDirectionalPadForController(GCController *controller) +static GCControllerDirectionPad *GetDirectionalPadForController(GCController *controller) { if (controller.extendedGamepad) { return controller.extendedGamepad.dpad; @@ -1749,9 +1713,8 @@ IOS_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController *gamecontrol if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { GCController *controller = SDL_GameControllerGetJoystick(gamecontroller)->hwdata->controller; if ([controller respondsToSelector:@selector(physicalInputProfile)]) { - NSDictionary *elements = controller.physicalInputProfile.elements; - switch (button) - { + NSDictionary *elements = controller.physicalInputProfile.elements; + switch (button) { case SDL_CONTROLLER_BUTTON_A: GetAppleSFSymbolsNameForElement(elements[GCInputButtonA], elementName); break; @@ -1785,8 +1748,9 @@ IOS_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController *gamecontrol case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER: GetAppleSFSymbolsNameForElement(elements[GCInputRightShoulder], elementName); break; - case SDL_CONTROLLER_BUTTON_DPAD_UP: { - GCControllerDirectionPad * dpad = GetDirectionalPadForController(controller); + case SDL_CONTROLLER_BUTTON_DPAD_UP: + { + GCControllerDirectionPad *dpad = GetDirectionalPadForController(controller); if (dpad) { GetAppleSFSymbolsNameForElement(dpad.up, elementName); if (SDL_strlen(elementName) == 0) { @@ -1795,8 +1759,9 @@ IOS_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController *gamecontrol } break; } - case SDL_CONTROLLER_BUTTON_DPAD_DOWN: { - GCControllerDirectionPad * dpad = GetDirectionalPadForController(controller); + case SDL_CONTROLLER_BUTTON_DPAD_DOWN: + { + GCControllerDirectionPad *dpad = GetDirectionalPadForController(controller); if (dpad) { GetAppleSFSymbolsNameForElement(dpad.down, elementName); if (SDL_strlen(elementName) == 0) { @@ -1805,8 +1770,9 @@ IOS_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController *gamecontrol } break; } - case SDL_CONTROLLER_BUTTON_DPAD_LEFT: { - GCControllerDirectionPad * dpad = GetDirectionalPadForController(controller); + case SDL_CONTROLLER_BUTTON_DPAD_LEFT: + { + GCControllerDirectionPad *dpad = GetDirectionalPadForController(controller); if (dpad) { GetAppleSFSymbolsNameForElement(dpad.left, elementName); if (SDL_strlen(elementName) == 0) { @@ -1815,8 +1781,9 @@ IOS_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController *gamecontrol } break; } - case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: { - GCControllerDirectionPad * dpad = GetDirectionalPadForController(controller); + case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: + { + GCControllerDirectionPad *dpad = GetDirectionalPadForController(controller); if (dpad) { GetAppleSFSymbolsNameForElement(dpad.right, elementName); if (SDL_strlen(elementName) == 0) { @@ -1862,9 +1829,8 @@ IOS_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController *gamecontrolle if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { GCController *controller = SDL_GameControllerGetJoystick(gamecontroller)->hwdata->controller; if ([controller respondsToSelector:@selector(physicalInputProfile)]) { - NSDictionary *elements = controller.physicalInputProfile.elements; - switch (axis) - { + NSDictionary *elements = controller.physicalInputProfile.elements; + switch (axis) { case SDL_CONTROLLER_AXIS_LEFTX: GetAppleSFSymbolsNameForElement(elements[GCInputLeftThumbstick], elementName); break; @@ -1893,9 +1859,7 @@ IOS_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController *gamecontrolle return *elementName ? elementName : NULL; } - -SDL_JoystickDriver SDL_IOS_JoystickDriver = -{ +SDL_JoystickDriver SDL_IOS_JoystickDriver = { IOS_JoystickInit, IOS_JoystickGetCount, IOS_JoystickDetect, diff --git a/src/joystick/iphoneos/SDL_mfijoystick_c.h b/src/joystick/iphoneos/SDL_mfijoystick_c.h index 157dc829e..50131d605 100644 --- a/src/joystick/iphoneos/SDL_mfijoystick_c.h +++ b/src/joystick/iphoneos/SDL_mfijoystick_c.h @@ -59,5 +59,4 @@ typedef joystick_hwdata SDL_JoystickDeviceItem; #endif /* SDL_JOYSTICK_IOS_H */ - /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index a03401b3a..922af2851 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -29,9 +29,9 @@ /* This is the Linux implementation of the SDL joystick API */ #include -#include /* errno, strerror */ +#include /* errno, strerror */ #include -#include /* For the definition of PATH_MAX */ +#include /* For the definition of PATH_MAX */ #ifdef HAVE_INOTIFY #include #endif @@ -57,22 +57,22 @@ #define SYN_DROPPED 3 #endif #ifndef BTN_NORTH -#define BTN_NORTH 0x133 +#define BTN_NORTH 0x133 #endif #ifndef BTN_WEST -#define BTN_WEST 0x134 +#define BTN_WEST 0x134 #endif #ifndef BTN_DPAD_UP -#define BTN_DPAD_UP 0x220 +#define BTN_DPAD_UP 0x220 #endif #ifndef BTN_DPAD_DOWN -#define BTN_DPAD_DOWN 0x221 +#define BTN_DPAD_DOWN 0x221 #endif #ifndef BTN_DPAD_LEFT -#define BTN_DPAD_LEFT 0x222 +#define BTN_DPAD_LEFT 0x222 #endif #ifndef BTN_DPAD_RIGHT -#define BTN_DPAD_RIGHT 0x223 +#define BTN_DPAD_RIGHT 0x223 #endif #include "../../core/linux/SDL_evdev_capabilities.h" @@ -104,8 +104,8 @@ static int MaybeRemoveDevice(const char *path); typedef struct SDL_joylist_item { SDL_JoystickID device_instance; - char *path; /* "/dev/input/event2" or whatever */ - char *name; /* "SideWinder 3D Pro" or whatever */ + char *path; /* "/dev/input/event2" or whatever */ + char *name; /* "SideWinder 3D Pro" or whatever */ SDL_JoystickGUID guid; dev_t devnum; struct joystick_hwdata *hwdata; @@ -127,8 +127,7 @@ static int inotify_fd = -1; static Uint32 last_joy_detect_time; static time_t last_input_dir_mtime; -static void -FixupDeviceInfoForMapping(int fd, struct input_id *inpid) +static void FixupDeviceInfoForMapping(int fd, struct input_id *inpid) { if (inpid->vendor == 0x045e && inpid->product == 0x0b05 && inpid->version == 0x0903) { /* This is a Microsoft Xbox One Elite Series 2 controller */ @@ -145,15 +144,13 @@ FixupDeviceInfoForMapping(int fd, struct input_id *inpid) /* For Atari vcs modern and classic controllers have the version reflecting * firmware version, but the mapping stays stable so ignore * version information */ - if (inpid->vendor == 0x3250 - && (inpid->product == 0x1001 || inpid->product == 0x1002)) { + if (inpid->vendor == 0x3250 && (inpid->product == 0x1001 || inpid->product == 0x1002)) { inpid->version = 0; } } #ifdef SDL_JOYSTICK_HIDAPI -static SDL_bool -IsVirtualJoystick(Uint16 vendor, Uint16 product, Uint16 version, const char *name) +static SDL_bool IsVirtualJoystick(Uint16 vendor, Uint16 product, Uint16 version, const char *name) { if (vendor == USB_VENDOR_MICROSOFT && product == USB_PRODUCT_XBOX_ONE_S && version == 0 && SDL_strcmp(name, "Xbox One S Controller") == 0) { @@ -164,8 +161,7 @@ IsVirtualJoystick(Uint16 vendor, Uint16 product, Uint16 version, const char *nam } #endif /* SDL_JOYSTICK_HIDAPI */ -static int -GuessIsJoystick(int fd) +static int GuessIsJoystick(int fd) { unsigned long evbit[NBITS(EV_MAX)] = { 0 }; unsigned long keybit[NBITS(KEY_MAX)] = { 0 }; @@ -189,8 +185,7 @@ GuessIsJoystick(int fd) return 0; } -static int -IsJoystick(const char *path, int fd, char **name_return, SDL_JoystickGUID *guid) +static int IsJoystick(const char *path, int fd, char **name_return, SDL_JoystickGUID *guid) { struct input_id inpid; char *name; @@ -254,39 +249,37 @@ static void joystick_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_clas } switch (udev_type) { - case SDL_UDEV_DEVICEADDED: - if (!(udev_class & SDL_UDEV_DEVICE_JOYSTICK)) { + case SDL_UDEV_DEVICEADDED: + if (!(udev_class & SDL_UDEV_DEVICE_JOYSTICK)) { + return; + } + if (SDL_classic_joysticks) { + if (!IsJoystickJSNode(devpath)) { return; } - if (SDL_classic_joysticks) { - if (!IsJoystickJSNode(devpath)) { - return; - } - } else { - if (IsJoystickJSNode(devpath)) { - return; - } + } else { + if (IsJoystickJSNode(devpath)) { + return; } + } - /* Wait a bit for the hidraw udev node to initialize */ - SDL_Delay(10); + /* Wait a bit for the hidraw udev node to initialize */ + SDL_Delay(10); - MaybeAddDevice(devpath); - break; - - case SDL_UDEV_DEVICEREMOVED: - MaybeRemoveDevice(devpath); - break; - - default: - break; + MaybeAddDevice(devpath); + break; + + case SDL_UDEV_DEVICEREMOVED: + MaybeRemoveDevice(devpath); + break; + + default: + break; } - } #endif /* SDL_USE_LIBUDEV */ -static void -FreeJoylistItem(SDL_joylist_item *item) +static void FreeJoylistItem(SDL_joylist_item *item) { SDL_free(item->mapping); SDL_free(item->path); @@ -294,8 +287,7 @@ FreeJoylistItem(SDL_joylist_item *item) SDL_free(item); } -static int -MaybeAddDevice(const char *path) +static int MaybeAddDevice(const char *path) { struct stat sb; int fd = -1; @@ -315,7 +307,7 @@ MaybeAddDevice(const char *path) /* Check to make sure it's not already in list. */ for (item = SDL_joylist; item != NULL; item = item->next) { if (sb.st_rdev == item->devnum) { - return -1; /* already have this one */ + return -1; /* already have this one */ } } @@ -334,7 +326,7 @@ MaybeAddDevice(const char *path) return -1; } - item = (SDL_joylist_item *) SDL_calloc(1, sizeof (SDL_joylist_item)); + item = (SDL_joylist_item *)SDL_calloc(1, sizeof(SDL_joylist_item)); if (item == NULL) { SDL_free(name); return -1; @@ -346,8 +338,8 @@ MaybeAddDevice(const char *path) item->guid = guid; if ((item->path == NULL) || (item->name == NULL)) { - FreeJoylistItem(item); - return -1; + FreeJoylistItem(item); + return -1; } item->device_instance = SDL_GetNextJoystickInstanceID(); @@ -366,8 +358,7 @@ MaybeAddDevice(const char *path) return numjoysticks; } -static void -RemoveJoylistItem(SDL_joylist_item *item, SDL_joylist_item *prev) +static void RemoveJoylistItem(SDL_joylist_item *item, SDL_joylist_item *prev) { if (item->hwdata) { item->hwdata->item = NULL; @@ -391,8 +382,7 @@ RemoveJoylistItem(SDL_joylist_item *item, SDL_joylist_item *prev) FreeJoylistItem(item); } -static int -MaybeRemoveDevice(const char *path) +static int MaybeRemoveDevice(const char *path) { SDL_joylist_item *item; SDL_joylist_item *prev = NULL; @@ -414,8 +404,7 @@ MaybeRemoveDevice(const char *path) return -1; } -static void -HandlePendingRemovals(void) +static void HandlePendingRemovals(void) { SDL_joylist_item *prev = NULL; SDL_joylist_item *item = SDL_joylist; @@ -440,7 +429,7 @@ static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_JoystickG { SDL_joylist_item *item; - item = (SDL_joylist_item *) SDL_calloc(1, sizeof (SDL_joylist_item)); + item = (SDL_joylist_item *)SDL_calloc(1, sizeof(SDL_joylist_item)); if (item == NULL) { return SDL_FALSE; } @@ -451,8 +440,8 @@ static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_JoystickG item->m_bSteamController = SDL_TRUE; if ((item->path == NULL) || (item->name == NULL)) { - FreeJoylistItem(item); - return SDL_FALSE; + FreeJoylistItem(item); + return SDL_FALSE; } *device_instance = item->device_instance = SDL_GetNextJoystickInstanceID(); @@ -486,14 +475,12 @@ static void SteamControllerDisconnectedCallback(int device_instance) } } -static int -StrHasPrefix(const char *string, const char *prefix) +static int StrHasPrefix(const char *string, const char *prefix) { return SDL_strncmp(string, prefix, SDL_strlen(prefix)) == 0; } -static int -StrIsInteger(const char *string) +static int StrIsInteger(const char *string) { const char *p; @@ -510,8 +497,7 @@ StrIsInteger(const char *string) return 1; } -static SDL_bool -IsJoystickJSNode(const char *node) +static SDL_bool IsJoystickJSNode(const char *node) { const char *last_slash = SDL_strrchr(node, '/'); if (last_slash) { @@ -520,8 +506,7 @@ IsJoystickJSNode(const char *node) return StrHasPrefix(node, "js") && StrIsInteger(node + 2); } -static SDL_bool -IsJoystickEventNode(const char *node) +static SDL_bool IsJoystickEventNode(const char *node) { const char *last_slash = SDL_strrchr(node, '/'); if (last_slash) { @@ -530,8 +515,7 @@ IsJoystickEventNode(const char *node) return StrHasPrefix(node, "event") && StrIsInteger(node + 5); } -static SDL_bool -IsJoystickDeviceNode(const char *node) +static SDL_bool IsJoystickDeviceNode(const char *node) { if (SDL_classic_joysticks) { return IsJoystickJSNode(node); @@ -542,11 +526,13 @@ IsJoystickDeviceNode(const char *node) #ifdef HAVE_INOTIFY #ifdef HAVE_INOTIFY_INIT1 -static int SDL_inotify_init1(void) { +static int SDL_inotify_init1(void) +{ return inotify_init1(IN_NONBLOCK | IN_CLOEXEC); } #else -static int SDL_inotify_init1(void) { +static int SDL_inotify_init1(void) +{ int fd = inotify_init(); if (fd < 0) { return -1; @@ -557,24 +543,23 @@ static int SDL_inotify_init1(void) { } #endif -static void -LINUX_InotifyJoystickDetect(void) +static void LINUX_InotifyJoystickDetect(void) { union { struct inotify_event event; char storage[4096]; - char enough_for_inotify[sizeof (struct inotify_event) + NAME_MAX + 1]; + char enough_for_inotify[sizeof(struct inotify_event) + NAME_MAX + 1]; } buf; ssize_t bytes; size_t remain = 0; size_t len; char path[PATH_MAX]; - bytes = read(inotify_fd, &buf, sizeof (buf)); + bytes = read(inotify_fd, &buf, sizeof(buf)); if (bytes > 0) { - remain = (size_t) bytes; + remain = (size_t)bytes; } while (remain > 0) { @@ -590,11 +575,11 @@ LINUX_InotifyJoystickDetect(void) } } - len = sizeof (struct inotify_event) + buf.event.len; + len = sizeof(struct inotify_event) + buf.event.len; remain -= len; if (remain != 0) { - SDL_memmove (&buf.storage[0], &buf.storage[len], remain); + SDL_memmove(&buf.storage[0], &buf.storage[len], remain); } } } @@ -611,7 +596,7 @@ static int get_event_joystick_index(int event) count = scandir(path, &entries, NULL, alphasort); for (i = 0; i < count; ++i) { if (SDL_strncmp(entries[i]->d_name, "js", 2) == 0) { - joystick_index = SDL_atoi(entries[i]->d_name+2); + joystick_index = SDL_atoi(entries[i]->d_name + 2); } free(entries[i]); /* This should NOT be SDL_free() */ } @@ -624,13 +609,11 @@ static int get_event_joystick_index(int event) * have to do this the first time, to detect devices that already existed * before we started; in the non-inotify code path we do this repeatedly * (polling). */ -static int -filter_entries(const struct dirent *entry) +static int filter_entries(const struct dirent *entry) { return IsJoystickDeviceNode(entry->d_name); } -static int -sort_entries(const void *_a, const void *_b) +static int sort_entries(const void *_a, const void *_b) { const struct dirent **a = (const struct dirent **)_a; const struct dirent **b = (const struct dirent **)_b; @@ -639,12 +622,12 @@ sort_entries(const void *_a, const void *_b) if (SDL_classic_joysticks) { offset = 2; /* strlen("js") */ - numA = SDL_atoi((*a)->d_name+offset); - numB = SDL_atoi((*b)->d_name+offset); + numA = SDL_atoi((*a)->d_name + offset); + numB = SDL_atoi((*b)->d_name + offset); } else { offset = 5; /* strlen("event") */ - numA = SDL_atoi((*a)->d_name+offset); - numB = SDL_atoi((*b)->d_name+offset); + numA = SDL_atoi((*a)->d_name + offset); + numB = SDL_atoi((*b)->d_name + offset); /* See if we can get the joystick ordering */ { @@ -663,10 +646,9 @@ sort_entries(const void *_a, const void *_b) return numA - numB; } -static void -LINUX_FallbackJoystickDetect(void) +static void LINUX_FallbackJoystickDetect(void) { - const Uint32 SDL_JOY_DETECT_INTERVAL_MS = 3000; /* Update every 3 seconds */ + const Uint32 SDL_JOY_DETECT_INTERVAL_MS = 3000; /* Update every 3 seconds */ Uint32 now = SDL_GetTicks(); if (!last_joy_detect_time || SDL_TICKS_PASSED(now, last_joy_detect_time + SDL_JOY_DETECT_INTERVAL_MS)) { @@ -697,8 +679,7 @@ LINUX_FallbackJoystickDetect(void) } } -static void -LINUX_JoystickDetect(void) +static void LINUX_JoystickDetect(void) { #if SDL_USE_LIBUDEV if (enumeration_method == ENUMERATION_LIBUDEV) { @@ -706,7 +687,7 @@ LINUX_JoystickDetect(void) } else #endif #ifdef HAVE_INOTIFY - if (inotify_fd >= 0 && last_joy_detect_time != 0) { + if (inotify_fd >= 0 && last_joy_detect_time != 0) { LINUX_InotifyJoystickDetect(); } else #endif @@ -719,8 +700,7 @@ LINUX_JoystickDetect(void) SDL_UpdateSteamControllers(); } -static int -LINUX_JoystickInit(void) +static int LINUX_JoystickInit(void) { const char *devices = SDL_GetHint(SDL_HINT_JOYSTICK_DEVICE); @@ -794,7 +774,7 @@ LINUX_JoystickInit(void) if (inotify_fd < 0) { SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, "Unable to initialize inotify, falling back to polling: %s", - strerror (errno)); + strerror(errno)); } else { /* We need to watch for attribute changes in addition to * creation, because when a device is first created, it has @@ -807,7 +787,7 @@ LINUX_JoystickInit(void) inotify_fd = -1; SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, "Unable to add inotify watch, falling back to polling: %s", - strerror (errno)); + strerror(errno)); } } #endif /* HAVE_INOTIFY */ @@ -816,14 +796,12 @@ LINUX_JoystickInit(void) return 0; } -static int -LINUX_JoystickGetCount(void) +static int LINUX_JoystickGetCount(void) { return numjoysticks; } -static SDL_joylist_item * -JoystickByDevIndex(int device_index) +static SDL_joylist_item *JoystickByDevIndex(int device_index) { SDL_joylist_item *item = SDL_joylist; @@ -840,50 +818,43 @@ JoystickByDevIndex(int device_index) return item; } -static const char * -LINUX_JoystickGetDeviceName(int device_index) +static const char *LINUX_JoystickGetDeviceName(int device_index) { return JoystickByDevIndex(device_index)->name; } -static const char * -LINUX_JoystickGetDevicePath(int device_index) +static const char *LINUX_JoystickGetDevicePath(int device_index) { return JoystickByDevIndex(device_index)->path; } -static int -LINUX_JoystickGetDevicePlayerIndex(int device_index) +static int LINUX_JoystickGetDevicePlayerIndex(int device_index) { return -1; } -static void -LINUX_JoystickSetDevicePlayerIndex(int device_index, int player_index) +static void LINUX_JoystickSetDevicePlayerIndex(int device_index, int player_index) { } -static SDL_JoystickGUID -LINUX_JoystickGetDeviceGUID( int device_index ) +static SDL_JoystickGUID LINUX_JoystickGetDeviceGUID(int device_index) { return JoystickByDevIndex(device_index)->guid; } /* Function to perform the mapping from device index to the instance id for this index */ -static SDL_JoystickID -LINUX_JoystickGetDeviceInstanceID(int device_index) +static SDL_JoystickID LINUX_JoystickGetDeviceInstanceID(int device_index) { return JoystickByDevIndex(device_index)->device_instance; } -static int -allocate_hatdata(SDL_Joystick *joystick) +static int allocate_hatdata(SDL_Joystick *joystick) { int i; joystick->hwdata->hats = - (struct hwdata_hat *) SDL_malloc(joystick->nhats * - sizeof(struct hwdata_hat)); + (struct hwdata_hat *)SDL_malloc(joystick->nhats * + sizeof(struct hwdata_hat)); if (joystick->hwdata->hats == NULL) { return -1; } @@ -894,14 +865,13 @@ allocate_hatdata(SDL_Joystick *joystick) return 0; } -static int -allocate_balldata(SDL_Joystick *joystick) +static int allocate_balldata(SDL_Joystick *joystick) { int i; joystick->hwdata->balls = - (struct hwdata_ball *) SDL_malloc(joystick->nballs * - sizeof(struct hwdata_ball)); + (struct hwdata_ball *)SDL_malloc(joystick->nballs * + sizeof(struct hwdata_ball)); if (joystick->hwdata->balls == NULL) { return -1; } @@ -912,8 +882,7 @@ allocate_balldata(SDL_Joystick *joystick) return 0; } -static SDL_bool -GuessIfAxesAreDigitalHat(struct input_absinfo *absinfo_x, struct input_absinfo *absinfo_y) +static SDL_bool GuessIfAxesAreDigitalHat(struct input_absinfo *absinfo_x, struct input_absinfo *absinfo_y) { /* A "hat" is assumed to be a digital input with at most 9 possible states * (3 per axis: negative/zero/positive), as opposed to a true "axis" which @@ -945,8 +914,7 @@ GuessIfAxesAreDigitalHat(struct input_absinfo *absinfo_x, struct input_absinfo * return SDL_FALSE; } -static void -ConfigJoystick(SDL_Joystick *joystick, int fd) +static void ConfigJoystick(SDL_Joystick *joystick, int fd) { int i, t; unsigned long keybit[NBITS(KEY_MAX)] = { 0 }; @@ -994,8 +962,8 @@ ConfigJoystick(SDL_Joystick *joystick, int fd) if (test_bit(i + 1, absbit)) { hat_y = ioctl(fd, EVIOCGABS(i + 1), &absinfo_y); } - if (GuessIfAxesAreDigitalHat((hat_x < 0 ? (void*)0 : &absinfo_x), - (hat_y < 0 ? (void*)0 : &absinfo_y))) { + if (GuessIfAxesAreDigitalHat((hat_x < 0 ? (void *)0 : &absinfo_x), + (hat_y < 0 ? (void *)0 : &absinfo_y))) { const int hat_index = (i - ABS_HAT0X) / 2; struct hat_axis_correct *correct = &joystick->hwdata->hat_correct[hat_index]; #ifdef DEBUG_INPUT_EVENTS @@ -1015,9 +983,9 @@ ConfigJoystick(SDL_Joystick *joystick, int fd) joystick->hwdata->has_hat[hat_index] = SDL_TRUE; correct->use_deadzones = use_hat_deadzones; correct->minimum[0] = (hat_x < 0) ? -1 : absinfo_x.minimum; - correct->maximum[0] = (hat_x < 0) ? 1 : absinfo_x.maximum; + correct->maximum[0] = (hat_x < 0) ? 1 : absinfo_x.maximum; correct->minimum[1] = (hat_y < 0) ? -1 : absinfo_y.minimum; - correct->maximum[1] = (hat_y < 0) ? 1 : absinfo_y.maximum; + correct->maximum[1] = (hat_y < 0) ? 1 : absinfo_y.maximum; ++joystick->nhats; } } @@ -1120,9 +1088,9 @@ ConfigJoystick(SDL_Joystick *joystick, int fd) joystick->hwdata->hats_indices[hat_index] = joystick->nhats++; joystick->hwdata->has_hat[hat_index] = SDL_TRUE; joystick->hwdata->hat_correct[hat_index].minimum[0] = -1; - joystick->hwdata->hat_correct[hat_index].maximum[0] = 1; + joystick->hwdata->hat_correct[hat_index].maximum[0] = 1; joystick->hwdata->hat_correct[hat_index].minimum[1] = -1; - joystick->hwdata->hat_correct[hat_index].maximum[1] = 1; + joystick->hwdata->hat_correct[hat_index].maximum[1] = 1; } } else { #ifdef DEBUG_INPUT_EVENTS @@ -1157,14 +1125,12 @@ ConfigJoystick(SDL_Joystick *joystick, int fd) } } - /* This is used to do the heavy lifting for LINUX_JoystickOpen and also LINUX_JoystickGetGamepadMapping, so we can query the hardware without adding an opened SDL_Joystick object to the system. This expects `joystick->hwdata` to be allocated and will not free it on error. Returns -1 on error, 0 on success. */ -static int -PrepareJoystickHwdata(SDL_Joystick *joystick, SDL_joylist_item *item) +static int PrepareJoystickHwdata(SDL_Joystick *joystick, SDL_joylist_item *item) { joystick->hwdata->item = item; joystick->hwdata->guid = item->guid; @@ -1205,14 +1171,12 @@ PrepareJoystickHwdata(SDL_Joystick *joystick, SDL_joylist_item *item) return 0; } - /* Function to open a joystick for use. The joystick to open is specified by the device index. This should fill the nbuttons and naxes fields of the joystick structure. It returns 0, or -1 if there is an error. */ -static int -LINUX_JoystickOpen(SDL_Joystick *joystick, int device_index) +static int LINUX_JoystickOpen(SDL_Joystick *joystick, int device_index) { SDL_joylist_item *item = JoystickByDevIndex(device_index); @@ -1230,7 +1194,7 @@ LINUX_JoystickOpen(SDL_Joystick *joystick, int device_index) if (PrepareJoystickHwdata(joystick, item) == -1) { SDL_free(joystick->hwdata); joystick->hwdata = NULL; - return -1; /* SDL_SetError will already have been called */ + return -1; /* SDL_SetError will already have been called */ } SDL_assert(item->hwdata == NULL); @@ -1242,8 +1206,7 @@ LINUX_JoystickOpen(SDL_Joystick *joystick, int device_index) return 0; } -static int -LINUX_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int LINUX_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { struct input_event event; @@ -1284,14 +1247,12 @@ LINUX_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 return 0; } -static int -LINUX_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int LINUX_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static Uint32 -LINUX_JoystickGetCapabilities(SDL_Joystick *joystick) +static Uint32 LINUX_JoystickGetCapabilities(SDL_Joystick *joystick) { Uint32 result = 0; @@ -1302,34 +1263,30 @@ LINUX_JoystickGetCapabilities(SDL_Joystick *joystick) return result; } -static int -LINUX_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int LINUX_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -LINUX_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) +static int LINUX_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -LINUX_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int LINUX_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } -static void -HandleHat(SDL_Joystick *stick, int hatidx, int axis, int value) +static void HandleHat(SDL_Joystick *stick, int hatidx, int axis, int value) { const int hatnum = stick->hwdata->hats_indices[hatidx]; struct hwdata_hat *the_hat; struct hat_axis_correct *correct; const Uint8 position_map[3][3] = { - {SDL_HAT_LEFTUP, SDL_HAT_UP, SDL_HAT_RIGHTUP}, - {SDL_HAT_LEFT, SDL_HAT_CENTERED, SDL_HAT_RIGHT}, - {SDL_HAT_LEFTDOWN, SDL_HAT_DOWN, SDL_HAT_RIGHTDOWN} + { SDL_HAT_LEFTUP, SDL_HAT_UP, SDL_HAT_RIGHTUP }, + { SDL_HAT_LEFT, SDL_HAT_CENTERED, SDL_HAT_RIGHT }, + { SDL_HAT_LEFTDOWN, SDL_HAT_DOWN, SDL_HAT_RIGHTDOWN } }; the_hat = &stick->hwdata->hats[hatnum]; @@ -1367,15 +1324,12 @@ HandleHat(SDL_Joystick *stick, int hatidx, int axis, int value) } } -static void -HandleBall(SDL_Joystick *stick, Uint8 ball, int axis, int value) +static void HandleBall(SDL_Joystick *stick, Uint8 ball, int axis, int value) { stick->hwdata->balls[ball].axis[axis] += value; } - -static int -AxisCorrect(SDL_Joystick *joystick, int which, int value) +static int AxisCorrect(SDL_Joystick *joystick, int which, int value) { struct axis_correct *correct; @@ -1408,8 +1362,7 @@ AxisCorrect(SDL_Joystick *joystick, int which, int value) return value; } -static void -PollAllValues(SDL_Joystick *joystick) +static void PollAllValues(SDL_Joystick *joystick) { struct input_absinfo absinfo; unsigned long keyinfo[NBITS(KEY_MAX)]; @@ -1424,11 +1377,11 @@ PollAllValues(SDL_Joystick *joystick) #ifdef DEBUG_INPUT_EVENTS SDL_Log("Joystick : Re-read Axis %d (%d) val= %d\n", - joystick->hwdata->abs_map[i], i, absinfo.value); + joystick->hwdata->abs_map[i], i, absinfo.value); #endif SDL_PrivateJoystickAxis(joystick, - joystick->hwdata->abs_map[i], - absinfo.value); + joystick->hwdata->abs_map[i], + absinfo.value); } } } @@ -1449,16 +1402,16 @@ PollAllValues(SDL_Joystick *joystick) /* Poll all buttons */ SDL_zeroa(keyinfo); - if (ioctl(joystick->hwdata->fd, EVIOCGKEY(sizeof (keyinfo)), keyinfo) >= 0) { + if (ioctl(joystick->hwdata->fd, EVIOCGKEY(sizeof(keyinfo)), keyinfo) >= 0) { for (i = 0; i < KEY_MAX; i++) { if (joystick->hwdata->has_key[i]) { const Uint8 value = test_bit(i, keyinfo) ? SDL_PRESSED : SDL_RELEASED; #ifdef DEBUG_INPUT_EVENTS SDL_Log("Joystick : Re-read Button %d (%d) val= %d\n", - joystick->hwdata->key_map[i], i, value); + joystick->hwdata->key_map[i], i, value); #endif SDL_PrivateJoystickButton(joystick, - joystick->hwdata->key_map[i], value); + joystick->hwdata->key_map[i], value); } } } @@ -1466,8 +1419,7 @@ PollAllValues(SDL_Joystick *joystick) /* Joyballs are relative input, so there's no poll state. Events only! */ } -static void -HandleInputEvents(SDL_Joystick *joystick) +static void HandleInputEvents(SDL_Joystick *joystick) { struct input_event events[32]; int i, len, code, hat_index; @@ -1484,8 +1436,8 @@ HandleInputEvents(SDL_Joystick *joystick) /* If the kernel sent a SYN_DROPPED, we are supposed to ignore the rest of the packet (the end of it signified by a SYN_REPORT) */ - if ( joystick->hwdata->recovering_from_dropped && - ((events[i].type != EV_SYN) || (code != SYN_REPORT)) ) { + if (joystick->hwdata->recovering_from_dropped && + ((events[i].type != EV_SYN) || (code != SYN_REPORT))) { continue; } @@ -1531,16 +1483,16 @@ HandleInputEvents(SDL_Joystick *joystick) break; case EV_SYN: switch (code) { - case SYN_DROPPED : + case SYN_DROPPED: #ifdef DEBUG_INPUT_EVENTS SDL_Log("Event SYN_DROPPED detected\n"); #endif joystick->hwdata->recovering_from_dropped = SDL_TRUE; break; - case SYN_REPORT : + case SYN_REPORT: if (joystick->hwdata->recovering_from_dropped) { joystick->hwdata->recovering_from_dropped = SDL_FALSE; - PollAllValues(joystick); /* try to sync up to current state now */ + PollAllValues(joystick); /* try to sync up to current state now */ } break; default: @@ -1558,8 +1510,7 @@ HandleInputEvents(SDL_Joystick *joystick) } } -static void -HandleClassicEvents(SDL_Joystick *joystick) +static void HandleClassicEvents(SDL_Joystick *joystick) { struct js_event events[32]; int i, len, code, hat_index; @@ -1602,8 +1553,7 @@ HandleClassicEvents(SDL_Joystick *joystick) } } -static void -LINUX_JoystickUpdate(SDL_Joystick *joystick) +static void LINUX_JoystickUpdate(SDL_Joystick *joystick) { int i; @@ -1627,14 +1577,13 @@ LINUX_JoystickUpdate(SDL_Joystick *joystick) if (xrel || yrel) { joystick->hwdata->balls[i].axis[0] = 0; joystick->hwdata->balls[i].axis[1] = 0; - SDL_PrivateJoystickBall(joystick, (Uint8) i, xrel, yrel); + SDL_PrivateJoystickBall(joystick, (Uint8)i, xrel, yrel); } } } /* Function to close a joystick after use */ -static void -LINUX_JoystickClose(SDL_Joystick *joystick) +static void LINUX_JoystickClose(SDL_Joystick *joystick) { if (joystick->hwdata) { if (joystick->hwdata->effect.id >= 0) { @@ -1657,8 +1606,7 @@ LINUX_JoystickClose(SDL_Joystick *joystick) } /* Function to perform any system-specific joystick related cleanup */ -static void -LINUX_JoystickQuit(void) +static void LINUX_JoystickQuit(void) { SDL_joylist_item *item = NULL; SDL_joylist_item *next = NULL; @@ -1691,8 +1639,7 @@ LINUX_JoystickQuit(void) This is based on the Linux Gamepad Specification available at: https://www.kernel.org/doc/html/v4.15/input/gamepad.html */ -static SDL_bool -LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { SDL_Joystick *joystick; SDL_joylist_item *item = JoystickByDevIndex(device_index); @@ -1712,7 +1659,7 @@ LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) /* We temporarily open the device to check how it's configured. Make a fake SDL_Joystick object to do so. */ - joystick = (SDL_Joystick *) SDL_calloc(sizeof(*joystick), 1); + joystick = (SDL_Joystick *)SDL_calloc(sizeof(*joystick), 1); if (joystick == NULL) { SDL_OutOfMemory(); return SDL_FALSE; @@ -1732,7 +1679,7 @@ LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) if (PrepareJoystickHwdata(joystick, item) == -1) { SDL_free(joystick->hwdata); SDL_free(joystick); - return SDL_FALSE; /* SDL_SetError will already have been called */ + return SDL_FALSE; /* SDL_SetError will already have been called */ } /* don't assign `item->hwdata` so it's not in any global state. */ @@ -2012,7 +1959,7 @@ LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) out->dpdown.target = hat | 0x4; mapped |= 0xF; #ifdef DEBUG_GAMEPAD_MAPPING - SDL_Log("Mapped DPUP+DOWN+LEFT+RIGHT to hat 0 (ABS_HAT0X, ABS_HAT0Y)"); + SDL_Log("Mapped DPUP+DOWN+LEFT+RIGHT to hat 0 (ABS_HAT0X, ABS_HAT0Y)"); #endif } else if (joystick->hwdata->has_abs[ABS_HAT0X] && joystick->hwdata->has_abs[ABS_HAT0Y]) { out->dpleft.kind = EMappingKind_Axis; @@ -2025,8 +1972,8 @@ LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) out->dpdown.target = joystick->hwdata->abs_map[ABS_HAT0Y]; mapped |= 0xF; #ifdef DEBUG_GAMEPAD_MAPPING - SDL_Log("Mapped DPUP+DOWN to axis %d (ABS_HAT0Y)", out->dpup.target); - SDL_Log("Mapped DPLEFT+RIGHT to axis %d (ABS_HAT0X)", out->dpleft.target); + SDL_Log("Mapped DPUP+DOWN to axis %d (ABS_HAT0Y)", out->dpup.target); + SDL_Log("Mapped DPLEFT+RIGHT to axis %d (ABS_HAT0X)", out->dpleft.target); #endif } } @@ -2068,8 +2015,7 @@ LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) return SDL_TRUE; } -SDL_JoystickDriver SDL_LINUX_JoystickDriver = -{ +SDL_JoystickDriver SDL_LINUX_JoystickDriver = { LINUX_JoystickInit, LINUX_JoystickGetCount, LINUX_JoystickDetect, diff --git a/src/joystick/linux/SDL_sysjoystick_c.h b/src/joystick/linux/SDL_sysjoystick_c.h index f0e27b9ca..138eedb0e 100644 --- a/src/joystick/linux/SDL_sysjoystick_c.h +++ b/src/joystick/linux/SDL_sysjoystick_c.h @@ -32,7 +32,7 @@ struct joystick_hwdata int fd; struct SDL_joylist_item *item; SDL_JoystickGUID guid; - char *fname; /* Used in haptic subsystem */ + char *fname; /* Used in haptic subsystem */ SDL_bool ff_rumble; SDL_bool ff_sine; @@ -43,12 +43,12 @@ struct joystick_hwdata struct hwdata_hat { int axis[2]; - } *hats; + } * hats; /* The current Linux joystick driver maps balls to two axes */ struct hwdata_ball { int axis[2]; - } *balls; + } * balls; /* Support for the Linux 2.4 unified input interface */ Uint8 key_map[KEY_MAX]; diff --git a/src/joystick/n3ds/SDL_sysjoystick.c b/src/joystick/n3ds/SDL_sysjoystick.c index 848bef350..956db1abc 100644 --- a/src/joystick/n3ds/SDL_sysjoystick.c +++ b/src/joystick/n3ds/SDL_sysjoystick.c @@ -50,40 +50,34 @@ SDL_FORCE_INLINE void UpdateN3DSReleasedButtons(SDL_Joystick *joystick); SDL_FORCE_INLINE void UpdateN3DSCircle(SDL_Joystick *joystick); SDL_FORCE_INLINE void UpdateN3DSCStick(SDL_Joystick *joystick); -static int -N3DS_JoystickInit(void) +static int N3DS_JoystickInit(void) { hidInit(); return 0; } -static const char * -N3DS_JoystickGetDeviceName(int device_index) +static const char *N3DS_JoystickGetDeviceName(int device_index) { return "Nintendo 3DS"; } -static int -N3DS_JoystickGetCount(void) +static int N3DS_JoystickGetCount(void) { return 1; } -static SDL_JoystickGUID -N3DS_JoystickGetDeviceGUID(int device_index) +static SDL_JoystickGUID N3DS_JoystickGetDeviceGUID(int device_index) { SDL_JoystickGUID guid = SDL_CreateJoystickGUIDForName("Nintendo 3DS"); return guid; } -static SDL_JoystickID -N3DS_JoystickGetDeviceInstanceID(int device_index) +static SDL_JoystickID N3DS_JoystickGetDeviceInstanceID(int device_index) { return device_index; } -static int -N3DS_JoystickOpen(SDL_Joystick *joystick, int device_index) +static int N3DS_JoystickOpen(SDL_Joystick *joystick, int device_index) { joystick->nbuttons = NB_BUTTONS; joystick->naxes = 4; @@ -93,14 +87,12 @@ N3DS_JoystickOpen(SDL_Joystick *joystick, int device_index) return 0; } -static int -N3DS_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int N3DS_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } -static void -N3DS_JoystickUpdate(SDL_Joystick *joystick) +static void N3DS_JoystickUpdate(SDL_Joystick *joystick) { UpdateN3DSPressedButtons(joystick); UpdateN3DSReleasedButtons(joystick); @@ -180,22 +172,19 @@ UpdateN3DSCStick(SDL_Joystick *joystick) previous_state = current_state; } -static void -N3DS_JoystickClose(SDL_Joystick *joystick) +static void N3DS_JoystickClose(SDL_Joystick *joystick) { } -static void -N3DS_JoystickQuit(void) +static void N3DS_JoystickQuit(void) { hidExit(); } -static SDL_bool -N3DS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static SDL_bool N3DS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { /* There is only one possible mapping. */ - *out = (SDL_GamepadMapping) { + *out = (SDL_GamepadMapping){ .a = { EMappingKind_Button, 0 }, .b = { EMappingKind_Button, 1 }, .x = { EMappingKind_Button, 10 }, @@ -226,54 +215,45 @@ N3DS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) return SDL_TRUE; } -static void -N3DS_JoystickDetect(void) +static void N3DS_JoystickDetect(void) { } -static const char * -N3DS_JoystickGetDevicePath(int device_index) +static const char *N3DS_JoystickGetDevicePath(int device_index) { return NULL; } -static int -N3DS_JoystickGetDevicePlayerIndex(int device_index) +static int N3DS_JoystickGetDevicePlayerIndex(int device_index) { return -1; } -static void -N3DS_JoystickSetDevicePlayerIndex(int device_index, int player_index) +static void N3DS_JoystickSetDevicePlayerIndex(int device_index, int player_index) { } -static Uint32 -N3DS_JoystickGetCapabilities(SDL_Joystick *joystick) +static Uint32 N3DS_JoystickGetCapabilities(SDL_Joystick *joystick) { return 0; } -static int -N3DS_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int N3DS_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { return SDL_Unsupported(); } -static int -N3DS_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int N3DS_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static int -N3DS_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int N3DS_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -N3DS_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) +static int N3DS_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } diff --git a/src/joystick/ps2/SDL_sysjoystick.c b/src/joystick/ps2/SDL_sysjoystick.c index d86f97231..b52a77f21 100644 --- a/src/joystick/ps2/SDL_sysjoystick.c +++ b/src/joystick/ps2/SDL_sysjoystick.c @@ -27,7 +27,7 @@ #include #include -#include /* For the definition of NULL */ +#include /* For the definition of NULL */ #include #include @@ -41,11 +41,12 @@ #define PS2_MAX_SLOT 4 /* maximum - 4 slots in one multitap */ #define MAX_CONTROLLERS (PS2_MAX_PORT * PS2_MAX_SLOT) #define PS2_ANALOG_STICKS 2 -#define PS2_ANALOG_AXIS 2 -#define PS2_BUTTONS 16 -#define PS2_TOTAL_AXIS (PS2_ANALOG_STICKS * PS2_ANALOG_AXIS) +#define PS2_ANALOG_AXIS 2 +#define PS2_BUTTONS 16 +#define PS2_TOTAL_AXIS (PS2_ANALOG_STICKS * PS2_ANALOG_AXIS) -struct JoyInfo { +struct JoyInfo +{ uint8_t padBuf[256]; uint16_t btns; uint8_t analog_state[PS2_TOTAL_AXIS]; @@ -53,20 +54,20 @@ struct JoyInfo { uint8_t slot; int8_t rumble_ready; int8_t opened; -} __attribute__ ((aligned (64))); +} __attribute__((aligned(64))); static uint8_t enabled_pads = 0; static struct JoyInfo joyInfo[MAX_CONTROLLERS]; static inline int16_t convert_u8_to_s16(uint8_t val) { - if (val == 0) { - return -0x7fff; - } - return val * 0x0101 - 0x8000; + if (val == 0) { + return -0x7fff; + } + return val * 0x0101 - 0x8000; } -static inline uint8_t rumble_status(uint8_t index) +static inline uint8_t rumble_status(uint8_t index) { char actAlign[6]; int res; @@ -79,7 +80,7 @@ static inline uint8_t rumble_status(uint8_t index) actAlign[3] = 0xff; actAlign[4] = 0xff; actAlign[5] = 0xff; - + res = padSetActAlign(info->port, info->slot, actAlign); info->rumble_ready = res <= 0 ? -1 : 1; } @@ -88,9 +89,9 @@ static inline uint8_t rumble_status(uint8_t index) } /* Function to scan the system for joysticks. -* Joystick 0 should be the system default joystick. -* This function should return 0, or -1 on an unrecoverable error. -*/ + * Joystick 0 should be the system default joystick. + * This function should return 0, or -1 on an unrecoverable error. + */ static int PS2_JoystickInit(void) { uint32_t port = 0; @@ -98,11 +99,11 @@ static int PS2_JoystickInit(void) if (init_joystick_driver(true) < 0) { return -1; - } + } - for (port = 0; port < PS2_MAX_PORT; port++) { + for (port = 0; port < PS2_MAX_PORT; port++) { mtapPortOpen(port); - } + } /* it can fail - we dont care, we will check it more strictly when padPortOpen */ for (slot = 0; slot < PS2_MAX_SLOT; slot++) { @@ -205,7 +206,7 @@ static int PS2_JoystickOpen(SDL_Joystick *joystick, int device_index) joystick->naxes = PS2_TOTAL_AXIS; joystick->nhats = 0; joystick->instance_id = device_index; - + return 0; } @@ -222,13 +223,13 @@ static int PS2_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumbl } // Initial value - actAlign[0] = low_frequency_rumble >> 8; // Enable small engine - actAlign[1] = high_frequency_rumble >> 8; // Enable big engine + actAlign[0] = low_frequency_rumble >> 8; // Enable small engine + actAlign[1] = high_frequency_rumble >> 8; // Enable big engine actAlign[2] = 0xff; actAlign[3] = 0xff; actAlign[4] = 0xff; actAlign[5] = 0xff; - + res = padSetActDirect(info->port, info->slot, actAlign); return res == 1 ? 0 : -1; } @@ -242,7 +243,7 @@ static int PS2_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left, Uint1 /* Capability detection */ static Uint32 PS2_JoystickGetCapabilities(SDL_Joystick *joystick) { - return SDL_JOYCAP_RUMBLE; + return SDL_JOYCAP_RUMBLE; } /* LED functionality */ @@ -264,10 +265,10 @@ static int PS2_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enable } /* Function to update the state of a joystick - called as a device poll. -* This function shouldn't update the joystick structure directly, -* but instead should call SDL_PrivateJoystick*() to deliver events -* and update joystick device state. -*/ + * This function shouldn't update the joystick structure directly, + * but instead should call SDL_PrivateJoystick*() to deliver events + * and update joystick device state. + */ static void PS2_JoystickUpdate(SDL_Joystick *joystick) { uint8_t i; @@ -283,7 +284,8 @@ static void PS2_JoystickUpdate(SDL_Joystick *joystick) int ret = padRead(info->port, info->slot, &buttons); /* port, slot, buttons */ if (ret != 0) { /* Buttons */ - int32_t pressed_buttons = 0xffff ^ buttons.btns;; + int32_t pressed_buttons = 0xffff ^ buttons.btns; + ; if (info->btns != pressed_buttons) { for (i = 0; i < PS2_BUTTONS; i++) { mask = (1 << i); @@ -308,7 +310,7 @@ static void PS2_JoystickUpdate(SDL_Joystick *joystick) if (previous_axis != current_axis) { SDL_PrivateJoystickAxis(joystick, i, convert_u8_to_s16(current_axis)); } - + info->analog_state[i] = current_axis; } } @@ -330,13 +332,12 @@ static void PS2_JoystickQuit(void) deinit_joystick_driver(true); } -static SDL_bool PS2_GetGamepadMapping(int device_index, SDL_GamepadMapping * out) +static SDL_bool PS2_GetGamepadMapping(int device_index, SDL_GamepadMapping *out) { return SDL_FALSE; } -SDL_JoystickDriver SDL_PS2_JoystickDriver = -{ +SDL_JoystickDriver SDL_PS2_JoystickDriver = { PS2_JoystickInit, PS2_JoystickGetCount, PS2_JoystickDetect, diff --git a/src/joystick/psp/SDL_sysjoystick.c b/src/joystick/psp/SDL_sysjoystick.c index ab8490b76..7e969c9e3 100644 --- a/src/joystick/psp/SDL_sysjoystick.c +++ b/src/joystick/psp/SDL_sysjoystick.c @@ -25,7 +25,7 @@ /* This is the PSP implementation of the SDL joystick API */ #include -#include /* For the definition of NULL */ +#include /* For the definition of NULL */ #include #include "../SDL_sysjoystick.h" @@ -40,38 +40,39 @@ static const enum PspCtrlButtons button_map[] = { PSP_CTRL_TRIANGLE, PSP_CTRL_CIRCLE, PSP_CTRL_CROSS, PSP_CTRL_SQUARE, PSP_CTRL_LTRIGGER, PSP_CTRL_RTRIGGER, PSP_CTRL_DOWN, PSP_CTRL_LEFT, PSP_CTRL_UP, PSP_CTRL_RIGHT, - PSP_CTRL_SELECT, PSP_CTRL_START, PSP_CTRL_HOME, PSP_CTRL_HOLD }; -static int analog_map[256]; /* Map analog inputs to -32768 -> 32767 */ + PSP_CTRL_SELECT, PSP_CTRL_START, PSP_CTRL_HOME, PSP_CTRL_HOLD +}; +static int analog_map[256]; /* Map analog inputs to -32768 -> 32767 */ typedef struct { - int x; - int y; + int x; + int y; } point; /* 4 points define the bezier-curve. */ static point a = { 0, 0 }; -static point b = { 50, 0 }; +static point b = { 50, 0 }; static point c = { 78, 32767 }; static point d = { 128, 32767 }; /* simple linear interpolation between two points */ -static SDL_INLINE void lerp (point *dest, point *pt_a, point *pt_b, float t) +static SDL_INLINE void lerp(point *dest, point *pt_a, point *pt_b, float t) { - dest->x = pt_a->x + (pt_b->x - pt_a->x)*t; - dest->y = pt_a->y + (pt_b->y - pt_a->y)*t; + dest->x = pt_a->x + (pt_b->x - pt_a->x) * t; + dest->y = pt_a->y + (pt_b->y - pt_a->y) * t; } /* evaluate a point on a bezier-curve. t goes from 0 to 1.0 */ static int calc_bezier_y(float t) { point ab, bc, cd, abbc, bccd, dest; - lerp (&ab, &a, &b, t); /* point between a and b */ - lerp (&bc, &b, &c, t); /* point between b and c */ - lerp (&cd, &c, &d, t); /* point between c and d */ - lerp (&abbc, &ab, &bc, t); /* point between ab and bc */ - lerp (&bccd, &bc, &cd, t); /* point between bc and cd */ - lerp (&dest, &abbc, &bccd, t); /* point on the bezier-curve */ + lerp(&ab, &a, &b, t); /* point between a and b */ + lerp(&bc, &b, &c, t); /* point between b and c */ + lerp(&cd, &c, &d, t); /* point between c and d */ + lerp(&abbc, &ab, &bc, t); /* point between ab and bc */ + lerp(&bccd, &bc, &cd, t); /* point between bc and cd */ + lerp(&dest, &abbc, &bccd, t); /* point on the bezier-curve */ return dest.y; } @@ -90,9 +91,9 @@ static int PSP_JoystickInit(void) /* Create an accurate map from analog inputs (0 to 255) to SDL joystick positions (-32768 to 32767) */ for (i = 0; i < 128; i++) { - float t = (float)i/127.0f; - analog_map[i+128] = calc_bezier_y(t); - analog_map[127-i] = -1 * analog_map[i+128]; + float t = (float)i / 127.0f; + analog_map[i + 128] = calc_bezier_y(t); + analog_map[127 - i] = -1 * analog_map[i + 128]; } return 1; @@ -227,8 +228,7 @@ static void PSP_JoystickUpdate(SDL_Joystick *joystick) if (changed & button_map[i]) { SDL_PrivateJoystickButton( joystick, i, - (buttons & button_map[i]) ? - SDL_PRESSED : SDL_RELEASED); + (buttons & button_map[i]) ? SDL_PRESSED : SDL_RELEASED); } } } @@ -244,14 +244,12 @@ static void PSP_JoystickQuit(void) { } -static SDL_bool -PSP_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static SDL_bool PSP_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { return SDL_FALSE; } -SDL_JoystickDriver SDL_PSP_JoystickDriver = -{ +SDL_JoystickDriver SDL_PSP_JoystickDriver = { PSP_JoystickInit, PSP_JoystickGetCount, PSP_JoystickDetect, diff --git a/src/joystick/steam/SDL_steamcontroller.c b/src/joystick/steam/SDL_steamcontroller.c index 52511fbea..199bb7787 100644 --- a/src/joystick/steam/SDL_steamcontroller.c +++ b/src/joystick/steam/SDL_steamcontroller.c @@ -24,7 +24,6 @@ #include "../SDL_joystick_c.h" #include "SDL_steamcontroller.h" - void SDL_InitSteamControllers(SteamControllerConnectedCallback_t connectedCallback, SteamControllerDisconnectedCallback_t disconnectedCallback) { diff --git a/src/joystick/usb_ids.h b/src/joystick/usb_ids.h index dd390f1d2..4dc67e480 100644 --- a/src/joystick/usb_ids.h +++ b/src/joystick/usb_ids.h @@ -48,110 +48,110 @@ #define USB_VENDOR_VALVE 0x28de #define USB_VENDOR_ZEROPLUS 0x0c12 -#define SONY_THIRDPARTY_VENDOR(X) \ - (X == USB_VENDOR_DRAGONRISE || \ - X == USB_VENDOR_HORI || \ - X == USB_VENDOR_MADCATZ || \ - X == USB_VENDOR_NACON || \ - X == USB_VENDOR_PDP || \ - X == USB_VENDOR_POWERA || \ - X == USB_VENDOR_POWERA_ALT || \ - X == USB_VENDOR_QANBA || \ - X == USB_VENDOR_RAZER || \ - X == USB_VENDOR_SHANWAN || \ - X == USB_VENDOR_SHANWAN_ALT || \ - X == USB_VENDOR_THRUSTMASTER || \ - X == USB_VENDOR_ZEROPLUS || \ +#define SONY_THIRDPARTY_VENDOR(X) \ + (X == USB_VENDOR_DRAGONRISE || \ + X == USB_VENDOR_HORI || \ + X == USB_VENDOR_MADCATZ || \ + X == USB_VENDOR_NACON || \ + X == USB_VENDOR_PDP || \ + X == USB_VENDOR_POWERA || \ + X == USB_VENDOR_POWERA_ALT || \ + X == USB_VENDOR_QANBA || \ + X == USB_VENDOR_RAZER || \ + X == USB_VENDOR_SHANWAN || \ + X == USB_VENDOR_SHANWAN_ALT || \ + X == USB_VENDOR_THRUSTMASTER || \ + X == USB_VENDOR_ZEROPLUS || \ X == 0x7545 /* SZ-MYPOWER */) -#define USB_PRODUCT_8BITDO_XBOX_CONTROLLER 0x2002 -#define USB_PRODUCT_AMAZON_LUNA_CONTROLLER 0x0419 -#define USB_PRODUCT_GOOGLE_STADIA_CONTROLLER 0x9400 -#define USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER 0x1846 -#define USB_PRODUCT_HORI_FIGHTING_COMMANDER_OCTA_SERIES_X 0x0150 -#define USB_PRODUCT_HORI_FIGHTING_STICK_ALPHA_PS4 0x011c -#define USB_PRODUCT_HORI_FIGHTING_STICK_ALPHA_PS5 0x0184 -#define USB_PRODUCT_NINTENDO_GAMECUBE_ADAPTER 0x0337 -#define USB_PRODUCT_NINTENDO_N64_CONTROLLER 0x2019 -#define USB_PRODUCT_NINTENDO_SEGA_GENESIS_CONTROLLER 0x201e -#define USB_PRODUCT_NINTENDO_SNES_CONTROLLER 0x2017 -#define USB_PRODUCT_NINTENDO_SWITCH_JOYCON_GRIP 0x200e -#define USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT 0x2006 -#define USB_PRODUCT_NINTENDO_SWITCH_JOYCON_PAIR 0x2008 /* Used by joycond */ -#define USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT 0x2007 -#define USB_PRODUCT_NINTENDO_SWITCH_PRO 0x2009 -#define USB_PRODUCT_NINTENDO_WII_REMOTE 0x0306 -#define USB_PRODUCT_NINTENDO_WII_REMOTE2 0x0330 -#define USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V103 0x7210 -#define USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V104 0x7214 -#define USB_PRODUCT_RAZER_ATROX 0x0a00 -#define USB_PRODUCT_RAZER_PANTHERA 0x0401 -#define USB_PRODUCT_RAZER_PANTHERA_EVO 0x1008 -#define USB_PRODUCT_RAZER_RAIJU 0x1000 -#define USB_PRODUCT_RAZER_TOURNAMENT_EDITION_USB 0x1007 -#define USB_PRODUCT_RAZER_TOURNAMENT_EDITION_BLUETOOTH 0x100a -#define USB_PRODUCT_RAZER_ULTIMATE_EDITION_USB 0x1004 -#define USB_PRODUCT_RAZER_ULTIMATE_EDITION_BLUETOOTH 0x1009 -#define USB_PRODUCT_SHANWAN_DS3 0x0523 -#define USB_PRODUCT_SONY_DS3 0x0268 -#define USB_PRODUCT_SONY_DS4 0x05c4 -#define USB_PRODUCT_SONY_DS4_DONGLE 0x0ba0 -#define USB_PRODUCT_SONY_DS4_SLIM 0x09cc -#define USB_PRODUCT_SONY_DS5 0x0ce6 -#define USB_PRODUCT_VICTRIX_FS_PRO_V2 0x0207 -#define USB_PRODUCT_XBOX360_XUSB_CONTROLLER 0x02a1 /* XUSB driver software PID */ -#define USB_PRODUCT_XBOX360_WIRED_CONTROLLER 0x028e -#define USB_PRODUCT_XBOX360_WIRELESS_RECEIVER 0x0719 -#define USB_PRODUCT_XBOX_ONE_ADAPTIVE 0x0b0a -#define USB_PRODUCT_XBOX_ONE_ADAPTIVE_BLUETOOTH 0x0b0c -#define USB_PRODUCT_XBOX_ONE_ADAPTIVE_BLE 0x0b21 -#define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_1 0x02e3 -#define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2 0x0b00 -#define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH 0x0b05 -#define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLE 0x0b22 -#define USB_PRODUCT_XBOX_ONE_S 0x02ea -#define USB_PRODUCT_XBOX_ONE_S_REV1_BLUETOOTH 0x02e0 -#define USB_PRODUCT_XBOX_ONE_S_REV2_BLUETOOTH 0x02fd -#define USB_PRODUCT_XBOX_ONE_S_REV2_BLE 0x0b20 -#define USB_PRODUCT_XBOX_SERIES_X 0x0b12 -#define USB_PRODUCT_XBOX_SERIES_X_BLE 0x0b13 -#define USB_PRODUCT_XBOX_SERIES_X_VICTRIX_GAMBIT 0x02d6 -#define USB_PRODUCT_XBOX_SERIES_X_PDP_BLUE 0x02d9 -#define USB_PRODUCT_XBOX_SERIES_X_PDP_AFTERGLOW 0x02da -#define USB_PRODUCT_XBOX_SERIES_X_POWERA_FUSION_PRO2 0x4001 -#define USB_PRODUCT_XBOX_SERIES_X_POWERA_SPECTRA 0x4002 -#define USB_PRODUCT_XBOX_ONE_XBOXGIP_CONTROLLER 0x02ff /* XBOXGIP driver software PID */ -#define USB_PRODUCT_XBOX_ONE_XINPUT_CONTROLLER 0x02fe /* Made up product ID for XInput */ -#define USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD 0x11ff +#define USB_PRODUCT_8BITDO_XBOX_CONTROLLER 0x2002 +#define USB_PRODUCT_AMAZON_LUNA_CONTROLLER 0x0419 +#define USB_PRODUCT_GOOGLE_STADIA_CONTROLLER 0x9400 +#define USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER 0x1846 +#define USB_PRODUCT_HORI_FIGHTING_COMMANDER_OCTA_SERIES_X 0x0150 +#define USB_PRODUCT_HORI_FIGHTING_STICK_ALPHA_PS4 0x011c +#define USB_PRODUCT_HORI_FIGHTING_STICK_ALPHA_PS5 0x0184 +#define USB_PRODUCT_NINTENDO_GAMECUBE_ADAPTER 0x0337 +#define USB_PRODUCT_NINTENDO_N64_CONTROLLER 0x2019 +#define USB_PRODUCT_NINTENDO_SEGA_GENESIS_CONTROLLER 0x201e +#define USB_PRODUCT_NINTENDO_SNES_CONTROLLER 0x2017 +#define USB_PRODUCT_NINTENDO_SWITCH_JOYCON_GRIP 0x200e +#define USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT 0x2006 +#define USB_PRODUCT_NINTENDO_SWITCH_JOYCON_PAIR 0x2008 /* Used by joycond */ +#define USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT 0x2007 +#define USB_PRODUCT_NINTENDO_SWITCH_PRO 0x2009 +#define USB_PRODUCT_NINTENDO_WII_REMOTE 0x0306 +#define USB_PRODUCT_NINTENDO_WII_REMOTE2 0x0330 +#define USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V103 0x7210 +#define USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V104 0x7214 +#define USB_PRODUCT_RAZER_ATROX 0x0a00 +#define USB_PRODUCT_RAZER_PANTHERA 0x0401 +#define USB_PRODUCT_RAZER_PANTHERA_EVO 0x1008 +#define USB_PRODUCT_RAZER_RAIJU 0x1000 +#define USB_PRODUCT_RAZER_TOURNAMENT_EDITION_USB 0x1007 +#define USB_PRODUCT_RAZER_TOURNAMENT_EDITION_BLUETOOTH 0x100a +#define USB_PRODUCT_RAZER_ULTIMATE_EDITION_USB 0x1004 +#define USB_PRODUCT_RAZER_ULTIMATE_EDITION_BLUETOOTH 0x1009 +#define USB_PRODUCT_SHANWAN_DS3 0x0523 +#define USB_PRODUCT_SONY_DS3 0x0268 +#define USB_PRODUCT_SONY_DS4 0x05c4 +#define USB_PRODUCT_SONY_DS4_DONGLE 0x0ba0 +#define USB_PRODUCT_SONY_DS4_SLIM 0x09cc +#define USB_PRODUCT_SONY_DS5 0x0ce6 +#define USB_PRODUCT_VICTRIX_FS_PRO_V2 0x0207 +#define USB_PRODUCT_XBOX360_XUSB_CONTROLLER 0x02a1 /* XUSB driver software PID */ +#define USB_PRODUCT_XBOX360_WIRED_CONTROLLER 0x028e +#define USB_PRODUCT_XBOX360_WIRELESS_RECEIVER 0x0719 +#define USB_PRODUCT_XBOX_ONE_ADAPTIVE 0x0b0a +#define USB_PRODUCT_XBOX_ONE_ADAPTIVE_BLUETOOTH 0x0b0c +#define USB_PRODUCT_XBOX_ONE_ADAPTIVE_BLE 0x0b21 +#define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_1 0x02e3 +#define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2 0x0b00 +#define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH 0x0b05 +#define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLE 0x0b22 +#define USB_PRODUCT_XBOX_ONE_S 0x02ea +#define USB_PRODUCT_XBOX_ONE_S_REV1_BLUETOOTH 0x02e0 +#define USB_PRODUCT_XBOX_ONE_S_REV2_BLUETOOTH 0x02fd +#define USB_PRODUCT_XBOX_ONE_S_REV2_BLE 0x0b20 +#define USB_PRODUCT_XBOX_SERIES_X 0x0b12 +#define USB_PRODUCT_XBOX_SERIES_X_BLE 0x0b13 +#define USB_PRODUCT_XBOX_SERIES_X_VICTRIX_GAMBIT 0x02d6 +#define USB_PRODUCT_XBOX_SERIES_X_PDP_BLUE 0x02d9 +#define USB_PRODUCT_XBOX_SERIES_X_PDP_AFTERGLOW 0x02da +#define USB_PRODUCT_XBOX_SERIES_X_POWERA_FUSION_PRO2 0x4001 +#define USB_PRODUCT_XBOX_SERIES_X_POWERA_SPECTRA 0x4002 +#define USB_PRODUCT_XBOX_ONE_XBOXGIP_CONTROLLER 0x02ff /* XBOXGIP driver software PID */ +#define USB_PRODUCT_XBOX_ONE_XINPUT_CONTROLLER 0x02fe /* Made up product ID for XInput */ +#define USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD 0x11ff /* USB usage pages */ -#define USB_USAGEPAGE_GENERIC_DESKTOP 0x0001 -#define USB_USAGEPAGE_BUTTON 0x0009 +#define USB_USAGEPAGE_GENERIC_DESKTOP 0x0001 +#define USB_USAGEPAGE_BUTTON 0x0009 /* USB usages for USAGE_PAGE_GENERIC_DESKTOP */ -#define USB_USAGE_GENERIC_POINTER 0x0001 -#define USB_USAGE_GENERIC_MOUSE 0x0002 -#define USB_USAGE_GENERIC_JOYSTICK 0x0004 -#define USB_USAGE_GENERIC_GAMEPAD 0x0005 -#define USB_USAGE_GENERIC_KEYBOARD 0x0006 -#define USB_USAGE_GENERIC_KEYPAD 0x0007 -#define USB_USAGE_GENERIC_MULTIAXISCONTROLLER 0x0008 -#define USB_USAGE_GENERIC_X 0x0030 -#define USB_USAGE_GENERIC_Y 0x0031 -#define USB_USAGE_GENERIC_Z 0x0032 -#define USB_USAGE_GENERIC_RX 0x0033 -#define USB_USAGE_GENERIC_RY 0x0034 -#define USB_USAGE_GENERIC_RZ 0x0035 -#define USB_USAGE_GENERIC_SLIDER 0x0036 -#define USB_USAGE_GENERIC_DIAL 0x0037 -#define USB_USAGE_GENERIC_WHEEL 0x0038 -#define USB_USAGE_GENERIC_HAT 0x0039 +#define USB_USAGE_GENERIC_POINTER 0x0001 +#define USB_USAGE_GENERIC_MOUSE 0x0002 +#define USB_USAGE_GENERIC_JOYSTICK 0x0004 +#define USB_USAGE_GENERIC_GAMEPAD 0x0005 +#define USB_USAGE_GENERIC_KEYBOARD 0x0006 +#define USB_USAGE_GENERIC_KEYPAD 0x0007 +#define USB_USAGE_GENERIC_MULTIAXISCONTROLLER 0x0008 +#define USB_USAGE_GENERIC_X 0x0030 +#define USB_USAGE_GENERIC_Y 0x0031 +#define USB_USAGE_GENERIC_Z 0x0032 +#define USB_USAGE_GENERIC_RX 0x0033 +#define USB_USAGE_GENERIC_RY 0x0034 +#define USB_USAGE_GENERIC_RZ 0x0035 +#define USB_USAGE_GENERIC_SLIDER 0x0036 +#define USB_USAGE_GENERIC_DIAL 0x0037 +#define USB_USAGE_GENERIC_WHEEL 0x0038 +#define USB_USAGE_GENERIC_HAT 0x0039 /* Bluetooth SIG assigned Company Identifiers https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers/ */ -#define BLUETOOTH_VENDOR_AMAZON 0x0171 +#define BLUETOOTH_VENDOR_AMAZON 0x0171 -#define BLUETOOTH_PRODUCT_LUNA_CONTROLLER 0x0419 +#define BLUETOOTH_PRODUCT_LUNA_CONTROLLER 0x0419 #endif /* usb_ids_h_ */ diff --git a/src/joystick/virtual/SDL_virtualjoystick.c b/src/joystick/virtual/SDL_virtualjoystick.c index ef3170927..a7a16c05e 100644 --- a/src/joystick/virtual/SDL_virtualjoystick.c +++ b/src/joystick/virtual/SDL_virtualjoystick.c @@ -29,12 +29,9 @@ #include "../SDL_sysjoystick.h" #include "../SDL_joystick_c.h" +static joystick_hwdata *g_VJoys = NULL; -static joystick_hwdata * g_VJoys = NULL; - - -static joystick_hwdata * -VIRTUAL_HWDataForIndex(int device_index) +static joystick_hwdata *VIRTUAL_HWDataForIndex(int device_index) { joystick_hwdata *vjoy = g_VJoys; while (vjoy) { @@ -47,13 +44,11 @@ VIRTUAL_HWDataForIndex(int device_index) return vjoy; } - -static void -VIRTUAL_FreeHWData(joystick_hwdata *hwdata) +static void VIRTUAL_FreeHWData(joystick_hwdata *hwdata) { - joystick_hwdata * cur = g_VJoys; - joystick_hwdata * prev = NULL; - + joystick_hwdata *cur = g_VJoys; + joystick_hwdata *prev = NULL; + if (hwdata == NULL) { return; } @@ -95,9 +90,7 @@ VIRTUAL_FreeHWData(joystick_hwdata *hwdata) SDL_free(hwdata); } - -int -SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *desc) +int SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *desc) { joystick_hwdata *hwdata = NULL; int device_index = -1; @@ -162,7 +155,7 @@ SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *desc) int i, axis; if (hwdata->desc.button_mask == 0) { - for (i = 0; i < hwdata->desc.nbuttons && i < sizeof(hwdata->desc.button_mask)*8; ++i) { + for (i = 0; i < hwdata->desc.nbuttons && i < sizeof(hwdata->desc.button_mask) * 8; ++i) { hwdata->desc.button_mask |= (1 << i); } } @@ -248,9 +241,7 @@ SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *desc) return device_index; } - -int -SDL_JoystickDetachVirtualInner(int device_index) +int SDL_JoystickDetachVirtualInner(int device_index) { SDL_JoystickID instance_id; joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); @@ -263,9 +254,7 @@ SDL_JoystickDetachVirtualInner(int device_index) return 0; } - -int -SDL_JoystickSetVirtualAxisInner(SDL_Joystick *joystick, int axis, Sint16 value) +int SDL_JoystickSetVirtualAxisInner(SDL_Joystick *joystick, int axis, Sint16 value) { joystick_hwdata *hwdata; @@ -288,9 +277,7 @@ SDL_JoystickSetVirtualAxisInner(SDL_Joystick *joystick, int axis, Sint16 value) return 0; } - -int -SDL_JoystickSetVirtualButtonInner(SDL_Joystick *joystick, int button, Uint8 value) +int SDL_JoystickSetVirtualButtonInner(SDL_Joystick *joystick, int button, Uint8 value) { joystick_hwdata *hwdata; @@ -313,9 +300,7 @@ SDL_JoystickSetVirtualButtonInner(SDL_Joystick *joystick, int button, Uint8 valu return 0; } - -int -SDL_JoystickSetVirtualHatInner(SDL_Joystick *joystick, int hat, Uint8 value) +int SDL_JoystickSetVirtualHatInner(SDL_Joystick *joystick, int hat, Uint8 value) { joystick_hwdata *hwdata; @@ -338,16 +323,12 @@ SDL_JoystickSetVirtualHatInner(SDL_Joystick *joystick, int hat, Uint8 value) return 0; } - -static int -VIRTUAL_JoystickInit(void) +static int VIRTUAL_JoystickInit(void) { return 0; } - -static int -VIRTUAL_JoystickGetCount(void) +static int VIRTUAL_JoystickGetCount(void) { int count = 0; joystick_hwdata *cur = g_VJoys; @@ -358,15 +339,11 @@ VIRTUAL_JoystickGetCount(void) return count; } - -static void -VIRTUAL_JoystickDetect(void) +static void VIRTUAL_JoystickDetect(void) { } - -static const char * -VIRTUAL_JoystickGetDeviceName(int device_index) +static const char *VIRTUAL_JoystickGetDeviceName(int device_index) { joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); if (hwdata == NULL) { @@ -375,23 +352,17 @@ VIRTUAL_JoystickGetDeviceName(int device_index) return hwdata->name; } - -static const char * -VIRTUAL_JoystickGetDevicePath(int device_index) +static const char *VIRTUAL_JoystickGetDevicePath(int device_index) { return NULL; } - -static int -VIRTUAL_JoystickGetDevicePlayerIndex(int device_index) +static int VIRTUAL_JoystickGetDevicePlayerIndex(int device_index) { return -1; } - -static void -VIRTUAL_JoystickSetDevicePlayerIndex(int device_index, int player_index) +static void VIRTUAL_JoystickSetDevicePlayerIndex(int device_index, int player_index) { joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); @@ -400,9 +371,7 @@ VIRTUAL_JoystickSetDevicePlayerIndex(int device_index, int player_index) } } - -static SDL_JoystickGUID -VIRTUAL_JoystickGetDeviceGUID(int device_index) +static SDL_JoystickGUID VIRTUAL_JoystickGetDeviceGUID(int device_index) { joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); if (hwdata == NULL) { @@ -413,9 +382,7 @@ VIRTUAL_JoystickGetDeviceGUID(int device_index) return hwdata->guid; } - -static SDL_JoystickID -VIRTUAL_JoystickGetDeviceInstanceID(int device_index) +static SDL_JoystickID VIRTUAL_JoystickGetDeviceInstanceID(int device_index) { joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); if (hwdata == NULL) { @@ -424,9 +391,7 @@ VIRTUAL_JoystickGetDeviceInstanceID(int device_index) return hwdata->instance_id; } - -static int -VIRTUAL_JoystickOpen(SDL_Joystick *joystick, int device_index) +static int VIRTUAL_JoystickOpen(SDL_Joystick *joystick, int device_index) { joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); if (hwdata == NULL) { @@ -441,9 +406,7 @@ VIRTUAL_JoystickOpen(SDL_Joystick *joystick, int device_index) return 0; } - -static int -VIRTUAL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int VIRTUAL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { int result; @@ -461,8 +424,7 @@ VIRTUAL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint return result; } -static int -VIRTUAL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int VIRTUAL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { int result; @@ -480,9 +442,7 @@ VIRTUAL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint1 return result; } - -static Uint32 -VIRTUAL_JoystickGetCapabilities(SDL_Joystick *joystick) +static Uint32 VIRTUAL_JoystickGetCapabilities(SDL_Joystick *joystick) { joystick_hwdata *hwdata = joystick->hwdata; Uint32 caps = 0; @@ -501,9 +461,7 @@ VIRTUAL_JoystickGetCapabilities(SDL_Joystick *joystick) return caps; } - -static int -VIRTUAL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int VIRTUAL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { int result; @@ -521,8 +479,7 @@ VIRTUAL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blu return result; } -static int -VIRTUAL_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) +static int VIRTUAL_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) { int result; @@ -540,15 +497,12 @@ VIRTUAL_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) return result; } -static int -VIRTUAL_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int VIRTUAL_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } - -static void -VIRTUAL_JoystickUpdate(SDL_Joystick *joystick) +static void VIRTUAL_JoystickUpdate(SDL_Joystick *joystick) { joystick_hwdata *hwdata; int i; @@ -577,9 +531,7 @@ VIRTUAL_JoystickUpdate(SDL_Joystick *joystick) } } - -static void -VIRTUAL_JoystickClose(SDL_Joystick *joystick) +static void VIRTUAL_JoystickClose(SDL_Joystick *joystick) { if (joystick->hwdata) { joystick_hwdata *hwdata = joystick->hwdata; @@ -588,17 +540,14 @@ VIRTUAL_JoystickClose(SDL_Joystick *joystick) } } - -static void -VIRTUAL_JoystickQuit(void) +static void VIRTUAL_JoystickQuit(void) { while (g_VJoys) { VIRTUAL_FreeHWData(g_VJoys); } } -static SDL_bool -VIRTUAL_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static SDL_bool VIRTUAL_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); int current_button = 0; @@ -741,8 +690,7 @@ VIRTUAL_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) return SDL_TRUE; } -SDL_JoystickDriver SDL_VIRTUAL_JoystickDriver = -{ +SDL_JoystickDriver SDL_VIRTUAL_JoystickDriver = { VIRTUAL_JoystickInit, VIRTUAL_JoystickGetCount, VIRTUAL_JoystickDetect, diff --git a/src/joystick/virtual/SDL_virtualjoystick_c.h b/src/joystick/virtual/SDL_virtualjoystick_c.h index 5e15f1dd6..18b03a0e1 100644 --- a/src/joystick/virtual/SDL_virtualjoystick_c.h +++ b/src/joystick/virtual/SDL_virtualjoystick_c.h @@ -49,12 +49,12 @@ typedef struct joystick_hwdata int SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *desc); int SDL_JoystickDetachVirtualInner(int device_index); -int SDL_JoystickSetVirtualAxisInner(SDL_Joystick * joystick, int axis, Sint16 value); -int SDL_JoystickSetVirtualButtonInner(SDL_Joystick * joystick, int button, Uint8 value); -int SDL_JoystickSetVirtualHatInner(SDL_Joystick * joystick, int hat, Uint8 value); +int SDL_JoystickSetVirtualAxisInner(SDL_Joystick *joystick, int axis, Sint16 value); +int SDL_JoystickSetVirtualButtonInner(SDL_Joystick *joystick, int button, Uint8 value); +int SDL_JoystickSetVirtualHatInner(SDL_Joystick *joystick, int hat, Uint8 value); -#endif /* SDL_JOYSTICK_VIRTUAL */ +#endif /* SDL_JOYSTICK_VIRTUAL */ -#endif /* SDL_VIRTUALJOYSTICK_C_H */ +#endif /* SDL_VIRTUALJOYSTICK_C_H */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/joystick/vita/SDL_sysjoystick.c b/src/joystick/vita/SDL_sysjoystick.c index c5dc86270..d2f936a55 100644 --- a/src/joystick/vita/SDL_sysjoystick.c +++ b/src/joystick/vita/SDL_sysjoystick.c @@ -27,7 +27,7 @@ #include #include -#include /* For the definition of NULL */ +#include /* For the definition of NULL */ #include #include "../SDL_sysjoystick.h" @@ -45,7 +45,7 @@ static SceCtrlData pad1 = { .lx = 0, .ly = 0, .rx = 0, .ry = 0, .lt = 0, .rt = 0 static SceCtrlData pad2 = { .lx = 0, .ly = 0, .rx = 0, .ry = 0, .lt = 0, .rt = 0, .buttons = 0 }; static SceCtrlData pad3 = { .lx = 0, .ly = 0, .rx = 0, .ry = 0, .lt = 0, .rt = 0, .buttons = 0 }; -static int ext_port_map[4]= { 1, 2, 3, 4 }; //index: SDL joy number, entry: Vita port number. For external controllers +static int ext_port_map[4] = { 1, 2, 3, 4 }; // index: SDL joy number, entry: Vita port number. For external controllers static int SDL_numjoysticks = 1; @@ -68,23 +68,23 @@ static const unsigned int ext_button_map[] = { SCE_CTRL_R3 }; -static int analog_map[256]; /* Map analog inputs to -32768 -> 32767 */ +static int analog_map[256]; /* Map analog inputs to -32768 -> 32767 */ typedef struct { - int x; - int y; + int x; + int y; } point; /* 4 points define the bezier-curve. */ /* The Vita has a good amount of analog travel, so use a linear curve */ static point a = { 0, 0 }; -static point b = { 0, 0 }; +static point b = { 0, 0 }; static point c = { 128, 32767 }; static point d = { 128, 32767 }; /* simple linear interpolation between two points */ -static SDL_INLINE void lerp (point *dest, point *first, point *second, float t) +static SDL_INLINE void lerp(point *dest, point *first, point *second, float t) { dest->x = first->x + (second->x - first->x) * t; dest->y = first->y + (second->y - first->y) * t; @@ -94,12 +94,12 @@ static SDL_INLINE void lerp (point *dest, point *first, point *second, float t) static int calc_bezier_y(float t) { point ab, bc, cd, abbc, bccd, dest; - lerp (&ab, &a, &b, t); /* point between a and b */ - lerp (&bc, &b, &c, t); /* point between b and c */ - lerp (&cd, &c, &d, t); /* point between c and d */ - lerp (&abbc, &ab, &bc, t); /* point between ab and bc */ - lerp (&bccd, &bc, &cd, t); /* point between bc and cd */ - lerp (&dest, &abbc, &bccd, t); /* point on the bezier-curve */ + lerp(&ab, &a, &b, t); /* point between a and b */ + lerp(&bc, &b, &c, t); /* point between b and c */ + lerp(&cd, &c, &d, t); /* point between c and d */ + lerp(&abbc, &ab, &bc, t); /* point between ab and bc */ + lerp(&bccd, &bc, &cd, t); /* point between bc and cd */ + lerp(&dest, &abbc, &bccd, t); /* point on the bezier-curve */ return dest.y; } @@ -119,9 +119,9 @@ int VITA_JoystickInit(void) /* Create an accurate map from analog inputs (0 to 255) to SDL joystick positions (-32768 to 32767) */ for (i = 0; i < 128; i++) { - float t = (float)i/127.0f; - analog_map[i+128] = calc_bezier_y(t); - analog_map[127-i] = -1 * analog_map[i+128]; + float t = (float)i / 127.0f; + analog_map[i + 128] = calc_bezier_y(t); + analog_map[127 - i] = -1 * analog_map[i + 128]; } // Assume we have at least one controller, even when nothing is paired @@ -136,8 +136,8 @@ int VITA_JoystickInit(void) // On Vita TV, port 0 and 1 are the same controller // and that is the first one, so start at port 2 - for (i=2; i<=4; i++) { - if (myPortInfo.port[i]!=SCE_CTRL_TYPE_UNPAIRED) { + for (i = 2; i <= 4; i++) { + if (myPortInfo.port[i] != SCE_CTRL_TYPE_UNPAIRED) { SDL_PrivateJoystickAdded(SDL_numjoysticks); SDL_numjoysticks++; } @@ -187,14 +187,12 @@ const char *VITA_JoystickGetDevicePath(int index) return NULL; } -static int -VITA_JoystickGetDevicePlayerIndex(int device_index) +static int VITA_JoystickGetDevicePlayerIndex(int device_index) { return -1; } -static void -VITA_JoystickSetDevicePlayerIndex(int device_index, int player_index) +static void VITA_JoystickSetDevicePlayerIndex(int device_index, int player_index) { } @@ -233,13 +231,18 @@ static void VITA_JoystickUpdate(SDL_Joystick *joystick) static unsigned char old_rt[] = { 0, 0, 0, 0 }; SceCtrlData *pad = NULL; - int index = (int) SDL_JoystickInstanceID(joystick); + int index = (int)SDL_JoystickInstanceID(joystick); - if (index == 0) pad = &pad0; - else if (index == 1) pad = &pad1; - else if (index == 2) pad = &pad2; - else if (index == 3) pad = &pad3; - else return; + if (index == 0) + pad = &pad0; + else if (index == 1) + pad = &pad1; + else if (index == 2) + pad = &pad2; + else if (index == 3) + pad = &pad3; + else + return; if (index == 0) { if (sceCtrlPeekBufferPositive2(ext_port_map[index], pad, 1) < 0) { @@ -296,8 +299,7 @@ static void VITA_JoystickUpdate(SDL_Joystick *joystick) if (changed & ext_button_map[i]) { SDL_PrivateJoystickButton( joystick, i, - (buttons & ext_button_map[i]) ? - SDL_PRESSED : SDL_RELEASED); + (buttons & ext_button_map[i]) ? SDL_PRESSED : SDL_RELEASED); } } } @@ -320,10 +322,9 @@ SDL_JoystickGUID VITA_JoystickGetDeviceGUID(int device_index) return SDL_CreateJoystickGUIDForName(name); } -static int -VITA_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int VITA_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { - int index = (int) SDL_JoystickInstanceID(joystick); + int index = (int)SDL_JoystickInstanceID(joystick); SceCtrlActuator act; SDL_zero(act); @@ -335,50 +336,42 @@ VITA_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 return 0; } -static int -VITA_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left, Uint16 right) +static int VITA_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left, Uint16 right) { return SDL_Unsupported(); } -static Uint32 -VITA_JoystickGetCapabilities(SDL_Joystick *joystick) +static Uint32 VITA_JoystickGetCapabilities(SDL_Joystick *joystick) { // always return LED and rumble supported for now return SDL_JOYCAP_LED | SDL_JOYCAP_RUMBLE; } - -static int -VITA_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int VITA_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { - int index = (int) SDL_JoystickInstanceID(joystick); + int index = (int)SDL_JoystickInstanceID(joystick); if (sceCtrlSetLightBar(ext_port_map[index], red, green, blue) < 0) { return SDL_Unsupported(); } return 0; } -static int -VITA_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) +static int VITA_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -VITA_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int VITA_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } -static SDL_bool -VITA_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static SDL_bool VITA_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { return SDL_FALSE; } -SDL_JoystickDriver SDL_VITA_JoystickDriver = -{ +SDL_JoystickDriver SDL_VITA_JoystickDriver = { VITA_JoystickInit, VITA_JoystickGetCount, VITA_JoystickDetect, diff --git a/src/joystick/windows/SDL_dinputjoystick.c b/src/joystick/windows/SDL_dinputjoystick.c index 7d1bd6d30..b911164e8 100644 --- a/src/joystick/windows/SDL_dinputjoystick.c +++ b/src/joystick/windows/SDL_dinputjoystick.c @@ -33,13 +33,13 @@ #include "../hidapi/SDL_hidapijoystick_c.h" #ifndef DIDFT_OPTIONAL -#define DIDFT_OPTIONAL 0x80000000 +#define DIDFT_OPTIONAL 0x80000000 #endif -#define INPUT_QSIZE 128 /* Buffer up to 128 input messages */ -#define JOY_AXIS_THRESHOLD (((SDL_JOYSTICK_AXIS_MAX)-(SDL_JOYSTICK_AXIS_MIN))/100) /* 1% motion */ +#define INPUT_QSIZE 128 /* Buffer up to 128 input messages */ +#define JOY_AXIS_THRESHOLD (((SDL_JOYSTICK_AXIS_MAX) - (SDL_JOYSTICK_AXIS_MIN)) / 100) /* 1% motion */ -#define CONVERT_MAGNITUDE(x) (((x)*10000) / 0x7FFF) +#define CONVERT_MAGNITUDE(x) (((x)*10000) / 0x7FFF) /* external variables referenced. */ #ifdef SDL_VIDEO_DRIVER_WINDOWS @@ -233,14 +233,12 @@ const DIDATAFORMAT SDL_c_dfDIJoystick2 = { }; /* Convert a DirectInput return code to a text message */ -static int -SetDIerror(const char *function, HRESULT code) +static int SetDIerror(const char *function, HRESULT code) { return SDL_SetError("%s() DirectX error 0x%8.8lx", function, code); } -static SDL_bool -SDL_IsXInputDevice(Uint16 vendor_id, Uint16 product_id, const char* hidPath) +static SDL_bool SDL_IsXInputDevice(Uint16 vendor_id, Uint16 product_id, const char *hidPath) { #ifdef SDL_JOYSTICK_XINPUT SDL_GameControllerType type; @@ -250,7 +248,7 @@ SDL_IsXInputDevice(Uint16 vendor_id, Uint16 product_id, const char* hidPath) #ifdef SDL_JOYSTICK_RAWINPUT && !RAWINPUT_IsEnabled() #endif - ) { + ) { return SDL_FALSE; } @@ -271,8 +269,7 @@ SDL_IsXInputDevice(Uint16 vendor_id, Uint16 product_id, const char* hidPath) return SDL_FALSE; } -static SDL_bool -QueryDeviceName(LPDIRECTINPUTDEVICE8 device, char** device_name) +static SDL_bool QueryDeviceName(LPDIRECTINPUTDEVICE8 device, char **device_name) { DIPROPSTRING dipstr; @@ -294,8 +291,7 @@ QueryDeviceName(LPDIRECTINPUTDEVICE8 device, char** device_name) return SDL_TRUE; } -static SDL_bool -QueryDevicePath(LPDIRECTINPUTDEVICE8 device, char** device_path) +static SDL_bool QueryDevicePath(LPDIRECTINPUTDEVICE8 device, char **device_path) { DIPROPGUIDANDPATH dippath; @@ -320,8 +316,7 @@ QueryDevicePath(LPDIRECTINPUTDEVICE8 device, char** device_path) return SDL_TRUE; } -static SDL_bool -QueryDeviceInfo(LPDIRECTINPUTDEVICE8 device, Uint16* vendor_id, Uint16* product_id) +static SDL_bool QueryDeviceInfo(LPDIRECTINPUTDEVICE8 device, Uint16 *vendor_id, Uint16 *product_id) { DIPROPDWORD dipdw; @@ -400,8 +395,7 @@ DIEFFECT *CreateRumbleEffectData(Sint16 magnitude) return effect; } -int -SDL_DINPUT_JoystickInit(void) +int SDL_DINPUT_JoystickInit(void) { HRESULT result; HINSTANCE instance; @@ -420,7 +414,7 @@ SDL_DINPUT_JoystickInit(void) coinitialized = SDL_TRUE; result = CoCreateInstance(&CLSID_DirectInput8, NULL, CLSCTX_INPROC_SERVER, - &IID_IDirectInput8, (LPVOID *)&dinput); + &IID_IDirectInput8, (LPVOID *)&dinput); if (FAILED(result)) { return SetDIerror("CoCreateInstance", result); @@ -444,10 +438,13 @@ SDL_DINPUT_JoystickInit(void) } /* helper function for direct input, gets called for each connected joystick */ -static BOOL CALLBACK -EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInstance, LPVOID pContext) +static BOOL CALLBACK EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInstance, LPVOID pContext) { -#define CHECK(expression) { if (!(expression)) goto err; } +#define CHECK(expression) \ + { \ + if (!(expression)) \ + goto err; \ + } JoyStick_DeviceData *pNewJoystick = NULL; JoyStick_DeviceData *pPrevJoystick = NULL; Uint16 vendor = 0; @@ -467,13 +464,13 @@ EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInstance, LPVOID pContext) CHECK(!SDL_IsXInputDevice(vendor, product, hidPath)); - pNewJoystick = *(JoyStick_DeviceData**)pContext; + pNewJoystick = *(JoyStick_DeviceData **)pContext; while (pNewJoystick) { /* update GUIDs of joysticks with matching paths, in case they're not open yet */ if (SDL_strcmp(pNewJoystick->path, hidPath) == 0) { /* if we are replacing the front of the list then update it */ - if (pNewJoystick == *(JoyStick_DeviceData**)pContext) { - *(JoyStick_DeviceData**)pContext = pNewJoystick->pNext; + if (pNewJoystick == *(JoyStick_DeviceData **)pContext) { + *(JoyStick_DeviceData **)pContext = pNewJoystick->pNext; } else if (pPrevJoystick) { pPrevJoystick->pNext = pNewJoystick->pNext; } @@ -538,8 +535,7 @@ err: #undef CHECK } -void -SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext) +void SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext) { if (dinput == NULL) { return; @@ -556,10 +552,13 @@ typedef struct SDL_bool present; } Joystick_PresentData; -static BOOL CALLBACK -EnumJoystickPresentCallback(LPCDIDEVICEINSTANCE pDeviceInstance, LPVOID pContext) +static BOOL CALLBACK EnumJoystickPresentCallback(LPCDIDEVICEINSTANCE pDeviceInstance, LPVOID pContext) { -#define CHECK(expression) { if (!(expression)) goto err; } +#define CHECK(expression) \ + { \ + if (!(expression)) \ + goto err; \ + } Joystick_PresentData *pData = (Joystick_PresentData *)pContext; Uint16 vendor = 0; Uint16 product = 0; @@ -602,8 +601,7 @@ SDL_DINPUT_JoystickPresent(Uint16 vendor_id, Uint16 product_id, Uint16 version_n return data.present; } -static BOOL CALLBACK -EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE pDeviceObject, LPVOID pContext) +static BOOL CALLBACK EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE pDeviceObject, LPVOID pContext) { SDL_Joystick *joystick = (SDL_Joystick *)pContext; HRESULT result; @@ -653,9 +651,9 @@ EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE pDeviceObject, LPVOID pContext) result = IDirectInputDevice8_SetProperty(joystick->hwdata->InputDevice, - DIPROP_RANGE, &diprg.diph); + DIPROP_RANGE, &diprg.diph); if (FAILED(result)) { - return DIENUM_CONTINUE; /* don't use this axis */ + return DIENUM_CONTINUE; /* don't use this axis */ } /* Set dead zone to 0. */ @@ -666,9 +664,9 @@ EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE pDeviceObject, LPVOID pContext) dilong.dwData = 0; result = IDirectInputDevice8_SetProperty(joystick->hwdata->InputDevice, - DIPROP_DEADZONE, &dilong.diph); + DIPROP_DEADZONE, &dilong.diph); if (FAILED(result)) { - return DIENUM_CONTINUE; /* don't use this axis */ + return DIENUM_CONTINUE; /* don't use this axis */ } joystick->naxes++; @@ -680,7 +678,7 @@ EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE pDeviceObject, LPVOID pContext) joystick->hwdata->NumInputs++; if (joystick->hwdata->NumInputs == MAX_INPUTS) { - return DIENUM_STOP; /* too many */ + return DIENUM_STOP; /* too many */ } return DIENUM_CONTINUE; @@ -689,11 +687,10 @@ EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE pDeviceObject, LPVOID pContext) /* Sort using the data offset into the DInput struct. * This gives a reasonable ordering for the inputs. */ -static int SDLCALL -SortDevFunc(const void *a, const void *b) +static int SDLCALL SortDevFunc(const void *a, const void *b) { - const input_t *inputA = (const input_t*)a; - const input_t *inputB = (const input_t*)b; + const input_t *inputA = (const input_t *)a; + const input_t *inputB = (const input_t *)b; if (inputA->ofs < inputB->ofs) { return -1; @@ -705,8 +702,7 @@ SortDevFunc(const void *a, const void *b) } /* Sort the input objects and recalculate the indices for each input. */ -static void -SortDevObjects(SDL_Joystick *joystick) +static void SortDevObjects(SDL_Joystick *joystick) { input_t *inputs = joystick->hwdata->Inputs; int nButtons = 0; @@ -736,8 +732,7 @@ SortDevObjects(SDL_Joystick *joystick) } } -int -SDL_DINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice) +int SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystickdevice) { HRESULT result; DIPROPDWORD dipdw; @@ -751,20 +746,19 @@ SDL_DINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickde result = IDirectInput8_CreateDevice(dinput, - &joystickdevice->dxdevice.guidInstance, - &joystick->hwdata->InputDevice, - NULL); + &joystickdevice->dxdevice.guidInstance, + &joystick->hwdata->InputDevice, + NULL); if (FAILED(result)) { return SetDIerror("IDirectInput::CreateDevice", result); } /* Acquire shared access. Exclusive access is required for forces, - * though. */ + * though. */ result = - IDirectInputDevice8_SetCooperativeLevel(joystick->hwdata-> - InputDevice, SDL_HelperWindow, - DISCL_EXCLUSIVE | - DISCL_BACKGROUND); + IDirectInputDevice8_SetCooperativeLevel(joystick->hwdata->InputDevice, SDL_HelperWindow, + DISCL_EXCLUSIVE | + DISCL_BACKGROUND); if (FAILED(result)) { return SetDIerror("IDirectInputDevice8::SetCooperativeLevel", result); } @@ -772,7 +766,7 @@ SDL_DINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickde /* Use the extended data structure: DIJOYSTATE2. */ result = IDirectInputDevice8_SetDataFormat(joystick->hwdata->InputDevice, - &SDL_c_dfDIJoystick2); + &SDL_c_dfDIJoystick2); if (FAILED(result)) { return SetDIerror("IDirectInputDevice8::SetDataFormat", result); } @@ -780,7 +774,7 @@ SDL_DINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickde /* Get device capabilities */ result = IDirectInputDevice8_GetCapabilities(joystick->hwdata->InputDevice, - &joystick->hwdata->Capabilities); + &joystick->hwdata->Capabilities); if (FAILED(result)) { return SetDIerror("IDirectInputDevice8::GetCapabilities", result); } @@ -794,9 +788,8 @@ SDL_DINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickde /* reset all actuators. */ result = - IDirectInputDevice8_SendForceFeedbackCommand(joystick->hwdata-> - InputDevice, - DISFFC_RESET); + IDirectInputDevice8_SendForceFeedbackCommand(joystick->hwdata->InputDevice, + DISFFC_RESET); /* Not necessarily supported, ignore if not supported. if (FAILED(result)) { @@ -811,14 +804,14 @@ SDL_DINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickde } /* Turn on auto-centering for a ForceFeedback device (until told - * otherwise). */ + * otherwise). */ dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; dipdw.dwData = DIPROPAUTOCENTER_ON; result = IDirectInputDevice8_SetProperty(joystick->hwdata->InputDevice, - DIPROP_AUTOCENTER, &dipdw.diph); + DIPROP_AUTOCENTER, &dipdw.diph); /* Not necessarily supported, ignore if not supported. if (FAILED(result)) { @@ -829,11 +822,11 @@ SDL_DINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickde /* What buttons and axes does it have? */ IDirectInputDevice8_EnumObjects(joystick->hwdata->InputDevice, - EnumDevObjectsCallback, joystick, - DIDFT_BUTTON | DIDFT_AXIS | DIDFT_POV); + EnumDevObjectsCallback, joystick, + DIDFT_BUTTON | DIDFT_AXIS | DIDFT_POV); /* Reorder the input objects. Some devices do not report the X axis as - * the first axis, for example. */ + * the first axis, for example. */ SortDevObjects(joystick); dipdw.diph.dwObj = 0; @@ -843,7 +836,7 @@ SDL_DINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickde /* Set the buffer size */ result = IDirectInputDevice8_SetProperty(joystick->hwdata->InputDevice, - DIPROP_BUFFERSIZE, &dipdw.diph); + DIPROP_BUFFERSIZE, &dipdw.diph); if (result == DI_POLLEDDEVICE) { /* This device doesn't support buffering, so we're forced @@ -864,8 +857,7 @@ SDL_DINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickde return 0; } -static int -SDL_DINPUT_JoystickInitRumble(SDL_Joystick * joystick, Sint16 magnitude) +static int SDL_DINPUT_JoystickInitRumble(SDL_Joystick *joystick, Sint16 magnitude) { HRESULT result; @@ -900,8 +892,7 @@ SDL_DINPUT_JoystickInitRumble(SDL_Joystick * joystick, Sint16 magnitude) return 0; } -int -SDL_DINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +int SDL_DINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { HRESULT result; @@ -947,7 +938,7 @@ SDL_DINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, } Uint32 -SDL_DINPUT_JoystickGetCapabilities(SDL_Joystick * joystick) +SDL_DINPUT_JoystickGetCapabilities(SDL_Joystick *joystick) { Uint32 result = 0; @@ -958,8 +949,7 @@ SDL_DINPUT_JoystickGetCapabilities(SDL_Joystick * joystick) return result; } -static Uint8 -TranslatePOV(DWORD value) +static Uint8 TranslatePOV(DWORD value) { const int HAT_VALS[] = { SDL_HAT_UP, @@ -993,8 +983,7 @@ TranslatePOV(DWORD value) * but instead should call SDL_PrivateJoystick*() to deliver events * and update joystick device state. */ -static void -UpdateDINPUTJoystickState_Polled(SDL_Joystick * joystick) +static void UpdateDINPUTJoystickState_Polled(SDL_Joystick *joystick) { DIJOYSTATE2 state; HRESULT result; @@ -1002,12 +991,12 @@ UpdateDINPUTJoystickState_Polled(SDL_Joystick * joystick) result = IDirectInputDevice8_GetDeviceState(joystick->hwdata->InputDevice, - sizeof(DIJOYSTATE2), &state); + sizeof(DIJOYSTATE2), &state); if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) { IDirectInputDevice8_Acquire(joystick->hwdata->InputDevice); result = IDirectInputDevice8_GetDeviceState(joystick->hwdata->InputDevice, - sizeof(DIJOYSTATE2), &state); + sizeof(DIJOYSTATE2), &state); } if (result != DI_OK) { @@ -1050,7 +1039,7 @@ UpdateDINPUTJoystickState_Polled(SDL_Joystick * joystick) case BUTTON: SDL_PrivateJoystickButton(joystick, in->num, - (Uint8)(state.rgbButtons[in->ofs - DIJOFS_BUTTON0] ? SDL_PRESSED : SDL_RELEASED)); + (Uint8)(state.rgbButtons[in->ofs - DIJOFS_BUTTON0] ? SDL_PRESSED : SDL_RELEASED)); break; case HAT: { @@ -1062,8 +1051,7 @@ UpdateDINPUTJoystickState_Polled(SDL_Joystick * joystick) } } -static void -UpdateDINPUTJoystickState_Buffered(SDL_Joystick * joystick) +static void UpdateDINPUTJoystickState_Buffered(SDL_Joystick *joystick) { int i; HRESULT result; @@ -1073,14 +1061,14 @@ UpdateDINPUTJoystickState_Buffered(SDL_Joystick * joystick) numevents = INPUT_QSIZE; result = IDirectInputDevice8_GetDeviceData(joystick->hwdata->InputDevice, - sizeof(DIDEVICEOBJECTDATA), evtbuf, - &numevents, 0); + sizeof(DIDEVICEOBJECTDATA), evtbuf, + &numevents, 0); if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) { IDirectInputDevice8_Acquire(joystick->hwdata->InputDevice); result = IDirectInputDevice8_GetDeviceData(joystick->hwdata->InputDevice, - sizeof(DIDEVICEOBJECTDATA), - evtbuf, &numevents, 0); + sizeof(DIDEVICEOBJECTDATA), + evtbuf, &numevents, 0); } /* Handle the events or punt */ @@ -1104,14 +1092,13 @@ UpdateDINPUTJoystickState_Buffered(SDL_Joystick * joystick) break; case BUTTON: SDL_PrivateJoystickButton(joystick, in->num, - (Uint8)(evtbuf[i].dwData ? SDL_PRESSED : SDL_RELEASED)); + (Uint8)(evtbuf[i].dwData ? SDL_PRESSED : SDL_RELEASED)); break; case HAT: - { - Uint8 pos = TranslatePOV(evtbuf[i].dwData); - SDL_PrivateJoystickHat(joystick, in->num, pos); - } - break; + { + Uint8 pos = TranslatePOV(evtbuf[i].dwData); + SDL_PrivateJoystickHat(joystick, in->num, pos); + } break; } } } @@ -1124,8 +1111,7 @@ UpdateDINPUTJoystickState_Buffered(SDL_Joystick * joystick) } } -void -SDL_DINPUT_JoystickUpdate(SDL_Joystick * joystick) +void SDL_DINPUT_JoystickUpdate(SDL_Joystick *joystick) { HRESULT result; @@ -1142,8 +1128,7 @@ SDL_DINPUT_JoystickUpdate(SDL_Joystick * joystick) } } -void -SDL_DINPUT_JoystickClose(SDL_Joystick * joystick) +void SDL_DINPUT_JoystickClose(SDL_Joystick *joystick) { if (joystick->hwdata->ffeffect_ref) { IDirectInputEffect_Unload(joystick->hwdata->ffeffect_ref); @@ -1158,8 +1143,7 @@ SDL_DINPUT_JoystickClose(SDL_Joystick * joystick) joystick->hwdata->ff_initialized = SDL_FALSE; } -void -SDL_DINPUT_JoystickQuit(void) +void SDL_DINPUT_JoystickQuit(void) { if (dinput != NULL) { IDirectInput8_Release(dinput); @@ -1176,14 +1160,12 @@ SDL_DINPUT_JoystickQuit(void) typedef struct JoyStick_DeviceData JoyStick_DeviceData; -int -SDL_DINPUT_JoystickInit(void) +int SDL_DINPUT_JoystickInit(void) { return 0; } -void -SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext) +void SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext) { } @@ -1193,36 +1175,31 @@ SDL_DINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version) return SDL_FALSE; } -int -SDL_DINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice) +int SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystickdevice) { return SDL_Unsupported(); } -int -SDL_DINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +int SDL_DINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { return SDL_Unsupported(); } Uint32 -SDL_DINPUT_JoystickGetCapabilities(SDL_Joystick * joystick) +SDL_DINPUT_JoystickGetCapabilities(SDL_Joystick *joystick) { return 0; } -void -SDL_DINPUT_JoystickUpdate(SDL_Joystick * joystick) +void SDL_DINPUT_JoystickUpdate(SDL_Joystick *joystick) { } -void -SDL_DINPUT_JoystickClose(SDL_Joystick * joystick) +void SDL_DINPUT_JoystickClose(SDL_Joystick *joystick) { } -void -SDL_DINPUT_JoystickQuit(void) +void SDL_DINPUT_JoystickQuit(void) { } diff --git a/src/joystick/windows/SDL_dinputjoystick_c.h b/src/joystick/windows/SDL_dinputjoystick_c.h index 229569ec1..43052121a 100644 --- a/src/joystick/windows/SDL_dinputjoystick_c.h +++ b/src/joystick/windows/SDL_dinputjoystick_c.h @@ -28,11 +28,11 @@ extern "C" { extern int SDL_DINPUT_JoystickInit(void); extern void SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext); extern SDL_bool SDL_DINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version); -extern int SDL_DINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice); -extern int SDL_DINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); -extern Uint32 SDL_DINPUT_JoystickGetCapabilities(SDL_Joystick * joystick); -extern void SDL_DINPUT_JoystickUpdate(SDL_Joystick * joystick); -extern void SDL_DINPUT_JoystickClose(SDL_Joystick * joystick); +extern int SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystickdevice); +extern int SDL_DINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); +extern Uint32 SDL_DINPUT_JoystickGetCapabilities(SDL_Joystick *joystick); +extern void SDL_DINPUT_JoystickUpdate(SDL_Joystick *joystick); +extern void SDL_DINPUT_JoystickClose(SDL_Joystick *joystick); extern void SDL_DINPUT_JoystickQuit(void); /* Ends C function definitions when using C++ */ diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c index 2583a8400..18558e17c 100644 --- a/src/joystick/windows/SDL_rawinputjoystick.c +++ b/src/joystick/windows/SDL_rawinputjoystick.c @@ -77,22 +77,21 @@ typedef struct WindowsGamingInputGamepadState WindowsGamingInputGamepadState; /*#define DEBUG_RAWINPUT*/ #ifndef RIDEV_EXINPUTSINK -#define RIDEV_EXINPUTSINK 0x00001000 -#define RIDEV_DEVNOTIFY 0x00002000 +#define RIDEV_EXINPUTSINK 0x00001000 +#define RIDEV_DEVNOTIFY 0x00002000 #endif #ifndef WM_INPUT_DEVICE_CHANGE -#define WM_INPUT_DEVICE_CHANGE 0x00FE +#define WM_INPUT_DEVICE_CHANGE 0x00FE #endif #ifndef WM_INPUT -#define WM_INPUT 0x00FF +#define WM_INPUT 0x00FF #endif #ifndef GIDC_ARRIVAL -#define GIDC_ARRIVAL 1 -#define GIDC_REMOVAL 2 +#define GIDC_ARRIVAL 1 +#define GIDC_REMOVAL 2 #endif - static SDL_bool SDL_RAWINPUT_inited = SDL_FALSE; static int SDL_RAWINPUT_numjoysticks = 0; @@ -170,13 +169,15 @@ static const Uint16 subscribed_devices[] = { #ifdef SDL_JOYSTICK_RAWINPUT_MATCHING -static struct { +static struct +{ Uint32 last_state_packet; SDL_Joystick *joystick; SDL_Joystick *last_joystick; } guide_button_candidate; -typedef struct WindowsMatchState { +typedef struct WindowsMatchState +{ #ifdef SDL_JOYSTICK_RAWINPUT_MATCH_AXES SHORT match_axes[SDL_JOYSTICK_RAWINPUT_MATCH_COUNT]; #endif @@ -219,11 +220,11 @@ static void RAWINPUT_FillMatchState(WindowsMatchState *state, Uint64 match_state #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT /* Match axes by checking if the distance between the high 4 bits of axis and the 4 bits from match_state is 1 or less */ -#define XInputAxesMatch(gamepad) (\ - (Uint32)(gamepad.sThumbLX - state->match_axes[0] + 0x1000) <= 0x2fff && \ - (Uint32)(~gamepad.sThumbLY - state->match_axes[1] + 0x1000) <= 0x2fff && \ - (Uint32)(gamepad.sThumbRX - state->match_axes[2] + 0x1000) <= 0x2fff && \ - (Uint32)(~gamepad.sThumbRY - state->match_axes[3] + 0x1000) <= 0x2fff) +#define XInputAxesMatch(gamepad) ( \ + (Uint32)(gamepad.sThumbLX - state->match_axes[0] + 0x1000) <= 0x2fff && \ + (Uint32)(~gamepad.sThumbLY - state->match_axes[1] + 0x1000) <= 0x2fff && \ + (Uint32)(gamepad.sThumbRX - state->match_axes[2] + 0x1000) <= 0x2fff && \ + (Uint32)(~gamepad.sThumbRY - state->match_axes[3] + 0x1000) <= 0x2fff) /* Explicit #define XInputAxesMatch(gamepad) (\ SDL_abs((Sint8)((gamepad.sThumbLX & 0xF000) >> 8) - ((match_state & 0x000F0000) >> 12)) <= 0x10 && \ @@ -232,9 +233,9 @@ static void RAWINPUT_FillMatchState(WindowsMatchState *state, Uint64 match_state SDL_abs((Sint8)((~gamepad.sThumbRY & 0xF000) >> 8) - ((match_state & 0xF0000000) >> 24)) <= 0x10) */ /* Can only match trigger values if a single trigger has a value. */ -#define XInputTriggersMatch(gamepad) ( \ - ((state->match_axes[4] == SDL_MIN_SINT16) && (state->match_axes[5] == SDL_MIN_SINT16)) || \ - ((gamepad.bLeftTrigger != 0) && (gamepad.bRightTrigger != 0)) || \ +#define XInputTriggersMatch(gamepad) ( \ + ((state->match_axes[4] == SDL_MIN_SINT16) && (state->match_axes[5] == SDL_MIN_SINT16)) || \ + ((gamepad.bLeftTrigger != 0) && (gamepad.bRightTrigger != 0)) || \ ((Uint32)((((int)gamepad.bLeftTrigger * 257) - 32768) - state->match_axes[4]) <= 0x2fff) || \ ((Uint32)((((int)gamepad.bRightTrigger * 257) - 32768) - state->match_axes[5]) <= 0x2fff)) @@ -265,15 +266,15 @@ static void RAWINPUT_FillMatchState(WindowsMatchState *state, Uint64 match_state #ifdef SDL_JOYSTICK_RAWINPUT_WGI /* Match axes by checking if the distance between the high 4 bits of axis and the 4 bits from match_state is 1 or less */ -#define WindowsGamingInputAxesMatch(gamepad) (\ - (Uint16)(((Sint16)(gamepad.LeftThumbstickX * SDL_MAX_SINT16) & 0xF000) - state->match_axes[0] + 0x1000) <= 0x2fff && \ +#define WindowsGamingInputAxesMatch(gamepad) ( \ + (Uint16)(((Sint16)(gamepad.LeftThumbstickX * SDL_MAX_SINT16) & 0xF000) - state->match_axes[0] + 0x1000) <= 0x2fff && \ (Uint16)((~(Sint16)(gamepad.LeftThumbstickY * SDL_MAX_SINT16) & 0xF000) - state->match_axes[1] + 0x1000) <= 0x2fff && \ (Uint16)(((Sint16)(gamepad.RightThumbstickX * SDL_MAX_SINT16) & 0xF000) - state->match_axes[2] + 0x1000) <= 0x2fff && \ (Uint16)((~(Sint16)(gamepad.RightThumbstickY * SDL_MAX_SINT16) & 0xF000) - state->match_axes[3] + 0x1000) <= 0x2fff) -#define WindowsGamingInputTriggersMatch(gamepad) ( \ - ((state->match_axes[4] == SDL_MIN_SINT16) && (state->match_axes[5] == SDL_MIN_SINT16)) || \ - ((gamepad.LeftTrigger == 0.0f) && (gamepad.RightTrigger == 0.0f)) || \ +#define WindowsGamingInputTriggersMatch(gamepad) ( \ + ((state->match_axes[4] == SDL_MIN_SINT16) && (state->match_axes[5] == SDL_MIN_SINT16)) || \ + ((gamepad.LeftTrigger == 0.0f) && (gamepad.RightTrigger == 0.0f)) || \ ((Uint16)((((int)(gamepad.LeftTrigger * SDL_MAX_UINT16)) - 32768) - state->match_axes[4]) <= 0x2fff) || \ ((Uint16)((((int)(gamepad.RightTrigger * SDL_MAX_UINT16)) - 32768) - state->match_axes[5]) <= 0x2fff)) @@ -301,25 +302,24 @@ static void RAWINPUT_FillMatchState(WindowsMatchState *state, Uint64 match_state state->any_data = SDL_TRUE; } #endif - } #endif /* SDL_JOYSTICK_RAWINPUT_MATCHING */ #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT -static struct { +static struct +{ XINPUT_STATE_EX state; XINPUT_BATTERY_INFORMATION_EX battery; SDL_bool connected; /* Currently has an active XInput device */ - SDL_bool used; /* Is currently mapped to an SDL device */ + SDL_bool used; /* Is currently mapped to an SDL device */ Uint8 correlation_id; } xinput_state[XUSER_MAX_COUNT]; static SDL_bool xinput_device_change = SDL_TRUE; static SDL_bool xinput_state_dirty = SDL_TRUE; -static void -RAWINPUT_UpdateXInput() +static void RAWINPUT_UpdateXInput() { DWORD user_index; if (xinput_device_change) { @@ -346,23 +346,20 @@ RAWINPUT_UpdateXInput() } } -static void -RAWINPUT_MarkXInputSlotUsed(Uint8 xinput_slot) +static void RAWINPUT_MarkXInputSlotUsed(Uint8 xinput_slot) { if (xinput_slot != XUSER_INDEX_ANY) { xinput_state[xinput_slot].used = SDL_TRUE; } } -static void -RAWINPUT_MarkXInputSlotFree(Uint8 xinput_slot) +static void RAWINPUT_MarkXInputSlotFree(Uint8 xinput_slot) { if (xinput_slot != XUSER_INDEX_ANY) { xinput_state[xinput_slot].used = SDL_FALSE; } } -static SDL_bool -RAWINPUT_MissingXInputSlot() +static SDL_bool RAWINPUT_MissingXInputSlot() { int ii; for (ii = 0; ii < SDL_arraysize(xinput_state); ii++) { @@ -373,8 +370,7 @@ RAWINPUT_MissingXInputSlot() return SDL_FALSE; } -static SDL_bool -RAWINPUT_XInputSlotMatches(const WindowsMatchState *state, Uint8 slot_idx) +static SDL_bool RAWINPUT_XInputSlotMatches(const WindowsMatchState *state, Uint8 slot_idx) { if (xinput_state[slot_idx].connected) { WORD xinput_buttons = xinput_state[slot_idx].state.Gamepad.wButtons; @@ -385,16 +381,14 @@ RAWINPUT_XInputSlotMatches(const WindowsMatchState *state, Uint8 slot_idx) #ifdef SDL_JOYSTICK_RAWINPUT_MATCH_TRIGGERS && XInputTriggersMatch(xinput_state[slot_idx].state.Gamepad) #endif - ) { + ) { return SDL_TRUE; } } return SDL_FALSE; } - -static SDL_bool -RAWINPUT_GuessXInputSlot(const WindowsMatchState *state, Uint8 *correlation_id, Uint8 *slot_idx) +static SDL_bool RAWINPUT_GuessXInputSlot(const WindowsMatchState *state, Uint8 *correlation_id, Uint8 *slot_idx) { int user_index; int match_count; @@ -423,17 +417,19 @@ RAWINPUT_GuessXInputSlot(const WindowsMatchState *state, Uint8 *correlation_id, #ifdef SDL_JOYSTICK_RAWINPUT_WGI -typedef struct WindowsGamingInputGamepadState { +typedef struct WindowsGamingInputGamepadState +{ __x_ABI_CWindows_CGaming_CInput_CIGamepad *gamepad; struct __x_ABI_CWindows_CGaming_CInput_CGamepadReading state; RAWINPUT_DeviceContext *correlated_context; - SDL_bool used; /* Is currently mapped to an SDL device */ + SDL_bool used; /* Is currently mapped to an SDL device */ SDL_bool connected; /* Just used during update to track disconnected */ Uint8 correlation_id; struct __x_ABI_CWindows_CGaming_CInput_CGamepadVibration vibration; } WindowsGamingInputGamepadState; -static struct { +static struct +{ WindowsGamingInputGamepadState **per_gamepad; int per_gamepad_count; SDL_bool initialized; @@ -443,22 +439,19 @@ static struct { __x_ABI_CWindows_CGaming_CInput_CIGamepadStatics *gamepad_statics; } wgi_state; -static void -RAWINPUT_MarkWindowsGamingInputSlotUsed(WindowsGamingInputGamepadState *wgi_slot, RAWINPUT_DeviceContext *ctx) +static void RAWINPUT_MarkWindowsGamingInputSlotUsed(WindowsGamingInputGamepadState *wgi_slot, RAWINPUT_DeviceContext *ctx) { wgi_slot->used = SDL_TRUE; wgi_slot->correlated_context = ctx; } -static void -RAWINPUT_MarkWindowsGamingInputSlotFree(WindowsGamingInputGamepadState *wgi_slot) +static void RAWINPUT_MarkWindowsGamingInputSlotFree(WindowsGamingInputGamepadState *wgi_slot) { wgi_slot->used = SDL_FALSE; wgi_slot->correlated_context = NULL; } -static SDL_bool -RAWINPUT_MissingWindowsGamingInputSlot() +static SDL_bool RAWINPUT_MissingWindowsGamingInputSlot() { int ii; for (ii = 0; ii < wgi_state.per_gamepad_count; ii++) { @@ -469,8 +462,7 @@ RAWINPUT_MissingWindowsGamingInputSlot() return SDL_FALSE; } -static void -RAWINPUT_UpdateWindowsGamingInput() +static void RAWINPUT_UpdateWindowsGamingInput() { int ii; if (!wgi_state.gamepad_statics) { @@ -505,7 +497,7 @@ RAWINPUT_UpdateWindowsGamingInput() if (SUCCEEDED(hr)) { SDL_bool found = SDL_FALSE; int jj; - for (jj = 0; jj < wgi_state.per_gamepad_count ; jj++) { + for (jj = 0; jj < wgi_state.per_gamepad_count; jj++) { if (wgi_state.per_gamepad[jj]->gamepad == gamepad) { found = SDL_TRUE; wgi_state.per_gamepad[jj]->connected = SDL_TRUE; @@ -562,8 +554,7 @@ RAWINPUT_UpdateWindowsGamingInput() } } } -static void -RAWINPUT_InitWindowsGamingInput(RAWINPUT_DeviceContext *ctx) +static void RAWINPUT_InitWindowsGamingInput(RAWINPUT_DeviceContext *ctx) { wgi_state.need_device_list_update = SDL_TRUE; wgi_state.ref_count++; @@ -578,8 +569,8 @@ RAWINPUT_InitWindowsGamingInput(RAWINPUT_DeviceContext *ctx) wgi_state.dirty = SDL_TRUE; { - typedef HRESULT (WINAPI *WindowsCreateStringReference_t)(PCWSTR sourceString, UINT32 length, HSTRING_HEADER *hstringHeader, HSTRING* string); - typedef HRESULT (WINAPI *RoGetActivationFactory_t)(HSTRING activatableClassId, REFIID iid, void** factory); + typedef HRESULT(WINAPI * WindowsCreateStringReference_t)(PCWSTR sourceString, UINT32 length, HSTRING_HEADER * hstringHeader, HSTRING * string); + typedef HRESULT(WINAPI * RoGetActivationFactory_t)(HSTRING activatableClassId, REFIID iid, void **factory); #ifdef __WINRT__ WindowsCreateStringReference_t WindowsCreateStringReferenceFunc = WindowsCreateStringReference; @@ -602,26 +593,24 @@ RAWINPUT_InitWindowsGamingInput(RAWINPUT_DeviceContext *ctx) } } -static SDL_bool -RAWINPUT_WindowsGamingInputSlotMatches(const WindowsMatchState *state, WindowsGamingInputGamepadState *slot, SDL_bool xinput_correlated) +static SDL_bool RAWINPUT_WindowsGamingInputSlotMatches(const WindowsMatchState *state, WindowsGamingInputGamepadState *slot, SDL_bool xinput_correlated) { Uint32 wgi_buttons = slot->state.Buttons; if ((wgi_buttons & 0x3FFF) == state->wgi_buttons #ifdef SDL_JOYSTICK_RAWINPUT_MATCH_AXES - && WindowsGamingInputAxesMatch(slot->state) + && WindowsGamingInputAxesMatch(slot->state) #endif #ifdef SDL_JOYSTICK_RAWINPUT_MATCH_TRIGGERS - // Don't try to match WGI triggers if getting values from XInput - && (xinput_correlated || WindowsGamingInputTriggersMatch(slot->state)) + // Don't try to match WGI triggers if getting values from XInput + && (xinput_correlated || WindowsGamingInputTriggersMatch(slot->state)) #endif - ) { + ) { return SDL_TRUE; } return SDL_FALSE; } -static SDL_bool -RAWINPUT_GuessWindowsGamingInputSlot(const WindowsMatchState *state, Uint8 *correlation_id, WindowsGamingInputGamepadState **slot, SDL_bool xinput_correlated) +static SDL_bool RAWINPUT_GuessWindowsGamingInputSlot(const WindowsMatchState *state, Uint8 *correlation_id, WindowsGamingInputGamepadState **slot, SDL_bool xinput_correlated) { int match_count, user_index; @@ -644,8 +633,7 @@ RAWINPUT_GuessWindowsGamingInputSlot(const WindowsMatchState *state, Uint8 *corr return SDL_FALSE; } -static void -RAWINPUT_QuitWindowsGamingInput(RAWINPUT_DeviceContext *ctx) +static void RAWINPUT_QuitWindowsGamingInput(RAWINPUT_DeviceContext *ctx) { wgi_state.need_device_list_update = SDL_TRUE; --wgi_state.ref_count; @@ -670,16 +658,13 @@ RAWINPUT_QuitWindowsGamingInput(RAWINPUT_DeviceContext *ctx) #endif /* SDL_JOYSTICK_RAWINPUT_WGI */ - -static SDL_RAWINPUT_Device * -RAWINPUT_AcquireDevice(SDL_RAWINPUT_Device *device) +static SDL_RAWINPUT_Device *RAWINPUT_AcquireDevice(SDL_RAWINPUT_Device *device) { SDL_AtomicIncRef(&device->refcount); return device; } -static void -RAWINPUT_ReleaseDevice(SDL_RAWINPUT_Device *device) +static void RAWINPUT_ReleaseDevice(SDL_RAWINPUT_Device *device) { #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT if (device->joystick) { @@ -700,8 +685,7 @@ RAWINPUT_ReleaseDevice(SDL_RAWINPUT_Device *device) } } -static SDL_RAWINPUT_Device * -RAWINPUT_DeviceFromHandle(HANDLE hDevice) +static SDL_RAWINPUT_Device *RAWINPUT_DeviceFromHandle(HANDLE hDevice) { SDL_RAWINPUT_Device *curr; @@ -713,10 +697,13 @@ RAWINPUT_DeviceFromHandle(HANDLE hDevice) return NULL; } -static void -RAWINPUT_AddDevice(HANDLE hDevice) +static void RAWINPUT_AddDevice(HANDLE hDevice) { -#define CHECK(expression) { if (!(expression)) goto err; } +#define CHECK(expression) \ + { \ + if (!(expression)) \ + goto err; \ + } SDL_RAWINPUT_Device *device = NULL; SDL_RAWINPUT_Device *curr, *last; RID_DEVICE_INFO rdi; @@ -758,7 +745,7 @@ RAWINPUT_AddDevice(HANDLE hDevice) CHECK(device->preparsed_data = (PHIDP_PREPARSED_DATA)SDL_calloc(size, sizeof(BYTE))); CHECK(GetRawInputDeviceInfoA(hDevice, RIDI_PREPARSEDDATA, device->preparsed_data, &size) != (UINT)-1); - hFile = CreateFileA(dev_name, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); + hFile = CreateFileA(dev_name, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); CHECK(hFile != INVALID_HANDLE_VALUE); { @@ -829,8 +816,7 @@ err: #undef CHECK } -static void -RAWINPUT_DelDevice(SDL_RAWINPUT_Device *device, SDL_bool send_event) +static void RAWINPUT_DelDevice(SDL_RAWINPUT_Device *device, SDL_bool send_event) { SDL_RAWINPUT_Device *curr, *last; for (curr = SDL_RAWINPUT_devices, last = NULL; curr; last = curr, curr = curr->next) { @@ -853,8 +839,7 @@ RAWINPUT_DelDevice(SDL_RAWINPUT_Device *device, SDL_bool send_event) } } -static int -RAWINPUT_JoystickInit(void) +static int RAWINPUT_JoystickInit(void) { UINT device_count = 0; @@ -893,8 +878,7 @@ RAWINPUT_JoystickInit(void) return 0; } -static int -RAWINPUT_JoystickGetCount(void) +static int RAWINPUT_JoystickGetCount(void) { return SDL_RAWINPUT_numjoysticks; } @@ -920,7 +904,7 @@ RAWINPUT_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, co device = SDL_RAWINPUT_devices; while (device) { - if (vendor_id == device->vendor_id && product_id == device->product_id ) { + if (vendor_id == device->vendor_id && product_id == device->product_id) { return SDL_TRUE; } @@ -945,8 +929,7 @@ RAWINPUT_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, co return SDL_FALSE; } -static void -RAWINPUT_PostUpdate(void) +static void RAWINPUT_PostUpdate(void) { #ifdef SDL_JOYSTICK_RAWINPUT_MATCHING SDL_bool unmapped_guide_pressed = SDL_FALSE; @@ -1004,14 +987,12 @@ RAWINPUT_PostUpdate(void) #endif /* SDL_JOYSTICK_RAWINPUT_MATCHING */ } -static void -RAWINPUT_JoystickDetect(void) +static void RAWINPUT_JoystickDetect(void) { RAWINPUT_PostUpdate(); } -static SDL_RAWINPUT_Device * -RAWINPUT_GetDeviceByIndex(int device_index) +static SDL_RAWINPUT_Device *RAWINPUT_GetDeviceByIndex(int device_index) { SDL_RAWINPUT_Device *device = SDL_RAWINPUT_devices; while (device) { @@ -1024,44 +1005,36 @@ RAWINPUT_GetDeviceByIndex(int device_index) return device; } -static const char * -RAWINPUT_JoystickGetDeviceName(int device_index) +static const char *RAWINPUT_JoystickGetDeviceName(int device_index) { return RAWINPUT_GetDeviceByIndex(device_index)->name; } -static const char * -RAWINPUT_JoystickGetDevicePath(int device_index) +static const char *RAWINPUT_JoystickGetDevicePath(int device_index) { return RAWINPUT_GetDeviceByIndex(device_index)->path; } -static int -RAWINPUT_JoystickGetDevicePlayerIndex(int device_index) +static int RAWINPUT_JoystickGetDevicePlayerIndex(int device_index) { return -1; } -static void -RAWINPUT_JoystickSetDevicePlayerIndex(int device_index, int player_index) +static void RAWINPUT_JoystickSetDevicePlayerIndex(int device_index, int player_index) { } - -static SDL_JoystickGUID -RAWINPUT_JoystickGetDeviceGUID(int device_index) +static SDL_JoystickGUID RAWINPUT_JoystickGetDeviceGUID(int device_index) { return RAWINPUT_GetDeviceByIndex(device_index)->guid; } -static SDL_JoystickID -RAWINPUT_JoystickGetDeviceInstanceID(int device_index) +static SDL_JoystickID RAWINPUT_JoystickGetDeviceInstanceID(int device_index) { return RAWINPUT_GetDeviceByIndex(device_index)->joystick_id; } -static int SDLCALL -RAWINPUT_SortValueCaps(const void *A, const void *B) +static int SDLCALL RAWINPUT_SortValueCaps(const void *A, const void *B) { HIDP_VALUE_CAPS *capsA = (HIDP_VALUE_CAPS *)A; HIDP_VALUE_CAPS *capsB = (HIDP_VALUE_CAPS *)B; @@ -1070,8 +1043,7 @@ RAWINPUT_SortValueCaps(const void *A, const void *B) return (int)capsA->NotRange.Usage - capsB->NotRange.Usage; } -static int -RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) +static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) { SDL_RAWINPUT_Device *device = RAWINPUT_GetDeviceByIndex(device_index); RAWINPUT_DeviceContext *ctx; @@ -1265,8 +1237,7 @@ RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) return 0; } -static int -RAWINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int RAWINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { #if defined(SDL_JOYSTICK_RAWINPUT_WGI) || defined(SDL_JOYSTICK_RAWINPUT_XINPUT) RAWINPUT_DeviceContext *ctx = joystick->hwdata; @@ -1314,8 +1285,7 @@ RAWINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uin return 0; } -static int -RAWINPUT_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int RAWINPUT_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { #if defined(SDL_JOYSTICK_RAWINPUT_WGI) RAWINPUT_DeviceContext *ctx = joystick->hwdata; @@ -1338,8 +1308,7 @@ RAWINPUT_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint #endif } -static Uint32 -RAWINPUT_JoystickGetCapabilities(SDL_Joystick *joystick) +static Uint32 RAWINPUT_JoystickGetCapabilities(SDL_Joystick *joystick) { Uint32 result = 0; #if defined(SDL_JOYSTICK_RAWINPUT_XINPUT) || defined(SDL_JOYSTICK_RAWINPUT_WGI) @@ -1364,20 +1333,17 @@ RAWINPUT_JoystickGetCapabilities(SDL_Joystick *joystick) return result; } -static int -RAWINPUT_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int RAWINPUT_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -RAWINPUT_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) +static int RAWINPUT_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -RAWINPUT_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int RAWINPUT_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } @@ -1406,8 +1372,7 @@ static HIDP_DATA *GetData(USHORT index, HIDP_DATA *data, ULONG length) We use XInput and Windows.Gaming.Input to make up for these shortcomings. */ -static void -RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int size) +static void RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int size) { RAWINPUT_DeviceContext *ctx = joystick->hwdata; #ifdef SDL_JOYSTICK_RAWINPUT_MATCHING @@ -1438,11 +1403,22 @@ RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int size) }; Uint64 match_state = ctx->match_state; /* Update match_state with button bit, then fall through */ -#define SDL_PrivateJoystickButton(joystick, button, state) if (button < SDL_arraysize(button_map)) { Uint64 button_bit = 1ull << button_map[button]; match_state = (match_state & ~button_bit) | (button_bit * (state)); } SDL_PrivateJoystickButton(joystick, button, state) +#define SDL_PrivateJoystickButton(joystick, button, state) \ + if (button < SDL_arraysize(button_map)) { \ + Uint64 button_bit = 1ull << button_map[button]; \ + match_state = (match_state & ~button_bit) | (button_bit * (state)); \ + } \ + SDL_PrivateJoystickButton(joystick, button, state) #ifdef SDL_JOYSTICK_RAWINPUT_MATCH_AXES /* Grab high 4 bits of value, then fall through */ -#define AddAxisToMatchState(axis, value) { match_state = (match_state & ~(0xFull << (4 * axis + 16))) | ((value) & 0xF000ull) << (4 * axis + 4); } -#define SDL_PrivateJoystickAxis(joystick, axis, value) if (axis < 4) AddAxisToMatchState(axis, value); SDL_PrivateJoystickAxis(joystick, axis, value) +#define AddAxisToMatchState(axis, value) \ + { \ + match_state = (match_state & ~(0xFull << (4 * axis + 16))) | ((value)&0xF000ull) << (4 * axis + 4); \ + } +#define SDL_PrivateJoystickAxis(joystick, axis, value) \ + if (axis < 4) \ + AddAxisToMatchState(axis, value); \ + SDL_PrivateJoystickAxis(joystick, axis, value) #endif #endif /* SDL_JOYSTICK_RAWINPUT_MATCHING */ @@ -1508,7 +1484,11 @@ RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int size) #endif #ifdef SDL_JOYSTICK_RAWINPUT_MATCH_TRIGGERS -#define AddTriggerToMatchState(axis, value) { int match_axis = axis + SDL_JOYSTICK_RAWINPUT_MATCH_COUNT - joystick->naxes; AddAxisToMatchState(match_axis, value); } +#define AddTriggerToMatchState(axis, value) \ + { \ + int match_axis = axis + SDL_JOYSTICK_RAWINPUT_MATCH_COUNT - joystick->naxes; \ + AddAxisToMatchState(match_axis, value); \ + } #endif /* SDL_JOYSTICK_RAWINPUT_MATCH_TRIGGERS */ if (ctx->trigger_hack) { @@ -1538,7 +1518,7 @@ RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int size) Sint16 value = (int)(Uint16)item->RawValue - 0x8000; Sint16 left_value = (value > 0) ? (value * 2 - 32767) : SDL_MIN_SINT16; Sint16 right_value = (value < 0) ? (-value * 2 - 32769) : SDL_MIN_SINT16; - + #ifdef SDL_JOYSTICK_RAWINPUT_MATCH_TRIGGERS AddTriggerToMatchState(left_trigger, left_value); AddTriggerToMatchState(right_trigger, right_value); @@ -1567,8 +1547,7 @@ RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int size) #endif } -static void -RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) +static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) { #ifdef SDL_JOYSTICK_RAWINPUT_MATCHING RAWINPUT_DeviceContext *ctx = joystick->hwdata; @@ -1585,11 +1564,11 @@ RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) RAWINPUT_FillMatchState(&match_state_xinput, ctx->match_state); #ifdef SDL_JOYSTICK_RAWINPUT_WGI - #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT +#ifdef SDL_JOYSTICK_RAWINPUT_XINPUT xinput_correlated = ctx->xinput_correlated; - #else +#else xinput_correlated = SDL_FALSE; - #endif +#endif /* Parallel logic to WINDOWS_XINPUT below */ RAWINPUT_UpdateWindowsGamingInput(); if (ctx->wgi_correlated && @@ -1815,7 +1794,7 @@ RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) #ifdef SDL_JOYSTICK_RAWINPUT_WGI if (!has_trigger_data && ctx->wgi_correlated) { RAWINPUT_UpdateWindowsGamingInput(); /* May detect disconnect / cause uncorrelation */ - if (ctx->wgi_correlated) { /* Still connected */ + if (ctx->wgi_correlated) { /* Still connected */ struct __x_ABI_CWindows_CGaming_CInput_CGamepadReading *state = &ctx->wgi_slot->state; if (ctx->guide_hack) { @@ -1832,11 +1811,8 @@ RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) if (!correlated) { if (!guide_button_candidate.joystick || - (ctx->last_state_packet && ( - !guide_button_candidate.last_state_packet || - SDL_TICKS_PASSED(ctx->last_state_packet, guide_button_candidate.last_state_packet) - )) - ) { + (ctx->last_state_packet && (!guide_button_candidate.last_state_packet || + SDL_TICKS_PASSED(ctx->last_state_packet, guide_button_candidate.last_state_packet)))) { guide_button_candidate.joystick = joystick; guide_button_candidate.last_state_packet = ctx->last_state_packet; } @@ -1844,14 +1820,12 @@ RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) #endif /* SDL_JOYSTICK_RAWINPUT_MATCHING */ } -static void -RAWINPUT_JoystickUpdate(SDL_Joystick *joystick) +static void RAWINPUT_JoystickUpdate(SDL_Joystick *joystick) { RAWINPUT_UpdateOtherAPIs(joystick); } -static void -RAWINPUT_JoystickClose(SDL_Joystick *joystick) +static void RAWINPUT_JoystickClose(SDL_Joystick *joystick) { RAWINPUT_DeviceContext *ctx = joystick->hwdata; @@ -1916,8 +1890,7 @@ RAWINPUT_RegisterNotifications(HWND hWnd) return SDL_TRUE; } -void -RAWINPUT_UnregisterNotifications() +void RAWINPUT_UnregisterNotifications() { int i; RAWINPUTDEVICE rid[SDL_arraysize(subscribed_devices)]; @@ -1944,45 +1917,45 @@ RAWINPUT_WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) SDL_LockJoysticks(); switch (msg) { - case WM_INPUT_DEVICE_CHANGE: + case WM_INPUT_DEVICE_CHANGE: + { + HANDLE hDevice = (HANDLE)lParam; + switch (wParam) { + case GIDC_ARRIVAL: + RAWINPUT_AddDevice(hDevice); + break; + case GIDC_REMOVAL: { - HANDLE hDevice = (HANDLE)lParam; - switch (wParam) { - case GIDC_ARRIVAL: - RAWINPUT_AddDevice(hDevice); - break; - case GIDC_REMOVAL: - { - SDL_RAWINPUT_Device *device; - device = RAWINPUT_DeviceFromHandle(hDevice); - if (device) { - RAWINPUT_DelDevice(device, SDL_TRUE); - } - break; - } - default: - break; + SDL_RAWINPUT_Device *device; + device = RAWINPUT_DeviceFromHandle(hDevice); + if (device) { + RAWINPUT_DelDevice(device, SDL_TRUE); } + break; } + default: + break; + } + } result = 0; break; - case WM_INPUT: - { - Uint8 data[sizeof(RAWINPUTHEADER) + sizeof(RAWHID) + USB_PACKET_LENGTH]; - UINT buffer_size = SDL_arraysize(data); + case WM_INPUT: + { + Uint8 data[sizeof(RAWINPUTHEADER) + sizeof(RAWHID) + USB_PACKET_LENGTH]; + UINT buffer_size = SDL_arraysize(data); - if ((int)GetRawInputData((HRAWINPUT)lParam, RID_INPUT, data, &buffer_size, sizeof(RAWINPUTHEADER)) > 0) { - PRAWINPUT raw_input = (PRAWINPUT)data; - SDL_RAWINPUT_Device *device = RAWINPUT_DeviceFromHandle(raw_input->header.hDevice); - if (device) { - SDL_Joystick *joystick = device->joystick; - if (joystick) { - RAWINPUT_HandleStatePacket(joystick, raw_input->data.hid.bRawData, raw_input->data.hid.dwSizeHid); - } + if ((int)GetRawInputData((HRAWINPUT)lParam, RID_INPUT, data, &buffer_size, sizeof(RAWINPUTHEADER)) > 0) { + PRAWINPUT raw_input = (PRAWINPUT)data; + SDL_RAWINPUT_Device *device = RAWINPUT_DeviceFromHandle(raw_input->header.hDevice); + if (device) { + SDL_Joystick *joystick = device->joystick; + if (joystick) { + RAWINPUT_HandleStatePacket(joystick, raw_input->data.hid.bRawData, raw_input->data.hid.dwSizeHid); } } } + } result = 0; break; } @@ -1996,8 +1969,7 @@ RAWINPUT_WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) return CallWindowProc(DefWindowProc, hWnd, msg, wParam, lParam); } -static void -RAWINPUT_JoystickQuit(void) +static void RAWINPUT_JoystickQuit(void) { if (!SDL_RAWINPUT_inited) { return; @@ -2014,14 +1986,12 @@ RAWINPUT_JoystickQuit(void) SDL_RAWINPUT_inited = SDL_FALSE; } -static SDL_bool -RAWINPUT_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static SDL_bool RAWINPUT_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { return SDL_FALSE; } -SDL_JoystickDriver SDL_RAWINPUT_JoystickDriver = -{ +SDL_JoystickDriver SDL_RAWINPUT_JoystickDriver = { RAWINPUT_JoystickInit, RAWINPUT_JoystickGetCount, RAWINPUT_JoystickDetect, diff --git a/src/joystick/windows/SDL_rawinputjoystick_c.h b/src/joystick/windows/SDL_rawinputjoystick_c.h index a5d8143e0..fb66c5e70 100644 --- a/src/joystick/windows/SDL_rawinputjoystick_c.h +++ b/src/joystick/windows/SDL_rawinputjoystick_c.h @@ -34,5 +34,4 @@ extern void RAWINPUT_UnregisterNotifications(); /* Returns 0 if message was handled */ extern LRESULT CALLBACK RAWINPUT_WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/joystick/windows/SDL_windows_gaming_input.c b/src/joystick/windows/SDL_windows_gaming_input.c index c86c22873..1b2d3746c 100644 --- a/src/joystick/windows/SDL_windows_gaming_input.c +++ b/src/joystick/windows/SDL_windows_gaming_input.c @@ -37,12 +37,11 @@ #include #include - #ifdef ____FIReference_1_INT32_INTERFACE_DEFINED__ /* MinGW-64 uses __FIReference_1_INT32 instead of Microsoft's __FIReference_1_int */ -#define __FIReference_1_int __FIReference_1_INT32 +#define __FIReference_1_int __FIReference_1_INT32 #define __FIReference_1_int_get_Value __FIReference_1_INT32_get_Value -#define __FIReference_1_int_Release __FIReference_1_INT32_Release +#define __FIReference_1_int_Release __FIReference_1_INT32_Release #endif struct joystick_hwdata @@ -55,7 +54,8 @@ struct joystick_hwdata UINT64 timestamp; }; -typedef struct WindowsGamingInputControllerState { +typedef struct WindowsGamingInputControllerState +{ SDL_JoystickID instance_id; __x_ABI_CWindows_CGaming_CInput_CIRawGameController *controller; char *name; @@ -66,7 +66,8 @@ typedef struct WindowsGamingInputControllerState { int nbuttons; } WindowsGamingInputControllerState; -static struct { +static struct +{ __x_ABI_CWindows_CGaming_CInput_CIRawGameControllerStatics *statics; __x_ABI_CWindows_CGaming_CInput_CIArcadeStickStatics *arcade_stick_statics; __x_ABI_CWindows_CGaming_CInput_CIArcadeStickStatics2 *arcade_stick_statics2; @@ -103,8 +104,7 @@ static const IID IID_IRacingWheelStatics2 = { 0xE666BCAA, 0xEDFD, 0x4323, { 0xA9 extern SDL_bool SDL_XINPUT_Enabled(void); extern SDL_bool SDL_DINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version); -static SDL_bool -SDL_IsXInputDevice(Uint16 vendor, Uint16 product) +static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) { #ifdef SDL_JOYSTICK_XINPUT PRAWINPUTDEVICELIST raw_devices = NULL; @@ -116,13 +116,13 @@ SDL_IsXInputDevice(Uint16 vendor, Uint16 product) #ifdef SDL_JOYSTICK_RAWINPUT && !RAWINPUT_IsEnabled() #endif - ) { + ) { return SDL_FALSE; } /* Go through RAWINPUT (WinXP and later) to find HID devices. */ if ((GetRawInputDeviceList(NULL, &raw_device_count, sizeof(RAWINPUTDEVICELIST)) == -1) || (!raw_device_count)) { - return SDL_FALSE; /* oh well. */ + return SDL_FALSE; /* oh well. */ } raw_devices = (PRAWINPUTDEVICELIST)SDL_malloc(sizeof(RAWINPUTDEVICELIST) * raw_device_count); @@ -134,7 +134,7 @@ SDL_IsXInputDevice(Uint16 vendor, Uint16 product) if (GetRawInputDeviceList(raw_devices, &raw_device_count, sizeof(RAWINPUTDEVICELIST)) == -1) { SDL_free(raw_devices); raw_devices = NULL; - return SDL_FALSE; /* oh well. */ + return SDL_FALSE; /* oh well. */ } for (i = 0; i < raw_device_count; i++) { @@ -209,12 +209,13 @@ SDL_IsXInputDevice(Uint16 vendor, Uint16 product) return SDL_FALSE; } -typedef struct RawGameControllerDelegate { +typedef struct RawGameControllerDelegate +{ __FIEventHandler_1_Windows__CGaming__CInput__CRawGameController iface; SDL_atomic_t refcount; } RawGameControllerDelegate; -static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_QueryInterface(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController * This, REFIID riid, void **ppvObject) +static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_QueryInterface(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController *This, REFIID riid, void **ppvObject) { if (ppvObject == NULL) { return E_INVALIDARG; @@ -233,13 +234,13 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_QueryInter } } -static ULONG STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_AddRef(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController * This) +static ULONG STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_AddRef(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController *This) { RawGameControllerDelegate *self = (RawGameControllerDelegate *)This; return SDL_AtomicAdd(&self->refcount, 1) + 1; } -static ULONG STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_Release(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController * This) +static ULONG STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_Release(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController *This) { RawGameControllerDelegate *self = (RawGameControllerDelegate *)This; int rc = SDL_AtomicAdd(&self->refcount, -1) - 1; @@ -248,7 +249,7 @@ static ULONG STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_Release(__FI return rc; } -static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdded(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController * This, IInspectable *sender, __x_ABI_CWindows_CGaming_CInput_CIRawGameController *e) +static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdded(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController *This, IInspectable *sender, __x_ABI_CWindows_CGaming_CInput_CIRawGameController *e) { HRESULT hr; __x_ABI_CWindows_CGaming_CInput_CIRawGameController *controller = NULL; @@ -279,8 +280,8 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde hr = __x_ABI_CWindows_CGaming_CInput_CIRawGameController_QueryInterface(controller, &IID_IRawGameController2, (void **)&controller2); if (SUCCEEDED(hr)) { - typedef PCWSTR (WINAPI *WindowsGetStringRawBuffer_t)(HSTRING string, UINT32 *length); - typedef HRESULT (WINAPI *WindowsDeleteString_t)(HSTRING string); + typedef PCWSTR(WINAPI * WindowsGetStringRawBuffer_t)(HSTRING string, UINT32 * length); + typedef HRESULT(WINAPI * WindowsDeleteString_t)(HSTRING string); WindowsGetStringRawBuffer_t WindowsGetStringRawBufferFunc = NULL; WindowsDeleteString_t WindowsDeleteStringFunc = NULL; @@ -340,7 +341,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde __x_ABI_CWindows_CGaming_CInput_CIGameController_Release(gamecontroller); } - guid = SDL_CreateJoystickGUID(bus, vendor, product, version, name, 'w', (Uint8) type); + guid = SDL_CreateJoystickGUID(bus, vendor, product, version, name, 'w', (Uint8)type); #ifdef SDL_JOYSTICK_HIDAPI if (!ignore_joystick && HIDAPI_IsDevicePresent(vendor, product, version, name)) { @@ -403,7 +404,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde return S_OK; } -static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeRemoved(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController * This, IInspectable *sender, __x_ABI_CWindows_CGaming_CInput_CIRawGameController *e) +static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeRemoved(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController *This, IInspectable *sender, __x_ABI_CWindows_CGaming_CInput_CIRawGameController *e) { HRESULT hr; __x_ABI_CWindows_CGaming_CInput_CIRawGameController *controller = NULL; @@ -420,7 +421,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeRemo if (SUCCEEDED(hr)) { int i; - for (i = 0; i < wgi.controller_count ; i++) { + for (i = 0; i < wgi.controller_count; i++) { if (wgi.controllers[i].controller == controller) { WindowsGamingInputControllerState *state = &wgi.controllers[i]; SDL_JoystickID joystickID = state->instance_id; @@ -469,11 +470,10 @@ static RawGameControllerDelegate controller_removed = { { 1 } }; -static int -WGI_JoystickInit(void) +static int WGI_JoystickInit(void) { - typedef HRESULT (WINAPI *WindowsCreateStringReference_t)(PCWSTR sourceString, UINT32 length, HSTRING_HEADER *hstringHeader, HSTRING* string); - typedef HRESULT (WINAPI *RoGetActivationFactory_t)(HSTRING activatableClassId, REFIID iid, void** factory); + typedef HRESULT(WINAPI * WindowsCreateStringReference_t)(PCWSTR sourceString, UINT32 length, HSTRING_HEADER * hstringHeader, HSTRING * string); + typedef HRESULT(WINAPI * RoGetActivationFactory_t)(HSTRING activatableClassId, REFIID iid, void **factory); WindowsCreateStringReference_t WindowsCreateStringReferenceFunc = NULL; RoGetActivationFactory_t RoGetActivationFactoryFunc = NULL; @@ -493,7 +493,7 @@ WGI_JoystickInit(void) */ static PVOID cookie = NULL; if (!cookie) { - typedef HRESULT (WINAPI *CoIncrementMTAUsage_t)(PVOID* pCookie); + typedef HRESULT(WINAPI * CoIncrementMTAUsage_t)(PVOID * pCookie); CoIncrementMTAUsage_t CoIncrementMTAUsageFunc = (CoIncrementMTAUsage_t)WIN_LoadComBaseFunction("CoIncrementMTAUsage"); if (CoIncrementMTAUsageFunc) { if (FAILED(CoIncrementMTAUsageFunc(&cookie))) { @@ -610,54 +610,45 @@ WGI_JoystickInit(void) return 0; } -static int -WGI_JoystickGetCount(void) +static int WGI_JoystickGetCount(void) { return wgi.controller_count; } -static void -WGI_JoystickDetect(void) +static void WGI_JoystickDetect(void) { } -static const char * -WGI_JoystickGetDeviceName(int device_index) +static const char *WGI_JoystickGetDeviceName(int device_index) { return wgi.controllers[device_index].name; } -static const char * -WGI_JoystickGetDevicePath(int device_index) +static const char *WGI_JoystickGetDevicePath(int device_index) { return NULL; } -static int -WGI_JoystickGetDevicePlayerIndex(int device_index) +static int WGI_JoystickGetDevicePlayerIndex(int device_index) { return -1; } -static void -WGI_JoystickSetDevicePlayerIndex(int device_index, int player_index) +static void WGI_JoystickSetDevicePlayerIndex(int device_index, int player_index) { } -static SDL_JoystickGUID -WGI_JoystickGetDeviceGUID(int device_index) +static SDL_JoystickGUID WGI_JoystickGetDeviceGUID(int device_index) { return wgi.controllers[device_index].guid; } -static SDL_JoystickID -WGI_JoystickGetDeviceInstanceID(int device_index) +static SDL_JoystickID WGI_JoystickGetDeviceInstanceID(int device_index) { return wgi.controllers[device_index].instance_id; } -static int -WGI_JoystickOpen(SDL_Joystick *joystick, int device_index) +static int WGI_JoystickOpen(SDL_Joystick *joystick, int device_index) { WindowsGamingInputControllerState *state = &wgi.controllers[device_index]; struct joystick_hwdata *hwdata; @@ -728,8 +719,7 @@ WGI_JoystickOpen(SDL_Joystick *joystick, int device_index) return 0; } -static int -WGI_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int WGI_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { struct joystick_hwdata *hwdata = joystick->hwdata; @@ -749,8 +739,7 @@ WGI_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 h } } -static int -WGI_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int WGI_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { struct joystick_hwdata *hwdata = joystick->hwdata; @@ -770,8 +759,7 @@ WGI_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 ri } } -static Uint32 -WGI_JoystickGetCapabilities(SDL_Joystick *joystick) +static Uint32 WGI_JoystickGetCapabilities(SDL_Joystick *joystick) { struct joystick_hwdata *hwdata = joystick->hwdata; @@ -783,26 +771,22 @@ WGI_JoystickGetCapabilities(SDL_Joystick *joystick) } } -static int -WGI_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int WGI_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -WGI_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) +static int WGI_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -WGI_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int WGI_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } -static Uint8 -ConvertHatValue(__x_ABI_CWindows_CGaming_CInput_CGameControllerSwitchPosition value) +static Uint8 ConvertHatValue(__x_ABI_CWindows_CGaming_CInput_CGameControllerSwitchPosition value) { switch (value) { case GameControllerSwitchPosition_Up: @@ -826,8 +810,7 @@ ConvertHatValue(__x_ABI_CWindows_CGaming_CInput_CGameControllerSwitchPosition va } } -static void -WGI_JoystickUpdate(SDL_Joystick *joystick) +static void WGI_JoystickUpdate(SDL_Joystick *joystick) { struct joystick_hwdata *hwdata = joystick->hwdata; HRESULT hr; @@ -865,13 +848,13 @@ WGI_JoystickUpdate(SDL_Joystick *joystick) SDL_PrivateJoystickForceRecentering(joystick); } else { for (i = 0; i < nbuttons; ++i) { - SDL_PrivateJoystickButton(joystick, (Uint8) i, buttons[i]); + SDL_PrivateJoystickButton(joystick, (Uint8)i, buttons[i]); } for (i = 0; i < nhats; ++i) { - SDL_PrivateJoystickHat(joystick, (Uint8) i, ConvertHatValue(hats[i])); + SDL_PrivateJoystickHat(joystick, (Uint8)i, ConvertHatValue(hats[i])); } for (i = 0; i < naxes; ++i) { - SDL_PrivateJoystickAxis(joystick, (Uint8)i, (Sint16)((int) (axes[i] * 65535) - 32768)); + SDL_PrivateJoystickAxis(joystick, (Uint8)i, (Sint16)((int)(axes[i] * 65535) - 32768)); } } hwdata->timestamp = timestamp; @@ -882,8 +865,7 @@ WGI_JoystickUpdate(SDL_Joystick *joystick) SDL_stack_free(axes); } -static void -WGI_JoystickClose(SDL_Joystick *joystick) +static void WGI_JoystickClose(SDL_Joystick *joystick) { struct joystick_hwdata *hwdata = joystick->hwdata; @@ -905,8 +887,7 @@ WGI_JoystickClose(SDL_Joystick *joystick) joystick->hwdata = NULL; } -static void -WGI_JoystickQuit(void) +static void WGI_JoystickQuit(void) { if (wgi.statics) { while (wgi.controller_count > 0) { @@ -950,14 +931,12 @@ WGI_JoystickQuit(void) SDL_zero(wgi); } -static SDL_bool -WGI_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static SDL_bool WGI_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { return SDL_FALSE; } -SDL_JoystickDriver SDL_WGI_JoystickDriver = -{ +SDL_JoystickDriver SDL_WGI_JoystickDriver = { WGI_JoystickInit, WGI_JoystickGetCount, WGI_JoystickDetect, diff --git a/src/joystick/windows/SDL_windowsjoystick.c b/src/joystick/windows/SDL_windowsjoystick.c index 4d8d45187..b54038408 100644 --- a/src/joystick/windows/SDL_windowsjoystick.c +++ b/src/joystick/windows/SDL_windowsjoystick.c @@ -51,9 +51,8 @@ #include "SDL_xinputjoystick_c.h" #include "SDL_rawinputjoystick_c.h" -#include "../../haptic/windows/SDL_dinputhaptic_c.h" /* For haptic hot plugging */ -#include "../../haptic/windows/SDL_xinputhaptic_c.h" /* For haptic hot plugging */ - +#include "../../haptic/windows/SDL_dinputhaptic_c.h" /* For haptic hot plugging */ +#include "../../haptic/windows/SDL_xinputhaptic_c.h" /* For haptic hot plugging */ #ifndef DEVICE_NOTIFY_WINDOW_HANDLE #define DEVICE_NOTIFY_WINDOW_HANDLE 0x00000000 @@ -69,34 +68,42 @@ extern "C" { #endif DECLARE_HANDLE(HCMNOTIFICATION); -typedef HCMNOTIFICATION* PHCMNOTIFICATION; +typedef HCMNOTIFICATION *PHCMNOTIFICATION; -typedef enum _CM_NOTIFY_FILTER_TYPE { +typedef enum _CM_NOTIFY_FILTER_TYPE +{ CM_NOTIFY_FILTER_TYPE_DEVICEINTERFACE = 0, CM_NOTIFY_FILTER_TYPE_DEVICEHANDLE, CM_NOTIFY_FILTER_TYPE_DEVICEINSTANCE, CM_NOTIFY_FILTER_TYPE_MAX -} CM_NOTIFY_FILTER_TYPE, * PCM_NOTIFY_FILTER_TYPE; +} CM_NOTIFY_FILTER_TYPE, + *PCM_NOTIFY_FILTER_TYPE; -typedef struct _CM_NOTIFY_FILTER { +typedef struct _CM_NOTIFY_FILTER +{ DWORD cbSize; DWORD Flags; CM_NOTIFY_FILTER_TYPE FilterType; DWORD Reserved; - union { - struct { + union + { + struct + { GUID ClassGuid; } DeviceInterface; - struct { - HANDLE hTarget; + struct + { + HANDLE hTarget; } DeviceHandle; - struct { + struct + { WCHAR InstanceId[200]; } DeviceInstance; } u; -} CM_NOTIFY_FILTER, * PCM_NOTIFY_FILTER; +} CM_NOTIFY_FILTER, *PCM_NOTIFY_FILTER; -typedef enum _CM_NOTIFY_ACTION { +typedef enum _CM_NOTIFY_ACTION +{ CM_NOTIFY_ACTION_DEVICEINTERFACEARRIVAL = 0, CM_NOTIFY_ACTION_DEVICEINTERFACEREMOVAL, CM_NOTIFY_ACTION_DEVICEQUERYREMOVE, @@ -108,32 +115,38 @@ typedef enum _CM_NOTIFY_ACTION { CM_NOTIFY_ACTION_DEVICEINSTANCESTARTED, CM_NOTIFY_ACTION_DEVICEINSTANCEREMOVED, CM_NOTIFY_ACTION_MAX -} CM_NOTIFY_ACTION, * PCM_NOTIFY_ACTION; +} CM_NOTIFY_ACTION, + *PCM_NOTIFY_ACTION; -typedef struct _CM_NOTIFY_EVENT_DATA { +typedef struct _CM_NOTIFY_EVENT_DATA +{ CM_NOTIFY_FILTER_TYPE FilterType; DWORD Reserved; - union { - struct { + union + { + struct + { GUID ClassGuid; WCHAR SymbolicLink[ANYSIZE_ARRAY]; } DeviceInterface; - struct { + struct + { GUID EventGuid; LONG NameOffset; DWORD DataSize; BYTE Data[ANYSIZE_ARRAY]; } DeviceHandle; - struct { + struct + { WCHAR InstanceId[ANYSIZE_ARRAY]; } DeviceInstance; } u; -} CM_NOTIFY_EVENT_DATA, * PCM_NOTIFY_EVENT_DATA; +} CM_NOTIFY_EVENT_DATA, *PCM_NOTIFY_EVENT_DATA; -typedef DWORD (CALLBACK *PCM_NOTIFY_CALLBACK)(HCMNOTIFICATION hNotify, PVOID Context, CM_NOTIFY_ACTION Action, PCM_NOTIFY_EVENT_DATA EventData, DWORD EventDataSize); +typedef DWORD(CALLBACK *PCM_NOTIFY_CALLBACK)(HCMNOTIFICATION hNotify, PVOID Context, CM_NOTIFY_ACTION Action, PCM_NOTIFY_EVENT_DATA EventData, DWORD EventDataSize); -typedef DWORD (WINAPI *CM_Register_NotificationFunc)(PCM_NOTIFY_FILTER pFilter, PVOID pContext, PCM_NOTIFY_CALLBACK pCallback, PHCMNOTIFICATION pNotifyContext); -typedef DWORD (WINAPI *CM_Unregister_NotificationFunc)(HCMNOTIFICATION NotifyContext); +typedef DWORD(WINAPI *CM_Register_NotificationFunc)(PCM_NOTIFY_FILTER pFilter, PVOID pContext, PCM_NOTIFY_CALLBACK pCallback, PHCMNOTIFICATION pNotifyContext); +typedef DWORD(WINAPI *CM_Unregister_NotificationFunc)(HCMNOTIFICATION NotifyContext); /* local variables */ static SDL_bool s_bJoystickThread = SDL_FALSE; @@ -144,7 +157,7 @@ static SDL_Thread *s_joystickThread = NULL; static SDL_bool s_bJoystickThreadQuit = SDL_FALSE; static GUID GUID_DEVINTERFACE_HID = { 0x4D1E55B2L, 0xF16F, 0x11CF, { 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 } }; -JoyStick_DeviceData *SYS_Joystick; /* array to hold joystick ID values */ +JoyStick_DeviceData *SYS_Joystick; /* array to hold joystick ID values */ #if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) static HMODULE cfgmgr32_lib_handle; @@ -152,8 +165,7 @@ static CM_Register_NotificationFunc CM_Register_Notification; static CM_Unregister_NotificationFunc CM_Unregister_Notification; static HCMNOTIFICATION s_DeviceNotificationFuncHandle; -static DWORD CALLBACK -SDL_DeviceNotificationFunc(HCMNOTIFICATION hNotify, PVOID context, CM_NOTIFY_ACTION action, PCM_NOTIFY_EVENT_DATA eventData, DWORD event_data_size) +static DWORD CALLBACK SDL_DeviceNotificationFunc(HCMNOTIFICATION hNotify, PVOID context, CM_NOTIFY_ACTION action, PCM_NOTIFY_EVENT_DATA eventData, DWORD event_data_size) { if (action == CM_NOTIFY_ACTION_DEVICEINTERFACEARRIVAL || action == CM_NOTIFY_ACTION_DEVICEINTERFACEREMOVAL) { @@ -162,8 +174,7 @@ SDL_DeviceNotificationFunc(HCMNOTIFICATION hNotify, PVOID context, CM_NOTIFY_ACT return ERROR_SUCCESS; } -static void -SDL_CleanupDeviceNotificationFunc(void) +static void SDL_CleanupDeviceNotificationFunc(void) { if (cfgmgr32_lib_handle) { if (s_DeviceNotificationFuncHandle) { @@ -176,8 +187,7 @@ SDL_CleanupDeviceNotificationFunc(void) } } -static SDL_bool -SDL_CreateDeviceNotificationFunc(void) +static SDL_bool SDL_CreateDeviceNotificationFunc(void) { cfgmgr32_lib_handle = LoadLibraryA("cfgmgr32.dll"); if (cfgmgr32_lib_handle) { @@ -212,15 +222,14 @@ typedef struct #define IDT_SDL_DEVICE_CHANGE_TIMER_2 1201 /* windowproc for our joystick detect thread message only window, to detect any USB device addition/removal */ -static LRESULT CALLBACK -SDL_PrivateJoystickDetectProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK SDL_PrivateJoystickDetectProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_DEVICECHANGE: switch (wParam) { case DBT_DEVICEARRIVAL: case DBT_DEVICEREMOVECOMPLETE: - if (((DEV_BROADCAST_HDR*)lParam)->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { + if (((DEV_BROADCAST_HDR *)lParam)->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { /* notify 300ms and 2 seconds later to ensure all APIs have updated status */ SetTimer(hwnd, IDT_SDL_DEVICE_CHANGE_TIMER_1, 300, NULL); SetTimer(hwnd, IDT_SDL_DEVICE_CHANGE_TIMER_2, 2000, NULL); @@ -245,8 +254,7 @@ SDL_PrivateJoystickDetectProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) #endif } -static void -SDL_CleanupDeviceNotification(SDL_DeviceNotificationData *data) +static void SDL_CleanupDeviceNotification(SDL_DeviceNotificationData *data) { #if SDL_JOYSTICK_RAWINPUT RAWINPUT_UnregisterNotifications(); @@ -267,8 +275,7 @@ SDL_CleanupDeviceNotification(SDL_DeviceNotificationData *data) } } -static int -SDL_CreateDeviceNotification(SDL_DeviceNotificationData *data) +static int SDL_CreateDeviceNotification(SDL_DeviceNotificationData *data) { DEV_BROADCAST_DEVICEINTERFACE dbh; @@ -278,8 +285,8 @@ SDL_CreateDeviceNotification(SDL_DeviceNotificationData *data) data->wincl.hInstance = GetModuleHandle(NULL); data->wincl.lpszClassName = TEXT("Message"); - data->wincl.lpfnWndProc = SDL_PrivateJoystickDetectProc; /* This function is called by windows */ - data->wincl.cbSize = sizeof (WNDCLASSEX); + data->wincl.lpfnWndProc = SDL_PrivateJoystickDetectProc; /* This function is called by windows */ + data->wincl.cbSize = sizeof(WNDCLASSEX); if (!RegisterClassEx(&data->wincl)) { WIN_SetError("Failed to create register class for joystick autodetect"); @@ -287,7 +294,7 @@ SDL_CreateDeviceNotification(SDL_DeviceNotificationData *data) return -1; } - data->messageWindow = (HWND)CreateWindowEx(0, TEXT("Message"), NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL); + data->messageWindow = (HWND)CreateWindowEx(0, TEXT("Message"), NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL); if (!data->messageWindow) { WIN_SetError("Failed to create message window for joystick autodetect"); SDL_CleanupDeviceNotification(data); @@ -312,8 +319,7 @@ SDL_CreateDeviceNotification(SDL_DeviceNotificationData *data) return 0; } -static SDL_bool -SDL_WaitForDeviceNotification(SDL_DeviceNotificationData *data, SDL_mutex *mutex) +static SDL_bool SDL_WaitForDeviceNotification(SDL_DeviceNotificationData *data, SDL_mutex *mutex) { MSG msg; int lastret = 1; @@ -336,7 +342,6 @@ SDL_WaitForDeviceNotification(SDL_DeviceNotificationData *data, SDL_mutex *mutex #endif /* !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) */ - #if !defined(__WINRT__) #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) @@ -344,8 +349,7 @@ static SDL_DeviceNotificationData s_notification_data; #endif /* Function/thread to scan the system for joysticks. */ -static int SDLCALL -SDL_JoystickThread(void *_data) +static int SDLCALL SDL_JoystickThread(void *_data) { #if SDL_JOYSTICK_XINPUT SDL_bool bOpenedXInputDevices[XUSER_MAX_COUNT]; @@ -398,8 +402,7 @@ SDL_JoystickThread(void *_data) } /* spin up the thread to detect hotplug of devices */ -static int -SDL_StartJoystickThread(void) +static int SDL_StartJoystickThread(void) { s_mutexJoyStickEnum = SDL_CreateMutex(); if (s_mutexJoyStickEnum == NULL) { @@ -419,8 +422,7 @@ SDL_StartJoystickThread(void) return 0; } -static void -SDL_StopJoystickThread(void) +static void SDL_StopJoystickThread(void) { if (s_joystickThread == NULL) { return; @@ -464,8 +466,7 @@ static void WINDOWS_JoystickQuit(void); * Joystick 0 should be the system default joystick. * It should return 0, or -1 on an unrecoverable fatal error. */ -static int -WINDOWS_JoystickInit(void) +static int WINDOWS_JoystickInit(void) { if (SDL_DINPUT_JoystickInit() < 0) { WINDOWS_JoystickQuit(); @@ -507,8 +508,7 @@ WINDOWS_JoystickInit(void) } /* return the number of joysticks that are connected right now */ -static int -WINDOWS_JoystickGetCount(void) +static int WINDOWS_JoystickGetCount(void) { int nJoysticks = 0; JoyStick_DeviceData *device = SYS_Joystick; @@ -521,14 +521,13 @@ WINDOWS_JoystickGetCount(void) } /* detect any new joysticks being inserted into the system */ -static void -WINDOWS_JoystickDetect(void) +static void WINDOWS_JoystickDetect(void) { JoyStick_DeviceData *pCurList = NULL; /* only enum the devices if the joystick thread told us something changed */ if (!s_bWindowsDeviceChanged) { - return; /* thread hasn't signaled, nothing to do right now. */ + return; /* thread hasn't signaled, nothing to do right now. */ } if (s_mutexJoyStickEnum) { @@ -590,8 +589,7 @@ WINDOWS_JoystickDetect(void) } } -static const char * -WINDOWS_JoystickGetDeviceName(int device_index) +static const char *WINDOWS_JoystickGetDeviceName(int device_index) { JoyStick_DeviceData *device = SYS_Joystick; int index; @@ -603,8 +601,7 @@ WINDOWS_JoystickGetDeviceName(int device_index) return device->joystickname; } -static const char * -WINDOWS_JoystickGetDevicePath(int device_index) +static const char *WINDOWS_JoystickGetDevicePath(int device_index) { JoyStick_DeviceData *device = SYS_Joystick; int index; @@ -616,8 +613,7 @@ WINDOWS_JoystickGetDevicePath(int device_index) return device->path; } -static int -WINDOWS_JoystickGetDevicePlayerIndex(int device_index) +static int WINDOWS_JoystickGetDevicePlayerIndex(int device_index) { JoyStick_DeviceData *device = SYS_Joystick; int index; @@ -629,14 +625,12 @@ WINDOWS_JoystickGetDevicePlayerIndex(int device_index) return device->bXInputDevice ? (int)device->XInputUserId : -1; } -static void -WINDOWS_JoystickSetDevicePlayerIndex(int device_index, int player_index) +static void WINDOWS_JoystickSetDevicePlayerIndex(int device_index, int player_index) { } /* return the stable device guid for this device index */ -static SDL_JoystickGUID -WINDOWS_JoystickGetDeviceGUID(int device_index) +static SDL_JoystickGUID WINDOWS_JoystickGetDeviceGUID(int device_index) { JoyStick_DeviceData *device = SYS_Joystick; int index; @@ -649,8 +643,7 @@ WINDOWS_JoystickGetDeviceGUID(int device_index) } /* Function to perform the mapping between current device instance and this joysticks instance id */ -static SDL_JoystickID -WINDOWS_JoystickGetDeviceInstanceID(int device_index) +static SDL_JoystickID WINDOWS_JoystickGetDeviceInstanceID(int device_index) { JoyStick_DeviceData *device = SYS_Joystick; int index; @@ -667,8 +660,7 @@ WINDOWS_JoystickGetDeviceInstanceID(int device_index) This should fill the nbuttons and naxes fields of the joystick structure. It returns 0, or -1 if there is an error. */ -static int -WINDOWS_JoystickOpen(SDL_Joystick *joystick, int device_index) +static int WINDOWS_JoystickOpen(SDL_Joystick *joystick, int device_index) { JoyStick_DeviceData *device = SYS_Joystick; int index; @@ -680,7 +672,7 @@ WINDOWS_JoystickOpen(SDL_Joystick *joystick, int device_index) /* allocate memory for system specific hardware data */ joystick->instance_id = device->nInstanceID; joystick->hwdata = - (struct joystick_hwdata *) SDL_malloc(sizeof(struct joystick_hwdata)); + (struct joystick_hwdata *)SDL_malloc(sizeof(struct joystick_hwdata)); if (joystick->hwdata == NULL) { return SDL_OutOfMemory(); } @@ -694,8 +686,7 @@ WINDOWS_JoystickOpen(SDL_Joystick *joystick, int device_index) } } -static int -WINDOWS_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +static int WINDOWS_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { if (joystick->hwdata->bXInputDevice) { return SDL_XINPUT_JoystickRumble(joystick, low_frequency_rumble, high_frequency_rumble); @@ -704,14 +695,12 @@ WINDOWS_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint } } -static int -WINDOWS_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +static int WINDOWS_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { return SDL_Unsupported(); } -static Uint32 -WINDOWS_JoystickGetCapabilities(SDL_Joystick *joystick) +static Uint32 WINDOWS_JoystickGetCapabilities(SDL_Joystick *joystick) { if (joystick->hwdata->bXInputDevice) { return SDL_XINPUT_JoystickGetCapabilities(joystick); @@ -720,26 +709,22 @@ WINDOWS_JoystickGetCapabilities(SDL_Joystick *joystick) } } -static int -WINDOWS_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +static int WINDOWS_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -static int -WINDOWS_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) +static int WINDOWS_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -static int -WINDOWS_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int WINDOWS_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); } -static void -WINDOWS_JoystickUpdate(SDL_Joystick *joystick) +static void WINDOWS_JoystickUpdate(SDL_Joystick *joystick) { if (!joystick->hwdata) { return; @@ -753,8 +738,7 @@ WINDOWS_JoystickUpdate(SDL_Joystick *joystick) } /* Function to close a joystick after use */ -static void -WINDOWS_JoystickClose(SDL_Joystick *joystick) +static void WINDOWS_JoystickClose(SDL_Joystick *joystick) { if (joystick->hwdata->bXInputDevice) { SDL_XINPUT_JoystickClose(joystick); @@ -766,8 +750,7 @@ WINDOWS_JoystickClose(SDL_Joystick *joystick) } /* Function to perform any system-specific joystick related cleanup */ -static void -WINDOWS_JoystickQuit(void) +static void WINDOWS_JoystickQuit(void) { JoyStick_DeviceData *device = SYS_Joystick; @@ -801,14 +784,12 @@ WINDOWS_JoystickQuit(void) s_bWindowsDeviceChanged = SDL_FALSE; } -static SDL_bool -WINDOWS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static SDL_bool WINDOWS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { return SDL_FALSE; } -SDL_JoystickDriver SDL_WINDOWS_JoystickDriver = -{ +SDL_JoystickDriver SDL_WINDOWS_JoystickDriver = { WINDOWS_JoystickInit, WINDOWS_JoystickGetCount, WINDOWS_JoystickDetect, diff --git a/src/joystick/windows/SDL_windowsjoystick_c.h b/src/joystick/windows/SDL_windowsjoystick_c.h index 00e1cf101..14fc95a43 100644 --- a/src/joystick/windows/SDL_windowsjoystick_c.h +++ b/src/joystick/windows/SDL_windowsjoystick_c.h @@ -25,7 +25,7 @@ #include "../../core/windows/SDL_windows.h" #include "../../core/windows/SDL_directx.h" -#define MAX_INPUTS 256 /* each joystick can have up to 256 inputs */ +#define MAX_INPUTS 256 /* each joystick can have up to 256 inputs */ /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus @@ -46,7 +46,7 @@ typedef struct JoyStick_DeviceData struct JoyStick_DeviceData *pNext; } JoyStick_DeviceData; -extern JoyStick_DeviceData *SYS_Joystick; /* array to hold joystick ID values */ +extern JoyStick_DeviceData *SYS_Joystick; /* array to hold joystick ID values */ typedef enum Type { @@ -86,7 +86,7 @@ struct joystick_hwdata SDL_bool bXInputDevice; /* SDL_TRUE if this device supports using the xinput API rather than DirectInput */ SDL_bool bXInputHaptic; /* Supports force feedback via XInput. */ - Uint8 userid; /* XInput userid index for this joystick */ + Uint8 userid; /* XInput userid index for this joystick */ DWORD dwPacketNumber; }; diff --git a/src/joystick/windows/SDL_xinputjoystick.c b/src/joystick/windows/SDL_xinputjoystick.c index 091c641df..3190930b0 100644 --- a/src/joystick/windows/SDL_xinputjoystick.c +++ b/src/joystick/windows/SDL_xinputjoystick.c @@ -42,9 +42,7 @@ extern "C" { static SDL_bool s_bXInputEnabled = SDL_TRUE; static char *s_arrXInputDevicePath[XUSER_MAX_COUNT]; - -static SDL_bool -SDL_XInputUseOldJoystickMapping() +static SDL_bool SDL_XInputUseOldJoystickMapping() { #ifdef __WINRT__ /* TODO: remove this __WINRT__ block, but only after integrating with UWP/WinRT's HID API */ @@ -66,8 +64,7 @@ SDL_bool SDL_XINPUT_Enabled(void) return s_bXInputEnabled; } -int -SDL_XINPUT_JoystickInit(void) +int SDL_XINPUT_JoystickInit(void) { s_bXInputEnabled = SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE); @@ -79,13 +76,12 @@ SDL_XINPUT_JoystickInit(void) #endif if (s_bXInputEnabled && WIN_LoadXInputDLL() < 0) { - s_bXInputEnabled = SDL_FALSE; /* oh well. */ + s_bXInputEnabled = SDL_FALSE; /* oh well. */ } return 0; } -static const char * -GetXInputName(const Uint8 userid, BYTE SubType) +static const char *GetXInputName(const Uint8 userid, BYTE SubType) { static char name[32]; @@ -130,15 +126,14 @@ GetXInputName(const Uint8 userid, BYTE SubType) /* We can't really tell what device is being used for XInput, but we can guess and we'll be correct for the case where only one device is connected. */ -static void -GuessXInputDevice(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *pVersion) +static void GuessXInputDevice(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *pVersion) { #if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* TODO: remove this ifndef __WINRT__ block, but only after integrating with UWP/WinRT's HID API */ PRAWINPUTDEVICELIST devices = NULL; UINT i, j, device_count = 0; if ((GetRawInputDeviceList(NULL, &device_count, sizeof(RAWINPUTDEVICELIST)) == -1) || (!device_count)) { - return; /* oh well. */ + return; /* oh well. */ } devices = (PRAWINPUTDEVICELIST)SDL_malloc(sizeof(RAWINPUTDEVICELIST) * device_count); @@ -148,7 +143,7 @@ GuessXInputDevice(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *pVersion) if (GetRawInputDeviceList(devices, &device_count, sizeof(RAWINPUTDEVICELIST)) == -1) { SDL_free(devices); - return; /* oh well. */ + return; /* oh well. */ } /* First see if we have a cached entry for this index */ @@ -231,7 +226,7 @@ GuessXInputDevice(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *pVersion) } } SDL_free(devices); -#endif /* !__WINRT__ */ +#endif /* !__WINRT__ */ /* The device wasn't in the raw HID device list, it's probably Bluetooth */ *pVID = 0x045e; /* Microsoft */ @@ -239,8 +234,7 @@ GuessXInputDevice(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *pVersion) *pVersion = 0; } -static void -AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pContext) +static void AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pContext) { Uint16 vendor = 0; Uint16 product = 0; @@ -267,7 +261,7 @@ AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pContext) pNewJoystick->pNext = SYS_Joystick; SYS_Joystick = pNewJoystick; - return; /* already in the list. */ + return; /* already in the list. */ } pPrevJoystick = pNewJoystick; @@ -319,8 +313,7 @@ AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pContext) WINDOWS_AddJoystickDevice(pNewJoystick); } -static void -DelXInputDevice(Uint8 userid) +static void DelXInputDevice(Uint8 userid) { if (s_arrXInputDevicePath[userid]) { SDL_free(s_arrXInputDevicePath[userid]); @@ -328,8 +321,7 @@ DelXInputDevice(Uint8 userid) } } -void -SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext) +void SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext) { int iuserid; @@ -361,8 +353,7 @@ SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext) } } -int -SDL_XINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice) +int SDL_XINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystickdevice) { const Uint8 userId = joystickdevice->XInputUserId; XINPUT_CAPABILITIES capabilities; @@ -396,8 +387,7 @@ SDL_XINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickde return 0; } -static void -UpdateXInputJoystickBatteryInformation(SDL_Joystick * joystick, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation) +static void UpdateXInputJoystickBatteryInformation(SDL_Joystick *joystick, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation) { if (pBatteryInformation->BatteryType != BATTERY_TYPE_UNKNOWN) { SDL_JoystickPowerLevel ePowerLevel = SDL_JOYSTICK_POWER_UNKNOWN; @@ -425,8 +415,7 @@ UpdateXInputJoystickBatteryInformation(SDL_Joystick * joystick, XINPUT_BATTERY_I } } -static void -UpdateXInputJoystickState_OLD(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputState, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation) +static void UpdateXInputJoystickState_OLD(SDL_Joystick *joystick, XINPUT_STATE_EX *pXInputState, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation) { static WORD s_XInputButtons[] = { XINPUT_GAMEPAD_DPAD_UP, XINPUT_GAMEPAD_DPAD_DOWN, XINPUT_GAMEPAD_DPAD_LEFT, XINPUT_GAMEPAD_DPAD_RIGHT, @@ -452,8 +441,7 @@ UpdateXInputJoystickState_OLD(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputS UpdateXInputJoystickBatteryInformation(joystick, pBatteryInformation); } -static void -UpdateXInputJoystickState(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputState, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation) +static void UpdateXInputJoystickState(SDL_Joystick *joystick, XINPUT_STATE_EX *pXInputState, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation) { static WORD s_XInputButtons[] = { XINPUT_GAMEPAD_A, XINPUT_GAMEPAD_B, XINPUT_GAMEPAD_X, XINPUT_GAMEPAD_Y, @@ -493,8 +481,7 @@ UpdateXInputJoystickState(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputState UpdateXInputJoystickBatteryInformation(joystick, pBatteryInformation); } -int -SDL_XINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +int SDL_XINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { XINPUT_VIBRATION XVibration; @@ -511,13 +498,12 @@ SDL_XINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, } Uint32 -SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick * joystick) +SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick *joystick) { return SDL_JOYCAP_RUMBLE; } -void -SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick) +void SDL_XINPUT_JoystickUpdate(SDL_Joystick *joystick) { HRESULT result; XINPUT_STATE_EX XInputState; @@ -553,13 +539,11 @@ SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick) #endif } -void -SDL_XINPUT_JoystickClose(SDL_Joystick * joystick) +void SDL_XINPUT_JoystickClose(SDL_Joystick *joystick) { } -void -SDL_XINPUT_JoystickQuit(void) +void SDL_XINPUT_JoystickQuit(void) { if (s_bXInputEnabled) { WIN_UnloadXInputDLL(); @@ -580,47 +564,40 @@ SDL_bool SDL_XINPUT_Enabled(void) return SDL_FALSE; } -int -SDL_XINPUT_JoystickInit(void) +int SDL_XINPUT_JoystickInit(void) { return 0; } -void -SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext) +void SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext) { } -int -SDL_XINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice) +int SDL_XINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystickdevice) { return SDL_Unsupported(); } -int -SDL_XINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +int SDL_XINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { return SDL_Unsupported(); } Uint32 -SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick * joystick) +SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick *joystick) { return 0; } -void -SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick) +void SDL_XINPUT_JoystickUpdate(SDL_Joystick *joystick) { } -void -SDL_XINPUT_JoystickClose(SDL_Joystick * joystick) +void SDL_XINPUT_JoystickClose(SDL_Joystick *joystick) { } -void -SDL_XINPUT_JoystickQuit(void) +void SDL_XINPUT_JoystickQuit(void) { } diff --git a/src/joystick/windows/SDL_xinputjoystick_c.h b/src/joystick/windows/SDL_xinputjoystick_c.h index 1a8bfdcfe..e4914dd0d 100644 --- a/src/joystick/windows/SDL_xinputjoystick_c.h +++ b/src/joystick/windows/SDL_xinputjoystick_c.h @@ -30,11 +30,11 @@ extern "C" { extern SDL_bool SDL_XINPUT_Enabled(void); extern int SDL_XINPUT_JoystickInit(void); extern void SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext); -extern int SDL_XINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice); -extern int SDL_XINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); -extern Uint32 SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick * joystick); -extern void SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick); -extern void SDL_XINPUT_JoystickClose(SDL_Joystick * joystick); +extern int SDL_XINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystickdevice); +extern int SDL_XINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); +extern Uint32 SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick *joystick); +extern void SDL_XINPUT_JoystickUpdate(SDL_Joystick *joystick); +extern void SDL_XINPUT_JoystickClose(SDL_Joystick *joystick); extern void SDL_XINPUT_JoystickQuit(void); /* Ends C function definitions when using C++ */ diff --git a/src/loadso/dlopen/SDL_sysloadso.c b/src/loadso/dlopen/SDL_sysloadso.c index 54337b92e..313c82aef 100644 --- a/src/loadso/dlopen/SDL_sysloadso.c +++ b/src/loadso/dlopen/SDL_sysloadso.c @@ -47,7 +47,7 @@ SDL_LoadObject(const char *sofile) } #endif - handle = dlopen(sofile, RTLD_NOW|RTLD_LOCAL); + handle = dlopen(sofile, RTLD_NOW | RTLD_LOCAL); loaderror = dlerror(); if (handle == NULL) { SDL_SetError("Failed loading %s: %s", sofile, loaderror); @@ -70,14 +70,13 @@ SDL_LoadFunction(void *handle, const char *name) SDL_small_free(_name, isstack); if (symbol == NULL) { SDL_SetError("Failed loading %s: %s", name, - (const char *) dlerror()); + (const char *)dlerror()); } } return symbol; } -void -SDL_UnloadObject(void *handle) +void SDL_UnloadObject(void *handle) { if (handle != NULL) { dlclose(handle); diff --git a/src/loadso/dummy/SDL_sysloadso.c b/src/loadso/dummy/SDL_sysloadso.c index feb1630ae..313532680 100644 --- a/src/loadso/dummy/SDL_sysloadso.c +++ b/src/loadso/dummy/SDL_sysloadso.c @@ -43,8 +43,7 @@ SDL_LoadFunction(void *handle, const char *name) return NULL; } -void -SDL_UnloadObject(void *handle) +void SDL_UnloadObject(void *handle) { /* no-op. */ } diff --git a/src/loadso/windows/SDL_sysloadso.c b/src/loadso/windows/SDL_sysloadso.c index 3db6be2d0..76004ca0a 100644 --- a/src/loadso/windows/SDL_sysloadso.c +++ b/src/loadso/windows/SDL_sysloadso.c @@ -45,9 +45,9 @@ SDL_LoadObject(const char *sofile) files. LoadLibrary() is a private API, and not available for apps (that can be published to MS' Windows Store.) */ - handle = (void *) LoadPackagedLibrary(tstr, 0); + handle = (void *)LoadPackagedLibrary(tstr, 0); #else - handle = (void *) LoadLibrary(tstr); + handle = (void *)LoadLibrary(tstr); #endif SDL_free(tstr); @@ -64,7 +64,7 @@ SDL_LoadObject(const char *sofile) void * SDL_LoadFunction(void *handle, const char *name) { - void *symbol = (void *) GetProcAddress((HMODULE) handle, name); + void *symbol = (void *)GetProcAddress((HMODULE)handle, name); if (symbol == NULL) { char errbuf[512]; SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf)); @@ -74,11 +74,10 @@ SDL_LoadFunction(void *handle, const char *name) return symbol; } -void -SDL_UnloadObject(void *handle) +void SDL_UnloadObject(void *handle) { if (handle != NULL) { - FreeLibrary((HMODULE) handle); + FreeLibrary((HMODULE)handle); } } diff --git a/src/locale/SDL_locale.c b/src/locale/SDL_locale.c index c9fa4787a..e9085b44d 100644 --- a/src/locale/SDL_locale.c +++ b/src/locale/SDL_locale.c @@ -23,10 +23,9 @@ #include "SDL_syslocale.h" #include "SDL_hints.h" -static SDL_Locale * -build_locales_from_csv_string(char *csv) +static SDL_Locale *build_locales_from_csv_string(char *csv) { - size_t num_locales = 1; /* at least one */ + size_t num_locales = 1; /* at least one */ size_t slen; size_t alloclen; char *ptr; @@ -34,7 +33,7 @@ build_locales_from_csv_string(char *csv) SDL_Locale *retval; if (csv == NULL || !csv[0]) { - return NULL; /* nothing to report */ + return NULL; /* nothing to report */ } for (ptr = csv; *ptr; ptr++) { @@ -43,20 +42,20 @@ build_locales_from_csv_string(char *csv) } } - num_locales++; /* one more for terminator */ + num_locales++; /* one more for terminator */ - slen = ((size_t) (ptr - csv)) + 1; /* SDL_strlen(csv) + 1 */ - alloclen = slen + (num_locales * sizeof (SDL_Locale)); + slen = ((size_t)(ptr - csv)) + 1; /* SDL_strlen(csv) + 1 */ + alloclen = slen + (num_locales * sizeof(SDL_Locale)); - loc = retval = (SDL_Locale *) SDL_calloc(1, alloclen); + loc = retval = (SDL_Locale *)SDL_calloc(1, alloclen); if (retval == NULL) { SDL_OutOfMemory(); - return NULL; /* oh well */ + return NULL; /* oh well */ } - ptr = (char *) (retval + num_locales); + ptr = (char *)(retval + num_locales); SDL_strlcpy(ptr, csv, slen); - while (SDL_TRUE) { /* parse out the string */ + while (SDL_TRUE) { /* parse out the string */ while (*ptr == ' ') { ptr++; /* skip whitespace. */ } @@ -71,7 +70,7 @@ build_locales_from_csv_string(char *csv) *(ptr++) = '\0'; loc->country = ptr; } else if (ch == ' ') { - *(ptr++) = '\0'; /* trim ending whitespace and keep going. */ + *(ptr++) = '\0'; /* trim ending whitespace and keep going. */ } else if (ch == ',') { *(ptr++) = '\0'; loc++; @@ -80,7 +79,7 @@ build_locales_from_csv_string(char *csv) loc++; break; } else { - ptr++; /* just keep going, still a valid string */ + ptr++; /* just keep going, still a valid string */ } } } @@ -91,16 +90,15 @@ build_locales_from_csv_string(char *csv) SDL_Locale * SDL_GetPreferredLocales(void) { - char locbuf[128]; /* enough for 21 "xx_YY," language strings. */ + char locbuf[128]; /* enough for 21 "xx_YY," language strings. */ const char *hint = SDL_GetHint(SDL_HINT_PREFERRED_LOCALES); if (hint) { - SDL_strlcpy(locbuf, hint, sizeof (locbuf)); + SDL_strlcpy(locbuf, hint, sizeof(locbuf)); } else { SDL_zeroa(locbuf); - SDL_SYS_GetPreferredLocales(locbuf, sizeof (locbuf)); + SDL_SYS_GetPreferredLocales(locbuf, sizeof(locbuf)); } return build_locales_from_csv_string(locbuf); } /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/locale/android/SDL_syslocale.c b/src/locale/android/SDL_syslocale.c index ed969b8dd..dee0d96de 100644 --- a/src/locale/android/SDL_syslocale.c +++ b/src/locale/android/SDL_syslocale.c @@ -23,11 +23,9 @@ #include "../SDL_syslocale.h" #include "../../core/android/SDL_android.h" -void -SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) +void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) { Android_JNI_GetLocale(buf, buflen); } /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/locale/dummy/SDL_syslocale.c b/src/locale/dummy/SDL_syslocale.c index e5ed1ad13..8e7e91cbe 100644 --- a/src/locale/dummy/SDL_syslocale.c +++ b/src/locale/dummy/SDL_syslocale.c @@ -22,12 +22,10 @@ #include "../../SDL_internal.h" #include "../SDL_syslocale.h" -void -SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) +void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) { /* dummy implementation. Caller already zero'd out buffer. */ SDL_Unsupported(); } /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/locale/emscripten/SDL_syslocale.c b/src/locale/emscripten/SDL_syslocale.c index 98d3c0353..de0bdde1d 100644 --- a/src/locale/emscripten/SDL_syslocale.c +++ b/src/locale/emscripten/SDL_syslocale.c @@ -24,9 +24,9 @@ #include "../../SDL_internal.h" #include "../SDL_syslocale.h" -void -SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) +void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) { + /* *INDENT-OFF* */ /* clang-format off */ EM_ASM({ var buf = $0; var buflen = $1; @@ -66,7 +66,7 @@ SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) setValue(buf + i, str.charCodeAt(i), "i8"); /* fill in C array. */ } }, buf, buflen); + /* *INDENT-ON* */ /* clang-format on */ } /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/locale/macosx/SDL_syslocale.m b/src/locale/macosx/SDL_syslocale.m index 0e6bd3634..ef8eabab2 100644 --- a/src/locale/macosx/SDL_syslocale.m +++ b/src/locale/macosx/SDL_syslocale.m @@ -24,53 +24,53 @@ #import -void -SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) -{ @autoreleasepool { - NSArray *languages = NSLocale.preferredLanguages; - size_t numlangs = 0; - size_t i; +void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) +{ + @autoreleasepool { + NSArray *languages = NSLocale.preferredLanguages; + size_t numlangs = 0; + size_t i; - numlangs = (size_t) [languages count]; + numlangs = (size_t)[languages count]; - for (i = 0; i < numlangs; i++) { - NSString *nsstr = [languages objectAtIndex:i]; - size_t len; - char *ptr; + for (i = 0; i < numlangs; i++) { + NSString *nsstr = [languages objectAtIndex:i]; + size_t len; + char *ptr; - if (nsstr == nil) { - break; - } - - [nsstr getCString:buf maxLength:buflen encoding:NSASCIIStringEncoding]; - len = SDL_strlen(buf); - - // convert '-' to '_'... - // These are always full lang-COUNTRY, so we search from the back, - // so things like zh-Hant-CN find the right '-' to convert. - if ((ptr = SDL_strrchr(buf, '-')) != NULL) { - *ptr = '_'; - } - - if (buflen <= len) { - *buf = '\0'; // drop this one and stop, we can't fit anymore. - break; - } - - buf += len; - buflen -= len; - - if (i < (numlangs - 1)) { - if (buflen <= 1) { - break; // out of room, stop looking. + if (nsstr == nil) { + break; + } + + [nsstr getCString:buf maxLength:buflen encoding:NSASCIIStringEncoding]; + len = SDL_strlen(buf); + + // convert '-' to '_'... + // These are always full lang-COUNTRY, so we search from the back, + // so things like zh-Hant-CN find the right '-' to convert. + if ((ptr = SDL_strrchr(buf, '-')) != NULL) { + *ptr = '_'; + } + + if (buflen <= len) { + *buf = '\0'; // drop this one and stop, we can't fit anymore. + break; + } + + buf += len; + buflen -= len; + + if (i < (numlangs - 1)) { + if (buflen <= 1) { + break; // out of room, stop looking. + } + buf[0] = ','; // add a comma between entries. + buf[1] = '\0'; + buf++; + buflen--; } - buf[0] = ','; // add a comma between entries. - buf[1] = '\0'; - buf++; - buflen--; } } -}} +} /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/locale/n3ds/SDL_syslocale.c b/src/locale/n3ds/SDL_syslocale.c index bcfec8f1d..00d777de4 100644 --- a/src/locale/n3ds/SDL_syslocale.c +++ b/src/locale/n3ds/SDL_syslocale.c @@ -29,8 +29,7 @@ SDL_FORCE_INLINE u8 GetLocaleIndex(void); -void -SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) +void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) { /* The 3DS only supports these 12 languages, only one can be active at a time */ static const char AVAILABLE_LOCALES[][6] = { "ja_JP", "en_US", "fr_FR", "de_DE", diff --git a/src/locale/unix/SDL_syslocale.c b/src/locale/unix/SDL_syslocale.c index 518856a36..94539c1d5 100644 --- a/src/locale/unix/SDL_syslocale.c +++ b/src/locale/unix/SDL_syslocale.c @@ -22,17 +22,16 @@ #include "../../SDL_internal.h" #include "../SDL_syslocale.h" -static void -normalize_locale_str(char *dst, char *str, size_t buflen) +static void normalize_locale_str(char *dst, char *str, size_t buflen) { char *ptr; - ptr = SDL_strchr(str, '.'); /* chop off encoding if specified. */ + ptr = SDL_strchr(str, '.'); /* chop off encoding if specified. */ if (ptr != NULL) { *ptr = '\0'; } - ptr = SDL_strchr(str, '@'); /* chop off extra bits if specified. */ + ptr = SDL_strchr(str, '@'); /* chop off extra bits if specified. */ if (ptr != NULL) { *ptr = '\0'; } @@ -44,14 +43,13 @@ normalize_locale_str(char *dst, char *str, size_t buflen) if (*str) { if (*dst) { - SDL_strlcat(dst, ",", buflen); /* SDL has these split by commas */ + SDL_strlcat(dst, ",", buflen); /* SDL has these split by commas */ } SDL_strlcat(dst, str, buflen); } } -static void -normalize_locales(char *dst, char *src, size_t buflen) +static void normalize_locales(char *dst, char *src, size_t buflen) { char *ptr; @@ -64,8 +62,7 @@ normalize_locales(char *dst, char *src, size_t buflen) normalize_locale_str(dst, src, buflen); } -void -SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) +void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) { /* !!! FIXME: should we be using setlocale()? Or some D-Bus thing? */ SDL_bool isstack; @@ -106,4 +103,3 @@ SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) } /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/locale/vita/SDL_syslocale.c b/src/locale/vita/SDL_syslocale.c index cde912cf8..f07f74653 100644 --- a/src/locale/vita/SDL_syslocale.c +++ b/src/locale/vita/SDL_syslocale.c @@ -25,8 +25,7 @@ #include #include -void -SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) +void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) { const char *vita_locales[] = { "ja_JP", @@ -69,4 +68,3 @@ SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) } /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/locale/windows/SDL_syslocale.c b/src/locale/windows/SDL_syslocale.c index 3bbaa1e68..8373ab9e2 100644 --- a/src/locale/windows/SDL_syslocale.c +++ b/src/locale/windows/SDL_syslocale.c @@ -23,7 +23,7 @@ #include "../../core/windows/SDL_windows.h" #include "../SDL_syslocale.h" -typedef BOOL (WINAPI *pfnGetUserPreferredUILanguages)(DWORD,PULONG,WCHAR*,PULONG); +typedef BOOL(WINAPI *pfnGetUserPreferredUILanguages)(DWORD, PULONG, WCHAR *, PULONG); #ifndef MUI_LANGUAGE_NAME #define MUI_LANGUAGE_NAME 0x8 #endif @@ -31,21 +31,19 @@ typedef BOOL (WINAPI *pfnGetUserPreferredUILanguages)(DWORD,PULONG,WCHAR*,PULONG static pfnGetUserPreferredUILanguages pGetUserPreferredUILanguages = NULL; static HMODULE kernel32 = 0; - /* this is the fallback for WinXP...one language, not a list. */ -static void -SDL_SYS_GetPreferredLocales_winxp(char *buf, size_t buflen) +static void SDL_SYS_GetPreferredLocales_winxp(char *buf, size_t buflen) { char lang[16]; char country[16]; const int langrc = GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, - lang, sizeof (lang)); + lang, sizeof(lang)); - const int ctryrc = GetLocaleInfoA(LOCALE_USER_DEFAULT, - LOCALE_SISO3166CTRYNAME, - country, sizeof (country)); + const int ctryrc = GetLocaleInfoA(LOCALE_USER_DEFAULT, + LOCALE_SISO3166CTRYNAME, + country, sizeof(country)); /* Win95 systems will fail, because they don't have LOCALE_SISO*NAME ... */ if (langrc == 0) { @@ -56,8 +54,7 @@ SDL_SYS_GetPreferredLocales_winxp(char *buf, size_t buflen) } /* this works on Windows Vista and later. */ -static void -SDL_SYS_GetPreferredLocales_vista(char *buf, size_t buflen) +static void SDL_SYS_GetPreferredLocales_vista(char *buf, size_t buflen) { ULONG numlangs = 0; WCHAR *wbuf = NULL; @@ -74,44 +71,42 @@ SDL_SYS_GetPreferredLocales_vista(char *buf, size_t buflen) } if (!pGetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &numlangs, wbuf, &wbuflen)) { - SDL_SYS_GetPreferredLocales_winxp(buf, buflen); /* oh well, try the fallback. */ + SDL_SYS_GetPreferredLocales_winxp(buf, buflen); /* oh well, try the fallback. */ } else { - const ULONG endidx = (ULONG) SDL_min(buflen, wbuflen - 1); + const ULONG endidx = (ULONG)SDL_min(buflen, wbuflen - 1); ULONG str_start = 0; ULONG i; for (i = 0; i < endidx; i++) { - const char ch = (char) wbuf[i]; /* these should all be low-ASCII, safe to cast */ + const char ch = (char)wbuf[i]; /* these should all be low-ASCII, safe to cast */ if (ch == '\0') { - buf[i] = ','; /* change null separators to commas */ + buf[i] = ','; /* change null separators to commas */ str_start = i; } else if (ch == '-') { - buf[i] = '_'; /* change '-' to '_' */ + buf[i] = '_'; /* change '-' to '_' */ } else { - buf[i] = ch; /* copy through as-is. */ + buf[i] = ch; /* copy through as-is. */ } } - buf[str_start] = '\0'; /* terminate string, chop off final ',' */ + buf[str_start] = '\0'; /* terminate string, chop off final ',' */ } SDL_small_free(wbuf, isstack); } -void -SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) +void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) { if (!kernel32) { kernel32 = GetModuleHandle(TEXT("kernel32.dll")); if (kernel32) { - pGetUserPreferredUILanguages = (pfnGetUserPreferredUILanguages) GetProcAddress(kernel32, "GetUserPreferredUILanguages"); + pGetUserPreferredUILanguages = (pfnGetUserPreferredUILanguages)GetProcAddress(kernel32, "GetUserPreferredUILanguages"); } } if (pGetUserPreferredUILanguages == NULL) { - SDL_SYS_GetPreferredLocales_winxp(buf, buflen); /* this is always available */ + SDL_SYS_GetPreferredLocales_winxp(buf, buflen); /* this is always available */ } else { - SDL_SYS_GetPreferredLocales_vista(buf, buflen); /* available on Vista and later. */ + SDL_SYS_GetPreferredLocales_vista(buf, buflen); /* available on Vista and later. */ } } /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/locale/winrt/SDL_syslocale.c b/src/locale/winrt/SDL_syslocale.c index 55de84521..62d35a946 100644 --- a/src/locale/winrt/SDL_syslocale.c +++ b/src/locale/winrt/SDL_syslocale.c @@ -27,31 +27,29 @@ /*using namespace Windows::Graphics::Display;*/ #include -void -SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) +void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) { WCHAR wbuffer[128] = L""; int ret = 0; /* !!! FIXME: do we not have GetUserPreferredUILanguages on WinPhone or UWP? */ -# if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP ret = GetLocaleInfoEx(LOCALE_NAME_SYSTEM_DEFAULT, LOCALE_SNAME, wbuffer, SDL_arraysize(wbuffer)); -# else +#else ret = GetSystemDefaultLocaleName(wbuffer, SDL_arraysize(wbuffer)); -# endif +#endif if (ret > 0) { /* Need to convert LPWSTR to LPSTR, that is wide char to char. */ int i; - if ( ((size_t) ret) >= (buflen - 1) ) { - ret = (int) (buflen - 1); + if (((size_t)ret) >= (buflen - 1)) { + ret = (int)(buflen - 1); } for (i = 0; i < ret; i++) { - buf[i] = (char) wbuffer[i]; /* assume this was ASCII anyhow. */ + buf[i] = (char)wbuffer[i]; /* assume this was ASCII anyhow. */ } } } /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/main/dummy/SDL_dummy_main.c b/src/main/dummy/SDL_dummy_main.c index 4abe47d07..097b210d7 100644 --- a/src/main/dummy/SDL_dummy_main.c +++ b/src/main/dummy/SDL_dummy_main.c @@ -8,15 +8,13 @@ #ifdef main #undef main -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { return SDL_main(argc, argv); } #else /* Nothing to do on this platform */ -int -SDL_main_stub_symbol(void) +int SDL_main_stub_symbol(void) { return 0; } diff --git a/src/main/gdk/SDL_gdk_main.c b/src/main/gdk/SDL_gdk_main.c index 4a25bbb18..617e0abcc 100644 --- a/src/main/gdk/SDL_gdk_main.c +++ b/src/main/gdk/SDL_gdk_main.c @@ -28,7 +28,7 @@ #include "SDL_main.h" #ifdef main -# undef main +#undef main #endif /* main */ /* This is where execution begins */ diff --git a/src/main/haiku/SDL_BApp.h b/src/main/haiku/SDL_BApp.h index 215f83662..416ebbb2d 100644 --- a/src/main/haiku/SDL_BApp.h +++ b/src/main/haiku/SDL_BApp.h @@ -30,7 +30,6 @@ #include "../../video/haiku/SDL_bkeyboard.h" - #ifdef __cplusplus extern "C" { #endif @@ -49,65 +48,63 @@ extern "C" { #include - - - /* Forward declarations */ class SDL_BWin; /* Message constants */ -enum ToSDL { +enum ToSDL +{ /* Intercepted by BWindow on its way to BView */ BAPP_MOUSE_MOVED, BAPP_MOUSE_BUTTON, BAPP_MOUSE_WHEEL, BAPP_KEY, - BAPP_REPAINT, /* from _UPDATE_ */ + BAPP_REPAINT, /* from _UPDATE_ */ /* From BWindow */ - BAPP_MAXIMIZE, /* from B_ZOOM */ + BAPP_MAXIMIZE, /* from B_ZOOM */ BAPP_MINIMIZE, - BAPP_RESTORE, /* TODO: IMPLEMENT! */ + BAPP_RESTORE, /* TODO: IMPLEMENT! */ BAPP_SHOW, BAPP_HIDE, - BAPP_MOUSE_FOCUS, /* caused by MOUSE_MOVE */ - BAPP_KEYBOARD_FOCUS, /* from WINDOW_ACTIVATED */ + BAPP_MOUSE_FOCUS, /* caused by MOUSE_MOVE */ + BAPP_KEYBOARD_FOCUS, /* from WINDOW_ACTIVATED */ BAPP_WINDOW_CLOSE_REQUESTED, BAPP_WINDOW_MOVED, BAPP_WINDOW_RESIZED, BAPP_SCREEN_CHANGED }; - - /* Create a descendant of BApplication */ -class SDL_BApp : public BApplication { -public: - SDL_BApp(const char* signature) : - BApplication(signature) { +class SDL_BApp : public BApplication +{ + public: + SDL_BApp(const char *signature) : BApplication(signature) + { #if SDL_VIDEO_OPENGL _current_context = NULL; #endif } - - virtual ~SDL_BApp() { + virtual ~SDL_BApp() + { } + virtual void RefsReceived(BMessage *message) + { + char filePath[512]; + entry_ref entryRef; + for (int32 i = 0; message->FindRef("refs", i, &entryRef) == B_OK; i++) { + BPath referencePath = BPath(&entryRef); + SDL_SendDropFile(NULL, referencePath.Path()); + } + return; + } - virtual void RefsReceived(BMessage* message) { - char filePath[512]; - entry_ref entryRef; - for (int32 i = 0; message->FindRef("refs", i, &entryRef) == B_OK; i++) { - BPath referencePath = BPath(&entryRef); - SDL_SendDropFile(NULL, referencePath.Path()); - } - return; - } - - /* Event-handling functions */ - virtual void MessageReceived(BMessage* message) { + /* Event-handling functions */ + virtual void MessageReceived(BMessage *message) + { /* Sort out SDL-related messages */ - switch ( message->what ) { + switch (message->what) { case BAPP_MOUSE_MOVED: _HandleMouseMove(message); break; @@ -173,23 +170,24 @@ public: break; default: - BApplication::MessageReceived(message); - break; + BApplication::MessageReceived(message); + break; } } /* Window creation/destruction methods */ - int32 GetID(SDL_Window *win) { + int32 GetID(SDL_Window *win) + { int32 i; - for(i = 0; i < _GetNumWindowSlots(); ++i) { - if( GetSDLWindow(i) == NULL ) { + for (i = 0; i < _GetNumWindowSlots(); ++i) { + if (GetSDLWindow(i) == NULL) { _SetSDLWindow(win, i); return i; } } /* Expand the vector if all slots are full */ - if( i == _GetNumWindowSlots() ) { + if (i == _GetNumWindowSlots()) { _PushBackWindow(win); return i; } @@ -202,18 +200,20 @@ public: there another way to do this? */ void ClearID(SDL_BWin *bwin); /* Defined in SDL_BeApp.cc */ - - SDL_Window *GetSDLWindow(int32 winID) { + SDL_Window *GetSDLWindow(int32 winID) + { return _window_map[winID]; } #if SDL_VIDEO_OPENGL - BGLView *GetCurrentContext() { + BGLView *GetCurrentContext() + { return _current_context; } - - void SetCurrentContext(BGLView *newContext) { - if(_current_context) + + void SetCurrentContext(BGLView *newContext) + { + if (_current_context) _current_context->UnlockGL(); _current_context = newContext; if (_current_context) @@ -221,25 +221,26 @@ public: } #endif -private: + private: /* Event management */ - void _HandleBasicWindowEvent(BMessage *msg, int32 sdlEventType) { + void _HandleBasicWindowEvent(BMessage *msg, int32 sdlEventType) + { SDL_Window *win; int32 winID; - if( - !_GetWinID(msg, &winID) - ) { + if ( + !_GetWinID(msg, &winID)) { return; } win = GetSDLWindow(winID); SDL_SendWindowEvent(win, sdlEventType, 0, 0); } - void _HandleMouseMove(BMessage *msg) { + void _HandleMouseMove(BMessage *msg) + { SDL_Window *win; int32 winID; int32 x = 0, y = 0; - if( + if ( !_GetWinID(msg, &winID) || msg->FindInt32("x", &x) != B_OK || /* x movement */ msg->FindInt32("y", &y) != B_OK /* y movement */ @@ -266,47 +267,47 @@ private: } } - void _HandleMouseButton(BMessage *msg) { + void _HandleMouseButton(BMessage *msg) + { SDL_Window *win; int32 winID; - int32 button, state; /* left/middle/right, pressed/released */ - if( + int32 button, state; /* left/middle/right, pressed/released */ + if ( !_GetWinID(msg, &winID) || msg->FindInt32("button-id", &button) != B_OK || - msg->FindInt32("button-state", &state) != B_OK - ) { + msg->FindInt32("button-state", &state) != B_OK) { return; } win = GetSDLWindow(winID); SDL_SendMouseButton(win, 0, state, button); } - void _HandleMouseWheel(BMessage *msg) { + void _HandleMouseWheel(BMessage *msg) + { SDL_Window *win; int32 winID; int32 xTicks, yTicks; - if( + if ( !_GetWinID(msg, &winID) || msg->FindInt32("xticks", &xTicks) != B_OK || - msg->FindInt32("yticks", &yTicks) != B_OK - ) { + msg->FindInt32("yticks", &yTicks) != B_OK) { return; } win = GetSDLWindow(winID); SDL_SendMouseWheel(win, 0, xTicks, -yTicks, SDL_MOUSEWHEEL_NORMAL); } - void _HandleKey(BMessage *msg) { - int32 scancode, state; /* scancode, pressed/released */ - if( + void _HandleKey(BMessage *msg) + { + int32 scancode, state; /* scancode, pressed/released */ + if ( msg->FindInt32("key-state", &state) != B_OK || - msg->FindInt32("key-scancode", &scancode) != B_OK - ) { + msg->FindInt32("key-scancode", &scancode) != B_OK) { return; } /* Make sure this isn't a repeated event (key pressed and held) */ - if(state == SDL_PRESSED && HAIKU_GetKeyState(scancode) == SDL_PRESSED) { + if (state == SDL_PRESSED && HAIKU_GetKeyState(scancode) == SDL_PRESSED) { return; } HAIKU_SetKeyState(scancode, state); @@ -315,7 +316,7 @@ private: if (state == SDL_PRESSED && SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { const int8 *keyUtf8; ssize_t count; - if (msg->FindData("key-utf8", B_INT8_TYPE, (const void**)&keyUtf8, &count) == B_OK) { + if (msg->FindData("key-utf8", B_INT8_TYPE, (const void **)&keyUtf8, &count) == B_OK) { char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; SDL_zeroa(text); SDL_memcpy(text, keyUtf8, count); @@ -324,107 +325,108 @@ private: } } - void _HandleMouseFocus(BMessage *msg) { + void _HandleMouseFocus(BMessage *msg) + { SDL_Window *win; int32 winID; bool bSetFocus; /* If false, lose focus */ - if( + if ( !_GetWinID(msg, &winID) || - msg->FindBool("focusGained", &bSetFocus) != B_OK - ) { + msg->FindBool("focusGained", &bSetFocus) != B_OK) { return; } win = GetSDLWindow(winID); - if(bSetFocus) { + if (bSetFocus) { SDL_SetMouseFocus(win); - } else if(SDL_GetMouseFocus() == win) { + } else if (SDL_GetMouseFocus() == win) { /* Only lose all focus if this window was the current focus */ SDL_SetMouseFocus(NULL); } } - void _HandleKeyboardFocus(BMessage *msg) { + void _HandleKeyboardFocus(BMessage *msg) + { SDL_Window *win; int32 winID; bool bSetFocus; /* If false, lose focus */ - if( + if ( !_GetWinID(msg, &winID) || - msg->FindBool("focusGained", &bSetFocus) != B_OK - ) { + msg->FindBool("focusGained", &bSetFocus) != B_OK) { return; } win = GetSDLWindow(winID); - if(bSetFocus) { + if (bSetFocus) { SDL_SetKeyboardFocus(win); - } else if(SDL_GetKeyboardFocus() == win) { + } else if (SDL_GetKeyboardFocus() == win) { /* Only lose all focus if this window was the current focus */ SDL_SetKeyboardFocus(NULL); } } - void _HandleWindowMoved(BMessage *msg) { + void _HandleWindowMoved(BMessage *msg) + { SDL_Window *win; int32 winID; int32 xPos, yPos; /* Get the window id and new x/y position of the window */ - if( + if ( !_GetWinID(msg, &winID) || msg->FindInt32("window-x", &xPos) != B_OK || - msg->FindInt32("window-y", &yPos) != B_OK - ) { + msg->FindInt32("window-y", &yPos) != B_OK) { return; } win = GetSDLWindow(winID); SDL_SendWindowEvent(win, SDL_WINDOWEVENT_MOVED, xPos, yPos); } - void _HandleWindowResized(BMessage *msg) { + void _HandleWindowResized(BMessage *msg) + { SDL_Window *win; int32 winID; int32 w, h; /* Get the window id ]and new x/y position of the window */ - if( + if ( !_GetWinID(msg, &winID) || msg->FindInt32("window-w", &w) != B_OK || - msg->FindInt32("window-h", &h) != B_OK - ) { + msg->FindInt32("window-h", &h) != B_OK) { return; } win = GetSDLWindow(winID); SDL_SendWindowEvent(win, SDL_WINDOWEVENT_RESIZED, w, h); } - bool _GetWinID(BMessage *msg, int32 *winID) { + bool _GetWinID(BMessage *msg, int32 *winID) + { return msg->FindInt32("window-id", winID) == B_OK; } - - /* Vector functions: Wraps vector stuff in case we need to change implementation */ - void _SetSDLWindow(SDL_Window *win, int32 winID) { + void _SetSDLWindow(SDL_Window *win, int32 winID) + { _window_map[winID] = win; } - int32 _GetNumWindowSlots() { + int32 _GetNumWindowSlots() + { return _window_map.size(); } - - void _PopBackWindow() { + void _PopBackWindow() + { _window_map.pop_back(); } - void _PushBackWindow(SDL_Window *win) { + void _PushBackWindow(SDL_Window *win) + { _window_map.push_back(win); } - /* Members */ - std::vector _window_map; /* Keeps track of SDL_Windows by index-id */ + std::vector _window_map; /* Keeps track of SDL_Windows by index-id */ #if SDL_VIDEO_OPENGL - BGLView *_current_context; + BGLView *_current_context; #endif }; diff --git a/src/main/haiku/SDL_BeApp.cc b/src/main/haiku/SDL_BeApp.cc index 1fb6fe1b2..81bafe4de 100644 --- a/src/main/haiku/SDL_BeApp.cc +++ b/src/main/haiku/SDL_BeApp.cc @@ -51,8 +51,7 @@ static SDL_Thread *SDL_AppThread = NULL; /* Default application signature */ const char *signature = "application/x-SDL-executable"; -static int -StartBeApp(void *unused) +static int StartBeApp(void *unused) { BApplication *App; diff --git a/src/main/n3ds/SDL_n3ds_main.c b/src/main/n3ds/SDL_n3ds_main.c index 1ccd01480..5d2762578 100644 --- a/src/main/n3ds/SDL_n3ds_main.c +++ b/src/main/n3ds/SDL_n3ds_main.c @@ -33,8 +33,7 @@ SDL_FORCE_INLINE void N3DS_Init(void); SDL_FORCE_INLINE void N3DS_Quit(void); -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int result; N3DS_Init(); diff --git a/src/main/ngage/SDL_ngage_main.cpp b/src/main/ngage/SDL_ngage_main.cpp index dc83a8b65..10d848870 100644 --- a/src/main/ngage/SDL_ngage_main.cpp +++ b/src/main/ngage/SDL_ngage_main.cpp @@ -23,17 +23,17 @@ extern "C" int main(int argc, char *argv[]); TInt E32Main() { /* Get the clean-up stack */ - CTrapCleanup* cleanup = CTrapCleanup::New(); + CTrapCleanup *cleanup = CTrapCleanup::New(); /* Arrange for multi-threaded operation */ SpawnPosixServerThread(); /* Get args and environment */ - int argc = 0; - char** argv = 0; - char** envp = 0; + int argc = 0; + char **argv = 0; + char **envp = 0; - __crt0(argc,argv,envp); + __crt0(argc, argv, envp); /* Start the application! */ @@ -42,19 +42,19 @@ TInt E32Main() /* Set process and thread priority and name */ - RThread currentThread; + RThread currentThread; RProcess thisProcess; - TParse exeName; + TParse exeName; exeName.Set(thisProcess.FileName(), NULL, NULL); currentThread.Rename(exeName.Name()); currentThread.SetProcessPriority(EPriorityLow); currentThread.SetPriority(EPriorityMuchLess); /* Increase heap size */ - RHeap* newHeap = NULL; - RHeap* oldHeap = NULL; - TInt heapSize = 7500000; - int ret; + RHeap *newHeap = NULL; + RHeap *oldHeap = NULL; + TInt heapSize = 7500000; + int ret; newHeap = User::ChunkHeap(NULL, heapSize, heapSize, KMinHeapGrowBy); diff --git a/src/main/ps2/SDL_ps2_main.c b/src/main/ps2/SDL_ps2_main.c index 0525797d2..d3fb6171f 100644 --- a/src/main/ps2/SDL_ps2_main.c +++ b/src/main/ps2/SDL_ps2_main.c @@ -1,5 +1,5 @@ /* - SDL_ps2_main.c, fjtrujy@gmail.com + SDL_ps2_main.c, fjtrujy@gmail.com */ #include "SDL_config.h" @@ -22,11 +22,11 @@ #include #ifdef main - #undef main +#undef main #endif -__attribute__((weak)) -void reset_IOP() { +__attribute__((weak)) void reset_IOP() +{ SifInitRpc(0); while (!SifIopReset(NULL, 0)) { } @@ -43,12 +43,14 @@ static void prepare_IOP() sbv_patch_fileio(); } -static void init_drivers() { +static void init_drivers() +{ init_memcard_driver(true); init_usb_driver(true); } -static void deinit_drivers() { +static void deinit_drivers() +{ deinit_usb_driver(true); deinit_memcard_driver(true); } @@ -75,14 +77,14 @@ int main(int argc, char *argv[]) prepare_IOP(); init_drivers(); - + getcwd(cwd, sizeof(cwd)); waitUntilDeviceIsReady(cwd); res = SDL_main(argc, argv); - deinit_drivers(); - + deinit_drivers(); + return res; } diff --git a/src/main/psp/SDL_psp_main.c b/src/main/psp/SDL_psp_main.c index 6e7bc8eef..3d083cc75 100644 --- a/src/main/psp/SDL_psp_main.c +++ b/src/main/psp/SDL_psp_main.c @@ -10,7 +10,7 @@ #include #ifdef main - #undef main +#undef main #endif /* If application's main() is redefined as SDL_main, and libSDLmain is @@ -36,7 +36,7 @@ int sdl_psp_callback_thread(SceSize args, void *argp) { int cbid; cbid = sceKernelCreateCallback("Exit Callback", - sdl_psp_exit_callback, NULL); + sdl_psp_exit_callback, NULL); sceKernelRegisterExitCallback(cbid); sceKernelSleepThreadCB(); return 0; @@ -46,7 +46,7 @@ int sdl_psp_setup_callbacks(void) { int thid; thid = sceKernelCreateThread("update_thread", - sdl_psp_callback_thread, 0x11, 0xFA0, 0, 0); + sdl_psp_callback_thread, 0x11, 0xFA0, 0, 0); if (thid >= 0) { sceKernelStartThread(thid, 0, 0); } diff --git a/src/main/uikit/SDL_uikit_main.c b/src/main/uikit/SDL_uikit_main.c index 90c20d1db..6ce349293 100644 --- a/src/main/uikit/SDL_uikit_main.c +++ b/src/main/uikit/SDL_uikit_main.c @@ -12,8 +12,7 @@ #undef main #endif -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { return SDL_UIKitRunApp(argc, argv, SDL_main); } diff --git a/src/main/windows/SDL_windows_main.c b/src/main/windows/SDL_windows_main.c index dd477aec3..1ed9e35d5 100644 --- a/src/main/windows/SDL_windows_main.c +++ b/src/main/windows/SDL_windows_main.c @@ -16,12 +16,11 @@ #include "SDL_main.h" #ifdef main -# undef main +#undef main #endif /* main */ /* Pop up an out of memory message, returns to Windows */ -static BOOL -OutOfMemory(void) +static BOOL OutOfMemory(void) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal Error", "Out of memory - aborting", NULL); return FALSE; @@ -29,16 +28,15 @@ OutOfMemory(void) #if defined(_MSC_VER) /* The VC++ compiler needs main/wmain defined */ -# define console_ansi_main main -# if UNICODE -# define console_wmain wmain -# endif +#define console_ansi_main main +#if UNICODE +#define console_wmain wmain +#endif #endif /* Gets the arguments with GetCommandLine, converts them to argc and argv and calls SDL_main */ -static int -main_getcmdline(void) +static int main_getcmdline(void) { LPWSTR *argvw; char **argv; @@ -91,17 +89,14 @@ main_getcmdline(void) } /* This is where execution begins [console apps, ansi] */ -int -console_ansi_main(int argc, char *argv[]) +int console_ansi_main(int argc, char *argv[]) { return main_getcmdline(); } - #if UNICODE /* This is where execution begins [console apps, unicode] */ -int -console_wmain(int argc, wchar_t *wargv[], wchar_t *wenvp) +int console_wmain(int argc, wchar_t *wargv[], wchar_t *wenvp) { return main_getcmdline(); } diff --git a/src/main/winrt/SDL_winrt_main_NonXAML.cpp b/src/main/winrt/SDL_winrt_main_NonXAML.cpp index 19d22504c..575a62c18 100644 --- a/src/main/winrt/SDL_winrt_main_NonXAML.cpp +++ b/src/main/winrt/SDL_winrt_main_NonXAML.cpp @@ -40,7 +40,7 @@ is compiled with C++/CX enabled (via the /ZW compiler flag). */ #ifdef _MSC_VER -#pragma warning(disable:4447) +#pragma warning(disable : 4447) #endif /* Make sure the function to initialize the Windows Runtime gets linked in. */ diff --git a/src/misc/SDL_url.c b/src/misc/SDL_url.c index 8091bd8d2..d3672d65c 100644 --- a/src/misc/SDL_url.c +++ b/src/misc/SDL_url.c @@ -23,8 +23,7 @@ extern int SDL_SYS_OpenURL(const char *url); -int -SDL_OpenURL(const char *url) +int SDL_OpenURL(const char *url) { if (url == NULL) { return SDL_InvalidParamError("url"); diff --git a/src/misc/android/SDL_sysurl.c b/src/misc/android/SDL_sysurl.c index c17fbca46..7a02c3a64 100644 --- a/src/misc/android/SDL_sysurl.c +++ b/src/misc/android/SDL_sysurl.c @@ -22,11 +22,9 @@ #include "../SDL_sysurl.h" #include "../../core/android/SDL_android.h" -int -SDL_SYS_OpenURL(const char *url) +int SDL_SYS_OpenURL(const char *url) { return Android_JNI_OpenURL(url); } /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/misc/dummy/SDL_sysurl.c b/src/misc/dummy/SDL_sysurl.c index d35d016fc..4f1053847 100644 --- a/src/misc/dummy/SDL_sysurl.c +++ b/src/misc/dummy/SDL_sysurl.c @@ -21,11 +21,9 @@ #include "../SDL_sysurl.h" -int -SDL_SYS_OpenURL(const char *url) +int SDL_SYS_OpenURL(const char *url) { return SDL_Unsupported(); } /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/misc/emscripten/SDL_sysurl.c b/src/misc/emscripten/SDL_sysurl.c index f344232ab..3cc63a880 100644 --- a/src/misc/emscripten/SDL_sysurl.c +++ b/src/misc/emscripten/SDL_sysurl.c @@ -23,15 +23,14 @@ #include -int -SDL_SYS_OpenURL(const char *url) +int SDL_SYS_OpenURL(const char *url) { EM_ASM({ window.open(UTF8ToString($0), "_blank"); - }, url); + }, + url); return 0; } /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/misc/ios/SDL_sysurl.m b/src/misc/ios/SDL_sysurl.m index 73d5c73ec..f8b9fff97 100644 --- a/src/misc/ios/SDL_sysurl.m +++ b/src/misc/ios/SDL_sysurl.m @@ -23,14 +23,14 @@ #import -int -SDL_SYS_OpenURL(const char *url) -{ @autoreleasepool { +int SDL_SYS_OpenURL(const char *url) +{ + @autoreleasepool { - NSString *nsstr = [NSString stringWithUTF8String:url]; - NSURL *nsurl = [NSURL URLWithString:nsstr]; - return [[UIApplication sharedApplication] openURL:nsurl] ? 0 : -1; -}} + NSString *nsstr = [NSString stringWithUTF8String:url]; + NSURL *nsurl = [NSURL URLWithString:nsstr]; + return [[UIApplication sharedApplication] openURL:nsurl] ? 0 : -1; + } +} /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/misc/macosx/SDL_sysurl.m b/src/misc/macosx/SDL_sysurl.m index 1b141ee1f..e62d4ffeb 100644 --- a/src/misc/macosx/SDL_sysurl.m +++ b/src/misc/macosx/SDL_sysurl.m @@ -23,14 +23,14 @@ #import -int -SDL_SYS_OpenURL(const char *url) -{ @autoreleasepool +int SDL_SYS_OpenURL(const char *url) { - CFURLRef cfurl = CFURLCreateWithBytes(NULL, (const UInt8 *) url, SDL_strlen(url), kCFStringEncodingUTF8, NULL); - OSStatus status = LSOpenCFURLRef(cfurl, NULL); - CFRelease(cfurl); - return status == noErr ? 0 : -1; -}} + @autoreleasepool { + CFURLRef cfurl = CFURLCreateWithBytes(NULL, (const UInt8 *)url, SDL_strlen(url), kCFStringEncodingUTF8, NULL); + OSStatus status = LSOpenCFURLRef(cfurl, NULL); + CFRelease(cfurl); + return status == noErr ? 0 : -1; + } +} /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/misc/riscos/SDL_sysurl.c b/src/misc/riscos/SDL_sysurl.c index 2662c4d68..566b6f86e 100644 --- a/src/misc/riscos/SDL_sysurl.c +++ b/src/misc/riscos/SDL_sysurl.c @@ -28,8 +28,7 @@ #define URI_Dispatch 0x4e381 #endif -int -SDL_SYS_OpenURL(const char *url) +int SDL_SYS_OpenURL(const char *url) { _kernel_swi_regs regs; _kernel_oserror *error; @@ -46,4 +45,3 @@ SDL_SYS_OpenURL(const char *url) } /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/misc/unix/SDL_sysurl.c b/src/misc/unix/SDL_sysurl.c index 8d6e0fc91..a9f6e0380 100644 --- a/src/misc/unix/SDL_sysurl.c +++ b/src/misc/unix/SDL_sysurl.c @@ -28,20 +28,19 @@ #include #include -int -SDL_SYS_OpenURL(const char *url) +int SDL_SYS_OpenURL(const char *url) { const pid_t pid1 = fork(); - if (pid1 == 0) { /* child process */ + if (pid1 == 0) { /* child process */ pid_t pid2; /* Clear LD_PRELOAD so Chrome opens correctly when this application is launched by Steam */ unsetenv("LD_PRELOAD"); /* Notice this is vfork and not fork! */ pid2 = vfork(); - if (pid2 == 0) { /* Grandchild process will try to launch the url */ + if (pid2 == 0) { /* Grandchild process will try to launch the url */ execlp("xdg-open", "xdg-open", url, NULL); _exit(EXIT_FAILURE); - } else if (pid2 < 0) { /* There was an error forking */ + } else if (pid2 < 0) { /* There was an error forking */ _exit(EXIT_FAILURE); } else { /* Child process doesn't wait for possibly-blocking grandchild. */ @@ -53,14 +52,14 @@ SDL_SYS_OpenURL(const char *url) int status; if (waitpid(pid1, &status, 0) == pid1) { if (WIFEXITED(status)) { - if (WEXITSTATUS(status) == 0) { - return 0; /* success! */ - } else { - return SDL_SetError("xdg-open reported error or failed to launch: %d", WEXITSTATUS(status)); - } - } else { + if (WEXITSTATUS(status) == 0) { + return 0; /* success! */ + } else { + return SDL_SetError("xdg-open reported error or failed to launch: %d", WEXITSTATUS(status)); + } + } else { return SDL_SetError("xdg-open failed for some reason"); - } + } } else { return SDL_SetError("Waiting on xdg-open failed: %s", strerror(errno)); } @@ -68,4 +67,3 @@ SDL_SYS_OpenURL(const char *url) } /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/misc/vita/SDL_sysurl.c b/src/misc/vita/SDL_sysurl.c index 1052efb40..684e78df8 100644 --- a/src/misc/vita/SDL_sysurl.c +++ b/src/misc/vita/SDL_sysurl.c @@ -24,8 +24,7 @@ #include #include -int -SDL_SYS_OpenURL(const char *url) +int SDL_SYS_OpenURL(const char *url) { SceAppUtilInitParam init_param; SceAppUtilBootParam boot_param; @@ -41,4 +40,3 @@ SDL_SYS_OpenURL(const char *url) } /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/misc/windows/SDL_sysurl.c b/src/misc/windows/SDL_sysurl.c index 6cfe7de60..2aa627e19 100644 --- a/src/misc/windows/SDL_sysurl.c +++ b/src/misc/windows/SDL_sysurl.c @@ -25,18 +25,16 @@ #include #if defined(__XBOXONE__) || defined(__XBOXSERIES__) -int -SDL_SYS_OpenURL(const char *url) +int SDL_SYS_OpenURL(const char *url) { /* Not supported */ return SDL_Unsupported(); } #else /* https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx */ -int -SDL_SYS_OpenURL(const char *url) +int SDL_SYS_OpenURL(const char *url) { - WCHAR* wurl; + WCHAR *wurl; HINSTANCE rc; /* MSDN says for safety's sake, make sure COM is initialized. */ @@ -55,9 +53,8 @@ SDL_SYS_OpenURL(const char *url) rc = ShellExecuteW(NULL, L"open", wurl, NULL, NULL, SW_SHOWNORMAL); SDL_free(wurl); WIN_CoUninitialize(); - return (rc > ((HINSTANCE) 32)) ? 0 : WIN_SetError("Couldn't open given URL."); + return (rc > ((HINSTANCE)32)) ? 0 : WIN_SetError("Couldn't open given URL."); } #endif /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/misc/winrt/SDL_sysurl.cpp b/src/misc/winrt/SDL_sysurl.cpp index 111a14413..e416bca21 100644 --- a/src/misc/winrt/SDL_sysurl.cpp +++ b/src/misc/winrt/SDL_sysurl.cpp @@ -22,8 +22,7 @@ #include "../SDL_sysurl.h" #include "../../core/windows/SDL_windows.h" -int -SDL_SYS_OpenURL(const char *url) +int SDL_SYS_OpenURL(const char *url) { WCHAR *wurl = WIN_UTF8ToStringW(url); if (!wurl) { @@ -34,8 +33,7 @@ SDL_SYS_OpenURL(const char *url) auto uri = ref new Windows::Foundation::Uri(strurl); Windows::System::Launcher::LaunchUriAsync(uri); - return 0; // oh well, we're not waiting on an async task here. + return 0; // oh well, we're not waiting on an async task here. } /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/power/SDL_power.c b/src/power/SDL_power.c index fbf8d5a65..80dd6b6b8 100644 --- a/src/power/SDL_power.c +++ b/src/power/SDL_power.c @@ -26,15 +26,13 @@ * Returns SDL_TRUE if we have a definitive answer. * SDL_FALSE to try next implementation. */ -typedef SDL_bool - (*SDL_GetPowerInfo_Impl) (SDL_PowerState * state, int *seconds, - int *percent); +typedef SDL_bool (*SDL_GetPowerInfo_Impl)(SDL_PowerState *state, int *seconds, + int *percent); #ifndef SDL_POWER_DISABLED #ifdef SDL_POWER_HARDWIRED /* This is for things that _never_ have a battery */ -static SDL_bool -SDL_GetPowerInfo_Hardwired(SDL_PowerState * state, int *seconds, int *percent) +static SDL_bool SDL_GetPowerInfo_Hardwired(SDL_PowerState *state, int *seconds, int *percent) { *seconds = -1; *percent = -1; @@ -44,40 +42,40 @@ SDL_GetPowerInfo_Hardwired(SDL_PowerState * state, int *seconds, int *percent) #endif static SDL_GetPowerInfo_Impl implementations[] = { -#ifdef SDL_POWER_LINUX /* in order of preference. More than could work. */ +#ifdef SDL_POWER_LINUX /* in order of preference. More than could work. */ SDL_GetPowerInfo_Linux_org_freedesktop_upower, SDL_GetPowerInfo_Linux_sys_class_power_supply, SDL_GetPowerInfo_Linux_proc_acpi, SDL_GetPowerInfo_Linux_proc_apm, #endif -#ifdef SDL_POWER_WINDOWS /* handles Win32, Win64, PocketPC. */ +#ifdef SDL_POWER_WINDOWS /* handles Win32, Win64, PocketPC. */ SDL_GetPowerInfo_Windows, #endif -#ifdef SDL_POWER_UIKIT /* handles iPhone/iPad/etc */ +#ifdef SDL_POWER_UIKIT /* handles iPhone/iPad/etc */ SDL_GetPowerInfo_UIKit, #endif #ifdef SDL_POWER_MACOSX /* handles Mac OS X, Darwin. */ SDL_GetPowerInfo_MacOSX, #endif -#ifdef SDL_POWER_HAIKU /* with BeOS euc.jp apm driver. Does this work on Haiku? */ +#ifdef SDL_POWER_HAIKU /* with BeOS euc.jp apm driver. Does this work on Haiku? */ SDL_GetPowerInfo_Haiku, #endif -#ifdef SDL_POWER_ANDROID /* handles Android. */ +#ifdef SDL_POWER_ANDROID /* handles Android. */ SDL_GetPowerInfo_Android, #endif -#ifdef SDL_POWER_PSP /* handles PSP. */ +#ifdef SDL_POWER_PSP /* handles PSP. */ SDL_GetPowerInfo_PSP, #endif -#ifdef SDL_POWER_VITA /* handles PSVita. */ +#ifdef SDL_POWER_VITA /* handles PSVita. */ SDL_GetPowerInfo_VITA, #endif -#ifdef SDL_POWER_N3DS /* handles N3DS. */ +#ifdef SDL_POWER_N3DS /* handles N3DS. */ SDL_GetPowerInfo_N3DS, #endif -#ifdef SDL_POWER_WINRT /* handles WinRT */ +#ifdef SDL_POWER_WINRT /* handles WinRT */ SDL_GetPowerInfo_WinRT, #endif -#ifdef SDL_POWER_EMSCRIPTEN /* handles Emscripten */ +#ifdef SDL_POWER_EMSCRIPTEN /* handles Emscripten */ SDL_GetPowerInfo_Emscripten, #endif diff --git a/src/power/android/SDL_syspower.c b/src/power/android/SDL_syspower.c index 4be3b1502..d72aa29c1 100644 --- a/src/power/android/SDL_syspower.c +++ b/src/power/android/SDL_syspower.c @@ -29,7 +29,7 @@ #include "../../core/android/SDL_android.h" SDL_bool -SDL_GetPowerInfo_Android(SDL_PowerState * state, int *seconds, int *percent) +SDL_GetPowerInfo_Android(SDL_PowerState *state, int *seconds, int *percent) { int battery; int plugged; diff --git a/src/power/haiku/SDL_syspower.c b/src/power/haiku/SDL_syspower.c index ac1fae917..7c06b952f 100644 --- a/src/power/haiku/SDL_syspower.c +++ b/src/power/haiku/SDL_syspower.c @@ -34,8 +34,8 @@ #include /* These values are from apm.h ... */ -#define APM_DEVICE_PATH "/dev/misc/apm" -#define APM_FUNC_OFFSET 0x5300 +#define APM_DEVICE_PATH "/dev/misc/apm" +#define APM_FUNC_OFFSET 0x5300 #define APM_FUNC_GET_POWER_STATUS 10 #define APM_DEVICE_ALL 1 #define APM_BIOS_CALL (B_DEVICE_OP_CODES_END + 3) @@ -43,7 +43,7 @@ #include "SDL_power.h" SDL_bool -SDL_GetPowerInfo_Haiku(SDL_PowerState * state, int *seconds, int *percent) +SDL_GetPowerInfo_Haiku(SDL_PowerState *state, int *seconds, int *percent) { const int fd = open("/dev/misc/apm", O_RDONLY | O_CLOEXEC); SDL_bool need_details = SDL_FALSE; @@ -56,7 +56,7 @@ SDL_GetPowerInfo_Haiku(SDL_PowerState * state, int *seconds, int *percent) int rc; if (fd == -1) { - return SDL_FALSE; /* maybe some other method will work? */ + return SDL_FALSE; /* maybe some other method will work? */ } SDL_memset(regs, '\0', sizeof(regs)); @@ -73,10 +73,10 @@ SDL_GetPowerInfo_Haiku(SDL_PowerState * state, int *seconds, int *percent) battery_status = regs[1] & 0xFF; battery_flags = regs[2] >> 8; battery_life = regs[2] & 0xFF; - battery_time = (uint32) regs[3]; + battery_time = (uint32)regs[3]; /* in theory, _something_ should be set in battery_flags, right? */ - if (battery_flags == 0x00) { /* older APM BIOS? Less fields. */ + if (battery_flags == 0x00) { /* older APM BIOS? Less fields. */ battery_time = 0xFFFF; if (battery_status == 0xFF) { battery_flags = 0xFF; @@ -90,36 +90,36 @@ SDL_GetPowerInfo_Haiku(SDL_PowerState * state, int *seconds, int *percent) battery_time = (battery_time & 0x7FFF) * 60; } - if (battery_flags == 0xFF) { /* unknown state */ + if (battery_flags == 0xFF) { /* unknown state */ *state = SDL_POWERSTATE_UNKNOWN; - } else if (battery_flags & (1 << 7)) { /* no battery */ + } else if (battery_flags & (1 << 7)) { /* no battery */ *state = SDL_POWERSTATE_NO_BATTERY; - } else if (battery_flags & (1 << 3)) { /* charging */ + } else if (battery_flags & (1 << 3)) { /* charging */ *state = SDL_POWERSTATE_CHARGING; need_details = SDL_TRUE; } else if (ac_status == 1) { - *state = SDL_POWERSTATE_CHARGED; /* on AC, not charging. */ + *state = SDL_POWERSTATE_CHARGED; /* on AC, not charging. */ need_details = SDL_TRUE; } else { - *state = SDL_POWERSTATE_ON_BATTERY; /* not on AC. */ + *state = SDL_POWERSTATE_ON_BATTERY; /* not on AC. */ need_details = SDL_TRUE; } *percent = -1; *seconds = -1; if (need_details) { - const int pct = (int) battery_life; - const int secs = (int) battery_time; + const int pct = (int)battery_life; + const int secs = (int)battery_time; - if (pct != 255) { /* 255 == unknown */ + if (pct != 255) { /* 255 == unknown */ *percent = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */ } - if (secs != 0xFFFF) { /* 0xFFFF == unknown */ + if (secs != 0xFFFF) { /* 0xFFFF == unknown */ *seconds = secs; } } - return SDL_TRUE; /* the definitive answer if APM driver replied. */ + return SDL_TRUE; /* the definitive answer if APM driver replied. */ } #endif /* SDL_POWER_HAIKU */ diff --git a/src/power/linux/SDL_syspower.c b/src/power/linux/SDL_syspower.c index d14a77d51..dbf5b525a 100644 --- a/src/power/linux/SDL_syspower.c +++ b/src/power/linux/SDL_syspower.c @@ -41,14 +41,13 @@ static const char *proc_acpi_battery_path = "/proc/acpi/battery"; static const char *proc_acpi_ac_adapter_path = "/proc/acpi/ac_adapter"; static const char *sys_class_power_supply_path = "/sys/class/power_supply"; -static int -open_power_file(const char *base, const char *node, const char *key) +static int open_power_file(const char *base, const char *node, const char *key) { int fd; const size_t pathlen = SDL_strlen(base) + SDL_strlen(node) + SDL_strlen(key) + 3; char *path = SDL_stack_alloc(char, pathlen); if (path == NULL) { - return -1; /* oh well. */ + return -1; /* oh well. */ } SDL_snprintf(path, pathlen, "%s/%s/%s", base, node, key); @@ -57,37 +56,33 @@ open_power_file(const char *base, const char *node, const char *key) return fd; } - -static SDL_bool -read_power_file(const char *base, const char *node, const char *key, - char *buf, size_t buflen) +static SDL_bool read_power_file(const char *base, const char *node, const char *key, + char *buf, size_t buflen) { ssize_t br = 0; const int fd = open_power_file(base, node, key); if (fd == -1) { return SDL_FALSE; } - br = read(fd, buf, buflen-1); + br = read(fd, buf, buflen - 1); close(fd); if (br < 0) { return SDL_FALSE; } - buf[br] = '\0'; /* null-terminate the string. */ + buf[br] = '\0'; /* null-terminate the string. */ return SDL_TRUE; } - -static SDL_bool -make_proc_acpi_key_val(char **_ptr, char **_key, char **_val) +static SDL_bool make_proc_acpi_key_val(char **_ptr, char **_key, char **_val) { char *ptr = *_ptr; while (*ptr == ' ') { - ptr++; /* skip whitespace. */ + ptr++; /* skip whitespace. */ } if (*ptr == '\0') { - return SDL_FALSE; /* EOF. */ + return SDL_FALSE; /* EOF. */ } *_key = ptr; @@ -97,17 +92,17 @@ make_proc_acpi_key_val(char **_ptr, char **_key, char **_val) } if (*ptr == '\0') { - return SDL_FALSE; /* (unexpected) EOF. */ + return SDL_FALSE; /* (unexpected) EOF. */ } - *(ptr++) = '\0'; /* terminate the key. */ + *(ptr++) = '\0'; /* terminate the key. */ while (*ptr == ' ') { - ptr++; /* skip whitespace. */ + ptr++; /* skip whitespace. */ } if (*ptr == '\0') { - return SDL_FALSE; /* (unexpected) EOF. */ + return SDL_FALSE; /* (unexpected) EOF. */ } *_val = ptr; @@ -117,16 +112,15 @@ make_proc_acpi_key_val(char **_ptr, char **_key, char **_val) } if (*ptr != '\0') { - *(ptr++) = '\0'; /* terminate the value. */ + *(ptr++) = '\0'; /* terminate the value. */ } - *_ptr = ptr; /* store for next time. */ + *_ptr = ptr; /* store for next time. */ return SDL_TRUE; } -static void -check_proc_acpi_battery(const char * node, SDL_bool * have_battery, - SDL_bool * charging, int *seconds, int *percent) +static void check_proc_acpi_battery(const char *node, SDL_bool *have_battery, + SDL_bool *charging, int *seconds, int *percent) { const char *base = proc_acpi_battery_path; char info[1024]; @@ -141,9 +135,9 @@ check_proc_acpi_battery(const char * node, SDL_bool * have_battery, int secs = -1; int pct = -1; - if (!read_power_file(base, node, "state", state, sizeof (state))) { + if (!read_power_file(base, node, "state", state, sizeof(state))) { return; - } else if (!read_power_file(base, node, "info", info, sizeof (info))) { + } else if (!read_power_file(base, node, "info", info, sizeof(info))) { return; } @@ -162,7 +156,7 @@ check_proc_acpi_battery(const char * node, SDL_bool * have_battery, } } else if (SDL_strcmp(key, "remaining capacity") == 0) { char *endptr = NULL; - const int cvt = (int) SDL_strtol(val, &endptr, 10); + const int cvt = (int)SDL_strtol(val, &endptr, 10); if (*endptr == ' ') { remaining = cvt; } @@ -173,7 +167,7 @@ check_proc_acpi_battery(const char * node, SDL_bool * have_battery, while (make_proc_acpi_key_val(&ptr, &key, &val)) { if (SDL_strcmp(key, "design capacity") == 0) { char *endptr = NULL; - const int cvt = (int) SDL_strtol(val, &endptr, 10); + const int cvt = (int)SDL_strtol(val, &endptr, 10); if (*endptr == ' ') { maximum = cvt; } @@ -181,7 +175,7 @@ check_proc_acpi_battery(const char * node, SDL_bool * have_battery, } if ((maximum >= 0) && (remaining >= 0)) { - pct = (int) ((((float) remaining) / ((float) maximum)) * 100.0f); + pct = (int)((((float)remaining) / ((float)maximum)) * 100.0f); if (pct < 0) { pct = 0; } else if (pct > 100) { @@ -197,7 +191,7 @@ check_proc_acpi_battery(const char * node, SDL_bool * have_battery, */ if ((secs < 0) && (*seconds < 0)) { if ((pct < 0) && (*percent < 0)) { - choose = SDL_TRUE; /* at least we know there's a battery. */ + choose = SDL_TRUE; /* at least we know there's a battery. */ } if (pct > *percent) { choose = SDL_TRUE; @@ -213,8 +207,7 @@ check_proc_acpi_battery(const char * node, SDL_bool * have_battery, } } -static void -check_proc_acpi_ac_adapter(const char * node, SDL_bool * have_ac) +static void check_proc_acpi_ac_adapter(const char *node, SDL_bool *have_ac) { const char *base = proc_acpi_ac_adapter_path; char state[256]; @@ -222,7 +215,7 @@ check_proc_acpi_ac_adapter(const char * node, SDL_bool * have_ac) char *key = NULL; char *val = NULL; - if (!read_power_file(base, node, "state", state, sizeof (state))) { + if (!read_power_file(base, node, "state", state, sizeof(state))) { return; } @@ -236,9 +229,8 @@ check_proc_acpi_ac_adapter(const char * node, SDL_bool * have_ac) } } - SDL_bool -SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState * state, +SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *state, int *seconds, int *percent) { struct dirent *dent = NULL; @@ -253,7 +245,7 @@ SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState * state, dirp = opendir(proc_acpi_battery_path); if (dirp == NULL) { - return SDL_FALSE; /* can't use this interface. */ + return SDL_FALSE; /* can't use this interface. */ } else { while ((dent = readdir(dirp)) != NULL) { const char *node = dent->d_name; @@ -265,7 +257,7 @@ SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState * state, dirp = opendir(proc_acpi_ac_adapter_path); if (dirp == NULL) { - return SDL_FALSE; /* can't use this interface. */ + return SDL_FALSE; /* can't use this interface. */ } else { while ((dent = readdir(dirp)) != NULL) { const char *node = dent->d_name; @@ -284,17 +276,15 @@ SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState * state, *state = SDL_POWERSTATE_ON_BATTERY; } - return SDL_TRUE; /* definitive answer. */ + return SDL_TRUE; /* definitive answer. */ } - -static SDL_bool -next_string(char **_ptr, char **_str) +static SDL_bool next_string(char **_ptr, char **_str) { char *ptr = *_ptr; char *str; - while (*ptr == ' ') { /* skip any spaces... */ + while (*ptr == ' ') { /* skip any spaces... */ ptr++; } @@ -316,17 +306,16 @@ next_string(char **_ptr, char **_str) return SDL_TRUE; } -static SDL_bool -int_string(char *str, int *val) +static SDL_bool int_string(char *str, int *val) { char *endptr = NULL; - *val = (int) SDL_strtol(str, &endptr, 0); + *val = (int)SDL_strtol(str, &endptr, 0); return (*str != '\0') && (*endptr == '\0'); } /* http://lxr.linux.no/linux+v2.6.29/drivers/char/apm-emulation.c */ SDL_bool -SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState * state, +SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *state, int *seconds, int *percent) { SDL_bool need_details = SDL_FALSE; @@ -342,44 +331,44 @@ SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState * state, ssize_t br; if (fd == -1) { - return SDL_FALSE; /* can't use this interface. */ + return SDL_FALSE; /* can't use this interface. */ } - br = read(fd, buf, sizeof (buf) - 1); + br = read(fd, buf, sizeof(buf) - 1); close(fd); if (br < 0) { return SDL_FALSE; } - buf[br] = '\0'; /* null-terminate the string. */ - if (!next_string(&ptr, &str)) { /* driver version */ + buf[br] = '\0'; /* null-terminate the string. */ + if (!next_string(&ptr, &str)) { /* driver version */ return SDL_FALSE; } - if (!next_string(&ptr, &str)) { /* BIOS version */ + if (!next_string(&ptr, &str)) { /* BIOS version */ return SDL_FALSE; } - if (!next_string(&ptr, &str)) { /* APM flags */ + if (!next_string(&ptr, &str)) { /* APM flags */ return SDL_FALSE; } - if (!next_string(&ptr, &str)) { /* AC line status */ + if (!next_string(&ptr, &str)) { /* AC line status */ return SDL_FALSE; } else if (!int_string(str, &ac_status)) { return SDL_FALSE; } - if (!next_string(&ptr, &str)) { /* battery status */ + if (!next_string(&ptr, &str)) { /* battery status */ return SDL_FALSE; } else if (!int_string(str, &battery_status)) { return SDL_FALSE; } - if (!next_string(&ptr, &str)) { /* battery flag */ + if (!next_string(&ptr, &str)) { /* battery flag */ return SDL_FALSE; } else if (!int_string(str, &battery_flag)) { return SDL_FALSE; } - if (!next_string(&ptr, &str)) { /* remaining battery life percent */ + if (!next_string(&ptr, &str)) { /* remaining battery life percent */ return SDL_FALSE; } if (str[SDL_strlen(str) - 1] == '%') { @@ -389,13 +378,13 @@ SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState * state, return SDL_FALSE; } - if (!next_string(&ptr, &str)) { /* remaining battery life time */ + if (!next_string(&ptr, &str)) { /* remaining battery life time */ return SDL_FALSE; } else if (!int_string(str, &battery_time)) { return SDL_FALSE; } - if (!next_string(&ptr, &str)) { /* remaining battery life time units */ + if (!next_string(&ptr, &str)) { /* remaining battery life time units */ return SDL_FALSE; } else if (SDL_strcmp(str, "min") == 0) { battery_time *= 60; @@ -403,13 +392,13 @@ SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState * state, if (battery_flag == 0xFF) { /* unknown state */ *state = SDL_POWERSTATE_UNKNOWN; - } else if (battery_flag & (1 << 7)) { /* no battery */ + } else if (battery_flag & (1 << 7)) { /* no battery */ *state = SDL_POWERSTATE_NO_BATTERY; - } else if (battery_flag & (1 << 3)) { /* charging */ + } else if (battery_flag & (1 << 3)) { /* charging */ *state = SDL_POWERSTATE_CHARGING; need_details = SDL_TRUE; } else if (ac_status == 1) { - *state = SDL_POWERSTATE_CHARGED; /* on AC, not charging. */ + *state = SDL_POWERSTATE_CHARGED; /* on AC, not charging. */ need_details = SDL_TRUE; } else { *state = SDL_POWERSTATE_ON_BATTERY; @@ -422,10 +411,10 @@ SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState * state, const int pct = battery_percent; const int secs = battery_time; - if (pct >= 0) { /* -1 == unknown */ + if (pct >= 0) { /* -1 == unknown */ *percent = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */ } - if (secs >= 0) { /* -1 == unknown */ + if (secs >= 0) { /* -1 == unknown */ *seconds = secs; } } @@ -445,7 +434,7 @@ SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, int *second return SDL_FALSE; } - *state = SDL_POWERSTATE_NO_BATTERY; /* assume we're just plugged in. */ + *state = SDL_POWERSTATE_NO_BATTERY; /* assume we're just plugged in. */ *seconds = -1; *percent = -1; @@ -460,28 +449,28 @@ SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, int *second int power; if ((SDL_strcmp(name, ".") == 0) || (SDL_strcmp(name, "..") == 0)) { - continue; /* skip these, of course. */ - } else if (!read_power_file(base, name, "type", str, sizeof (str))) { - continue; /* Don't know _what_ we're looking at. Give up on it. */ + continue; /* skip these, of course. */ + } else if (!read_power_file(base, name, "type", str, sizeof(str))) { + continue; /* Don't know _what_ we're looking at. Give up on it. */ } else if (SDL_strcmp(str, "Battery\n") != 0) { - continue; /* we don't care about UPS and such. */ + continue; /* we don't care about UPS and such. */ } /* if the scope is "device," it might be something like a PS4 controller reporting its own battery, and not something that powers the system. Most system batteries don't list a scope at all; we assume it's a system battery if not specified. */ - if (read_power_file(base, name, "scope", str, sizeof (str))) { + if (read_power_file(base, name, "scope", str, sizeof(str))) { if (SDL_strcmp(str, "device\n") == 0) { - continue; /* skip external devices with their own batteries. */ + continue; /* skip external devices with their own batteries. */ } } /* some drivers don't offer this, so if it's not explicitly reported assume it's present. */ - if (read_power_file(base, name, "present", str, sizeof (str)) && (SDL_strcmp(str, "0\n") == 0)) { + if (read_power_file(base, name, "present", str, sizeof(str)) && (SDL_strcmp(str, "0\n") == 0)) { st = SDL_POWERSTATE_NO_BATTERY; - } else if (!read_power_file(base, name, "status", str, sizeof (str))) { - st = SDL_POWERSTATE_UNKNOWN; /* uh oh */ + } else if (!read_power_file(base, name, "status", str, sizeof(str))) { + st = SDL_POWERSTATE_UNKNOWN; /* uh oh */ } else if (SDL_strcmp(str, "Charging\n") == 0) { st = SDL_POWERSTATE_CHARGING; } else if (SDL_strcmp(str, "Discharging\n") == 0) { @@ -489,23 +478,23 @@ SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, int *second } else if ((SDL_strcmp(str, "Full\n") == 0) || (SDL_strcmp(str, "Not charging\n") == 0)) { st = SDL_POWERSTATE_CHARGED; } else { - st = SDL_POWERSTATE_UNKNOWN; /* uh oh */ + st = SDL_POWERSTATE_UNKNOWN; /* uh oh */ } - if (!read_power_file(base, name, "capacity", str, sizeof (str))) { + if (!read_power_file(base, name, "capacity", str, sizeof(str))) { pct = -1; } else { pct = SDL_atoi(str); pct = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */ } - if (read_power_file(base, name, "time_to_empty_now", str, sizeof (str))) { + if (read_power_file(base, name, "time_to_empty_now", str, sizeof(str))) { secs = SDL_atoi(str); - secs = (secs <= 0) ? -1 : secs; /* 0 == unknown */ + secs = (secs <= 0) ? -1 : secs; /* 0 == unknown */ } else if (st == SDL_POWERSTATE_ON_BATTERY) { /* energy is Watt*hours and power is Watts */ - energy = (read_power_file(base, name, "energy_now", str, sizeof (str))) ? SDL_atoi(str) : -1; - power = (read_power_file(base, name, "power_now", str, sizeof (str))) ? SDL_atoi(str) : -1; + energy = (read_power_file(base, name, "energy_now", str, sizeof(str))) ? SDL_atoi(str) : -1; + power = (read_power_file(base, name, "power_now", str, sizeof(str))) ? SDL_atoi(str) : -1; secs = (energy >= 0 && power > 0) ? (3600LL * energy) / power : -1; } else { secs = -1; @@ -517,7 +506,7 @@ SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, int *second */ if ((secs < 0) && (*seconds < 0)) { if ((pct < 0) && (*percent < 0)) { - choose = SDL_TRUE; /* at least we know there's a battery. */ + choose = SDL_TRUE; /* at least we know there's a battery. */ } else if (pct > *percent) { choose = SDL_TRUE; } @@ -533,19 +522,17 @@ SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, int *second } closedir(dirp); - return SDL_TRUE; /* don't look any further. */ + return SDL_TRUE; /* don't look any further. */ } - /* d-bus queries to org.freedesktop.UPower. */ #if SDL_USE_LIBDBUS -#define UPOWER_DBUS_NODE "org.freedesktop.UPower" -#define UPOWER_DBUS_PATH "/org/freedesktop/UPower" -#define UPOWER_DBUS_INTERFACE "org.freedesktop.UPower" +#define UPOWER_DBUS_NODE "org.freedesktop.UPower" +#define UPOWER_DBUS_PATH "/org/freedesktop/UPower" +#define UPOWER_DBUS_INTERFACE "org.freedesktop.UPower" #define UPOWER_DEVICE_DBUS_INTERFACE "org.freedesktop.UPower.Device" -static void -check_upower_device(DBusConnection *conn, const char *path, SDL_PowerState *state, int *seconds, int *percent) +static void check_upower_device(DBusConnection *conn, const char *path, SDL_PowerState *state, int *seconds, int *percent) { SDL_bool choose = SDL_FALSE; SDL_PowerState st; @@ -556,13 +543,13 @@ check_upower_device(DBusConnection *conn, const char *path, SDL_PowerState *stat double d = 0.0; if (!SDL_DBus_QueryPropertyOnConnection(conn, UPOWER_DBUS_NODE, path, UPOWER_DEVICE_DBUS_INTERFACE, "Type", DBUS_TYPE_UINT32, &ui32)) { - return; /* Don't know _what_ we're looking at. Give up on it. */ - } else if (ui32 != 2) { /* 2==Battery*/ - return; /* we don't care about UPS and such. */ + return; /* Don't know _what_ we're looking at. Give up on it. */ + } else if (ui32 != 2) { /* 2==Battery*/ + return; /* we don't care about UPS and such. */ } else if (!SDL_DBus_QueryPropertyOnConnection(conn, UPOWER_DBUS_NODE, path, UPOWER_DEVICE_DBUS_INTERFACE, "PowerSupply", DBUS_TYPE_BOOLEAN, &ui32)) { return; } else if (!ui32) { - return; /* we don't care about random devices with batteries, like wireless controllers, etc */ + return; /* we don't care about random devices with batteries, like wireless controllers, etc */ } if (!SDL_DBus_QueryPropertyOnConnection(conn, UPOWER_DBUS_NODE, path, UPOWER_DEVICE_DBUS_INTERFACE, "IsPresent", DBUS_TYPE_BOOLEAN, &ui32)) { @@ -577,30 +564,30 @@ check_upower_device(DBusConnection *conn, const char *path, SDL_PowerState *stat SDL_DBus_CallMethodOnConnection(conn, UPOWER_DBUS_NODE, path, UPOWER_DEVICE_DBUS_INTERFACE, "Refresh", DBUS_TYPE_INVALID, DBUS_TYPE_INVALID); if (!SDL_DBus_QueryPropertyOnConnection(conn, UPOWER_DBUS_NODE, path, UPOWER_DEVICE_DBUS_INTERFACE, "State", DBUS_TYPE_UINT32, &ui32)) { - st = SDL_POWERSTATE_UNKNOWN; /* uh oh */ - } else if (ui32 == 1) { /* 1 == charging */ + st = SDL_POWERSTATE_UNKNOWN; /* uh oh */ + } else if (ui32 == 1) { /* 1 == charging */ st = SDL_POWERSTATE_CHARGING; - } else if ((ui32 == 2) || (ui32 == 3)) { /* 2 == discharging, 3 == empty. */ + } else if ((ui32 == 2) || (ui32 == 3)) { /* 2 == discharging, 3 == empty. */ st = SDL_POWERSTATE_ON_BATTERY; - } else if (ui32 == 4) { /* 4 == full */ + } else if (ui32 == 4) { /* 4 == full */ st = SDL_POWERSTATE_CHARGED; } else { - st = SDL_POWERSTATE_UNKNOWN; /* uh oh */ + st = SDL_POWERSTATE_UNKNOWN; /* uh oh */ } } if (!SDL_DBus_QueryPropertyOnConnection(conn, UPOWER_DBUS_NODE, path, UPOWER_DEVICE_DBUS_INTERFACE, "Percentage", DBUS_TYPE_DOUBLE, &d)) { - pct = -1; /* some old/cheap batteries don't set this property. */ + pct = -1; /* some old/cheap batteries don't set this property. */ } else { - pct = (int) d; + pct = (int)d; pct = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */ } if (!SDL_DBus_QueryPropertyOnConnection(conn, UPOWER_DBUS_NODE, path, UPOWER_DEVICE_DBUS_INTERFACE, "TimeToEmpty", DBUS_TYPE_INT64, &si64)) { secs = -1; } else { - secs = (int) si64; - secs = (secs <= 0) ? -1 : secs; /* 0 == unknown */ + secs = (int)si64; + secs = (secs <= 0) ? -1 : secs; /* 0 == unknown */ } /* @@ -609,7 +596,7 @@ check_upower_device(DBusConnection *conn, const char *path, SDL_PowerState *stat */ if ((secs < 0) && (*seconds < 0)) { if ((pct < 0) && (*percent < 0)) { - choose = SDL_TRUE; /* at least we know there's a battery. */ + choose = SDL_TRUE; /* at least we know there's a battery. */ } else if (pct > *percent) { choose = SDL_TRUE; } @@ -638,11 +625,11 @@ SDL_GetPowerInfo_Linux_org_freedesktop_upower(SDL_PowerState *state, int *second if (dbus == NULL || !SDL_DBus_CallMethodOnConnection(dbus->system_conn, UPOWER_DBUS_NODE, UPOWER_DBUS_PATH, UPOWER_DBUS_INTERFACE, "EnumerateDevices", DBUS_TYPE_INVALID, DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH, &paths, &numpaths, DBUS_TYPE_INVALID)) { - return SDL_FALSE; /* try a different approach than UPower. */ + return SDL_FALSE; /* try a different approach than UPower. */ } - retval = SDL_TRUE; /* Clearly we can use this interface. */ - *state = SDL_POWERSTATE_NO_BATTERY; /* assume we're just plugged in. */ + retval = SDL_TRUE; /* Clearly we can use this interface. */ + *state = SDL_POWERSTATE_NO_BATTERY; /* assume we're just plugged in. */ *seconds = -1; *percent = -1; @@ -651,7 +638,7 @@ SDL_GetPowerInfo_Linux_org_freedesktop_upower(SDL_PowerState *state, int *second } dbus->free_string_array(paths); -#endif /* SDL_USE_LIBDBUS */ +#endif /* SDL_USE_LIBDBUS */ return retval; } diff --git a/src/power/macosx/SDL_syspower.c b/src/power/macosx/SDL_syspower.c index 8277b3472..7f428e463 100644 --- a/src/power/macosx/SDL_syspower.c +++ b/src/power/macosx/SDL_syspower.c @@ -30,16 +30,15 @@ #include "SDL_power.h" /* CoreFoundation is so verbose... */ -#define STRMATCH(a,b) (CFStringCompare(a, b, 0) == kCFCompareEqualTo) -#define GETVAL(k,v) \ - CFDictionaryGetValueIfPresent(dict, CFSTR(k), (const void **) v) +#define STRMATCH(a, b) (CFStringCompare(a, b, 0) == kCFCompareEqualTo) +#define GETVAL(k, v) \ + CFDictionaryGetValueIfPresent(dict, CFSTR(k), (const void **)v) /* Note that AC power sources also include a laptop battery it is charging. */ -static void -checkps(CFDictionaryRef dict, SDL_bool * have_ac, SDL_bool * have_battery, - SDL_bool * charging, int *seconds, int *percent) +static void checkps(CFDictionaryRef dict, SDL_bool *have_ac, SDL_bool *have_battery, + SDL_bool *charging, int *seconds, int *percent) { - CFStringRef strval; /* don't CFRelease() this. */ + CFStringRef strval; /* don't CFRelease() this. */ CFBooleanRef bval; CFNumberRef numval; SDL_bool charge = SDL_FALSE; @@ -50,7 +49,7 @@ checkps(CFDictionaryRef dict, SDL_bool * have_ac, SDL_bool * have_battery, int pct = -1; if ((GETVAL(kIOPSIsPresentKey, &bval)) && (bval == kCFBooleanFalse)) { - return; /* nothing to see here. */ + return; /* nothing to see here. */ } if (!GETVAL(kIOPSPowerSourceStateKey, &strval)) { @@ -60,7 +59,7 @@ checkps(CFDictionaryRef dict, SDL_bool * have_ac, SDL_bool * have_battery, if (STRMATCH(strval, CFSTR(kIOPSACPowerValue))) { is_ac = *have_ac = SDL_TRUE; } else if (!STRMATCH(strval, CFSTR(kIOPSBatteryPowerValue))) { - return; /* not a battery? */ + return; /* not a battery? */ } if ((GETVAL(kIOPSIsChargingKey, &bval)) && (bval == kCFBooleanTrue)) { @@ -72,7 +71,7 @@ checkps(CFDictionaryRef dict, SDL_bool * have_ac, SDL_bool * have_battery, CFNumberGetValue(numval, kCFNumberSInt32Type, &val); if (val > 0) { *have_battery = SDL_TRUE; - maxpct = (int) val; + maxpct = (int)val; } } @@ -81,7 +80,7 @@ checkps(CFDictionaryRef dict, SDL_bool * have_ac, SDL_bool * have_battery, CFNumberGetValue(numval, kCFNumberSInt32Type, &val); if (val > 0) { *have_battery = SDL_TRUE; - maxpct = (int) val; + maxpct = (int)val; } } @@ -91,23 +90,23 @@ checkps(CFDictionaryRef dict, SDL_bool * have_ac, SDL_bool * have_battery, /* Mac OS X reports 0 minutes until empty if you're plugged in. :( */ if ((val == 0) && (is_ac)) { - val = -1; /* !!! FIXME: calc from timeToFull and capacity? */ + val = -1; /* !!! FIXME: calc from timeToFull and capacity? */ } - secs = (int) val; + secs = (int)val; if (secs > 0) { - secs *= 60; /* value is in minutes, so convert to seconds. */ + secs *= 60; /* value is in minutes, so convert to seconds. */ } } if (GETVAL(kIOPSCurrentCapacityKey, &numval)) { SInt32 val = -1; CFNumberGetValue(numval, kCFNumberSInt32Type, &val); - pct = (int) val; + pct = (int)val; } if ((pct > 0) && (maxpct > 0)) { - pct = (int) ((((double) pct) / ((double) maxpct)) * 100.0); + pct = (int)((((double)pct) / ((double)maxpct)) * 100.0); } if (pct > 100) { @@ -120,7 +119,7 @@ checkps(CFDictionaryRef dict, SDL_bool * have_ac, SDL_bool * have_battery, */ if ((secs < 0) && (*seconds < 0)) { if ((pct < 0) && (*percent < 0)) { - choose = SDL_TRUE; /* at least we know there's a battery. */ + choose = SDL_TRUE; /* at least we know there's a battery. */ } if (pct > *percent) { choose = SDL_TRUE; @@ -139,9 +138,8 @@ checkps(CFDictionaryRef dict, SDL_bool * have_ac, SDL_bool * have_battery, #undef GETVAL #undef STRMATCH - SDL_bool -SDL_GetPowerInfo_MacOSX(SDL_PowerState * state, int *seconds, int *percent) +SDL_GetPowerInfo_MacOSX(SDL_PowerState *state, int *seconds, int *percent) { CFTypeRef blob = IOPSCopyPowerSourcesInfo(); @@ -159,7 +157,7 @@ SDL_GetPowerInfo_MacOSX(SDL_PowerState * state, int *seconds, int *percent) const CFIndex total = CFArrayGetCount(list); CFIndex i; for (i = 0; i < total; i++) { - CFTypeRef ps = (CFTypeRef) CFArrayGetValueAtIndex(list, i); + CFTypeRef ps = (CFTypeRef)CFArrayGetValueAtIndex(list, i); CFDictionaryRef dict = IOPSGetPowerSourceDescription(blob, ps); if (dict != NULL) { diff --git a/src/power/n3ds/SDL_syspower.c b/src/power/n3ds/SDL_syspower.c index fe167aff6..2491abe6c 100644 --- a/src/power/n3ds/SDL_syspower.c +++ b/src/power/n3ds/SDL_syspower.c @@ -103,7 +103,7 @@ GetBatteryPercentage(void) mcuHwcExit(); - return (int) SDL_round(data[0] + data[1] / 256.0); + return (int)SDL_round(data[0] + data[1] / 256.0); } #endif /* !SDL_POWER_DISABLED && SDL_POWER_N3DS */ diff --git a/src/power/psp/SDL_syspower.c b/src/power/psp/SDL_syspower.c index ca9ba66b7..c8d343b7b 100644 --- a/src/power/psp/SDL_syspower.c +++ b/src/power/psp/SDL_syspower.c @@ -27,10 +27,9 @@ #include "SDL_power.h" #include - SDL_bool -SDL_GetPowerInfo_PSP(SDL_PowerState * state, int *seconds, - int *percent) +SDL_GetPowerInfo_PSP(SDL_PowerState *state, int *seconds, + int *percent) { int battery = scePowerIsBatteryExist(); int plugged = scePowerIsPowerOnline(); @@ -47,19 +46,18 @@ SDL_GetPowerInfo_PSP(SDL_PowerState * state, int *seconds, } else if (charging) { *state = SDL_POWERSTATE_CHARGING; *percent = scePowerGetBatteryLifePercent(); - *seconds = scePowerGetBatteryLifeTime()*60; + *seconds = scePowerGetBatteryLifeTime() * 60; } else if (plugged) { *state = SDL_POWERSTATE_CHARGED; *percent = scePowerGetBatteryLifePercent(); - *seconds = scePowerGetBatteryLifeTime()*60; + *seconds = scePowerGetBatteryLifeTime() * 60; } else { *state = SDL_POWERSTATE_ON_BATTERY; *percent = scePowerGetBatteryLifePercent(); - *seconds = scePowerGetBatteryLifeTime()*60; + *seconds = scePowerGetBatteryLifeTime() * 60; } - - return SDL_TRUE; /* always the definitive answer on PSP. */ + return SDL_TRUE; /* always the definitive answer on PSP. */ } #endif /* SDL_POWER_PSP */ diff --git a/src/power/uikit/SDL_syspower.h b/src/power/uikit/SDL_syspower.h index a412780b0..18b1386af 100644 --- a/src/power/uikit/SDL_syspower.h +++ b/src/power/uikit/SDL_syspower.h @@ -25,7 +25,7 @@ #include "SDL_power.h" void SDL_UIKit_UpdateBatteryMonitoring(void); -SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState * state, int *seconds, int *percent); +SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *state, int *seconds, int *percent); #endif /* SDL_POWER_UIKIT */ diff --git a/src/power/uikit/SDL_syspower.m b/src/power/uikit/SDL_syspower.m index 2a5ec9c6a..252da528e 100644 --- a/src/power/uikit/SDL_syspower.m +++ b/src/power/uikit/SDL_syspower.m @@ -34,8 +34,7 @@ static const int BATTERY_MONITORING_TIMEOUT = 3000; static Uint32 SDL_UIKitLastPowerInfoQuery = 0; -void -SDL_UIKit_UpdateBatteryMonitoring(void) +void SDL_UIKit_UpdateBatteryMonitoring(void) { if (SDL_UIKitLastPowerInfoQuery) { if (SDL_TICKS_PASSED(SDL_GetTicks(), SDL_UIKitLastPowerInfoQuery + BATTERY_MONITORING_TIMEOUT)) { @@ -47,21 +46,20 @@ SDL_UIKit_UpdateBatteryMonitoring(void) } } #else -void -SDL_UIKit_UpdateBatteryMonitoring(void) +void SDL_UIKit_UpdateBatteryMonitoring(void) { /* Do nothing. */ } #endif /* !TARGET_OS_TV */ SDL_bool -SDL_GetPowerInfo_UIKit(SDL_PowerState * state, int *seconds, int *percent) +SDL_GetPowerInfo_UIKit(SDL_PowerState *state, int *seconds, int *percent) { #if TARGET_OS_TV *state = SDL_POWERSTATE_NO_BATTERY; *seconds = -1; *percent = -1; -#else /* TARGET_OS_TV */ +#else /* TARGET_OS_TV */ @autoreleasepool { UIDevice *uidev = [UIDevice currentDevice]; @@ -77,7 +75,7 @@ SDL_GetPowerInfo_UIKit(SDL_PowerState * state, int *seconds, int *percent) */ SDL_UIKitLastPowerInfoQuery = SDL_GetTicks(); - *seconds = -1; /* no API to estimate this in UIKit. */ + *seconds = -1; /* no API to estimate this in UIKit. */ switch (uidev.batteryState) { case UIDeviceBatteryStateCharging: @@ -99,7 +97,7 @@ SDL_GetPowerInfo_UIKit(SDL_PowerState * state, int *seconds, int *percent) } const float level = uidev.batteryLevel; - *percent = ( (level < 0.0f) ? -1 : ((int) ((level * 100) + 0.5f)) ); + *percent = ((level < 0.0f) ? -1 : ((int)((level * 100) + 0.5f))); } #endif /* TARGET_OS_TV */ diff --git a/src/power/vita/SDL_syspower.c b/src/power/vita/SDL_syspower.c index 46eef930e..3d01d9e46 100644 --- a/src/power/vita/SDL_syspower.c +++ b/src/power/vita/SDL_syspower.c @@ -27,10 +27,9 @@ #include "SDL_power.h" #include - SDL_bool -SDL_GetPowerInfo_VITA(SDL_PowerState * state, int *seconds, - int *percent) +SDL_GetPowerInfo_VITA(SDL_PowerState *state, int *seconds, + int *percent) { int battery = 1; int plugged = scePowerIsPowerOnline(); @@ -47,19 +46,18 @@ SDL_GetPowerInfo_VITA(SDL_PowerState * state, int *seconds, } else if (charging) { *state = SDL_POWERSTATE_CHARGING; *percent = scePowerGetBatteryLifePercent(); - *seconds = scePowerGetBatteryLifeTime()*60; + *seconds = scePowerGetBatteryLifeTime() * 60; } else if (plugged) { *state = SDL_POWERSTATE_CHARGED; *percent = scePowerGetBatteryLifePercent(); - *seconds = scePowerGetBatteryLifeTime()*60; + *seconds = scePowerGetBatteryLifeTime() * 60; } else { *state = SDL_POWERSTATE_ON_BATTERY; *percent = scePowerGetBatteryLifePercent(); - *seconds = scePowerGetBatteryLifeTime()*60; + *seconds = scePowerGetBatteryLifeTime() * 60; } - - return SDL_TRUE; /* always the definitive answer on VITA. */ + return SDL_TRUE; /* always the definitive answer on VITA. */ } #endif /* SDL_POWER_VITA */ diff --git a/src/power/windows/SDL_syspower.c b/src/power/windows/SDL_syspower.c index 02e4fa849..9819bd477 100644 --- a/src/power/windows/SDL_syspower.c +++ b/src/power/windows/SDL_syspower.c @@ -28,7 +28,7 @@ #include "SDL_power.h" SDL_bool -SDL_GetPowerInfo_Windows(SDL_PowerState * state, int *seconds, int *percent) +SDL_GetPowerInfo_Windows(SDL_PowerState *state, int *seconds, int *percent) { SYSTEM_POWER_STATUS status; SDL_bool need_details = SDL_FALSE; @@ -37,7 +37,7 @@ SDL_GetPowerInfo_Windows(SDL_PowerState * state, int *seconds, int *percent) if (!GetSystemPowerStatus(&status)) { /* !!! FIXME: push GetLastError() into SDL_GetError() */ *state = SDL_POWERSTATE_UNKNOWN; - } else if (status.BatteryFlag == 0xFF) { /* unknown state */ + } else if (status.BatteryFlag == 0xFF) { /* unknown state */ *state = SDL_POWERSTATE_UNKNOWN; } else if (status.BatteryFlag & (1 << 7)) { /* no battery */ *state = SDL_POWERSTATE_NO_BATTERY; @@ -45,28 +45,28 @@ SDL_GetPowerInfo_Windows(SDL_PowerState * state, int *seconds, int *percent) *state = SDL_POWERSTATE_CHARGING; need_details = SDL_TRUE; } else if (status.ACLineStatus == 1) { - *state = SDL_POWERSTATE_CHARGED; /* on AC, not charging. */ + *state = SDL_POWERSTATE_CHARGED; /* on AC, not charging. */ need_details = SDL_TRUE; } else { - *state = SDL_POWERSTATE_ON_BATTERY; /* not on AC. */ + *state = SDL_POWERSTATE_ON_BATTERY; /* not on AC. */ need_details = SDL_TRUE; } *percent = -1; *seconds = -1; if (need_details) { - const int pct = (int) status.BatteryLifePercent; - const int secs = (int) status.BatteryLifeTime; + const int pct = (int)status.BatteryLifePercent; + const int secs = (int)status.BatteryLifeTime; - if (pct != 255) { /* 255 == unknown */ + if (pct != 255) { /* 255 == unknown */ *percent = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */ } - if (secs != 0xFFFFFFFF) { /* ((DWORD)-1) == unknown */ + if (secs != 0xFFFFFFFF) { /* ((DWORD)-1) == unknown */ *seconds = secs; } } - return SDL_TRUE; /* always the definitive answer on Windows. */ + return SDL_TRUE; /* always the definitive answer on Windows. */ } #endif /* SDL_POWER_WINDOWS */ diff --git a/src/render/SDL_d3dmath.c b/src/render/SDL_d3dmath.c index fb7de371f..2ed7f8ce7 100644 --- a/src/render/SDL_d3dmath.c +++ b/src/render/SDL_d3dmath.c @@ -128,7 +128,6 @@ Float4X4 MatrixRotationZ(float r) m.v._33 = 1.0f; m.v._44 = 1.0f; return m; - } #endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12) && !SDL_RENDER_DISABLED */ diff --git a/src/render/SDL_d3dmath.h b/src/render/SDL_d3dmath.h index 6460bf17d..56f135e2f 100644 --- a/src/render/SDL_d3dmath.h +++ b/src/render/SDL_d3dmath.h @@ -52,8 +52,10 @@ typedef struct typedef struct { - union { - struct { + union + { + struct + { float _11, _12, _13, _14; float _21, _22, _23, _24; float _31, _32, _33, _34; @@ -63,7 +65,6 @@ typedef struct }; } Float4X4; - Float4X4 MatrixIdentity(); Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2); Float4X4 MatrixScaling(float x, float y, float z); diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index f49272e46..75aa59268 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -30,7 +30,7 @@ #include "../video/SDL_pixels_c.h" #if defined(__ANDROID__) -# include "../core/android/SDL_android.h" +#include "../core/android/SDL_android.h" #endif /* as a courtesy to iOS apps, we don't try to draw when in the background, as @@ -45,47 +45,47 @@ this should probably be removed at some point in the future. --ryan. */ #define DONT_DRAW_WHILE_HIDDEN 0 #endif -#define SDL_WINDOWRENDERDATA "_SDL_WindowRenderData" +#define SDL_WINDOWRENDERDATA "_SDL_WindowRenderData" -#define CHECK_RENDERER_MAGIC(renderer, retval) \ +#define CHECK_RENDERER_MAGIC(renderer, retval) \ if (!renderer || renderer->magic != &renderer_magic) { \ - SDL_InvalidParamError("renderer"); \ - return retval; \ + SDL_InvalidParamError("renderer"); \ + return retval; \ } -#define CHECK_TEXTURE_MAGIC(texture, retval) \ +#define CHECK_TEXTURE_MAGIC(texture, retval) \ if (!texture || texture->magic != &texture_magic) { \ - SDL_InvalidParamError("texture"); \ - return retval; \ + SDL_InvalidParamError("texture"); \ + return retval; \ } /* Predefined blend modes */ #define SDL_COMPOSE_BLENDMODE(srcColorFactor, dstColorFactor, colorOperation, \ srcAlphaFactor, dstAlphaFactor, alphaOperation) \ - (SDL_BlendMode)(((Uint32)colorOperation << 0) | \ - ((Uint32)srcColorFactor << 4) | \ - ((Uint32)dstColorFactor << 8) | \ - ((Uint32)alphaOperation << 16) | \ - ((Uint32)srcAlphaFactor << 20) | \ + (SDL_BlendMode)(((Uint32)colorOperation << 0) | \ + ((Uint32)srcColorFactor << 4) | \ + ((Uint32)dstColorFactor << 8) | \ + ((Uint32)alphaOperation << 16) | \ + ((Uint32)srcAlphaFactor << 20) | \ ((Uint32)dstAlphaFactor << 24)) -#define SDL_BLENDMODE_NONE_FULL \ +#define SDL_BLENDMODE_NONE_FULL \ SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ZERO, SDL_BLENDOPERATION_ADD, \ SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ZERO, SDL_BLENDOPERATION_ADD) -#define SDL_BLENDMODE_BLEND_FULL \ +#define SDL_BLENDMODE_BLEND_FULL \ SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, \ SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD) -#define SDL_BLENDMODE_ADD_FULL \ +#define SDL_BLENDMODE_ADD_FULL \ SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD, \ SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD) -#define SDL_BLENDMODE_MOD_FULL \ +#define SDL_BLENDMODE_MOD_FULL \ SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_SRC_COLOR, SDL_BLENDOPERATION_ADD, \ SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD) -#define SDL_BLENDMODE_MUL_FULL \ +#define SDL_BLENDMODE_MUL_FULL \ SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_DST_COLOR, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, \ SDL_BLENDFACTOR_DST_ALPHA, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD) @@ -133,8 +133,7 @@ static const SDL_RenderDriver *render_drivers[] = { static char renderer_magic; static char texture_magic; -static SDL_INLINE void -DebugLogRenderCommands(const SDL_RenderCommand *cmd) +static SDL_INLINE void DebugLogRenderCommands(const SDL_RenderCommand *cmd) { #if 0 unsigned int i = 1; @@ -234,14 +233,13 @@ DebugLogRenderCommands(const SDL_RenderCommand *cmd) #endif } -static int -FlushRenderCommands(SDL_Renderer *renderer) +static int FlushRenderCommands(SDL_Renderer *renderer) { int retval; SDL_assert((renderer->render_commands == NULL) == (renderer->render_commands_tail == NULL)); - if (renderer->render_commands == NULL) { /* nothing to do! */ + if (renderer->render_commands == NULL) { /* nothing to do! */ SDL_assert(renderer->vertex_data_used == 0); return 0; } @@ -265,8 +263,7 @@ FlushRenderCommands(SDL_Renderer *renderer) return retval; } -static int -FlushRenderCommandsIfTextureNeeded(SDL_Texture *texture) +static int FlushRenderCommandsIfTextureNeeded(SDL_Texture *texture) { SDL_Renderer *renderer = texture->renderer; if (texture->last_command_generation == renderer->render_command_generation) { @@ -276,14 +273,12 @@ FlushRenderCommandsIfTextureNeeded(SDL_Texture *texture) return 0; } -static SDL_INLINE int -FlushRenderCommandsIfNotBatching(SDL_Renderer *renderer) +static SDL_INLINE int FlushRenderCommandsIfNotBatching(SDL_Renderer *renderer) { return renderer->batching ? 0 : FlushRenderCommands(renderer); } -int -SDL_RenderFlush(SDL_Renderer * renderer) +int SDL_RenderFlush(SDL_Renderer *renderer) { return FlushRenderCommands(renderer); } @@ -321,11 +316,10 @@ SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes, const renderer->vertex_data_used += aligner + numbytes; - return ((Uint8 *) renderer->vertex_data) + aligned; + return ((Uint8 *)renderer->vertex_data) + aligned; } -static SDL_RenderCommand * -AllocateRenderCommand(SDL_Renderer *renderer) +static SDL_RenderCommand *AllocateRenderCommand(SDL_Renderer *renderer) { SDL_RenderCommand *retval = NULL; @@ -335,7 +329,7 @@ AllocateRenderCommand(SDL_Renderer *renderer) renderer->render_commands_pool = retval->next; retval->next = NULL; } else { - retval = SDL_calloc(1, sizeof (*retval)); + retval = SDL_calloc(1, sizeof(*retval)); if (retval == NULL) { SDL_OutOfMemory(); return NULL; @@ -353,16 +347,15 @@ AllocateRenderCommand(SDL_Renderer *renderer) return retval; } -static int -QueueCmdSetViewport(SDL_Renderer *renderer) +static int QueueCmdSetViewport(SDL_Renderer *renderer) { int retval = 0; - if (!renderer->viewport_queued || (SDL_memcmp(&renderer->viewport, &renderer->last_queued_viewport, sizeof (SDL_DRect)) != 0)) { + if (!renderer->viewport_queued || (SDL_memcmp(&renderer->viewport, &renderer->last_queued_viewport, sizeof(SDL_DRect)) != 0)) { SDL_RenderCommand *cmd = AllocateRenderCommand(renderer); retval = -1; if (cmd != NULL) { cmd->command = SDL_RENDERCMD_SETVIEWPORT; - cmd->data.viewport.first = 0; /* render backend will fill this in. */ + cmd->data.viewport.first = 0; /* render backend will fill this in. */ /* Convert SDL_DRect to SDL_Rect */ cmd->data.viewport.rect.x = (int)SDL_floor(renderer->viewport.x); cmd->data.viewport.rect.y = (int)SDL_floor(renderer->viewport.y); @@ -380,13 +373,12 @@ QueueCmdSetViewport(SDL_Renderer *renderer) return retval; } -static int -QueueCmdSetClipRect(SDL_Renderer *renderer) +static int QueueCmdSetClipRect(SDL_Renderer *renderer) { int retval = 0; if ((!renderer->cliprect_queued) || - (renderer->clipping_enabled != renderer->last_queued_cliprect_enabled) || - (SDL_memcmp(&renderer->clip_rect, &renderer->last_queued_cliprect, sizeof (SDL_DRect)) != 0)) { + (renderer->clipping_enabled != renderer->last_queued_cliprect_enabled) || + (SDL_memcmp(&renderer->clip_rect, &renderer->last_queued_cliprect, sizeof(SDL_DRect)) != 0)) { SDL_RenderCommand *cmd = AllocateRenderCommand(renderer); if (cmd == NULL) { retval = -1; @@ -406,8 +398,7 @@ QueueCmdSetClipRect(SDL_Renderer *renderer) return retval; } -static int -QueueCmdSetDrawColor(SDL_Renderer *renderer, SDL_Color *col) +static int QueueCmdSetDrawColor(SDL_Renderer *renderer, SDL_Color *col) { const Uint32 color = (((Uint32)col->a << 24) | (col->r << 16) | (col->g << 8) | col->b); int retval = 0; @@ -418,7 +409,7 @@ QueueCmdSetDrawColor(SDL_Renderer *renderer, SDL_Color *col) if (cmd != NULL) { cmd->command = SDL_RENDERCMD_SETDRAWCOLOR; - cmd->data.color.first = 0; /* render backend will fill this in. */ + cmd->data.color.first = 0; /* render backend will fill this in. */ cmd->data.color.r = col->r; cmd->data.color.g = col->g; cmd->data.color.b = col->b; @@ -435,8 +426,7 @@ QueueCmdSetDrawColor(SDL_Renderer *renderer, SDL_Color *col) return retval; } -static int -QueueCmdClear(SDL_Renderer *renderer) +static int QueueCmdClear(SDL_Renderer *renderer) { SDL_RenderCommand *cmd = AllocateRenderCommand(renderer); if (cmd == NULL) { @@ -452,8 +442,7 @@ QueueCmdClear(SDL_Renderer *renderer) return 0; } -static SDL_RenderCommand * -PrepQueueCmdDraw(SDL_Renderer *renderer, const SDL_RenderCommandType cmdtype, SDL_Texture *texture) +static SDL_RenderCommand *PrepQueueCmdDraw(SDL_Renderer *renderer, const SDL_RenderCommandType cmdtype, SDL_Texture *texture) { SDL_RenderCommand *cmd = NULL; int retval = 0; @@ -486,8 +475,8 @@ PrepQueueCmdDraw(SDL_Renderer *renderer, const SDL_RenderCommandType cmdtype, SD cmd = AllocateRenderCommand(renderer); if (cmd != NULL) { cmd->command = cmdtype; - cmd->data.draw.first = 0; /* render backend will fill this in. */ - cmd->data.draw.count = 0; /* render backend will fill this in. */ + cmd->data.draw.first = 0; /* render backend will fill this in. */ + cmd->data.draw.count = 0; /* render backend will fill this in. */ cmd->data.draw.r = color->r; cmd->data.draw.g = color->g; cmd->data.draw.b = color->b; @@ -499,8 +488,7 @@ PrepQueueCmdDraw(SDL_Renderer *renderer, const SDL_RenderCommandType cmdtype, SD return cmd; } -static int -QueueCmdDrawPoints(SDL_Renderer *renderer, const SDL_FPoint * points, const int count) +static int QueueCmdDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, const int count) { SDL_RenderCommand *cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_DRAW_POINTS, NULL); int retval = -1; @@ -513,8 +501,7 @@ QueueCmdDrawPoints(SDL_Renderer *renderer, const SDL_FPoint * points, const int return retval; } -static int -QueueCmdDrawLines(SDL_Renderer *renderer, const SDL_FPoint * points, const int count) +static int QueueCmdDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, const int count) { SDL_RenderCommand *cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_DRAW_LINES, NULL); int retval = -1; @@ -527,8 +514,7 @@ QueueCmdDrawLines(SDL_Renderer *renderer, const SDL_FPoint * points, const int c return retval; } -static int -QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect * rects, const int count) +static int QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, const int count) { SDL_RenderCommand *cmd; int retval = -1; @@ -547,7 +533,7 @@ QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect * rects, const int cou int i; float *ptr_xy = xy; int *ptr_indices = indices; - const int xy_stride = 2 * sizeof (float); + const int xy_stride = 2 * sizeof(float); const int num_vertices = 4 * count; const int num_indices = 6 * count; const int size_indices = 4; @@ -581,9 +567,9 @@ QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect * rects, const int cou } retval = renderer->QueueGeometry(renderer, cmd, NULL, - xy, xy_stride, &renderer->color, 0 /* color_stride */, NULL, 0, - num_vertices, indices, num_indices, size_indices, - 1.0f, 1.0f); + xy, xy_stride, &renderer->color, 0 /* color_stride */, NULL, 0, + num_vertices, indices, num_indices, size_indices, + 1.0f, 1.0f); if (retval < 0) { cmd->command = SDL_RENDERCMD_NO_OP; @@ -591,7 +577,7 @@ QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect * rects, const int cou } SDL_small_free(xy, isstack1); SDL_small_free(indices, isstack2); - + } else { retval = renderer->QueueFillRects(renderer, cmd, rects, count); if (retval < 0) { @@ -602,8 +588,7 @@ QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect * rects, const int cou return retval; } -static int -QueueCmdCopy(SDL_Renderer *renderer, SDL_Texture * texture, const SDL_Rect * srcrect, const SDL_FRect * dstrect) +static int QueueCmdCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect) { SDL_RenderCommand *cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_COPY, texture); int retval = -1; @@ -616,10 +601,9 @@ QueueCmdCopy(SDL_Renderer *renderer, SDL_Texture * texture, const SDL_Rect * src return retval; } -static int -QueueCmdCopyEx(SDL_Renderer *renderer, SDL_Texture * texture, - const SDL_Rect * srcquad, const SDL_FRect * dstrect, - const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip, float scale_x, float scale_y) +static int QueueCmdCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *srcquad, const SDL_FRect *dstrect, + const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip, float scale_x, float scale_y) { SDL_RenderCommand *cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_COPY_EX, texture); int retval = -1; @@ -632,24 +616,23 @@ QueueCmdCopyEx(SDL_Renderer *renderer, SDL_Texture * texture, return retval; } -static int -QueueCmdGeometry(SDL_Renderer *renderer, SDL_Texture *texture, - const float *xy, int xy_stride, - const SDL_Color *color, int color_stride, - const float *uv, int uv_stride, - int num_vertices, - const void *indices, int num_indices, int size_indices, - float scale_x, float scale_y) +static int QueueCmdGeometry(SDL_Renderer *renderer, SDL_Texture *texture, + const float *xy, int xy_stride, + const SDL_Color *color, int color_stride, + const float *uv, int uv_stride, + int num_vertices, + const void *indices, int num_indices, int size_indices, + float scale_x, float scale_y) { SDL_RenderCommand *cmd; int retval = -1; cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_GEOMETRY, texture); if (cmd != NULL) { retval = renderer->QueueGeometry(renderer, cmd, texture, - xy, xy_stride, - color, color_stride, uv, uv_stride, - num_vertices, indices, num_indices, size_indices, - scale_x, scale_y); + xy, xy_stride, + color, color_stride, uv, uv_stride, + num_vertices, indices, num_indices, size_indices, + scale_x, scale_y); if (retval < 0) { cmd->command = SDL_RENDERCMD_NO_OP; } @@ -659,8 +642,7 @@ QueueCmdGeometry(SDL_Renderer *renderer, SDL_Texture *texture, static int UpdateLogicalSize(SDL_Renderer *renderer, SDL_bool flush_viewport_cmd); -int -SDL_GetNumRenderDrivers(void) +int SDL_GetNumRenderDrivers(void) { #if !SDL_RENDER_DISABLED return SDL_arraysize(render_drivers); @@ -669,8 +651,7 @@ SDL_GetNumRenderDrivers(void) #endif } -int -SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info) +int SDL_GetRenderDriverInfo(int index, SDL_RendererInfo *info) { #if !SDL_RENDER_DISABLED if (index < 0 || index >= SDL_GetNumRenderDrivers()) { @@ -694,8 +675,7 @@ static void GetWindowViewportValues(SDL_Renderer *renderer, int *logical_w, int SDL_UnlockMutex(renderer->target_mutex); } -static int SDLCALL -SDL_RendererEventWatch(void *userdata, SDL_Event *event) +static int SDLCALL SDL_RendererEventWatch(void *userdata, SDL_Event *event) { SDL_Renderer *renderer = (SDL_Renderer *)userdata; @@ -795,13 +775,13 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event) float rel = renderer->xrel + event->motion.xrel / (scale.x * renderer->dpi_scale.x); float truncated = SDL_truncf(rel); renderer->xrel = rel - truncated; - event->motion.xrel = (Sint32) truncated; + event->motion.xrel = (Sint32)truncated; } if (event->motion.yrel != 0 && renderer->relative_scaling) { float rel = renderer->yrel + event->motion.yrel / (scale.y * renderer->dpi_scale.y); float truncated = SDL_truncf(rel); renderer->yrel = rel - truncated; - event->motion.yrel = (Sint32) truncated; + event->motion.yrel = (Sint32)truncated; } } } @@ -839,38 +819,38 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event) if (renderer->GetOutputSize) { int w, h; renderer->GetOutputSize(renderer, &w, &h); - physical_w = (float) w; - physical_h = (float) h; + physical_w = (float)w; + physical_h = (float)h; } else { int w, h; SDL_GetWindowSize(renderer->window, &w, &h); - physical_w = ((float) w) * renderer->dpi_scale.x; - physical_h = ((float) h) * renderer->dpi_scale.y; + physical_w = ((float)w) * renderer->dpi_scale.x; + physical_h = ((float)h) * renderer->dpi_scale.y; } - if (physical_w == 0.0f) { /* nowhere for the touch to go, avoid division by zero and put it dead center. */ + if (physical_w == 0.0f) { /* nowhere for the touch to go, avoid division by zero and put it dead center. */ event->tfinger.x = 0.5f; } else { - const float normalized_viewport_x = ((float) viewport.x) / physical_w; - const float normalized_viewport_w = ((float) viewport.w) / physical_w; + const float normalized_viewport_x = ((float)viewport.x) / physical_w; + const float normalized_viewport_w = ((float)viewport.w) / physical_w; if (event->tfinger.x <= normalized_viewport_x) { - event->tfinger.x = 0.0f; /* to the left of the viewport, clamp to the edge. */ + event->tfinger.x = 0.0f; /* to the left of the viewport, clamp to the edge. */ } else if (event->tfinger.x >= (normalized_viewport_x + normalized_viewport_w)) { - event->tfinger.x = 1.0f; /* to the right of the viewport, clamp to the edge. */ + event->tfinger.x = 1.0f; /* to the right of the viewport, clamp to the edge. */ } else { event->tfinger.x = (event->tfinger.x - normalized_viewport_x) / normalized_viewport_w; } } - if (physical_h == 0.0f) { /* nowhere for the touch to go, avoid division by zero and put it dead center. */ + if (physical_h == 0.0f) { /* nowhere for the touch to go, avoid division by zero and put it dead center. */ event->tfinger.y = 0.5f; } else { - const float normalized_viewport_y = ((float) viewport.y) / physical_h; - const float normalized_viewport_h = ((float) viewport.h) / physical_h; + const float normalized_viewport_y = ((float)viewport.y) / physical_h; + const float normalized_viewport_h = ((float)viewport.h) / physical_h; if (event->tfinger.y <= normalized_viewport_y) { - event->tfinger.y = 0.0f; /* to the left of the viewport, clamp to the edge. */ + event->tfinger.y = 0.0f; /* to the left of the viewport, clamp to the edge. */ } else if (event->tfinger.y >= (normalized_viewport_y + normalized_viewport_h)) { - event->tfinger.y = 1.0f; /* to the right of the viewport, clamp to the edge. */ + event->tfinger.y = 1.0f; /* to the right of the viewport, clamp to the edge. */ } else { event->tfinger.y = (event->tfinger.y - normalized_viewport_y) / normalized_viewport_h; } @@ -880,13 +860,12 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event) return 0; } -int -SDL_CreateWindowAndRenderer(int width, int height, Uint32 window_flags, - SDL_Window **window, SDL_Renderer **renderer) +int SDL_CreateWindowAndRenderer(int width, int height, Uint32 window_flags, + SDL_Window **window, SDL_Renderer **renderer) { *window = SDL_CreateWindow(NULL, SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, - width, height, window_flags); + SDL_WINDOWPOS_UNDEFINED, + width, height, window_flags); if (!*window) { *renderer = NULL; return -1; @@ -901,8 +880,7 @@ SDL_CreateWindowAndRenderer(int width, int height, Uint32 window_flags, } #if !SDL_RENDER_DISABLED -static SDL_INLINE -void VerifyDrawQueueFunctions(const SDL_Renderer *renderer) +static SDL_INLINE void VerifyDrawQueueFunctions(const SDL_Renderer *renderer) { /* all of these functions are required to be implemented, even as no-ops, so we don't have to check that they aren't NULL over and over. */ @@ -957,7 +935,7 @@ static void SDL_CalculateSimulatedVSyncInterval(SDL_Renderer *renderer, SDL_Wind #endif /* !SDL_RENDER_DISABLED */ SDL_Renderer * -SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags) +SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags) { #if !SDL_RENDER_DISABLED SDL_Renderer *renderer = NULL; @@ -1092,7 +1070,7 @@ SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags) renderer->line_method = SDL_GetRenderLineMethod(); - if (SDL_GetWindowFlags(window) & (SDL_WINDOW_HIDDEN|SDL_WINDOW_MINIMIZED)) { + if (SDL_GetWindowFlags(window) & (SDL_WINDOW_HIDDEN | SDL_WINDOW_MINIMIZED)) { renderer->hidden = SDL_TRUE; } else { renderer->hidden = SDL_FALSE; @@ -1126,7 +1104,7 @@ error: } SDL_Renderer * -SDL_CreateSoftwareRenderer(SDL_Surface * surface) +SDL_CreateSoftwareRenderer(SDL_Surface *surface) { #if !SDL_RENDER_DISABLED && SDL_VIDEO_RENDER_SW SDL_Renderer *renderer; @@ -1156,7 +1134,7 @@ SDL_CreateSoftwareRenderer(SDL_Surface * surface) } SDL_Renderer * -SDL_GetRenderer(SDL_Window * window) +SDL_GetRenderer(SDL_Window *window) { return (SDL_Renderer *)SDL_GetWindowData(window, SDL_WINDOWRENDERDATA); } @@ -1168,8 +1146,7 @@ SDL_RenderGetWindow(SDL_Renderer *renderer) return renderer->window; } -int -SDL_GetRendererInfo(SDL_Renderer * renderer, SDL_RendererInfo * info) +int SDL_GetRendererInfo(SDL_Renderer *renderer, SDL_RendererInfo *info) { CHECK_RENDERER_MAGIC(renderer, -1); @@ -1177,8 +1154,7 @@ SDL_GetRendererInfo(SDL_Renderer * renderer, SDL_RendererInfo * info) return 0; } -int -SDL_GetRendererOutputSize(SDL_Renderer * renderer, int *w, int *h) +int SDL_GetRendererOutputSize(SDL_Renderer *renderer, int *w, int *h) { CHECK_RENDERER_MAGIC(renderer, -1); @@ -1195,11 +1171,9 @@ SDL_GetRendererOutputSize(SDL_Renderer * renderer, int *w, int *h) } } -static SDL_bool -IsSupportedBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +static SDL_bool IsSupportedBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { - switch (blendMode) - { + switch (blendMode) { /* These are required to be supported by all renderers */ case SDL_BLENDMODE_NONE: case SDL_BLENDMODE_BLEND: @@ -1213,8 +1187,7 @@ IsSupportedBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) } } -static SDL_bool -IsSupportedFormat(SDL_Renderer * renderer, Uint32 format) +static SDL_bool IsSupportedFormat(SDL_Renderer *renderer, Uint32 format) { Uint32 i; @@ -1226,8 +1199,7 @@ IsSupportedFormat(SDL_Renderer * renderer, Uint32 format) return SDL_FALSE; } -static Uint32 -GetClosestSupportedFormat(SDL_Renderer * renderer, Uint32 format) +static Uint32 GetClosestSupportedFormat(SDL_Renderer *renderer, Uint32 format) { Uint32 i; @@ -1252,7 +1224,6 @@ GetClosestSupportedFormat(SDL_Renderer * renderer, Uint32 format) return renderer->info.texture_formats[0]; } - static SDL_ScaleMode SDL_GetScaleMode(void) { const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY); @@ -1269,7 +1240,7 @@ static SDL_ScaleMode SDL_GetScaleMode(void) } SDL_Texture * -SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int h) +SDL_CreateTexture(SDL_Renderer *renderer, Uint32 format, int access, int w, int h) { SDL_Texture *texture; SDL_bool texture_is_fourcc_and_target; @@ -1298,7 +1269,7 @@ SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int SDL_SetError("Texture dimensions are limited to %dx%d", renderer->info.max_texture_width, renderer->info.max_texture_height); return NULL; } - texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture)); + texture = (SDL_Texture *)SDL_calloc(1, sizeof(*texture)); if (texture == NULL) { SDL_OutOfMemory(); return NULL; @@ -1380,7 +1351,7 @@ SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int } SDL_Texture * -SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface) +SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface) { const SDL_PixelFormat *fmt; SDL_bool needAlpha; @@ -1446,7 +1417,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface) format = renderer->info.texture_formats[0]; for (i = 0; i < (int)renderer->info.num_texture_formats; ++i) { if (!SDL_ISPIXELFORMAT_FOURCC(renderer->info.texture_formats[i]) && - SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == needAlpha) { + SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == needAlpha) { format = renderer->info.texture_formats[i]; break; } @@ -1461,7 +1432,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface) if (format == surface->format->format) { if (surface->format->Amask && SDL_HasColorKey(surface)) { - /* Surface and Renderer formats are identicals. + /* Surface and Renderer formats are identicals. * Intermediate conversion is needed to convert color key to alpha (SDL_ConvertColorkeyToAlpha()). */ direct_update = SDL_FALSE; } else { @@ -1500,8 +1471,8 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface) /* Set up a destination surface for the texture update */ dst_fmt = SDL_AllocFormat(format); if (dst_fmt == NULL) { - SDL_DestroyTexture(texture); - return NULL; + SDL_DestroyTexture(texture); + return NULL; } temp = SDL_ConvertSurface(surface, dst_fmt, 0); SDL_FreeFormat(dst_fmt); @@ -1535,9 +1506,8 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface) return texture; } -int -SDL_QueryTexture(SDL_Texture * texture, Uint32 * format, int *access, - int *w, int *h) +int SDL_QueryTexture(SDL_Texture *texture, Uint32 *format, int *access, + int *w, int *h) { CHECK_TEXTURE_MAGIC(texture, -1); @@ -1556,8 +1526,7 @@ SDL_QueryTexture(SDL_Texture * texture, Uint32 * format, int *access, return 0; } -int -SDL_SetTextureColorMod(SDL_Texture * texture, Uint8 r, Uint8 g, Uint8 b) +int SDL_SetTextureColorMod(SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b) { CHECK_TEXTURE_MAGIC(texture, -1); @@ -1575,9 +1544,8 @@ SDL_SetTextureColorMod(SDL_Texture * texture, Uint8 r, Uint8 g, Uint8 b) return 0; } -int -SDL_GetTextureColorMod(SDL_Texture * texture, Uint8 * r, Uint8 * g, - Uint8 * b) +int SDL_GetTextureColorMod(SDL_Texture *texture, Uint8 *r, Uint8 *g, + Uint8 *b) { CHECK_TEXTURE_MAGIC(texture, -1); @@ -1593,8 +1561,7 @@ SDL_GetTextureColorMod(SDL_Texture * texture, Uint8 * r, Uint8 * g, return 0; } -int -SDL_SetTextureAlphaMod(SDL_Texture * texture, Uint8 alpha) +int SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha) { CHECK_TEXTURE_MAGIC(texture, -1); @@ -1610,8 +1577,7 @@ SDL_SetTextureAlphaMod(SDL_Texture * texture, Uint8 alpha) return 0; } -int -SDL_GetTextureAlphaMod(SDL_Texture * texture, Uint8 * alpha) +int SDL_GetTextureAlphaMod(SDL_Texture *texture, Uint8 *alpha) { CHECK_TEXTURE_MAGIC(texture, -1); @@ -1621,8 +1587,7 @@ SDL_GetTextureAlphaMod(SDL_Texture * texture, Uint8 * alpha) return 0; } -int -SDL_SetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode blendMode) +int SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode) { SDL_Renderer *renderer; @@ -1639,8 +1604,7 @@ SDL_SetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode blendMode) return 0; } -int -SDL_GetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode *blendMode) +int SDL_GetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode *blendMode) { CHECK_TEXTURE_MAGIC(texture, -1); @@ -1650,8 +1614,7 @@ SDL_GetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode *blendMode) return 0; } -int -SDL_SetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode scaleMode) +int SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode) { SDL_Renderer *renderer; @@ -1667,8 +1630,7 @@ SDL_SetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode scaleMode) return 0; } -int -SDL_GetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode *scaleMode) +int SDL_GetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode *scaleMode) { CHECK_TEXTURE_MAGIC(texture, -1); @@ -1678,8 +1640,7 @@ SDL_GetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode *scaleMode) return 0; } -int -SDL_SetTextureUserData(SDL_Texture * texture, void *userdata) +int SDL_SetTextureUserData(SDL_Texture *texture, void *userdata) { CHECK_TEXTURE_MAGIC(texture, -1); @@ -1688,7 +1649,7 @@ SDL_SetTextureUserData(SDL_Texture * texture, void *userdata) } void * -SDL_GetTextureUserData(SDL_Texture * texture) +SDL_GetTextureUserData(SDL_Texture *texture) { CHECK_TEXTURE_MAGIC(texture, NULL); @@ -1696,9 +1657,8 @@ SDL_GetTextureUserData(SDL_Texture * texture) } #if SDL_HAVE_YUV -static int -SDL_UpdateTextureYUV(SDL_Texture * texture, const SDL_Rect * rect, - const void *pixels, int pitch) +static int SDL_UpdateTextureYUV(SDL_Texture *texture, const SDL_Rect *rect, + const void *pixels, int pitch) { SDL_Texture *native = texture->native; SDL_Rect full_rect; @@ -1743,14 +1703,13 @@ SDL_UpdateTextureYUV(SDL_Texture * texture, const SDL_Rect * rect, } #endif /* SDL_HAVE_YUV */ -static int -SDL_UpdateTextureNative(SDL_Texture * texture, const SDL_Rect * rect, - const void *pixels, int pitch) +static int SDL_UpdateTextureNative(SDL_Texture *texture, const SDL_Rect *rect, + const void *pixels, int pitch) { SDL_Texture *native = texture->native; if (!rect->w || !rect->h) { - return 0; /* nothing to do. */ + return 0; /* nothing to do. */ } if (texture->access == SDL_TEXTUREACCESS_STREAMING) { @@ -1784,9 +1743,8 @@ SDL_UpdateTextureNative(SDL_Texture * texture, const SDL_Rect * rect, return 0; } -int -SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect, - const void *pixels, int pitch) +int SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, + const void *pixels, int pitch) { SDL_Rect real_rect; @@ -1810,7 +1768,7 @@ SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect, } if (real_rect.w == 0 || real_rect.h == 0) { - return 0; /* nothing to do. */ + return 0; /* nothing to do. */ #if SDL_HAVE_YUV } else if (texture->yuv) { return SDL_UpdateTextureYUV(texture, &real_rect, pixels, pitch); @@ -1827,11 +1785,10 @@ SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect, } #if SDL_HAVE_YUV -static int -SDL_UpdateTextureYUVPlanar(SDL_Texture * texture, const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *Uplane, int Upitch, - const Uint8 *Vplane, int Vpitch) +static int SDL_UpdateTextureYUVPlanar(SDL_Texture *texture, const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) { SDL_Texture *native = texture->native; SDL_Rect full_rect; @@ -1847,7 +1804,7 @@ SDL_UpdateTextureYUVPlanar(SDL_Texture * texture, const SDL_Rect * rect, rect = &full_rect; if (!rect->w || !rect->h) { - return 0; /* nothing to do. */ + return 0; /* nothing to do. */ } if (texture->access == SDL_TEXTUREACCESS_STREAMING) { @@ -1879,10 +1836,9 @@ SDL_UpdateTextureYUVPlanar(SDL_Texture * texture, const SDL_Rect * rect, return 0; } -static int -SDL_UpdateTextureNVPlanar(SDL_Texture * texture, const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *UVplane, int UVpitch) +static int SDL_UpdateTextureNVPlanar(SDL_Texture *texture, const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch) { SDL_Texture *native = texture->native; SDL_Rect full_rect; @@ -1898,7 +1854,7 @@ SDL_UpdateTextureNVPlanar(SDL_Texture * texture, const SDL_Rect * rect, rect = &full_rect; if (!rect->w || !rect->h) { - return 0; /* nothing to do. */ + return 0; /* nothing to do. */ } if (texture->access == SDL_TEXTUREACCESS_STREAMING) { @@ -1930,10 +1886,9 @@ SDL_UpdateTextureNVPlanar(SDL_Texture * texture, const SDL_Rect * rect, return 0; } - #endif /* SDL_HAVE_YUV */ -int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect, +int SDL_UpdateYUVTexture(SDL_Texture *texture, const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch) @@ -1977,7 +1932,7 @@ int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect, } if (real_rect.w == 0 || real_rect.h == 0) { - return 0; /* nothing to do. */ + return 0; /* nothing to do. */ } if (texture->yuv) { @@ -2000,9 +1955,9 @@ int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect, #endif } -int SDL_UpdateNVTexture(SDL_Texture * texture, const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *UVplane, int UVpitch) +int SDL_UpdateNVTexture(SDL_Texture *texture, const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch) { #if SDL_HAVE_YUV SDL_Renderer *renderer; @@ -2037,7 +1992,7 @@ int SDL_UpdateNVTexture(SDL_Texture * texture, const SDL_Rect * rect, } if (real_rect.w == 0 || real_rect.h == 0) { - return 0; /* nothing to do. */ + return 0; /* nothing to do. */ } if (texture->yuv) { @@ -2060,32 +2015,27 @@ int SDL_UpdateNVTexture(SDL_Texture * texture, const SDL_Rect * rect, #endif } - - #if SDL_HAVE_YUV -static int -SDL_LockTextureYUV(SDL_Texture * texture, const SDL_Rect * rect, - void **pixels, int *pitch) +static int SDL_LockTextureYUV(SDL_Texture *texture, const SDL_Rect *rect, + void **pixels, int *pitch) { return SDL_SW_LockYUVTexture(texture->yuv, rect, pixels, pitch); } #endif /* SDL_HAVE_YUV */ -static int -SDL_LockTextureNative(SDL_Texture * texture, const SDL_Rect * rect, - void **pixels, int *pitch) +static int SDL_LockTextureNative(SDL_Texture *texture, const SDL_Rect *rect, + void **pixels, int *pitch) { texture->locked_rect = *rect; - *pixels = (void *) ((Uint8 *) texture->pixels + - rect->y * texture->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); + *pixels = (void *)((Uint8 *)texture->pixels + + rect->y * texture->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); *pitch = texture->pitch; return 0; } -int -SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect, - void **pixels, int *pitch) +int SDL_LockTexture(SDL_Texture *texture, const SDL_Rect *rect, + void **pixels, int *pitch) { SDL_Rect full_rect; @@ -2111,7 +2061,7 @@ SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect, return SDL_LockTextureYUV(texture, rect, pixels, pitch); } else #endif - if (texture->native) { + if (texture->native) { /* Calls a real SDL_LockTexture/SDL_UnlockTexture on unlock, flushing then. */ return SDL_LockTextureNative(texture, rect, pixels, pitch); } else { @@ -2123,9 +2073,8 @@ SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect, } } -int -SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, - SDL_Surface **surface) +int SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, + SDL_Surface **surface) { SDL_Rect real_rect; void *pixels = NULL; @@ -2160,8 +2109,7 @@ SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, } #if SDL_HAVE_YUV -static void -SDL_UnlockTextureYUV(SDL_Texture * texture) +static void SDL_UnlockTextureYUV(SDL_Texture *texture) { SDL_Texture *native = texture->native; void *native_pixels = NULL; @@ -2182,16 +2130,15 @@ SDL_UnlockTextureYUV(SDL_Texture * texture) } #endif /* SDL_HAVE_YUV */ -static void -SDL_UnlockTextureNative(SDL_Texture * texture) +static void SDL_UnlockTextureNative(SDL_Texture *texture) { SDL_Texture *native = texture->native; void *native_pixels = NULL; int native_pitch = 0; const SDL_Rect *rect = &texture->locked_rect; - const void* pixels = (void *) ((Uint8 *) texture->pixels + - rect->y * texture->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); + const void *pixels = (void *)((Uint8 *)texture->pixels + + rect->y * texture->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); int pitch = texture->pitch; if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) { @@ -2203,8 +2150,7 @@ SDL_UnlockTextureNative(SDL_Texture * texture) SDL_UnlockTexture(native); } -void -SDL_UnlockTexture(SDL_Texture * texture) +void SDL_UnlockTexture(SDL_Texture *texture) { CHECK_TEXTURE_MAGIC(texture, ); @@ -2216,7 +2162,7 @@ SDL_UnlockTexture(SDL_Texture * texture) SDL_UnlockTextureYUV(texture); } else #endif - if (texture->native) { + if (texture->native) { SDL_UnlockTextureNative(texture); } else { SDL_Renderer *renderer = texture->renderer; @@ -2236,8 +2182,7 @@ SDL_RenderTargetSupported(SDL_Renderer *renderer) return (renderer->info.flags & SDL_RENDERER_TARGETTEXTURE) != 0; } -int -SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) +int SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) { if (!SDL_RenderTargetSupported(renderer)) { return SDL_Unsupported(); @@ -2263,7 +2208,7 @@ SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) return 0; } - FlushRenderCommands(renderer); /* time to send everything to the GPU! */ + FlushRenderCommands(renderer); /* time to send everything to the GPU! */ SDL_LockMutex(renderer->target_mutex); @@ -2324,8 +2269,7 @@ SDL_GetRenderTarget(SDL_Renderer *renderer) return renderer->target; } -static int -UpdateLogicalSize(SDL_Renderer *renderer, SDL_bool flush_viewport_cmd) +static int UpdateLogicalSize(SDL_Renderer *renderer, SDL_bool flush_viewport_cmd) { int w = 1, h = 1; float want_aspect; @@ -2382,7 +2326,7 @@ UpdateLogicalSize(SDL_Renderer *renderer, SDL_bool flush_viewport_cmd) viewport.x = (w - viewport.w) / 2; viewport.h = (int)SDL_floor(renderer->logical_h * scale); viewport.y = (h - viewport.h) / 2; - } else if (SDL_fabs(want_aspect-real_aspect) < 0.0001) { + } else if (SDL_fabs(want_aspect - real_aspect) < 0.0001) { /* The aspect ratios are the same, just scale appropriately */ scale = (float)w / renderer->logical_w; @@ -2390,9 +2334,9 @@ UpdateLogicalSize(SDL_Renderer *renderer, SDL_bool flush_viewport_cmd) SDL_GetRendererOutputSize(renderer, &viewport.w, &viewport.h); } else if (want_aspect > real_aspect) { if (scale_policy == 1) { - /* We want a wider aspect ratio than is available - - zoom so logical height matches the real height - and the width will grow off the screen + /* We want a wider aspect ratio than is available - + zoom so logical height matches the real height + and the width will grow off the screen */ scale = (float)h / renderer->logical_h; viewport.y = 0; @@ -2420,11 +2364,11 @@ UpdateLogicalSize(SDL_Renderer *renderer, SDL_bool flush_viewport_cmd) viewport.y = (h - viewport.h) / 2; } else { /* We want a narrower aspect ratio than is available - use side-bars */ - scale = (float)h / renderer->logical_h; - viewport.y = 0; - viewport.h = h; - viewport.w = (int)SDL_floor(renderer->logical_w * scale); - viewport.x = (w - viewport.w) / 2; + scale = (float)h / renderer->logical_h; + viewport.y = 0; + viewport.h = h; + viewport.w = (int)SDL_floor(renderer->logical_w * scale); + viewport.x = (w - viewport.w) / 2; } } @@ -2444,8 +2388,7 @@ UpdateLogicalSize(SDL_Renderer *renderer, SDL_bool flush_viewport_cmd) return 0; } -int -SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h) +int SDL_RenderSetLogicalSize(SDL_Renderer *renderer, int w, int h) { CHECK_RENDERER_MAGIC(renderer, -1); @@ -2464,8 +2407,7 @@ SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h) return UpdateLogicalSize(renderer, SDL_TRUE); } -void -SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h) +void SDL_RenderGetLogicalSize(SDL_Renderer *renderer, int *w, int *h) { CHECK_RENDERER_MAGIC(renderer, ); @@ -2477,8 +2419,7 @@ SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h) } } -int -SDL_RenderSetIntegerScale(SDL_Renderer * renderer, SDL_bool enable) +int SDL_RenderSetIntegerScale(SDL_Renderer *renderer, SDL_bool enable) { CHECK_RENDERER_MAGIC(renderer, -1); @@ -2488,15 +2429,15 @@ SDL_RenderSetIntegerScale(SDL_Renderer * renderer, SDL_bool enable) } SDL_bool -SDLCALL SDL_RenderGetIntegerScale(SDL_Renderer * renderer) + SDLCALL + SDL_RenderGetIntegerScale(SDL_Renderer *renderer) { CHECK_RENDERER_MAGIC(renderer, SDL_FALSE); return renderer->integer_scale; } -int -SDL_RenderSetViewport(SDL_Renderer * renderer, const SDL_Rect * rect) +int SDL_RenderSetViewport(SDL_Renderer *renderer, const SDL_Rect *rect) { int retval; CHECK_RENDERER_MAGIC(renderer, -1); @@ -2520,8 +2461,7 @@ SDL_RenderSetViewport(SDL_Renderer * renderer, const SDL_Rect * rect) return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer); } -void -SDL_RenderGetViewport(SDL_Renderer * renderer, SDL_Rect * rect) +void SDL_RenderGetViewport(SDL_Renderer *renderer, SDL_Rect *rect) { CHECK_RENDERER_MAGIC(renderer, ); @@ -2533,8 +2473,7 @@ SDL_RenderGetViewport(SDL_Renderer * renderer, SDL_Rect * rect) } } -static void -RenderGetViewportSize(SDL_Renderer * renderer, SDL_FRect * rect) +static void RenderGetViewportSize(SDL_Renderer *renderer, SDL_FRect *rect) { rect->x = 0.0f; rect->y = 0.0f; @@ -2542,8 +2481,7 @@ RenderGetViewportSize(SDL_Renderer * renderer, SDL_FRect * rect) rect->h = (float)(renderer->viewport.h / renderer->scale.y); } -int -SDL_RenderSetClipRect(SDL_Renderer * renderer, const SDL_Rect * rect) +int SDL_RenderSetClipRect(SDL_Renderer *renderer, const SDL_Rect *rect) { int retval; CHECK_RENDERER_MAGIC(renderer, -1) @@ -2563,8 +2501,7 @@ SDL_RenderSetClipRect(SDL_Renderer * renderer, const SDL_Rect * rect) return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer); } -void -SDL_RenderGetClipRect(SDL_Renderer * renderer, SDL_Rect * rect) +void SDL_RenderGetClipRect(SDL_Renderer *renderer, SDL_Rect *rect) { CHECK_RENDERER_MAGIC(renderer, ) @@ -2577,14 +2514,13 @@ SDL_RenderGetClipRect(SDL_Renderer * renderer, SDL_Rect * rect) } SDL_bool -SDL_RenderIsClipEnabled(SDL_Renderer * renderer) +SDL_RenderIsClipEnabled(SDL_Renderer *renderer) { CHECK_RENDERER_MAGIC(renderer, SDL_FALSE) return renderer->clipping_enabled; } -int -SDL_RenderSetScale(SDL_Renderer * renderer, float scaleX, float scaleY) +int SDL_RenderSetScale(SDL_Renderer *renderer, float scaleX, float scaleY) { CHECK_RENDERER_MAGIC(renderer, -1); @@ -2593,8 +2529,7 @@ SDL_RenderSetScale(SDL_Renderer * renderer, float scaleX, float scaleY) return 0; } -void -SDL_RenderGetScale(SDL_Renderer * renderer, float *scaleX, float *scaleY) +void SDL_RenderGetScale(SDL_Renderer *renderer, float *scaleX, float *scaleY) { CHECK_RENDERER_MAGIC(renderer, ); @@ -2606,15 +2541,14 @@ SDL_RenderGetScale(SDL_Renderer * renderer, float *scaleX, float *scaleY) } } -void -SDL_RenderWindowToLogical(SDL_Renderer * renderer, int windowX, int windowY, float *logicalX, float *logicalY) +void SDL_RenderWindowToLogical(SDL_Renderer *renderer, int windowX, int windowY, float *logicalX, float *logicalY) { float window_physical_x, window_physical_y; CHECK_RENDERER_MAGIC(renderer, ); - window_physical_x = ((float) windowX) / renderer->dpi_scale.x; - window_physical_y = ((float) windowY) / renderer->dpi_scale.y; + window_physical_x = ((float)windowX) / renderer->dpi_scale.x; + window_physical_y = ((float)windowY) / renderer->dpi_scale.y; if (logicalX) { *logicalX = (float)((window_physical_x - renderer->viewport.x) / renderer->scale.x); @@ -2624,8 +2558,7 @@ SDL_RenderWindowToLogical(SDL_Renderer * renderer, int windowX, int windowY, flo } } -void -SDL_RenderLogicalToWindow(SDL_Renderer * renderer, float logicalX, float logicalY, int *windowX, int *windowY) +void SDL_RenderLogicalToWindow(SDL_Renderer *renderer, float logicalX, float logicalY, int *windowX, int *windowY) { float window_physical_x, window_physical_y; @@ -2642,9 +2575,8 @@ SDL_RenderLogicalToWindow(SDL_Renderer * renderer, float logicalX, float logical } } -int -SDL_SetRenderDrawColor(SDL_Renderer * renderer, - Uint8 r, Uint8 g, Uint8 b, Uint8 a) +int SDL_SetRenderDrawColor(SDL_Renderer *renderer, + Uint8 r, Uint8 g, Uint8 b, Uint8 a) { CHECK_RENDERER_MAGIC(renderer, -1); @@ -2655,9 +2587,8 @@ SDL_SetRenderDrawColor(SDL_Renderer * renderer, return 0; } -int -SDL_GetRenderDrawColor(SDL_Renderer * renderer, - Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a) +int SDL_GetRenderDrawColor(SDL_Renderer *renderer, + Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) { CHECK_RENDERER_MAGIC(renderer, -1); @@ -2676,8 +2607,7 @@ SDL_GetRenderDrawColor(SDL_Renderer * renderer, return 0; } -int -SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +int SDL_SetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { CHECK_RENDERER_MAGIC(renderer, -1); @@ -2688,8 +2618,7 @@ SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) return 0; } -int -SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, SDL_BlendMode *blendMode) +int SDL_GetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode *blendMode) { CHECK_RENDERER_MAGIC(renderer, -1); @@ -2697,8 +2626,7 @@ SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, SDL_BlendMode *blendMode) return 0; } -int -SDL_RenderClear(SDL_Renderer * renderer) +int SDL_RenderClear(SDL_Renderer *renderer) { int retval; CHECK_RENDERER_MAGIC(renderer, -1); @@ -2706,21 +2634,18 @@ SDL_RenderClear(SDL_Renderer * renderer) return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer); } - /* !!! FIXME: delete all the duplicate code for the integer versions in 2.1, !!! FIXME: making the floating point versions the only available APIs. */ -int -SDL_RenderDrawPoint(SDL_Renderer * renderer, int x, int y) +int SDL_RenderDrawPoint(SDL_Renderer *renderer, int x, int y) { SDL_FPoint fpoint; - fpoint.x = (float) x; - fpoint.y = (float) y; + fpoint.x = (float)x; + fpoint.y = (float)y; return SDL_RenderDrawPointsF(renderer, &fpoint, 1); } -int -SDL_RenderDrawPointF(SDL_Renderer * renderer, float x, float y) +int SDL_RenderDrawPointF(SDL_Renderer *renderer, float x, float y) { SDL_FPoint fpoint; fpoint.x = x; @@ -2728,9 +2653,8 @@ SDL_RenderDrawPointF(SDL_Renderer * renderer, float x, float y) return SDL_RenderDrawPointsF(renderer, &fpoint, 1); } -static int -RenderDrawPointsWithRects(SDL_Renderer * renderer, - const SDL_Point * points, const int count) +static int RenderDrawPointsWithRects(SDL_Renderer *renderer, + const SDL_Point *points, const int count) { int retval; SDL_bool isstack; @@ -2760,9 +2684,8 @@ RenderDrawPointsWithRects(SDL_Renderer * renderer, return retval; } -int -SDL_RenderDrawPoints(SDL_Renderer * renderer, - const SDL_Point * points, int count) +int SDL_RenderDrawPoints(SDL_Renderer *renderer, + const SDL_Point *points, int count) { SDL_FPoint *fpoints; int i; @@ -2793,8 +2716,8 @@ SDL_RenderDrawPoints(SDL_Renderer * renderer, return SDL_OutOfMemory(); } for (i = 0; i < count; ++i) { - fpoints[i].x = (float) points[i].x; - fpoints[i].y = (float) points[i].y; + fpoints[i].x = (float)points[i].x; + fpoints[i].y = (float)points[i].y; } retval = QueueCmdDrawPoints(renderer, fpoints, count); @@ -2804,9 +2727,8 @@ SDL_RenderDrawPoints(SDL_Renderer * renderer, return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer); } -static int -RenderDrawPointsWithRectsF(SDL_Renderer * renderer, - const SDL_FPoint * fpoints, const int count) +static int RenderDrawPointsWithRectsF(SDL_Renderer *renderer, + const SDL_FPoint *fpoints, const int count) { int retval; SDL_bool isstack; @@ -2836,9 +2758,8 @@ RenderDrawPointsWithRectsF(SDL_Renderer * renderer, return retval; } -int -SDL_RenderDrawPointsF(SDL_Renderer * renderer, - const SDL_FPoint * points, int count) +int SDL_RenderDrawPointsF(SDL_Renderer *renderer, + const SDL_FPoint *points, int count) { int retval; @@ -2866,19 +2787,17 @@ SDL_RenderDrawPointsF(SDL_Renderer * renderer, return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer); } -int -SDL_RenderDrawLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) +int SDL_RenderDrawLine(SDL_Renderer *renderer, int x1, int y1, int x2, int y2) { SDL_FPoint points[2]; - points[0].x = (float) x1; - points[0].y = (float) y1; - points[1].x = (float) x2; - points[1].y = (float) y2; + points[0].x = (float)x1; + points[0].y = (float)y1; + points[1].x = (float)x2; + points[1].y = (float)y2; return SDL_RenderDrawLinesF(renderer, points, 2); } -int -SDL_RenderDrawLineF(SDL_Renderer * renderer, float x1, float y1, float x2, float y2) +int SDL_RenderDrawLineF(SDL_Renderer *renderer, float x1, float y1, float x2, float y2) { SDL_FPoint points[2]; points[0].x = x1; @@ -2967,9 +2886,8 @@ static int RenderDrawLineBresenham(SDL_Renderer *renderer, int x1, int y1, int x return retval; } -static int -RenderDrawLinesWithRectsF(SDL_Renderer * renderer, - const SDL_FPoint * points, const int count) +static int RenderDrawLinesWithRectsF(SDL_Renderer *renderer, + const SDL_FPoint *points, const int count) { const float scale_x = renderer->scale.x; const float scale_y = renderer->scale.y; @@ -2981,17 +2899,17 @@ RenderDrawLinesWithRectsF(SDL_Renderer * renderer, SDL_bool drew_line = SDL_FALSE; SDL_bool draw_last = SDL_FALSE; - frects = SDL_small_alloc(SDL_FRect, count-1, &isstack); + frects = SDL_small_alloc(SDL_FRect, count - 1, &isstack); if (frects == NULL) { return SDL_OutOfMemory(); } - for (i = 0; i < count-1; ++i) { - SDL_bool same_x = (points[i].x == points[i+1].x); - SDL_bool same_y = (points[i].y == points[i+1].y); + for (i = 0; i < count - 1; ++i) { + SDL_bool same_x = (points[i].x == points[i + 1].x); + SDL_bool same_y = (points[i].y == points[i + 1].y); if (i == (count - 2)) { - if (!drew_line || points[i+1].x != points[0].x || points[i+1].y != points[0].y) { + if (!drew_line || points[i + 1].x != points[0].x || points[i + 1].y != points[0].y) { draw_last = SDL_TRUE; } } else { @@ -3000,32 +2918,32 @@ RenderDrawLinesWithRectsF(SDL_Renderer * renderer, } } if (same_x) { - const float minY = SDL_min(points[i].y, points[i+1].y); - const float maxY = SDL_max(points[i].y, points[i+1].y); + const float minY = SDL_min(points[i].y, points[i + 1].y); + const float maxY = SDL_max(points[i].y, points[i + 1].y); frect = &frects[nrects++]; frect->x = points[i].x * scale_x; frect->y = minY * scale_y; frect->w = scale_x; frect->h = (maxY - minY + draw_last) * scale_y; - if (!draw_last && points[i+1].y < points[i].y) { + if (!draw_last && points[i + 1].y < points[i].y) { frect->y += scale_y; } } else if (same_y) { - const float minX = SDL_min(points[i].x, points[i+1].x); - const float maxX = SDL_max(points[i].x, points[i+1].x); + const float minX = SDL_min(points[i].x, points[i + 1].x); + const float maxX = SDL_max(points[i].x, points[i + 1].x); frect = &frects[nrects++]; frect->x = minX * scale_x; frect->y = points[i].y * scale_y; frect->w = (maxX - minX + draw_last) * scale_x; frect->h = scale_y; - if (!draw_last && points[i+1].x < points[i].x) { + if (!draw_last && points[i + 1].x < points[i].x) { frect->x += scale_x; } } else { retval += RenderDrawLineBresenham(renderer, (int)SDL_roundf(points[i].x), (int)SDL_roundf(points[i].y), - (int)SDL_roundf(points[i+1].x), (int)SDL_roundf(points[i+1].y), draw_last); + (int)SDL_roundf(points[i + 1].x), (int)SDL_roundf(points[i + 1].y), draw_last); } drew_line = SDL_TRUE; } @@ -3042,9 +2960,8 @@ RenderDrawLinesWithRectsF(SDL_Renderer * renderer, return retval; } -int -SDL_RenderDrawLines(SDL_Renderer * renderer, - const SDL_Point * points, int count) +int SDL_RenderDrawLines(SDL_Renderer *renderer, + const SDL_Point *points, int count) { SDL_FPoint *fpoints; int i; @@ -3073,8 +2990,8 @@ SDL_RenderDrawLines(SDL_Renderer * renderer, } for (i = 0; i < count; ++i) { - fpoints[i].x = (float) points[i].x; - fpoints[i].y = (float) points[i].y; + fpoints[i].x = (float)points[i].x; + fpoints[i].y = (float)points[i].y; } retval = SDL_RenderDrawLinesF(renderer, fpoints, count); @@ -3084,9 +3001,8 @@ SDL_RenderDrawLines(SDL_Renderer * renderer, return retval; } -int -SDL_RenderDrawLinesF(SDL_Renderer * renderer, - const SDL_FPoint * points, int count) +int SDL_RenderDrawLinesF(SDL_Renderer *renderer, + const SDL_FPoint *points, int count) { int retval = 0; @@ -3115,15 +3031,13 @@ SDL_RenderDrawLinesF(SDL_Renderer * renderer, const float scale_y = renderer->scale.y; float *xy = SDL_small_alloc(float, 4 * 2 * count, &isstack1); int *indices = SDL_small_alloc(int, - (4) * 3 * (count - 1) - + (2) * 3 * (count) - , &isstack2); + (4) * 3 * (count - 1) + (2) * 3 * (count), &isstack2); if (xy && indices) { int i; float *ptr_xy = xy; int *ptr_indices = indices; - const int xy_stride = 2 * sizeof (float); + const int xy_stride = 2 * sizeof(float); int num_vertices = 4 * count; int num_indices = 0; const int size_indices = 4; @@ -3153,11 +3067,11 @@ SDL_RenderDrawLinesF(SDL_Renderer * renderer, *ptr_xy++ = q.x; *ptr_xy++ = q.y + scale_y; -#define ADD_TRIANGLE(i1, i2, i3) \ - *ptr_indices++ = cur_index + i1; \ - *ptr_indices++ = cur_index + i2; \ - *ptr_indices++ = cur_index + i3; \ - num_indices += 3; \ +#define ADD_TRIANGLE(i1, i2, i3) \ + *ptr_indices++ = cur_index + i1; \ + *ptr_indices++ = cur_index + i2; \ + *ptr_indices++ = cur_index + i3; \ + num_indices += 3; /* closed polyline, don´t draw twice the point */ if (i || is_looping == 0) { @@ -3222,10 +3136,9 @@ SDL_RenderDrawLinesF(SDL_Renderer * renderer, } retval = QueueCmdGeometry(renderer, NULL, - xy, xy_stride, &renderer->color, 0 /* color_stride */, NULL, 0, - num_vertices, indices, num_indices, size_indices, - 1.0f, 1.0f); - + xy, xy_stride, &renderer->color, 0 /* color_stride */, NULL, 0, + num_vertices, indices, num_indices, size_indices, + 1.0f, 1.0f); } SDL_small_free(xy, isstack1); @@ -3240,25 +3153,23 @@ SDL_RenderDrawLinesF(SDL_Renderer * renderer, return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer); } -int -SDL_RenderDrawRect(SDL_Renderer * renderer, const SDL_Rect * rect) +int SDL_RenderDrawRect(SDL_Renderer *renderer, const SDL_Rect *rect) { SDL_FRect frect; SDL_FRect *prect = NULL; if (rect) { - frect.x = (float) rect->x; - frect.y = (float) rect->y; - frect.w = (float) rect->w; - frect.h = (float) rect->h; + frect.x = (float)rect->x; + frect.y = (float)rect->y; + frect.w = (float)rect->w; + frect.h = (float)rect->h; prect = &frect; } return SDL_RenderDrawRectF(renderer, prect); } -int -SDL_RenderDrawRectF(SDL_Renderer * renderer, const SDL_FRect * rect) +int SDL_RenderDrawRectF(SDL_Renderer *renderer, const SDL_FRect *rect) { SDL_FRect frect; SDL_FPoint points[5]; @@ -3273,20 +3184,19 @@ SDL_RenderDrawRectF(SDL_Renderer * renderer, const SDL_FRect * rect) points[0].x = rect->x; points[0].y = rect->y; - points[1].x = rect->x+rect->w-1; + points[1].x = rect->x + rect->w - 1; points[1].y = rect->y; - points[2].x = rect->x+rect->w-1; - points[2].y = rect->y+rect->h-1; + points[2].x = rect->x + rect->w - 1; + points[2].y = rect->y + rect->h - 1; points[3].x = rect->x; - points[3].y = rect->y+rect->h-1; + points[3].y = rect->y + rect->h - 1; points[4].x = rect->x; points[4].y = rect->y; return SDL_RenderDrawLinesF(renderer, points, 5); } -int -SDL_RenderDrawRects(SDL_Renderer * renderer, - const SDL_Rect * rects, int count) +int SDL_RenderDrawRects(SDL_Renderer *renderer, + const SDL_Rect *rects, int count) { int i; @@ -3314,9 +3224,8 @@ SDL_RenderDrawRects(SDL_Renderer * renderer, return 0; } -int -SDL_RenderDrawRectsF(SDL_Renderer * renderer, - const SDL_FRect * rects, int count) +int SDL_RenderDrawRectsF(SDL_Renderer *renderer, + const SDL_FRect *rects, int count) { int i; @@ -3344,8 +3253,7 @@ SDL_RenderDrawRectsF(SDL_Renderer * renderer, return 0; } -int -SDL_RenderFillRect(SDL_Renderer * renderer, const SDL_Rect * rect) +int SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_Rect *rect) { SDL_FRect frect; @@ -3353,18 +3261,17 @@ SDL_RenderFillRect(SDL_Renderer * renderer, const SDL_Rect * rect) /* If 'rect' == NULL, then outline the whole surface */ if (rect) { - frect.x = (float) rect->x; - frect.y = (float) rect->y; - frect.w = (float) rect->w; - frect.h = (float) rect->h; + frect.x = (float)rect->x; + frect.y = (float)rect->y; + frect.w = (float)rect->w; + frect.h = (float)rect->h; } else { RenderGetViewportSize(renderer, &frect); } return SDL_RenderFillRectsF(renderer, &frect, 1); } -int -SDL_RenderFillRectF(SDL_Renderer * renderer, const SDL_FRect * rect) +int SDL_RenderFillRectF(SDL_Renderer *renderer, const SDL_FRect *rect) { SDL_FRect frect; @@ -3378,9 +3285,8 @@ SDL_RenderFillRectF(SDL_Renderer * renderer, const SDL_FRect * rect) return SDL_RenderFillRectsF(renderer, rect, 1); } -int -SDL_RenderFillRects(SDL_Renderer * renderer, - const SDL_Rect * rects, int count) +int SDL_RenderFillRects(SDL_Renderer *renderer, + const SDL_Rect *rects, int count) { SDL_FRect *frects; int i; @@ -3421,9 +3327,8 @@ SDL_RenderFillRects(SDL_Renderer * renderer, return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer); } -int -SDL_RenderFillRectsF(SDL_Renderer * renderer, - const SDL_FRect * rects, int count) +int SDL_RenderFillRectsF(SDL_Renderer *renderer, + const SDL_FRect *rects, int count) { SDL_FRect *frects; int i; @@ -3464,32 +3369,29 @@ SDL_RenderFillRectsF(SDL_Renderer * renderer, return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer); } -int -SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect) +int SDL_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *srcrect, const SDL_Rect *dstrect) { SDL_FRect dstfrect; SDL_FRect *pdstfrect = NULL; if (dstrect) { - dstfrect.x = (float) dstrect->x; - dstfrect.y = (float) dstrect->y; - dstfrect.w = (float) dstrect->w; - dstfrect.h = (float) dstrect->h; + dstfrect.x = (float)dstrect->x; + dstfrect.y = (float)dstrect->y; + dstfrect.w = (float)dstrect->w; + dstfrect.h = (float)dstrect->h; pdstfrect = &dstfrect; } return SDL_RenderCopyF(renderer, texture, srcrect, pdstfrect); } -int -SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_FRect * dstrect) +int SDL_RenderCopyF(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *srcrect, const SDL_FRect *dstrect) { SDL_Rect real_srcrect; SDL_FRect real_dstrect; int retval; int use_rendergeometry; - CHECK_RENDERER_MAGIC(renderer, -1); CHECK_TEXTURE_MAGIC(texture, -1); @@ -3532,9 +3434,9 @@ SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture, if (use_rendergeometry) { float xy[8]; - const int xy_stride = 2 * sizeof (float); + const int xy_stride = 2 * sizeof(float); float uv[8]; - const int uv_stride = 2 * sizeof (float); + const int uv_stride = 2 * sizeof(float); const int num_vertices = 4; const int *indices = renderer->rect_index_order; const int num_indices = 6; @@ -3542,10 +3444,10 @@ SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture, float minu, minv, maxu, maxv; float minx, miny, maxx, maxy; - minu = (float) (real_srcrect.x) / (float) texture->w; - minv = (float) (real_srcrect.y) / (float) texture->h; - maxu = (float) (real_srcrect.x + real_srcrect.w) / (float) texture->w; - maxv = (float) (real_srcrect.y + real_srcrect.h) / (float) texture->h; + minu = (float)(real_srcrect.x) / (float)texture->w; + minv = (float)(real_srcrect.y) / (float)texture->h; + maxu = (float)(real_srcrect.x + real_srcrect.w) / (float)texture->w; + maxv = (float)(real_srcrect.y + real_srcrect.h) / (float)texture->h; minx = real_dstrect.x; miny = real_dstrect.y; @@ -3571,10 +3473,10 @@ SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture, xy[7] = maxy; retval = QueueCmdGeometry(renderer, texture, - xy, xy_stride, &texture->color, 0 /* color_stride */, uv, uv_stride, - num_vertices, - indices, num_indices, size_indices, - renderer->scale.x, renderer->scale.y); + xy, xy_stride, &texture->color, 0 /* color_stride */, uv, uv_stride, + num_vertices, + indices, num_indices, size_indices, + renderer->scale.x, renderer->scale.y); } else { real_dstrect.x *= renderer->scale.x; @@ -3587,10 +3489,9 @@ SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture, return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer); } -int -SDL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect, - const double angle, const SDL_Point *center, const SDL_RendererFlip flip) +int SDL_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *srcrect, const SDL_Rect *dstrect, + const double angle, const SDL_Point *center, const SDL_RendererFlip flip) { SDL_FRect dstfrect; SDL_FRect *pdstfrect = NULL; @@ -3598,26 +3499,25 @@ SDL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, SDL_FPoint *pfcenter = NULL; if (dstrect) { - dstfrect.x = (float) dstrect->x; - dstfrect.y = (float) dstrect->y; - dstfrect.w = (float) dstrect->w; - dstfrect.h = (float) dstrect->h; + dstfrect.x = (float)dstrect->x; + dstfrect.y = (float)dstrect->y; + dstfrect.w = (float)dstrect->w; + dstfrect.h = (float)dstrect->h; pdstfrect = &dstfrect; } if (center) { - fcenter.x = (float) center->x; - fcenter.y = (float) center->y; + fcenter.x = (float)center->x; + fcenter.y = (float)center->y; pfcenter = &fcenter; } return SDL_RenderCopyExF(renderer, texture, srcrect, pdstfrect, angle, pfcenter, flip); } -int -SDL_RenderCopyExF(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_FRect * dstrect, - const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip) +int SDL_RenderCopyExF(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *srcrect, const SDL_FRect *dstrect, + const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip) { SDL_Rect real_srcrect; SDL_FRect real_dstrect; @@ -3625,7 +3525,7 @@ SDL_RenderCopyExF(SDL_Renderer * renderer, SDL_Texture * texture, int retval; int use_rendergeometry; - if (flip == SDL_FLIP_NONE && (int)(angle/360) == angle/360) { /* fast path when we don't need rotation or flipping */ + if (flip == SDL_FLIP_NONE && (int)(angle / 360) == angle / 360) { /* fast path when we don't need rotation or flipping */ return SDL_RenderCopyF(renderer, texture, srcrect, dstrect); } @@ -3680,9 +3580,9 @@ SDL_RenderCopyExF(SDL_Renderer * renderer, SDL_Texture * texture, if (use_rendergeometry) { float xy[8]; - const int xy_stride = 2 * sizeof (float); + const int xy_stride = 2 * sizeof(float); float uv[8]; - const int uv_stride = 2 * sizeof (float); + const int uv_stride = 2 * sizeof(float); const int num_vertices = 4; const int *indices = renderer->rect_index_order; const int num_indices = 6; @@ -3698,10 +3598,10 @@ SDL_RenderCopyExF(SDL_Renderer * renderer, SDL_Texture * texture, const float s = SDL_sinf(radian_angle); const float c = SDL_cosf(radian_angle); - minu = (float) (real_srcrect.x) / (float) texture->w; - minv = (float) (real_srcrect.y) / (float) texture->h; - maxu = (float) (real_srcrect.x + real_srcrect.w) / (float) texture->w; - maxv = (float) (real_srcrect.y + real_srcrect.h) / (float) texture->h; + minu = (float)(real_srcrect.x) / (float)texture->w; + minv = (float)(real_srcrect.y) / (float)texture->h; + maxu = (float)(real_srcrect.x + real_srcrect.w) / (float)texture->w; + maxv = (float)(real_srcrect.y + real_srcrect.h) / (float)texture->h; centerx = real_center.x + real_dstrect.x; centery = real_center.y + real_dstrect.y; @@ -3756,10 +3656,10 @@ SDL_RenderCopyExF(SDL_Renderer * renderer, SDL_Texture * texture, xy[7] = (s_minx + c_maxy) + centery; retval = QueueCmdGeometry(renderer, texture, - xy, xy_stride, &texture->color, 0 /* color_stride */, uv, uv_stride, - num_vertices, - indices, num_indices, size_indices, - renderer->scale.x, renderer->scale.y); + xy, xy_stride, &texture->color, 0 /* color_stride */, uv, uv_stride, + num_vertices, + indices, num_indices, size_indices, + renderer->scale.x, renderer->scale.y); } else { retval = QueueCmdCopyEx(renderer, texture, &real_srcrect, &real_dstrect, angle, &real_center, flip, renderer->scale.x, renderer->scale.y); @@ -3767,19 +3667,18 @@ SDL_RenderCopyExF(SDL_Renderer * renderer, SDL_Texture * texture, return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer); } -int -SDL_RenderGeometry(SDL_Renderer *renderer, - SDL_Texture *texture, - const SDL_Vertex *vertices, int num_vertices, - const int *indices, int num_indices) +int SDL_RenderGeometry(SDL_Renderer *renderer, + SDL_Texture *texture, + const SDL_Vertex *vertices, int num_vertices, + const int *indices, int num_indices) { if (vertices) { const float *xy = &vertices->position.x; - int xy_stride = sizeof (SDL_Vertex); + int xy_stride = sizeof(SDL_Vertex); const SDL_Color *color = &vertices->color; - int color_stride = sizeof (SDL_Vertex); + int color_stride = sizeof(SDL_Vertex); const float *uv = &vertices->tex_coord.x; - int uv_stride = sizeof (SDL_Vertex); + int uv_stride = sizeof(SDL_Vertex); int size_indices = 4; return SDL_RenderGeometryRaw(renderer, texture, xy, xy_stride, color, color_stride, uv, uv_stride, num_vertices, indices, num_indices, size_indices); } else { @@ -3787,19 +3686,18 @@ SDL_RenderGeometry(SDL_Renderer *renderer, } } -static int -remap_one_indice( - int prev, - int k, - SDL_Texture *texture, - const float *xy, int xy_stride, - const SDL_Color *color, int color_stride, - const float *uv, int uv_stride) +static int remap_one_indice( + int prev, + int k, + SDL_Texture *texture, + const float *xy, int xy_stride, + const SDL_Color *color, int color_stride, + const float *uv, int uv_stride) { const float *xy0_, *xy1_, *uv0_, *uv1_; int col0_, col1_; - xy0_ = (const float *)((const char*)xy + prev * xy_stride); - xy1_ = (const float *)((const char*)xy + k * xy_stride); + xy0_ = (const float *)((const char *)xy + prev * xy_stride); + xy1_ = (const float *)((const char *)xy + k * xy_stride); if (xy0_[0] != xy1_[0]) { return k; } @@ -3807,8 +3705,8 @@ remap_one_indice( return k; } if (texture) { - uv0_ = (const float *)((const char*)uv + prev * uv_stride); - uv1_ = (const float *)((const char*)uv + k * uv_stride); + uv0_ = (const float *)((const char *)uv + prev * uv_stride); + uv1_ = (const float *)((const char *)uv + k * uv_stride); if (uv0_[0] != uv1_[0]) { return k; } @@ -3816,8 +3714,8 @@ remap_one_indice( return k; } } - col0_ = *(const int *)((const char*)color + prev * color_stride); - col1_ = *(const int *)((const char*)color + k * color_stride); + col0_ = *(const int *)((const char *)color + prev * color_stride); + col1_ = *(const int *)((const char *)color + k * color_stride); if (col0_ != col1_) { return k; @@ -3826,14 +3724,13 @@ remap_one_indice( return prev; } -static int -remap_indices( - int prev[3], - int k, - SDL_Texture *texture, - const float *xy, int xy_stride, - const SDL_Color *color, int color_stride, - const float *uv, int uv_stride) +static int remap_indices( + int prev[3], + int k, + SDL_Texture *texture, + const float *xy, int xy_stride, + const SDL_Color *color, int color_stride, + const float *uv, int uv_stride) { int i; if (prev[0] == -1) { @@ -3851,14 +3748,13 @@ remap_indices( #define DEBUG_SW_RENDER_GEOMETRY 0 /* For the software renderer, try to reinterpret triangles as SDL_Rect */ -static int SDLCALL -SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, - SDL_Texture *texture, - const float *xy, int xy_stride, - const SDL_Color *color, int color_stride, - const float *uv, int uv_stride, - int num_vertices, - const void *indices, int num_indices, int size_indices) +static int SDLCALL SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, + SDL_Texture *texture, + const float *xy, int xy_stride, + const SDL_Color *color, int color_stride, + const float *uv, int uv_stride, + int num_vertices, + const void *indices, int num_indices, int size_indices) { int i; int retval = 0; @@ -3876,7 +3772,9 @@ SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, SDL_QueryTexture(texture, NULL, NULL, &texw, &texh); } - prev[0] = -1; prev[1] = -1; prev[2] = -1; + prev[0] = -1; + prev[1] = -1; + prev[2] = -1; size_indices = indices ? size_indices : 0; for (i = 0; i < count; i += 3) { @@ -3936,12 +3834,15 @@ SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, const float *xy0_, *xy1_, *xy2_; float x0, x1, x2; float y0, y1, y2; - xy0_ = (const float *)((const char*)xy + k0 * xy_stride); - xy1_ = (const float *)((const char*)xy + k1 * xy_stride); - xy2_ = (const float *)((const char*)xy + k2 * xy_stride); - x0 = xy0_[0]; y0 = xy0_[1]; - x1 = xy1_[0]; y1 = xy1_[1]; - x2 = xy2_[0]; y2 = xy2_[1]; + xy0_ = (const float *)((const char *)xy + k0 * xy_stride); + xy1_ = (const float *)((const char *)xy + k1 * xy_stride); + xy2_ = (const float *)((const char *)xy + k2 * xy_stride); + x0 = xy0_[0]; + y0 = xy0_[1]; + x1 = xy1_[0]; + y1 = xy1_[1]; + x2 = xy2_[0]; + y2 = xy2_[1]; /* Find top-left */ if (x0 <= x1 && y0 <= y1) { @@ -3991,12 +3892,15 @@ SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, C2 = prev[2]; } - xy0_ = (const float *)((const char*)xy + A * xy_stride); - xy1_ = (const float *)((const char*)xy + B * xy_stride); - xy2_ = (const float *)((const char*)xy + C * xy_stride); - x0 = xy0_[0]; y0 = xy0_[1]; - x1 = xy1_[0]; y1 = xy1_[1]; - x2 = xy2_[0]; y2 = xy2_[1]; + xy0_ = (const float *)((const char *)xy + A * xy_stride); + xy1_ = (const float *)((const char *)xy + B * xy_stride); + xy2_ = (const float *)((const char *)xy + C * xy_stride); + x0 = xy0_[0]; + y0 = xy0_[1]; + x1 = xy1_[0]; + y1 = xy1_[1]; + x2 = xy2_[0]; + y2 = xy2_[1]; /* Check if triangle A B C is rectangle */ if ((x0 == x2 && y1 == y2) || (y0 == y2 && x1 == x2)) { @@ -4008,8 +3912,9 @@ SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, #endif } - xy2_ = (const float *)((const char*)xy + C2 * xy_stride); - x2 = xy2_[0]; y2 = xy2_[1]; + xy2_ = (const float *)((const char *)xy + C2 * xy_stride); + x2 = xy2_[0]; + y2 = xy2_[1]; /* Check if triangle A B C2 is rectangle */ if ((x0 == x2 && y1 == y2) || (y0 == y2 && x1 == x2)) { @@ -4024,10 +3929,10 @@ SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, /* Check if uniformly colored */ if (is_quad) { - const int col0_ = *(const int *)((const char*)color + A * color_stride); - const int col1_ = *(const int *)((const char*)color + B * color_stride); - const int col2_ = *(const int *)((const char*)color + C * color_stride); - const int col3_ = *(const int *)((const char*)color + C2 * color_stride); + const int col0_ = *(const int *)((const char *)color + A * color_stride); + const int col1_ = *(const int *)((const char *)color + B * color_stride); + const int col2_ = *(const int *)((const char *)color + C * color_stride); + const int col3_ = *(const int *)((const char *)color + C2 * color_stride); if (col0_ == col1_ && col0_ == col2_ && col0_ == col3_) { /* ok */ } else { @@ -4043,18 +3948,18 @@ SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, SDL_Rect s; SDL_FRect d; const float *xy0_, *xy1_, *uv0_, *uv1_; - SDL_Color col0_ = *(const SDL_Color *)((const char*)color + k0 * color_stride); + SDL_Color col0_ = *(const SDL_Color *)((const char *)color + k0 * color_stride); - xy0_ = (const float *)((const char*)xy + A * xy_stride); - xy1_ = (const float *)((const char*)xy + B * xy_stride); + xy0_ = (const float *)((const char *)xy + A * xy_stride); + xy1_ = (const float *)((const char *)xy + B * xy_stride); if (texture) { - uv0_ = (const float *)((const char*)uv + A * uv_stride); - uv1_ = (const float *)((const char*)uv + B * uv_stride); - s.x = (int) (uv0_[0] * texw); - s.y = (int) (uv0_[1] * texh); - s.w = (int) (uv1_[0] * texw - s.x); - s.h = (int) (uv1_[1] * texh - s.y); + uv0_ = (const float *)((const char *)uv + A * uv_stride); + uv1_ = (const float *)((const char *)uv + B * uv_stride); + s.x = (int)(uv0_[0] * texw); + s.y = (int)(uv0_[1] * texh); + s.w = (int)(uv1_[0] * texw - s.x); + s.h = (int)(uv1_[1] * texh - s.y); } d.x = xy0_[0]; @@ -4146,14 +4051,13 @@ end: return retval; } -int -SDL_RenderGeometryRaw(SDL_Renderer *renderer, - SDL_Texture *texture, - const float *xy, int xy_stride, - const SDL_Color *color, int color_stride, - const float *uv, int uv_stride, - int num_vertices, - const void *indices, int num_indices, int size_indices) +int SDL_RenderGeometryRaw(SDL_Renderer *renderer, + SDL_Texture *texture, + const float *xy, int xy_stride, + const SDL_Color *color, int color_stride, + const float *uv, int uv_stride, + int num_vertices, + const void *indices, int num_indices, int size_indices) { int i; int retval = 0; @@ -4214,7 +4118,7 @@ SDL_RenderGeometryRaw(SDL_Renderer *renderer, if (texture) { for (i = 0; i < num_vertices; ++i) { - const float *uv_ = (const float *)((const char*)uv + i * uv_stride); + const float *uv_ = (const float *)((const char *)uv + i * uv_stride); float u = uv_[0]; float v = uv_[1]; if (u < 0.0f || v < 0.0f || u > 1.0f || v > 1.0f) { @@ -4246,23 +4150,21 @@ SDL_RenderGeometryRaw(SDL_Renderer *renderer, /* For the software renderer, try to reinterpret triangles as SDL_Rect */ if (renderer->info.flags & SDL_RENDERER_SOFTWARE) { return SDL_SW_RenderGeometryRaw(renderer, texture, - xy, xy_stride, color, color_stride, uv, uv_stride, num_vertices, - indices, num_indices, size_indices); + xy, xy_stride, color, color_stride, uv, uv_stride, num_vertices, + indices, num_indices, size_indices); } retval = QueueCmdGeometry(renderer, texture, - xy, xy_stride, color, color_stride, uv, uv_stride, - num_vertices, - indices, num_indices, size_indices, - renderer->scale.x, renderer->scale.y); + xy, xy_stride, color, color_stride, uv, uv_stride, + num_vertices, + indices, num_indices, size_indices, + renderer->scale.x, renderer->scale.y); return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer); } - -int -SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, void * pixels, int pitch) +int SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, + Uint32 format, void *pixels, int pitch) { SDL_Rect real_rect; @@ -4272,7 +4174,7 @@ SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, return SDL_Unsupported(); } - FlushRenderCommands(renderer); /* we need to render before we read the results. */ + FlushRenderCommands(renderer); /* we need to render before we read the results. */ if (!format) { if (renderer->target == NULL) { @@ -4303,8 +4205,7 @@ SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, format, pixels, pitch); } -static void -SDL_RenderSimulateVSync(SDL_Renderer * renderer) +static void SDL_RenderSimulateVSync(SDL_Renderer *renderer) { Uint32 now, elapsed; const Uint32 interval = renderer->simulate_vsync_interval; @@ -4331,14 +4232,13 @@ SDL_RenderSimulateVSync(SDL_Renderer * renderer) } } -void -SDL_RenderPresent(SDL_Renderer * renderer) +void SDL_RenderPresent(SDL_Renderer *renderer) { SDL_bool presented = SDL_TRUE; CHECK_RENDERER_MAGIC(renderer, ); - FlushRenderCommands(renderer); /* time to send everything to the GPU! */ + FlushRenderCommands(renderer); /* time to send everything to the GPU! */ #if DONT_DRAW_WHILE_HIDDEN /* Don't present while we're hidden */ @@ -4346,18 +4246,17 @@ SDL_RenderPresent(SDL_Renderer * renderer) presented = SDL_FALSE; } else #endif - if (renderer->RenderPresent(renderer) < 0) { + if (renderer->RenderPresent(renderer) < 0) { presented = SDL_FALSE; } - if (renderer->simulate_vsync || + if (renderer->simulate_vsync || (!presented && renderer->wanted_vsync)) { SDL_RenderSimulateVSync(renderer); } } -void -SDL_DestroyTexture(SDL_Texture * texture) +void SDL_DestroyTexture(SDL_Texture *texture) { SDL_Renderer *renderer; @@ -4365,7 +4264,7 @@ SDL_DestroyTexture(SDL_Texture * texture) renderer = texture->renderer; if (texture == renderer->target) { - SDL_SetRenderTarget(renderer, NULL); /* implies command queue flush */ + SDL_SetRenderTarget(renderer, NULL); /* implies command queue flush */ } else { FlushRenderCommandsIfTextureNeeded(texture); } @@ -4399,8 +4298,7 @@ SDL_DestroyTexture(SDL_Texture * texture) SDL_free(texture); } -void -SDL_DestroyRenderer(SDL_Renderer * renderer) +void SDL_DestroyRenderer(SDL_Renderer *renderer) { SDL_RenderCommand *cmd; @@ -4429,9 +4327,10 @@ SDL_DestroyRenderer(SDL_Renderer * renderer) /* Free existing textures for this renderer */ while (renderer->textures) { - SDL_Texture *tex = renderer->textures; (void) tex; + SDL_Texture *tex = renderer->textures; + (void)tex; SDL_DestroyTexture(renderer->textures); - SDL_assert(tex != renderer->textures); /* satisfy static analysis. */ + SDL_assert(tex != renderer->textures); /* satisfy static analysis. */ } if (renderer->window) { @@ -4458,7 +4357,7 @@ int SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh) if (texture->native) { return SDL_GL_BindTexture(texture->native, texw, texh); } else if (renderer && renderer->GL_BindTexture) { - FlushRenderCommandsIfTextureNeeded(texture); /* in case the app is going to mess with it. */ + FlushRenderCommandsIfTextureNeeded(texture); /* in case the app is going to mess with it. */ return renderer->GL_BindTexture(renderer, texture, texw, texh); } else { return SDL_Unsupported(); @@ -4474,7 +4373,7 @@ int SDL_GL_UnbindTexture(SDL_Texture *texture) if (texture->native) { return SDL_GL_UnbindTexture(texture->native); } else if (renderer && renderer->GL_UnbindTexture) { - FlushRenderCommandsIfTextureNeeded(texture); /* in case the app messed with it. */ + FlushRenderCommandsIfTextureNeeded(texture); /* in case the app messed with it. */ return renderer->GL_UnbindTexture(renderer, texture); } @@ -4482,31 +4381,30 @@ int SDL_GL_UnbindTexture(SDL_Texture *texture) } void * -SDL_RenderGetMetalLayer(SDL_Renderer * renderer) +SDL_RenderGetMetalLayer(SDL_Renderer *renderer) { CHECK_RENDERER_MAGIC(renderer, NULL); if (renderer->GetMetalLayer) { - FlushRenderCommands(renderer); /* in case the app is going to mess with it. */ + FlushRenderCommands(renderer); /* in case the app is going to mess with it. */ return renderer->GetMetalLayer(renderer); } return NULL; } void * -SDL_RenderGetMetalCommandEncoder(SDL_Renderer * renderer) +SDL_RenderGetMetalCommandEncoder(SDL_Renderer *renderer) { CHECK_RENDERER_MAGIC(renderer, NULL); if (renderer->GetMetalCommandEncoder) { - FlushRenderCommands(renderer); /* in case the app is going to mess with it. */ + FlushRenderCommands(renderer); /* in case the app is going to mess with it. */ return renderer->GetMetalCommandEncoder(renderer); } return NULL; } -static SDL_BlendMode -SDL_GetShortBlendMode(SDL_BlendMode blendMode) +static SDL_BlendMode SDL_GetShortBlendMode(SDL_BlendMode blendMode) { if (blendMode == SDL_BLENDMODE_NONE_FULL) { return SDL_BLENDMODE_NONE; @@ -4526,8 +4424,7 @@ SDL_GetShortBlendMode(SDL_BlendMode blendMode) return blendMode; } -static SDL_BlendMode -SDL_GetLongBlendMode(SDL_BlendMode blendMode) +static SDL_BlendMode SDL_GetLongBlendMode(SDL_BlendMode blendMode) { if (blendMode == SDL_BLENDMODE_NONE) { return SDL_BLENDMODE_NONE_FULL; @@ -4600,8 +4497,7 @@ SDL_GetBlendModeAlphaOperation(SDL_BlendMode blendMode) return (SDL_BlendOperation)(((Uint32)blendMode >> 16) & 0xF); } -int -SDL_RenderSetVSync(SDL_Renderer * renderer, int vsync) +int SDL_RenderSetVSync(SDL_Renderer *renderer, int vsync) { CHECK_RENDERER_MAGIC(renderer, -1); diff --git a/src/render/SDL_sysrender.h b/src/render/SDL_sysrender.h index d87b2563e..e4f94a907 100644 --- a/src/render/SDL_sysrender.h +++ b/src/render/SDL_sysrender.h @@ -44,7 +44,6 @@ typedef struct SDL_DRect double h; } SDL_DRect; - /* The SDL 2D rendering system */ typedef struct SDL_RenderDriver SDL_RenderDriver; @@ -53,14 +52,14 @@ typedef struct SDL_RenderDriver SDL_RenderDriver; struct SDL_Texture { const void *magic; - Uint32 format; /**< The pixel format of the texture */ - int access; /**< SDL_TextureAccess */ - int w; /**< The width of the texture */ - int h; /**< The height of the texture */ - int modMode; /**< The texture modulation mode */ - SDL_BlendMode blendMode; /**< The texture blend mode */ - SDL_ScaleMode scaleMode; /**< The texture scale mode */ - SDL_Color color; /**< Texture modulation values */ + Uint32 format; /**< The pixel format of the texture */ + int access; /**< SDL_TextureAccess */ + int w; /**< The width of the texture */ + int h; /**< The height of the texture */ + int modMode; /**< The texture modulation mode */ + SDL_BlendMode blendMode; /**< The texture blend mode */ + SDL_ScaleMode scaleMode; /**< The texture scale mode */ + SDL_Color color; /**< Texture modulation values */ SDL_Renderer *renderer; @@ -70,11 +69,11 @@ struct SDL_Texture void *pixels; int pitch; SDL_Rect locked_rect; - SDL_Surface *locked_surface; /**< Locked region exposed as a SDL surface */ + SDL_Surface *locked_surface; /**< Locked region exposed as a SDL surface */ Uint32 last_command_generation; /* last command queue generation this texture was in. */ - void *driverdata; /**< Driver specific texture representation */ + void *driverdata; /**< Driver specific texture representation */ void *userdata; SDL_Texture *prev; @@ -99,23 +98,28 @@ typedef enum typedef struct SDL_RenderCommand { SDL_RenderCommandType command; - union { - struct { + union + { + struct + { size_t first; SDL_Rect rect; } viewport; - struct { + struct + { SDL_bool enabled; SDL_Rect rect; } cliprect; - struct { + struct + { size_t first; size_t count; Uint8 r, g, b, a; SDL_BlendMode blend; SDL_Texture *texture; } draw; - struct { + struct + { size_t first; Uint8 r, g, b, a; } color; @@ -123,14 +127,12 @@ typedef struct SDL_RenderCommand struct SDL_RenderCommand *next; } SDL_RenderCommand; - typedef struct SDL_VertexSolid { SDL_FPoint position; - SDL_Color color; + SDL_Color color; } SDL_VertexSolid; - typedef enum { SDL_RENDERLINEMETHOD_POINTS, @@ -138,68 +140,67 @@ typedef enum SDL_RENDERLINEMETHOD_GEOMETRY, } SDL_RenderLineMethod; - /* Define the SDL renderer structure */ struct SDL_Renderer { const void *magic; - void (*WindowEvent) (SDL_Renderer * renderer, const SDL_WindowEvent *event); - int (*GetOutputSize) (SDL_Renderer * renderer, int *w, int *h); - SDL_bool (*SupportsBlendMode)(SDL_Renderer * renderer, SDL_BlendMode blendMode); - int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture); - int (*QueueSetViewport) (SDL_Renderer * renderer, SDL_RenderCommand *cmd); - int (*QueueSetDrawColor) (SDL_Renderer * renderer, SDL_RenderCommand *cmd); - int (*QueueDrawPoints) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, - int count); - int (*QueueDrawLines) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, - int count); - int (*QueueFillRects) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, - int count); - int (*QueueCopy) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_FRect * dstrect); - int (*QueueCopyEx) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture, - const SDL_Rect * srcquad, const SDL_FRect * dstrect, - const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip, float scale_x, float scale_y); - int (*QueueGeometry) (SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, - const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, - int num_vertices, const void *indices, int num_indices, int size_indices, - float scale_x, float scale_y); + void (*WindowEvent)(SDL_Renderer *renderer, const SDL_WindowEvent *event); + int (*GetOutputSize)(SDL_Renderer *renderer, int *w, int *h); + SDL_bool (*SupportsBlendMode)(SDL_Renderer *renderer, SDL_BlendMode blendMode); + int (*CreateTexture)(SDL_Renderer *renderer, SDL_Texture *texture); + int (*QueueSetViewport)(SDL_Renderer *renderer, SDL_RenderCommand *cmd); + int (*QueueSetDrawColor)(SDL_Renderer *renderer, SDL_RenderCommand *cmd); + int (*QueueDrawPoints)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, + int count); + int (*QueueDrawLines)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, + int count); + int (*QueueFillRects)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FRect *rects, + int count); + int (*QueueCopy)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const SDL_Rect *srcrect, const SDL_FRect *dstrect); + int (*QueueCopyEx)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const SDL_Rect *srcquad, const SDL_FRect *dstrect, + const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip, float scale_x, float scale_y); + int (*QueueGeometry)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, + int num_vertices, const void *indices, int num_indices, int size_indices, + float scale_x, float scale_y); - int (*RunCommandQueue) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize); - int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, - int pitch); + int (*RunCommandQueue)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize); + int (*UpdateTexture)(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, const void *pixels, + int pitch); #if SDL_HAVE_YUV - int (*UpdateTextureYUV) (SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, + int (*UpdateTextureYUV)(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch); - int (*UpdateTextureNV) (SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *UVplane, int UVpitch); + int (*UpdateTextureNV)(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch); #endif - int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, void **pixels, int *pitch); - void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture); - void (*SetTextureScaleMode) (SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode); - int (*SetRenderTarget) (SDL_Renderer * renderer, SDL_Texture * texture); - int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, void * pixels, int pitch); - int (*RenderPresent) (SDL_Renderer * renderer); - void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture); + int (*LockTexture)(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, void **pixels, int *pitch); + void (*UnlockTexture)(SDL_Renderer *renderer, SDL_Texture *texture); + void (*SetTextureScaleMode)(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode); + int (*SetRenderTarget)(SDL_Renderer *renderer, SDL_Texture *texture); + int (*RenderReadPixels)(SDL_Renderer *renderer, const SDL_Rect *rect, + Uint32 format, void *pixels, int pitch); + int (*RenderPresent)(SDL_Renderer *renderer); + void (*DestroyTexture)(SDL_Renderer *renderer, SDL_Texture *texture); - void (*DestroyRenderer) (SDL_Renderer * renderer); + void (*DestroyRenderer)(SDL_Renderer *renderer); - int (*SetVSync) (SDL_Renderer * renderer, int vsync); + int (*SetVSync)(SDL_Renderer *renderer, int vsync); - int (*GL_BindTexture) (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh); - int (*GL_UnbindTexture) (SDL_Renderer * renderer, SDL_Texture *texture); + int (*GL_BindTexture)(SDL_Renderer *renderer, SDL_Texture *texture, float *texw, float *texh); + int (*GL_UnbindTexture)(SDL_Renderer *renderer, SDL_Texture *texture); - void *(*GetMetalLayer) (SDL_Renderer * renderer); - void *(*GetMetalCommandEncoder) (SDL_Renderer * renderer); + void *(*GetMetalLayer)(SDL_Renderer *renderer); + void *(*GetMetalCommandEncoder)(SDL_Renderer *renderer); /* The current renderer info */ SDL_RendererInfo info; @@ -260,8 +261,8 @@ struct SDL_Renderer SDL_Texture *target; SDL_mutex *target_mutex; - SDL_Color color; /**< Color for drawing operations values */ - SDL_BlendMode blendMode; /**< The drawing blend mode */ + SDL_Color color; /**< Color for drawing operations values */ + SDL_BlendMode blendMode; /**< The drawing blend mode */ SDL_bool always_batch; SDL_bool batching; @@ -287,7 +288,7 @@ struct SDL_Renderer /* Define the SDL render driver structure */ struct SDL_RenderDriver { - SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags); + SDL_Renderer *(*CreateRenderer)(SDL_Window *window, Uint32 flags); /* Info about the renderer capabilities */ SDL_RendererInfo info; @@ -320,8 +321,8 @@ extern SDL_BlendOperation SDL_GetBlendModeAlphaOperation(SDL_BlendMode blendMode the next call, because it might be in an array that gets realloc()'d. */ extern void *SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes, const size_t alignment, size_t *offset); -extern int SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode); -extern int SDL_PrivateUpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode); +extern int SDL_PrivateLowerBlitScaled(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, SDL_ScaleMode scaleMode); +extern int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, SDL_ScaleMode scaleMode); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c index 2db8c708d..30a0b6da6 100644 --- a/src/render/SDL_yuv_sw.c +++ b/src/render/SDL_yuv_sw.c @@ -24,11 +24,9 @@ #if SDL_HAVE_YUV - #include "SDL_yuv_sw_c.h" #include "SDL_cpuinfo.h" - SDL_SW_YUVTexture * SDL_SW_CreateYUVTexture(Uint32 format, int w, int h) { @@ -48,7 +46,7 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h) return NULL; } - swdata = (SDL_SW_YUVTexture *) SDL_calloc(1, sizeof(*swdata)); + swdata = (SDL_SW_YUVTexture *)SDL_calloc(1, sizeof(*swdata)); if (swdata == NULL) { SDL_OutOfMemory(); return NULL; @@ -59,33 +57,32 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h) swdata->w = w; swdata->h = h; { - const int sz_plane = w * h; - const int sz_plane_chroma = ((w + 1) / 2) * ((h + 1) / 2); - const int sz_plane_packed = ((w + 1) / 2) * h; - int dst_size = 0; - switch(format) - { - case SDL_PIXELFORMAT_YV12: /**< Planar mode: Y + V + U (3 planes) */ - case SDL_PIXELFORMAT_IYUV: /**< Planar mode: Y + U + V (3 planes) */ - dst_size = sz_plane + sz_plane_chroma + sz_plane_chroma; - break; + const int sz_plane = w * h; + const int sz_plane_chroma = ((w + 1) / 2) * ((h + 1) / 2); + const int sz_plane_packed = ((w + 1) / 2) * h; + int dst_size = 0; + switch (format) { + case SDL_PIXELFORMAT_YV12: /**< Planar mode: Y + V + U (3 planes) */ + case SDL_PIXELFORMAT_IYUV: /**< Planar mode: Y + U + V (3 planes) */ + dst_size = sz_plane + sz_plane_chroma + sz_plane_chroma; + break; - case SDL_PIXELFORMAT_YUY2: /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */ - case SDL_PIXELFORMAT_UYVY: /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */ - case SDL_PIXELFORMAT_YVYU: /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */ - dst_size = 4 * sz_plane_packed; - break; + case SDL_PIXELFORMAT_YUY2: /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */ + case SDL_PIXELFORMAT_UYVY: /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */ + case SDL_PIXELFORMAT_YVYU: /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */ + dst_size = 4 * sz_plane_packed; + break; - case SDL_PIXELFORMAT_NV12: /**< Planar mode: Y + U/V interleaved (2 planes) */ - case SDL_PIXELFORMAT_NV21: /**< Planar mode: Y + V/U interleaved (2 planes) */ - dst_size = sz_plane + sz_plane_chroma + sz_plane_chroma; - break; + case SDL_PIXELFORMAT_NV12: /**< Planar mode: Y + U/V interleaved (2 planes) */ + case SDL_PIXELFORMAT_NV21: /**< Planar mode: Y + V/U interleaved (2 planes) */ + dst_size = sz_plane + sz_plane_chroma + sz_plane_chroma; + break; - default: - SDL_assert(0 && "We should never get here (caught above)"); - break; + default: + SDL_assert(0 && "We should never get here (caught above)"); + break; } - swdata->pixels = (Uint8 *) SDL_SIMDAlloc(dst_size); + swdata->pixels = (Uint8 *)SDL_SIMDAlloc(dst_size); if (!swdata->pixels) { SDL_SW_DestroyYUVTexture(swdata); SDL_OutOfMemory(); @@ -128,33 +125,31 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h) return swdata; } -int -SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture * swdata, void **pixels, - int *pitch) +int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture *swdata, void **pixels, + int *pitch) { *pixels = swdata->planes[0]; *pitch = swdata->pitches[0]; return 0; } -int -SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, - const void *pixels, int pitch) +int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, + const void *pixels, int pitch) { switch (swdata->format) { case SDL_PIXELFORMAT_YV12: case SDL_PIXELFORMAT_IYUV: if (rect->x == 0 && rect->y == 0 && rect->w == swdata->w && rect->h == swdata->h) { - SDL_memcpy(swdata->pixels, pixels, - (swdata->h * swdata->w) + 2* ((swdata->h + 1) /2) * ((swdata->w + 1) / 2)); + SDL_memcpy(swdata->pixels, pixels, + (swdata->h * swdata->w) + 2 * ((swdata->h + 1) / 2) * ((swdata->w + 1) / 2)); } else { Uint8 *src, *dst; int row; size_t length; /* Copy the Y plane */ - src = (Uint8 *) pixels; + src = (Uint8 *)pixels; dst = swdata->pixels + rect->y * swdata->w + rect->x; length = rect->w; for (row = 0; row < rect->h; ++row) { @@ -162,94 +157,92 @@ SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, src += pitch; dst += swdata->w; } - + /* Copy the next plane */ - src = (Uint8 *) pixels + rect->h * pitch; + src = (Uint8 *)pixels + rect->h * pitch; dst = swdata->pixels + swdata->h * swdata->w; - dst += rect->y/2 * ((swdata->w + 1) / 2) + rect->x/2; + dst += rect->y / 2 * ((swdata->w + 1) / 2) + rect->x / 2; length = (rect->w + 1) / 2; - for (row = 0; row < (rect->h + 1)/2; ++row) { + for (row = 0; row < (rect->h + 1) / 2; ++row) { SDL_memcpy(dst, src, length); - src += (pitch + 1)/2; - dst += (swdata->w + 1)/2; + src += (pitch + 1) / 2; + dst += (swdata->w + 1) / 2; } /* Copy the next plane */ - src = (Uint8 *) pixels + rect->h * pitch + ((rect->h + 1) / 2) * ((pitch + 1) / 2); + src = (Uint8 *)pixels + rect->h * pitch + ((rect->h + 1) / 2) * ((pitch + 1) / 2); dst = swdata->pixels + swdata->h * swdata->w + - ((swdata->h + 1)/2) * ((swdata->w+1) / 2); - dst += rect->y/2 * ((swdata->w + 1)/2) + rect->x/2; + ((swdata->h + 1) / 2) * ((swdata->w + 1) / 2); + dst += rect->y / 2 * ((swdata->w + 1) / 2) + rect->x / 2; length = (rect->w + 1) / 2; - for (row = 0; row < (rect->h + 1)/2; ++row) { + for (row = 0; row < (rect->h + 1) / 2; ++row) { SDL_memcpy(dst, src, length); - src += (pitch + 1)/2; - dst += (swdata->w + 1)/2; + src += (pitch + 1) / 2; + dst += (swdata->w + 1) / 2; } } break; case SDL_PIXELFORMAT_YUY2: case SDL_PIXELFORMAT_UYVY: case SDL_PIXELFORMAT_YVYU: - { + { + Uint8 *src, *dst; + int row; + size_t length; + + src = (Uint8 *)pixels; + dst = + swdata->planes[0] + rect->y * swdata->pitches[0] + + rect->x * 2; + length = 4 * ((rect->w + 1) / 2); + for (row = 0; row < rect->h; ++row) { + SDL_memcpy(dst, src, length); + src += pitch; + dst += swdata->pitches[0]; + } + } break; + case SDL_PIXELFORMAT_NV12: + case SDL_PIXELFORMAT_NV21: + { + if (rect->x == 0 && rect->y == 0 && rect->w == swdata->w && rect->h == swdata->h) { + SDL_memcpy(swdata->pixels, pixels, + (swdata->h * swdata->w) + 2 * ((swdata->h + 1) / 2) * ((swdata->w + 1) / 2)); + } else { + Uint8 *src, *dst; int row; size_t length; - src = (Uint8 *) pixels; - dst = - swdata->planes[0] + rect->y * swdata->pitches[0] + - rect->x * 2; - length = 4 * ((rect->w + 1) / 2); + /* Copy the Y plane */ + src = (Uint8 *)pixels; + dst = swdata->pixels + rect->y * swdata->w + rect->x; + length = rect->w; for (row = 0; row < rect->h; ++row) { SDL_memcpy(dst, src, length); src += pitch; - dst += swdata->pitches[0]; - } - } - break; - case SDL_PIXELFORMAT_NV12: - case SDL_PIXELFORMAT_NV21: - { - if (rect->x == 0 && rect->y == 0 && rect->w == swdata->w && rect->h == swdata->h) { - SDL_memcpy(swdata->pixels, pixels, - (swdata->h * swdata->w) + 2* ((swdata->h + 1) /2) * ((swdata->w + 1) / 2)); - } else { - - Uint8 *src, *dst; - int row; - size_t length; - - /* Copy the Y plane */ - src = (Uint8 *) pixels; - dst = swdata->pixels + rect->y * swdata->w + rect->x; - length = rect->w; - for (row = 0; row < rect->h; ++row) { - SDL_memcpy(dst, src, length); - src += pitch; - dst += swdata->w; - } - - /* Copy the next plane */ - src = (Uint8 *) pixels + rect->h * pitch; - dst = swdata->pixels + swdata->h * swdata->w; - dst += 2 * ((rect->y + 1)/2) * ((swdata->w + 1) / 2) + 2 * (rect->x/2); - length = 2 * ((rect->w + 1) / 2); - for (row = 0; row < (rect->h + 1)/2; ++row) { - SDL_memcpy(dst, src, length); - src += 2 * ((pitch + 1)/2); - dst += 2 * ((swdata->w + 1)/2); - } + dst += swdata->w; + } + + /* Copy the next plane */ + src = (Uint8 *)pixels + rect->h * pitch; + dst = swdata->pixels + swdata->h * swdata->w; + dst += 2 * ((rect->y + 1) / 2) * ((swdata->w + 1) / 2) + 2 * (rect->x / 2); + length = 2 * ((rect->w + 1) / 2); + for (row = 0; row < (rect->h + 1) / 2; ++row) { + SDL_memcpy(dst, src, length); + src += 2 * ((pitch + 1) / 2); + dst += 2 * ((swdata->w + 1) / 2); } } } + } return 0; } -int -SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *Uplane, int Upitch, - const Uint8 *Vplane, int Vpitch) +int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) { const Uint8 *src; Uint8 *dst; @@ -274,12 +267,12 @@ SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, dst = swdata->pixels + swdata->h * swdata->w + ((swdata->h + 1) / 2) * ((swdata->w + 1) / 2); } - dst += rect->y/2 * ((swdata->w + 1)/2) + rect->x/2; + dst += rect->y / 2 * ((swdata->w + 1) / 2) + rect->x / 2; length = (rect->w + 1) / 2; - for (row = 0; row < (rect->h + 1)/2; ++row) { + for (row = 0; row < (rect->h + 1) / 2; ++row) { SDL_memcpy(dst, src, length); src += Upitch; - dst += (swdata->w + 1)/2; + dst += (swdata->w + 1) / 2; } /* Copy the V plane */ @@ -290,19 +283,19 @@ SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, dst = swdata->pixels + swdata->h * swdata->w + ((swdata->h + 1) / 2) * ((swdata->w + 1) / 2); } - dst += rect->y/2 * ((swdata->w + 1)/2) + rect->x/2; + dst += rect->y / 2 * ((swdata->w + 1) / 2) + rect->x / 2; length = (rect->w + 1) / 2; - for (row = 0; row < (rect->h + 1)/2; ++row) { + for (row = 0; row < (rect->h + 1) / 2; ++row) { SDL_memcpy(dst, src, length); src += Vpitch; - dst += (swdata->w + 1)/2; + dst += (swdata->w + 1) / 2; } return 0; } -int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *UVplane, int UVpitch) +int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch) { const Uint8 *src; Uint8 *dst; @@ -322,30 +315,27 @@ int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * re /* Copy the UV or VU plane */ src = UVplane; dst = swdata->pixels + swdata->h * swdata->w; - dst += rect->y * ((swdata->w + 1)/2) + rect->x; + dst += rect->y * ((swdata->w + 1) / 2) + rect->x; length = (rect->w + 1) / 2; length *= 2; - for (row = 0; row < (rect->h + 1)/2; ++row) { + for (row = 0; row < (rect->h + 1) / 2; ++row) { SDL_memcpy(dst, src, length); src += UVpitch; - dst += 2 * ((swdata->w + 1)/2); + dst += 2 * ((swdata->w + 1) / 2); } return 0; } -int -SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, - void **pixels, int *pitch) +int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, + void **pixels, int *pitch) { switch (swdata->format) { case SDL_PIXELFORMAT_YV12: case SDL_PIXELFORMAT_IYUV: case SDL_PIXELFORMAT_NV12: case SDL_PIXELFORMAT_NV21: - if (rect - && (rect->x != 0 || rect->y != 0 || rect->w != swdata->w - || rect->h != swdata->h)) { + if (rect && (rect->x != 0 || rect->y != 0 || rect->w != swdata->w || rect->h != swdata->h)) { return SDL_SetError("YV12, IYUV, NV12, NV21 textures only support full surface locks"); } break; @@ -360,15 +350,13 @@ SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, return 0; } -void -SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata) +void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture *swdata) { } -int -SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect, - Uint32 target_format, int w, int h, void *pixels, - int pitch) +int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect, + Uint32 target_format, int w, int h, void *pixels, + int pitch) { int stretch; @@ -424,7 +412,7 @@ SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect, pitch = swdata->stretch->pitch; } if (SDL_ConvertPixels(swdata->w, swdata->h, swdata->format, - swdata->planes[0], swdata->pitches[0], + swdata->planes[0], swdata->pitches[0], target_format, pixels, pitch) < 0) { return -1; } @@ -435,8 +423,7 @@ SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect, return 0; } -void -SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata) +void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata) { if (swdata) { SDL_SIMDFree(swdata->pixels); diff --git a/src/render/SDL_yuv_sw_c.h b/src/render/SDL_yuv_sw_c.h index 8d9dc79cd..c073e1a79 100644 --- a/src/render/SDL_yuv_sw_c.h +++ b/src/render/SDL_yuv_sw_c.h @@ -47,24 +47,24 @@ struct SDL_SW_YUVTexture typedef struct SDL_SW_YUVTexture SDL_SW_YUVTexture; SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(Uint32 format, int w, int h); -int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture * swdata, void **pixels, +int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture *swdata, void **pixels, int *pitch); -int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, +int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, const void *pixels, int pitch); -int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, +int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch); -int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *UVplane, int UVpitch); -int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, +int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch); +int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, void **pixels, int *pitch); -void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata); -int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect, +void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture *swdata); +int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect, Uint32 target_format, int w, int h, void *pixels, int pitch); -void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata); +void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata); #endif /* SDL_yuv_sw_c_h_ */ diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 1bb62c317..4518428ed 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -54,12 +54,11 @@ typedef struct LPDIRECT3DPIXELSHADER9 shader; } D3D_DrawStateCache; - /* Direct3D renderer implementation */ typedef struct { - void* d3dDLL; + void *d3dDLL; IDirect3D9 *d3d; IDirect3DDevice9 *device; UINT adapter; @@ -70,7 +69,7 @@ typedef struct D3DTEXTUREFILTERTYPE scaleMode[8]; IDirect3DSurface9 *defaultRenderTarget; IDirect3DSurface9 *currentRenderTarget; - void* d3dxDLL; + void *d3dxDLL; #if SDL_HAVE_YUV LPDIRECT3DPIXELSHADER9 shaders[NUM_SHADERS]; #endif @@ -115,8 +114,7 @@ typedef struct float u, v; } Vertex; -static int -D3D_SetError(const char *prefix, HRESULT result) +static int D3D_SetError(const char *prefix, HRESULT result) { const char *error; @@ -194,8 +192,7 @@ D3D_SetError(const char *prefix, HRESULT result) return SDL_SetError("%s: %s", prefix, error); } -static D3DFORMAT -PixelFormatToD3DFMT(Uint32 format) +static D3DFORMAT PixelFormatToD3DFMT(Uint32 format) { switch (format) { case SDL_PIXELFORMAT_RGB565: @@ -214,8 +211,7 @@ PixelFormatToD3DFMT(Uint32 format) } } -static Uint32 -D3DFMTToPixelFormat(D3DFORMAT format) +static Uint32 D3DFMTToPixelFormat(D3DFORMAT format) { switch (format) { case D3DFMT_R5G6B5: @@ -229,8 +225,7 @@ D3DFMTToPixelFormat(D3DFORMAT format) } } -static void -D3D_InitRenderState(D3D_RenderData *data) +static void D3D_InitRenderState(D3D_RenderData *data) { D3DMATRIX matrix; @@ -288,12 +283,11 @@ D3D_InitRenderState(D3D_RenderData *data) data->beginScene = SDL_TRUE; } -static int D3D_Reset(SDL_Renderer * renderer); +static int D3D_Reset(SDL_Renderer *renderer); -static int -D3D_ActivateRenderer(SDL_Renderer * renderer) +static int D3D_ActivateRenderer(SDL_Renderer *renderer) { - D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; HRESULT result; if (data->updateSize) { @@ -337,25 +331,22 @@ D3D_ActivateRenderer(SDL_Renderer * renderer) return 0; } -static void -D3D_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +static void D3D_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event) { - D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { data->updateSize = SDL_TRUE; } } -static int -D3D_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) +static int D3D_GetOutputSize(SDL_Renderer *renderer, int *w, int *h) { SDL_GetWindowSizeInPixels(renderer->window, w, h); return 0; } -static D3DBLEND -GetBlendFunc(SDL_BlendFactor factor) +static D3DBLEND GetBlendFunc(SDL_BlendFactor factor) { switch (factor) { case SDL_BLENDFACTOR_ZERO: @@ -378,13 +369,13 @@ GetBlendFunc(SDL_BlendFactor factor) return D3DBLEND_DESTALPHA; case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA: return D3DBLEND_INVDESTALPHA; - default: break; + default: + break; } - return (D3DBLEND) 0; + return (D3DBLEND)0; } -static D3DBLENDOP -GetBlendEquation(SDL_BlendOperation operation) +static D3DBLENDOP GetBlendEquation(SDL_BlendOperation operation) { switch (operation) { case SDL_BLENDOPERATION_ADD: @@ -397,15 +388,15 @@ GetBlendEquation(SDL_BlendOperation operation) return D3DBLENDOP_MIN; case SDL_BLENDOPERATION_MAXIMUM: return D3DBLENDOP_MAX; - default: break; + default: + break; } - return (D3DBLENDOP) 0; + return (D3DBLENDOP)0; } -static SDL_bool -D3D_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +static SDL_bool D3D_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { - D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode); @@ -428,8 +419,7 @@ D3D_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) return SDL_TRUE; } -static int -D3D_CreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD usage, Uint32 format, D3DFORMAT d3dfmt, int w, int h) +static int D3D_CreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD usage, Uint32 format, D3DFORMAT d3dfmt, int w, int h) { HRESULT result; @@ -441,23 +431,21 @@ D3D_CreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD us texture->d3dfmt = d3dfmt; result = IDirect3DDevice9_CreateTexture(device, w, h, 1, usage, - PixelFormatToD3DFMT(format), - D3DPOOL_DEFAULT, &texture->texture, NULL); + PixelFormatToD3DFMT(format), + D3DPOOL_DEFAULT, &texture->texture, NULL); if (FAILED(result)) { return D3D_SetError("CreateTexture(D3DPOOL_DEFAULT)", result); } return 0; } - -static int -D3D_CreateStagingTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture) +static int D3D_CreateStagingTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture) { HRESULT result; if (texture->staging == NULL) { result = IDirect3DDevice9_CreateTexture(device, texture->w, texture->h, 1, 0, - texture->d3dfmt, D3DPOOL_SYSTEMMEM, &texture->staging, NULL); + texture->d3dfmt, D3DPOOL_SYSTEMMEM, &texture->staging, NULL); if (FAILED(result)) { return D3D_SetError("CreateTexture(D3DPOOL_SYSTEMMEM)", result); } @@ -465,8 +453,7 @@ D3D_CreateStagingTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture) return 0; } -static int -D3D_RecreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture) +static int D3D_RecreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture) { if (texture->texture) { IDirect3DTexture9_Release(texture->texture); @@ -479,8 +466,7 @@ D3D_RecreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture) return 0; } -static int -D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, int x, int y, int w, int h, const void *pixels, int pitch) +static int D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, int x, int y, int w, int h, const void *pixels, int pitch) { RECT d3drect; D3DLOCKED_RECT locked; @@ -497,7 +483,7 @@ D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, int x, i d3drect.right = x + w; d3drect.top = y; d3drect.bottom = y + h; - + result = IDirect3DTexture9_LockRect(texture->staging, 0, &locked, &d3drect, 0); if (FAILED(result)) { return D3D_SetError("LockRect()", result); @@ -507,7 +493,7 @@ D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, int x, i dst = (Uint8 *)locked.pBits; length = w * SDL_BYTESPERPIXEL(texture->format); if (length == pitch && length == locked.Pitch) { - SDL_memcpy(dst, src, length*h); + SDL_memcpy(dst, src, length * h); } else { if (length > pitch) { length = pitch; @@ -530,8 +516,7 @@ D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, int x, i return 0; } -static void -D3D_DestroyTextureRep(D3D_TextureRep *texture) +static void D3D_DestroyTextureRep(D3D_TextureRep *texture) { if (texture->texture) { IDirect3DTexture9_Release(texture->texture); @@ -543,14 +528,13 @@ D3D_DestroyTextureRep(D3D_TextureRep *texture) } } -static int -D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static int D3D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; D3D_TextureData *texturedata; DWORD usage; - texturedata = (D3D_TextureData *) SDL_calloc(1, sizeof(*texturedata)); + texturedata = (D3D_TextureData *)SDL_calloc(1, sizeof(*texturedata)); if (texturedata == NULL) { return SDL_OutOfMemory(); } @@ -584,8 +568,7 @@ D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) return 0; } -static int -D3D_RecreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static int D3D_RecreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) { D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; @@ -611,12 +594,11 @@ D3D_RecreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) return 0; } -static int -D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, int pitch) +static int D3D_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, const void *pixels, int pitch) { D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; - D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata; + D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; if (texturedata == NULL) { return SDL_SetError("Texture is not currently available"); @@ -628,14 +610,14 @@ D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, #if SDL_HAVE_YUV if (texturedata->yuv) { /* Skip to the correct offset into the next texture */ - pixels = (const void*)((const Uint8*)pixels + rect->h * pitch); + pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch); if (D3D_UpdateTextureRep(data->device, texture->format == SDL_PIXELFORMAT_YV12 ? &texturedata->vtexture : &texturedata->utexture, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, pixels, (pitch + 1) / 2) < 0) { return -1; } /* Skip to the correct offset into the next texture */ - pixels = (const void*)((const Uint8*)pixels + ((rect->h + 1) / 2) * ((pitch + 1) / 2)); + pixels = (const void *)((const Uint8 *)pixels + ((rect->h + 1) / 2) * ((pitch + 1) / 2)); if (D3D_UpdateTextureRep(data->device, texture->format == SDL_PIXELFORMAT_YV12 ? &texturedata->utexture : &texturedata->vtexture, rect->x / 2, (rect->y + 1) / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, pixels, (pitch + 1) / 2) < 0) { return -1; } @@ -645,15 +627,14 @@ D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, } #if SDL_HAVE_YUV -static int -D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *Uplane, int Upitch, - const Uint8 *Vplane, int Vpitch) +static int D3D_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) { D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; - D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata; + D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; if (texturedata == NULL) { return SDL_SetError("Texture is not currently available"); @@ -672,9 +653,8 @@ D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, } #endif -static int -D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, void **pixels, int *pitch) +static int D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, void **pixels, int *pitch) { D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; @@ -696,8 +676,8 @@ D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, } } *pixels = - (void *) ((Uint8 *) texturedata->pixels + rect->y * texturedata->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); + (void *)((Uint8 *)texturedata->pixels + rect->y * texturedata->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); *pitch = texturedata->pitch; } else #endif @@ -725,8 +705,7 @@ D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, return 0; } -static void -D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static void D3D_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) { D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; @@ -738,8 +717,8 @@ D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) if (texturedata->yuv) { const SDL_Rect *rect = &texturedata->locked_rect; void *pixels = - (void *) ((Uint8 *) texturedata->pixels + rect->y * texturedata->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); + (void *)((Uint8 *)texturedata->pixels + rect->y * texturedata->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); D3D_UpdateTexture(renderer, texture, rect, pixels, texturedata->pitch); } else #endif @@ -755,8 +734,7 @@ D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) } } -static void -D3D_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode) +static void D3D_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode) { D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; @@ -767,10 +745,9 @@ D3D_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Scal texturedata->scaleMode = (scaleMode == SDL_ScaleModeNearest) ? D3DTEXF_POINT : D3DTEXF_LINEAR; } -static int -D3D_SetRenderTargetInternal(SDL_Renderer * renderer, SDL_Texture * texture) +static int D3D_SetRenderTargetInternal(SDL_Renderer *renderer, SDL_Texture *texture) { - D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; D3D_TextureData *texturedata; D3D_TextureRep *texturerep; HRESULT result; @@ -797,7 +774,7 @@ D3D_SetRenderTargetInternal(SDL_Renderer * renderer, SDL_Texture * texture) if (texturerep->dirty && texturerep->staging) { if (!texturerep->texture) { result = IDirect3DDevice9_CreateTexture(device, texturerep->w, texturerep->h, 1, texturerep->usage, - PixelFormatToD3DFMT(texturerep->format), D3DPOOL_DEFAULT, &texturerep->texture, NULL); + PixelFormatToD3DFMT(texturerep->format), D3DPOOL_DEFAULT, &texturerep->texture, NULL); if (FAILED(result)) { return D3D_SetError("CreateTexture(D3DPOOL_DEFAULT)", result); } @@ -822,8 +799,7 @@ D3D_SetRenderTargetInternal(SDL_Renderer * renderer, SDL_Texture * texture) return 0; } -static int -D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +static int D3D_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) { if (D3D_ActivateRenderer(renderer) < 0) { return -1; @@ -832,19 +808,16 @@ D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) return D3D_SetRenderTargetInternal(renderer, texture); } - -static int -D3D_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd) +static int D3D_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { - return 0; /* nothing to do in this backend. */ + return 0; /* nothing to do in this backend. */ } -static int -D3D_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) +static int D3D_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { const DWORD color = D3DCOLOR_ARGB(cmd->data.draw.a, cmd->data.draw.r, cmd->data.draw.g, cmd->data.draw.b); - const size_t vertslen = count * sizeof (Vertex); - Vertex *verts = (Vertex *) SDL_AllocateRenderVertices(renderer, vertslen, 0, &cmd->data.draw.first); + const size_t vertslen = count * sizeof(Vertex); + Vertex *verts = (Vertex *)SDL_AllocateRenderVertices(renderer, vertslen, 0, &cmd->data.draw.first); int i; if (verts == NULL) { @@ -863,15 +836,14 @@ D3D_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F return 0; } -static int -D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, - const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, - int num_vertices, const void *indices, int num_indices, int size_indices, - float scale_x, float scale_y) +static int D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, + int num_vertices, const void *indices, int num_indices, int size_indices, + float scale_x, float scale_y) { int i; int count = indices ? num_indices : num_vertices; - Vertex *verts = (Vertex *) SDL_AllocateRenderVertices(renderer, count * sizeof (Vertex), 0, &cmd->data.draw.first); + Vertex *verts = (Vertex *)SDL_AllocateRenderVertices(renderer, count * sizeof(Vertex), 0, &cmd->data.draw.first); if (verts == NULL) { return -1; @@ -894,8 +866,8 @@ D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t j = i; } - xy_ = (float *)((char*)xy + j * xy_stride); - col_ = *(SDL_Color *)((char*)color + j * color_stride); + xy_ = (float *)((char *)xy + j * xy_stride); + col_ = *(SDL_Color *)((char *)color + j * color_stride); verts->x = xy_[0] * scale_x - 0.5f; verts->y = xy_[1] * scale_y - 0.5f; @@ -903,7 +875,7 @@ D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t verts->color = D3DCOLOR_ARGB(col_.a, col_.r, col_.g, col_.b); if (texture) { - float *uv_ = (float *)((char*)uv + j * uv_stride); + float *uv_ = (float *)((char *)uv + j * uv_stride); verts->u = uv_[0]; verts->v = uv_[1]; } else { @@ -916,14 +888,13 @@ D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t return 0; } -static int -UpdateDirtyTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture) +static int UpdateDirtyTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture) { if (texture->dirty && texture->staging) { HRESULT result; if (!texture->texture) { result = IDirect3DDevice9_CreateTexture(device, texture->w, texture->h, 1, texture->usage, - PixelFormatToD3DFMT(texture->format), D3DPOOL_DEFAULT, &texture->texture, NULL); + PixelFormatToD3DFMT(texture->format), D3DPOOL_DEFAULT, &texture->texture, NULL); if (FAILED(result)) { return D3D_SetError("CreateTexture(D3DPOOL_DEFAULT)", result); } @@ -938,8 +909,7 @@ UpdateDirtyTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture) return 0; } -static int -BindTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD sampler) +static int BindTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD sampler) { HRESULT result; UpdateDirtyTexture(device, texture); @@ -950,8 +920,7 @@ BindTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD sampler) return 0; } -static void -UpdateTextureScaleMode(D3D_RenderData *data, D3D_TextureData *texturedata, unsigned index) +static void UpdateTextureScaleMode(D3D_RenderData *data, D3D_TextureData *texturedata, unsigned index) { if (texturedata->scaleMode != data->scaleMode[index]) { IDirect3DDevice9_SetSamplerState(data->device, index, D3DSAMP_MINFILTER, @@ -966,8 +935,7 @@ UpdateTextureScaleMode(D3D_RenderData *data, D3D_TextureData *texturedata, unsig } } -static int -SetupTextureState(D3D_RenderData *data, SDL_Texture * texture, LPDIRECT3DPIXELSHADER9 *shader) +static int SetupTextureState(D3D_RenderData *data, SDL_Texture *texture, LPDIRECT3DPIXELSHADER9 *shader) { D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; @@ -1012,16 +980,15 @@ SetupTextureState(D3D_RenderData *data, SDL_Texture * texture, LPDIRECT3DPIXELSH return 0; } -static int -SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd) +static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd) { SDL_Texture *texture = cmd->data.draw.texture; const SDL_BlendMode blend = cmd->data.draw.blend; if (texture != data->drawstate.texture) { #if SDL_HAVE_YUV - D3D_TextureData *oldtexturedata = data->drawstate.texture ? (D3D_TextureData *) data->drawstate.texture->driverdata : NULL; - D3D_TextureData *newtexturedata = texture ? (D3D_TextureData *) texture->driverdata : NULL; + D3D_TextureData *oldtexturedata = data->drawstate.texture ? (D3D_TextureData *)data->drawstate.texture->driverdata : NULL; + D3D_TextureData *newtexturedata = texture ? (D3D_TextureData *)texture->driverdata : NULL; #endif LPDIRECT3DPIXELSHADER9 shader = NULL; @@ -1049,7 +1016,7 @@ SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd) data->drawstate.texture = texture; } else if (texture) { - D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata; + D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; UpdateDirtyTexture(data->device, &texturedata->texture); #if SDL_HAVE_YUV if (texturedata->yuv) { @@ -1130,10 +1097,9 @@ SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd) return 0; } -static int -D3D_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) +static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) { - D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; const int vboidx = data->currentVertexBuffer; IDirect3DVertexBuffer9 *vbo = NULL; const SDL_bool istarget = renderer->target != NULL; @@ -1152,7 +1118,7 @@ D3D_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti IDirect3DVertexBuffer9_Release(vbo); } - if (FAILED(IDirect3DDevice9_CreateVertexBuffer(data->device, (UINT) vertsize, usage, fvf, D3DPOOL_DEFAULT, &vbo, NULL))) { + if (FAILED(IDirect3DDevice9_CreateVertexBuffer(data->device, (UINT)vertsize, usage, fvf, D3DPOOL_DEFAULT, &vbo, NULL))) { vbo = NULL; } data->vertexBuffers[vboidx] = vbo; @@ -1161,12 +1127,12 @@ D3D_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti if (vbo) { void *ptr; - if (FAILED(IDirect3DVertexBuffer9_Lock(vbo, 0, (UINT) vertsize, &ptr, D3DLOCK_DISCARD))) { - vbo = NULL; /* oh well, we'll do immediate mode drawing. :( */ + if (FAILED(IDirect3DVertexBuffer9_Lock(vbo, 0, (UINT)vertsize, &ptr, D3DLOCK_DISCARD))) { + vbo = NULL; /* oh well, we'll do immediate mode drawing. :( */ } else { SDL_memcpy(ptr, vertices, vertsize); if (FAILED(IDirect3DVertexBuffer9_Unlock(vbo))) { - vbo = NULL; /* oh well, we'll do immediate mode drawing. :( */ + vbo = NULL; /* oh well, we'll do immediate mode drawing. :( */ } } } @@ -1186,130 +1152,137 @@ D3D_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti } } - IDirect3DDevice9_SetStreamSource(data->device, 0, vbo, 0, sizeof (Vertex)); + IDirect3DDevice9_SetStreamSource(data->device, 0, vbo, 0, sizeof(Vertex)); while (cmd) { switch (cmd->command) { - case SDL_RENDERCMD_SETDRAWCOLOR: { - /* currently this is sent with each vertex, but if we move to - shaders, we can put this in a uniform here and reduce vertex - buffer bandwidth */ - break; + case SDL_RENDERCMD_SETDRAWCOLOR: + { + /* currently this is sent with each vertex, but if we move to + shaders, we can put this in a uniform here and reduce vertex + buffer bandwidth */ + break; + } + + case SDL_RENDERCMD_SETVIEWPORT: + { + SDL_Rect *viewport = &data->drawstate.viewport; + if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { + SDL_copyp(viewport, &cmd->data.viewport.rect); + data->drawstate.viewport_dirty = SDL_TRUE; + } + break; + } + + case SDL_RENDERCMD_SETCLIPRECT: + { + const SDL_Rect *rect = &cmd->data.cliprect.rect; + if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) { + data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled; + data->drawstate.cliprect_enabled_dirty = SDL_TRUE; } - case SDL_RENDERCMD_SETVIEWPORT: { - SDL_Rect *viewport = &data->drawstate.viewport; - if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { - SDL_copyp(viewport, &cmd->data.viewport.rect); - data->drawstate.viewport_dirty = SDL_TRUE; - } - break; + if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) { + SDL_copyp(&data->drawstate.cliprect, rect); + data->drawstate.cliprect_dirty = SDL_TRUE; + } + break; + } + + case SDL_RENDERCMD_CLEAR: + { + const DWORD color = D3DCOLOR_ARGB(cmd->data.color.a, cmd->data.color.r, cmd->data.color.g, cmd->data.color.b); + const SDL_Rect *viewport = &data->drawstate.viewport; + const int backw = istarget ? renderer->target->w : data->pparams.BackBufferWidth; + const int backh = istarget ? renderer->target->h : data->pparams.BackBufferHeight; + const SDL_bool viewport_equal = ((viewport->x == 0) && (viewport->y == 0) && (viewport->w == backw) && (viewport->h == backh)) ? SDL_TRUE : SDL_FALSE; + + if (data->drawstate.cliprect_enabled || data->drawstate.cliprect_enabled_dirty) { + IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE, FALSE); + data->drawstate.cliprect_enabled_dirty = data->drawstate.cliprect_enabled; } - case SDL_RENDERCMD_SETCLIPRECT: { - const SDL_Rect *rect = &cmd->data.cliprect.rect; - if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) { - data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled; - data->drawstate.cliprect_enabled_dirty = SDL_TRUE; - } - - if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) { - SDL_copyp(&data->drawstate.cliprect, rect); - data->drawstate.cliprect_dirty = SDL_TRUE; - } - break; + /* Don't reset the viewport if we don't have to! */ + if (!data->drawstate.viewport_dirty && viewport_equal) { + IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0); + } else { + /* Clear is defined to clear the entire render target */ + D3DVIEWPORT9 wholeviewport = { 0, 0, 0, 0, 0.0f, 1.0f }; + wholeviewport.Width = backw; + wholeviewport.Height = backh; + IDirect3DDevice9_SetViewport(data->device, &wholeviewport); + data->drawstate.viewport_dirty = SDL_TRUE; /* we still need to (re)set orthographic projection, so always mark it dirty. */ + IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0); } - case SDL_RENDERCMD_CLEAR: { - const DWORD color = D3DCOLOR_ARGB(cmd->data.color.a, cmd->data.color.r, cmd->data.color.g, cmd->data.color.b); - const SDL_Rect *viewport = &data->drawstate.viewport; - const int backw = istarget ? renderer->target->w : data->pparams.BackBufferWidth; - const int backh = istarget ? renderer->target->h : data->pparams.BackBufferHeight; - const SDL_bool viewport_equal = ((viewport->x == 0) && (viewport->y == 0) && (viewport->w == backw) && (viewport->h == backh)) ? SDL_TRUE : SDL_FALSE; + break; + } - if (data->drawstate.cliprect_enabled || data->drawstate.cliprect_enabled_dirty) { - IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE, FALSE); - data->drawstate.cliprect_enabled_dirty = data->drawstate.cliprect_enabled; - } - - /* Don't reset the viewport if we don't have to! */ - if (!data->drawstate.viewport_dirty && viewport_equal) { - IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0); - } else { - /* Clear is defined to clear the entire render target */ - D3DVIEWPORT9 wholeviewport = { 0, 0, 0, 0, 0.0f, 1.0f }; - wholeviewport.Width = backw; - wholeviewport.Height = backh; - IDirect3DDevice9_SetViewport(data->device, &wholeviewport); - data->drawstate.viewport_dirty = SDL_TRUE; /* we still need to (re)set orthographic projection, so always mark it dirty. */ - IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0); - } - - break; + case SDL_RENDERCMD_DRAW_POINTS: + { + const size_t count = cmd->data.draw.count; + const size_t first = cmd->data.draw.first; + SetDrawState(data, cmd); + if (vbo) { + IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_POINTLIST, (UINT)(first / sizeof(Vertex)), (UINT)count); + } else { + const Vertex *verts = (Vertex *)(((Uint8 *)vertices) + first); + IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, (UINT)count, verts, sizeof(Vertex)); } + break; + } - case SDL_RENDERCMD_DRAW_POINTS: { - const size_t count = cmd->data.draw.count; - const size_t first = cmd->data.draw.first; - SetDrawState(data, cmd); - if (vbo) { - IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_POINTLIST, (UINT) (first / sizeof (Vertex)), (UINT) count); - } else { - const Vertex *verts = (Vertex *) (((Uint8 *) vertices) + first); - IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, (UINT) count, verts, sizeof (Vertex)); + case SDL_RENDERCMD_DRAW_LINES: + { + const size_t count = cmd->data.draw.count; + const size_t first = cmd->data.draw.first; + const Vertex *verts = (Vertex *)(((Uint8 *)vertices) + first); + + /* DirectX 9 has the same line rasterization semantics as GDI, + so we need to close the endpoint of the line with a second draw call. */ + const SDL_bool close_endpoint = ((count == 2) || (verts[0].x != verts[count - 1].x) || (verts[0].y != verts[count - 1].y)); + + SetDrawState(data, cmd); + + if (vbo) { + IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_LINESTRIP, (UINT)(first / sizeof(Vertex)), (UINT)(count - 1)); + if (close_endpoint) { + IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_POINTLIST, (UINT)((first / sizeof(Vertex)) + (count - 1)), 1); } - break; - } - - case SDL_RENDERCMD_DRAW_LINES: { - const size_t count = cmd->data.draw.count; - const size_t first = cmd->data.draw.first; - const Vertex *verts = (Vertex *) (((Uint8 *) vertices) + first); - - /* DirectX 9 has the same line rasterization semantics as GDI, - so we need to close the endpoint of the line with a second draw call. */ - const SDL_bool close_endpoint = ((count == 2) || (verts[0].x != verts[count-1].x) || (verts[0].y != verts[count-1].y)); - - SetDrawState(data, cmd); - - if (vbo) { - IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_LINESTRIP, (UINT) (first / sizeof (Vertex)), (UINT) (count - 1)); - if (close_endpoint) { - IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_POINTLIST, (UINT) ((first / sizeof (Vertex)) + (count - 1)), 1); - } - } else { - IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, (UINT) (count - 1), verts, sizeof (Vertex)); - if (close_endpoint) { - IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, &verts[count-1], sizeof (Vertex)); - } + } else { + IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, (UINT)(count - 1), verts, sizeof(Vertex)); + if (close_endpoint) { + IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, &verts[count - 1], sizeof(Vertex)); } - break; } + break; + } - case SDL_RENDERCMD_FILL_RECTS: /* unused */ - break; + case SDL_RENDERCMD_FILL_RECTS: /* unused */ + break; - case SDL_RENDERCMD_COPY: /* unused */ - break; + case SDL_RENDERCMD_COPY: /* unused */ + break; - case SDL_RENDERCMD_COPY_EX: /* unused */ - break; + case SDL_RENDERCMD_COPY_EX: /* unused */ + break; - case SDL_RENDERCMD_GEOMETRY: { - const size_t count = cmd->data.draw.count; - const size_t first = cmd->data.draw.first; - SetDrawState(data, cmd); - if (vbo) { - IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_TRIANGLELIST, (UINT) (first / sizeof (Vertex)), (UINT) count / 3); - } else { - const Vertex* verts = (Vertex*)(((Uint8*)vertices) + first); - IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLELIST, (UINT) count / 3, verts, sizeof(Vertex)); - } - break; + case SDL_RENDERCMD_GEOMETRY: + { + const size_t count = cmd->data.draw.count; + const size_t first = cmd->data.draw.first; + SetDrawState(data, cmd); + if (vbo) { + IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_TRIANGLELIST, (UINT)(first / sizeof(Vertex)), (UINT)count / 3); + } else { + const Vertex *verts = (Vertex *)(((Uint8 *)vertices) + first); + IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLELIST, (UINT)count / 3, verts, sizeof(Vertex)); } + break; + } - case SDL_RENDERCMD_NO_OP: - break; + case SDL_RENDERCMD_NO_OP: + break; } cmd = cmd->next; @@ -1318,12 +1291,10 @@ D3D_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti return 0; } - -static int -D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, void * pixels, int pitch) +static int D3D_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, + Uint32 format, void *pixels, int pitch) { - D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; D3DSURFACE_DESC desc; LPDIRECT3DSURFACE9 backBuffer; LPDIRECT3DSURFACE9 surface; @@ -1366,8 +1337,8 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, } status = SDL_ConvertPixels(rect->w, rect->h, - D3DFMTToPixelFormat(desc.Format), locked.pBits, locked.Pitch, - format, pixels, pitch); + D3DFMTToPixelFormat(desc.Format), locked.pBits, locked.Pitch, + format, pixels, pitch); IDirect3DSurface9_UnlockRect(surface); @@ -1376,10 +1347,9 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, return status; } -static int -D3D_RenderPresent(SDL_Renderer * renderer) +static int D3D_RenderPresent(SDL_Renderer *renderer) { - D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; HRESULT result; if (!data->beginScene) { @@ -1402,11 +1372,10 @@ D3D_RenderPresent(SDL_Renderer * renderer) return 0; } -static void -D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static void D3D_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata; - D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; + D3D_RenderData *renderdata = (D3D_RenderData *)renderer->driverdata; + D3D_TextureData *data = (D3D_TextureData *)texture->driverdata; if (renderdata->drawstate.texture == texture) { renderdata->drawstate.texture = NULL; @@ -1435,10 +1404,9 @@ D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) texture->driverdata = NULL; } -static void -D3D_DestroyRenderer(SDL_Renderer * renderer) +static void D3D_DestroyRenderer(SDL_Renderer *renderer) { - D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; if (data) { int i; @@ -1480,10 +1448,9 @@ D3D_DestroyRenderer(SDL_Renderer * renderer) SDL_free(renderer); } -static int -D3D_Reset(SDL_Renderer * renderer) +static int D3D_Reset(SDL_Renderer *renderer) { - D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; const Float4X4 d3dmatrix = MatrixIdentity(); HRESULT result; SDL_Texture *texture; @@ -1549,7 +1516,7 @@ D3D_Reset(SDL_Renderer * renderer) data->drawstate.texture = NULL; data->drawstate.shader = NULL; data->drawstate.blend = SDL_BLENDMODE_INVALID; - IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&d3dmatrix); + IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX *)&d3dmatrix); /* Let the application know that render targets were reset */ { @@ -1561,8 +1528,7 @@ D3D_Reset(SDL_Renderer * renderer) return 0; } -static int -D3D_SetVSync(SDL_Renderer * renderer, const int vsync) +static int D3D_SetVSync(SDL_Renderer *renderer, const int vsync) { D3D_RenderData *data = renderer->driverdata; if (vsync) { @@ -1580,7 +1546,7 @@ D3D_SetVSync(SDL_Renderer * renderer, const int vsync) } SDL_Renderer * -D3D_CreateRenderer(SDL_Window * window, Uint32 flags) +D3D_CreateRenderer(SDL_Window *window, Uint32 flags) { SDL_Renderer *renderer; D3D_RenderData *data; @@ -1601,7 +1567,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) return NULL; } - data = (D3D_RenderData *) SDL_calloc(1, sizeof(*data)); + data = (D3D_RenderData *)SDL_calloc(1, sizeof(*data)); if (data == NULL) { SDL_free(renderer); SDL_OutOfMemory(); @@ -1628,9 +1594,9 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->SetTextureScaleMode = D3D_SetTextureScaleMode; renderer->SetRenderTarget = D3D_SetRenderTarget; renderer->QueueSetViewport = D3D_QueueSetViewport; - renderer->QueueSetDrawColor = D3D_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */ + renderer->QueueSetDrawColor = D3D_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */ renderer->QueueDrawPoints = D3D_QueueDrawPoints; - renderer->QueueDrawLines = D3D_QueueDrawPoints; /* lines and points queue vertices the same way. */ + renderer->QueueDrawLines = D3D_QueueDrawPoints; /* lines and points queue vertices the same way. */ renderer->QueueGeometry = D3D_QueueGeometry; renderer->RunCommandQueue = D3D_RunCommandQueue; renderer->RenderReadPixels = D3D_RenderReadPixels; @@ -1758,25 +1724,24 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) SDL_RenderDriver D3D_RenderDriver = { D3D_CreateRenderer, - { - "direct3d", - (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE), - 1, - {SDL_PIXELFORMAT_ARGB8888}, - 0, - 0} + { "direct3d", + (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE), + 1, + { SDL_PIXELFORMAT_ARGB8888 }, + 0, + 0 } }; #endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */ #if defined(__WIN32__) || defined(__WINGDK__) /* This function needs to always exist on Windows, for the Dynamic API. */ IDirect3DDevice9 * -SDL_RenderGetD3D9Device(SDL_Renderer * renderer) +SDL_RenderGetD3D9Device(SDL_Renderer *renderer) { IDirect3DDevice9 *device = NULL; #if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED - D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; /* Make sure that this is a D3D renderer */ if (renderer->DestroyRenderer != D3D_DestroyRenderer) { diff --git a/src/render/direct3d/SDL_shaders_d3d.c b/src/render/direct3d/SDL_shaders_d3d.c index d734351c8..9c22f2136 100644 --- a/src/render/direct3d/SDL_shaders_d3d.c +++ b/src/render/direct3d/SDL_shaders_d3d.c @@ -257,7 +257,6 @@ static const DWORD D3D9_PixelShader_YUV_BT709[] = { 0x90e40000, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff }; - static const DWORD *D3D9_shaders[] = { D3D9_PixelShader_YUV_JPEG, D3D9_PixelShader_YUV_BT601, diff --git a/src/render/direct3d/SDL_shaders_d3d.h b/src/render/direct3d/SDL_shaders_d3d.h index b7715cb75..681cd370c 100644 --- a/src/render/direct3d/SDL_shaders_d3d.h +++ b/src/render/direct3d/SDL_shaders_d3d.h @@ -22,7 +22,8 @@ /* D3D9 shader implementation */ -typedef enum { +typedef enum +{ SHADER_YUV_JPEG, SHADER_YUV_BT601, SHADER_YUV_BT709, diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index 9d02297e4..a37c1df38 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -51,11 +51,10 @@ #if WINAPI_FAMILY == WINAPI_FAMILY_APP #include /* TODO, WinRT, XAML: get the ISwapChainBackgroundPanelNative from something other than a global var */ -extern ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNative; -#endif /* WINAPI_FAMILY == WINAPI_FAMILY_APP */ - -#endif /* __WINRT__ */ +extern ISwapChainBackgroundPanelNative *WINRT_GlobalSwapChainBackgroundPanelNative; +#endif /* WINAPI_FAMILY == WINAPI_FAMILY_APP */ +#endif /* __WINRT__ */ #if defined(_MSC_VER) && !defined(__clang__) #define SDL_COMPOSE_ERROR(str) __FUNCTION__ ", " str @@ -63,8 +62,11 @@ extern ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNat #define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str #endif -#define SAFE_RELEASE(X) if ((X)) { IUnknown_Release(SDL_static_cast(IUnknown*, X)); X = NULL; } - +#define SAFE_RELEASE(X) \ + if ((X)) { \ + IUnknown_Release(SDL_static_cast(IUnknown *, X)); \ + X = NULL; \ + } /* !!! FIXME: vertex buffer bandwidth could be lower; only use UV coords when !!! FIXME: textures are needed. */ @@ -170,15 +172,14 @@ typedef struct int currentVertexBuffer; } D3D11_RenderData; - /* Define D3D GUIDs here so we don't have to include uuid.lib. -* -* Fix for SDL bug https://bugzilla.libsdl.org/show_bug.cgi?id=3437: -* The extra 'SDL_' was added to the start of each IID's name, in order -* to prevent build errors on both MinGW-w64 and WinRT/UWP. -* (SDL bug https://bugzilla.libsdl.org/show_bug.cgi?id=3336 led to -* linker errors in WinRT/UWP builds.) -*/ + * + * Fix for SDL bug https://bugzilla.libsdl.org/show_bug.cgi?id=3437: + * The extra 'SDL_' was added to the start of each IID's name, in order + * to prevent build errors on both MinGW-w64 and WinRT/UWP. + * (SDL bug https://bugzilla.libsdl.org/show_bug.cgi?id=3336 led to + * linker errors in WinRT/UWP builds.) + */ #ifdef __GNUC__ #pragma GCC diagnostic push @@ -199,45 +200,41 @@ static const GUID SDL_IID_ID3D11DeviceContext1 = { 0xbb2c6faa, 0xb5fb, 0x4082, { #pragma GCC diagnostic pop #endif - - Uint32 D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat) { switch (dxgiFormat) { - case DXGI_FORMAT_B8G8R8A8_UNORM: - return SDL_PIXELFORMAT_ARGB8888; - case DXGI_FORMAT_B8G8R8X8_UNORM: - return SDL_PIXELFORMAT_RGB888; - default: - return SDL_PIXELFORMAT_UNKNOWN; + case DXGI_FORMAT_B8G8R8A8_UNORM: + return SDL_PIXELFORMAT_ARGB8888; + case DXGI_FORMAT_B8G8R8X8_UNORM: + return SDL_PIXELFORMAT_RGB888; + default: + return SDL_PIXELFORMAT_UNKNOWN; } } -static DXGI_FORMAT -SDLPixelFormatToDXGIFormat(Uint32 sdlFormat) +static DXGI_FORMAT SDLPixelFormatToDXGIFormat(Uint32 sdlFormat) { switch (sdlFormat) { - case SDL_PIXELFORMAT_ARGB8888: - return DXGI_FORMAT_B8G8R8A8_UNORM; - case SDL_PIXELFORMAT_RGB888: - return DXGI_FORMAT_B8G8R8X8_UNORM; - case SDL_PIXELFORMAT_YV12: - case SDL_PIXELFORMAT_IYUV: - case SDL_PIXELFORMAT_NV12: /* For the Y texture */ - case SDL_PIXELFORMAT_NV21: /* For the Y texture */ - return DXGI_FORMAT_R8_UNORM; - default: - return DXGI_FORMAT_UNKNOWN; + case SDL_PIXELFORMAT_ARGB8888: + return DXGI_FORMAT_B8G8R8A8_UNORM; + case SDL_PIXELFORMAT_RGB888: + return DXGI_FORMAT_B8G8R8X8_UNORM; + case SDL_PIXELFORMAT_YV12: + case SDL_PIXELFORMAT_IYUV: + case SDL_PIXELFORMAT_NV12: /* For the Y texture */ + case SDL_PIXELFORMAT_NV21: /* For the Y texture */ + return DXGI_FORMAT_R8_UNORM; + default: + return DXGI_FORMAT_UNKNOWN; } } -static void D3D11_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static void D3D11_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture); -static void -D3D11_ReleaseAll(SDL_Renderer * renderer) +static void D3D11_ReleaseAll(SDL_Renderer *renderer) { - D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; SDL_Texture *texture = NULL; /* Release all textures */ @@ -278,7 +275,7 @@ D3D11_ReleaseAll(SDL_Renderer * renderer) SAFE_RELEASE(data->clippedRasterizer); SAFE_RELEASE(data->vertexShaderConstants); - data->swapEffect = (DXGI_SWAP_EFFECT) 0; + data->swapEffect = (DXGI_SWAP_EFFECT)0; data->rotation = DXGI_MODE_ROTATION_UNSPECIFIED; data->currentRenderTargetView = NULL; data->currentRasterizerState = NULL; @@ -301,10 +298,9 @@ D3D11_ReleaseAll(SDL_Renderer * renderer) } } -static void -D3D11_DestroyRenderer(SDL_Renderer * renderer) +static void D3D11_DestroyRenderer(SDL_Renderer *renderer) { - D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; D3D11_ReleaseAll(renderer); if (data) { SDL_free(data); @@ -358,10 +354,9 @@ static D3D11_BLEND_OP GetBlendEquation(SDL_BlendOperation operation) } } -static ID3D11BlendState * -D3D11_CreateBlendState(SDL_Renderer * renderer, SDL_BlendMode blendMode) +static ID3D11BlendState *D3D11_CreateBlendState(SDL_Renderer *renderer, SDL_BlendMode blendMode) { - D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode); @@ -405,12 +400,11 @@ D3D11_CreateBlendState(SDL_Renderer * renderer, SDL_BlendMode blendMode) } /* Create resources that depend on the device. */ -static HRESULT -D3D11_CreateDeviceResources(SDL_Renderer * renderer) +static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) { - typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory); + typedef HRESULT(WINAPI * PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory); PFN_CREATE_DXGI_FACTORY CreateDXGIFactoryFunc; - D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; PFN_D3D11_CREATE_DEVICE D3D11CreateDeviceFunc; ID3D11Device *d3dDevice = NULL; ID3D11DeviceContext *d3dContext = NULL; @@ -424,8 +418,7 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer) * Don't forget to declare your application's minimum required feature level in its * description. All applications are assumed to support 9.1 unless otherwise stated. */ - D3D_FEATURE_LEVEL featureLevels[] = - { + D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, @@ -504,11 +497,11 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer) creationFlags, /* Set set debug and Direct2D compatibility flags. */ featureLevels, /* List of feature levels this app can support. */ SDL_arraysize(featureLevels), - D3D11_SDK_VERSION, /* Always set this to D3D11_SDK_VERSION for Windows Store apps. */ - &d3dDevice, /* Returns the Direct3D device created. */ + D3D11_SDK_VERSION, /* Always set this to D3D11_SDK_VERSION for Windows Store apps. */ + &d3dDevice, /* Returns the Direct3D device created. */ &data->featureLevel, /* Returns feature level of device created. */ - &d3dContext /* Returns the device immediate context. */ - ); + &d3dContext /* Returns the device immediate context. */ + ); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D11CreateDevice"), result); goto done; @@ -546,29 +539,29 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer) * http://msdn.microsoft.com/en-us/library/windows/apps/ff476876.aspx */ switch (data->featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - renderer->info.max_texture_width = renderer->info.max_texture_height = 16384; - break; + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: + renderer->info.max_texture_width = renderer->info.max_texture_height = 16384; + break; - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - renderer->info.max_texture_width = renderer->info.max_texture_height = 8192; - break; + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: + renderer->info.max_texture_width = renderer->info.max_texture_height = 8192; + break; - case D3D_FEATURE_LEVEL_9_3: - renderer->info.max_texture_width = renderer->info.max_texture_height = 4096; - break; + case D3D_FEATURE_LEVEL_9_3: + renderer->info.max_texture_width = renderer->info.max_texture_height = 4096; + break; - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - renderer->info.max_texture_width = renderer->info.max_texture_height = 2048; - break; + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: + renderer->info.max_texture_width = renderer->info.max_texture_height = 2048; + break; - default: - SDL_SetError("%s, Unexpected feature level: %d", __FUNCTION__, data->featureLevel); - result = E_FAIL; - goto done; + default: + SDL_SetError("%s, Unexpected feature level: %d", __FUNCTION__, data->featureLevel); + result = E_FAIL; + goto done; } if (D3D11_CreateVertexShader(data->d3dDevice, &data->vertexShader, &data->inputLayout) < 0) { @@ -587,10 +580,9 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer) constantBufferDesc.Usage = D3D11_USAGE_DEFAULT; constantBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; result = ID3D11Device_CreateBuffer(data->d3dDevice, - &constantBufferDesc, - NULL, - &data->vertexShaderConstants - ); + &constantBufferDesc, + NULL, + &data->vertexShaderConstants); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateBuffer [vertex shader constants]"), result); goto done; @@ -608,9 +600,8 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer) samplerDesc.MinLOD = 0.0f; samplerDesc.MaxLOD = D3D11_FLOAT32_MAX; result = ID3D11Device_CreateSamplerState(data->d3dDevice, - &samplerDesc, - &data->nearestPixelSampler - ); + &samplerDesc, + &data->nearestPixelSampler); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateSamplerState [nearest-pixel filter]"), result); goto done; @@ -618,9 +609,8 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer) samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; result = ID3D11Device_CreateSamplerState(data->d3dDevice, - &samplerDesc, - &data->linearSampler - ); + &samplerDesc, + &data->linearSampler); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateSamplerState [linear filter]"), result); goto done; @@ -674,8 +664,7 @@ done: #if defined(__WIN32__) || defined(__WINGDK__) -static DXGI_MODE_ROTATION -D3D11_GetCurrentRotation() +static DXGI_MODE_ROTATION D3D11_GetCurrentRotation() { /* FIXME */ return DXGI_MODE_ROTATION_IDENTITY; @@ -683,20 +672,18 @@ D3D11_GetCurrentRotation() #endif /* defined(__WIN32__) || defined(__WINGDK__) */ -static BOOL -D3D11_IsDisplayRotated90Degrees(DXGI_MODE_ROTATION rotation) +static BOOL D3D11_IsDisplayRotated90Degrees(DXGI_MODE_ROTATION rotation) { switch (rotation) { - case DXGI_MODE_ROTATION_ROTATE90: - case DXGI_MODE_ROTATION_ROTATE270: - return TRUE; - default: - return FALSE; + case DXGI_MODE_ROTATION_ROTATE90: + case DXGI_MODE_ROTATION_ROTATE270: + return TRUE; + default: + return FALSE; } } -static int -D3D11_GetRotationForCurrentRenderTarget(SDL_Renderer * renderer) +static int D3D11_GetRotationForCurrentRenderTarget(SDL_Renderer *renderer) { D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; if (data->currentOffscreenRenderTargetView) { @@ -706,52 +693,50 @@ D3D11_GetRotationForCurrentRenderTarget(SDL_Renderer * renderer) } } -static int -D3D11_GetViewportAlignedD3DRect(SDL_Renderer * renderer, const SDL_Rect * sdlRect, D3D11_RECT * outRect, BOOL includeViewportOffset) +static int D3D11_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rect *sdlRect, D3D11_RECT *outRect, BOOL includeViewportOffset) { - D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; const int rotation = D3D11_GetRotationForCurrentRenderTarget(renderer); const SDL_Rect *viewport = &data->currentViewport; switch (rotation) { - case DXGI_MODE_ROTATION_IDENTITY: - outRect->left = sdlRect->x; - outRect->right = sdlRect->x + sdlRect->w; - outRect->top = sdlRect->y; - outRect->bottom = sdlRect->y + sdlRect->h; - if (includeViewportOffset) { - outRect->left += viewport->x; - outRect->right += viewport->x; - outRect->top += viewport->y; - outRect->bottom += viewport->y; - } - break; - case DXGI_MODE_ROTATION_ROTATE270: - outRect->left = sdlRect->y; - outRect->right = sdlRect->y + sdlRect->h; - outRect->top = viewport->w - sdlRect->x - sdlRect->w; - outRect->bottom = viewport->w - sdlRect->x; - break; - case DXGI_MODE_ROTATION_ROTATE180: - outRect->left = viewport->w - sdlRect->x - sdlRect->w; - outRect->right = viewport->w - sdlRect->x; - outRect->top = viewport->h - sdlRect->y - sdlRect->h; - outRect->bottom = viewport->h - sdlRect->y; - break; - case DXGI_MODE_ROTATION_ROTATE90: - outRect->left = viewport->h - sdlRect->y - sdlRect->h; - outRect->right = viewport->h - sdlRect->y; - outRect->top = sdlRect->x; - outRect->bottom = sdlRect->x + sdlRect->h; - break; - default: - return SDL_SetError("The physical display is in an unknown or unsupported rotation"); + case DXGI_MODE_ROTATION_IDENTITY: + outRect->left = sdlRect->x; + outRect->right = sdlRect->x + sdlRect->w; + outRect->top = sdlRect->y; + outRect->bottom = sdlRect->y + sdlRect->h; + if (includeViewportOffset) { + outRect->left += viewport->x; + outRect->right += viewport->x; + outRect->top += viewport->y; + outRect->bottom += viewport->y; + } + break; + case DXGI_MODE_ROTATION_ROTATE270: + outRect->left = sdlRect->y; + outRect->right = sdlRect->y + sdlRect->h; + outRect->top = viewport->w - sdlRect->x - sdlRect->w; + outRect->bottom = viewport->w - sdlRect->x; + break; + case DXGI_MODE_ROTATION_ROTATE180: + outRect->left = viewport->w - sdlRect->x - sdlRect->w; + outRect->right = viewport->w - sdlRect->x; + outRect->top = viewport->h - sdlRect->y - sdlRect->h; + outRect->bottom = viewport->h - sdlRect->y; + break; + case DXGI_MODE_ROTATION_ROTATE90: + outRect->left = viewport->h - sdlRect->y - sdlRect->h; + outRect->right = viewport->h - sdlRect->y; + outRect->top = sdlRect->x; + outRect->bottom = sdlRect->x + sdlRect->h; + break; + default: + return SDL_SetError("The physical display is in an unknown or unsupported rotation"); } return 0; } -static HRESULT -D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h) +static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) { D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; #ifdef __WINRT__ @@ -775,7 +760,7 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h) swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swapChainDesc.BufferCount = 2; /* Use double-buffering to minimize latency. */ #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP - swapChainDesc.Scaling = DXGI_SCALING_STRETCH; /* On phone, only stretch and aspect-ratio stretch scaling are allowed. */ + swapChainDesc.Scaling = DXGI_SCALING_STRETCH; /* On phone, only stretch and aspect-ratio stretch scaling are allowed. */ swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; /* On phone, no swap effects are supported. */ /* TODO, WinRT: see if Win 8.x DXGI_SWAP_CHAIN_DESC1 settings are available on Windows Phone 8.1, and if there's any advantage to having them on */ #else @@ -794,29 +779,28 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h) if (coreWindow) { result = IDXGIFactory2_CreateSwapChainForCoreWindow(data->dxgiFactory, - (IUnknown *)data->d3dDevice, - coreWindow, - &swapChainDesc, - NULL, /* Allow on all displays. */ - &data->swapChain - ); + (IUnknown *)data->d3dDevice, + coreWindow, + &swapChainDesc, + NULL, /* Allow on all displays. */ + &data->swapChain); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForCoreWindow"), result); goto done; } } else if (usingXAML) { result = IDXGIFactory2_CreateSwapChainForComposition(data->dxgiFactory, - (IUnknown *)data->d3dDevice, - &swapChainDesc, - NULL, - &data->swapChain); + (IUnknown *)data->d3dDevice, + &swapChainDesc, + NULL, + &data->swapChain); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForComposition"), result); goto done; } #if WINAPI_FAMILY == WINAPI_FAMILY_APP - result = ISwapChainBackgroundPanelNative_SetSwapChain(WINRT_GlobalSwapChainBackgroundPanelNative, (IDXGISwapChain *) data->swapChain); + result = ISwapChainBackgroundPanelNative_SetSwapChain(WINRT_GlobalSwapChainBackgroundPanelNative, (IDXGISwapChain *)data->swapChain); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ISwapChainBackgroundPanelNative::SetSwapChain"), result); goto done; @@ -833,13 +817,12 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h) SDL_GetWindowWMInfo(renderer->window, &windowinfo); result = IDXGIFactory2_CreateSwapChainForHwnd(data->dxgiFactory, - (IUnknown *)data->d3dDevice, - windowinfo.info.win.window, - &swapChainDesc, - NULL, - NULL, /* Allow on all displays. */ - &data->swapChain - ); + (IUnknown *)data->d3dDevice, + windowinfo.info.win.window, + &swapChainDesc, + NULL, + NULL, /* Allow on all displays. */ + &data->swapChain); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForHwnd"), result); goto done; @@ -847,9 +830,9 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h) IDXGIFactory_MakeWindowAssociation(data->dxgiFactory, windowinfo.info.win.window, DXGI_MWA_NO_WINDOW_CHANGES); #else - SDL_SetError(__FUNCTION__", Unable to find something to attach a swap chain to"); + SDL_SetError(__FUNCTION__ ", Unable to find something to attach a swap chain to"); goto done; -#endif /* defined(__WIN32__) || defined(__WINGDK__) / else */ +#endif /* defined(__WIN32__) || defined(__WINGDK__) / else */ } data->swapEffect = swapChainDesc.SwapEffect; @@ -858,19 +841,17 @@ done: return result; } -static void -D3D11_ReleaseMainRenderTargetView(SDL_Renderer * renderer) +static void D3D11_ReleaseMainRenderTargetView(SDL_Renderer *renderer) { D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; ID3D11DeviceContext_OMSetRenderTargets(data->d3dContext, 0, NULL, NULL); SAFE_RELEASE(data->mainRenderTargetView); } -static HRESULT D3D11_UpdateForWindowSizeChange(SDL_Renderer * renderer); - +static HRESULT D3D11_UpdateForWindowSizeChange(SDL_Renderer *renderer); HRESULT -D3D11_HandleDeviceLost(SDL_Renderer * renderer) +D3D11_HandleDeviceLost(SDL_Renderer *renderer) { HRESULT result = S_OK; @@ -899,8 +880,7 @@ D3D11_HandleDeviceLost(SDL_Renderer * renderer) } /* Initialize all resources that change when the window's size changes. */ -static HRESULT -D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer) +static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer) { D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; ID3D11Texture2D *backBuffer = NULL; @@ -931,16 +911,15 @@ D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer) #if !defined(__WINRT__) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) /* If the swap chain already exists, resize it. */ result = IDXGISwapChain_ResizeBuffers(data->swapChain, - 0, - w, h, - DXGI_FORMAT_UNKNOWN, - 0 - ); + 0, + w, h, + DXGI_FORMAT_UNKNOWN, + 0); if (result == DXGI_ERROR_DEVICE_REMOVED) { /* If the device was removed for any reason, a new device and swap chain will need to be created. */ D3D11_HandleDeviceLost(renderer); - /* Everything is set up now. Do not continue execution of this method. HandleDeviceLost will reenter this method + /* Everything is set up now. Do not continue execution of this method. HandleDeviceLost will reenter this method * and correctly set up the new device. */ goto done; @@ -955,7 +934,7 @@ D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer) goto done; } } - + #if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP /* Set the proper rotation for the swap chain. * @@ -985,10 +964,9 @@ D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer) #endif result = IDXGISwapChain_GetBuffer(data->swapChain, - 0, - &SDL_IID_ID3D11Texture2D, - (void **)&backBuffer - ); + 0, + &SDL_IID_ID3D11Texture2D, + (void **)&backBuffer); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::GetBuffer [back-buffer]"), result); goto done; @@ -996,10 +974,9 @@ D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer) /* Create a render target view of the swap chain back buffer. */ result = ID3D11Device_CreateRenderTargetView(data->d3dDevice, - (ID3D11Resource *)backBuffer, - NULL, - &data->mainRenderTargetView - ); + (ID3D11Resource *)backBuffer, + NULL, + &data->mainRenderTargetView); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device::CreateRenderTargetView"), result); goto done; @@ -1010,10 +987,9 @@ D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer) * null references in places like ReadPixels! */ ID3D11DeviceContext_OMSetRenderTargets(data->d3dContext, - 1, - &data->mainRenderTargetView, - NULL - ); + 1, + &data->mainRenderTargetView, + NULL); data->viewportDirty = SDL_TRUE; @@ -1023,14 +999,12 @@ done: } /* This method is called when the window's size changes. */ -static HRESULT -D3D11_UpdateForWindowSizeChange(SDL_Renderer * renderer) +static HRESULT D3D11_UpdateForWindowSizeChange(SDL_Renderer *renderer) { return D3D11_CreateWindowSizeDependentResources(renderer); } -void -D3D11_Trim(SDL_Renderer * renderer) +void D3D11_Trim(SDL_Renderer *renderer) { #ifdef __WINRT__ #if NTDDI_VERSION > NTDDI_WIN8 @@ -1040,7 +1014,7 @@ D3D11_Trim(SDL_Renderer * renderer) result = ID3D11Device_QueryInterface(data->d3dDevice, &SDL_IID_IDXGIDevice3, &dxgiDevice); if (FAILED(result)) { - //WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device to IDXGIDevice3", result); + // WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device to IDXGIDevice3", result); return; } @@ -1050,8 +1024,7 @@ D3D11_Trim(SDL_Renderer * renderer) #endif } -static void -D3D11_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +static void D3D11_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event) { if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { D3D11_UpdateForWindowSizeChange(renderer); @@ -1059,16 +1032,14 @@ D3D11_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) } #if !defined(__WINRT__) -static int -D3D11_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) +static int D3D11_GetOutputSize(SDL_Renderer *renderer, int *w, int *h) { SDL_GetWindowSizeInPixels(renderer->window, w, h); return 0; } #endif -static SDL_bool -D3D11_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +static SDL_bool D3D11_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); @@ -1086,10 +1057,9 @@ D3D11_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) return SDL_TRUE; } -static int -D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData; HRESULT result; DXGI_FORMAT textureFormat = SDLPixelFormatToDXGIFormat(texture->format); @@ -1098,15 +1068,15 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) if (textureFormat == DXGI_FORMAT_UNKNOWN) { return SDL_SetError("%s, An unsupported SDL pixel format (0x%x) was specified", - __FUNCTION__, texture->format); + __FUNCTION__, texture->format); } - textureData = (D3D11_TextureData*) SDL_calloc(1, sizeof(*textureData)); + textureData = (D3D11_TextureData *)SDL_calloc(1, sizeof(*textureData)); if (textureData == NULL) { SDL_OutOfMemory(); return -1; } - textureData->scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? D3D11_FILTER_MIN_MAG_MIP_POINT : D3D11_FILTER_MIN_MAG_MIP_LINEAR; + textureData->scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? D3D11_FILTER_MIN_MAG_MIP_POINT : D3D11_FILTER_MIN_MAG_MIP_LINEAR; texture->driverdata = textureData; @@ -1135,10 +1105,9 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) } result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, - &textureDesc, - NULL, - &textureData->mainTexture - ); + &textureDesc, + NULL, + &textureData->mainTexture); if (FAILED(result)) { D3D11_DestroyTexture(renderer, texture); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); @@ -1152,20 +1121,18 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) textureDesc.Height = (textureDesc.Height + 1) / 2; result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, - &textureDesc, - NULL, - &textureData->mainTextureU - ); + &textureDesc, + NULL, + &textureData->mainTextureU); if (FAILED(result)) { D3D11_DestroyTexture(renderer, texture); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); } result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, - &textureDesc, - NULL, - &textureData->mainTextureV - ); + &textureDesc, + NULL, + &textureData->mainTextureV); if (FAILED(result)) { D3D11_DestroyTexture(renderer, texture); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); @@ -1183,10 +1150,9 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) nvTextureDesc.Height = (textureDesc.Height + 1) / 2; result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, - &nvTextureDesc, - NULL, - &textureData->mainTextureNV - ); + &nvTextureDesc, + NULL, + &textureData->mainTextureNV); if (FAILED(result)) { D3D11_DestroyTexture(renderer, texture); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); @@ -1199,10 +1165,9 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) resourceViewDesc.Texture2D.MostDetailedMip = 0; resourceViewDesc.Texture2D.MipLevels = textureDesc.MipLevels; result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice, - (ID3D11Resource *)textureData->mainTexture, - &resourceViewDesc, - &textureData->mainTextureResourceView - ); + (ID3D11Resource *)textureData->mainTexture, + &resourceViewDesc, + &textureData->mainTextureResourceView); if (FAILED(result)) { D3D11_DestroyTexture(renderer, texture); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); @@ -1210,19 +1175,17 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) #if SDL_HAVE_YUV if (textureData->yuv) { result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice, - (ID3D11Resource *)textureData->mainTextureU, - &resourceViewDesc, - &textureData->mainTextureResourceViewU - ); + (ID3D11Resource *)textureData->mainTextureU, + &resourceViewDesc, + &textureData->mainTextureResourceViewU); if (FAILED(result)) { D3D11_DestroyTexture(renderer, texture); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); } result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice, - (ID3D11Resource *)textureData->mainTextureV, - &resourceViewDesc, - &textureData->mainTextureResourceViewV - ); + (ID3D11Resource *)textureData->mainTextureV, + &resourceViewDesc, + &textureData->mainTextureResourceViewV); if (FAILED(result)) { D3D11_DestroyTexture(renderer, texture); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); @@ -1235,10 +1198,9 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) nvResourceViewDesc.Format = DXGI_FORMAT_R8G8_UNORM; result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice, - (ID3D11Resource *)textureData->mainTextureNV, - &nvResourceViewDesc, - &textureData->mainTextureResourceViewNV - ); + (ID3D11Resource *)textureData->mainTextureNV, + &nvResourceViewDesc, + &textureData->mainTextureResourceViewNV); if (FAILED(result)) { D3D11_DestroyTexture(renderer, texture); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); @@ -1254,9 +1216,9 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) renderTargetViewDesc.Texture2D.MipSlice = 0; result = ID3D11Device_CreateRenderTargetView(rendererData->d3dDevice, - (ID3D11Resource *)textureData->mainTexture, - &renderTargetViewDesc, - &textureData->mainTextureRenderTargetView); + (ID3D11Resource *)textureData->mainTexture, + &renderTargetViewDesc, + &textureData->mainTextureRenderTargetView); if (FAILED(result)) { D3D11_DestroyTexture(renderer, texture); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateRenderTargetView"), result); @@ -1266,9 +1228,8 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) return 0; } -static void -D3D11_DestroyTexture(SDL_Renderer * renderer, - SDL_Texture * texture) +static void D3D11_DestroyTexture(SDL_Renderer *renderer, + SDL_Texture *texture) { D3D11_TextureData *data = (D3D11_TextureData *)texture->driverdata; @@ -1293,8 +1254,7 @@ D3D11_DestroyTexture(SDL_Renderer * renderer, texture->driverdata = NULL; } -static int -D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *texture, int bpp, int x, int y, int w, int h, const void *pixels, int pitch) +static int D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *texture, int bpp, int x, int y, int w, int h, const void *pixels, int pitch) { ID3D11Texture2D *stagingTexture; const Uint8 *src; @@ -1314,21 +1274,20 @@ D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *tex stagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; stagingTextureDesc.Usage = D3D11_USAGE_STAGING; result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, - &stagingTextureDesc, - NULL, - &stagingTexture); + &stagingTextureDesc, + NULL, + &stagingTexture); if (FAILED(result)) { return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result); } /* Get a write-only pointer to data in the staging texture: */ result = ID3D11DeviceContext_Map(rendererData->d3dContext, - (ID3D11Resource *)stagingTexture, - 0, - D3D11_MAP_WRITE, - 0, - &textureMemory - ); + (ID3D11Resource *)stagingTexture, + 0, + D3D11_MAP_WRITE, + 0, + &textureMemory); if (FAILED(result)) { SAFE_RELEASE(stagingTexture); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result); @@ -1338,7 +1297,7 @@ D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *tex dst = textureMemory.pData; length = w * bpp; if (length == pitch && length == textureMemory.RowPitch) { - SDL_memcpy(dst, src, length*h); + SDL_memcpy(dst, src, length * h); } else { if (length > (UINT)pitch) { length = pitch; @@ -1355,29 +1314,28 @@ D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *tex /* Commit the pixel buffer's changes back to the staging texture: */ ID3D11DeviceContext_Unmap(rendererData->d3dContext, - (ID3D11Resource *)stagingTexture, - 0); + (ID3D11Resource *)stagingTexture, + 0); /* Copy the staging texture's contents back to the texture: */ ID3D11DeviceContext_CopySubresourceRegion(rendererData->d3dContext, - (ID3D11Resource *)texture, - 0, - x, - y, - 0, - (ID3D11Resource *)stagingTexture, - 0, - NULL); + (ID3D11Resource *)texture, + 0, + x, + y, + 0, + (ID3D11Resource *)stagingTexture, + 0, + NULL); SAFE_RELEASE(stagingTexture); return 0; } -static int -D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void * srcPixels, - int srcPitch) +static int D3D11_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, const void *srcPixels, + int srcPitch) { D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; @@ -1392,14 +1350,14 @@ D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, #if SDL_HAVE_YUV if (textureData->yuv) { /* Skip to the correct offset into the next texture */ - srcPixels = (const void*)((const Uint8*)srcPixels + rect->h * srcPitch); + srcPixels = (const void *)((const Uint8 *)srcPixels + rect->h * srcPitch); if (D3D11_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureV : textureData->mainTextureU, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, (srcPitch + 1) / 2) < 0) { return -1; } /* Skip to the correct offset into the next texture */ - srcPixels = (const void*)((const Uint8*)srcPixels + ((rect->h + 1) / 2) * ((srcPitch + 1) / 2)); + srcPixels = (const void *)((const Uint8 *)srcPixels + ((rect->h + 1) / 2) * ((srcPitch + 1) / 2)); if (D3D11_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureU : textureData->mainTextureV, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, (srcPitch + 1) / 2) < 0) { return -1; } @@ -1407,9 +1365,9 @@ D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, if (textureData->nv12) { /* Skip to the correct offset into the next texture */ - srcPixels = (const void*)((const Uint8*)srcPixels + rect->h * srcPitch); + srcPixels = (const void *)((const Uint8 *)srcPixels + rect->h * srcPitch); - if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureNV, 2, rect->x / 2, rect->y / 2, ((rect->w + 1) / 2), (rect->h + 1) / 2, srcPixels, 2*((srcPitch + 1) / 2)) < 0) { + if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureNV, 2, rect->x / 2, rect->y / 2, ((rect->w + 1) / 2), (rect->h + 1) / 2, srcPixels, 2 * ((srcPitch + 1) / 2)) < 0) { return -1; } } @@ -1418,12 +1376,11 @@ D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, } #if SDL_HAVE_YUV -static int -D3D11_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *Uplane, int Upitch, - const Uint8 *Vplane, int Vpitch) +static int D3D11_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) { D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; @@ -1444,11 +1401,10 @@ D3D11_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, return 0; } -static int -D3D11_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *UVplane, int UVpitch) +static int D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch) { D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; @@ -1468,12 +1424,11 @@ D3D11_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, } #endif -static int -D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, void **pixels, int *pitch) +static int D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, void **pixels, int *pitch) { - D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; - D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata; + D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; + D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; HRESULT result = S_OK; D3D11_TEXTURE2D_DESC stagingTextureDesc; D3D11_MAPPED_SUBRESOURCE textureMemory; @@ -1494,7 +1449,7 @@ D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, textureData->locked_rect = *rect; *pixels = (void *)((Uint8 *)textureData->pixels + rect->y * textureData->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); + rect->x * SDL_BYTESPERPIXEL(texture->format)); *pitch = textureData->pitch; return 0; } @@ -1502,7 +1457,7 @@ D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, if (textureData->stagingTexture) { return SDL_SetError("texture is already locked"); } - + /* Create a 'staging' texture, which will be used to write to a portion * of the main texture. This is necessary, as Direct3D 11.1 does not * have the ability to write a CPU-bound pixel buffer to a rectangular @@ -1519,27 +1474,26 @@ D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, stagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; stagingTextureDesc.Usage = D3D11_USAGE_STAGING; result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, - &stagingTextureDesc, - NULL, - &textureData->stagingTexture); + &stagingTextureDesc, + NULL, + &textureData->stagingTexture); if (FAILED(result)) { return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result); } /* Get a write-only pointer to data in the staging texture: */ result = ID3D11DeviceContext_Map(rendererData->d3dContext, - (ID3D11Resource *)textureData->stagingTexture, - 0, - D3D11_MAP_WRITE, - 0, - &textureMemory - ); + (ID3D11Resource *)textureData->stagingTexture, + 0, + D3D11_MAP_WRITE, + 0, + &textureMemory); if (FAILED(result)) { SAFE_RELEASE(textureData->stagingTexture); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result); } - /* Make note of where the staging texture will be written to + /* Make note of where the staging texture will be written to * (on a call to SDL_UnlockTexture): */ textureData->lockedTexturePositionX = rect->x; @@ -1553,12 +1507,11 @@ D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, return 0; } -static void -D3D11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static void D3D11_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; - D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata; - + D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; + D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; + if (textureData == NULL) { return; } @@ -1566,47 +1519,45 @@ D3D11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) if (textureData->yuv || textureData->nv12) { const SDL_Rect *rect = &textureData->locked_rect; void *pixels = - (void *) ((Uint8 *) textureData->pixels + rect->y * textureData->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); + (void *)((Uint8 *)textureData->pixels + rect->y * textureData->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); D3D11_UpdateTexture(renderer, texture, rect, pixels, textureData->pitch); return; } #endif /* Commit the pixel buffer's changes back to the staging texture: */ ID3D11DeviceContext_Unmap(rendererData->d3dContext, - (ID3D11Resource *)textureData->stagingTexture, - 0); + (ID3D11Resource *)textureData->stagingTexture, + 0); /* Copy the staging texture's contents back to the main texture: */ ID3D11DeviceContext_CopySubresourceRegion(rendererData->d3dContext, - (ID3D11Resource *)textureData->mainTexture, - 0, - textureData->lockedTexturePositionX, - textureData->lockedTexturePositionY, - 0, - (ID3D11Resource *)textureData->stagingTexture, - 0, - NULL); + (ID3D11Resource *)textureData->mainTexture, + 0, + textureData->lockedTexturePositionX, + textureData->lockedTexturePositionY, + 0, + (ID3D11Resource *)textureData->stagingTexture, + 0, + NULL); SAFE_RELEASE(textureData->stagingTexture); } -static void -D3D11_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode) +static void D3D11_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode) { - D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata; - + D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; + if (textureData == NULL) { return; } - textureData->scaleMode = (scaleMode == SDL_ScaleModeNearest) ? D3D11_FILTER_MIN_MAG_MIP_POINT : D3D11_FILTER_MIN_MAG_MIP_LINEAR; + textureData->scaleMode = (scaleMode == SDL_ScaleModeNearest) ? D3D11_FILTER_MIN_MAG_MIP_POINT : D3D11_FILTER_MIN_MAG_MIP_LINEAR; } -static int -D3D11_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +static int D3D11_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) { - D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData = NULL; if (texture == NULL) { @@ -1614,7 +1565,7 @@ D3D11_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) return 0; } - textureData = (D3D11_TextureData *) texture->driverdata; + textureData = (D3D11_TextureData *)texture->driverdata; if (!textureData->mainTextureRenderTargetView) { return SDL_SetError("specified texture is not a render target"); @@ -1625,16 +1576,14 @@ D3D11_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) return 0; } -static int -D3D11_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd) +static int D3D11_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { - return 0; /* nothing to do in this backend. */ + return 0; /* nothing to do in this backend. */ } -static int -D3D11_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) +static int D3D11_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { - VertexPositionColor *verts = (VertexPositionColor *) SDL_AllocateRenderVertices(renderer, count * sizeof (VertexPositionColor), 0, &cmd->data.draw.first); + VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first); int i; SDL_Color color; color.r = cmd->data.draw.r; @@ -1660,15 +1609,14 @@ D3D11_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL return 0; } -static int -D3D11_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, - const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, - int num_vertices, const void *indices, int num_indices, int size_indices, - float scale_x, float scale_y) +static int D3D11_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, + int num_vertices, const void *indices, int num_indices, int size_indices, + float scale_x, float scale_y) { int i; int count = indices ? num_indices : num_vertices; - VertexPositionColor *verts = (VertexPositionColor *) SDL_AllocateRenderVertices(renderer, count * sizeof (VertexPositionColor), 0, &cmd->data.draw.first); + VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first); if (verts == NULL) { return -1; @@ -1690,14 +1638,14 @@ D3D11_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture j = i; } - xy_ = (float *)((char*)xy + j * xy_stride); + xy_ = (float *)((char *)xy + j * xy_stride); verts->pos.x = xy_[0] * scale_x; verts->pos.y = xy_[1] * scale_y; - verts->color = *(SDL_Color*)((char*)color + j * color_stride); + verts->color = *(SDL_Color *)((char *)color + j * color_stride); if (texture) { - float *uv_ = (float *)((char*)uv + j * uv_stride); + float *uv_ = (float *)((char *)uv + j * uv_stride); verts->tex.x = uv_[0]; verts->tex.y = uv_[1]; } else { @@ -1710,29 +1658,27 @@ D3D11_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture return 0; } -static int -D3D11_UpdateVertexBuffer(SDL_Renderer *renderer, - const void * vertexData, size_t dataSizeInBytes) +static int D3D11_UpdateVertexBuffer(SDL_Renderer *renderer, + const void *vertexData, size_t dataSizeInBytes) { - D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; HRESULT result = S_OK; const int vbidx = rendererData->currentVertexBuffer; const UINT stride = sizeof(VertexPositionColor); const UINT offset = 0; if (dataSizeInBytes == 0) { - return 0; /* nothing to do. */ + return 0; /* nothing to do. */ } if (rendererData->vertexBuffers[vbidx] && rendererData->vertexBufferSizes[vbidx] >= dataSizeInBytes) { D3D11_MAPPED_SUBRESOURCE mappedResource; result = ID3D11DeviceContext_Map(rendererData->d3dContext, - (ID3D11Resource *)rendererData->vertexBuffers[vbidx], - 0, - D3D11_MAP_WRITE_DISCARD, - 0, - &mappedResource - ); + (ID3D11Resource *)rendererData->vertexBuffers[vbidx], + 0, + D3D11_MAP_WRITE_DISCARD, + 0, + &mappedResource); if (FAILED(result)) { return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [vertex buffer]"), result); } @@ -1745,7 +1691,7 @@ D3D11_UpdateVertexBuffer(SDL_Renderer *renderer, SAFE_RELEASE(rendererData->vertexBuffers[vbidx]); SDL_zero(vertexBufferDesc); - vertexBufferDesc.ByteWidth = (UINT) dataSizeInBytes; + vertexBufferDesc.ByteWidth = (UINT)dataSizeInBytes; vertexBufferDesc.Usage = D3D11_USAGE_DYNAMIC; vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; vertexBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; @@ -1756,10 +1702,9 @@ D3D11_UpdateVertexBuffer(SDL_Renderer *renderer, vertexBufferData.SysMemSlicePitch = 0; result = ID3D11Device_CreateBuffer(rendererData->d3dDevice, - &vertexBufferDesc, - &vertexBufferData, - &rendererData->vertexBuffers[vbidx] - ); + &vertexBufferDesc, + &vertexBufferData, + &rendererData->vertexBuffers[vbidx]); if (FAILED(result)) { return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateBuffer [vertex buffer]"), result); } @@ -1768,12 +1713,11 @@ D3D11_UpdateVertexBuffer(SDL_Renderer *renderer, } ID3D11DeviceContext_IASetVertexBuffers(rendererData->d3dContext, - 0, - 1, - &rendererData->vertexBuffers[vbidx], - &stride, - &offset - ); + 0, + 1, + &rendererData->vertexBuffers[vbidx], + &stride, + &offset); rendererData->currentVertexBuffer++; if (rendererData->currentVertexBuffer >= SDL_arraysize(rendererData->vertexBuffers)) { @@ -1783,10 +1727,9 @@ D3D11_UpdateVertexBuffer(SDL_Renderer *renderer, return 0; } -static int -D3D11_UpdateViewport(SDL_Renderer * renderer) +static int D3D11_UpdateViewport(SDL_Renderer *renderer) { - D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; const SDL_Rect *viewport = &data->currentViewport; Float4X4 projection; Float4X4 view; @@ -1840,8 +1783,8 @@ D3D11_UpdateViewport(SDL_Renderer * renderer) * for eventual transfer to the GPU. */ data->vertexShaderConstantsData.projectionAndView = MatrixMultiply( - view, - projection); + view, + projection); /* Update the Direct3D viewport, which seems to be aligned to the * swap buffer's coordinate space, which is always in either @@ -1850,15 +1793,15 @@ D3D11_UpdateViewport(SDL_Renderer * renderer) */ swapDimensions = D3D11_IsDisplayRotated90Degrees(rotation); if (swapDimensions) { - orientationAlignedViewport.x = (float) viewport->y; - orientationAlignedViewport.y = (float) viewport->x; - orientationAlignedViewport.w = (float) viewport->h; - orientationAlignedViewport.h = (float) viewport->w; + orientationAlignedViewport.x = (float)viewport->y; + orientationAlignedViewport.y = (float)viewport->x; + orientationAlignedViewport.w = (float)viewport->h; + orientationAlignedViewport.h = (float)viewport->w; } else { - orientationAlignedViewport.x = (float) viewport->x; - orientationAlignedViewport.y = (float) viewport->y; - orientationAlignedViewport.w = (float) viewport->w; - orientationAlignedViewport.h = (float) viewport->h; + orientationAlignedViewport.x = (float)viewport->x; + orientationAlignedViewport.y = (float)viewport->y; + orientationAlignedViewport.w = (float)viewport->w; + orientationAlignedViewport.h = (float)viewport->h; } /* TODO, WinRT: get custom viewports working with non-Landscape modes (Portrait, PortraitFlipped, and LandscapeFlipped) */ @@ -1876,8 +1819,7 @@ D3D11_UpdateViewport(SDL_Renderer * renderer) return 0; } -static ID3D11RenderTargetView * -D3D11_GetCurrentRenderTargetView(SDL_Renderer * renderer) +static ID3D11RenderTargetView *D3D11_GetCurrentRenderTargetView(SDL_Renderer *renderer) { D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; if (data->currentOffscreenRenderTargetView) { @@ -1887,10 +1829,9 @@ D3D11_GetCurrentRenderTargetView(SDL_Renderer * renderer) } } -static int -D3D11_SetDrawState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, ID3D11PixelShader * shader, - const int numShaderResources, ID3D11ShaderResourceView ** shaderResources, - ID3D11SamplerState * sampler, const Float4X4 *matrix) +static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, ID3D11PixelShader *shader, + const int numShaderResources, ID3D11ShaderResourceView **shaderResources, + ID3D11SamplerState *sampler, const Float4X4 *matrix) { D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; @@ -1904,10 +1845,9 @@ D3D11_SetDrawState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, ID3D11 if (renderTargetView != rendererData->currentRenderTargetView) { ID3D11DeviceContext_OMSetRenderTargets(rendererData->d3dContext, - 1, - &renderTargetView, - NULL - ); + 1, + &renderTargetView, + NULL); rendererData->currentRenderTargetView = renderTargetView; } @@ -1980,27 +1920,25 @@ D3D11_SetDrawState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, ID3D11 rendererData->currentSampler = sampler; } - if (updateSubresource == SDL_TRUE || SDL_memcmp(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof (*newmatrix)) != 0) { + if (updateSubresource == SDL_TRUE || SDL_memcmp(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof(*newmatrix)) != 0) { SDL_copyp(&rendererData->vertexShaderConstantsData.model, newmatrix); ID3D11DeviceContext_UpdateSubresource(rendererData->d3dContext, - (ID3D11Resource *)rendererData->vertexShaderConstants, - 0, - NULL, - &rendererData->vertexShaderConstantsData, - 0, - 0 - ); + (ID3D11Resource *)rendererData->vertexShaderConstants, + 0, + NULL, + &rendererData->vertexShaderConstantsData, + 0, + 0); } return 0; } -static int -D3D11_SetCopyState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, const Float4X4 *matrix) +static int D3D11_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const Float4X4 *matrix) { SDL_Texture *texture = cmd->data.draw.texture; - D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; - D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata; + D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; + D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; ID3D11SamplerState *textureSampler; switch (textureData->scaleMode) { @@ -2062,25 +2000,22 @@ D3D11_SetCopyState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, const return D3D11_SetDrawState(renderer, cmd, rendererData->pixelShaders[shader], SDL_arraysize(shaderResources), shaderResources, textureSampler, matrix); - } #endif /* SDL_HAVE_YUV */ return D3D11_SetDrawState(renderer, cmd, rendererData->pixelShaders[SHADER_RGB], 1, &textureData->mainTextureResourceView, textureSampler, matrix); } -static void -D3D11_DrawPrimitives(SDL_Renderer * renderer, D3D11_PRIMITIVE_TOPOLOGY primitiveTopology, const size_t vertexStart, const size_t vertexCount) +static void D3D11_DrawPrimitives(SDL_Renderer *renderer, D3D11_PRIMITIVE_TOPOLOGY primitiveTopology, const size_t vertexStart, const size_t vertexCount) { - D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; ID3D11DeviceContext_IASetPrimitiveTopology(rendererData->d3dContext, primitiveTopology); - ID3D11DeviceContext_Draw(rendererData->d3dContext, (UINT) vertexCount, (UINT) vertexStart); + ID3D11DeviceContext_Draw(rendererData->d3dContext, (UINT)vertexCount, (UINT)vertexStart); } -static int -D3D11_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) +static int D3D11_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) { - D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; const int viewportRotation = D3D11_GetRotationForCurrentRenderTarget(renderer); if (rendererData->currentViewportRotation != viewportRotation) { @@ -2094,92 +2029,99 @@ D3D11_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *ver while (cmd) { switch (cmd->command) { - case SDL_RENDERCMD_SETDRAWCOLOR: { - break; /* this isn't currently used in this render backend. */ - } + case SDL_RENDERCMD_SETDRAWCOLOR: + { + break; /* this isn't currently used in this render backend. */ + } - case SDL_RENDERCMD_SETVIEWPORT: { - SDL_Rect *viewport = &rendererData->currentViewport; - if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { - SDL_copyp(viewport, &cmd->data.viewport.rect); - rendererData->viewportDirty = SDL_TRUE; - } - break; + case SDL_RENDERCMD_SETVIEWPORT: + { + SDL_Rect *viewport = &rendererData->currentViewport; + if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { + SDL_copyp(viewport, &cmd->data.viewport.rect); + rendererData->viewportDirty = SDL_TRUE; } + break; + } - case SDL_RENDERCMD_SETCLIPRECT: { - const SDL_Rect *rect = &cmd->data.cliprect.rect; - if (rendererData->currentCliprectEnabled != cmd->data.cliprect.enabled) { - rendererData->currentCliprectEnabled = cmd->data.cliprect.enabled; - rendererData->cliprectDirty = SDL_TRUE; - } - if (SDL_memcmp(&rendererData->currentCliprect, rect, sizeof(*rect)) != 0) { - SDL_copyp(&rendererData->currentCliprect, rect); - rendererData->cliprectDirty = SDL_TRUE; - } - break; + case SDL_RENDERCMD_SETCLIPRECT: + { + const SDL_Rect *rect = &cmd->data.cliprect.rect; + if (rendererData->currentCliprectEnabled != cmd->data.cliprect.enabled) { + rendererData->currentCliprectEnabled = cmd->data.cliprect.enabled; + rendererData->cliprectDirty = SDL_TRUE; } - - case SDL_RENDERCMD_CLEAR: { - const float colorRGBA[] = { - (cmd->data.color.r / 255.0f), - (cmd->data.color.g / 255.0f), - (cmd->data.color.b / 255.0f), - (cmd->data.color.a / 255.0f) - }; - ID3D11DeviceContext_ClearRenderTargetView(rendererData->d3dContext, D3D11_GetCurrentRenderTargetView(renderer), colorRGBA); - break; + if (SDL_memcmp(&rendererData->currentCliprect, rect, sizeof(*rect)) != 0) { + SDL_copyp(&rendererData->currentCliprect, rect); + rendererData->cliprectDirty = SDL_TRUE; } + break; + } - case SDL_RENDERCMD_DRAW_POINTS: { - const size_t count = cmd->data.draw.count; - const size_t first = cmd->data.draw.first; - const size_t start = first / sizeof (VertexPositionColor); + case SDL_RENDERCMD_CLEAR: + { + const float colorRGBA[] = { + (cmd->data.color.r / 255.0f), + (cmd->data.color.g / 255.0f), + (cmd->data.color.b / 255.0f), + (cmd->data.color.a / 255.0f) + }; + ID3D11DeviceContext_ClearRenderTargetView(rendererData->d3dContext, D3D11_GetCurrentRenderTargetView(renderer), colorRGBA); + break; + } + + case SDL_RENDERCMD_DRAW_POINTS: + { + const size_t count = cmd->data.draw.count; + const size_t first = cmd->data.draw.first; + const size_t start = first / sizeof(VertexPositionColor); + D3D11_SetDrawState(renderer, cmd, rendererData->pixelShaders[SHADER_SOLID], 0, NULL, NULL, NULL); + D3D11_DrawPrimitives(renderer, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST, start, count); + break; + } + + case SDL_RENDERCMD_DRAW_LINES: + { + const size_t count = cmd->data.draw.count; + const size_t first = cmd->data.draw.first; + const size_t start = first / sizeof(VertexPositionColor); + const VertexPositionColor *verts = (VertexPositionColor *)(((Uint8 *)vertices) + first); + D3D11_SetDrawState(renderer, cmd, rendererData->pixelShaders[SHADER_SOLID], 0, NULL, NULL, NULL); + D3D11_DrawPrimitives(renderer, D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP, start, count); + if (verts[0].pos.x != verts[count - 1].pos.x || verts[0].pos.y != verts[count - 1].pos.y) { + D3D11_DrawPrimitives(renderer, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST, start + (count - 1), 1); + } + break; + } + + case SDL_RENDERCMD_FILL_RECTS: /* unused */ + break; + + case SDL_RENDERCMD_COPY: /* unused */ + break; + + case SDL_RENDERCMD_COPY_EX: /* unused */ + break; + + case SDL_RENDERCMD_GEOMETRY: + { + SDL_Texture *texture = cmd->data.draw.texture; + const size_t count = cmd->data.draw.count; + const size_t first = cmd->data.draw.first; + const size_t start = first / sizeof(VertexPositionColor); + + if (texture) { + D3D11_SetCopyState(renderer, cmd, NULL); + } else { D3D11_SetDrawState(renderer, cmd, rendererData->pixelShaders[SHADER_SOLID], 0, NULL, NULL, NULL); - D3D11_DrawPrimitives(renderer, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST, start, count); - break; } - case SDL_RENDERCMD_DRAW_LINES: { - const size_t count = cmd->data.draw.count; - const size_t first = cmd->data.draw.first; - const size_t start = first / sizeof (VertexPositionColor); - const VertexPositionColor *verts = (VertexPositionColor *) (((Uint8 *) vertices) + first); - D3D11_SetDrawState(renderer, cmd, rendererData->pixelShaders[SHADER_SOLID], 0, NULL, NULL, NULL); - D3D11_DrawPrimitives(renderer, D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP, start, count); - if (verts[0].pos.x != verts[count - 1].pos.x || verts[0].pos.y != verts[count - 1].pos.y) { - D3D11_DrawPrimitives(renderer, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST, start + (count-1), 1); - } - break; - } + D3D11_DrawPrimitives(renderer, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, start, count); + break; + } - case SDL_RENDERCMD_FILL_RECTS: /* unused */ - break; - - case SDL_RENDERCMD_COPY: /* unused */ - break; - - case SDL_RENDERCMD_COPY_EX: /* unused */ - break; - - case SDL_RENDERCMD_GEOMETRY: { - SDL_Texture *texture = cmd->data.draw.texture; - const size_t count = cmd->data.draw.count; - const size_t first = cmd->data.draw.first; - const size_t start = first / sizeof (VertexPositionColor); - - if (texture) { - D3D11_SetCopyState(renderer, cmd, NULL); - } else { - D3D11_SetDrawState(renderer, cmd, rendererData->pixelShaders[SHADER_SOLID], 0, NULL, NULL, NULL); - } - - D3D11_DrawPrimitives(renderer, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, start, count); - break; - } - - case SDL_RENDERCMD_NO_OP: - break; + case SDL_RENDERCMD_NO_OP: + break; } cmd = cmd->next; @@ -2188,18 +2130,17 @@ D3D11_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *ver return 0; } -static int -D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, void * pixels, int pitch) +static int D3D11_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, + Uint32 format, void *pixels, int pitch) { - D3D11_RenderData * data = (D3D11_RenderData *) renderer->driverdata; + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; ID3D11RenderTargetView *renderTargetView = NULL; ID3D11Texture2D *backBuffer = NULL; ID3D11Texture2D *stagingTexture = NULL; HRESULT result; int status = -1; D3D11_TEXTURE2D_DESC stagingTextureDesc; - D3D11_RECT srcRect = {0, 0, 0, 0}; + D3D11_RECT srcRect = { 0, 0, 0, 0 }; D3D11_BOX srcBox; D3D11_MAPPED_SUBRESOURCE textureMemory; @@ -2209,7 +2150,7 @@ D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, goto done; } - ID3D11View_GetResource(renderTargetView, (ID3D11Resource**)&backBuffer); + ID3D11View_GetResource(renderTargetView, (ID3D11Resource **)&backBuffer); if (backBuffer == NULL) { SDL_SetError("%s, ID3D11View::GetResource failed", __FUNCTION__); goto done; @@ -2224,9 +2165,9 @@ D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, stagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; stagingTextureDesc.Usage = D3D11_USAGE_STAGING; result = ID3D11Device_CreateTexture2D(data->d3dDevice, - &stagingTextureDesc, - NULL, - &stagingTexture); + &stagingTextureDesc, + NULL, + &stagingTexture); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result); goto done; @@ -2245,20 +2186,20 @@ D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, srcBox.front = 0; srcBox.back = 1; ID3D11DeviceContext_CopySubresourceRegion(data->d3dContext, - (ID3D11Resource *)stagingTexture, - 0, - 0, 0, 0, - (ID3D11Resource *)backBuffer, - 0, - &srcBox); + (ID3D11Resource *)stagingTexture, + 0, + 0, 0, 0, + (ID3D11Resource *)backBuffer, + 0, + &srcBox); /* Map the staging texture's data to CPU-accessible memory: */ result = ID3D11DeviceContext_Map(data->d3dContext, - (ID3D11Resource *)stagingTexture, - 0, - D3D11_MAP_READ, - 0, - &textureMemory); + (ID3D11Resource *)stagingTexture, + 0, + D3D11_MAP_READ, + 0, + &textureMemory); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result); goto done; @@ -2278,8 +2219,8 @@ D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, /* Unmap the texture: */ ID3D11DeviceContext_Unmap(data->d3dContext, - (ID3D11Resource *)stagingTexture, - 0); + (ID3D11Resource *)stagingTexture, + 0); done: SAFE_RELEASE(backBuffer); @@ -2287,10 +2228,9 @@ done: return status; } -static int -D3D11_RenderPresent(SDL_Renderer * renderer) +static int D3D11_RenderPresent(SDL_Renderer *renderer) { - D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; UINT syncInterval; UINT presentFlags; HRESULT result; @@ -2322,13 +2262,13 @@ D3D11_RenderPresent(SDL_Renderer * renderer) * This is a valid operation only when the existing contents will be entirely * overwritten. If dirty or scroll rects are used, this call should be removed. */ - ID3D11DeviceContext1_DiscardView(data->d3dContext, (ID3D11View*)data->mainRenderTargetView); + ID3D11DeviceContext1_DiscardView(data->d3dContext, (ID3D11View *)data->mainRenderTargetView); /* When the present flips, it unbinds the current view, so bind it again on the next draw call */ data->currentRenderTargetView = NULL; if (FAILED(result) && result != DXGI_ERROR_WAS_STILL_DRAWING) { - /* If the device was removed either by a disconnect or a driver upgrade, we + /* If the device was removed either by a disconnect or a driver upgrade, we * must recreate all device resources. * * TODO, WinRT: consider throwing an exception if D3D11_RenderPresent fails, especially if there is a way to salvage debug info from users' machines @@ -2347,10 +2287,9 @@ D3D11_RenderPresent(SDL_Renderer * renderer) } #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP - /* no-op. */ +/* no-op. */ #else -static int -D3D11_SetVSync(SDL_Renderer * renderer, const int vsync) +static int D3D11_SetVSync(SDL_Renderer *renderer, const int vsync) { if (vsync) { renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; @@ -2362,18 +2301,18 @@ D3D11_SetVSync(SDL_Renderer * renderer, const int vsync) #endif SDL_Renderer * -D3D11_CreateRenderer(SDL_Window * window, Uint32 flags) +D3D11_CreateRenderer(SDL_Window *window, Uint32 flags) { SDL_Renderer *renderer; D3D11_RenderData *data; - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); if (renderer == NULL) { SDL_OutOfMemory(); return NULL; } - data = (D3D11_RenderData *) SDL_calloc(1, sizeof(*data)); + data = (D3D11_RenderData *)SDL_calloc(1, sizeof(*data)); if (data == NULL) { SDL_free(renderer); SDL_OutOfMemory(); @@ -2398,9 +2337,9 @@ D3D11_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->SetTextureScaleMode = D3D11_SetTextureScaleMode; renderer->SetRenderTarget = D3D11_SetRenderTarget; renderer->QueueSetViewport = D3D11_QueueSetViewport; - renderer->QueueSetDrawColor = D3D11_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */ + renderer->QueueSetDrawColor = D3D11_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */ renderer->QueueDrawPoints = D3D11_QueueDrawPoints; - renderer->QueueDrawLines = D3D11_QueueDrawPoints; /* lines and points queue vertices the same way. */ + renderer->QueueDrawLines = D3D11_QueueDrawPoints; /* lines and points queue vertices the same way. */ renderer->QueueGeometry = D3D11_QueueGeometry; renderer->RunCommandQueue = D3D11_RunCommandQueue; renderer->RenderReadPixels = D3D11_RenderReadPixels; @@ -2420,8 +2359,8 @@ D3D11_CreateRenderer(SDL_Window * window, Uint32 flags) * * - with the D3D11 debug runtime turned ON, vsync gets automatically * turned back on, and the following gets output to the debug console: - * - * DXGI ERROR: IDXGISwapChain::Present: Interval 0 is not supported, changed to Interval 1. [ UNKNOWN ERROR #1024: ] + * + * DXGI ERROR: IDXGISwapChain::Present: Interval 0 is not supported, changed to Interval 1. [ UNKNOWN ERROR #1024: ] */ renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; #else @@ -2456,19 +2395,17 @@ SDL_RenderDriver D3D11_RenderDriver = { ( SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | - SDL_RENDERER_TARGETTEXTURE - ), /* flags. see SDL_RendererFlags */ - 6, /* num_texture_formats */ - { /* texture_formats */ - SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_RGB888, - SDL_PIXELFORMAT_YV12, - SDL_PIXELFORMAT_IYUV, - SDL_PIXELFORMAT_NV12, - SDL_PIXELFORMAT_NV21 - }, - 0, /* max_texture_width: will be filled in later */ - 0 /* max_texture_height: will be filled in later */ + SDL_RENDERER_TARGETTEXTURE), /* flags. see SDL_RendererFlags */ + 6, /* num_texture_formats */ + { /* texture_formats */ + SDL_PIXELFORMAT_ARGB8888, + SDL_PIXELFORMAT_RGB888, + SDL_PIXELFORMAT_YV12, + SDL_PIXELFORMAT_IYUV, + SDL_PIXELFORMAT_NV12, + SDL_PIXELFORMAT_NV21 }, + 0, /* max_texture_width: will be filled in later */ + 0 /* max_texture_height: will be filled in later */ } }; @@ -2477,12 +2414,12 @@ SDL_RenderDriver D3D11_RenderDriver = { #if defined(__WIN32__) || defined(__WINGDK__) /* This function needs to always exist on Windows, for the Dynamic API. */ ID3D11Device * -SDL_RenderGetD3D11Device(SDL_Renderer * renderer) +SDL_RenderGetD3D11Device(SDL_Renderer *renderer) { ID3D11Device *device = NULL; #if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED - D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; /* Make sure that this is a D3D renderer */ if (renderer->DestroyRenderer != D3D11_DestroyRenderer) { diff --git a/src/render/direct3d11/SDL_render_winrt.cpp b/src/render/direct3d11/SDL_render_winrt.cpp index 7fb4fa673..9c9a6371a 100644 --- a/src/render/direct3d11/SDL_render_winrt.cpp +++ b/src/render/direct3d11/SDL_render_winrt.cpp @@ -42,11 +42,10 @@ using namespace Windows::Graphics::Display; #include "SDL_render_winrt.h" - extern "C" void * -D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer) +D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer *renderer) { - SDL_Window * sdlWindow = renderer->window; + SDL_Window *sdlWindow = renderer->window; if (renderer->window == NULL) { return NULL; } @@ -110,7 +109,6 @@ D3D11_GetCurrentRotation() return DXGI_MODE_ROTATION_IDENTITY; } - #endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/direct3d11/SDL_render_winrt.h b/src/render/direct3d11/SDL_render_winrt.h index 97d27cb27..507f8e076 100644 --- a/src/render/direct3d11/SDL_render_winrt.h +++ b/src/render/direct3d11/SDL_render_winrt.h @@ -28,7 +28,7 @@ extern "C" { #endif -void * D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer); +void *D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer *renderer); DXGI_MODE_ROTATION D3D11_GetCurrentRotation(); #ifdef __cplusplus diff --git a/src/render/direct3d11/SDL_shaders_d3d11.c b/src/render/direct3d11/SDL_shaders_d3d11.c index 3a6807b5f..bb1daeb37 100644 --- a/src/render/direct3d11/SDL_shaders_d3d11.c +++ b/src/render/direct3d11/SDL_shaders_d3d11.c @@ -32,7 +32,6 @@ #define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str - /* Direct3D 11.x shaders SDL's shaders are compiled into SDL itself, to simplify distribution. @@ -52,7 +51,7 @@ - vs_4_0_level_9_1: Vertex shader for Windows 8+, including Windows RT - ps_4_0_level_9_3: Pixel shader for Windows Phone 8 - vs_4_0_level_9_3: Vertex shader for Windows Phone 8 - + Shader object code was converted to a list of DWORDs via the following *nix style command (available separately from Windows + MSVC): @@ -1905,8 +1904,7 @@ static struct int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vertexShader, ID3D11InputLayout **inputLayout) { /* Declare how the input layout for SDL's vertex shader will be setup: */ - const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = - { + const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = { { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 }, @@ -1915,23 +1913,21 @@ int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vert /* Load in SDL's one and only vertex shader: */ result = ID3D11Device_CreateVertexShader(d3dDevice, - D3D11_VertexShader, - sizeof(D3D11_VertexShader), - NULL, - vertexShader - ); + D3D11_VertexShader, + sizeof(D3D11_VertexShader), + NULL, + vertexShader); if (FAILED(result)) { return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateVertexShader"), result); } /* Create an input layout for SDL's vertex shader: */ result = ID3D11Device_CreateInputLayout(d3dDevice, - vertexDesc, - ARRAYSIZE(vertexDesc), - D3D11_VertexShader, - sizeof(D3D11_VertexShader), - inputLayout - ); + vertexDesc, + ARRAYSIZE(vertexDesc), + D3D11_VertexShader, + sizeof(D3D11_VertexShader), + inputLayout); if (FAILED(result)) { return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateInputLayout"), result); } @@ -1943,11 +1939,10 @@ int D3D11_CreatePixelShader(ID3D11Device1 *d3dDevice, D3D11_Shader shader, ID3D1 HRESULT result; result = ID3D11Device_CreatePixelShader(d3dDevice, - D3D11_shaders[shader].shader_data, - D3D11_shaders[shader].shader_size, - NULL, - pixelShader - ); + D3D11_shaders[shader].shader_data, + D3D11_shaders[shader].shader_size, + NULL, + pixelShader); if (FAILED(result)) { return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreatePixelShader"), result); } diff --git a/src/render/direct3d11/SDL_shaders_d3d11.h b/src/render/direct3d11/SDL_shaders_d3d11.h index d877c0906..03867ce3d 100644 --- a/src/render/direct3d11/SDL_shaders_d3d11.h +++ b/src/render/direct3d11/SDL_shaders_d3d11.h @@ -22,7 +22,8 @@ /* D3D11 shader implementation */ -typedef enum { +typedef enum +{ SHADER_SOLID, SHADER_RGB, #if SDL_HAVE_YUV diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c index 2f7fcd490..75c003034 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/src/render/direct3d12/SDL_render_d3d12.c @@ -25,9 +25,9 @@ #if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED -#define SDL_D3D12_NUM_BUFFERS 2 +#define SDL_D3D12_NUM_BUFFERS 2 #define SDL_D3D12_NUM_VERTEX_BUFFERS 256 -#define SDL_D3D12_MAX_NUM_TEXTURES 16384 +#define SDL_D3D12_MAX_NUM_TEXTURES 16384 #define SDL_D3D12_NUM_UPLOAD_BUFFERS 32 #include "../../core/windows/SDL_windows.h" @@ -59,15 +59,23 @@ #endif #ifdef __cplusplus -#define SAFE_RELEASE(X) if (X) { (X)->Release(); X = NULL; } -#define D3D_CALL(THIS, FUNC, ...) (THIS)->FUNC(__VA_ARGS__) +#define SAFE_RELEASE(X) \ + if (X) { \ + (X)->Release(); \ + X = NULL; \ + } +#define D3D_CALL(THIS, FUNC, ...) (THIS)->FUNC(__VA_ARGS__) #define D3D_CALL_RET(THIS, FUNC, RETVAL, ...) *(RETVAL) = (THIS)->FUNC(__VA_ARGS__) -#define D3D_GUID(X) (X) +#define D3D_GUID(X) (X) #else -#define SAFE_RELEASE(X) if (X) { (X)->lpVtbl->Release(X); X = NULL; } -#define D3D_CALL(THIS, FUNC, ...) (THIS)->lpVtbl->FUNC((THIS), ##__VA_ARGS__) +#define SAFE_RELEASE(X) \ + if (X) { \ + (X)->lpVtbl->Release(X); \ + X = NULL; \ + } +#define D3D_CALL(THIS, FUNC, ...) (THIS)->lpVtbl->FUNC((THIS), ##__VA_ARGS__) #define D3D_CALL_RET(THIS, FUNC, ...) (THIS)->lpVtbl->FUNC((THIS), ##__VA_ARGS__) -#define D3D_GUID(X) &(X) +#define D3D_GUID(X) &(X) #endif /* Set up for C function definitions, even when using C++ */ @@ -141,7 +149,7 @@ typedef struct } D3D12_PipelineState; /* Vertex Buffer */ -typedef struct +typedef struct { ID3D12Resource *resource; D3D12_VERTEX_BUFFER_VIEW view; @@ -176,12 +184,12 @@ typedef struct UINT swapFlags; /* Descriptor heaps */ - ID3D12DescriptorHeap* rtvDescriptorHeap; + ID3D12DescriptorHeap *rtvDescriptorHeap; UINT rtvDescriptorSize; - ID3D12DescriptorHeap* textureRTVDescriptorHeap; - ID3D12DescriptorHeap* srvDescriptorHeap; + ID3D12DescriptorHeap *textureRTVDescriptorHeap; + ID3D12DescriptorHeap *srvDescriptorHeap; UINT srvDescriptorSize; - ID3D12DescriptorHeap* samplerDescriptorHeap; + ID3D12DescriptorHeap *samplerDescriptorHeap; UINT samplerDescriptorSize; /* Data needed per backbuffer */ @@ -189,7 +197,7 @@ typedef struct ID3D12Resource *renderTargets[SDL_D3D12_NUM_BUFFERS]; UINT64 fenceValue; int currentBackBufferIndex; - + /* Fences */ ID3D12Fence *fence; HANDLE fenceEvent; @@ -214,10 +222,10 @@ typedef struct /* Vertex buffer constants */ VertexShaderConstants vertexShaderConstantsData; - + /* Cached renderer properties */ DXGI_MODE_ROTATION rotation; - D3D12_TextureData* textureRenderTarget; + D3D12_TextureData *textureRenderTarget; D3D12_CPU_DESCRIPTOR_HANDLE currentRenderTargetView; D3D12_CPU_DESCRIPTOR_HANDLE currentShaderResource; D3D12_CPU_DESCRIPTOR_HANDLE currentSampler; @@ -232,7 +240,6 @@ typedef struct SDL_bool issueBatch; } D3D12_RenderData; - /* Define D3D GUIDs here so we don't have to include uuid.lib. */ #if defined(__GNUC__) || defined(__clang__) @@ -246,7 +253,7 @@ static const GUID SDL_IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0 static const GUID SDL_IID_ID3D12Device1 = { 0x77acce80, 0x638e, 0x4e65, { 0x88, 0x95, 0xc1, 0xf2, 0x33, 0x86, 0x86, 0x3e } }; static const GUID SDL_IID_IDXGISwapChain4 = { 0x3D585D5A, 0xBD4A, 0x489E, { 0xB1, 0xF4, 0x3D, 0xBC, 0xB6, 0x45, 0x2F, 0xFB } }; static const GUID SDL_IID_IDXGIDebug1 = { 0xc5a05f0c, 0x16f2, 0x4adf, { 0x9f, 0x4d, 0xa8, 0xc4, 0xd5, 0x8a, 0xc5, 0x50 } }; -static const GUID SDL_IID_IDXGIInfoQueue = { 0xD67441C7,0x672A,0x476f, { 0x9E,0x82,0xCD,0x55,0xB4,0x49,0x49,0xCE } }; +static const GUID SDL_IID_IDXGIInfoQueue = { 0xD67441C7, 0x672A, 0x476f, { 0x9E, 0x82, 0xCD, 0x55, 0xB4, 0x49, 0x49, 0xCE } }; static const GUID SDL_IID_ID3D12Debug = { 0x344488b7, 0x6846, 0x474b, { 0xb9, 0x89, 0xf0, 0x27, 0x44, 0x82, 0x45, 0xe0 } }; static const GUID SDL_DXGI_DEBUG_ALL = { 0xe48ae283, 0xda80, 0x490b, { 0x87, 0xe6, 0x43, 0xe9, 0xa9, 0xcf, 0xda, 0x8 } }; static const GUID SDL_IID_ID3D12CommandQueue = { 0x0ec870a6, 0x5d7e, 0x4c22, { 0x8c, 0xfc, 0x5b, 0xaa, 0xe0, 0x76, 0x16, 0xed } }; @@ -264,9 +271,7 @@ static const GUID SDL_IID_ID3D12InfoQueue = { 0x0742a90b, 0xc387, 0x483f, { 0xb9 #pragma GCC diagnostic pop #endif - -UINT -D3D12_Align(UINT location, UINT alignment) +UINT D3D12_Align(UINT location, UINT alignment) { return (location + (alignment - 1)) & ~(alignment - 1); } @@ -275,39 +280,37 @@ Uint32 D3D12_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat) { switch (dxgiFormat) { - case DXGI_FORMAT_B8G8R8A8_UNORM: - return SDL_PIXELFORMAT_ARGB8888; - case DXGI_FORMAT_B8G8R8X8_UNORM: - return SDL_PIXELFORMAT_RGB888; - default: - return SDL_PIXELFORMAT_UNKNOWN; + case DXGI_FORMAT_B8G8R8A8_UNORM: + return SDL_PIXELFORMAT_ARGB8888; + case DXGI_FORMAT_B8G8R8X8_UNORM: + return SDL_PIXELFORMAT_RGB888; + default: + return SDL_PIXELFORMAT_UNKNOWN; } } -static DXGI_FORMAT -SDLPixelFormatToDXGIFormat(Uint32 sdlFormat) +static DXGI_FORMAT SDLPixelFormatToDXGIFormat(Uint32 sdlFormat) { switch (sdlFormat) { - case SDL_PIXELFORMAT_ARGB8888: - return DXGI_FORMAT_B8G8R8A8_UNORM; - case SDL_PIXELFORMAT_RGB888: - return DXGI_FORMAT_B8G8R8X8_UNORM; - case SDL_PIXELFORMAT_YV12: - case SDL_PIXELFORMAT_IYUV: - case SDL_PIXELFORMAT_NV12: /* For the Y texture */ - case SDL_PIXELFORMAT_NV21: /* For the Y texture */ - return DXGI_FORMAT_R8_UNORM; - default: - return DXGI_FORMAT_UNKNOWN; + case SDL_PIXELFORMAT_ARGB8888: + return DXGI_FORMAT_B8G8R8A8_UNORM; + case SDL_PIXELFORMAT_RGB888: + return DXGI_FORMAT_B8G8R8X8_UNORM; + case SDL_PIXELFORMAT_YV12: + case SDL_PIXELFORMAT_IYUV: + case SDL_PIXELFORMAT_NV12: /* For the Y texture */ + case SDL_PIXELFORMAT_NV21: /* For the Y texture */ + return DXGI_FORMAT_R8_UNORM; + default: + return DXGI_FORMAT_UNKNOWN; } } -static void D3D12_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static void D3D12_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture); -static void -D3D12_ReleaseAll(SDL_Renderer * renderer) +static void D3D12_ReleaseAll(SDL_Renderer *renderer) { - D3D12_RenderData *data = (D3D12_RenderData *) renderer->driverdata; + D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; SDL_Texture *texture = NULL; /* Release all textures */ @@ -355,8 +358,8 @@ D3D12_ReleaseAll(SDL_Renderer * renderer) SAFE_RELEASE(data->vertexBuffers[i].resource); data->vertexBuffers[i].size = 0; } - - data->swapEffect = (DXGI_SWAP_EFFECT) 0; + + data->swapEffect = (DXGI_SWAP_EFFECT)0; data->swapFlags = 0; data->currentRenderTargetView.ptr = 0; data->currentSampler.ptr = 0; @@ -384,33 +387,30 @@ D3D12_ReleaseAll(SDL_Renderer * renderer) } } -static D3D12_GPU_DESCRIPTOR_HANDLE -D3D12_CPUtoGPUHandle(ID3D12DescriptorHeap * heap, D3D12_CPU_DESCRIPTOR_HANDLE CPUHandle) +static D3D12_GPU_DESCRIPTOR_HANDLE D3D12_CPUtoGPUHandle(ID3D12DescriptorHeap *heap, D3D12_CPU_DESCRIPTOR_HANDLE CPUHandle) { D3D12_CPU_DESCRIPTOR_HANDLE CPUHeapStart; D3D12_GPU_DESCRIPTOR_HANDLE GPUHandle; SIZE_T offset; - + /* Calculate the correct offset into the heap */ D3D_CALL_RET(heap, GetCPUDescriptorHandleForHeapStart, &CPUHeapStart); offset = CPUHandle.ptr - CPUHeapStart.ptr; - + D3D_CALL_RET(heap, GetGPUDescriptorHandleForHeapStart, &GPUHandle); GPUHandle.ptr += offset; return GPUHandle; } -static void -D3D12_WaitForGPU(D3D12_RenderData * data) +static void D3D12_WaitForGPU(D3D12_RenderData *data) { if (data->commandQueue && data->fence && data->fenceEvent) { D3D_CALL(data->commandQueue, Signal, data->fence, data->fenceValue); if (D3D_CALL(data->fence, GetCompletedValue) < data->fenceValue) { D3D_CALL(data->fence, SetEventOnCompletion, - data->fenceValue, - data->fenceEvent - ); + data->fenceValue, + data->fenceEvent); WaitForSingleObjectEx(data->fenceEvent, INFINITE, FALSE); } @@ -418,10 +418,9 @@ D3D12_WaitForGPU(D3D12_RenderData * data) } } -static D3D12_CPU_DESCRIPTOR_HANDLE -D3D12_GetCurrentRenderTargetView(SDL_Renderer * renderer) +static D3D12_CPU_DESCRIPTOR_HANDLE D3D12_GetCurrentRenderTargetView(SDL_Renderer *renderer) { - D3D12_RenderData* data = (D3D12_RenderData*)renderer->driverdata; + D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; D3D12_CPU_DESCRIPTOR_HANDLE rtvDescriptor; if (data->textureRenderTarget) { @@ -434,12 +433,10 @@ D3D12_GetCurrentRenderTargetView(SDL_Renderer * renderer) return rtvDescriptor; } -static void -D3D12_TransitionResource(D3D12_RenderData * data, - ID3D12Resource * resource, - D3D12_RESOURCE_STATES beforeState, - D3D12_RESOURCE_STATES afterState -) +static void D3D12_TransitionResource(D3D12_RenderData *data, + ID3D12Resource *resource, + D3D12_RESOURCE_STATES beforeState, + D3D12_RESOURCE_STATES afterState) { D3D12_RESOURCE_BARRIER barrier; @@ -455,8 +452,7 @@ D3D12_TransitionResource(D3D12_RenderData * data, } } -static void -D3D12_ResetCommandList(D3D12_RenderData * data) +static void D3D12_ResetCommandList(D3D12_RenderData *data) { int i; ID3D12DescriptorHeap *rootDescriptorHeaps[] = { data->srvDescriptorHeap, data->samplerDescriptorHeap }; @@ -480,8 +476,7 @@ D3D12_ResetCommandList(D3D12_RenderData * data) D3D_CALL(data->commandList, SetDescriptorHeaps, 2, rootDescriptorHeaps); } -static int -D3D12_IssueBatch(D3D12_RenderData * data) +static int D3D12_IssueBatch(D3D12_RenderData *data) { HRESULT result = S_OK; @@ -491,19 +486,18 @@ D3D12_IssueBatch(D3D12_RenderData * data) WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D12_IssueBatch"), result); return result; } - D3D_CALL(data->commandQueue, ExecuteCommandLists, 1, (ID3D12CommandList* const*)&data->commandList); + D3D_CALL(data->commandQueue, ExecuteCommandLists, 1, (ID3D12CommandList *const *)&data->commandList); D3D12_WaitForGPU(data); - + D3D12_ResetCommandList(data); return result; } -static void -D3D12_DestroyRenderer(SDL_Renderer * renderer) +static void D3D12_DestroyRenderer(SDL_Renderer *renderer) { - D3D12_RenderData *data = (D3D12_RenderData *) renderer->driverdata; + D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; D3D12_WaitForGPU(data); D3D12_ReleaseAll(renderer); if (data) { @@ -512,15 +506,13 @@ D3D12_DestroyRenderer(SDL_Renderer * renderer) SDL_free(renderer); } -static int -D3D12_GetOutputSize(SDL_Renderer *renderer, int *w, int *h) +static int D3D12_GetOutputSize(SDL_Renderer *renderer, int *w, int *h) { SDL_GetWindowSizeInPixels(renderer->window, w, h); return 0; } -static D3D12_BLEND -GetBlendFunc(SDL_BlendFactor factor) +static D3D12_BLEND GetBlendFunc(SDL_BlendFactor factor) { switch (factor) { case SDL_BLENDFACTOR_ZERO: @@ -548,8 +540,7 @@ GetBlendFunc(SDL_BlendFactor factor) } } -static D3D12_BLEND_OP -GetBlendEquation(SDL_BlendOperation operation) +static D3D12_BLEND_OP GetBlendEquation(SDL_BlendOperation operation) { switch (operation) { case SDL_BLENDOPERATION_ADD: @@ -567,8 +558,7 @@ GetBlendEquation(SDL_BlendOperation operation) } } -static void -D3D12_CreateBlendState(SDL_Renderer * renderer, SDL_BlendMode blendMode, D3D12_BLEND_DESC * outBlendDesc) +static void D3D12_CreateBlendState(SDL_Renderer *renderer, SDL_BlendMode blendMode, D3D12_BLEND_DESC *outBlendDesc) { SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); @@ -590,23 +580,21 @@ D3D12_CreateBlendState(SDL_Renderer * renderer, SDL_BlendMode blendMode, D3D12_B outBlendDesc->RenderTarget[0].RenderTargetWriteMask = D3D12_COLOR_WRITE_ENABLE_ALL; } -static D3D12_PipelineState * -D3D12_CreatePipelineState(SDL_Renderer * renderer, - D3D12_Shader shader, - SDL_BlendMode blendMode, - D3D12_PRIMITIVE_TOPOLOGY_TYPE topology, - DXGI_FORMAT rtvFormat - ) +static D3D12_PipelineState *D3D12_CreatePipelineState(SDL_Renderer *renderer, + D3D12_Shader shader, + SDL_BlendMode blendMode, + D3D12_PRIMITIVE_TOPOLOGY_TYPE topology, + DXGI_FORMAT rtvFormat) { const D3D12_INPUT_ELEMENT_DESC vertexDesc[] = { { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 16, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, }; - D3D12_RenderData* data = (D3D12_RenderData*)renderer->driverdata; + D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; D3D12_GRAPHICS_PIPELINE_STATE_DESC pipelineDesc; - ID3D12PipelineState* pipelineState = NULL; - D3D12_PipelineState* pipelineStates; + ID3D12PipelineState *pipelineState = NULL; + D3D12_PipelineState *pipelineStates; HRESULT result = S_OK; SDL_zero(pipelineDesc); @@ -637,16 +625,15 @@ D3D12_CreatePipelineState(SDL_Renderer * renderer, pipelineDesc.SampleDesc.Quality = 0; result = D3D_CALL(data->d3dDevice, CreateGraphicsPipelineState, - &pipelineDesc, - D3D_GUID(SDL_IID_ID3D12PipelineState), - (void **)&pipelineState - ); + &pipelineDesc, + D3D_GUID(SDL_IID_ID3D12PipelineState), + (void **)&pipelineState); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateGraphicsPipelineState"), result); return NULL; } - pipelineStates = (D3D12_PipelineState*)SDL_realloc(data->pipelineStates, (data->pipelineStateCount + 1) * sizeof(*pipelineStates)); + pipelineStates = (D3D12_PipelineState *)SDL_realloc(data->pipelineStates, (data->pipelineStateCount + 1) * sizeof(*pipelineStates)); if (pipelineStates == NULL) { SAFE_RELEASE(pipelineState); SDL_OutOfMemory(); @@ -664,8 +651,7 @@ D3D12_CreatePipelineState(SDL_Renderer * renderer, return &pipelineStates[data->pipelineStateCount - 1]; } -static HRESULT -D3D12_CreateVertexBuffer(D3D12_RenderData *data, size_t vbidx, size_t size) +static HRESULT D3D12_CreateVertexBuffer(D3D12_RenderData *data, size_t vbidx, size_t size) { D3D12_HEAP_PROPERTIES vbufferHeapProps; D3D12_RESOURCE_DESC vbufferDesc; @@ -692,14 +678,13 @@ D3D12_CreateVertexBuffer(D3D12_RenderData *data, size_t vbidx, size_t size) vbufferDesc.Flags = D3D12_RESOURCE_FLAG_NONE; result = D3D_CALL(data->d3dDevice, CreateCommittedResource, - &vbufferHeapProps, - D3D12_HEAP_FLAG_NONE, - &vbufferDesc, - D3D12_RESOURCE_STATE_GENERIC_READ, - NULL, - D3D_GUID(SDL_IID_ID3D12Resource), - (void **) &data->vertexBuffers[vbidx].resource - ); + &vbufferHeapProps, + D3D12_HEAP_FLAG_NONE, + &vbufferDesc, + D3D12_RESOURCE_STATE_GENERIC_READ, + NULL, + D3D_GUID(SDL_IID_ID3D12Resource), + (void **)&data->vertexBuffers[vbidx].resource); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreatePlacedResource [vertex buffer]"), result); @@ -714,19 +699,18 @@ D3D12_CreateVertexBuffer(D3D12_RenderData *data, size_t vbidx, size_t size) } /* Create resources that depend on the device. */ -static HRESULT -D3D12_CreateDeviceResources(SDL_Renderer* renderer) +static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) { #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) - typedef HRESULT(WINAPI* PFN_CREATE_DXGI_FACTORY)(UINT flags, REFIID riid, void** ppFactory); + typedef HRESULT(WINAPI * PFN_CREATE_DXGI_FACTORY)(UINT flags, REFIID riid, void **ppFactory); PFN_CREATE_DXGI_FACTORY CreateDXGIFactoryFunc; PFN_D3D12_CREATE_DEVICE D3D12CreateDeviceFunc; #endif - typedef HANDLE(WINAPI* PFN_CREATE_EVENT_EX)(LPSECURITY_ATTRIBUTES lpEventAttributes, LPCWSTR lpName, DWORD dwFlags, DWORD dwDesiredAccess); + typedef HANDLE(WINAPI * PFN_CREATE_EVENT_EX)(LPSECURITY_ATTRIBUTES lpEventAttributes, LPCWSTR lpName, DWORD dwFlags, DWORD dwDesiredAccess); PFN_CREATE_EVENT_EX CreateEventExFunc; - D3D12_RenderData* data = (D3D12_RenderData*)renderer->driverdata; - ID3D12Device* d3dDevice = NULL; + D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; + ID3D12Device *d3dDevice = NULL; HRESULT result = S_OK; UINT creationFlags = 0; int i, j, k, l; @@ -761,7 +745,7 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer) HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll")); CreateEventExFunc = NULL; if (kernel32) { - CreateEventExFunc = (PFN_CREATE_EVENT_EX) GetProcAddress(kernel32, "CreateEventExW"); + CreateEventExFunc = (PFN_CREATE_EVENT_EX)GetProcAddress(kernel32, "CreateEventExW"); } } #endif @@ -803,7 +787,7 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer) result = E_FAIL; goto done; } - D3D12GetDebugInterfaceFunc(D3D_GUID(SDL_IID_ID3D12Debug), (void**)&data->debugInterface); + D3D12GetDebugInterfaceFunc(D3D_GUID(SDL_IID_ID3D12Debug), (void **)&data->debugInterface); D3D_CALL(data->debugInterface, EnableDebugLayer); } #endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ @@ -846,7 +830,7 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer) creationFlags = DXGI_CREATE_FACTORY_DEBUG; } - result = CreateDXGIFactoryFunc(creationFlags, D3D_GUID(SDL_IID_IDXGIFactory6), (void**)&data->dxgiFactory); + result = CreateDXGIFactoryFunc(creationFlags, D3D_GUID(SDL_IID_IDXGIFactory6), (void **)&data->dxgiFactory); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("CreateDXGIFactory"), result); goto done; @@ -854,21 +838,19 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer) /* Prefer a high performance adapter if there are multiple choices */ result = D3D_CALL(data->dxgiFactory, EnumAdapterByGpuPreference, - 0, - DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE, - D3D_GUID(SDL_IID_IDXGIAdapter4), - (void **)&data->dxgiAdapter - ); + 0, + DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE, + D3D_GUID(SDL_IID_IDXGIAdapter4), + (void **)&data->dxgiAdapter); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D12CreateDevice"), result); goto done; } - + result = D3D12CreateDeviceFunc((IUnknown *)data->dxgiAdapter, - D3D_FEATURE_LEVEL_11_0, /* Request minimum feature level 11.0 for maximum compatibility */ - D3D_GUID(SDL_IID_ID3D12Device1), - (void **)&d3dDevice - ); + D3D_FEATURE_LEVEL_11_0, /* Request minimum feature level 11.0 for maximum compatibility */ + D3D_GUID(SDL_IID_ID3D12Device1), + (void **)&d3dDevice); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D12CreateDevice"), result); goto done; @@ -910,10 +892,9 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer) queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; result = D3D_CALL(data->d3dDevice, CreateCommandQueue, - &queueDesc, - D3D_GUID(SDL_IID_ID3D12CommandQueue), - (void **)&data->commandQueue - ); + &queueDesc, + D3D_GUID(SDL_IID_ID3D12CommandQueue), + (void **)&data->commandQueue); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateCommandQueue"), result); goto done; @@ -924,10 +905,9 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer) descriptorHeapDesc.NumDescriptors = SDL_D3D12_NUM_BUFFERS; descriptorHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; result = D3D_CALL(data->d3dDevice, CreateDescriptorHeap, - &descriptorHeapDesc, - D3D_GUID(SDL_IID_ID3D12DescriptorHeap), - (void **)&data->rtvDescriptorHeap - ); + &descriptorHeapDesc, + D3D_GUID(SDL_IID_ID3D12DescriptorHeap), + (void **)&data->rtvDescriptorHeap); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateDescriptorHeap [rtv]"), result); goto done; @@ -936,10 +916,9 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer) descriptorHeapDesc.NumDescriptors = SDL_D3D12_MAX_NUM_TEXTURES; result = D3D_CALL(data->d3dDevice, CreateDescriptorHeap, - &descriptorHeapDesc, - D3D_GUID(SDL_IID_ID3D12DescriptorHeap), - (void **)&data->textureRTVDescriptorHeap - ); + &descriptorHeapDesc, + D3D_GUID(SDL_IID_ID3D12DescriptorHeap), + (void **)&data->textureRTVDescriptorHeap); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateDescriptorHeap [texture rtv]"), result); goto done; @@ -950,10 +929,9 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer) descriptorHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; descriptorHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; result = D3D_CALL(data->d3dDevice, CreateDescriptorHeap, - &descriptorHeapDesc, - D3D_GUID(SDL_IID_ID3D12DescriptorHeap), - (void **)&data->srvDescriptorHeap - ); + &descriptorHeapDesc, + D3D_GUID(SDL_IID_ID3D12DescriptorHeap), + (void **)&data->srvDescriptorHeap); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateDescriptorHeap [srv]"), result); goto done; @@ -966,10 +944,9 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer) descriptorHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER; descriptorHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; result = D3D_CALL(data->d3dDevice, CreateDescriptorHeap, - &descriptorHeapDesc, - D3D_GUID(SDL_IID_ID3D12DescriptorHeap), - (void **)&data->samplerDescriptorHeap - ); + &descriptorHeapDesc, + D3D_GUID(SDL_IID_ID3D12DescriptorHeap), + (void **)&data->samplerDescriptorHeap); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateDescriptorHeap [sampler]"), result); goto done; @@ -980,10 +957,9 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer) /* Create a command allocator for each back buffer */ for (i = 0; i < SDL_D3D12_NUM_BUFFERS; ++i) { result = D3D_CALL(data->d3dDevice, CreateCommandAllocator, - D3D12_COMMAND_LIST_TYPE_DIRECT, - D3D_GUID(SDL_IID_ID3D12CommandAllocator), - (void **)&data->commandAllocators[i] - ); + D3D12_COMMAND_LIST_TYPE_DIRECT, + D3D_GUID(SDL_IID_ID3D12CommandAllocator), + (void **)&data->commandAllocators[i]); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateCommandAllocator"), result); goto done; @@ -992,13 +968,12 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer) /* Create the command list */ result = D3D_CALL(data->d3dDevice, CreateCommandList, - 0, - D3D12_COMMAND_LIST_TYPE_DIRECT, - data->commandAllocators[0], - NULL, - D3D_GUID(SDL_IID_ID3D12GraphicsCommandList2), - (void **)&data->commandList - ); + 0, + D3D12_COMMAND_LIST_TYPE_DIRECT, + data->commandAllocators[0], + NULL, + D3D_GUID(SDL_IID_ID3D12GraphicsCommandList2), + (void **)&data->commandList); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateCommandList"), result); goto done; @@ -1009,11 +984,10 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer) /* Create the fence and fence event */ result = D3D_CALL(data->d3dDevice, CreateFence, - data->fenceValue, - D3D12_FENCE_FLAG_NONE, - D3D_GUID(SDL_IID_ID3D12Fence), - (void **)&data->fence - ); + data->fenceValue, + D3D12_FENCE_FLAG_NONE, + D3D_GUID(SDL_IID_ID3D12Fence), + (void **)&data->fence); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateFence"), result); goto done; @@ -1030,14 +1004,13 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer) /* Create all the root signatures */ for (i = 0; i < NUM_ROOTSIGS; ++i) { D3D12_SHADER_BYTECODE rootSigData; - D3D12_GetRootSignatureData((D3D12_RootSignature) i, &rootSigData); + D3D12_GetRootSignatureData((D3D12_RootSignature)i, &rootSigData); result = D3D_CALL(data->d3dDevice, CreateRootSignature, - 0, - rootSigData.pShaderBytecode, - rootSigData.BytecodeLength, - D3D_GUID(SDL_IID_ID3D12RootSignature), - (void **)&data->rootSignatures[i] - ); + 0, + rootSigData.pShaderBytecode, + rootSigData.BytecodeLength, + D3D_GUID(SDL_IID_ID3D12RootSignature), + (void **)&data->rootSignatures[i]); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateRootSignature"), result); goto done; @@ -1050,7 +1023,7 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer) for (j = 0; j < SDL_arraysize(defaultBlendModes); ++j) { for (k = D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT; k < D3D12_PRIMITIVE_TOPOLOGY_TYPE_PATCH; ++k) { for (l = 0; l < SDL_arraysize(defaultRTVFormats); ++l) { - if (!D3D12_CreatePipelineState(renderer, (D3D12_Shader) i, defaultBlendModes[j], (D3D12_PRIMITIVE_TOPOLOGY_TYPE) k, defaultRTVFormats[l])) { + if (!D3D12_CreatePipelineState(renderer, (D3D12_Shader)i, defaultBlendModes[j], (D3D12_PRIMITIVE_TOPOLOGY_TYPE)k, defaultRTVFormats[l])) { /* D3D12_CreatePipelineState will set the SDL error, if it fails */ goto done; } @@ -1095,27 +1068,24 @@ done: return result; } -static DXGI_MODE_ROTATION -D3D12_GetCurrentRotation() +static DXGI_MODE_ROTATION D3D12_GetCurrentRotation() { /* FIXME */ return DXGI_MODE_ROTATION_IDENTITY; } -static BOOL -D3D12_IsDisplayRotated90Degrees(DXGI_MODE_ROTATION rotation) +static BOOL D3D12_IsDisplayRotated90Degrees(DXGI_MODE_ROTATION rotation) { switch (rotation) { - case DXGI_MODE_ROTATION_ROTATE90: - case DXGI_MODE_ROTATION_ROTATE270: - return TRUE; - default: - return FALSE; + case DXGI_MODE_ROTATION_ROTATE90: + case DXGI_MODE_ROTATION_ROTATE270: + return TRUE; + default: + return FALSE; } } -static int -D3D12_GetRotationForCurrentRenderTarget(SDL_Renderer * renderer) +static int D3D12_GetRotationForCurrentRenderTarget(SDL_Renderer *renderer) { D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; if (data->textureRenderTarget) { @@ -1125,53 +1095,51 @@ D3D12_GetRotationForCurrentRenderTarget(SDL_Renderer * renderer) } } -static int -D3D12_GetViewportAlignedD3DRect(SDL_Renderer * renderer, const SDL_Rect * sdlRect, D3D12_RECT * outRect, BOOL includeViewportOffset) +static int D3D12_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rect *sdlRect, D3D12_RECT *outRect, BOOL includeViewportOffset) { - D3D12_RenderData *data = (D3D12_RenderData *) renderer->driverdata; + D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; const int rotation = D3D12_GetRotationForCurrentRenderTarget(renderer); const SDL_Rect *viewport = &data->currentViewport; switch (rotation) { - case DXGI_MODE_ROTATION_IDENTITY: - outRect->left = sdlRect->x; - outRect->right = sdlRect->x + sdlRect->w; - outRect->top = sdlRect->y; - outRect->bottom = sdlRect->y + sdlRect->h; - if (includeViewportOffset) { - outRect->left += viewport->x; - outRect->right += viewport->x; - outRect->top += viewport->y; - outRect->bottom += viewport->y; - } - break; - case DXGI_MODE_ROTATION_ROTATE270: - outRect->left = sdlRect->y; - outRect->right = sdlRect->y + sdlRect->h; - outRect->top = viewport->w - sdlRect->x - sdlRect->w; - outRect->bottom = viewport->w - sdlRect->x; - break; - case DXGI_MODE_ROTATION_ROTATE180: - outRect->left = viewport->w - sdlRect->x - sdlRect->w; - outRect->right = viewport->w - sdlRect->x; - outRect->top = viewport->h - sdlRect->y - sdlRect->h; - outRect->bottom = viewport->h - sdlRect->y; - break; - case DXGI_MODE_ROTATION_ROTATE90: - outRect->left = viewport->h - sdlRect->y - sdlRect->h; - outRect->right = viewport->h - sdlRect->y; - outRect->top = sdlRect->x; - outRect->bottom = sdlRect->x + sdlRect->h; - break; - default: - return SDL_SetError("The physical display is in an unknown or unsupported rotation"); + case DXGI_MODE_ROTATION_IDENTITY: + outRect->left = sdlRect->x; + outRect->right = sdlRect->x + sdlRect->w; + outRect->top = sdlRect->y; + outRect->bottom = sdlRect->y + sdlRect->h; + if (includeViewportOffset) { + outRect->left += viewport->x; + outRect->right += viewport->x; + outRect->top += viewport->y; + outRect->bottom += viewport->y; + } + break; + case DXGI_MODE_ROTATION_ROTATE270: + outRect->left = sdlRect->y; + outRect->right = sdlRect->y + sdlRect->h; + outRect->top = viewport->w - sdlRect->x - sdlRect->w; + outRect->bottom = viewport->w - sdlRect->x; + break; + case DXGI_MODE_ROTATION_ROTATE180: + outRect->left = viewport->w - sdlRect->x - sdlRect->w; + outRect->right = viewport->w - sdlRect->x; + outRect->top = viewport->h - sdlRect->y - sdlRect->h; + outRect->bottom = viewport->h - sdlRect->y; + break; + case DXGI_MODE_ROTATION_ROTATE90: + outRect->left = viewport->h - sdlRect->y - sdlRect->h; + outRect->right = viewport->h - sdlRect->y; + outRect->top = sdlRect->x; + outRect->bottom = sdlRect->x + sdlRect->h; + break; + default: + return SDL_SetError("The physical display is in an unknown or unsupported rotation"); } return 0; } #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) -static HRESULT -D3D12_CreateSwapChain(SDL_Renderer * renderer, int w, int h) +static HRESULT D3D12_CreateSwapChain(SDL_Renderer *renderer, int w, int h) { D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; IDXGISwapChain1* swapChain; @@ -1194,21 +1162,20 @@ D3D12_CreateSwapChain(SDL_Renderer * renderer, int w, int h) } else { swapChainDesc.Scaling = DXGI_SCALING_STRETCH; } - swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; /* All Windows Store apps must use this SwapEffect. */ + swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; /* All Windows Store apps must use this SwapEffect. */ swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT | /* To support SetMaximumFrameLatency */ - DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; /* To support presenting with allow tearing on */ + DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; /* To support presenting with allow tearing on */ SDL_VERSION(&windowinfo.version); SDL_GetWindowWMInfo(renderer->window, &windowinfo); result = D3D_CALL(data->dxgiFactory, CreateSwapChainForHwnd, - (IUnknown *)data->commandQueue, - windowinfo.info.win.window, - &swapChainDesc, - NULL, - NULL, /* Allow on all displays. */ - &swapChain - ); + (IUnknown *)data->commandQueue, + windowinfo.info.win.window, + &swapChainDesc, + NULL, + NULL, /* Allow on all displays. */ + &swapChain); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForHwnd"), result); goto done; @@ -1240,11 +1207,10 @@ done: } #endif -static HRESULT D3D12_UpdateForWindowSizeChange(SDL_Renderer * renderer); - +static HRESULT D3D12_UpdateForWindowSizeChange(SDL_Renderer *renderer); HRESULT -D3D12_HandleDeviceLost(SDL_Renderer * renderer) +D3D12_HandleDeviceLost(SDL_Renderer *renderer) { HRESULT result = S_OK; @@ -1273,8 +1239,7 @@ D3D12_HandleDeviceLost(SDL_Renderer * renderer) } /* Initialize all resources that change when the window's size changes. */ -static HRESULT -D3D12_CreateWindowSizeDependentResources(SDL_Renderer * renderer) +static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer) { D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; HRESULT result = S_OK; @@ -1307,16 +1272,15 @@ D3D12_CreateWindowSizeDependentResources(SDL_Renderer * renderer) if (data->swapChain) { /* If the swap chain already exists, resize it. */ result = D3D_CALL(data->swapChain, ResizeBuffers, - 0, - w, h, - DXGI_FORMAT_UNKNOWN, - data->swapFlags - ); + 0, + w, h, + DXGI_FORMAT_UNKNOWN, + data->swapFlags); if (result == DXGI_ERROR_DEVICE_REMOVED) { /* If the device was removed for any reason, a new device and swap chain will need to be created. */ D3D12_HandleDeviceLost(renderer); - /* Everything is set up now. Do not continue execution of this method. HandleDeviceLost will reenter this method + /* Everything is set up now. Do not continue execution of this method. HandleDeviceLost will reenter this method * and correctly set up the new device. */ goto done; @@ -1330,7 +1294,7 @@ D3D12_CreateWindowSizeDependentResources(SDL_Renderer * renderer) goto done; } } - + /* Set the proper rotation for the swap chain. */ if (WIN_IsWindows8OrGreater()) { if (data->swapEffect == DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL) { @@ -1346,17 +1310,16 @@ D3D12_CreateWindowSizeDependentResources(SDL_Renderer * renderer) /* Get each back buffer render target and create render target views */ for (i = 0; i < SDL_D3D12_NUM_BUFFERS; ++i) { #if defined(__XBOXONE__) || defined(__XBOXSERIES__) - result = D3D12_XBOX_CreateBackBufferTarget(data->d3dDevice, renderer->window->w, renderer->window->h, (void **) &data->renderTargets[i]); + result = D3D12_XBOX_CreateBackBufferTarget(data->d3dDevice, renderer->window->w, renderer->window->h, (void **)&data->renderTargets[i]); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D12_XBOX_CreateBackBufferTarget"), result); goto done; } #else result = D3D_CALL(data->swapChain, GetBuffer, - i, - D3D_GUID(SDL_IID_ID3D12Resource), - (void **) &data->renderTargets[i] - ); + i, + D3D_GUID(SDL_IID_ID3D12Resource), + (void **)&data->renderTargets[i]); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain4::GetBuffer"), result); goto done; @@ -1387,10 +1350,9 @@ D3D12_CreateWindowSizeDependentResources(SDL_Renderer * renderer) data->currentRenderTargetView = D3D12_GetCurrentRenderTargetView(renderer); D3D_CALL(data->commandList, OMSetRenderTargets, 1, &data->currentRenderTargetView, FALSE, NULL); D3D12_TransitionResource(data, - data->renderTargets[data->currentBackBufferIndex], - D3D12_RESOURCE_STATE_PRESENT, - D3D12_RESOURCE_STATE_RENDER_TARGET - ); + data->renderTargets[data->currentBackBufferIndex], + D3D12_RESOURCE_STATE_PRESENT, + D3D12_RESOURCE_STATE_RENDER_TARGET); data->viewportDirty = SDL_TRUE; @@ -1403,25 +1365,22 @@ done: } /* This method is called when the window's size changes. */ -static HRESULT -D3D12_UpdateForWindowSizeChange(SDL_Renderer * renderer) +static HRESULT D3D12_UpdateForWindowSizeChange(SDL_Renderer *renderer) { - D3D12_RenderData* data = (D3D12_RenderData*)renderer->driverdata; + D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; /* If the GPU has previous work, wait for it to be done first */ D3D12_WaitForGPU(data); return D3D12_CreateWindowSizeDependentResources(renderer); } -static void -D3D12_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +static void D3D12_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event) { if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { D3D12_UpdateForWindowSizeChange(renderer); } } -static SDL_bool -D3D12_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +static SDL_bool D3D12_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); @@ -1439,13 +1398,12 @@ D3D12_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) return SDL_TRUE; } -static SIZE_T -D3D12_GetAvailableSRVIndex(SDL_Renderer * renderer) +static SIZE_T D3D12_GetAvailableSRVIndex(SDL_Renderer *renderer) { - D3D12_RenderData* rendererData = (D3D12_RenderData*)renderer->driverdata; + D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; if (rendererData->srvPoolHead) { SIZE_T index = rendererData->srvPoolHead->index; - rendererData->srvPoolHead = (D3D12_SRVPoolNode*)(rendererData->srvPoolHead->next); + rendererData->srvPoolHead = (D3D12_SRVPoolNode *)(rendererData->srvPoolHead->next); return index; } else { SDL_SetError("[d3d12] Cannot allocate more than %d textures!", SDL_D3D12_MAX_NUM_TEXTURES); @@ -1453,18 +1411,16 @@ D3D12_GetAvailableSRVIndex(SDL_Renderer * renderer) } } -static void -D3D12_FreeSRVIndex(SDL_Renderer * renderer, SIZE_T index) +static void D3D12_FreeSRVIndex(SDL_Renderer *renderer, SIZE_T index) { - D3D12_RenderData* rendererData = (D3D12_RenderData*)renderer->driverdata; + D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; rendererData->srvPoolNodes[index].next = rendererData->srvPoolHead; rendererData->srvPoolHead = &rendererData->srvPoolNodes[index]; } -static int -D3D12_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - D3D12_RenderData *rendererData = (D3D12_RenderData *) renderer->driverdata; + D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData; HRESULT result; DXGI_FORMAT textureFormat = SDLPixelFormatToDXGIFormat(texture->format); @@ -1476,12 +1432,12 @@ D3D12_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) return SDL_SetError("%s, An unsupported SDL pixel format (0x%x) was specified", __FUNCTION__, texture->format); } - textureData = (D3D12_TextureData*) SDL_calloc(1, sizeof(*textureData)); + textureData = (D3D12_TextureData *)SDL_calloc(1, sizeof(*textureData)); if (textureData == NULL) { SDL_OutOfMemory(); return -1; } - textureData->scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? D3D12_FILTER_MIN_MAG_MIP_POINT : D3D12_FILTER_MIN_MAG_MIP_LINEAR; + textureData->scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? D3D12_FILTER_MIN_MAG_MIP_POINT : D3D12_FILTER_MIN_MAG_MIP_LINEAR; texture->driverdata = textureData; textureData->mainTextureFormat = textureFormat; @@ -1507,14 +1463,13 @@ D3D12_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) heapProps.VisibleNodeMask = 1; result = D3D_CALL(rendererData->d3dDevice, CreateCommittedResource, - &heapProps, - D3D12_HEAP_FLAG_NONE, - &textureDesc, - D3D12_RESOURCE_STATE_COPY_DEST, - NULL, - D3D_GUID(SDL_IID_ID3D12Resource), - (void **)&textureData->mainTexture - ); + &heapProps, + D3D12_HEAP_FLAG_NONE, + &textureDesc, + D3D12_RESOURCE_STATE_COPY_DEST, + NULL, + D3D_GUID(SDL_IID_ID3D12Resource), + (void **)&textureData->mainTexture); textureData->mainResourceState = D3D12_RESOURCE_STATE_COPY_DEST; if (FAILED(result)) { D3D12_DestroyTexture(renderer, texture); @@ -1529,14 +1484,13 @@ D3D12_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) textureDesc.Height = (textureDesc.Height + 1) / 2; result = D3D_CALL(rendererData->d3dDevice, CreateCommittedResource, - &heapProps, - D3D12_HEAP_FLAG_NONE, - &textureDesc, - D3D12_RESOURCE_STATE_COPY_DEST, - NULL, - D3D_GUID(SDL_IID_ID3D12Resource), - (void **)&textureData->mainTextureU - ); + &heapProps, + D3D12_HEAP_FLAG_NONE, + &textureDesc, + D3D12_RESOURCE_STATE_COPY_DEST, + NULL, + D3D_GUID(SDL_IID_ID3D12Resource), + (void **)&textureData->mainTextureU); textureData->mainResourceStateU = D3D12_RESOURCE_STATE_COPY_DEST; if (FAILED(result)) { D3D12_DestroyTexture(renderer, texture); @@ -1544,14 +1498,13 @@ D3D12_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) } result = D3D_CALL(rendererData->d3dDevice, CreateCommittedResource, - &heapProps, - D3D12_HEAP_FLAG_NONE, - &textureDesc, - D3D12_RESOURCE_STATE_COPY_DEST, - NULL, - D3D_GUID(SDL_IID_ID3D12Resource), - (void **)&textureData->mainTextureV - ); + &heapProps, + D3D12_HEAP_FLAG_NONE, + &textureDesc, + D3D12_RESOURCE_STATE_COPY_DEST, + NULL, + D3D_GUID(SDL_IID_ID3D12Resource), + (void **)&textureData->mainTextureV); textureData->mainResourceStateV = D3D12_RESOURCE_STATE_COPY_DEST; if (FAILED(result)) { D3D12_DestroyTexture(renderer, texture); @@ -1570,14 +1523,13 @@ D3D12_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) nvTextureDesc.Height = (textureDesc.Height + 1) / 2; result = D3D_CALL(rendererData->d3dDevice, CreateCommittedResource, - &heapProps, - D3D12_HEAP_FLAG_NONE, - &nvTextureDesc, - D3D12_RESOURCE_STATE_COPY_DEST, - NULL, - D3D_GUID(SDL_IID_ID3D12Resource), - (void **)&textureData->mainTextureNV - ); + &heapProps, + D3D12_HEAP_FLAG_NONE, + &nvTextureDesc, + D3D12_RESOURCE_STATE_COPY_DEST, + NULL, + D3D_GUID(SDL_IID_ID3D12Resource), + (void **)&textureData->mainTextureNV); textureData->mainResourceStateNV = D3D12_RESOURCE_STATE_COPY_DEST; if (FAILED(result)) { D3D12_DestroyTexture(renderer, texture); @@ -1597,29 +1549,26 @@ D3D12_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) textureData->mainTextureResourceView.ptr += textureData->mainSRVIndex * rendererData->srvDescriptorSize; D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView, - textureData->mainTexture, - &resourceViewDesc, - textureData->mainTextureResourceView - ); + textureData->mainTexture, + &resourceViewDesc, + textureData->mainTextureResourceView); #if SDL_HAVE_YUV if (textureData->yuv) { D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceViewU); textureData->mainSRVIndexU = D3D12_GetAvailableSRVIndex(renderer); textureData->mainTextureResourceViewU.ptr += textureData->mainSRVIndexU * rendererData->srvDescriptorSize; D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView, - textureData->mainTextureU, - &resourceViewDesc, - textureData->mainTextureResourceViewU - ); + textureData->mainTextureU, + &resourceViewDesc, + textureData->mainTextureResourceViewU); D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceViewV); textureData->mainSRVIndexV = D3D12_GetAvailableSRVIndex(renderer); textureData->mainTextureResourceViewV.ptr += textureData->mainSRVIndexV * rendererData->srvDescriptorSize; D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView, - textureData->mainTextureV, - &resourceViewDesc, - textureData->mainTextureResourceViewV - ); + textureData->mainTextureV, + &resourceViewDesc, + textureData->mainTextureResourceViewV); } if (textureData->nv12) { @@ -1631,10 +1580,9 @@ D3D12_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) textureData->mainSRVIndexNV = D3D12_GetAvailableSRVIndex(renderer); textureData->mainTextureResourceViewNV.ptr += textureData->mainSRVIndexNV * rendererData->srvDescriptorSize; D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView, - textureData->mainTextureNV, - &nvResourceViewDesc, - textureData->mainTextureResourceViewNV - ); + textureData->mainTextureNV, + &nvResourceViewDesc, + textureData->mainTextureResourceViewNV); } #endif /* SDL_HAVE_YUV */ @@ -1649,19 +1597,18 @@ D3D12_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) textureData->mainTextureRenderTargetView.ptr += textureData->mainSRVIndex * rendererData->rtvDescriptorSize; D3D_CALL(rendererData->d3dDevice, CreateRenderTargetView, - (ID3D12Resource*)textureData->mainTexture, - &renderTargetViewDesc, - textureData->mainTextureRenderTargetView); + (ID3D12Resource *)textureData->mainTexture, + &renderTargetViewDesc, + textureData->mainTextureRenderTargetView); } return 0; } -static void -D3D12_DestroyTexture(SDL_Renderer * renderer, - SDL_Texture * texture) +static void D3D12_DestroyTexture(SDL_Renderer *renderer, + SDL_Texture *texture) { - D3D12_RenderData *rendererData = (D3D12_RenderData*)renderer->driverdata; + D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; if (textureData == NULL) { @@ -1692,8 +1639,7 @@ D3D12_DestroyTexture(SDL_Renderer * renderer, texture->driverdata = NULL; } -static int -D3D12_UpdateTextureInternal(D3D12_RenderData * rendererData, ID3D12Resource * texture, int bpp, int x, int y, int w, int h, const void *pixels, int pitch, D3D12_RESOURCE_STATES *resourceState) +static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Resource *texture, int bpp, int x, int y, int w, int h, const void *pixels, int pitch, D3D12_RESOURCE_STATES *resourceState) { const Uint8 *src; Uint8 *dst; @@ -1730,15 +1676,14 @@ D3D12_UpdateTextureInternal(D3D12_RenderData * rendererData, ID3D12Resource * te /* Figure out how much we need to allocate for the upload buffer */ D3D_CALL(rendererData->d3dDevice, GetCopyableFootprints, - &textureDesc, - 0, - 1, - 0, - NULL, - NULL, - NULL, - &uploadDesc.Width - ); + &textureDesc, + 0, + 1, + 0, + NULL, + NULL, + NULL, + &uploadDesc.Width); SDL_zero(heapProps); heapProps.Type = D3D12_HEAP_TYPE_UPLOAD; @@ -1747,14 +1692,13 @@ D3D12_UpdateTextureInternal(D3D12_RenderData * rendererData, ID3D12Resource * te /* Create the upload buffer */ result = D3D_CALL(rendererData->d3dDevice, CreateCommittedResource, - &heapProps, - D3D12_HEAP_FLAG_NONE, - &uploadDesc, - D3D12_RESOURCE_STATE_GENERIC_READ, - NULL, - D3D_GUID(SDL_IID_ID3D12Resource), - (void **)&rendererData->uploadBuffers[rendererData->currentUploadBuffer] - ); + &heapProps, + D3D12_HEAP_FLAG_NONE, + &uploadDesc, + D3D12_RESOURCE_STATE_GENERIC_READ, + NULL, + D3D_GUID(SDL_IID_ID3D12Resource), + (void **)&rendererData->uploadBuffers[rendererData->currentUploadBuffer]); if (FAILED(result)) { return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateCommittedResource [create upload buffer]"), result); } @@ -1762,10 +1706,9 @@ D3D12_UpdateTextureInternal(D3D12_RenderData * rendererData, ID3D12Resource * te /* Get a write-only pointer to data in the upload buffer: */ uploadBuffer = rendererData->uploadBuffers[rendererData->currentUploadBuffer]; result = D3D_CALL(uploadBuffer, Map, - 0, - NULL, - (void **)&textureMemory - ); + 0, + NULL, + (void **)&textureMemory); if (FAILED(result)) { SAFE_RELEASE(rendererData->uploadBuffers[rendererData->currentUploadBuffer]); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Resource::Map [map staging texture]"), result); @@ -1786,7 +1729,7 @@ D3D12_UpdateTextureInternal(D3D12_RenderData * rendererData, ID3D12Resource * te dst = textureMemory; length = w * bpp; if (length == pitch && length == pitchedDesc.RowPitch) { - SDL_memcpy(dst, src, length*h); + SDL_memcpy(dst, src, length * h); } else { if (length > (UINT)pitch) { length = pitch; @@ -1819,18 +1762,17 @@ D3D12_UpdateTextureInternal(D3D12_RenderData * rendererData, ID3D12Resource * te srcLocation.PlacedFootprint = placedTextureDesc; D3D_CALL(rendererData->commandList, CopyTextureRegion, - &dstLocation, - x, - y, - 0, - &srcLocation, - NULL - ); + &dstLocation, + x, + y, + 0, + &srcLocation, + NULL); /* Transition the texture to be shader accessible */ D3D12_TransitionResource(rendererData, texture, *resourceState, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); *resourceState = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; - + rendererData->currentUploadBuffer++; /* If we've used up all the upload buffers, we need to issue the batch */ if (rendererData->currentUploadBuffer == SDL_D3D12_NUM_UPLOAD_BUFFERS) { @@ -1840,10 +1782,9 @@ D3D12_UpdateTextureInternal(D3D12_RenderData * rendererData, ID3D12Resource * te return 0; } -static int -D3D12_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void * srcPixels, - int srcPitch) +static int D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, const void *srcPixels, + int srcPitch) { D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; @@ -1858,14 +1799,14 @@ D3D12_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, #if SDL_HAVE_YUV if (textureData->yuv) { /* Skip to the correct offset into the next texture */ - srcPixels = (const void*)((const Uint8*)srcPixels + rect->h * srcPitch); + srcPixels = (const void *)((const Uint8 *)srcPixels + rect->h * srcPitch); if (D3D12_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureV : textureData->mainTextureU, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, (srcPitch + 1) / 2, texture->format == SDL_PIXELFORMAT_YV12 ? &textureData->mainResourceStateV : &textureData->mainResourceStateU) < 0) { return -1; } /* Skip to the correct offset into the next texture */ - srcPixels = (const void*)((const Uint8*)srcPixels + ((rect->h + 1) / 2) * ((srcPitch + 1) / 2)); + srcPixels = (const void *)((const Uint8 *)srcPixels + ((rect->h + 1) / 2) * ((srcPitch + 1) / 2)); if (D3D12_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureU : textureData->mainTextureV, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, (srcPitch + 1) / 2, texture->format == SDL_PIXELFORMAT_YV12 ? &textureData->mainResourceStateU : &textureData->mainResourceStateV) < 0) { return -1; } @@ -1873,9 +1814,9 @@ D3D12_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, if (textureData->nv12) { /* Skip to the correct offset into the next texture */ - srcPixels = (const void*)((const Uint8*)srcPixels + rect->h * srcPitch); + srcPixels = (const void *)((const Uint8 *)srcPixels + rect->h * srcPitch); - if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTextureNV, 2, rect->x / 2, rect->y / 2, ((rect->w + 1) / 2), (rect->h + 1) / 2, srcPixels, 2*((srcPitch + 1) / 2), &textureData->mainResourceStateNV) < 0) { + if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTextureNV, 2, rect->x / 2, rect->y / 2, ((rect->w + 1) / 2), (rect->h + 1) / 2, srcPixels, 2 * ((srcPitch + 1) / 2), &textureData->mainResourceStateNV) < 0) { return -1; } } @@ -1884,12 +1825,11 @@ D3D12_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, } #if SDL_HAVE_YUV -static int -D3D12_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *Uplane, int Upitch, - const Uint8 *Vplane, int Vpitch) +static int D3D12_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) { D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; @@ -1910,11 +1850,10 @@ D3D12_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, return 0; } -static int -D3D12_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *UVplane, int UVpitch) +static int D3D12_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch) { D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; @@ -1934,12 +1873,11 @@ D3D12_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, } #endif -static int -D3D12_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, void **pixels, int *pitch) +static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, void **pixels, int *pitch) { - D3D12_RenderData *rendererData = (D3D12_RenderData *) renderer->driverdata; - D3D12_TextureData *textureData = (D3D12_TextureData *) texture->driverdata; + D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; + D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; HRESULT result = S_OK; D3D12_RESOURCE_DESC textureDesc; @@ -1965,7 +1903,7 @@ D3D12_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, textureData->lockedRect = *rect; *pixels = (void *)((Uint8 *)textureData->pixels + rect->y * textureData->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); + rect->x * SDL_BYTESPERPIXEL(texture->format)); *pitch = textureData->pitch; return 0; } @@ -1973,7 +1911,7 @@ D3D12_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, if (textureData->stagingBuffer) { return SDL_SetError("texture is already locked"); } - + /* Create an upload buffer, which will be used to write to the main texture. */ SDL_zero(textureDesc); D3D_CALL_RET(textureData->mainTexture, GetDesc, &textureDesc); @@ -1994,15 +1932,14 @@ D3D12_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, /* Figure out how much we need to allocate for the upload buffer */ D3D_CALL(rendererData->d3dDevice, GetCopyableFootprints, - &textureDesc, - 0, - 1, - 0, - NULL, - NULL, - NULL, - &uploadDesc.Width - ); + &textureDesc, + 0, + 1, + 0, + NULL, + NULL, + NULL, + &uploadDesc.Width); SDL_zero(heapProps); heapProps.Type = D3D12_HEAP_TYPE_UPLOAD; @@ -2011,24 +1948,22 @@ D3D12_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, /* Create the upload buffer */ result = D3D_CALL(rendererData->d3dDevice, CreateCommittedResource, - &heapProps, - D3D12_HEAP_FLAG_NONE, - &uploadDesc, - D3D12_RESOURCE_STATE_GENERIC_READ, - NULL, - D3D_GUID(SDL_IID_ID3D12Resource), - (void **)&textureData->stagingBuffer - ); + &heapProps, + D3D12_HEAP_FLAG_NONE, + &uploadDesc, + D3D12_RESOURCE_STATE_GENERIC_READ, + NULL, + D3D_GUID(SDL_IID_ID3D12Resource), + (void **)&textureData->stagingBuffer); if (FAILED(result)) { return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateCommittedResource [create upload buffer]"), result); } /* Get a write-only pointer to data in the upload buffer: */ result = D3D_CALL(textureData->stagingBuffer, Map, - 0, - NULL, - (void **)&textureMemory - ); + 0, + NULL, + (void **)&textureMemory); if (FAILED(result)) { SAFE_RELEASE(rendererData->uploadBuffers[rendererData->currentUploadBuffer]); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Resource::Map [map staging texture]"), result); @@ -2046,7 +1981,7 @@ D3D12_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, } pitchedDesc.RowPitch = D3D12_Align(rect->w * bpp, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT); - /* Make note of where the staging texture will be written to + /* Make note of where the staging texture will be written to * (on a call to SDL_UnlockTexture): */ textureData->lockedRect = *rect; @@ -2059,11 +1994,10 @@ D3D12_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, return 0; } -static void -D3D12_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static void D3D12_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - D3D12_RenderData *rendererData = (D3D12_RenderData *) renderer->driverdata; - D3D12_TextureData *textureData = (D3D12_TextureData *) texture->driverdata; + D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; + D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; D3D12_RESOURCE_DESC textureDesc; D3D12_SUBRESOURCE_FOOTPRINT pitchedDesc; @@ -2071,7 +2005,7 @@ D3D12_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) D3D12_TEXTURE_COPY_LOCATION srcLocation; D3D12_TEXTURE_COPY_LOCATION dstLocation; int bpp; - + if (textureData == NULL) { return; } @@ -2079,8 +2013,8 @@ D3D12_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) if (textureData->yuv || textureData->nv12) { const SDL_Rect *rect = &textureData->lockedRect; void *pixels = - (void *) ((Uint8 *) textureData->pixels + rect->y * textureData->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); + (void *)((Uint8 *)textureData->pixels + rect->y * textureData->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); D3D12_UpdateTexture(renderer, texture, rect, pixels, textureData->pitch); return; } @@ -2123,13 +2057,12 @@ D3D12_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) srcLocation.PlacedFootprint = placedTextureDesc; D3D_CALL(rendererData->commandList, CopyTextureRegion, - &dstLocation, - textureData->lockedRect.x, - textureData->lockedRect.y, - 0, - &srcLocation, - NULL - ); + &dstLocation, + textureData->lockedRect.x, + textureData->lockedRect.y, + 0, + &srcLocation, + NULL); /* Transition the texture to be shader accessible */ D3D12_TransitionResource(rendererData, textureData->mainTexture, textureData->mainResourceState, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); @@ -2140,38 +2073,35 @@ D3D12_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) SAFE_RELEASE(textureData->stagingBuffer); } -static void -D3D12_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode) +static void D3D12_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode) { - D3D12_TextureData *textureData = (D3D12_TextureData *) texture->driverdata; - + D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; + if (textureData == NULL) { return; } - textureData->scaleMode = (scaleMode == SDL_ScaleModeNearest) ? D3D12_FILTER_MIN_MAG_MIP_POINT : D3D12_FILTER_MIN_MAG_MIP_LINEAR; + textureData->scaleMode = (scaleMode == SDL_ScaleModeNearest) ? D3D12_FILTER_MIN_MAG_MIP_POINT : D3D12_FILTER_MIN_MAG_MIP_LINEAR; } -static int -D3D12_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +static int D3D12_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) { - D3D12_RenderData *rendererData = (D3D12_RenderData *) renderer->driverdata; + D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = NULL; if (texture == NULL) { if (rendererData->textureRenderTarget) { D3D12_TransitionResource(rendererData, - rendererData->textureRenderTarget->mainTexture, - rendererData->textureRenderTarget->mainResourceState, - D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE - ); + rendererData->textureRenderTarget->mainTexture, + rendererData->textureRenderTarget->mainResourceState, + D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); rendererData->textureRenderTarget->mainResourceState = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; } rendererData->textureRenderTarget = NULL; return 0; } - textureData = (D3D12_TextureData *) texture->driverdata; + textureData = (D3D12_TextureData *)texture->driverdata; if (!textureData->mainTextureRenderTargetView.ptr) { return SDL_SetError("specified texture is not a render target"); @@ -2179,26 +2109,22 @@ D3D12_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) rendererData->textureRenderTarget = textureData; D3D12_TransitionResource(rendererData, - rendererData->textureRenderTarget->mainTexture, - rendererData->textureRenderTarget->mainResourceState, - D3D12_RESOURCE_STATE_RENDER_TARGET - ); + rendererData->textureRenderTarget->mainTexture, + rendererData->textureRenderTarget->mainResourceState, + D3D12_RESOURCE_STATE_RENDER_TARGET); rendererData->textureRenderTarget->mainResourceState = D3D12_RESOURCE_STATE_RENDER_TARGET; - return 0; } -static int -D3D12_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd) +static int D3D12_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { - return 0; /* nothing to do in this backend. */ + return 0; /* nothing to do in this backend. */ } -static int -D3D12_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) +static int D3D12_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { - VertexPositionColor *verts = (VertexPositionColor *) SDL_AllocateRenderVertices(renderer, count * sizeof (VertexPositionColor), 0, &cmd->data.draw.first); + VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first); int i; SDL_Color color; color.r = cmd->data.draw.r; @@ -2224,15 +2150,14 @@ D3D12_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL return 0; } -static int -D3D12_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, - const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, - int num_vertices, const void *indices, int num_indices, int size_indices, - float scale_x, float scale_y) +static int D3D12_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, + int num_vertices, const void *indices, int num_indices, int size_indices, + float scale_x, float scale_y) { int i; int count = indices ? num_indices : num_vertices; - VertexPositionColor *verts = (VertexPositionColor *) SDL_AllocateRenderVertices(renderer, count * sizeof (VertexPositionColor), 0, &cmd->data.draw.first); + VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first); if (verts == NULL) { return -1; @@ -2254,14 +2179,14 @@ D3D12_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture j = i; } - xy_ = (float *)((char*)xy + j * xy_stride); + xy_ = (float *)((char *)xy + j * xy_stride); verts->pos.x = xy_[0] * scale_x; verts->pos.y = xy_[1] * scale_y; - verts->color = *(SDL_Color*)((char*)color + j * color_stride); + verts->color = *(SDL_Color *)((char *)color + j * color_stride); if (texture) { - float *uv_ = (float *)((char*)uv + j * uv_stride); + float *uv_ = (float *)((char *)uv + j * uv_stride); verts->tex.x = uv_[0]; verts->tex.y = uv_[1]; } else { @@ -2271,25 +2196,24 @@ D3D12_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture verts += 1; } - return 0; + return 0; } -static int -D3D12_UpdateVertexBuffer(SDL_Renderer *renderer, - const void * vertexData, size_t dataSizeInBytes) +static int D3D12_UpdateVertexBuffer(SDL_Renderer *renderer, + const void *vertexData, size_t dataSizeInBytes) { - D3D12_RenderData *rendererData = (D3D12_RenderData *) renderer->driverdata; + D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; HRESULT result = S_OK; const int vbidx = rendererData->currentVertexBuffer; - UINT8* vertexBufferData = NULL; + UINT8 *vertexBufferData = NULL; D3D12_RANGE range; ID3D12Resource *vertexBuffer; range.Begin = 0; range.End = 0; - + if (dataSizeInBytes == 0) { - return 0; /* nothing to do. */ + return 0; /* nothing to do. */ } if (rendererData->issueBatch) { @@ -2325,10 +2249,9 @@ D3D12_UpdateVertexBuffer(SDL_Renderer *renderer, return S_OK; } -static int -D3D12_UpdateViewport(SDL_Renderer * renderer) +static int D3D12_UpdateViewport(SDL_Renderer *renderer) { - D3D12_RenderData *data = (D3D12_RenderData *) renderer->driverdata; + D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; const SDL_Rect *viewport = &data->currentViewport; Float4X4 projection; Float4X4 view; @@ -2382,25 +2305,25 @@ D3D12_UpdateViewport(SDL_Renderer * renderer) * for eventual transfer to the GPU. */ data->vertexShaderConstantsData.projectionAndView = MatrixMultiply( - view, - projection); + view, + projection); /* Update the Direct3D viewport, which seems to be aligned to the * swap buffer's coordinate space, which is always in either * a landscape mode, for all Windows 8/RT devices, or a portrait mode, * for Windows Phone devices. */ - swapDimensions = D3D12_IsDisplayRotated90Degrees((DXGI_MODE_ROTATION) rotation); + swapDimensions = D3D12_IsDisplayRotated90Degrees((DXGI_MODE_ROTATION)rotation); if (swapDimensions) { - orientationAlignedViewport.x = (float) viewport->y; - orientationAlignedViewport.y = (float) viewport->x; - orientationAlignedViewport.w = (float) viewport->h; - orientationAlignedViewport.h = (float) viewport->w; + orientationAlignedViewport.x = (float)viewport->y; + orientationAlignedViewport.y = (float)viewport->x; + orientationAlignedViewport.w = (float)viewport->h; + orientationAlignedViewport.h = (float)viewport->w; } else { - orientationAlignedViewport.x = (float) viewport->x; - orientationAlignedViewport.y = (float) viewport->y; - orientationAlignedViewport.w = (float) viewport->w; - orientationAlignedViewport.h = (float) viewport->h; + orientationAlignedViewport.x = (float)viewport->x; + orientationAlignedViewport.y = (float)viewport->y; + orientationAlignedViewport.w = (float)viewport->w; + orientationAlignedViewport.h = (float)viewport->h; } d3dviewport.TopLeftX = orientationAlignedViewport.x; @@ -2417,11 +2340,10 @@ D3D12_UpdateViewport(SDL_Renderer * renderer) return 0; } -static int -D3D12_SetDrawState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, D3D12_Shader shader, - D3D12_PRIMITIVE_TOPOLOGY_TYPE topology, - const int numShaderResources, D3D12_CPU_DESCRIPTOR_HANDLE * shaderResources, - D3D12_CPU_DESCRIPTOR_HANDLE * sampler, const Float4X4 *matrix) +static int D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, D3D12_Shader shader, + D3D12_PRIMITIVE_TOPOLOGY_TYPE topology, + const int numShaderResources, D3D12_CPU_DESCRIPTOR_HANDLE *shaderResources, + D3D12_CPU_DESCRIPTOR_HANDLE *sampler, const Float4X4 *matrix) { D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; @@ -2443,7 +2365,7 @@ D3D12_SetDrawState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, D3D12_ rendererData->currentPipelineState->blendMode != blendMode || rendererData->currentPipelineState->topology != topology || rendererData->currentPipelineState->rtvFormat != rtvFormat) { - + /* Find the matching pipeline. NOTE: Although it may seem inefficient to linearly search through ~450 pipelines to find the correct one, in profiling this doesn't come up at all. @@ -2452,7 +2374,7 @@ D3D12_SetDrawState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, D3D12_ */ rendererData->currentPipelineState = NULL; for (i = 0; i < rendererData->pipelineStateCount; ++i) { - D3D12_PipelineState* candidatePiplineState = &rendererData->pipelineStates[i]; + D3D12_PipelineState *candidatePiplineState = &rendererData->pipelineStates[i]; if (candidatePiplineState->shader == shader && candidatePiplineState->blendMode == blendMode && candidatePiplineState->topology == topology && @@ -2473,7 +2395,7 @@ D3D12_SetDrawState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, D3D12_ D3D_CALL(rendererData->commandList, SetPipelineState, rendererData->currentPipelineState->pipelineState); D3D_CALL(rendererData->commandList, SetGraphicsRootSignature, - rendererData->rootSignatures[D3D12_GetRootSignatureType(rendererData->currentPipelineState->shader)]); + rendererData->rootSignatures[D3D12_GetRootSignatureType(rendererData->currentPipelineState->shader)]); /* When we change these we will need to re-upload the constant buffer and reset any descriptors */ updateSubresource = SDL_TRUE; rendererData->currentSampler.ptr = 0; @@ -2521,52 +2443,50 @@ D3D12_SetDrawState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, D3D12_ /* Figure out the correct sampler descriptor table index based on the type of shader */ switch (shader) { - case SHADER_RGB: - tableIndex = 2; - break; + case SHADER_RGB: + tableIndex = 2; + break; #if SDL_HAVE_YUV - case SHADER_YUV_JPEG: - case SHADER_YUV_BT601: - case SHADER_YUV_BT709: - tableIndex = 4; - break; - case SHADER_NV12_JPEG: - case SHADER_NV12_BT601: - case SHADER_NV12_BT709: - case SHADER_NV21_JPEG: - case SHADER_NV21_BT601: - case SHADER_NV21_BT709: - tableIndex = 3; - break; + case SHADER_YUV_JPEG: + case SHADER_YUV_BT601: + case SHADER_YUV_BT709: + tableIndex = 4; + break; + case SHADER_NV12_JPEG: + case SHADER_NV12_BT601: + case SHADER_NV12_BT709: + case SHADER_NV21_JPEG: + case SHADER_NV21_BT601: + case SHADER_NV21_BT709: + tableIndex = 3; + break; #endif - default: - return SDL_SetError("[direct3d12] Trying to set a sampler for a shader which doesn't have one"); - break; + default: + return SDL_SetError("[direct3d12] Trying to set a sampler for a shader which doesn't have one"); + break; } D3D_CALL(rendererData->commandList, SetGraphicsRootDescriptorTable, tableIndex, GPUHandle); rendererData->currentSampler = *sampler; } - if (updateSubresource == SDL_TRUE || SDL_memcmp(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof (*newmatrix)) != 0) { - SDL_memcpy(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof (*newmatrix)); + if (updateSubresource == SDL_TRUE || SDL_memcmp(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof(*newmatrix)) != 0) { + SDL_memcpy(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof(*newmatrix)); D3D_CALL(rendererData->commandList, SetGraphicsRoot32BitConstants, - 0, - 32, - &rendererData->vertexShaderConstantsData, - 0 - ); + 0, + 32, + &rendererData->vertexShaderConstantsData, + 0); } return 0; } -static int -D3D12_SetCopyState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, const Float4X4 *matrix) +static int D3D12_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const Float4X4 *matrix) { SDL_Texture *texture = cmd->data.draw.texture; - D3D12_RenderData *rendererData = (D3D12_RenderData *) renderer->driverdata; - D3D12_TextureData *textureData = (D3D12_TextureData *) texture->driverdata; + D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; + D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; D3D12_CPU_DESCRIPTOR_HANDLE *textureSampler; switch (textureData->scaleMode) { @@ -2649,18 +2569,16 @@ D3D12_SetCopyState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, const textureSampler, matrix); } -static void -D3D12_DrawPrimitives(SDL_Renderer * renderer, D3D12_PRIMITIVE_TOPOLOGY primitiveTopology, const size_t vertexStart, const size_t vertexCount) +static void D3D12_DrawPrimitives(SDL_Renderer *renderer, D3D12_PRIMITIVE_TOPOLOGY primitiveTopology, const size_t vertexStart, const size_t vertexCount) { - D3D12_RenderData *rendererData = (D3D12_RenderData *) renderer->driverdata; - D3D_CALL(rendererData->commandList, IASetPrimitiveTopology, primitiveTopology); - D3D_CALL(rendererData->commandList, DrawInstanced, (UINT)vertexCount, 1, (UINT)vertexStart, 0); + D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; + D3D_CALL(rendererData->commandList, IASetPrimitiveTopology, primitiveTopology); + D3D_CALL(rendererData->commandList, DrawInstanced, (UINT)vertexCount, 1, (UINT)vertexStart, 0); } -static int -D3D12_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) +static int D3D12_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) { - D3D12_RenderData *rendererData = (D3D12_RenderData *) renderer->driverdata; + D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; const int viewportRotation = D3D12_GetRotationForCurrentRenderTarget(renderer); if (rendererData->currentViewportRotation != viewportRotation) { @@ -2674,99 +2592,106 @@ D3D12_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *ver while (cmd) { switch (cmd->command) { - case SDL_RENDERCMD_SETDRAWCOLOR: { - break; /* this isn't currently used in this render backend. */ + case SDL_RENDERCMD_SETDRAWCOLOR: + { + break; /* this isn't currently used in this render backend. */ + } + + case SDL_RENDERCMD_SETVIEWPORT: + { + SDL_Rect *viewport = &rendererData->currentViewport; + if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { + SDL_copyp(viewport, &cmd->data.viewport.rect); + rendererData->viewportDirty = SDL_TRUE; + } + break; + } + + case SDL_RENDERCMD_SETCLIPRECT: + { + const SDL_Rect *rect = &cmd->data.cliprect.rect; + if (rendererData->currentCliprectEnabled != cmd->data.cliprect.enabled) { + rendererData->currentCliprectEnabled = cmd->data.cliprect.enabled; + rendererData->cliprectDirty = SDL_TRUE; + } + if (!rendererData->currentCliprectEnabled) { + /* If the clip rect is disabled, then the scissor rect should be the whole viewport, + since direct3d12 doesn't allow disabling the scissor rectangle */ + rect = &rendererData->currentViewport; + } + if (SDL_memcmp(&rendererData->currentCliprect, rect, sizeof(*rect)) != 0) { + SDL_copyp(&rendererData->currentCliprect, rect); + rendererData->cliprectDirty = SDL_TRUE; + } + break; + } + + case SDL_RENDERCMD_CLEAR: + { + const float colorRGBA[] = { + (cmd->data.color.r / 255.0f), + (cmd->data.color.g / 255.0f), + (cmd->data.color.b / 255.0f), + (cmd->data.color.a / 255.0f) + }; + + D3D12_CPU_DESCRIPTOR_HANDLE rtvDescriptor = D3D12_GetCurrentRenderTargetView(renderer); + D3D_CALL(rendererData->commandList, ClearRenderTargetView, rtvDescriptor, colorRGBA, 0, NULL); + break; + } + + case SDL_RENDERCMD_DRAW_POINTS: + { + const size_t count = cmd->data.draw.count; + const size_t first = cmd->data.draw.first; + const size_t start = first / sizeof(VertexPositionColor); + D3D12_SetDrawState(renderer, cmd, SHADER_SOLID, D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT, 0, NULL, NULL, NULL); + D3D12_DrawPrimitives(renderer, D3D_PRIMITIVE_TOPOLOGY_POINTLIST, start, count); + break; + } + + case SDL_RENDERCMD_DRAW_LINES: + { + const size_t count = cmd->data.draw.count; + const size_t first = cmd->data.draw.first; + const size_t start = first / sizeof(VertexPositionColor); + const VertexPositionColor *verts = (VertexPositionColor *)(((Uint8 *)vertices) + first); + D3D12_SetDrawState(renderer, cmd, SHADER_SOLID, D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE, 0, NULL, NULL, NULL); + D3D12_DrawPrimitives(renderer, D3D_PRIMITIVE_TOPOLOGY_LINESTRIP, start, count); + if (verts[0].pos.x != verts[count - 1].pos.x || verts[0].pos.y != verts[count - 1].pos.y) { + D3D12_DrawPrimitives(renderer, D3D_PRIMITIVE_TOPOLOGY_POINTLIST, start + (count - 1), 1); + } + break; + } + + case SDL_RENDERCMD_FILL_RECTS: /* unused */ + break; + + case SDL_RENDERCMD_COPY: /* unused */ + break; + + case SDL_RENDERCMD_COPY_EX: /* unused */ + break; + + case SDL_RENDERCMD_GEOMETRY: + { + SDL_Texture *texture = cmd->data.draw.texture; + const size_t count = cmd->data.draw.count; + const size_t first = cmd->data.draw.first; + const size_t start = first / sizeof(VertexPositionColor); + + if (texture) { + D3D12_SetCopyState(renderer, cmd, NULL); + } else { + D3D12_SetDrawState(renderer, cmd, SHADER_SOLID, D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, 0, NULL, NULL, NULL); } - case SDL_RENDERCMD_SETVIEWPORT: { - SDL_Rect *viewport = &rendererData->currentViewport; - if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { - SDL_copyp(viewport, &cmd->data.viewport.rect); - rendererData->viewportDirty = SDL_TRUE; - } - break; - } + D3D12_DrawPrimitives(renderer, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST, start, count); + break; + } - case SDL_RENDERCMD_SETCLIPRECT: { - const SDL_Rect *rect = &cmd->data.cliprect.rect; - if (rendererData->currentCliprectEnabled != cmd->data.cliprect.enabled) { - rendererData->currentCliprectEnabled = cmd->data.cliprect.enabled; - rendererData->cliprectDirty = SDL_TRUE; - } - if (!rendererData->currentCliprectEnabled) { - /* If the clip rect is disabled, then the scissor rect should be the whole viewport, - since direct3d12 doesn't allow disabling the scissor rectangle */ - rect = &rendererData->currentViewport; - } - if (SDL_memcmp(&rendererData->currentCliprect, rect, sizeof(*rect)) != 0) { - SDL_copyp(&rendererData->currentCliprect, rect); - rendererData->cliprectDirty = SDL_TRUE; - } - break; - } - - case SDL_RENDERCMD_CLEAR: { - const float colorRGBA[] = { - (cmd->data.color.r / 255.0f), - (cmd->data.color.g / 255.0f), - (cmd->data.color.b / 255.0f), - (cmd->data.color.a / 255.0f) - }; - - D3D12_CPU_DESCRIPTOR_HANDLE rtvDescriptor = D3D12_GetCurrentRenderTargetView(renderer); - D3D_CALL(rendererData->commandList, ClearRenderTargetView, rtvDescriptor, colorRGBA, 0, NULL); - break; - } - - case SDL_RENDERCMD_DRAW_POINTS: { - const size_t count = cmd->data.draw.count; - const size_t first = cmd->data.draw.first; - const size_t start = first / sizeof (VertexPositionColor); - D3D12_SetDrawState(renderer, cmd, SHADER_SOLID, D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT, 0, NULL, NULL, NULL); - D3D12_DrawPrimitives(renderer, D3D_PRIMITIVE_TOPOLOGY_POINTLIST, start, count); - break; - } - - case SDL_RENDERCMD_DRAW_LINES: { - const size_t count = cmd->data.draw.count; - const size_t first = cmd->data.draw.first; - const size_t start = first / sizeof (VertexPositionColor); - const VertexPositionColor *verts = (VertexPositionColor *) (((Uint8 *) vertices) + first); - D3D12_SetDrawState(renderer, cmd, SHADER_SOLID, D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE, 0, NULL, NULL, NULL); - D3D12_DrawPrimitives(renderer, D3D_PRIMITIVE_TOPOLOGY_LINESTRIP, start, count); - if (verts[0].pos.x != verts[count - 1].pos.x || verts[0].pos.y != verts[count - 1].pos.y) { - D3D12_DrawPrimitives(renderer, D3D_PRIMITIVE_TOPOLOGY_POINTLIST, start + (count-1), 1); - } - break; - } - - case SDL_RENDERCMD_FILL_RECTS: /* unused */ - break; - - case SDL_RENDERCMD_COPY: /* unused */ - break; - - case SDL_RENDERCMD_COPY_EX: /* unused */ - break; - - case SDL_RENDERCMD_GEOMETRY: { - SDL_Texture *texture = cmd->data.draw.texture; - const size_t count = cmd->data.draw.count; - const size_t first = cmd->data.draw.first; - const size_t start = first / sizeof (VertexPositionColor); - - if (texture) { - D3D12_SetCopyState(renderer, cmd, NULL); - } else { - D3D12_SetDrawState(renderer, cmd, SHADER_SOLID, D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, 0, NULL, NULL, NULL); - } - - D3D12_DrawPrimitives(renderer, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST, start, count); - break; - } - - case SDL_RENDERCMD_NO_OP: - break; + case SDL_RENDERCMD_NO_OP: + break; } cmd = cmd->next; @@ -2775,11 +2700,10 @@ D3D12_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *ver return 0; } -static int -D3D12_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, void * pixels, int pitch) +static int D3D12_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, + Uint32 format, void *pixels, int pitch) { - D3D12_RenderData * data = (D3D12_RenderData *) renderer->driverdata; + D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; ID3D12Resource *backBuffer = NULL; ID3D12Resource *readbackBuffer = NULL; HRESULT result; @@ -2787,7 +2711,7 @@ D3D12_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, D3D12_RESOURCE_DESC textureDesc; D3D12_RESOURCE_DESC readbackDesc; D3D12_HEAP_PROPERTIES heapProps; - D3D12_RECT srcRect = {0, 0, 0, 0}; + D3D12_RECT srcRect = { 0, 0, 0, 0 }; D3D12_BOX srcBox; D3D12_TEXTURE_COPY_LOCATION dstLocation; D3D12_TEXTURE_COPY_LOCATION srcLocation; @@ -2822,30 +2746,28 @@ D3D12_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, /* Figure out how much we need to allocate for the upload buffer */ D3D_CALL(data->d3dDevice, GetCopyableFootprints, - &textureDesc, - 0, - 1, - 0, - NULL, - NULL, - NULL, - &readbackDesc.Width - ); - + &textureDesc, + 0, + 1, + 0, + NULL, + NULL, + NULL, + &readbackDesc.Width); + SDL_zero(heapProps); heapProps.Type = D3D12_HEAP_TYPE_READBACK; heapProps.CreationNodeMask = 1; heapProps.VisibleNodeMask = 1; result = D3D_CALL(data->d3dDevice, CreateCommittedResource, - &heapProps, - D3D12_HEAP_FLAG_NONE, - &readbackDesc, - D3D12_RESOURCE_STATE_COPY_DEST, - NULL, - D3D_GUID(SDL_IID_ID3D12Resource), - (void **)&readbackBuffer - ); + &heapProps, + D3D12_HEAP_FLAG_NONE, + &readbackDesc, + D3D12_RESOURCE_STATE_COPY_DEST, + NULL, + D3D_GUID(SDL_IID_ID3D12Resource), + (void **)&readbackBuffer); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateTexture2D [create staging texture]"), result); goto done; @@ -2894,24 +2816,22 @@ D3D12_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, srcLocation.SubresourceIndex = 0; D3D_CALL(data->commandList, CopyTextureRegion, - &dstLocation, - 0, 0, 0, - &srcLocation, - &srcBox - ); + &dstLocation, + 0, 0, 0, + &srcLocation, + &srcBox); /* We need to issue the command list for the copy to finish */ D3D12_IssueBatch(data); /* Transition the render target back to a render target */ - D3D12_TransitionResource(data, backBuffer, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET ); + D3D12_TransitionResource(data, backBuffer, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET); /* Map the staging texture's data to CPU-accessible memory: */ result = D3D_CALL(readbackBuffer, Map, - 0, - NULL, - (void **)&textureMemory - ); + 0, + NULL, + (void **)&textureMemory); if (FAILED(result)) { SAFE_RELEASE(readbackBuffer); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Resource::Map [map staging texture]"), result); @@ -2937,10 +2857,9 @@ done: return status; } -static int -D3D12_RenderPresent(SDL_Renderer * renderer) +static int D3D12_RenderPresent(SDL_Renderer *renderer) { - D3D12_RenderData *data = (D3D12_RenderData *) renderer->driverdata; + D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) UINT syncInterval; UINT presentFlags; @@ -2949,14 +2868,13 @@ D3D12_RenderPresent(SDL_Renderer * renderer) /* Transition the render target to present state */ D3D12_TransitionResource(data, - data->renderTargets[data->currentBackBufferIndex], - D3D12_RESOURCE_STATE_RENDER_TARGET, - D3D12_RESOURCE_STATE_PRESENT - ); + data->renderTargets[data->currentBackBufferIndex], + D3D12_RESOURCE_STATE_RENDER_TARGET, + D3D12_RESOURCE_STATE_PRESENT); /* Issue the command list */ result = D3D_CALL(data->commandList, Close); - D3D_CALL(data->commandQueue, ExecuteCommandLists, 1, (ID3D12CommandList * const *)&data->commandList); + D3D_CALL(data->commandQueue, ExecuteCommandLists, 1, (ID3D12CommandList *const *)&data->commandList); #if defined(__XBOXONE__) || defined(__XBOXSERIES__) result = D3D12_XBOX_PresentFrame(data->commandQueue, data->frameToken, data->renderTargets[data->currentBackBufferIndex]); @@ -2976,10 +2894,10 @@ D3D12_RenderPresent(SDL_Renderer * renderer) #endif if (FAILED(result) && result != DXGI_ERROR_WAS_STILL_DRAWING) { - /* If the device was removed either by a disconnect or a driver upgrade, we + /* If the device was removed either by a disconnect or a driver upgrade, we * must recreate all device resources. */ - if ( result == DXGI_ERROR_DEVICE_REMOVED ) { + if (result == DXGI_ERROR_DEVICE_REMOVED) { D3D12_HandleDeviceLost(renderer); } else if (result == DXGI_ERROR_INVALID_CALL) { /* We probably went through a fullscreen <-> windowed transition */ @@ -2994,9 +2912,8 @@ D3D12_RenderPresent(SDL_Renderer * renderer) if (D3D_CALL(data->fence, GetCompletedValue) < data->fenceValue) { result = D3D_CALL(data->fence, SetEventOnCompletion, - data->fenceValue, - data->fenceEvent - ); + data->fenceValue, + data->fenceEvent); WaitForSingleObjectEx(data->fenceEvent, INFINITE, FALSE); } @@ -3011,10 +2928,9 @@ D3D12_RenderPresent(SDL_Renderer * renderer) /* Reset the command allocator and command list, and transition back to render target */ D3D12_ResetCommandList(data); D3D12_TransitionResource(data, - data->renderTargets[data->currentBackBufferIndex], - D3D12_RESOURCE_STATE_PRESENT, - D3D12_RESOURCE_STATE_RENDER_TARGET - ); + data->renderTargets[data->currentBackBufferIndex], + D3D12_RESOURCE_STATE_PRESENT, + D3D12_RESOURCE_STATE_RENDER_TARGET); #if defined(__XBOXONE__) || defined(__XBOXSERIES__) D3D12_XBOX_StartFrame(data->d3dDevice, &data->frameToken); @@ -3023,8 +2939,7 @@ D3D12_RenderPresent(SDL_Renderer * renderer) } } -static int -D3D12_SetVSync(SDL_Renderer * renderer, const int vsync) +static int D3D12_SetVSync(SDL_Renderer *renderer, const int vsync) { if (vsync) { renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; @@ -3035,18 +2950,18 @@ D3D12_SetVSync(SDL_Renderer * renderer, const int vsync) } SDL_Renderer * -D3D12_CreateRenderer(SDL_Window * window, Uint32 flags) +D3D12_CreateRenderer(SDL_Window *window, Uint32 flags) { SDL_Renderer *renderer; D3D12_RenderData *data; - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); if (renderer == NULL) { SDL_OutOfMemory(); return NULL; } - data = (D3D12_RenderData *) SDL_calloc(1, sizeof(*data)); + data = (D3D12_RenderData *)SDL_calloc(1, sizeof(*data)); if (data == NULL) { SDL_free(renderer); SDL_OutOfMemory(); @@ -3069,9 +2984,9 @@ D3D12_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->SetTextureScaleMode = D3D12_SetTextureScaleMode; renderer->SetRenderTarget = D3D12_SetRenderTarget; renderer->QueueSetViewport = D3D12_QueueSetViewport; - renderer->QueueSetDrawColor = D3D12_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */ + renderer->QueueSetDrawColor = D3D12_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */ renderer->QueueDrawPoints = D3D12_QueueDrawPoints; - renderer->QueueDrawLines = D3D12_QueueDrawPoints; /* lines and points queue vertices the same way. */ + renderer->QueueDrawLines = D3D12_QueueDrawPoints; /* lines and points queue vertices the same way. */ renderer->QueueGeometry = D3D12_QueueGeometry; renderer->RunCommandQueue = D3D12_RunCommandQueue; renderer->RenderReadPixels = D3D12_RenderReadPixels; @@ -3112,19 +3027,17 @@ SDL_RenderDriver D3D12_RenderDriver = { ( SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | - SDL_RENDERER_TARGETTEXTURE - ), /* flags. see SDL_RendererFlags */ - 6, /* num_texture_formats */ - { /* texture_formats */ - SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_RGB888, - SDL_PIXELFORMAT_YV12, - SDL_PIXELFORMAT_IYUV, - SDL_PIXELFORMAT_NV12, - SDL_PIXELFORMAT_NV21 - }, - 16384, /* max_texture_width */ - 16384 /* max_texture_height */ + SDL_RENDERER_TARGETTEXTURE), /* flags. see SDL_RendererFlags */ + 6, /* num_texture_formats */ + { /* texture_formats */ + SDL_PIXELFORMAT_ARGB8888, + SDL_PIXELFORMAT_RGB888, + SDL_PIXELFORMAT_YV12, + SDL_PIXELFORMAT_IYUV, + SDL_PIXELFORMAT_NV12, + SDL_PIXELFORMAT_NV21 }, + 16384, /* max_texture_width */ + 16384 /* max_texture_height */ } }; @@ -3139,14 +3052,14 @@ SDL_RenderDriver D3D12_RenderDriver = { #ifdef __cplusplus extern "C" #endif -/* This function needs to always exist on Windows, for the Dynamic API. */ -ID3D12Device * -SDL_RenderGetD3D12Device(SDL_Renderer * renderer) + /* This function needs to always exist on Windows, for the Dynamic API. */ + ID3D12Device * + SDL_RenderGetD3D12Device(SDL_Renderer *renderer) { ID3D12Device *device = NULL; #if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED - D3D12_RenderData *data = (D3D12_RenderData *) renderer->driverdata; + D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; /* Make sure that this is a D3D renderer */ if (renderer->DestroyRenderer != D3D12_DestroyRenderer) { diff --git a/src/render/direct3d12/SDL_shaders_d3d12.c b/src/render/direct3d12/SDL_shaders_d3d12.c index 2bb56d5d5..e8cab7fd0 100644 --- a/src/render/direct3d12/SDL_shaders_d3d12.c +++ b/src/render/direct3d12/SDL_shaders_d3d12.c @@ -31,7 +31,6 @@ #define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str - /* Direct3D 12 shaders SDL's shaders are compiled into SDL itself, to simplify distribution. @@ -51,7 +50,7 @@ Shader types: - ps_6_0: Pixel shader - vs_6_0: Vertex shader - + Shader object code was converted to unsigned chars via the following *nix style command (available separately from Windows + MSVC): @@ -1729,7 +1728,7 @@ static unsigned char D3D12_PixelShader_YUV_BT601[] = { float2 tex : TEXCOORD0; float4 color : COLOR0; }; - + #define YUVRS \ "RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \ " DENY_DOMAIN_SHADER_ROOT_ACCESS |" \ @@ -6770,7 +6769,7 @@ static unsigned char D3D12_VertexShader_NV[] = { /* Root signature blobs extracted from Vertex Shader dxc command line is: dxc -E -T rootsig_1_1 -rootsig-define -Fo D3D12_VertexShader.hlsl - + Variables: - : the root signature define - : the output file name. @@ -6858,78 +6857,57 @@ static struct { const void *ps_shader_data; SIZE_T ps_shader_size; - const void* vs_shader_data; + const void *vs_shader_data; SIZE_T vs_shader_size; D3D12_RootSignature root_sig; } D3D12_shaders[NUM_SHADERS] = { - { - D3D12_PixelShader_Colors, sizeof(D3D12_PixelShader_Colors), - D3D12_VertexShader_Colors, sizeof(D3D12_VertexShader_Colors), - ROOTSIG_COLOR - }, - { - D3D12_PixelShader_Textures, sizeof(D3D12_PixelShader_Textures), - D3D12_VertexShader_Textures, sizeof(D3D12_VertexShader_Textures), - ROOTSIG_TEXTURE - }, + { D3D12_PixelShader_Colors, sizeof(D3D12_PixelShader_Colors), + D3D12_VertexShader_Colors, sizeof(D3D12_VertexShader_Colors), + ROOTSIG_COLOR }, + { D3D12_PixelShader_Textures, sizeof(D3D12_PixelShader_Textures), + D3D12_VertexShader_Textures, sizeof(D3D12_VertexShader_Textures), + ROOTSIG_TEXTURE }, #if SDL_HAVE_YUV - { - D3D12_PixelShader_YUV_JPEG, sizeof(D3D12_PixelShader_YUV_JPEG), - D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV), - ROOTSIG_YUV - }, - { - D3D12_PixelShader_YUV_BT601, sizeof(D3D12_PixelShader_YUV_BT601), - D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV), - ROOTSIG_YUV - }, - { - D3D12_PixelShader_YUV_BT709, sizeof(D3D12_PixelShader_YUV_BT709), - D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV), - ROOTSIG_YUV - }, - { - D3D12_PixelShader_NV12_JPEG, sizeof(D3D12_PixelShader_NV12_JPEG), - D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), - ROOTSIG_NV - }, - { - D3D12_PixelShader_NV12_BT601, sizeof(D3D12_PixelShader_NV12_BT601), - D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), - ROOTSIG_NV - }, - { - D3D12_PixelShader_NV12_BT709, sizeof(D3D12_PixelShader_NV12_BT709), - D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), - ROOTSIG_NV - }, - { - D3D12_PixelShader_NV21_JPEG, sizeof(D3D12_PixelShader_NV21_JPEG), - D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), - ROOTSIG_NV - }, - { - D3D12_PixelShader_NV21_BT601, sizeof(D3D12_PixelShader_NV21_BT601), - D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), - ROOTSIG_NV - }, - { - D3D12_PixelShader_NV21_BT709, sizeof(D3D12_PixelShader_NV21_BT709), - D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), - ROOTSIG_NV - }, + { D3D12_PixelShader_YUV_JPEG, sizeof(D3D12_PixelShader_YUV_JPEG), + D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV), + ROOTSIG_YUV }, + { D3D12_PixelShader_YUV_BT601, sizeof(D3D12_PixelShader_YUV_BT601), + D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV), + ROOTSIG_YUV }, + { D3D12_PixelShader_YUV_BT709, sizeof(D3D12_PixelShader_YUV_BT709), + D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV), + ROOTSIG_YUV }, + { D3D12_PixelShader_NV12_JPEG, sizeof(D3D12_PixelShader_NV12_JPEG), + D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), + ROOTSIG_NV }, + { D3D12_PixelShader_NV12_BT601, sizeof(D3D12_PixelShader_NV12_BT601), + D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), + ROOTSIG_NV }, + { D3D12_PixelShader_NV12_BT709, sizeof(D3D12_PixelShader_NV12_BT709), + D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), + ROOTSIG_NV }, + { D3D12_PixelShader_NV21_JPEG, sizeof(D3D12_PixelShader_NV21_JPEG), + D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), + ROOTSIG_NV }, + { D3D12_PixelShader_NV21_BT601, sizeof(D3D12_PixelShader_NV21_BT601), + D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), + ROOTSIG_NV }, + { D3D12_PixelShader_NV21_BT709, sizeof(D3D12_PixelShader_NV21_BT709), + D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), + ROOTSIG_NV }, #endif }; -static struct { - const void* rs_shader_data; +static struct +{ + const void *rs_shader_data; SIZE_T rs_shader_size; } D3D12_rootsigs[NUM_ROOTSIGS] = { - {D3D12_RootSig_Color, sizeof(D3D12_RootSig_Color)}, - {D3D12_RootSig_Texture, sizeof(D3D12_RootSig_Texture)}, + { D3D12_RootSig_Color, sizeof(D3D12_RootSig_Color) }, + { D3D12_RootSig_Texture, sizeof(D3D12_RootSig_Texture) }, #if SDL_HAVE_YUV - {D3D12_RootSig_YUV, sizeof(D3D12_RootSig_YUV)}, - {D3D12_RootSig_NV, sizeof(D3D12_RootSig_NV)}, + { D3D12_RootSig_YUV, sizeof(D3D12_RootSig_YUV) }, + { D3D12_RootSig_NV, sizeof(D3D12_RootSig_NV) }, #endif }; diff --git a/src/render/direct3d12/SDL_shaders_d3d12.h b/src/render/direct3d12/SDL_shaders_d3d12.h index e56c5ccf2..22f402a5e 100644 --- a/src/render/direct3d12/SDL_shaders_d3d12.h +++ b/src/render/direct3d12/SDL_shaders_d3d12.h @@ -27,7 +27,8 @@ extern "C" { #endif -typedef enum { +typedef enum +{ SHADER_SOLID, SHADER_RGB, #if SDL_HAVE_YUV @@ -44,7 +45,8 @@ typedef enum { NUM_SHADERS } D3D12_Shader; -typedef enum { +typedef enum +{ ROOTSIG_COLOR, ROOTSIG_TEXTURE, #if SDL_HAVE_YUV @@ -57,7 +59,7 @@ typedef enum { extern void D3D12_GetVertexShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode); extern void D3D12_GetPixelShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode); extern D3D12_RootSignature D3D12_GetRootSignatureType(D3D12_Shader shader); -extern void D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE* outBytecode); +extern void D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *outBytecode); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/src/render/metal/SDL_render_metal.m b/src/render/metal/SDL_render_metal.m index 80fd96f07..51899f582 100644 --- a/src/render/metal/SDL_render_metal.m +++ b/src/render/metal/SDL_render_metal.m @@ -120,47 +120,46 @@ typedef struct METAL_ShaderPipelines } METAL_ShaderPipelines; @interface METAL_RenderData : NSObject - @property (nonatomic, retain) id mtldevice; - @property (nonatomic, retain) id mtlcmdqueue; - @property (nonatomic, retain) id mtlcmdbuffer; - @property (nonatomic, retain) id mtlcmdencoder; - @property (nonatomic, retain) id mtllibrary; - @property (nonatomic, retain) id mtlbackbuffer; - @property (nonatomic, retain) id mtlsamplernearest; - @property (nonatomic, retain) id mtlsamplerlinear; - @property (nonatomic, retain) id mtlbufconstants; - @property (nonatomic, retain) id mtlbufquadindices; - @property (nonatomic, assign) SDL_MetalView mtlview; - @property (nonatomic, retain) CAMetalLayer *mtllayer; - @property (nonatomic, retain) MTLRenderPassDescriptor *mtlpassdesc; - @property (nonatomic, assign) METAL_ShaderPipelines *activepipelines; - @property (nonatomic, assign) METAL_ShaderPipelines *allpipelines; - @property (nonatomic, assign) int pipelinescount; +@property(nonatomic, retain) id mtldevice; +@property(nonatomic, retain) id mtlcmdqueue; +@property(nonatomic, retain) id mtlcmdbuffer; +@property(nonatomic, retain) id mtlcmdencoder; +@property(nonatomic, retain) id mtllibrary; +@property(nonatomic, retain) id mtlbackbuffer; +@property(nonatomic, retain) id mtlsamplernearest; +@property(nonatomic, retain) id mtlsamplerlinear; +@property(nonatomic, retain) id mtlbufconstants; +@property(nonatomic, retain) id mtlbufquadindices; +@property(nonatomic, assign) SDL_MetalView mtlview; +@property(nonatomic, retain) CAMetalLayer *mtllayer; +@property(nonatomic, retain) MTLRenderPassDescriptor *mtlpassdesc; +@property(nonatomic, assign) METAL_ShaderPipelines *activepipelines; +@property(nonatomic, assign) METAL_ShaderPipelines *allpipelines; +@property(nonatomic, assign) int pipelinescount; @end @implementation METAL_RenderData @end @interface METAL_TextureData : NSObject - @property (nonatomic, retain) id mtltexture; - @property (nonatomic, retain) id mtltexture_uv; - @property (nonatomic, retain) id mtlsampler; - @property (nonatomic, assign) SDL_MetalFragmentFunction fragmentFunction; +@property(nonatomic, retain) id mtltexture; +@property(nonatomic, retain) id mtltexture_uv; +@property(nonatomic, retain) id mtlsampler; +@property(nonatomic, assign) SDL_MetalFragmentFunction fragmentFunction; #if SDL_HAVE_YUV - @property (nonatomic, assign) BOOL yuv; - @property (nonatomic, assign) BOOL nv12; - @property (nonatomic, assign) size_t conversionBufferOffset; +@property(nonatomic, assign) BOOL yuv; +@property(nonatomic, assign) BOOL nv12; +@property(nonatomic, assign) size_t conversionBufferOffset; #endif - @property (nonatomic, assign) BOOL hasdata; - @property (nonatomic, retain) id lockedbuffer; - @property (nonatomic, assign) SDL_Rect lockedrect; +@property(nonatomic, assign) BOOL hasdata; +@property(nonatomic, retain) id lockedbuffer; +@property(nonatomic, assign) SDL_Rect lockedrect; @end @implementation METAL_TextureData @end -static int -IsMetalAvailable(const SDL_SysWMinfo *syswm) +static int IsMetalAvailable(const SDL_SysWMinfo *syswm) { if (syswm->subsystem != SDL_SYSWM_COCOA && syswm->subsystem != SDL_SYSWM_UIKIT) { return SDL_SetError("Metal render target only supports Cocoa and UIKit video targets at the moment."); @@ -179,63 +178,84 @@ IsMetalAvailable(const SDL_SysWMinfo *syswm) static const MTLBlendOperation invalidBlendOperation = (MTLBlendOperation)0xFFFFFFFF; static const MTLBlendFactor invalidBlendFactor = (MTLBlendFactor)0xFFFFFFFF; -static MTLBlendOperation -GetBlendOperation(SDL_BlendOperation operation) +static MTLBlendOperation GetBlendOperation(SDL_BlendOperation operation) { switch (operation) { - case SDL_BLENDOPERATION_ADD: return MTLBlendOperationAdd; - case SDL_BLENDOPERATION_SUBTRACT: return MTLBlendOperationSubtract; - case SDL_BLENDOPERATION_REV_SUBTRACT: return MTLBlendOperationReverseSubtract; - case SDL_BLENDOPERATION_MINIMUM: return MTLBlendOperationMin; - case SDL_BLENDOPERATION_MAXIMUM: return MTLBlendOperationMax; - default: return invalidBlendOperation; + case SDL_BLENDOPERATION_ADD: + return MTLBlendOperationAdd; + case SDL_BLENDOPERATION_SUBTRACT: + return MTLBlendOperationSubtract; + case SDL_BLENDOPERATION_REV_SUBTRACT: + return MTLBlendOperationReverseSubtract; + case SDL_BLENDOPERATION_MINIMUM: + return MTLBlendOperationMin; + case SDL_BLENDOPERATION_MAXIMUM: + return MTLBlendOperationMax; + default: + return invalidBlendOperation; } } -static MTLBlendFactor -GetBlendFactor(SDL_BlendFactor factor) +static MTLBlendFactor GetBlendFactor(SDL_BlendFactor factor) { switch (factor) { - case SDL_BLENDFACTOR_ZERO: return MTLBlendFactorZero; - case SDL_BLENDFACTOR_ONE: return MTLBlendFactorOne; - case SDL_BLENDFACTOR_SRC_COLOR: return MTLBlendFactorSourceColor; - case SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR: return MTLBlendFactorOneMinusSourceColor; - case SDL_BLENDFACTOR_SRC_ALPHA: return MTLBlendFactorSourceAlpha; - case SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA: return MTLBlendFactorOneMinusSourceAlpha; - case SDL_BLENDFACTOR_DST_COLOR: return MTLBlendFactorDestinationColor; - case SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR: return MTLBlendFactorOneMinusDestinationColor; - case SDL_BLENDFACTOR_DST_ALPHA: return MTLBlendFactorDestinationAlpha; - case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA: return MTLBlendFactorOneMinusDestinationAlpha; - default: return invalidBlendFactor; + case SDL_BLENDFACTOR_ZERO: + return MTLBlendFactorZero; + case SDL_BLENDFACTOR_ONE: + return MTLBlendFactorOne; + case SDL_BLENDFACTOR_SRC_COLOR: + return MTLBlendFactorSourceColor; + case SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR: + return MTLBlendFactorOneMinusSourceColor; + case SDL_BLENDFACTOR_SRC_ALPHA: + return MTLBlendFactorSourceAlpha; + case SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA: + return MTLBlendFactorOneMinusSourceAlpha; + case SDL_BLENDFACTOR_DST_COLOR: + return MTLBlendFactorDestinationColor; + case SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR: + return MTLBlendFactorOneMinusDestinationColor; + case SDL_BLENDFACTOR_DST_ALPHA: + return MTLBlendFactorDestinationAlpha; + case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA: + return MTLBlendFactorOneMinusDestinationAlpha; + default: + return invalidBlendFactor; } } -static NSString * -GetVertexFunctionName(SDL_MetalVertexFunction function) +static NSString *GetVertexFunctionName(SDL_MetalVertexFunction function) { switch (function) { - case SDL_METAL_VERTEX_SOLID: return @"SDL_Solid_vertex"; - case SDL_METAL_VERTEX_COPY: return @"SDL_Copy_vertex"; - default: return nil; + case SDL_METAL_VERTEX_SOLID: + return @"SDL_Solid_vertex"; + case SDL_METAL_VERTEX_COPY: + return @"SDL_Copy_vertex"; + default: + return nil; } } -static NSString * -GetFragmentFunctionName(SDL_MetalFragmentFunction function) +static NSString *GetFragmentFunctionName(SDL_MetalFragmentFunction function) { switch (function) { - case SDL_METAL_FRAGMENT_SOLID: return @"SDL_Solid_fragment"; - case SDL_METAL_FRAGMENT_COPY: return @"SDL_Copy_fragment"; - case SDL_METAL_FRAGMENT_YUV: return @"SDL_YUV_fragment"; - case SDL_METAL_FRAGMENT_NV12: return @"SDL_NV12_fragment"; - case SDL_METAL_FRAGMENT_NV21: return @"SDL_NV21_fragment"; - default: return nil; + case SDL_METAL_FRAGMENT_SOLID: + return @"SDL_Solid_fragment"; + case SDL_METAL_FRAGMENT_COPY: + return @"SDL_Copy_fragment"; + case SDL_METAL_FRAGMENT_YUV: + return @"SDL_YUV_fragment"; + case SDL_METAL_FRAGMENT_NV12: + return @"SDL_NV12_fragment"; + case SDL_METAL_FRAGMENT_NV21: + return @"SDL_NV21_fragment"; + default: + return nil; } } -static id -MakePipelineState(METAL_RenderData *data, METAL_PipelineCache *cache, - NSString *blendlabel, SDL_BlendMode blendmode) +static id MakePipelineState(METAL_RenderData *data, METAL_PipelineCache *cache, + NSString *blendlabel, SDL_BlendMode blendmode) { MTLRenderPipelineDescriptor *mtlpipedesc; MTLVertexDescriptor *vertdesc; @@ -257,37 +277,37 @@ MakePipelineState(METAL_RenderData *data, METAL_PipelineCache *cache, vertdesc = [MTLVertexDescriptor vertexDescriptor]; switch (cache->vertexFunction) { - case SDL_METAL_VERTEX_SOLID: - /* position (float2), color (uchar4normalized) */ - vertdesc.layouts[0].stride = sizeof(float) * 2 + sizeof (int); - vertdesc.layouts[0].stepFunction = MTLVertexStepFunctionPerVertex; + case SDL_METAL_VERTEX_SOLID: + /* position (float2), color (uchar4normalized) */ + vertdesc.layouts[0].stride = sizeof(float) * 2 + sizeof(int); + vertdesc.layouts[0].stepFunction = MTLVertexStepFunctionPerVertex; - vertdesc.attributes[0].format = MTLVertexFormatFloat2; - vertdesc.attributes[0].offset = 0; - vertdesc.attributes[0].bufferIndex = 0; + vertdesc.attributes[0].format = MTLVertexFormatFloat2; + vertdesc.attributes[0].offset = 0; + vertdesc.attributes[0].bufferIndex = 0; - vertdesc.attributes[1].format = MTLVertexFormatUChar4Normalized; - vertdesc.attributes[1].offset = sizeof (float) * 2; - vertdesc.attributes[1].bufferIndex = 0; + vertdesc.attributes[1].format = MTLVertexFormatUChar4Normalized; + vertdesc.attributes[1].offset = sizeof(float) * 2; + vertdesc.attributes[1].bufferIndex = 0; - break; - case SDL_METAL_VERTEX_COPY: - /* position (float2), color (uchar4normalized), texcoord (float2) */ - vertdesc.layouts[0].stride = sizeof(float) * 2 + sizeof (int) + sizeof (float) * 2; - vertdesc.layouts[0].stepFunction = MTLVertexStepFunctionPerVertex; + break; + case SDL_METAL_VERTEX_COPY: + /* position (float2), color (uchar4normalized), texcoord (float2) */ + vertdesc.layouts[0].stride = sizeof(float) * 2 + sizeof(int) + sizeof(float) * 2; + vertdesc.layouts[0].stepFunction = MTLVertexStepFunctionPerVertex; - vertdesc.attributes[0].format = MTLVertexFormatFloat2; - vertdesc.attributes[0].offset = 0; - vertdesc.attributes[0].bufferIndex = 0; + vertdesc.attributes[0].format = MTLVertexFormatFloat2; + vertdesc.attributes[0].offset = 0; + vertdesc.attributes[0].bufferIndex = 0; - vertdesc.attributes[1].format = MTLVertexFormatUChar4Normalized; - vertdesc.attributes[1].offset = sizeof (float) * 2; - vertdesc.attributes[1].bufferIndex = 0; + vertdesc.attributes[1].format = MTLVertexFormatUChar4Normalized; + vertdesc.attributes[1].offset = sizeof(float) * 2; + vertdesc.attributes[1].bufferIndex = 0; - vertdesc.attributes[2].format = MTLVertexFormatFloat2; - vertdesc.attributes[2].offset = sizeof(float) * 2 + sizeof (int); - vertdesc.attributes[2].bufferIndex = 0; - break; + vertdesc.attributes[2].format = MTLVertexFormatFloat2; + vertdesc.attributes[2].offset = sizeof(float) * 2 + sizeof(int); + vertdesc.attributes[2].bufferIndex = 0; + break; } mtlpipedesc.vertexDescriptor = vertdesc; @@ -328,9 +348,8 @@ MakePipelineState(METAL_RenderData *data, METAL_PipelineCache *cache, } } -static void -MakePipelineCache(METAL_RenderData *data, METAL_PipelineCache *cache, const char *label, - MTLPixelFormat rtformat, SDL_MetalVertexFunction vertfn, SDL_MetalFragmentFunction fragfn) +static void MakePipelineCache(METAL_RenderData *data, METAL_PipelineCache *cache, const char *label, + MTLPixelFormat rtformat, SDL_MetalVertexFunction vertfn, SDL_MetalFragmentFunction fragfn) { SDL_zerop(cache); @@ -348,8 +367,7 @@ MakePipelineCache(METAL_RenderData *data, METAL_PipelineCache *cache, const char MakePipelineState(data, cache, @" (blend=mul)", SDL_BLENDMODE_MUL); } -static void -DestroyPipelineCache(METAL_PipelineCache *cache) +static void DestroyPipelineCache(METAL_PipelineCache *cache) { if (cache != NULL) { for (int i = 0; i < cache->count; i++) { @@ -360,8 +378,7 @@ DestroyPipelineCache(METAL_PipelineCache *cache) } } -void -MakeShaderPipelines(METAL_RenderData *data, METAL_ShaderPipelines *pipelines, MTLPixelFormat rtformat) +void MakeShaderPipelines(METAL_RenderData *data, METAL_ShaderPipelines *pipelines, MTLPixelFormat rtformat) { SDL_zerop(pipelines); @@ -374,8 +391,7 @@ MakeShaderPipelines(METAL_RenderData *data, METAL_ShaderPipelines *pipelines, MT MakePipelineCache(data, &pipelines->caches[SDL_METAL_FRAGMENT_NV21], "SDL NV21 pipeline", rtformat, SDL_METAL_VERTEX_COPY, SDL_METAL_FRAGMENT_NV21); } -static METAL_ShaderPipelines * -ChooseShaderPipelines(METAL_RenderData *data, MTLPixelFormat rtformat) +static METAL_ShaderPipelines *ChooseShaderPipelines(METAL_RenderData *data, MTLPixelFormat rtformat) { METAL_ShaderPipelines *allpipelines = data.allpipelines; int count = data.pipelinescount; @@ -401,8 +417,7 @@ ChooseShaderPipelines(METAL_RenderData *data, MTLPixelFormat rtformat) return &data.allpipelines[count]; } -static void -DestroyAllPipelines(METAL_ShaderPipelines *allpipelines, int count) +static void DestroyAllPipelines(METAL_ShaderPipelines *allpipelines, int count) { if (allpipelines != NULL) { for (int i = 0; i < count; i++) { @@ -415,8 +430,7 @@ DestroyAllPipelines(METAL_ShaderPipelines *allpipelines, int count) } } -static inline id -ChoosePipelineState(METAL_RenderData *data, METAL_ShaderPipelines *pipelines, SDL_MetalFragmentFunction fragfn, SDL_BlendMode blendmode) +static inline id ChoosePipelineState(METAL_RenderData *data, METAL_ShaderPipelines *pipelines, SDL_MetalFragmentFunction fragfn, SDL_BlendMode blendmode) { METAL_PipelineCache *cache = &pipelines->caches[fragfn]; @@ -429,10 +443,9 @@ ChoosePipelineState(METAL_RenderData *data, METAL_ShaderPipelines *pipelines, SD return MakePipelineState(data, cache, [NSString stringWithFormat:@" (blend=custom 0x%x)", blendmode], blendmode); } -static SDL_bool -METAL_ActivateRenderCommandEncoder(SDL_Renderer * renderer, MTLLoadAction load, MTLClearColor *clear_color, id vertex_buffer) +static SDL_bool METAL_ActivateRenderCommandEncoder(SDL_Renderer *renderer, MTLLoadAction load, MTLClearColor *clear_color, id vertex_buffer) { - METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata; /* Our SetRenderTarget just signals that the next render operation should * set up a new render pass. This is where that work happens. */ @@ -497,26 +510,25 @@ METAL_ActivateRenderCommandEncoder(SDL_Renderer * renderer, MTLLoadAction load, return SDL_TRUE; } -static void -METAL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +static void METAL_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event) { } -static int -METAL_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) -{ @autoreleasepool { - METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; - if (w) { - *w = (int)data.mtllayer.drawableSize.width; +static int METAL_GetOutputSize(SDL_Renderer *renderer, int *w, int *h) +{ + @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata; + if (w) { + *w = (int)data.mtllayer.drawableSize.width; + } + if (h) { + *h = (int)data.mtllayer.drawableSize.height; + } + return 0; } - if (h) { - *h = (int)data.mtllayer.drawableSize.height; - } - return 0; -}} +} -static SDL_bool -METAL_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +static SDL_bool METAL_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); @@ -536,17 +548,17 @@ METAL_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) return SDL_TRUE; } -static int -METAL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ @autoreleasepool { - METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; - MTLPixelFormat pixfmt; - MTLTextureDescriptor *mtltexdesc; - id mtltexture, mtltexture_uv; - BOOL yuv, nv12; - METAL_TextureData *texturedata; +static int METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata; + MTLPixelFormat pixfmt; + MTLTextureDescriptor *mtltexdesc; + id mtltexture, mtltexture_uv; + BOOL yuv, nv12; + METAL_TextureData *texturedata; - switch (texture->format) { + switch (texture->format) { case SDL_PIXELFORMAT_ABGR8888: pixfmt = MTLPixelFormatRGBA8Unorm; break; @@ -561,93 +573,103 @@ METAL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) break; default: return SDL_SetError("Texture format %s not supported by Metal", SDL_GetPixelFormatName(texture->format)); - } - - mtltexdesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:pixfmt - width:(NSUInteger)texture->w height:(NSUInteger)texture->h mipmapped:NO]; - - /* Not available in iOS 8. */ - if ([mtltexdesc respondsToSelector:@selector(usage)]) { - if (texture->access == SDL_TEXTUREACCESS_TARGET) { - mtltexdesc.usage = MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget; - } else { - mtltexdesc.usage = MTLTextureUsageShaderRead; } - } - mtltexture = [data.mtldevice newTextureWithDescriptor:mtltexdesc]; - if (mtltexture == nil) { - return SDL_SetError("Texture allocation failed"); - } + mtltexdesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:pixfmt + width:(NSUInteger)texture->w + height:(NSUInteger)texture->h + mipmapped:NO]; - mtltexture_uv = nil; -#if SDL_HAVE_YUV - yuv = (texture->format == SDL_PIXELFORMAT_IYUV) || (texture->format == SDL_PIXELFORMAT_YV12); - nv12 = (texture->format == SDL_PIXELFORMAT_NV12) || (texture->format == SDL_PIXELFORMAT_NV21); + /* Not available in iOS 8. */ + if ([mtltexdesc respondsToSelector:@selector(usage)]) { + if (texture->access == SDL_TEXTUREACCESS_TARGET) { + mtltexdesc.usage = MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget; + } else { + mtltexdesc.usage = MTLTextureUsageShaderRead; + } + } - if (yuv) { - mtltexdesc.pixelFormat = MTLPixelFormatR8Unorm; - mtltexdesc.width = (texture->w + 1) / 2; - mtltexdesc.height = (texture->h + 1) / 2; - mtltexdesc.textureType = MTLTextureType2DArray; - mtltexdesc.arrayLength = 2; - } else if (nv12) { - mtltexdesc.pixelFormat = MTLPixelFormatRG8Unorm; - mtltexdesc.width = (texture->w + 1) / 2; - mtltexdesc.height = (texture->h + 1) / 2; - } - - if (yuv || nv12) { - mtltexture_uv = [data.mtldevice newTextureWithDescriptor:mtltexdesc]; - if (mtltexture_uv == nil) { + mtltexture = [data.mtldevice newTextureWithDescriptor:mtltexdesc]; + if (mtltexture == nil) { return SDL_SetError("Texture allocation failed"); } - } -#endif /* SDL_HAVE_YUV */ - texturedata = [[METAL_TextureData alloc] init]; - if (texture->scaleMode == SDL_ScaleModeNearest) { - texturedata.mtlsampler = data.mtlsamplernearest; - } else { - texturedata.mtlsampler = data.mtlsamplerlinear; - } - texturedata.mtltexture = mtltexture; - texturedata.mtltexture_uv = mtltexture_uv; -#if SDL_HAVE_YUV - texturedata.yuv = yuv; - texturedata.nv12 = nv12; - if (yuv) { - texturedata.fragmentFunction = SDL_METAL_FRAGMENT_YUV; - } else if (texture->format == SDL_PIXELFORMAT_NV12) { - texturedata.fragmentFunction = SDL_METAL_FRAGMENT_NV12; - } else if (texture->format == SDL_PIXELFORMAT_NV21) { - texturedata.fragmentFunction = SDL_METAL_FRAGMENT_NV21; - } else -#endif - { - texturedata.fragmentFunction = SDL_METAL_FRAGMENT_COPY; - } + mtltexture_uv = nil; #if SDL_HAVE_YUV - if (yuv || nv12) { - size_t offset = 0; - SDL_YUV_CONVERSION_MODE mode = SDL_GetYUVConversionModeForResolution(texture->w, texture->h); - switch (mode) { - case SDL_YUV_CONVERSION_JPEG: offset = CONSTANTS_OFFSET_DECODE_JPEG; break; - case SDL_YUV_CONVERSION_BT601: offset = CONSTANTS_OFFSET_DECODE_BT601; break; - case SDL_YUV_CONVERSION_BT709: offset = CONSTANTS_OFFSET_DECODE_BT709; break; - default: offset = 0; break; + yuv = (texture->format == SDL_PIXELFORMAT_IYUV) || (texture->format == SDL_PIXELFORMAT_YV12); + nv12 = (texture->format == SDL_PIXELFORMAT_NV12) || (texture->format == SDL_PIXELFORMAT_NV21); + + if (yuv) { + mtltexdesc.pixelFormat = MTLPixelFormatR8Unorm; + mtltexdesc.width = (texture->w + 1) / 2; + mtltexdesc.height = (texture->h + 1) / 2; + mtltexdesc.textureType = MTLTextureType2DArray; + mtltexdesc.arrayLength = 2; + } else if (nv12) { + mtltexdesc.pixelFormat = MTLPixelFormatRG8Unorm; + mtltexdesc.width = (texture->w + 1) / 2; + mtltexdesc.height = (texture->h + 1) / 2; } - texturedata.conversionBufferOffset = offset; - } + + if (yuv || nv12) { + mtltexture_uv = [data.mtldevice newTextureWithDescriptor:mtltexdesc]; + if (mtltexture_uv == nil) { + return SDL_SetError("Texture allocation failed"); + } + } +#endif /* SDL_HAVE_YUV */ + texturedata = [[METAL_TextureData alloc] init]; + if (texture->scaleMode == SDL_ScaleModeNearest) { + texturedata.mtlsampler = data.mtlsamplernearest; + } else { + texturedata.mtlsampler = data.mtlsamplerlinear; + } + texturedata.mtltexture = mtltexture; + texturedata.mtltexture_uv = mtltexture_uv; +#if SDL_HAVE_YUV + texturedata.yuv = yuv; + texturedata.nv12 = nv12; + + if (yuv) { + texturedata.fragmentFunction = SDL_METAL_FRAGMENT_YUV; + } else if (texture->format == SDL_PIXELFORMAT_NV12) { + texturedata.fragmentFunction = SDL_METAL_FRAGMENT_NV12; + } else if (texture->format == SDL_PIXELFORMAT_NV21) { + texturedata.fragmentFunction = SDL_METAL_FRAGMENT_NV21; + } else #endif - texture->driverdata = (void*)CFBridgingRetain(texturedata); + { + texturedata.fragmentFunction = SDL_METAL_FRAGMENT_COPY; + } +#if SDL_HAVE_YUV + if (yuv || nv12) { + size_t offset = 0; + SDL_YUV_CONVERSION_MODE mode = SDL_GetYUVConversionModeForResolution(texture->w, texture->h); + switch (mode) { + case SDL_YUV_CONVERSION_JPEG: + offset = CONSTANTS_OFFSET_DECODE_JPEG; + break; + case SDL_YUV_CONVERSION_BT601: + offset = CONSTANTS_OFFSET_DECODE_BT601; + break; + case SDL_YUV_CONVERSION_BT709: + offset = CONSTANTS_OFFSET_DECODE_BT709; + break; + default: + offset = 0; + break; + } + texturedata.conversionBufferOffset = offset; + } +#endif + texture->driverdata = (void *)CFBridgingRetain(texturedata); - return 0; -}} + return 0; + } +} -static void -METAL_UploadTextureData(id texture, SDL_Rect rect, int slice, - const void * pixels, int pitch) +static void METAL_UploadTextureData(id texture, SDL_Rect rect, int slice, + const void *pixels, int pitch) { [texture replaceRegion:MTLRegionMake2D(rect.x, rect.y, rect.w, rect.h) mipmapLevel:0 @@ -657,8 +679,7 @@ METAL_UploadTextureData(id texture, SDL_Rect rect, int slice, bytesPerImage:0]; } -static MTLStorageMode -METAL_GetStorageMode(id resource) +static MTLStorageMode METAL_GetStorageMode(id resource) { /* iOS 8 does not have this method. */ if ([resource respondsToSelector:@selector(storageMode)]) { @@ -667,13 +688,12 @@ METAL_GetStorageMode(id resource) return MTLStorageModeShared; } -static int -METAL_UpdateTextureInternal(SDL_Renderer * renderer, METAL_TextureData *texturedata, - id texture, SDL_Rect rect, int slice, - const void * pixels, int pitch) +static int METAL_UpdateTextureInternal(SDL_Renderer *renderer, METAL_TextureData *texturedata, + id texture, SDL_Rect rect, int slice, + const void *pixels, int pitch) { - METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; - SDL_Rect stagingrect = {0, 0, rect.w, rect.h}; + METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata; + SDL_Rect stagingrect = { 0, 0, rect.w, rect.h }; MTLTextureDescriptor *desc; id stagingtex; id blitcmd; @@ -736,274 +756,279 @@ METAL_UpdateTextureInternal(SDL_Renderer * renderer, METAL_TextureData *textured return 0; } -static int -METAL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, int pitch) -{ @autoreleasepool { - METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata; +static int METAL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, const void *pixels, int pitch) +{ + @autoreleasepool { + METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata; - if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture, *rect, 0, pixels, pitch) < 0) { - return -1; - } + if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture, *rect, 0, pixels, pitch) < 0) { + return -1; + } #if SDL_HAVE_YUV - if (texturedata.yuv) { - int Uslice = texture->format == SDL_PIXELFORMAT_YV12 ? 1 : 0; - int Vslice = texture->format == SDL_PIXELFORMAT_YV12 ? 0 : 1; - int UVpitch = (pitch + 1) / 2; - SDL_Rect UVrect = {rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2}; + if (texturedata.yuv) { + int Uslice = texture->format == SDL_PIXELFORMAT_YV12 ? 1 : 0; + int Vslice = texture->format == SDL_PIXELFORMAT_YV12 ? 0 : 1; + int UVpitch = (pitch + 1) / 2; + SDL_Rect UVrect = { rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2 }; - /* Skip to the correct offset into the next texture */ - pixels = (const void*)((const Uint8*)pixels + rect->h * pitch); - if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, Uslice, pixels, UVpitch) < 0) { - return -1; + /* Skip to the correct offset into the next texture */ + pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch); + if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, Uslice, pixels, UVpitch) < 0) { + return -1; + } + + /* Skip to the correct offset into the next texture */ + pixels = (const void *)((const Uint8 *)pixels + UVrect.h * UVpitch); + if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, Vslice, pixels, UVpitch) < 0) { + return -1; + } } - /* Skip to the correct offset into the next texture */ - pixels = (const void*)((const Uint8*)pixels + UVrect.h * UVpitch); - if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, Vslice, pixels, UVpitch) < 0) { - return -1; - } - } + if (texturedata.nv12) { + SDL_Rect UVrect = { rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2 }; + int UVpitch = 2 * ((pitch + 1) / 2); - if (texturedata.nv12) { - SDL_Rect UVrect = {rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2}; - int UVpitch = 2 * ((pitch + 1) / 2); - - /* Skip to the correct offset into the next texture */ - pixels = (const void*)((const Uint8*)pixels + rect->h * pitch); - if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, 0, pixels, UVpitch) < 0) { - return -1; + /* Skip to the correct offset into the next texture */ + pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch); + if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, 0, pixels, UVpitch) < 0) { + return -1; + } } - } #endif - texturedata.hasdata = YES; + texturedata.hasdata = YES; - return 0; -}} - -#if SDL_HAVE_YUV -static int -METAL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *Uplane, int Upitch, - const Uint8 *Vplane, int Vpitch) -{ @autoreleasepool { - METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata; - const int Uslice = 0; - const int Vslice = 1; - SDL_Rect UVrect = {rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2}; - - /* Bail out if we're supposed to update an empty rectangle */ - if (rect->w <= 0 || rect->h <= 0) { return 0; } +} - if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture, *rect, 0, Yplane, Ypitch) < 0) { - return -1; - } - if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, Uslice, Uplane, Upitch)) { - return -1; - } - if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, Vslice, Vplane, Vpitch)) { - return -1; - } +#if SDL_HAVE_YUV +static int METAL_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + @autoreleasepool { + METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata; + const int Uslice = 0; + const int Vslice = 1; + SDL_Rect UVrect = { rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2 }; - texturedata.hasdata = YES; + /* Bail out if we're supposed to update an empty rectangle */ + if (rect->w <= 0 || rect->h <= 0) { + return 0; + } - return 0; -}} + if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture, *rect, 0, Yplane, Ypitch) < 0) { + return -1; + } + if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, Uslice, Uplane, Upitch)) { + return -1; + } + if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, Vslice, Vplane, Vpitch)) { + return -1; + } -static int -METAL_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *UVplane, int UVpitch) -{ @autoreleasepool { - METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata; - SDL_Rect UVrect = {rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2}; + texturedata.hasdata = YES; - /* Bail out if we're supposed to update an empty rectangle */ - if (rect->w <= 0 || rect->h <= 0) { return 0; } +} - if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture, *rect, 0, Yplane, Ypitch) < 0) { - return -1; +static int METAL_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch) +{ + @autoreleasepool { + METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata; + SDL_Rect UVrect = { rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2 }; + + /* Bail out if we're supposed to update an empty rectangle */ + if (rect->w <= 0 || rect->h <= 0) { + return 0; + } + + if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture, *rect, 0, Yplane, Ypitch) < 0) { + return -1; + } + + if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, 0, UVplane, UVpitch) < 0) { + return -1; + } + + texturedata.hasdata = YES; + + return 0; } - - if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, 0, UVplane, UVpitch) < 0) { - return -1; - } - - texturedata.hasdata = YES; - - return 0; -}} +} #endif -static int -METAL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, void **pixels, int *pitch) -{ @autoreleasepool { - METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; - METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata; - int buffersize = 0; - id lockedbuffer = nil; +static int METAL_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, void **pixels, int *pitch) +{ + @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata; + METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata; + int buffersize = 0; + id lockedbuffer = nil; - if (rect->w <= 0 || rect->h <= 0) { - return SDL_SetError("Invalid rectangle dimensions for LockTexture."); - } + if (rect->w <= 0 || rect->h <= 0) { + return SDL_SetError("Invalid rectangle dimensions for LockTexture."); + } - *pitch = SDL_BYTESPERPIXEL(texture->format) * rect->w; + *pitch = SDL_BYTESPERPIXEL(texture->format) * rect->w; #if SDL_HAVE_YUV - if (texturedata.yuv || texturedata.nv12) { - buffersize = ((*pitch) * rect->h) + (2 * (*pitch + 1) / 2) * ((rect->h + 1) / 2); - } else + if (texturedata.yuv || texturedata.nv12) { + buffersize = ((*pitch) * rect->h) + (2 * (*pitch + 1) / 2) * ((rect->h + 1) / 2); + } else #endif - { - buffersize = (*pitch) * rect->h; + { + buffersize = (*pitch) * rect->h; + } + + lockedbuffer = [data.mtldevice newBufferWithLength:buffersize options:MTLResourceStorageModeShared]; + if (lockedbuffer == nil) { + return SDL_OutOfMemory(); + } + + texturedata.lockedrect = *rect; + texturedata.lockedbuffer = lockedbuffer; + *pixels = [lockedbuffer contents]; + + return 0; } +} - lockedbuffer = [data.mtldevice newBufferWithLength:buffersize options:MTLResourceStorageModeShared]; - if (lockedbuffer == nil) { - return SDL_OutOfMemory(); - } +static void METAL_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata; + METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata; + id blitcmd; + SDL_Rect rect = texturedata.lockedrect; + int pitch = SDL_BYTESPERPIXEL(texture->format) * rect.w; + SDL_Rect UVrect = { rect.x / 2, rect.y / 2, (rect.w + 1) / 2, (rect.h + 1) / 2 }; - texturedata.lockedrect = *rect; - texturedata.lockedbuffer = lockedbuffer; - *pixels = [lockedbuffer contents]; + if (texturedata.lockedbuffer == nil) { + return; + } - return 0; -}} + if (data.mtlcmdencoder != nil) { + [data.mtlcmdencoder endEncoding]; + data.mtlcmdencoder = nil; + } -static void -METAL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ @autoreleasepool { - METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; - METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata; - id blitcmd; - SDL_Rect rect = texturedata.lockedrect; - int pitch = SDL_BYTESPERPIXEL(texture->format) * rect.w; - SDL_Rect UVrect = {rect.x / 2, rect.y / 2, (rect.w + 1) / 2, (rect.h + 1) / 2}; + if (data.mtlcmdbuffer == nil) { + data.mtlcmdbuffer = [data.mtlcmdqueue commandBuffer]; + } - if (texturedata.lockedbuffer == nil) { - return; - } - - if (data.mtlcmdencoder != nil) { - [data.mtlcmdencoder endEncoding]; - data.mtlcmdencoder = nil; - } - - if (data.mtlcmdbuffer == nil) { - data.mtlcmdbuffer = [data.mtlcmdqueue commandBuffer]; - } - - blitcmd = [data.mtlcmdbuffer blitCommandEncoder]; - - [blitcmd copyFromBuffer:texturedata.lockedbuffer - sourceOffset:0 - sourceBytesPerRow:pitch - sourceBytesPerImage:0 - sourceSize:MTLSizeMake(rect.w, rect.h, 1) - toTexture:texturedata.mtltexture - destinationSlice:0 - destinationLevel:0 - destinationOrigin:MTLOriginMake(rect.x, rect.y, 0)]; -#if SDL_HAVE_YUV - if (texturedata.yuv) { - int Uslice = texture->format == SDL_PIXELFORMAT_YV12 ? 1 : 0; - int Vslice = texture->format == SDL_PIXELFORMAT_YV12 ? 0 : 1; - int UVpitch = (pitch + 1) / 2; + blitcmd = [data.mtlcmdbuffer blitCommandEncoder]; [blitcmd copyFromBuffer:texturedata.lockedbuffer - sourceOffset:rect.h * pitch - sourceBytesPerRow:UVpitch - sourceBytesPerImage:UVpitch * UVrect.h - sourceSize:MTLSizeMake(UVrect.w, UVrect.h, 1) - toTexture:texturedata.mtltexture_uv - destinationSlice:Uslice - destinationLevel:0 - destinationOrigin:MTLOriginMake(UVrect.x, UVrect.y, 0)]; - - [blitcmd copyFromBuffer:texturedata.lockedbuffer - sourceOffset:(rect.h * pitch) + UVrect.h * UVpitch - sourceBytesPerRow:UVpitch - sourceBytesPerImage:UVpitch * UVrect.h - sourceSize:MTLSizeMake(UVrect.w, UVrect.h, 1) - toTexture:texturedata.mtltexture_uv - destinationSlice:Vslice - destinationLevel:0 - destinationOrigin:MTLOriginMake(UVrect.x, UVrect.y, 0)]; - } - - if (texturedata.nv12) { - int UVpitch = 2 * ((pitch + 1) / 2); - - [blitcmd copyFromBuffer:texturedata.lockedbuffer - sourceOffset:rect.h * pitch - sourceBytesPerRow:UVpitch + sourceOffset:0 + sourceBytesPerRow:pitch sourceBytesPerImage:0 - sourceSize:MTLSizeMake(UVrect.w, UVrect.h, 1) - toTexture:texturedata.mtltexture_uv + sourceSize:MTLSizeMake(rect.w, rect.h, 1) + toTexture:texturedata.mtltexture destinationSlice:0 destinationLevel:0 - destinationOrigin:MTLOriginMake(UVrect.x, UVrect.y, 0)]; - } + destinationOrigin:MTLOriginMake(rect.x, rect.y, 0)]; +#if SDL_HAVE_YUV + if (texturedata.yuv) { + int Uslice = texture->format == SDL_PIXELFORMAT_YV12 ? 1 : 0; + int Vslice = texture->format == SDL_PIXELFORMAT_YV12 ? 0 : 1; + int UVpitch = (pitch + 1) / 2; + + [blitcmd copyFromBuffer:texturedata.lockedbuffer + sourceOffset:rect.h * pitch + sourceBytesPerRow:UVpitch + sourceBytesPerImage:UVpitch * UVrect.h + sourceSize:MTLSizeMake(UVrect.w, UVrect.h, 1) + toTexture:texturedata.mtltexture_uv + destinationSlice:Uslice + destinationLevel:0 + destinationOrigin:MTLOriginMake(UVrect.x, UVrect.y, 0)]; + + [blitcmd copyFromBuffer:texturedata.lockedbuffer + sourceOffset:(rect.h * pitch) + UVrect.h * UVpitch + sourceBytesPerRow:UVpitch + sourceBytesPerImage:UVpitch * UVrect.h + sourceSize:MTLSizeMake(UVrect.w, UVrect.h, 1) + toTexture:texturedata.mtltexture_uv + destinationSlice:Vslice + destinationLevel:0 + destinationOrigin:MTLOriginMake(UVrect.x, UVrect.y, 0)]; + } + + if (texturedata.nv12) { + int UVpitch = 2 * ((pitch + 1) / 2); + + [blitcmd copyFromBuffer:texturedata.lockedbuffer + sourceOffset:rect.h * pitch + sourceBytesPerRow:UVpitch + sourceBytesPerImage:0 + sourceSize:MTLSizeMake(UVrect.w, UVrect.h, 1) + toTexture:texturedata.mtltexture_uv + destinationSlice:0 + destinationLevel:0 + destinationOrigin:MTLOriginMake(UVrect.x, UVrect.y, 0)]; + } #endif - [blitcmd endEncoding]; + [blitcmd endEncoding]; - [data.mtlcmdbuffer commit]; - data.mtlcmdbuffer = nil; - - texturedata.lockedbuffer = nil; /* Retained property, so it calls release. */ - texturedata.hasdata = YES; -}} - -static void -METAL_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode) -{ @autoreleasepool { - METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; - METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata; - - if (scaleMode == SDL_ScaleModeNearest) { - texturedata.mtlsampler = data.mtlsamplernearest; - } else { - texturedata.mtlsampler = data.mtlsamplerlinear; - } -}} - -static int -METAL_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) -{ @autoreleasepool { - METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; - - if (data.mtlcmdencoder) { - /* End encoding for the previous render target so we can set up a new - * render pass for this one. */ - [data.mtlcmdencoder endEncoding]; [data.mtlcmdbuffer commit]; - - data.mtlcmdencoder = nil; data.mtlcmdbuffer = nil; + + texturedata.lockedbuffer = nil; /* Retained property, so it calls release. */ + texturedata.hasdata = YES; } +} - /* We don't begin a new render pass right away - we delay it until an actual - * draw or clear happens. That way we can use hardware clears when possible, - * which are only available when beginning a new render pass. */ - return 0; -}} - - -static int -METAL_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd) +static void METAL_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode) { - float projection[4][4]; /* Prepare an orthographic projection */ + @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata; + METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata; + + if (scaleMode == SDL_ScaleModeNearest) { + texturedata.mtlsampler = data.mtlsamplernearest; + } else { + texturedata.mtlsampler = data.mtlsamplerlinear; + } + } +} + +static int METAL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) +{ + @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata; + + if (data.mtlcmdencoder) { + /* End encoding for the previous render target so we can set up a new + * render pass for this one. */ + [data.mtlcmdencoder endEncoding]; + [data.mtlcmdbuffer commit]; + + data.mtlcmdencoder = nil; + data.mtlcmdbuffer = nil; + } + + /* We don't begin a new render pass right away - we delay it until an actual + * draw or clear happens. That way we can use hardware clears when possible, + * which are only available when beginning a new render pass. */ + return 0; + } +} + +static int METAL_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd) +{ + float projection[4][4]; /* Prepare an orthographic projection */ const int w = cmd->data.viewport.rect.w; const int h = cmd->data.viewport.rect.h; - const size_t matrixlen = sizeof (projection); - float *matrix = (float *) SDL_AllocateRenderVertices(renderer, matrixlen, CONSTANT_ALIGN(16), &cmd->data.viewport.first); + const size_t matrixlen = sizeof(projection); + float *matrix = (float *)SDL_AllocateRenderVertices(renderer, matrixlen, CONSTANT_ALIGN(16), &cmd->data.viewport.first); if (!matrix) { return -1; } @@ -1021,27 +1046,25 @@ METAL_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd) return 0; } -static int -METAL_QueueSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd) +static int METAL_QueueSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { - const size_t vertlen = sizeof (float) * 4; - float *verts = (float *) SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(16), &cmd->data.color.first); + const size_t vertlen = sizeof(float) * 4; + float *verts = (float *)SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(16), &cmd->data.color.first); if (!verts) { return -1; } /* - * FIXME: not needed anymore, some cleanup to do + * FIXME: not needed anymore, some cleanup to do * - *(verts++) = ((float)cmd->data.color.r) / 255.0f; - *(verts++) = ((float)cmd->data.color.g) / 255.0f; - *(verts++) = ((float)cmd->data.color.b) / 255.0f; - *(verts++) = ((float)cmd->data.color.a) / 255.0f; - */ + *(verts++) = ((float)cmd->data.color.r) / 255.0f; + *(verts++) = ((float)cmd->data.color.g) / 255.0f; + *(verts++) = ((float)cmd->data.color.b) / 255.0f; + *(verts++) = ((float)cmd->data.color.a) / 255.0f; + */ return 0; } -static int -METAL_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) +static int METAL_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { const SDL_Color color = { cmd->data.draw.r, @@ -1050,8 +1073,8 @@ METAL_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL cmd->data.draw.a }; - const size_t vertlen = (2 * sizeof (float) + sizeof (SDL_Color)) * count; - float *verts = (float *) SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(8), &cmd->data.draw.first); + const size_t vertlen = (2 * sizeof(float) + sizeof(SDL_Color)) * count; + float *verts = (float *)SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(8), &cmd->data.draw.first); if (!verts) { return -1; } @@ -1065,8 +1088,7 @@ METAL_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL return 0; } -static int -METAL_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) +static int METAL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { const SDL_Color color = { cmd->data.draw.r, @@ -1077,10 +1099,10 @@ METAL_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_ size_t vertlen; float *verts; - SDL_assert(count >= 2); /* should have been checked at the higher level. */ + SDL_assert(count >= 2); /* should have been checked at the higher level. */ - vertlen = (2 * sizeof (float) + sizeof (SDL_Color)) * count; - verts = (float *) SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(8), &cmd->data.draw.first); + vertlen = (2 * sizeof(float) + sizeof(SDL_Color)) * count; + verts = (float *)SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(8), &cmd->data.draw.first); if (!verts) { return -1; } @@ -1100,7 +1122,7 @@ METAL_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_ that are missing a pixel that frames something and not arbitrary angles. Maybe !!! FIXME for later, though. */ - points -= 2; /* update the last line. */ + points -= 2; /* update the last line. */ verts -= 2 + 1; { @@ -1109,9 +1131,9 @@ METAL_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_ const float xend = points[1].x; const float yend = points[1].y; - if (ystart == yend) { /* horizontal line */ + if (ystart == yend) { /* horizontal line */ verts[0] += (xend > xstart) ? 1.0f : -1.0f; - } else if (xstart == xend) { /* vertical line */ + } else if (xstart == xend) { /* vertical line */ verts[1] += (yend > ystart) ? 1.0f : -1.0f; } } @@ -1119,15 +1141,14 @@ METAL_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_ return 0; } -static int -METAL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, - const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, - int num_vertices, const void *indices, int num_indices, int size_indices, - float scale_x, float scale_y) +static int METAL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, + int num_vertices, const void *indices, int num_indices, int size_indices, + float scale_x, float scale_y) { int count = indices ? num_indices : num_vertices; - const size_t vertlen = (2 * sizeof (float) + sizeof (int) + (texture ? 2 : 0) * sizeof (float)) * count; - float *verts = (float *) SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(8), &cmd->data.draw.first); + const size_t vertlen = (2 * sizeof(float) + sizeof(int) + (texture ? 2 : 0) * sizeof(float)) * count; + float *verts = (float *)SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(8), &cmd->data.draw.first); if (!verts) { return -1; } @@ -1148,15 +1169,15 @@ METAL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture j = i; } - xy_ = (float *)((char*)xy + j * xy_stride); + xy_ = (float *)((char *)xy + j * xy_stride); *(verts++) = xy_[0] * scale_x; *(verts++) = xy_[1] * scale_y; - *((SDL_Color *)verts++) = *(SDL_Color *)((char*)color + j * color_stride); + *((SDL_Color *)verts++) = *(SDL_Color *)((char *)color + j * color_stride); if (texture) { - float *uv_ = (float *)((char*)uv + j * uv_stride); + float *uv_ = (float *)((char *)uv + j * uv_stride); *(verts++) = uv_[0]; *(verts++) = uv_[1]; } @@ -1181,11 +1202,10 @@ typedef struct size_t color_offset; } METAL_DrawStateCache; -static SDL_bool -SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const SDL_MetalFragmentFunction shader, - const size_t constants_offset, id mtlbufvertex, METAL_DrawStateCache *statecache) +static SDL_bool SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const SDL_MetalFragmentFunction shader, + const size_t constants_offset, id mtlbufvertex, METAL_DrawStateCache *statecache) { - METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata; const SDL_BlendMode blend = cmd->data.draw.blend; size_t first = cmd->data.draw.first; id newpipeline; @@ -1203,7 +1223,7 @@ SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const SDL_Met viewport.znear = 0.0; viewport.zfar = 1.0; [data.mtlcmdencoder setViewport:viewport]; - [data.mtlcmdencoder setVertexBuffer:mtlbufvertex offset:statecache->projection_offset atIndex:2]; // projection + [data.mtlcmdencoder setVertexBuffer:mtlbufvertex offset:statecache->projection_offset atIndex:2]; // projection statecache->viewport_dirty = SDL_FALSE; } @@ -1262,11 +1282,10 @@ SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const SDL_Met return SDL_TRUE; } -static SDL_bool -SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const size_t constants_offset, - id mtlbufvertex, METAL_DrawStateCache *statecache) +static SDL_bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const size_t constants_offset, + id mtlbufvertex, METAL_DrawStateCache *statecache) { - METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata; SDL_Texture *texture = cmd->data.draw.texture; METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata; @@ -1277,7 +1296,7 @@ SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const size_t if (texture != statecache->texture) { METAL_TextureData *oldtexturedata = NULL; if (statecache->texture) { - oldtexturedata = (__bridge METAL_TextureData *) statecache->texture->driverdata; + oldtexturedata = (__bridge METAL_TextureData *)statecache->texture->driverdata; } if (!oldtexturedata || (texturedata.mtlsampler != oldtexturedata.mtlsampler)) { [data.mtlcmdencoder setFragmentSamplerState:texturedata.mtlsampler atIndex:0]; @@ -1295,70 +1314,74 @@ SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const size_t return SDL_TRUE; } -static int -METAL_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) -{ @autoreleasepool { - METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; - id mtlbufvertex = nil; - METAL_DrawStateCache statecache; - SDL_zero(statecache); +static int METAL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) +{ + @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata; + id mtlbufvertex = nil; + METAL_DrawStateCache statecache; + SDL_zero(statecache); - statecache.pipeline = nil; - statecache.vertex_buffer = nil; - statecache.constants_offset = CONSTANTS_OFFSET_INVALID; - statecache.texture = NULL; - statecache.color_dirty = SDL_TRUE; - statecache.cliprect_dirty = SDL_TRUE; - statecache.viewport_dirty = SDL_TRUE; - statecache.projection_offset = 0; - statecache.color_offset = 0; + statecache.pipeline = nil; + statecache.vertex_buffer = nil; + statecache.constants_offset = CONSTANTS_OFFSET_INVALID; + statecache.texture = NULL; + statecache.color_dirty = SDL_TRUE; + statecache.cliprect_dirty = SDL_TRUE; + statecache.viewport_dirty = SDL_TRUE; + statecache.projection_offset = 0; + statecache.color_offset = 0; - // !!! FIXME: have a ring of pre-made MTLBuffers we cycle through? How expensive is creation? - if (vertsize > 0) { - /* We can memcpy to a shared buffer from the CPU and read it from the GPU - * without any extra copying. It's a bit slower on macOS to read shared - * data from the GPU than to read managed/private data, but we avoid the - * cost of copying the data and the code's simpler. Apple's best - * practices guide recommends this approach for streamed vertex data. - * TODO: this buffer is also used for constants. Is performance still - * good for those, or should we have a managed buffer for them? */ - mtlbufvertex = [data.mtldevice newBufferWithLength:vertsize options:MTLResourceStorageModeShared]; - mtlbufvertex.label = @"SDL vertex data"; - SDL_memcpy([mtlbufvertex contents], vertices, vertsize); + // !!! FIXME: have a ring of pre-made MTLBuffers we cycle through? How expensive is creation? + if (vertsize > 0) { + /* We can memcpy to a shared buffer from the CPU and read it from the GPU + * without any extra copying. It's a bit slower on macOS to read shared + * data from the GPU than to read managed/private data, but we avoid the + * cost of copying the data and the code's simpler. Apple's best + * practices guide recommends this approach for streamed vertex data. + * TODO: this buffer is also used for constants. Is performance still + * good for those, or should we have a managed buffer for them? */ + mtlbufvertex = [data.mtldevice newBufferWithLength:vertsize options:MTLResourceStorageModeShared]; + mtlbufvertex.label = @"SDL vertex data"; + SDL_memcpy([mtlbufvertex contents], vertices, vertsize); - statecache.vertex_buffer = mtlbufvertex; - } + statecache.vertex_buffer = mtlbufvertex; + } - // If there's a command buffer here unexpectedly (app requested one?). Commit it so we can start fresh. - [data.mtlcmdencoder endEncoding]; - [data.mtlcmdbuffer commit]; - data.mtlcmdencoder = nil; - data.mtlcmdbuffer = nil; + // If there's a command buffer here unexpectedly (app requested one?). Commit it so we can start fresh. + [data.mtlcmdencoder endEncoding]; + [data.mtlcmdbuffer commit]; + data.mtlcmdencoder = nil; + data.mtlcmdbuffer = nil; - while (cmd) { - switch (cmd->command) { - case SDL_RENDERCMD_SETVIEWPORT: { - SDL_memcpy(&statecache.viewport, &cmd->data.viewport.rect, sizeof (statecache.viewport)); + while (cmd) { + switch (cmd->command) { + case SDL_RENDERCMD_SETVIEWPORT: + { + SDL_memcpy(&statecache.viewport, &cmd->data.viewport.rect, sizeof(statecache.viewport)); statecache.projection_offset = cmd->data.viewport.first; statecache.viewport_dirty = SDL_TRUE; statecache.cliprect_dirty = SDL_TRUE; break; } - case SDL_RENDERCMD_SETCLIPRECT: { - SDL_memcpy(&statecache.cliprect, &cmd->data.cliprect.rect, sizeof (statecache.cliprect)); + case SDL_RENDERCMD_SETCLIPRECT: + { + SDL_memcpy(&statecache.cliprect, &cmd->data.cliprect.rect, sizeof(statecache.cliprect)); statecache.cliprect_enabled = cmd->data.cliprect.enabled; statecache.cliprect_dirty = SDL_TRUE; break; } - case SDL_RENDERCMD_SETDRAWCOLOR: { + case SDL_RENDERCMD_SETDRAWCOLOR: + { statecache.color_offset = cmd->data.color.first; statecache.color_dirty = SDL_TRUE; break; } - case SDL_RENDERCMD_CLEAR: { + case SDL_RENDERCMD_CLEAR: + { /* If we're already encoding a command buffer, dump it without committing it. We'd just clear all its work anyhow, and starting a new encoder will let us use a hardware clear operation via MTLLoadActionClear. */ @@ -1394,7 +1417,8 @@ METAL_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *ver } case SDL_RENDERCMD_DRAW_POINTS: - case SDL_RENDERCMD_DRAW_LINES: { + case SDL_RENDERCMD_DRAW_LINES: + { const size_t count = cmd->data.draw.count; const MTLPrimitiveType primtype = (cmd->command == SDL_RENDERCMD_DRAW_POINTS) ? MTLPrimitiveTypePoint : MTLPrimitiveTypeLineStrip; if (SetDrawState(renderer, cmd, SDL_METAL_FRAGMENT_SOLID, CONSTANTS_OFFSET_HALF_PIXEL_TRANSFORM, mtlbufvertex, &statecache)) { @@ -1412,7 +1436,8 @@ METAL_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *ver case SDL_RENDERCMD_COPY_EX: /* unused */ break; - case SDL_RENDERCMD_GEOMETRY: { + case SDL_RENDERCMD_GEOMETRY: + { const size_t count = cmd->data.draw.count; SDL_Texture *texture = cmd->data.draw.texture; @@ -1430,29 +1455,30 @@ METAL_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *ver case SDL_RENDERCMD_NO_OP: break; + } + cmd = cmd->next; } - cmd = cmd->next; + + return 0; } +} - return 0; -}} +static int METAL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, + Uint32 pixel_format, void *pixels, int pitch) +{ + @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata; + id mtltexture; + MTLRegion mtlregion; + int temp_pitch, status; + Uint32 temp_format; + void *temp_pixels; + if (!METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionLoad, NULL, nil)) { + return SDL_SetError("Failed to activate render command encoder (is your window in the background?"); + } -static int -METAL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 pixel_format, void * pixels, int pitch) -{ @autoreleasepool { - METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; - id mtltexture; - MTLRegion mtlregion; - int temp_pitch, status; - Uint32 temp_format; - void *temp_pixels; - if (!METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionLoad, NULL, nil)) { - return SDL_SetError("Failed to activate render command encoder (is your window in the background?"); - } - - [data.mtlcmdencoder endEncoding]; - mtltexture = data.mtlpassdesc.colorAttachments[0].texture; + [data.mtlcmdencoder endEncoding]; + mtltexture = data.mtlpassdesc.colorAttachments[0].texture; #ifdef __MACOSX__ /* on macOS with managed-storage textures, we need to tell the driver to @@ -1466,122 +1492,127 @@ METAL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, } #endif - /* Commit the current command buffer and wait until it's completed, to make - * sure the GPU has finished rendering to it by the time we read it. */ - [data.mtlcmdbuffer commit]; - [data.mtlcmdbuffer waitUntilCompleted]; - data.mtlcmdencoder = nil; - data.mtlcmdbuffer = nil; + /* Commit the current command buffer and wait until it's completed, to make + * sure the GPU has finished rendering to it by the time we read it. */ + [data.mtlcmdbuffer commit]; + [data.mtlcmdbuffer waitUntilCompleted]; + data.mtlcmdencoder = nil; + data.mtlcmdbuffer = nil; - mtlregion = MTLRegionMake2D(rect->x, rect->y, rect->w, rect->h); + mtlregion = MTLRegionMake2D(rect->x, rect->y, rect->w, rect->h); - // we only do BGRA8 or RGBA8 at the moment, so 4 will do. - temp_pitch = rect->w * 4; - temp_pixels = SDL_malloc(temp_pitch * rect->h); - if (!temp_pixels) { - return SDL_OutOfMemory(); - } - - [mtltexture getBytes:temp_pixels bytesPerRow:temp_pitch fromRegion:mtlregion mipmapLevel:0]; - - temp_format = (mtltexture.pixelFormat == MTLPixelFormatBGRA8Unorm) ? SDL_PIXELFORMAT_ARGB8888 : SDL_PIXELFORMAT_ABGR8888; - status = SDL_ConvertPixels(rect->w, rect->h, temp_format, temp_pixels, temp_pitch, pixel_format, pixels, pitch); - SDL_free(temp_pixels); - return status; -}} - -static int -METAL_RenderPresent(SDL_Renderer * renderer) -{ @autoreleasepool { - METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; - SDL_bool ready = SDL_TRUE; - - // If we don't have a command buffer, we can't present, so activate to get one. - if (data.mtlcmdencoder == nil) { - // We haven't even gotten a backbuffer yet? Clear it to black. Otherwise, load the existing data. - if (data.mtlbackbuffer == nil) { - MTLClearColor color = MTLClearColorMake(0.0f, 0.0f, 0.0f, 1.0f); - ready = METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionClear, &color, nil); - } else { - ready = METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionLoad, NULL, nil); - } - } - - [data.mtlcmdencoder endEncoding]; - - // If we don't have a drawable to present, don't try to present it. - // But we'll still try to commit the command buffer in case it was already enqueued. - if (ready) { - SDL_assert(data.mtlbackbuffer != nil); - [data.mtlcmdbuffer presentDrawable:data.mtlbackbuffer]; - } - - [data.mtlcmdbuffer commit]; - - data.mtlcmdencoder = nil; - data.mtlcmdbuffer = nil; - data.mtlbackbuffer = nil; - - if (renderer->hidden || !ready) { - return -1; - } - return 0; -}} - -static void -METAL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ @autoreleasepool { - CFBridgingRelease(texture->driverdata); - texture->driverdata = NULL; -}} - -static void -METAL_DestroyRenderer(SDL_Renderer * renderer) -{ @autoreleasepool { - if (renderer->driverdata) { - METAL_RenderData *data = CFBridgingRelease(renderer->driverdata); - - if (data.mtlcmdencoder != nil) { - [data.mtlcmdencoder endEncoding]; + // we only do BGRA8 or RGBA8 at the moment, so 4 will do. + temp_pitch = rect->w * 4; + temp_pixels = SDL_malloc(temp_pitch * rect->h); + if (!temp_pixels) { + return SDL_OutOfMemory(); } - DestroyAllPipelines(data.allpipelines, data.pipelinescount); + [mtltexture getBytes:temp_pixels bytesPerRow:temp_pitch fromRegion:mtlregion mipmapLevel:0]; - /* Release the metal view instead of destroying it, - in case we want to use it later (recreating the renderer) - */ - /* SDL_Metal_DestroyView(data.mtlview); */ - CFBridgingRelease(data.mtlview); + temp_format = (mtltexture.pixelFormat == MTLPixelFormatBGRA8Unorm) ? SDL_PIXELFORMAT_ARGB8888 : SDL_PIXELFORMAT_ABGR8888; + status = SDL_ConvertPixels(rect->w, rect->h, temp_format, temp_pixels, temp_pitch, pixel_format, pixels, pitch); + SDL_free(temp_pixels); + return status; } +} - SDL_free(renderer); -}} +static int METAL_RenderPresent(SDL_Renderer *renderer) +{ + @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata; + SDL_bool ready = SDL_TRUE; -static void * -METAL_GetMetalLayer(SDL_Renderer * renderer) -{ @autoreleasepool { - METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; - return (__bridge void*)data.mtllayer; -}} + // If we don't have a command buffer, we can't present, so activate to get one. + if (data.mtlcmdencoder == nil) { + // We haven't even gotten a backbuffer yet? Clear it to black. Otherwise, load the existing data. + if (data.mtlbackbuffer == nil) { + MTLClearColor color = MTLClearColorMake(0.0f, 0.0f, 0.0f, 1.0f); + ready = METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionClear, &color, nil); + } else { + ready = METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionLoad, NULL, nil); + } + } -static void * -METAL_GetMetalCommandEncoder(SDL_Renderer * renderer) -{ @autoreleasepool { - // note that data.mtlcmdencoder can be nil if METAL_ActivateRenderCommandEncoder fails. - // Before SDL 2.0.18, it might have returned a non-nil encoding that might not have been - // usable for presentation. Check your return values! - METAL_RenderData *data; - METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionLoad, NULL, nil); - data = (__bridge METAL_RenderData *) renderer->driverdata; - return (__bridge void*)data.mtlcmdencoder; -}} + [data.mtlcmdencoder endEncoding]; -static int -METAL_SetVSync(SDL_Renderer * renderer, const int vsync) + // If we don't have a drawable to present, don't try to present it. + // But we'll still try to commit the command buffer in case it was already enqueued. + if (ready) { + SDL_assert(data.mtlbackbuffer != nil); + [data.mtlcmdbuffer presentDrawable:data.mtlbackbuffer]; + } + + [data.mtlcmdbuffer commit]; + + data.mtlcmdencoder = nil; + data.mtlcmdbuffer = nil; + data.mtlbackbuffer = nil; + + if (renderer->hidden || !ready) { + return -1; + } + return 0; + } +} + +static void METAL_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + @autoreleasepool { + CFBridgingRelease(texture->driverdata); + texture->driverdata = NULL; + } +} + +static void METAL_DestroyRenderer(SDL_Renderer *renderer) +{ + @autoreleasepool { + if (renderer->driverdata) { + METAL_RenderData *data = CFBridgingRelease(renderer->driverdata); + + if (data.mtlcmdencoder != nil) { + [data.mtlcmdencoder endEncoding]; + } + + DestroyAllPipelines(data.allpipelines, data.pipelinescount); + + /* Release the metal view instead of destroying it, + in case we want to use it later (recreating the renderer) + */ + /* SDL_Metal_DestroyView(data.mtlview); */ + CFBridgingRelease(data.mtlview); + } + + SDL_free(renderer); + } +} + +static void *METAL_GetMetalLayer(SDL_Renderer *renderer) +{ + @autoreleasepool { + METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata; + return (__bridge void *)data.mtllayer; + } +} + +static void *METAL_GetMetalCommandEncoder(SDL_Renderer *renderer) +{ + @autoreleasepool { + // note that data.mtlcmdencoder can be nil if METAL_ActivateRenderCommandEncoder fails. + // Before SDL 2.0.18, it might have returned a non-nil encoding that might not have been + // usable for presentation. Check your return values! + METAL_RenderData *data; + METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionLoad, NULL, nil); + data = (__bridge METAL_RenderData *)renderer->driverdata; + return (__bridge void *)data.mtlcmdencoder; + } +} + +static int METAL_SetVSync(SDL_Renderer *renderer, const int vsync) { #if (defined(__MACOSX__) && defined(MAC_OS_X_VERSION_10_13)) || TARGET_OS_MACCATALYST if (@available(macOS 10.13, *)) { - METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; + METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata; if (vsync) { data.mtllayer.displaySyncEnabled = YES; renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; @@ -1623,238 +1654,263 @@ static SDL_MetalView GetWindowView(SDL_Window *window) return nil; } -static SDL_Renderer * -METAL_CreateRenderer(SDL_Window * window, Uint32 flags) -{ @autoreleasepool { - SDL_Renderer *renderer = NULL; - METAL_RenderData *data = NULL; - id mtldevice = nil; - SDL_MetalView view = NULL; - CAMetalLayer *layer = nil; - SDL_SysWMinfo syswm; - NSError *err = nil; - dispatch_data_t mtllibdata; - char *constantdata; - int maxtexsize, quadcount = UINT16_MAX / 4; - UInt16 *indexdata; - size_t indicessize = sizeof(UInt16) * quadcount * 6; - MTLSamplerDescriptor *samplerdesc; - id mtlcmdqueue; - id mtllibrary; - id mtlsamplernearest, mtlsamplerlinear; - id mtlbufconstantstaging, mtlbufquadindicesstaging, mtlbufconstants, mtlbufquadindices; - id cmdbuffer; - id blitcmd; +static SDL_Renderer *METAL_CreateRenderer(SDL_Window *window, Uint32 flags) +{ + @autoreleasepool { + SDL_Renderer *renderer = NULL; + METAL_RenderData *data = NULL; + id mtldevice = nil; + SDL_MetalView view = NULL; + CAMetalLayer *layer = nil; + SDL_SysWMinfo syswm; + NSError *err = nil; + dispatch_data_t mtllibdata; + char *constantdata; + int maxtexsize, quadcount = UINT16_MAX / 4; + UInt16 *indexdata; + size_t indicessize = sizeof(UInt16) * quadcount * 6; + MTLSamplerDescriptor *samplerdesc; + id mtlcmdqueue; + id mtllibrary; + id mtlsamplernearest, mtlsamplerlinear; + id mtlbufconstantstaging, mtlbufquadindicesstaging, mtlbufconstants, mtlbufquadindices; + id cmdbuffer; + id blitcmd; - /* Note: matrices are column major. */ - float identitytransform[16] = { - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f, - }; + /* Note: matrices are column major. */ + float identitytransform[16] = { + 1.0f, + 0.0f, + 0.0f, + 0.0f, + 0.0f, + 1.0f, + 0.0f, + 0.0f, + 0.0f, + 0.0f, + 1.0f, + 0.0f, + 0.0f, + 0.0f, + 0.0f, + 1.0f, + }; - float halfpixeltransform[16] = { - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.5f, 0.5f, 0.0f, 1.0f, - }; + float halfpixeltransform[16] = { + 1.0f, + 0.0f, + 0.0f, + 0.0f, + 0.0f, + 1.0f, + 0.0f, + 0.0f, + 0.0f, + 0.0f, + 1.0f, + 0.0f, + 0.5f, + 0.5f, + 0.0f, + 1.0f, + }; - /* Metal pads float3s to 16 bytes. */ - float decodetransformJPEG[4*4] = { - 0.0, -0.501960814, -0.501960814, 0.0, /* offset */ - 1.0000, 0.0000, 1.4020, 0.0, /* Rcoeff */ - 1.0000, -0.3441, -0.7141, 0.0, /* Gcoeff */ - 1.0000, 1.7720, 0.0000, 0.0, /* Bcoeff */ - }; + /* Metal pads float3s to 16 bytes. */ + float decodetransformJPEG[4 * 4] = { + 0.0, -0.501960814, -0.501960814, 0.0, /* offset */ + 1.0000, 0.0000, 1.4020, 0.0, /* Rcoeff */ + 1.0000, -0.3441, -0.7141, 0.0, /* Gcoeff */ + 1.0000, 1.7720, 0.0000, 0.0, /* Bcoeff */ + }; - float decodetransformBT601[4*4] = { - -0.0627451017, -0.501960814, -0.501960814, 0.0, /* offset */ - 1.1644, 0.0000, 1.5960, 0.0, /* Rcoeff */ - 1.1644, -0.3918, -0.8130, 0.0, /* Gcoeff */ - 1.1644, 2.0172, 0.0000, 0.0, /* Bcoeff */ - }; + float decodetransformBT601[4 * 4] = { + -0.0627451017, -0.501960814, -0.501960814, 0.0, /* offset */ + 1.1644, 0.0000, 1.5960, 0.0, /* Rcoeff */ + 1.1644, -0.3918, -0.8130, 0.0, /* Gcoeff */ + 1.1644, 2.0172, 0.0000, 0.0, /* Bcoeff */ + }; - float decodetransformBT709[4*4] = { - 0.0, -0.501960814, -0.501960814, 0.0, /* offset */ - 1.0000, 0.0000, 1.4020, 0.0, /* Rcoeff */ - 1.0000, -0.3441, -0.7141, 0.0, /* Gcoeff */ - 1.0000, 1.7720, 0.0000, 0.0, /* Bcoeff */ - }; + float decodetransformBT709[4 * 4] = { + 0.0, -0.501960814, -0.501960814, 0.0, /* offset */ + 1.0000, 0.0000, 1.4020, 0.0, /* Rcoeff */ + 1.0000, -0.3441, -0.7141, 0.0, /* Gcoeff */ + 1.0000, 1.7720, 0.0000, 0.0, /* Bcoeff */ + }; SDL_VERSION(&syswm.version); if (!SDL_GetWindowWMInfo(window, &syswm)) { return NULL; } - if (IsMetalAvailable(&syswm) == -1) { - return NULL; - } + if (IsMetalAvailable(&syswm) == -1) { + return NULL; + } - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); - if (!renderer) { - SDL_OutOfMemory(); - return NULL; - } + renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); + if (!renderer) { + SDL_OutOfMemory(); + return NULL; + } - // !!! FIXME: MTLCopyAllDevices() can find other GPUs on macOS... - mtldevice = MTLCreateSystemDefaultDevice(); + // !!! FIXME: MTLCopyAllDevices() can find other GPUs on macOS... + mtldevice = MTLCreateSystemDefaultDevice(); - if (mtldevice == nil) { - SDL_free(renderer); - SDL_SetError("Failed to obtain Metal device"); - return NULL; - } + if (mtldevice == nil) { + SDL_free(renderer); + SDL_SetError("Failed to obtain Metal device"); + return NULL; + } - view = GetWindowView(window); - if (view == nil) { - view = SDL_Metal_CreateView(window); - } + view = GetWindowView(window); + if (view == nil) { + view = SDL_Metal_CreateView(window); + } - if (view == NULL) { - SDL_free(renderer); - return NULL; - } + if (view == NULL) { + SDL_free(renderer); + return NULL; + } - // !!! FIXME: error checking on all of this. - data = [[METAL_RenderData alloc] init]; + // !!! FIXME: error checking on all of this. + data = [[METAL_RenderData alloc] init]; - if (data == nil) { - /* Release the metal view instead of destroying it, - in case we want to use it later (recreating the renderer) - */ - /* SDL_Metal_DestroyView(view); */ - CFBridgingRelease(view); - SDL_free(renderer); - return NULL; - } + if (data == nil) { + /* Release the metal view instead of destroying it, + in case we want to use it later (recreating the renderer) + */ + /* SDL_Metal_DestroyView(view); */ + CFBridgingRelease(view); + SDL_free(renderer); + return NULL; + } - renderer->driverdata = (void*)CFBridgingRetain(data); - renderer->window = window; + renderer->driverdata = (void *)CFBridgingRetain(data); + renderer->window = window; - data.mtlview = view; + data.mtlview = view; #ifdef __MACOSX__ layer = (CAMetalLayer *)[(__bridge NSView *)view layer]; #else - layer = (CAMetalLayer *)[(__bridge UIView *)view layer]; + layer = (CAMetalLayer *)[(__bridge UIView *)view layer]; #endif - layer.device = mtldevice; + layer.device = mtldevice; - /* Necessary for RenderReadPixels. */ - layer.framebufferOnly = NO; + /* Necessary for RenderReadPixels. */ + layer.framebufferOnly = NO; - data.mtldevice = layer.device; - data.mtllayer = layer; - mtlcmdqueue = [data.mtldevice newCommandQueue]; - data.mtlcmdqueue = mtlcmdqueue; - data.mtlcmdqueue.label = @"SDL Metal Renderer"; - data.mtlpassdesc = [MTLRenderPassDescriptor renderPassDescriptor]; + data.mtldevice = layer.device; + data.mtllayer = layer; + mtlcmdqueue = [data.mtldevice newCommandQueue]; + data.mtlcmdqueue = mtlcmdqueue; + data.mtlcmdqueue.label = @"SDL Metal Renderer"; + data.mtlpassdesc = [MTLRenderPassDescriptor renderPassDescriptor]; - // The compiled .metallib is embedded in a static array in a header file - // but the original shader source code is in SDL_shaders_metal.metal. - mtllibdata = dispatch_data_create(sdl_metallib, sdl_metallib_len, dispatch_get_global_queue(0, 0), ^{}); - mtllibrary = [data.mtldevice newLibraryWithData:mtllibdata error:&err]; - data.mtllibrary = mtllibrary; - SDL_assert(err == nil); - data.mtllibrary.label = @"SDL Metal renderer shader library"; + // The compiled .metallib is embedded in a static array in a header file + // but the original shader source code is in SDL_shaders_metal.metal. + mtllibdata = dispatch_data_create(sdl_metallib, sdl_metallib_len, dispatch_get_global_queue(0, 0), ^{ + }); + mtllibrary = [data.mtldevice newLibraryWithData:mtllibdata error:&err]; + data.mtllibrary = mtllibrary; + SDL_assert(err == nil); + data.mtllibrary.label = @"SDL Metal renderer shader library"; - /* Do some shader pipeline state loading up-front rather than on demand. */ - data.pipelinescount = 0; - data.allpipelines = NULL; - ChooseShaderPipelines(data, MTLPixelFormatBGRA8Unorm); + /* Do some shader pipeline state loading up-front rather than on demand. */ + data.pipelinescount = 0; + data.allpipelines = NULL; + ChooseShaderPipelines(data, MTLPixelFormatBGRA8Unorm); - samplerdesc = [[MTLSamplerDescriptor alloc] init]; + samplerdesc = [[MTLSamplerDescriptor alloc] init]; - samplerdesc.minFilter = MTLSamplerMinMagFilterNearest; - samplerdesc.magFilter = MTLSamplerMinMagFilterNearest; - mtlsamplernearest = [data.mtldevice newSamplerStateWithDescriptor:samplerdesc]; - data.mtlsamplernearest = mtlsamplernearest; + samplerdesc.minFilter = MTLSamplerMinMagFilterNearest; + samplerdesc.magFilter = MTLSamplerMinMagFilterNearest; + mtlsamplernearest = [data.mtldevice newSamplerStateWithDescriptor:samplerdesc]; + data.mtlsamplernearest = mtlsamplernearest; - samplerdesc.minFilter = MTLSamplerMinMagFilterLinear; - samplerdesc.magFilter = MTLSamplerMinMagFilterLinear; - mtlsamplerlinear = [data.mtldevice newSamplerStateWithDescriptor:samplerdesc]; - data.mtlsamplerlinear = mtlsamplerlinear; + samplerdesc.minFilter = MTLSamplerMinMagFilterLinear; + samplerdesc.magFilter = MTLSamplerMinMagFilterLinear; + mtlsamplerlinear = [data.mtldevice newSamplerStateWithDescriptor:samplerdesc]; + data.mtlsamplerlinear = mtlsamplerlinear; - mtlbufconstantstaging = [data.mtldevice newBufferWithLength:CONSTANTS_LENGTH options:MTLResourceStorageModeShared]; + mtlbufconstantstaging = [data.mtldevice newBufferWithLength:CONSTANTS_LENGTH options:MTLResourceStorageModeShared]; - constantdata = [mtlbufconstantstaging contents]; - SDL_memcpy(constantdata + CONSTANTS_OFFSET_IDENTITY, identitytransform, sizeof(identitytransform)); - SDL_memcpy(constantdata + CONSTANTS_OFFSET_HALF_PIXEL_TRANSFORM, halfpixeltransform, sizeof(halfpixeltransform)); - SDL_memcpy(constantdata + CONSTANTS_OFFSET_DECODE_JPEG, decodetransformJPEG, sizeof(decodetransformJPEG)); - SDL_memcpy(constantdata + CONSTANTS_OFFSET_DECODE_BT601, decodetransformBT601, sizeof(decodetransformBT601)); - SDL_memcpy(constantdata + CONSTANTS_OFFSET_DECODE_BT709, decodetransformBT709, sizeof(decodetransformBT709)); + constantdata = [mtlbufconstantstaging contents]; + SDL_memcpy(constantdata + CONSTANTS_OFFSET_IDENTITY, identitytransform, sizeof(identitytransform)); + SDL_memcpy(constantdata + CONSTANTS_OFFSET_HALF_PIXEL_TRANSFORM, halfpixeltransform, sizeof(halfpixeltransform)); + SDL_memcpy(constantdata + CONSTANTS_OFFSET_DECODE_JPEG, decodetransformJPEG, sizeof(decodetransformJPEG)); + SDL_memcpy(constantdata + CONSTANTS_OFFSET_DECODE_BT601, decodetransformBT601, sizeof(decodetransformBT601)); + SDL_memcpy(constantdata + CONSTANTS_OFFSET_DECODE_BT709, decodetransformBT709, sizeof(decodetransformBT709)); - mtlbufquadindicesstaging = [data.mtldevice newBufferWithLength:indicessize options:MTLResourceStorageModeShared]; + mtlbufquadindicesstaging = [data.mtldevice newBufferWithLength:indicessize options:MTLResourceStorageModeShared]; - /* Quads in the following vertex order (matches the FillRects vertices): - * 1---3 - * | \ | - * 0---2 - */ - indexdata = [mtlbufquadindicesstaging contents]; - for (int i = 0; i < quadcount; i++) { - indexdata[i * 6 + 0] = i * 4 + 0; - indexdata[i * 6 + 1] = i * 4 + 1; - indexdata[i * 6 + 2] = i * 4 + 2; + /* Quads in the following vertex order (matches the FillRects vertices): + * 1---3 + * | \ | + * 0---2 + */ + indexdata = [mtlbufquadindicesstaging contents]; + for (int i = 0; i < quadcount; i++) { + indexdata[i * 6 + 0] = i * 4 + 0; + indexdata[i * 6 + 1] = i * 4 + 1; + indexdata[i * 6 + 2] = i * 4 + 2; - indexdata[i * 6 + 3] = i * 4 + 2; - indexdata[i * 6 + 4] = i * 4 + 1; - indexdata[i * 6 + 5] = i * 4 + 3; - } + indexdata[i * 6 + 3] = i * 4 + 2; + indexdata[i * 6 + 4] = i * 4 + 1; + indexdata[i * 6 + 5] = i * 4 + 3; + } - mtlbufconstants = [data.mtldevice newBufferWithLength:CONSTANTS_LENGTH options:MTLResourceStorageModePrivate]; - data.mtlbufconstants = mtlbufconstants; - data.mtlbufconstants.label = @"SDL constant data"; + mtlbufconstants = [data.mtldevice newBufferWithLength:CONSTANTS_LENGTH options:MTLResourceStorageModePrivate]; + data.mtlbufconstants = mtlbufconstants; + data.mtlbufconstants.label = @"SDL constant data"; - mtlbufquadindices = [data.mtldevice newBufferWithLength:indicessize options:MTLResourceStorageModePrivate]; - data.mtlbufquadindices = mtlbufquadindices; - data.mtlbufquadindices.label = @"SDL quad index buffer"; + mtlbufquadindices = [data.mtldevice newBufferWithLength:indicessize options:MTLResourceStorageModePrivate]; + data.mtlbufquadindices = mtlbufquadindices; + data.mtlbufquadindices.label = @"SDL quad index buffer"; - cmdbuffer = [data.mtlcmdqueue commandBuffer]; - blitcmd = [cmdbuffer blitCommandEncoder]; + cmdbuffer = [data.mtlcmdqueue commandBuffer]; + blitcmd = [cmdbuffer blitCommandEncoder]; - [blitcmd copyFromBuffer:mtlbufconstantstaging sourceOffset:0 toBuffer:mtlbufconstants destinationOffset:0 size:CONSTANTS_LENGTH]; - [blitcmd copyFromBuffer:mtlbufquadindicesstaging sourceOffset:0 toBuffer:mtlbufquadindices destinationOffset:0 size:indicessize]; + [blitcmd copyFromBuffer:mtlbufconstantstaging sourceOffset:0 toBuffer:mtlbufconstants destinationOffset:0 size:CONSTANTS_LENGTH]; + [blitcmd copyFromBuffer:mtlbufquadindicesstaging sourceOffset:0 toBuffer:mtlbufquadindices destinationOffset:0 size:indicessize]; - [blitcmd endEncoding]; - [cmdbuffer commit]; + [blitcmd endEncoding]; + [cmdbuffer commit]; - // !!! FIXME: force more clears here so all the drawables are sane to start, and our static buffers are definitely flushed. + // !!! FIXME: force more clears here so all the drawables are sane to start, and our static buffers are definitely flushed. - renderer->WindowEvent = METAL_WindowEvent; - renderer->GetOutputSize = METAL_GetOutputSize; - renderer->SupportsBlendMode = METAL_SupportsBlendMode; - renderer->CreateTexture = METAL_CreateTexture; - renderer->UpdateTexture = METAL_UpdateTexture; + renderer->WindowEvent = METAL_WindowEvent; + renderer->GetOutputSize = METAL_GetOutputSize; + renderer->SupportsBlendMode = METAL_SupportsBlendMode; + renderer->CreateTexture = METAL_CreateTexture; + renderer->UpdateTexture = METAL_UpdateTexture; #if SDL_HAVE_YUV - renderer->UpdateTextureYUV = METAL_UpdateTextureYUV; - renderer->UpdateTextureNV = METAL_UpdateTextureNV; + renderer->UpdateTextureYUV = METAL_UpdateTextureYUV; + renderer->UpdateTextureNV = METAL_UpdateTextureNV; #endif - renderer->LockTexture = METAL_LockTexture; - renderer->UnlockTexture = METAL_UnlockTexture; - renderer->SetTextureScaleMode = METAL_SetTextureScaleMode; - renderer->SetRenderTarget = METAL_SetRenderTarget; - renderer->QueueSetViewport = METAL_QueueSetViewport; - renderer->QueueSetDrawColor = METAL_QueueSetDrawColor; - renderer->QueueDrawPoints = METAL_QueueDrawPoints; - renderer->QueueDrawLines = METAL_QueueDrawLines; - renderer->QueueGeometry = METAL_QueueGeometry; - renderer->RunCommandQueue = METAL_RunCommandQueue; - renderer->RenderReadPixels = METAL_RenderReadPixels; - renderer->RenderPresent = METAL_RenderPresent; - renderer->DestroyTexture = METAL_DestroyTexture; - renderer->DestroyRenderer = METAL_DestroyRenderer; - renderer->SetVSync = METAL_SetVSync; - renderer->GetMetalLayer = METAL_GetMetalLayer; - renderer->GetMetalCommandEncoder = METAL_GetMetalCommandEncoder; + renderer->LockTexture = METAL_LockTexture; + renderer->UnlockTexture = METAL_UnlockTexture; + renderer->SetTextureScaleMode = METAL_SetTextureScaleMode; + renderer->SetRenderTarget = METAL_SetRenderTarget; + renderer->QueueSetViewport = METAL_QueueSetViewport; + renderer->QueueSetDrawColor = METAL_QueueSetDrawColor; + renderer->QueueDrawPoints = METAL_QueueDrawPoints; + renderer->QueueDrawLines = METAL_QueueDrawLines; + renderer->QueueGeometry = METAL_QueueGeometry; + renderer->RunCommandQueue = METAL_RunCommandQueue; + renderer->RenderReadPixels = METAL_RenderReadPixels; + renderer->RenderPresent = METAL_RenderPresent; + renderer->DestroyTexture = METAL_DestroyTexture; + renderer->DestroyRenderer = METAL_DestroyRenderer; + renderer->SetVSync = METAL_SetVSync; + renderer->GetMetalLayer = METAL_GetMetalLayer; + renderer->GetMetalCommandEncoder = METAL_GetMetalCommandEncoder; - renderer->info = METAL_RenderDriver.info; - renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); + renderer->info = METAL_RenderDriver.info; + renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); - renderer->always_batch = SDL_TRUE; + renderer->always_batch = SDL_TRUE; #if (defined(__MACOSX__) && defined(MAC_OS_X_VERSION_10_13)) || TARGET_OS_MACCATALYST if (@available(macOS 10.13, *)) { @@ -1862,51 +1918,47 @@ METAL_CreateRenderer(SDL_Window * window, Uint32 flags) if (data.mtllayer.displaySyncEnabled) { renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; } - } else -#endif - { - renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; - } /* https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf */ maxtexsize = 4096; #if defined(__MACOSX__) || TARGET_OS_MACCATALYST maxtexsize = 16384; #elif defined(__TVOS__) - maxtexsize = 8192; + maxtexsize = 8192; #ifdef __TVOS_11_0 - if (@available(tvOS 11.0, *)) { - if ([mtldevice supportsFeatureSet:MTLFeatureSet_tvOS_GPUFamily2_v1]) { - maxtexsize = 16384; + if (@available(tvOS 11.0, *)) { + if ([mtldevice supportsFeatureSet:MTLFeatureSet_tvOS_GPUFamily2_v1]) { + maxtexsize = 16384; + } } - } #endif #else #ifdef __IPHONE_11_0 #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunguarded-availability-new" - if ([mtldevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily4_v1]) { - maxtexsize = 16384; - } else + if ([mtldevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily4_v1]) { + maxtexsize = 16384; + } else #pragma clang diagnostic pop #endif #ifdef __IPHONE_10_0 - if ([mtldevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1]) { - maxtexsize = 16384; - } else + if ([mtldevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1]) { + maxtexsize = 16384; + } else #endif - if ([mtldevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily2_v2] || [mtldevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v2]) { - maxtexsize = 8192; - } else { - maxtexsize = 4096; + if ([mtldevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily2_v2] || [mtldevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v2]) { + maxtexsize = 8192; + } else { + maxtexsize = 4096; + } +#endif + + renderer->info.max_texture_width = maxtexsize; + renderer->info.max_texture_height = maxtexsize; + + return renderer; } -#endif - - renderer->info.max_texture_width = maxtexsize; - renderer->info.max_texture_height = maxtexsize; - - return renderer; -}} +} SDL_RenderDriver METAL_RenderDriver = { METAL_CreateRenderer, @@ -1914,15 +1966,14 @@ SDL_RenderDriver METAL_RenderDriver = { "metal", (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE), 6, - { - SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_ABGR8888, - SDL_PIXELFORMAT_YV12, - SDL_PIXELFORMAT_IYUV, - SDL_PIXELFORMAT_NV12, - SDL_PIXELFORMAT_NV21 - }, - 0, 0, + { SDL_PIXELFORMAT_ARGB8888, + SDL_PIXELFORMAT_ABGR8888, + SDL_PIXELFORMAT_YV12, + SDL_PIXELFORMAT_IYUV, + SDL_PIXELFORMAT_NV12, + SDL_PIXELFORMAT_NV21 }, + 0, + 0, } }; diff --git a/src/render/opengl/SDL_glfuncs.h b/src/render/opengl/SDL_glfuncs.h index acdcf8803..f85f9029f 100644 --- a/src/render/opengl/SDL_glfuncs.h +++ b/src/render/opengl/SDL_glfuncs.h @@ -23,7 +23,7 @@ If you need to use a GL function from the SDL video subsystem, change its entry from SDL_PROC_UNUSED to SDL_PROC and rebuild. */ -#define SDL_PROC_UNUSED(ret,func,params) +#define SDL_PROC_UNUSED(ret, func, params) SDL_PROC_UNUSED(void, glAccum, (GLenum, GLfloat)) SDL_PROC_UNUSED(void, glAlphaFunc, (GLenum, GLclampf)) @@ -74,21 +74,21 @@ SDL_PROC_UNUSED(void, glColor4iv, (const GLint *)) SDL_PROC_UNUSED(void, glColor4s, (GLshort, GLshort, GLshort, GLshort)) SDL_PROC_UNUSED(void, glColor4sv, (const GLshort *)) SDL_PROC(void, glColor4ub, - (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)) -SDL_PROC_UNUSED(void, glColor4ubv, (const GLubyte * v)) + (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)) +SDL_PROC_UNUSED(void, glColor4ubv, (const GLubyte *v)) SDL_PROC_UNUSED(void, glColor4ui, (GLuint red, GLuint green, GLuint blue, GLuint alpha)) -SDL_PROC_UNUSED(void, glColor4uiv, (const GLuint * v)) +SDL_PROC_UNUSED(void, glColor4uiv, (const GLuint *v)) SDL_PROC_UNUSED(void, glColor4us, (GLushort red, GLushort green, GLushort blue, GLushort alpha)) -SDL_PROC_UNUSED(void, glColor4usv, (const GLushort * v)) +SDL_PROC_UNUSED(void, glColor4usv, (const GLushort *v)) SDL_PROC_UNUSED(void, glColorMask, (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)) SDL_PROC_UNUSED(void, glColorMaterial, (GLenum face, GLenum mode)) SDL_PROC(void, glColorPointer, - (GLint size, GLenum type, GLsizei stride, - const GLvoid * pointer)) + (GLint size, GLenum type, GLsizei stride, + const GLvoid *pointer)) SDL_PROC_UNUSED(void, glCopyPixels, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)) @@ -106,7 +106,7 @@ SDL_PROC_UNUSED(void, glCopyTexSubImage2D, GLint x, GLint y, GLsizei width, GLsizei height)) SDL_PROC_UNUSED(void, glCullFace, (GLenum mode)) SDL_PROC_UNUSED(void, glDeleteLists, (GLuint list, GLsizei range)) -SDL_PROC(void, glDeleteTextures, (GLsizei n, const GLuint * textures)) +SDL_PROC(void, glDeleteTextures, (GLsizei n, const GLuint *textures)) SDL_PROC(void, glDepthFunc, (GLenum func)) SDL_PROC_UNUSED(void, glDepthMask, (GLboolean flag)) SDL_PROC_UNUSED(void, glDepthRange, (GLclampd zNear, GLclampd zFar)) @@ -116,141 +116,141 @@ SDL_PROC(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count)) SDL_PROC_UNUSED(void, glDrawBuffer, (GLenum mode)) SDL_PROC_UNUSED(void, glDrawElements, (GLenum mode, GLsizei count, GLenum type, - const GLvoid * indices)) + const GLvoid *indices)) SDL_PROC(void, glDrawPixels, (GLsizei width, GLsizei height, GLenum format, GLenum type, - const GLvoid * pixels)) + const GLvoid *pixels)) SDL_PROC_UNUSED(void, glEdgeFlag, (GLboolean flag)) SDL_PROC_UNUSED(void, glEdgeFlagPointer, - (GLsizei stride, const GLvoid * pointer)) -SDL_PROC_UNUSED(void, glEdgeFlagv, (const GLboolean * flag)) + (GLsizei stride, const GLvoid *pointer)) +SDL_PROC_UNUSED(void, glEdgeFlagv, (const GLboolean *flag)) SDL_PROC(void, glEnable, (GLenum cap)) SDL_PROC(void, glEnableClientState, (GLenum array)) SDL_PROC(void, glEnd, (void)) SDL_PROC_UNUSED(void, glEndList, (void)) SDL_PROC_UNUSED(void, glEvalCoord1d, (GLdouble u)) -SDL_PROC_UNUSED(void, glEvalCoord1dv, (const GLdouble * u)) +SDL_PROC_UNUSED(void, glEvalCoord1dv, (const GLdouble *u)) SDL_PROC_UNUSED(void, glEvalCoord1f, (GLfloat u)) -SDL_PROC_UNUSED(void, glEvalCoord1fv, (const GLfloat * u)) +SDL_PROC_UNUSED(void, glEvalCoord1fv, (const GLfloat *u)) SDL_PROC_UNUSED(void, glEvalCoord2d, (GLdouble u, GLdouble v)) -SDL_PROC_UNUSED(void, glEvalCoord2dv, (const GLdouble * u)) +SDL_PROC_UNUSED(void, glEvalCoord2dv, (const GLdouble *u)) SDL_PROC_UNUSED(void, glEvalCoord2f, (GLfloat u, GLfloat v)) -SDL_PROC_UNUSED(void, glEvalCoord2fv, (const GLfloat * u)) +SDL_PROC_UNUSED(void, glEvalCoord2fv, (const GLfloat *u)) SDL_PROC_UNUSED(void, glEvalMesh1, (GLenum mode, GLint i1, GLint i2)) SDL_PROC_UNUSED(void, glEvalMesh2, (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)) SDL_PROC_UNUSED(void, glEvalPoint1, (GLint i)) SDL_PROC_UNUSED(void, glEvalPoint2, (GLint i, GLint j)) SDL_PROC_UNUSED(void, glFeedbackBuffer, - (GLsizei size, GLenum type, GLfloat * buffer)) + (GLsizei size, GLenum type, GLfloat *buffer)) SDL_PROC_UNUSED(void, glFinish, (void)) SDL_PROC_UNUSED(void, glFlush, (void)) SDL_PROC_UNUSED(void, glFogf, (GLenum pname, GLfloat param)) -SDL_PROC_UNUSED(void, glFogfv, (GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glFogfv, (GLenum pname, const GLfloat *params)) SDL_PROC_UNUSED(void, glFogi, (GLenum pname, GLint param)) -SDL_PROC_UNUSED(void, glFogiv, (GLenum pname, const GLint * params)) +SDL_PROC_UNUSED(void, glFogiv, (GLenum pname, const GLint *params)) SDL_PROC_UNUSED(void, glFrontFace, (GLenum mode)) SDL_PROC_UNUSED(void, glFrustum, (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)) SDL_PROC_UNUSED(GLuint, glGenLists, (GLsizei range)) -SDL_PROC(void, glGenTextures, (GLsizei n, GLuint * textures)) -SDL_PROC_UNUSED(void, glGetBooleanv, (GLenum pname, GLboolean * params)) -SDL_PROC_UNUSED(void, glGetClipPlane, (GLenum plane, GLdouble * equation)) -SDL_PROC_UNUSED(void, glGetDoublev, (GLenum pname, GLdouble * params)) +SDL_PROC(void, glGenTextures, (GLsizei n, GLuint *textures)) +SDL_PROC_UNUSED(void, glGetBooleanv, (GLenum pname, GLboolean *params)) +SDL_PROC_UNUSED(void, glGetClipPlane, (GLenum plane, GLdouble *equation)) +SDL_PROC_UNUSED(void, glGetDoublev, (GLenum pname, GLdouble *params)) SDL_PROC(GLenum, glGetError, (void)) -SDL_PROC(void, glGetFloatv, (GLenum pname, GLfloat * params)) -SDL_PROC(void, glGetIntegerv, (GLenum pname, GLint * params)) +SDL_PROC(void, glGetFloatv, (GLenum pname, GLfloat *params)) +SDL_PROC(void, glGetIntegerv, (GLenum pname, GLint *params)) SDL_PROC_UNUSED(void, glGetLightfv, - (GLenum light, GLenum pname, GLfloat * params)) + (GLenum light, GLenum pname, GLfloat *params)) SDL_PROC_UNUSED(void, glGetLightiv, - (GLenum light, GLenum pname, GLint * params)) -SDL_PROC_UNUSED(void, glGetMapdv, (GLenum target, GLenum query, GLdouble * v)) -SDL_PROC_UNUSED(void, glGetMapfv, (GLenum target, GLenum query, GLfloat * v)) -SDL_PROC_UNUSED(void, glGetMapiv, (GLenum target, GLenum query, GLint * v)) + (GLenum light, GLenum pname, GLint *params)) +SDL_PROC_UNUSED(void, glGetMapdv, (GLenum target, GLenum query, GLdouble *v)) +SDL_PROC_UNUSED(void, glGetMapfv, (GLenum target, GLenum query, GLfloat *v)) +SDL_PROC_UNUSED(void, glGetMapiv, (GLenum target, GLenum query, GLint *v)) SDL_PROC_UNUSED(void, glGetMaterialfv, - (GLenum face, GLenum pname, GLfloat * params)) + (GLenum face, GLenum pname, GLfloat *params)) SDL_PROC_UNUSED(void, glGetMaterialiv, - (GLenum face, GLenum pname, GLint * params)) -SDL_PROC_UNUSED(void, glGetPixelMapfv, (GLenum map, GLfloat * values)) -SDL_PROC_UNUSED(void, glGetPixelMapuiv, (GLenum map, GLuint * values)) -SDL_PROC_UNUSED(void, glGetPixelMapusv, (GLenum map, GLushort * values)) -SDL_PROC(void, glGetPointerv, (GLenum pname, GLvoid * *params)) + (GLenum face, GLenum pname, GLint *params)) +SDL_PROC_UNUSED(void, glGetPixelMapfv, (GLenum map, GLfloat *values)) +SDL_PROC_UNUSED(void, glGetPixelMapuiv, (GLenum map, GLuint *values)) +SDL_PROC_UNUSED(void, glGetPixelMapusv, (GLenum map, GLushort *values)) +SDL_PROC(void, glGetPointerv, (GLenum pname, GLvoid **params)) SDL_PROC_UNUSED(void, glGetPolygonStipple, (GLubyte * mask)) SDL_PROC(const GLubyte *, glGetString, (GLenum name)) SDL_PROC_UNUSED(void, glGetTexEnvfv, - (GLenum target, GLenum pname, GLfloat * params)) + (GLenum target, GLenum pname, GLfloat *params)) SDL_PROC_UNUSED(void, glGetTexEnviv, - (GLenum target, GLenum pname, GLint * params)) + (GLenum target, GLenum pname, GLint *params)) SDL_PROC_UNUSED(void, glGetTexGendv, - (GLenum coord, GLenum pname, GLdouble * params)) + (GLenum coord, GLenum pname, GLdouble *params)) SDL_PROC_UNUSED(void, glGetTexGenfv, - (GLenum coord, GLenum pname, GLfloat * params)) + (GLenum coord, GLenum pname, GLfloat *params)) SDL_PROC_UNUSED(void, glGetTexGeniv, - (GLenum coord, GLenum pname, GLint * params)) + (GLenum coord, GLenum pname, GLint *params)) SDL_PROC_UNUSED(void, glGetTexImage, (GLenum target, GLint level, GLenum format, GLenum type, - GLvoid * pixels)) + GLvoid *pixels)) SDL_PROC_UNUSED(void, glGetTexLevelParameterfv, - (GLenum target, GLint level, GLenum pname, GLfloat * params)) + (GLenum target, GLint level, GLenum pname, GLfloat *params)) SDL_PROC_UNUSED(void, glGetTexLevelParameteriv, - (GLenum target, GLint level, GLenum pname, GLint * params)) + (GLenum target, GLint level, GLenum pname, GLint *params)) SDL_PROC_UNUSED(void, glGetTexParameterfv, - (GLenum target, GLenum pname, GLfloat * params)) + (GLenum target, GLenum pname, GLfloat *params)) SDL_PROC_UNUSED(void, glGetTexParameteriv, - (GLenum target, GLenum pname, GLint * params)) + (GLenum target, GLenum pname, GLint *params)) SDL_PROC_UNUSED(void, glHint, (GLenum target, GLenum mode)) SDL_PROC_UNUSED(void, glIndexMask, (GLuint mask)) SDL_PROC_UNUSED(void, glIndexPointer, - (GLenum type, GLsizei stride, const GLvoid * pointer)) + (GLenum type, GLsizei stride, const GLvoid *pointer)) SDL_PROC_UNUSED(void, glIndexd, (GLdouble c)) -SDL_PROC_UNUSED(void, glIndexdv, (const GLdouble * c)) +SDL_PROC_UNUSED(void, glIndexdv, (const GLdouble *c)) SDL_PROC_UNUSED(void, glIndexf, (GLfloat c)) -SDL_PROC_UNUSED(void, glIndexfv, (const GLfloat * c)) +SDL_PROC_UNUSED(void, glIndexfv, (const GLfloat *c)) SDL_PROC_UNUSED(void, glIndexi, (GLint c)) -SDL_PROC_UNUSED(void, glIndexiv, (const GLint * c)) +SDL_PROC_UNUSED(void, glIndexiv, (const GLint *c)) SDL_PROC_UNUSED(void, glIndexs, (GLshort c)) -SDL_PROC_UNUSED(void, glIndexsv, (const GLshort * c)) +SDL_PROC_UNUSED(void, glIndexsv, (const GLshort *c)) SDL_PROC_UNUSED(void, glIndexub, (GLubyte c)) -SDL_PROC_UNUSED(void, glIndexubv, (const GLubyte * c)) +SDL_PROC_UNUSED(void, glIndexubv, (const GLubyte *c)) SDL_PROC_UNUSED(void, glInitNames, (void)) SDL_PROC_UNUSED(void, glInterleavedArrays, - (GLenum format, GLsizei stride, const GLvoid * pointer)) + (GLenum format, GLsizei stride, const GLvoid *pointer)) SDL_PROC_UNUSED(GLboolean, glIsEnabled, (GLenum cap)) SDL_PROC_UNUSED(GLboolean, glIsList, (GLuint list)) SDL_PROC_UNUSED(GLboolean, glIsTexture, (GLuint texture)) SDL_PROC_UNUSED(void, glLightModelf, (GLenum pname, GLfloat param)) -SDL_PROC_UNUSED(void, glLightModelfv, (GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glLightModelfv, (GLenum pname, const GLfloat *params)) SDL_PROC_UNUSED(void, glLightModeli, (GLenum pname, GLint param)) -SDL_PROC_UNUSED(void, glLightModeliv, (GLenum pname, const GLint * params)) +SDL_PROC_UNUSED(void, glLightModeliv, (GLenum pname, const GLint *params)) SDL_PROC_UNUSED(void, glLightf, (GLenum light, GLenum pname, GLfloat param)) SDL_PROC_UNUSED(void, glLightfv, - (GLenum light, GLenum pname, const GLfloat * params)) + (GLenum light, GLenum pname, const GLfloat *params)) SDL_PROC_UNUSED(void, glLighti, (GLenum light, GLenum pname, GLint param)) SDL_PROC_UNUSED(void, glLightiv, - (GLenum light, GLenum pname, const GLint * params)) + (GLenum light, GLenum pname, const GLint *params)) SDL_PROC_UNUSED(void, glLineStipple, (GLint factor, GLushort pattern)) SDL_PROC(void, glLineWidth, (GLfloat width)) SDL_PROC_UNUSED(void, glListBase, (GLuint base)) SDL_PROC(void, glLoadIdentity, (void)) -SDL_PROC_UNUSED(void, glLoadMatrixd, (const GLdouble * m)) -SDL_PROC_UNUSED(void, glLoadMatrixf, (const GLfloat * m)) +SDL_PROC_UNUSED(void, glLoadMatrixd, (const GLdouble *m)) +SDL_PROC_UNUSED(void, glLoadMatrixf, (const GLfloat *m)) SDL_PROC_UNUSED(void, glLoadName, (GLuint name)) SDL_PROC_UNUSED(void, glLogicOp, (GLenum opcode)) SDL_PROC_UNUSED(void, glMap1d, (GLenum target, GLdouble u1, GLdouble u2, GLint stride, - GLint order, const GLdouble * points)) + GLint order, const GLdouble *points)) SDL_PROC_UNUSED(void, glMap1f, (GLenum target, GLfloat u1, GLfloat u2, GLint stride, - GLint order, const GLfloat * points)) + GLint order, const GLfloat *points)) SDL_PROC_UNUSED(void, glMap2d, (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, - GLint vorder, const GLdouble * points)) + GLint vorder, const GLdouble *points)) SDL_PROC_UNUSED(void, glMap2f, (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, - GLint vorder, const GLfloat * points)) + GLint vorder, const GLfloat *points)) SDL_PROC_UNUSED(void, glMapGrid1d, (GLint un, GLdouble u1, GLdouble u2)) SDL_PROC_UNUSED(void, glMapGrid1f, (GLint un, GLfloat u1, GLfloat u2)) SDL_PROC_UNUSED(void, glMapGrid2d, @@ -261,36 +261,36 @@ SDL_PROC_UNUSED(void, glMapGrid2f, GLfloat v2)) SDL_PROC_UNUSED(void, glMaterialf, (GLenum face, GLenum pname, GLfloat param)) SDL_PROC_UNUSED(void, glMaterialfv, - (GLenum face, GLenum pname, const GLfloat * params)) + (GLenum face, GLenum pname, const GLfloat *params)) SDL_PROC_UNUSED(void, glMateriali, (GLenum face, GLenum pname, GLint param)) SDL_PROC_UNUSED(void, glMaterialiv, - (GLenum face, GLenum pname, const GLint * params)) + (GLenum face, GLenum pname, const GLint *params)) SDL_PROC(void, glMatrixMode, (GLenum mode)) -SDL_PROC_UNUSED(void, glMultMatrixd, (const GLdouble * m)) -SDL_PROC_UNUSED(void, glMultMatrixf, (const GLfloat * m)) +SDL_PROC_UNUSED(void, glMultMatrixd, (const GLdouble *m)) +SDL_PROC_UNUSED(void, glMultMatrixf, (const GLfloat *m)) SDL_PROC_UNUSED(void, glNewList, (GLuint list, GLenum mode)) SDL_PROC_UNUSED(void, glNormal3b, (GLbyte nx, GLbyte ny, GLbyte nz)) -SDL_PROC_UNUSED(void, glNormal3bv, (const GLbyte * v)) +SDL_PROC_UNUSED(void, glNormal3bv, (const GLbyte *v)) SDL_PROC_UNUSED(void, glNormal3d, (GLdouble nx, GLdouble ny, GLdouble nz)) -SDL_PROC_UNUSED(void, glNormal3dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glNormal3dv, (const GLdouble *v)) SDL_PROC_UNUSED(void, glNormal3f, (GLfloat nx, GLfloat ny, GLfloat nz)) -SDL_PROC_UNUSED(void, glNormal3fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glNormal3fv, (const GLfloat *v)) SDL_PROC_UNUSED(void, glNormal3i, (GLint nx, GLint ny, GLint nz)) -SDL_PROC_UNUSED(void, glNormal3iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glNormal3iv, (const GLint *v)) SDL_PROC_UNUSED(void, glNormal3s, (GLshort nx, GLshort ny, GLshort nz)) -SDL_PROC_UNUSED(void, glNormal3sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glNormal3sv, (const GLshort *v)) SDL_PROC_UNUSED(void, glNormalPointer, - (GLenum type, GLsizei stride, const GLvoid * pointer)) + (GLenum type, GLsizei stride, const GLvoid *pointer)) SDL_PROC(void, glOrtho, (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)) SDL_PROC_UNUSED(void, glPassThrough, (GLfloat token)) SDL_PROC_UNUSED(void, glPixelMapfv, - (GLenum map, GLsizei mapsize, const GLfloat * values)) + (GLenum map, GLsizei mapsize, const GLfloat *values)) SDL_PROC_UNUSED(void, glPixelMapuiv, - (GLenum map, GLsizei mapsize, const GLuint * values)) + (GLenum map, GLsizei mapsize, const GLuint *values)) SDL_PROC_UNUSED(void, glPixelMapusv, - (GLenum map, GLsizei mapsize, const GLushort * values)) + (GLenum map, GLsizei mapsize, const GLushort *values)) SDL_PROC_UNUSED(void, glPixelStoref, (GLenum pname, GLfloat param)) SDL_PROC(void, glPixelStorei, (GLenum pname, GLint param)) SDL_PROC_UNUSED(void, glPixelTransferf, (GLenum pname, GLfloat param)) @@ -299,180 +299,180 @@ SDL_PROC_UNUSED(void, glPixelZoom, (GLfloat xfactor, GLfloat yfactor)) SDL_PROC(void, glPointSize, (GLfloat size)) SDL_PROC_UNUSED(void, glPolygonMode, (GLenum face, GLenum mode)) SDL_PROC_UNUSED(void, glPolygonOffset, (GLfloat factor, GLfloat units)) -SDL_PROC_UNUSED(void, glPolygonStipple, (const GLubyte * mask)) +SDL_PROC_UNUSED(void, glPolygonStipple, (const GLubyte *mask)) SDL_PROC_UNUSED(void, glPopAttrib, (void)) SDL_PROC_UNUSED(void, glPopClientAttrib, (void)) SDL_PROC_UNUSED(void, glPopMatrix, (void)) SDL_PROC_UNUSED(void, glPopName, (void)) SDL_PROC_UNUSED(void, glPrioritizeTextures, - (GLsizei n, const GLuint * textures, - const GLclampf * priorities)) + (GLsizei n, const GLuint *textures, + const GLclampf *priorities)) SDL_PROC_UNUSED(void, glPushAttrib, (GLbitfield mask)) SDL_PROC_UNUSED(void, glPushClientAttrib, (GLbitfield mask)) SDL_PROC_UNUSED(void, glPushMatrix, (void)) SDL_PROC_UNUSED(void, glPushName, (GLuint name)) SDL_PROC_UNUSED(void, glRasterPos2d, (GLdouble x, GLdouble y)) -SDL_PROC_UNUSED(void, glRasterPos2dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glRasterPos2dv, (const GLdouble *v)) SDL_PROC_UNUSED(void, glRasterPos2f, (GLfloat x, GLfloat y)) -SDL_PROC_UNUSED(void, glRasterPos2fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glRasterPos2fv, (const GLfloat *v)) SDL_PROC(void, glRasterPos2i, (GLint x, GLint y)) -SDL_PROC_UNUSED(void, glRasterPos2iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glRasterPos2iv, (const GLint *v)) SDL_PROC_UNUSED(void, glRasterPos2s, (GLshort x, GLshort y)) -SDL_PROC_UNUSED(void, glRasterPos2sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glRasterPos2sv, (const GLshort *v)) SDL_PROC_UNUSED(void, glRasterPos3d, (GLdouble x, GLdouble y, GLdouble z)) -SDL_PROC_UNUSED(void, glRasterPos3dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glRasterPos3dv, (const GLdouble *v)) SDL_PROC_UNUSED(void, glRasterPos3f, (GLfloat x, GLfloat y, GLfloat z)) -SDL_PROC_UNUSED(void, glRasterPos3fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glRasterPos3fv, (const GLfloat *v)) SDL_PROC_UNUSED(void, glRasterPos3i, (GLint x, GLint y, GLint z)) -SDL_PROC_UNUSED(void, glRasterPos3iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glRasterPos3iv, (const GLint *v)) SDL_PROC_UNUSED(void, glRasterPos3s, (GLshort x, GLshort y, GLshort z)) -SDL_PROC_UNUSED(void, glRasterPos3sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glRasterPos3sv, (const GLshort *v)) SDL_PROC_UNUSED(void, glRasterPos4d, (GLdouble x, GLdouble y, GLdouble z, GLdouble w)) -SDL_PROC_UNUSED(void, glRasterPos4dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glRasterPos4dv, (const GLdouble *v)) SDL_PROC_UNUSED(void, glRasterPos4f, (GLfloat x, GLfloat y, GLfloat z, GLfloat w)) -SDL_PROC_UNUSED(void, glRasterPos4fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glRasterPos4fv, (const GLfloat *v)) SDL_PROC_UNUSED(void, glRasterPos4i, (GLint x, GLint y, GLint z, GLint w)) -SDL_PROC_UNUSED(void, glRasterPos4iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glRasterPos4iv, (const GLint *v)) SDL_PROC_UNUSED(void, glRasterPos4s, (GLshort x, GLshort y, GLshort z, GLshort w)) -SDL_PROC_UNUSED(void, glRasterPos4sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glRasterPos4sv, (const GLshort *v)) SDL_PROC(void, glReadBuffer, (GLenum mode)) SDL_PROC(void, glReadPixels, (GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, GLvoid * pixels)) + GLenum format, GLenum type, GLvoid *pixels)) SDL_PROC_UNUSED(void, glRectd, (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)) -SDL_PROC_UNUSED(void, glRectdv, (const GLdouble * v1, const GLdouble * v2)) +SDL_PROC_UNUSED(void, glRectdv, (const GLdouble *v1, const GLdouble *v2)) SDL_PROC(void, glRectf, - (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)) -SDL_PROC_UNUSED(void, glRectfv, (const GLfloat * v1, const GLfloat * v2)) + (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)) +SDL_PROC_UNUSED(void, glRectfv, (const GLfloat *v1, const GLfloat *v2)) SDL_PROC_UNUSED(void, glRecti, (GLint x1, GLint y1, GLint x2, GLint y2)) -SDL_PROC_UNUSED(void, glRectiv, (const GLint * v1, const GLint * v2)) +SDL_PROC_UNUSED(void, glRectiv, (const GLint *v1, const GLint *v2)) SDL_PROC_UNUSED(void, glRects, (GLshort x1, GLshort y1, GLshort x2, GLshort y2)) -SDL_PROC_UNUSED(void, glRectsv, (const GLshort * v1, const GLshort * v2)) +SDL_PROC_UNUSED(void, glRectsv, (const GLshort *v1, const GLshort *v2)) SDL_PROC_UNUSED(GLint, glRenderMode, (GLenum mode)) SDL_PROC_UNUSED(void, glRotated, (GLdouble angle, GLdouble x, GLdouble y, GLdouble z)) SDL_PROC(void, glRotatef, - (GLfloat angle, GLfloat x, GLfloat y, GLfloat z)) + (GLfloat angle, GLfloat x, GLfloat y, GLfloat z)) SDL_PROC_UNUSED(void, glScaled, (GLdouble x, GLdouble y, GLdouble z)) SDL_PROC_UNUSED(void, glScalef, (GLfloat x, GLfloat y, GLfloat z)) SDL_PROC(void, glScissor, (GLint x, GLint y, GLsizei width, GLsizei height)) -SDL_PROC_UNUSED(void, glSelectBuffer, (GLsizei size, GLuint * buffer)) +SDL_PROC_UNUSED(void, glSelectBuffer, (GLsizei size, GLuint *buffer)) SDL_PROC(void, glShadeModel, (GLenum mode)) SDL_PROC_UNUSED(void, glStencilFunc, (GLenum func, GLint ref, GLuint mask)) SDL_PROC_UNUSED(void, glStencilMask, (GLuint mask)) SDL_PROC_UNUSED(void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass)) SDL_PROC_UNUSED(void, glTexCoord1d, (GLdouble s)) -SDL_PROC_UNUSED(void, glTexCoord1dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glTexCoord1dv, (const GLdouble *v)) SDL_PROC_UNUSED(void, glTexCoord1f, (GLfloat s)) -SDL_PROC_UNUSED(void, glTexCoord1fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glTexCoord1fv, (const GLfloat *v)) SDL_PROC_UNUSED(void, glTexCoord1i, (GLint s)) -SDL_PROC_UNUSED(void, glTexCoord1iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glTexCoord1iv, (const GLint *v)) SDL_PROC_UNUSED(void, glTexCoord1s, (GLshort s)) -SDL_PROC_UNUSED(void, glTexCoord1sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glTexCoord1sv, (const GLshort *v)) SDL_PROC_UNUSED(void, glTexCoord2d, (GLdouble s, GLdouble t)) -SDL_PROC_UNUSED(void, glTexCoord2dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glTexCoord2dv, (const GLdouble *v)) SDL_PROC(void, glTexCoord2f, (GLfloat s, GLfloat t)) -SDL_PROC_UNUSED(void, glTexCoord2fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glTexCoord2fv, (const GLfloat *v)) SDL_PROC_UNUSED(void, glTexCoord2i, (GLint s, GLint t)) -SDL_PROC_UNUSED(void, glTexCoord2iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glTexCoord2iv, (const GLint *v)) SDL_PROC_UNUSED(void, glTexCoord2s, (GLshort s, GLshort t)) -SDL_PROC_UNUSED(void, glTexCoord2sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glTexCoord2sv, (const GLshort *v)) SDL_PROC_UNUSED(void, glTexCoord3d, (GLdouble s, GLdouble t, GLdouble r)) -SDL_PROC_UNUSED(void, glTexCoord3dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glTexCoord3dv, (const GLdouble *v)) SDL_PROC_UNUSED(void, glTexCoord3f, (GLfloat s, GLfloat t, GLfloat r)) -SDL_PROC_UNUSED(void, glTexCoord3fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glTexCoord3fv, (const GLfloat *v)) SDL_PROC_UNUSED(void, glTexCoord3i, (GLint s, GLint t, GLint r)) -SDL_PROC_UNUSED(void, glTexCoord3iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glTexCoord3iv, (const GLint *v)) SDL_PROC_UNUSED(void, glTexCoord3s, (GLshort s, GLshort t, GLshort r)) -SDL_PROC_UNUSED(void, glTexCoord3sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glTexCoord3sv, (const GLshort *v)) SDL_PROC_UNUSED(void, glTexCoord4d, (GLdouble s, GLdouble t, GLdouble r, GLdouble q)) -SDL_PROC_UNUSED(void, glTexCoord4dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glTexCoord4dv, (const GLdouble *v)) SDL_PROC_UNUSED(void, glTexCoord4f, (GLfloat s, GLfloat t, GLfloat r, GLfloat q)) -SDL_PROC_UNUSED(void, glTexCoord4fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glTexCoord4fv, (const GLfloat *v)) SDL_PROC_UNUSED(void, glTexCoord4i, (GLint s, GLint t, GLint r, GLint q)) -SDL_PROC_UNUSED(void, glTexCoord4iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glTexCoord4iv, (const GLint *v)) SDL_PROC_UNUSED(void, glTexCoord4s, (GLshort s, GLshort t, GLshort r, GLshort q)) -SDL_PROC_UNUSED(void, glTexCoord4sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glTexCoord4sv, (const GLshort *v)) SDL_PROC(void, glTexCoordPointer, - (GLint size, GLenum type, GLsizei stride, - const GLvoid * pointer)) + (GLint size, GLenum type, GLsizei stride, + const GLvoid *pointer)) SDL_PROC(void, glTexEnvf, (GLenum target, GLenum pname, GLfloat param)) SDL_PROC_UNUSED(void, glTexEnvfv, - (GLenum target, GLenum pname, const GLfloat * params)) + (GLenum target, GLenum pname, const GLfloat *params)) SDL_PROC_UNUSED(void, glTexEnvi, (GLenum target, GLenum pname, GLint param)) SDL_PROC_UNUSED(void, glTexEnviv, - (GLenum target, GLenum pname, const GLint * params)) + (GLenum target, GLenum pname, const GLint *params)) SDL_PROC_UNUSED(void, glTexGend, (GLenum coord, GLenum pname, GLdouble param)) SDL_PROC_UNUSED(void, glTexGendv, - (GLenum coord, GLenum pname, const GLdouble * params)) + (GLenum coord, GLenum pname, const GLdouble *params)) SDL_PROC_UNUSED(void, glTexGenf, (GLenum coord, GLenum pname, GLfloat param)) SDL_PROC_UNUSED(void, glTexGenfv, - (GLenum coord, GLenum pname, const GLfloat * params)) + (GLenum coord, GLenum pname, const GLfloat *params)) SDL_PROC_UNUSED(void, glTexGeni, (GLenum coord, GLenum pname, GLint param)) SDL_PROC_UNUSED(void, glTexGeniv, - (GLenum coord, GLenum pname, const GLint * params)) + (GLenum coord, GLenum pname, const GLint *params)) SDL_PROC_UNUSED(void, glTexImage1D, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, - const GLvoid * pixels)) + const GLvoid *pixels)) SDL_PROC(void, glTexImage2D, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, - const GLvoid * pixels)) + const GLvoid *pixels)) SDL_PROC_UNUSED(void, glTexParameterf, (GLenum target, GLenum pname, GLfloat param)) SDL_PROC_UNUSED(void, glTexParameterfv, - (GLenum target, GLenum pname, const GLfloat * params)) + (GLenum target, GLenum pname, const GLfloat *params)) SDL_PROC(void, glTexParameteri, (GLenum target, GLenum pname, GLint param)) SDL_PROC_UNUSED(void, glTexParameteriv, - (GLenum target, GLenum pname, const GLint * params)) + (GLenum target, GLenum pname, const GLint *params)) SDL_PROC_UNUSED(void, glTexSubImage1D, (GLenum target, GLint level, GLint xoffset, GLsizei width, - GLenum format, GLenum type, const GLvoid * pixels)) + GLenum format, GLenum type, const GLvoid *pixels)) SDL_PROC(void, glTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, - const GLvoid * pixels)) + const GLvoid *pixels)) SDL_PROC_UNUSED(void, glTranslated, (GLdouble x, GLdouble y, GLdouble z)) SDL_PROC_UNUSED(void, glTranslatef, (GLfloat x, GLfloat y, GLfloat z)) SDL_PROC_UNUSED(void, glVertex2d, (GLdouble x, GLdouble y)) -SDL_PROC_UNUSED(void, glVertex2dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glVertex2dv, (const GLdouble *v)) SDL_PROC(void, glVertex2f, (GLfloat x, GLfloat y)) -SDL_PROC_UNUSED(void, glVertex2fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glVertex2fv, (const GLfloat *v)) SDL_PROC_UNUSED(void, glVertex2i, (GLint x, GLint y)) -SDL_PROC_UNUSED(void, glVertex2iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glVertex2iv, (const GLint *v)) SDL_PROC_UNUSED(void, glVertex2s, (GLshort x, GLshort y)) -SDL_PROC_UNUSED(void, glVertex2sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glVertex2sv, (const GLshort *v)) SDL_PROC_UNUSED(void, glVertex3d, (GLdouble x, GLdouble y, GLdouble z)) -SDL_PROC_UNUSED(void, glVertex3dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glVertex3dv, (const GLdouble *v)) SDL_PROC_UNUSED(void, glVertex3f, (GLfloat x, GLfloat y, GLfloat z)) -SDL_PROC(void, glVertex3fv, (const GLfloat * v)) +SDL_PROC(void, glVertex3fv, (const GLfloat *v)) SDL_PROC_UNUSED(void, glVertex3i, (GLint x, GLint y, GLint z)) -SDL_PROC_UNUSED(void, glVertex3iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glVertex3iv, (const GLint *v)) SDL_PROC_UNUSED(void, glVertex3s, (GLshort x, GLshort y, GLshort z)) -SDL_PROC_UNUSED(void, glVertex3sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glVertex3sv, (const GLshort *v)) SDL_PROC_UNUSED(void, glVertex4d, (GLdouble x, GLdouble y, GLdouble z, GLdouble w)) -SDL_PROC_UNUSED(void, glVertex4dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glVertex4dv, (const GLdouble *v)) SDL_PROC_UNUSED(void, glVertex4f, (GLfloat x, GLfloat y, GLfloat z, GLfloat w)) -SDL_PROC_UNUSED(void, glVertex4fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glVertex4fv, (const GLfloat *v)) SDL_PROC_UNUSED(void, glVertex4i, (GLint x, GLint y, GLint z, GLint w)) -SDL_PROC_UNUSED(void, glVertex4iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glVertex4iv, (const GLint *v)) SDL_PROC_UNUSED(void, glVertex4s, (GLshort x, GLshort y, GLshort z, GLshort w)) -SDL_PROC_UNUSED(void, glVertex4sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glVertex4sv, (const GLshort *v)) SDL_PROC(void, glVertexPointer, - (GLint size, GLenum type, GLsizei stride, - const GLvoid * pointer)) + (GLint size, GLenum type, GLsizei stride, + const GLvoid *pointer)) SDL_PROC(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height)) /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index bdb0d2ba1..ef8532533 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -37,8 +37,8 @@ #include #endif -/* To prevent unnecessary window recreation, - * these should match the defaults selected in SDL_GL_ResetAttributes +/* To prevent unnecessary window recreation, + * these should match the defaults selected in SDL_GL_ResetAttributes */ #define RENDERER_CONTEXT_MAJOR 2 @@ -51,7 +51,7 @@ */ /* Used to re-create the window with OpenGL capability */ -extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags); +extern int SDL_RecreateWindow(SDL_Window *window, Uint32 flags); static const float inv255f = 1.0f / 255.0f; @@ -105,7 +105,7 @@ typedef struct GL_FBOList *framebuffers; /* OpenGL functions */ -#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; +#define SDL_PROC(ret, func, params) ret(APIENTRY *func) params; #include "SDL_glfuncs.h" #undef SDL_PROC @@ -149,29 +149,31 @@ typedef struct GL_FBOList *fbo; } GL_TextureData; -SDL_FORCE_INLINE const char* -GL_TranslateError (GLenum error) +SDL_FORCE_INLINE const char * +GL_TranslateError(GLenum error) { -#define GL_ERROR_TRANSLATE(e) case e: return #e; +#define GL_ERROR_TRANSLATE(e) \ + case e: \ + return #e; switch (error) { - GL_ERROR_TRANSLATE(GL_INVALID_ENUM) - GL_ERROR_TRANSLATE(GL_INVALID_VALUE) - GL_ERROR_TRANSLATE(GL_INVALID_OPERATION) - GL_ERROR_TRANSLATE(GL_OUT_OF_MEMORY) - GL_ERROR_TRANSLATE(GL_NO_ERROR) - GL_ERROR_TRANSLATE(GL_STACK_OVERFLOW) - GL_ERROR_TRANSLATE(GL_STACK_UNDERFLOW) - GL_ERROR_TRANSLATE(GL_TABLE_TOO_LARGE) + GL_ERROR_TRANSLATE(GL_INVALID_ENUM) + GL_ERROR_TRANSLATE(GL_INVALID_VALUE) + GL_ERROR_TRANSLATE(GL_INVALID_OPERATION) + GL_ERROR_TRANSLATE(GL_OUT_OF_MEMORY) + GL_ERROR_TRANSLATE(GL_NO_ERROR) + GL_ERROR_TRANSLATE(GL_STACK_OVERFLOW) + GL_ERROR_TRANSLATE(GL_STACK_UNDERFLOW) + GL_ERROR_TRANSLATE(GL_TABLE_TOO_LARGE) default: return "UNKNOWN"; -} + } #undef GL_ERROR_TRANSLATE } SDL_FORCE_INLINE void GL_ClearErrors(SDL_Renderer *renderer) { - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + GL_RenderData *data = (GL_RenderData *)renderer->driverdata; if (!data->debug_enabled) { return; @@ -195,9 +197,9 @@ GL_ClearErrors(SDL_Renderer *renderer) } SDL_FORCE_INLINE int -GL_CheckAllErrors (const char *prefix, SDL_Renderer *renderer, const char *file, int line, const char *function) +GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const char *file, int line, const char *function) { - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + GL_RenderData *data = (GL_RenderData *)renderer->driverdata; int ret = 0; if (!data->debug_enabled) { @@ -236,20 +238,19 @@ GL_CheckAllErrors (const char *prefix, SDL_Renderer *renderer, const char *file, #define GL_CheckError(prefix, renderer) GL_CheckAllErrors(prefix, renderer, SDL_FILE, SDL_LINE, SDL_FUNCTION) #endif -static int -GL_LoadFunctions(GL_RenderData * data) +static int GL_LoadFunctions(GL_RenderData *data) { #ifdef __SDL_NOGETPROCADDR__ -#define SDL_PROC(ret,func,params) data->func=func; +#define SDL_PROC(ret, func, params) data->func = func; #else int retval = 0; -#define SDL_PROC(ret,func,params) \ - do { \ - data->func = SDL_GL_GetProcAddress(#func); \ - if ( ! data->func ) { \ +#define SDL_PROC(ret, func, params) \ + do { \ + data->func = SDL_GL_GetProcAddress(#func); \ + if (!data->func) { \ retval = SDL_SetError("Couldn't load GL function %s: %s", #func, SDL_GetError()); \ - } \ - } while ( 0 ); + } \ + } while (0); #endif /* __SDL_NOGETPROCADDR__ */ #include "SDL_glfuncs.h" @@ -257,10 +258,9 @@ GL_LoadFunctions(GL_RenderData * data) return retval; } -static int -GL_ActivateRenderer(SDL_Renderer * renderer) +static int GL_ActivateRenderer(SDL_Renderer *renderer) { - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + GL_RenderData *data = (GL_RenderData *)renderer->driverdata; if (SDL_GL_GetCurrentContext() != data->context) { if (SDL_GL_MakeCurrent(renderer->window, data->context) < 0) { @@ -273,11 +273,10 @@ GL_ActivateRenderer(SDL_Renderer * renderer) return 0; } -static void APIENTRY -GL_HandleDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char *message, const void *userParam) +static void APIENTRY GL_HandleDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char *message, const void *userParam) { - SDL_Renderer *renderer = (SDL_Renderer *) userParam; - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + SDL_Renderer *renderer = (SDL_Renderer *)userParam; + GL_RenderData *data = (GL_RenderData *)renderer->driverdata; if (type == GL_DEBUG_TYPE_ERROR_ARB) { /* Record this error */ @@ -286,7 +285,7 @@ GL_HandleDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GL if (error_messages) { data->errors = errors; data->error_messages = error_messages; - data->error_messages[data->errors-1] = SDL_strdup(message); + data->error_messages[data->errors - 1] = SDL_strdup(message); } } @@ -302,8 +301,7 @@ GL_HandleDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GL } } -static GL_FBOList * -GL_GetFBO(GL_RenderData *data, Uint32 w, Uint32 h) +static GL_FBOList *GL_GetFBO(GL_RenderData *data, Uint32 w, Uint32 h) { GL_FBOList *result = data->framebuffers; @@ -324,8 +322,7 @@ GL_GetFBO(GL_RenderData *data, Uint32 w, Uint32 h) return result; } -static void -GL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +static void GL_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event) { /* If the window x/y/w/h changed at all, assume the viewport has been * changed behind our backs. x/y changes might seem weird but viewport @@ -333,13 +330,12 @@ GL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) */ if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED || event->event == SDL_WINDOWEVENT_MOVED) { - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + GL_RenderData *data = (GL_RenderData *)renderer->driverdata; data->drawstate.viewport_dirty = SDL_TRUE; } } -static int -GL_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) +static int GL_GetOutputSize(SDL_Renderer *renderer, int *w, int *h) { SDL_GL_GetDrawableSize(renderer->window, w, h); return 0; @@ -387,8 +383,7 @@ static GLenum GetBlendEquation(SDL_BlendOperation operation) } } -static SDL_bool -GL_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +static SDL_bool GL_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); @@ -413,7 +408,7 @@ GL_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) SDL_FORCE_INLINE SDL_bool convert_format(GL_RenderData *renderdata, Uint32 pixel_format, - GLint* internalFormat, GLenum* format, GLenum* type) + GLint *internalFormat, GLenum *format, GLenum *type) { switch (pixel_format) { case SDL_PIXELFORMAT_ARGB8888: @@ -449,10 +444,9 @@ convert_format(GL_RenderData *renderdata, Uint32 pixel_format, return SDL_TRUE; } -static int -GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; + GL_RenderData *renderdata = (GL_RenderData *)renderer->driverdata; const GLenum textype = renderdata->textype; GL_TextureData *data; GLint internalFormat; @@ -462,7 +456,7 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) GL_ActivateRenderer(renderer); - renderdata->drawstate.texture = NULL; /* we trash this state. */ + renderdata->drawstate.texture = NULL; /* we trash this state. */ if (texture->access == SDL_TEXTUREACCESS_TARGET && !renderdata->GL_EXT_framebuffer_object_supported) { @@ -475,7 +469,7 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) SDL_GetPixelFormatName(texture->format)); } - data = (GL_TextureData *) SDL_calloc(1, sizeof(*data)); + data = (GL_TextureData *)SDL_calloc(1, sizeof(*data)); if (data == NULL) { return SDL_OutOfMemory(); } @@ -526,13 +520,13 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) } else if (renderdata->GL_ARB_texture_rectangle_supported) { texture_w = texture->w; texture_h = texture->h; - data->texw = (GLfloat) texture_w; - data->texh = (GLfloat) texture_h; + data->texw = (GLfloat)texture_w; + data->texh = (GLfloat)texture_h; } else { texture_w = SDL_powerof2(texture->w); texture_h = SDL_powerof2(texture->h); - data->texw = (GLfloat) (texture->w) / texture_w; - data->texh = (GLfloat) texture->h / texture_h; + data->texw = (GLfloat)(texture->w) / texture_w; + data->texh = (GLfloat)texture->h / texture_h; } data->format = format; @@ -553,13 +547,13 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) } #ifdef __MACOSX__ #ifndef GL_TEXTURE_STORAGE_HINT_APPLE -#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC #endif #ifndef STORAGE_CACHED_APPLE -#define STORAGE_CACHED_APPLE 0x85BE +#define STORAGE_CACHED_APPLE 0x85BE #endif #ifndef STORAGE_SHARED_APPLE -#define STORAGE_SHARED_APPLE 0x85BF +#define STORAGE_SHARED_APPLE 0x85BF #endif if (texture->access == SDL_TEXTUREACCESS_STREAMING) { renderdata->glTexParameteri(textype, GL_TEXTURE_STORAGE_HINT_APPLE, @@ -568,13 +562,11 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) renderdata->glTexParameteri(textype, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_CACHED_APPLE); } - if (texture->access == SDL_TEXTUREACCESS_STREAMING - && texture->format == SDL_PIXELFORMAT_ARGB8888 - && (texture->w % 8) == 0) { + if (texture->access == SDL_TEXTUREACCESS_STREAMING && texture->format == SDL_PIXELFORMAT_ARGB8888 && (texture->w % 8) == 0) { renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, - (data->pitch / SDL_BYTESPERPIXEL(texture->format))); + (data->pitch / SDL_BYTESPERPIXEL(texture->format))); renderdata->glTexImage2D(textype, 0, internalFormat, texture_w, texture_h, 0, format, type, data->pixels); renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE); @@ -606,8 +598,8 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) GL_CLAMP_TO_EDGE); renderdata->glTexParameteri(textype, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - renderdata->glTexImage2D(textype, 0, internalFormat, (texture_w+1)/2, - (texture_h+1)/2, 0, format, type, NULL); + renderdata->glTexImage2D(textype, 0, internalFormat, (texture_w + 1) / 2, + (texture_h + 1) / 2, 0, format, type, NULL); renderdata->glBindTexture(textype, data->vtexture); renderdata->glTexParameteri(textype, GL_TEXTURE_MIN_FILTER, @@ -618,8 +610,8 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) GL_CLAMP_TO_EDGE); renderdata->glTexParameteri(textype, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - renderdata->glTexImage2D(textype, 0, internalFormat, (texture_w+1)/2, - (texture_h+1)/2, 0, format, type, NULL); + renderdata->glTexImage2D(textype, 0, internalFormat, (texture_w + 1) / 2, + (texture_h + 1) / 2, 0, format, type, NULL); } if (texture->format == SDL_PIXELFORMAT_NV12 || @@ -636,8 +628,8 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) GL_CLAMP_TO_EDGE); renderdata->glTexParameteri(textype, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - renderdata->glTexImage2D(textype, 0, GL_LUMINANCE_ALPHA, (texture_w+1)/2, - (texture_h+1)/2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL); + renderdata->glTexImage2D(textype, 0, GL_LUMINANCE_ALPHA, (texture_w + 1) / 2, + (texture_h + 1) / 2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL); } #endif @@ -650,44 +642,44 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) #if SDL_HAVE_YUV if (data->yuv || data->nv12) { switch (SDL_GetYUVConversionModeForResolution(texture->w, texture->h)) { - case SDL_YUV_CONVERSION_JPEG: - if (data->yuv) { - data->shader = SHADER_YUV_JPEG; - } else if (texture->format == SDL_PIXELFORMAT_NV12) { - data->shader = SHADER_NV12_JPEG; + case SDL_YUV_CONVERSION_JPEG: + if (data->yuv) { + data->shader = SHADER_YUV_JPEG; + } else if (texture->format == SDL_PIXELFORMAT_NV12) { + data->shader = SHADER_NV12_JPEG; + } else { + data->shader = SHADER_NV21_JPEG; + } + break; + case SDL_YUV_CONVERSION_BT601: + if (data->yuv) { + data->shader = SHADER_YUV_BT601; + } else if (texture->format == SDL_PIXELFORMAT_NV12) { + if (SDL_GetHintBoolean("SDL_RENDER_OPENGL_NV12_RG_SHADER", SDL_FALSE)) { + data->shader = SHADER_NV12_RG_BT601; } else { - data->shader = SHADER_NV21_JPEG; + data->shader = SHADER_NV12_RA_BT601; } - break; - case SDL_YUV_CONVERSION_BT601: - if (data->yuv) { - data->shader = SHADER_YUV_BT601; - } else if (texture->format == SDL_PIXELFORMAT_NV12) { - if (SDL_GetHintBoolean("SDL_RENDER_OPENGL_NV12_RG_SHADER", SDL_FALSE)) { - data->shader = SHADER_NV12_RG_BT601; - } else { - data->shader = SHADER_NV12_RA_BT601; - } + } else { + data->shader = SHADER_NV21_BT601; + } + break; + case SDL_YUV_CONVERSION_BT709: + if (data->yuv) { + data->shader = SHADER_YUV_BT709; + } else if (texture->format == SDL_PIXELFORMAT_NV12) { + if (SDL_GetHintBoolean("SDL_RENDER_OPENGL_NV12_RG_SHADER", SDL_FALSE)) { + data->shader = SHADER_NV12_RG_BT709; } else { - data->shader = SHADER_NV21_BT601; + data->shader = SHADER_NV12_RA_BT709; } - break; - case SDL_YUV_CONVERSION_BT709: - if (data->yuv) { - data->shader = SHADER_YUV_BT709; - } else if (texture->format == SDL_PIXELFORMAT_NV12) { - if (SDL_GetHintBoolean("SDL_RENDER_OPENGL_NV12_RG_SHADER", SDL_FALSE)) { - data->shader = SHADER_NV12_RG_BT709; - } else { - data->shader = SHADER_NV12_RA_BT709; - } - } else { - data->shader = SHADER_NV21_BT709; - } - break; - default: - SDL_assert(!"unsupported YUV conversion mode"); - break; + } else { + data->shader = SHADER_NV21_BT709; + } + break; + default: + SDL_assert(!"unsupported YUV conversion mode"); + break; } } #endif /* SDL_HAVE_YUV */ @@ -695,20 +687,19 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) return GL_CheckError("", renderer); } -static int -GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, int pitch) +static int GL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, const void *pixels, int pitch) { - GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; + GL_RenderData *renderdata = (GL_RenderData *)renderer->driverdata; const GLenum textype = renderdata->textype; - GL_TextureData *data = (GL_TextureData *) texture->driverdata; + GL_TextureData *data = (GL_TextureData *)texture->driverdata; const int texturebpp = SDL_BYTESPERPIXEL(texture->format); - SDL_assert(texturebpp != 0); /* otherwise, division by zero later. */ + SDL_assert(texturebpp != 0); /* otherwise, division by zero later. */ GL_ActivateRenderer(renderer); - renderdata->drawstate.texture = NULL; /* we trash this state. */ + renderdata->drawstate.texture = NULL; /* we trash this state. */ renderdata->glBindTexture(textype, data->texture); renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -721,25 +712,25 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, ((pitch + 1) / 2)); /* Skip to the correct offset into the next texture */ - pixels = (const void*)((const Uint8*)pixels + rect->h * pitch); + pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch); if (texture->format == SDL_PIXELFORMAT_YV12) { renderdata->glBindTexture(textype, data->vtexture); } else { renderdata->glBindTexture(textype, data->utexture); } - renderdata->glTexSubImage2D(textype, 0, rect->x/2, rect->y/2, - (rect->w+1)/2, (rect->h+1)/2, + renderdata->glTexSubImage2D(textype, 0, rect->x / 2, rect->y / 2, + (rect->w + 1) / 2, (rect->h + 1) / 2, data->format, data->formattype, pixels); /* Skip to the correct offset into the next texture */ - pixels = (const void*)((const Uint8*)pixels + ((rect->h + 1) / 2) * ((pitch + 1) / 2)); + pixels = (const void *)((const Uint8 *)pixels + ((rect->h + 1) / 2) * ((pitch + 1) / 2)); if (texture->format == SDL_PIXELFORMAT_YV12) { renderdata->glBindTexture(textype, data->utexture); } else { renderdata->glBindTexture(textype, data->vtexture); } - renderdata->glTexSubImage2D(textype, 0, rect->x/2, rect->y/2, - (rect->w+1)/2, (rect->h+1)/2, + renderdata->glTexSubImage2D(textype, 0, rect->x / 2, rect->y / 2, + (rect->w + 1) / 2, (rect->h + 1) / 2, data->format, data->formattype, pixels); } @@ -747,10 +738,10 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, ((pitch + 1) / 2)); /* Skip to the correct offset into the next texture */ - pixels = (const void*)((const Uint8*)pixels + rect->h * pitch); + pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch); renderdata->glBindTexture(textype, data->utexture); - renderdata->glTexSubImage2D(textype, 0, rect->x/2, rect->y/2, - (rect->w + 1)/2, (rect->h + 1)/2, + renderdata->glTexSubImage2D(textype, 0, rect->x / 2, rect->y / 2, + (rect->w + 1) / 2, (rect->h + 1) / 2, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, pixels); } #endif @@ -758,20 +749,19 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, } #if SDL_HAVE_YUV -static int -GL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *Uplane, int Upitch, - const Uint8 *Vplane, int Vpitch) +static int GL_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) { - GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; + GL_RenderData *renderdata = (GL_RenderData *)renderer->driverdata; const GLenum textype = renderdata->textype; - GL_TextureData *data = (GL_TextureData *) texture->driverdata; + GL_TextureData *data = (GL_TextureData *)texture->driverdata; GL_ActivateRenderer(renderer); - renderdata->drawstate.texture = NULL; /* we trash this state. */ + renderdata->drawstate.texture = NULL; /* we trash this state. */ renderdata->glBindTexture(textype, data->texture); renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -782,32 +772,31 @@ GL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, Upitch); renderdata->glBindTexture(textype, data->utexture); - renderdata->glTexSubImage2D(textype, 0, rect->x/2, rect->y/2, - (rect->w + 1)/2, (rect->h + 1)/2, + renderdata->glTexSubImage2D(textype, 0, rect->x / 2, rect->y / 2, + (rect->w + 1) / 2, (rect->h + 1) / 2, data->format, data->formattype, Uplane); renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, Vpitch); renderdata->glBindTexture(textype, data->vtexture); - renderdata->glTexSubImage2D(textype, 0, rect->x/2, rect->y/2, - (rect->w + 1)/2, (rect->h + 1)/2, + renderdata->glTexSubImage2D(textype, 0, rect->x / 2, rect->y / 2, + (rect->w + 1) / 2, (rect->h + 1) / 2, data->format, data->formattype, Vplane); return GL_CheckError("glTexSubImage2D()", renderer); } -static int -GL_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *UVplane, int UVpitch) +static int GL_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch) { - GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; + GL_RenderData *renderdata = (GL_RenderData *)renderer->driverdata; const GLenum textype = renderdata->textype; - GL_TextureData *data = (GL_TextureData *) texture->driverdata; + GL_TextureData *data = (GL_TextureData *)texture->driverdata; GL_ActivateRenderer(renderer); - renderdata->drawstate.texture = NULL; /* we trash this state. */ + renderdata->drawstate.texture = NULL; /* we trash this state. */ renderdata->glBindTexture(textype, data->texture); renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -816,51 +805,47 @@ GL_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, rect->h, data->format, data->formattype, Yplane); - renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, UVpitch / 2); renderdata->glBindTexture(textype, data->utexture); - renderdata->glTexSubImage2D(textype, 0, rect->x/2, rect->y/2, - (rect->w + 1)/2, (rect->h + 1)/2, + renderdata->glTexSubImage2D(textype, 0, rect->x / 2, rect->y / 2, + (rect->w + 1) / 2, (rect->h + 1) / 2, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, UVplane); return GL_CheckError("glTexSubImage2D()", renderer); } #endif -static int -GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, void **pixels, int *pitch) +static int GL_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, void **pixels, int *pitch) { - GL_TextureData *data = (GL_TextureData *) texture->driverdata; + GL_TextureData *data = (GL_TextureData *)texture->driverdata; data->locked_rect = *rect; *pixels = - (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); + (void *)((Uint8 *)data->pixels + rect->y * data->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); *pitch = data->pitch; return 0; } -static void -GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static void GL_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - GL_TextureData *data = (GL_TextureData *) texture->driverdata; + GL_TextureData *data = (GL_TextureData *)texture->driverdata; const SDL_Rect *rect; void *pixels; rect = &data->locked_rect; pixels = - (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); + (void *)((Uint8 *)data->pixels + rect->y * data->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); GL_UpdateTexture(renderer, texture, rect, pixels, data->pitch); } -static void -GL_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode) +static void GL_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode) { - GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; + GL_RenderData *renderdata = (GL_RenderData *)renderer->driverdata; const GLenum textype = renderdata->textype; - GL_TextureData *data = (GL_TextureData *) texture->driverdata; + GL_TextureData *data = (GL_TextureData *)texture->driverdata; GLenum glScaleMode = (scaleMode == SDL_ScaleModeNearest) ? GL_NEAREST : GL_LINEAR; renderdata->glBindTexture(textype, data->texture); @@ -888,10 +873,9 @@ GL_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Scale #endif } -static int -GL_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +static int GL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) { - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + GL_RenderData *data = (GL_RenderData *)renderer->driverdata; GL_TextureData *texturedata; GLenum status; @@ -908,7 +892,7 @@ GL_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) return 0; } - texturedata = (GL_TextureData *) texture->driverdata; + texturedata = (GL_TextureData *)texture->driverdata; data->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, texturedata->fbo->FBO); /* TODO: check if texture pixel format allows this operation */ data->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, data->textype, texturedata->texture, 0); @@ -923,16 +907,14 @@ GL_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) /* !!! FIXME: all these Queue* calls set up the vertex buffer the way the immediate mode !!! FIXME: renderer wants it, but this might want to operate differently if we move to !!! FIXME: VBOs at some point. */ -static int -GL_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd) +static int GL_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { - return 0; /* nothing to do in this backend. */ + return 0; /* nothing to do in this backend. */ } -static int -GL_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) +static int GL_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { - GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, count * 2 * sizeof (GLfloat), 0, &cmd->data.draw.first); + GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(GLfloat), 0, &cmd->data.draw.first); int i; if (verts == NULL) { @@ -948,13 +930,12 @@ GL_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FP return 0; } -static int -GL_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) +static int GL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { int i; GLfloat prevx, prevy; - const size_t vertlen = (sizeof (GLfloat) * 2) * count; - GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first); + const size_t vertlen = (sizeof(GLfloat) * 2) * count; + GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first); if (verts == NULL) { return -1; @@ -974,7 +955,7 @@ GL_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPo for (i = 1; i < count; i++) { const GLfloat xstart = prevx; const GLfloat ystart = prevy; - const GLfloat xend = points[i].x + 0.5f; /* 0.5f to hit pixel center. */ + const GLfloat xend = points[i].x + 0.5f; /* 0.5f to hit pixel center. */ const GLfloat yend = points[i].y + 0.5f; /* bump a little in the direction we are moving in. */ const GLfloat deltax = xend - xstart; @@ -989,11 +970,10 @@ GL_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPo return 0; } -static int -GL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, - const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, - int num_vertices, const void *indices, int num_indices, int size_indices, - float scale_x, float scale_y) +static int GL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, + int num_vertices, const void *indices, int num_indices, int size_indices, + float scale_x, float scale_y) { GL_TextureData *texturedata = NULL; int i; @@ -1001,13 +981,13 @@ GL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te GLfloat *verts; size_t sz = 2 * sizeof(GLfloat) + 4 * sizeof(Uint8) + (texture ? 2 : 0) * sizeof(GLfloat); - verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first); + verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first); if (verts == NULL) { return -1; } if (texture) { - texturedata = (GL_TextureData *) texture->driverdata; + texturedata = (GL_TextureData *)texture->driverdata; } cmd->data.draw.count = count; @@ -1026,18 +1006,18 @@ GL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te j = i; } - xy_ = (float *)((char*)xy + j * xy_stride); + xy_ = (float *)((char *)xy + j * xy_stride); *(verts++) = xy_[0] * scale_x; *(verts++) = xy_[1] * scale_y; /* Not really a float, but it is still 4 bytes and will be cast to the right type in the graphics driver. */ - SDL_memcpy(verts, ((char*)color + j * color_stride), sizeof(*color)); + SDL_memcpy(verts, ((char *)color + j * color_stride), sizeof(*color)); ++verts; if (texture) { - float *uv_ = (float *)((char*)uv + j * uv_stride); + float *uv_ = (float *)((char *)uv + j * uv_stride); *(verts++) = uv_[0] * texturedata->texw; *(verts++) = uv_[1] * texturedata->texh; } @@ -1045,8 +1025,7 @@ GL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te return 0; } -static int -SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const GL_Shader shader) +static int SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const GL_Shader shader) { const SDL_BlendMode blend = cmd->data.draw.blend; SDL_bool vertex_array; @@ -1062,9 +1041,9 @@ SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const GL_Shader istarget ? viewport->y : (data->drawstate.drawableh - viewport->y - viewport->h), viewport->w, viewport->h); if (viewport->w && viewport->h) { - data->glOrtho((GLdouble) 0, (GLdouble) viewport->w, - (GLdouble) istarget ? 0 : viewport->h, - (GLdouble) istarget ? viewport->h : 0, + data->glOrtho((GLdouble)0, (GLdouble)viewport->w, + (GLdouble)istarget ? 0 : viewport->h, + (GLdouble)istarget ? viewport->h : 0, 0.0, 1.0); } data->glMatrixMode(GL_MODELVIEW); @@ -1118,9 +1097,7 @@ SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const GL_Shader } } - vertex_array = cmd->command == SDL_RENDERCMD_DRAW_POINTS - || cmd->command == SDL_RENDERCMD_DRAW_LINES - || cmd->command == SDL_RENDERCMD_GEOMETRY; + vertex_array = cmd->command == SDL_RENDERCMD_DRAW_POINTS || cmd->command == SDL_RENDERCMD_DRAW_LINES || cmd->command == SDL_RENDERCMD_GEOMETRY; color_array = cmd->command == SDL_RENDERCMD_GEOMETRY; texture_array = cmd->data.draw.texture != NULL; @@ -1156,11 +1133,10 @@ SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const GL_Shader return 0; } -static int -SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd) +static int SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd) { SDL_Texture *texture = cmd->data.draw.texture; - const GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata; + const GL_TextureData *texturedata = (GL_TextureData *)texture->driverdata; SetDrawState(data, cmd, texturedata->shader); @@ -1196,11 +1172,10 @@ SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd) return 0; } -static int -GL_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) +static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) { /* !!! FIXME: it'd be nice to use a vertex buffer instead of immediate mode... */ - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + GL_RenderData *data = (GL_RenderData *)renderer->driverdata; if (GL_ActivateRenderer(renderer) < 0) { return -1; @@ -1211,7 +1186,7 @@ GL_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic int w, h; SDL_GL_GetDrawableSize(renderer->window, &w, &h); if ((w != data->drawstate.drawablew) || (h != data->drawstate.drawableh)) { - data->drawstate.viewport_dirty = SDL_TRUE; // if the window dimensions changed, invalidate the current viewport, etc. + data->drawstate.viewport_dirty = SDL_TRUE; // if the window dimensions changed, invalidate the current viewport, etc. data->drawstate.cliprect_dirty = SDL_TRUE; data->drawstate.drawablew = w; data->drawstate.drawableh = h; @@ -1227,185 +1202,191 @@ GL_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic while (cmd) { switch (cmd->command) { - case SDL_RENDERCMD_SETDRAWCOLOR: { - const Uint8 r = cmd->data.color.r; - const Uint8 g = cmd->data.color.g; - const Uint8 b = cmd->data.color.b; - const Uint8 a = cmd->data.color.a; - const Uint32 color = (((Uint32)a << 24) | (r << 16) | (g << 8) | b); - if (color != data->drawstate.color) { - data->glColor4ub((GLubyte) r, (GLubyte) g, (GLubyte) b, (GLubyte) a); - data->drawstate.color = color; - } - break; + case SDL_RENDERCMD_SETDRAWCOLOR: + { + const Uint8 r = cmd->data.color.r; + const Uint8 g = cmd->data.color.g; + const Uint8 b = cmd->data.color.b; + const Uint8 a = cmd->data.color.a; + const Uint32 color = (((Uint32)a << 24) | (r << 16) | (g << 8) | b); + if (color != data->drawstate.color) { + data->glColor4ub((GLubyte)r, (GLubyte)g, (GLubyte)b, (GLubyte)a); + data->drawstate.color = color; + } + break; + } + + case SDL_RENDERCMD_SETVIEWPORT: + { + SDL_Rect *viewport = &data->drawstate.viewport; + if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { + SDL_copyp(viewport, &cmd->data.viewport.rect); + data->drawstate.viewport_dirty = SDL_TRUE; + } + break; + } + + case SDL_RENDERCMD_SETCLIPRECT: + { + const SDL_Rect *rect = &cmd->data.cliprect.rect; + if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) { + data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled; + data->drawstate.cliprect_enabled_dirty = SDL_TRUE; } - case SDL_RENDERCMD_SETVIEWPORT: { - SDL_Rect *viewport = &data->drawstate.viewport; - if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { - SDL_copyp(viewport, &cmd->data.viewport.rect); - data->drawstate.viewport_dirty = SDL_TRUE; - } - break; + if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) { + SDL_copyp(&data->drawstate.cliprect, rect); + data->drawstate.cliprect_dirty = SDL_TRUE; + } + break; + } + + case SDL_RENDERCMD_CLEAR: + { + const Uint8 r = cmd->data.color.r; + const Uint8 g = cmd->data.color.g; + const Uint8 b = cmd->data.color.b; + const Uint8 a = cmd->data.color.a; + const Uint32 color = (((Uint32)a << 24) | (r << 16) | (g << 8) | b); + if (color != data->drawstate.clear_color) { + const GLfloat fr = ((GLfloat)r) * inv255f; + const GLfloat fg = ((GLfloat)g) * inv255f; + const GLfloat fb = ((GLfloat)b) * inv255f; + const GLfloat fa = ((GLfloat)a) * inv255f; + data->glClearColor(fr, fg, fb, fa); + data->drawstate.clear_color = color; } - case SDL_RENDERCMD_SETCLIPRECT: { - const SDL_Rect *rect = &cmd->data.cliprect.rect; - if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) { - data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled; - data->drawstate.cliprect_enabled_dirty = SDL_TRUE; - } - - if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) { - SDL_copyp(&data->drawstate.cliprect, rect); - data->drawstate.cliprect_dirty = SDL_TRUE; - } - break; + if (data->drawstate.cliprect_enabled || data->drawstate.cliprect_enabled_dirty) { + data->glDisable(GL_SCISSOR_TEST); + data->drawstate.cliprect_enabled_dirty = data->drawstate.cliprect_enabled; } - case SDL_RENDERCMD_CLEAR: { - const Uint8 r = cmd->data.color.r; - const Uint8 g = cmd->data.color.g; - const Uint8 b = cmd->data.color.b; - const Uint8 a = cmd->data.color.a; - const Uint32 color = (((Uint32)a << 24) | (r << 16) | (g << 8) | b); - if (color != data->drawstate.clear_color) { - const GLfloat fr = ((GLfloat) r) * inv255f; - const GLfloat fg = ((GLfloat) g) * inv255f; - const GLfloat fb = ((GLfloat) b) * inv255f; - const GLfloat fa = ((GLfloat) a) * inv255f; - data->glClearColor(fr, fg, fb, fa); - data->drawstate.clear_color = color; - } + data->glClear(GL_COLOR_BUFFER_BIT); + break; + } - if (data->drawstate.cliprect_enabled || data->drawstate.cliprect_enabled_dirty) { - data->glDisable(GL_SCISSOR_TEST); - data->drawstate.cliprect_enabled_dirty = data->drawstate.cliprect_enabled; - } + case SDL_RENDERCMD_FILL_RECTS: /* unused */ + break; - data->glClear(GL_COLOR_BUFFER_BIT); - break; + case SDL_RENDERCMD_COPY: /* unused */ + break; + + case SDL_RENDERCMD_COPY_EX: /* unused */ + break; + + case SDL_RENDERCMD_DRAW_LINES: + { + if (SetDrawState(data, cmd, SHADER_SOLID) == 0) { + size_t count = cmd->data.draw.count; + const GLfloat *verts = (GLfloat *)(((Uint8 *)vertices) + cmd->data.draw.first); + + /* SetDrawState handles glEnableClientState. */ + data->glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, verts); + + if (count > 2) { + /* joined lines cannot be grouped */ + data->glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)count); + } else { + /* let's group non joined lines */ + SDL_RenderCommand *finalcmd = cmd; + SDL_RenderCommand *nextcmd = cmd->next; + SDL_BlendMode thisblend = cmd->data.draw.blend; + + while (nextcmd != NULL) { + const SDL_RenderCommandType nextcmdtype = nextcmd->command; + if (nextcmdtype != SDL_RENDERCMD_DRAW_LINES) { + break; /* can't go any further on this draw call, different render command up next. */ + } else if (nextcmd->data.draw.count != 2) { + break; /* can't go any further on this draw call, those are joined lines */ + } else if (nextcmd->data.draw.blend != thisblend) { + break; /* can't go any further on this draw call, different blendmode copy up next. */ + } else { + finalcmd = nextcmd; /* we can combine copy operations here. Mark this one as the furthest okay command. */ + count += nextcmd->data.draw.count; + } + nextcmd = nextcmd->next; + } + + data->glDrawArrays(GL_LINES, 0, (GLsizei)count); + cmd = finalcmd; /* skip any copy commands we just combined in here. */ + } + } + break; + } + + case SDL_RENDERCMD_DRAW_POINTS: + case SDL_RENDERCMD_GEOMETRY: + { + /* as long as we have the same copy command in a row, with the + same texture, we can combine them all into a single draw call. */ + SDL_Texture *thistexture = cmd->data.draw.texture; + SDL_BlendMode thisblend = cmd->data.draw.blend; + const SDL_RenderCommandType thiscmdtype = cmd->command; + SDL_RenderCommand *finalcmd = cmd; + SDL_RenderCommand *nextcmd = cmd->next; + size_t count = cmd->data.draw.count; + int ret; + while (nextcmd != NULL) { + const SDL_RenderCommandType nextcmdtype = nextcmd->command; + if (nextcmdtype != thiscmdtype) { + break; /* can't go any further on this draw call, different render command up next. */ + } else if (nextcmd->data.draw.texture != thistexture || nextcmd->data.draw.blend != thisblend) { + break; /* can't go any further on this draw call, different texture/blendmode copy up next. */ + } else { + finalcmd = nextcmd; /* we can combine copy operations here. Mark this one as the furthest okay command. */ + count += nextcmd->data.draw.count; + } + nextcmd = nextcmd->next; } - case SDL_RENDERCMD_FILL_RECTS: /* unused */ - break; + if (thistexture) { + ret = SetCopyState(data, cmd); + } else { + ret = SetDrawState(data, cmd, SHADER_SOLID); + } - case SDL_RENDERCMD_COPY: /* unused */ - break; - - case SDL_RENDERCMD_COPY_EX: /* unused */ - break; - - case SDL_RENDERCMD_DRAW_LINES: { - if (SetDrawState(data, cmd, SHADER_SOLID) == 0) { - size_t count = cmd->data.draw.count; - const GLfloat *verts = (GLfloat *) (((Uint8 *) vertices) + cmd->data.draw.first); + if (ret == 0) { + const GLfloat *verts = (GLfloat *)(((Uint8 *)vertices) + cmd->data.draw.first); + int op = GL_TRIANGLES; /* SDL_RENDERCMD_GEOMETRY */ + if (thiscmdtype == SDL_RENDERCMD_DRAW_POINTS) { + op = GL_POINTS; + } + if (thiscmdtype == SDL_RENDERCMD_DRAW_POINTS) { /* SetDrawState handles glEnableClientState. */ data->glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, verts); - - if (count > 2) { - /* joined lines cannot be grouped */ - data->glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)count); - } else { - /* let's group non joined lines */ - SDL_RenderCommand *finalcmd = cmd; - SDL_RenderCommand *nextcmd = cmd->next; - SDL_BlendMode thisblend = cmd->data.draw.blend; - - while (nextcmd != NULL) { - const SDL_RenderCommandType nextcmdtype = nextcmd->command; - if (nextcmdtype != SDL_RENDERCMD_DRAW_LINES) { - break; /* can't go any further on this draw call, different render command up next. */ - } else if (nextcmd->data.draw.count != 2) { - break; /* can't go any further on this draw call, those are joined lines */ - } else if (nextcmd->data.draw.blend != thisblend) { - break; /* can't go any further on this draw call, different blendmode copy up next. */ - } else { - finalcmd = nextcmd; /* we can combine copy operations here. Mark this one as the furthest okay command. */ - count += nextcmd->data.draw.count; - } - nextcmd = nextcmd->next; - } - - data->glDrawArrays(GL_LINES, 0, (GLsizei)count); - cmd = finalcmd; /* skip any copy commands we just combined in here. */ - } - } - break; - } - - case SDL_RENDERCMD_DRAW_POINTS: - case SDL_RENDERCMD_GEOMETRY: { - /* as long as we have the same copy command in a row, with the - same texture, we can combine them all into a single draw call. */ - SDL_Texture *thistexture = cmd->data.draw.texture; - SDL_BlendMode thisblend = cmd->data.draw.blend; - const SDL_RenderCommandType thiscmdtype = cmd->command; - SDL_RenderCommand *finalcmd = cmd; - SDL_RenderCommand *nextcmd = cmd->next; - size_t count = cmd->data.draw.count; - int ret; - while (nextcmd != NULL) { - const SDL_RenderCommandType nextcmdtype = nextcmd->command; - if (nextcmdtype != thiscmdtype) { - break; /* can't go any further on this draw call, different render command up next. */ - } else if (nextcmd->data.draw.texture != thistexture || nextcmd->data.draw.blend != thisblend) { - break; /* can't go any further on this draw call, different texture/blendmode copy up next. */ - } else { - finalcmd = nextcmd; /* we can combine copy operations here. Mark this one as the furthest okay command. */ - count += nextcmd->data.draw.count; - } - nextcmd = nextcmd->next; - } - - if (thistexture) { - ret = SetCopyState(data, cmd); } else { - ret = SetDrawState(data, cmd, SHADER_SOLID); - } - - if (ret == 0) { - const GLfloat *verts = (GLfloat *) (((Uint8 *) vertices) + cmd->data.draw.first); - int op = GL_TRIANGLES; /* SDL_RENDERCMD_GEOMETRY */ - if (thiscmdtype == SDL_RENDERCMD_DRAW_POINTS) { - op = GL_POINTS; - } - - if (thiscmdtype == SDL_RENDERCMD_DRAW_POINTS) { - /* SetDrawState handles glEnableClientState. */ - data->glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, verts); + /* SetDrawState handles glEnableClientState. */ + if (thistexture) { + data->glVertexPointer(2, GL_FLOAT, sizeof(float) * 5, verts + 0); + data->glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(float) * 5, verts + 2); + data->glTexCoordPointer(2, GL_FLOAT, sizeof(float) * 5, verts + 3); } else { - /* SetDrawState handles glEnableClientState. */ - if (thistexture) { - data->glVertexPointer(2, GL_FLOAT, sizeof(float) * 5, verts + 0); - data->glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(float) * 5, verts + 2); - data->glTexCoordPointer(2, GL_FLOAT, sizeof(float) * 5, verts + 3); - } else { - data->glVertexPointer(2, GL_FLOAT, sizeof(float) * 3, verts + 0); - data->glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(float) * 3, verts + 2); - } - } - - data->glDrawArrays(op, 0, (GLsizei) count); - - /* Restore previously set color when we're done. */ - if (thiscmdtype != SDL_RENDERCMD_DRAW_POINTS) { - Uint32 color = data->drawstate.color; - GLubyte a = (GLubyte)((color >> 24) & 0xFF); - GLubyte r = (GLubyte)((color >> 16) & 0xFF); - GLubyte g = (GLubyte)((color >> 8) & 0xFF); - GLubyte b = (GLubyte)((color >> 0) & 0xFF); - data->glColor4ub(r, g, b, a); + data->glVertexPointer(2, GL_FLOAT, sizeof(float) * 3, verts + 0); + data->glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(float) * 3, verts + 2); } } - cmd = finalcmd; /* skip any copy commands we just combined in here. */ - break; + data->glDrawArrays(op, 0, (GLsizei)count); + + /* Restore previously set color when we're done. */ + if (thiscmdtype != SDL_RENDERCMD_DRAW_POINTS) { + Uint32 color = data->drawstate.color; + GLubyte a = (GLubyte)((color >> 24) & 0xFF); + GLubyte r = (GLubyte)((color >> 16) & 0xFF); + GLubyte g = (GLubyte)((color >> 8) & 0xFF); + GLubyte b = (GLubyte)((color >> 0) & 0xFF); + data->glColor4ub(r, g, b, a); + } } - case SDL_RENDERCMD_NO_OP: - break; + cmd = finalcmd; /* skip any copy commands we just combined in here. */ + break; + } + + case SDL_RENDERCMD_NO_OP: + break; } cmd = cmd->next; @@ -1429,11 +1410,10 @@ GL_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic return GL_CheckError("", renderer); } -static int -GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 pixel_format, void * pixels, int pitch) +static int GL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, + Uint32 pixel_format, void *pixels, int pitch) { - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + GL_RenderData *data = (GL_RenderData *)renderer->driverdata; Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ARGB8888; void *temp_pixels; int temp_pitch; @@ -1451,7 +1431,7 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, } if (!rect->w || !rect->h) { - return 0; /* nothing to do. */ + return 0; /* nothing to do. */ } temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format); @@ -1466,7 +1446,7 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, data->glPixelStorei(GL_PACK_ROW_LENGTH, (temp_pitch / SDL_BYTESPERPIXEL(temp_format))); - data->glReadPixels(rect->x, renderer->target ? rect->y : (h-rect->y)-rect->h, + data->glReadPixels(rect->x, renderer->target ? rect->y : (h - rect->y) - rect->h, rect->w, rect->h, format, type, temp_pixels); if (GL_CheckError("glReadPixels()", renderer) < 0) { @@ -1478,8 +1458,8 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, if (!renderer->target) { SDL_bool isstack; length = rect->w * SDL_BYTESPERPIXEL(temp_format); - src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch; - dst = (Uint8*)temp_pixels; + src = (Uint8 *)temp_pixels + (rect->h - 1) * temp_pitch; + dst = (Uint8 *)temp_pixels; tmp = SDL_small_alloc(Uint8, length, &isstack); rows = rect->h / 2; while (rows--) { @@ -1500,19 +1480,17 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, return status; } -static int -GL_RenderPresent(SDL_Renderer * renderer) +static int GL_RenderPresent(SDL_Renderer *renderer) { GL_ActivateRenderer(renderer); return SDL_GL_SwapWindowWithResult(renderer->window); } -static void -GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static void GL_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; - GL_TextureData *data = (GL_TextureData *) texture->driverdata; + GL_RenderData *renderdata = (GL_RenderData *)renderer->driverdata; + GL_TextureData *data = (GL_TextureData *)texture->driverdata; GL_ActivateRenderer(renderer); @@ -1540,10 +1518,9 @@ GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) texture->driverdata = NULL; } -static void -GL_DestroyRenderer(SDL_Renderer * renderer) +static void GL_DestroyRenderer(SDL_Renderer *renderer) { - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + GL_RenderData *data = (GL_RenderData *)renderer->driverdata; if (data) { if (data->context != NULL) { @@ -1553,7 +1530,7 @@ GL_DestroyRenderer(SDL_Renderer * renderer) GL_ClearErrors(renderer); if (data->GL_ARB_debug_output_supported) { - PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARBFunc = (PFNGLDEBUGMESSAGECALLBACKARBPROC) SDL_GL_GetProcAddress("glDebugMessageCallbackARB"); + PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARBFunc = (PFNGLDEBUGMESSAGECALLBACKARBPROC)SDL_GL_GetProcAddress("glDebugMessageCallbackARB"); /* Uh oh, we don't have a safe way of removing ourselves from the callback chain, if it changed after we set our callback. */ /* For now, just always replace the callback with the original one */ @@ -1578,11 +1555,10 @@ GL_DestroyRenderer(SDL_Renderer * renderer) SDL_free(renderer); } -static int -GL_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh) +static int GL_BindTexture(SDL_Renderer *renderer, SDL_Texture *texture, float *texw, float *texh) { - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata; + GL_RenderData *data = (GL_RenderData *)renderer->driverdata; + GL_TextureData *texturedata = (GL_TextureData *)texture->driverdata; const GLenum textype = data->textype; GL_ActivateRenderer(renderer); @@ -1629,11 +1605,10 @@ GL_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, floa return 0; } -static int -GL_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) +static int GL_UnbindTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata; + GL_RenderData *data = (GL_RenderData *)renderer->driverdata; + GL_TextureData *texturedata = (GL_TextureData *)texture->driverdata; const GLenum textype = data->textype; GL_ActivateRenderer(renderer); @@ -1677,8 +1652,7 @@ GL_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) return 0; } -static int -GL_SetVSync(SDL_Renderer * renderer, const int vsync) +static int GL_SetVSync(SDL_Renderer *renderer, const int vsync) { int retval; if (vsync) { @@ -1697,26 +1671,25 @@ GL_SetVSync(SDL_Renderer * renderer, const int vsync) return retval; } -static SDL_bool -GL_IsProbablyAccelerated(const GL_RenderData *data) +static SDL_bool GL_IsProbablyAccelerated(const GL_RenderData *data) { /*const char *vendor = (const char *) data->glGetString(GL_VENDOR);*/ - const char *renderer = (const char *) data->glGetString(GL_RENDERER); + const char *renderer = (const char *)data->glGetString(GL_RENDERER); #if defined(__WINDOWS__) || defined(__WINGDK__) if (SDL_strcmp(renderer, "GDI Generic") == 0) { - return SDL_FALSE; /* Microsoft's fallback software renderer. Fix your system! */ + return SDL_FALSE; /* Microsoft's fallback software renderer. Fix your system! */ } #endif #ifdef __APPLE__ if (SDL_strcmp(renderer, "Apple Software Renderer") == 0) { - return SDL_FALSE; /* (a probably very old) Apple software-based OpenGL. */ + return SDL_FALSE; /* (a probably very old) Apple software-based OpenGL. */ } #endif - if (SDL_strcmp(renderer, "Software Rasterizer") == 0) { - return SDL_FALSE; /* (a probably very old) Software Mesa, or some other generic thing. */ + if (SDL_strcmp(renderer, "Software Rasterizer") == 0) { + return SDL_FALSE; /* (a probably very old) Software Mesa, or some other generic thing. */ } /* !!! FIXME: swrast? llvmpipe? softpipe? */ @@ -1724,8 +1697,7 @@ GL_IsProbablyAccelerated(const GL_RenderData *data) return SDL_TRUE; } -static SDL_Renderer * -GL_CreateRenderer(SDL_Window * window, Uint32 flags) +static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, Uint32 flags) { SDL_Renderer *renderer; GL_RenderData *data; @@ -1756,13 +1728,13 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) } #endif - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); if (renderer == NULL) { SDL_OutOfMemory(); goto error; } - data = (GL_RenderData *) SDL_calloc(1, sizeof(*data)); + data = (GL_RenderData *)SDL_calloc(1, sizeof(*data)); if (data == NULL) { SDL_free(renderer); SDL_OutOfMemory(); @@ -1783,7 +1755,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->SetTextureScaleMode = GL_SetTextureScaleMode; renderer->SetRenderTarget = GL_SetRenderTarget; renderer->QueueSetViewport = GL_QueueSetViewport; - renderer->QueueSetDrawColor = GL_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */ + renderer->QueueSetDrawColor = GL_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */ renderer->QueueDrawPoints = GL_QueueDrawPoints; renderer->QueueDrawLines = GL_QueueDrawLines; renderer->QueueGeometry = GL_QueueGeometry; @@ -1796,7 +1768,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->GL_BindTexture = GL_BindTexture; renderer->GL_UnbindTexture = GL_UnbindTexture; renderer->info = GL_RenderDriver.info; - renderer->info.flags = 0; /* will set some flags below. */ + renderer->info.flags = 0; /* will set some flags below. */ renderer->driverdata = data; renderer->window = window; @@ -1846,7 +1818,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) data->debug_enabled = SDL_TRUE; } if (data->debug_enabled && SDL_GL_ExtensionSupported("GL_ARB_debug_output")) { - PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARBFunc = (PFNGLDEBUGMESSAGECALLBACKARBPROC) SDL_GL_GetProcAddress("glDebugMessageCallbackARB"); + PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARBFunc = (PFNGLDEBUGMESSAGECALLBACKARBPROC)SDL_GL_GetProcAddress("glDebugMessageCallbackARB"); data->GL_ARB_debug_output_supported = SDL_TRUE; data->glGetPointerv(GL_DEBUG_CALLBACK_FUNCTION_ARB, (GLvoid **)(char *)&data->next_error_callback); @@ -1864,7 +1836,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) if (verstr) { char verbuf[16]; char *ptr; - SDL_strlcpy(verbuf, verstr, sizeof (verbuf)); + SDL_strlcpy(verbuf, verstr, sizeof(verbuf)); ptr = SDL_strchr(verbuf, '.'); if (ptr) { *ptr = '\0'; @@ -1899,7 +1871,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) /* Check for multitexture support */ if (SDL_GL_ExtensionSupported("GL_ARB_multitexture")) { - data->glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) SDL_GL_GetProcAddress("glActiveTextureARB"); + data->glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)SDL_GL_GetProcAddress("glActiveTextureARB"); if (data->glActiveTextureARB) { data->GL_ARB_multitexture_supported = SDL_TRUE; data->glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &data->num_texture_units); @@ -1982,24 +1954,19 @@ error: return NULL; } - SDL_RenderDriver GL_RenderDriver = { GL_CreateRenderer, - { - "opengl", - (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE), - 4, - { - SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_ABGR8888, - SDL_PIXELFORMAT_RGB888, - SDL_PIXELFORMAT_BGR888 - }, - 0, - 0} + { "opengl", + (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE), + 4, + { SDL_PIXELFORMAT_ARGB8888, + SDL_PIXELFORMAT_ABGR8888, + SDL_PIXELFORMAT_RGB888, + SDL_PIXELFORMAT_BGR888 }, + 0, + 0 } }; - #endif /* SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/opengl/SDL_shaders_gl.c b/src/render/opengl/SDL_shaders_gl.c index 4c06350be..14bfeb4ae 100644 --- a/src/render/opengl/SDL_shaders_gl.c +++ b/src/render/opengl/SDL_shaders_gl.c @@ -61,6 +61,8 @@ struct GL_ShaderContext GL_ShaderData shaders[NUM_SHADERS]; }; +/* *INDENT-OFF* */ /* clang-format off */ + #define COLOR_VERTEX_SHADER \ "varying vec4 v_color;\n" \ "\n" \ @@ -235,8 +237,7 @@ struct GL_ShaderContext * NOTE: Always use sampler2D, etc here. We'll #define them to the * texture_rectangle versions if we choose to use that extension. */ -static const char *shader_source[NUM_SHADERS][2] = -{ +static const char *shader_source[NUM_SHADERS][2] = { /* SHADER_NONE */ { NULL, NULL }, @@ -387,8 +388,9 @@ static const char *shader_source[NUM_SHADERS][2] = #endif /* SDL_HAVE_YUV */ }; -static SDL_bool -CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, const char *source) +/* *INDENT-ON* */ /* clang-format on */ + +static SDL_bool CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, const char *source) { GLint status; const char *sources[2]; @@ -405,13 +407,13 @@ CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, co char *info; ctx->glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); - info = SDL_small_alloc(char, length+1, &isstack); + info = SDL_small_alloc(char, length + 1, &isstack); ctx->glGetInfoLogARB(shader, length, NULL, info); SDL_LogError(SDL_LOG_CATEGORY_RENDER, - "Failed to compile shader:\n%s%s\n%s", defines, source, info); + "Failed to compile shader:\n%s%s\n%s", defines, source, info); #ifdef DEBUG_SHADERS fprintf(stderr, - "Failed to compile shader:\n%s%s\n%s", defines, source, info); + "Failed to compile shader:\n%s%s\n%s", defines, source, info); #endif SDL_small_free(info, isstack); @@ -421,8 +423,7 @@ CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, co } } -static SDL_bool -CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data) +static SDL_bool CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data) { const int num_tmus_bound = 4; const char *vert_defines = ""; @@ -439,12 +440,12 @@ CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data) /* Make sure we use the correct sampler type for our texture type */ if (ctx->GL_ARB_texture_rectangle_supported) { frag_defines = -"#define sampler2D sampler2DRect\n" -"#define texture2D texture2DRect\n" -"#define UVCoordScale 0.5\n"; + "#define sampler2D sampler2DRect\n" + "#define texture2D texture2DRect\n" + "#define UVCoordScale 0.5\n"; } else { - frag_defines = -"#define UVCoordScale 1.0\n"; + frag_defines = + "#define UVCoordScale 1.0\n"; } /* Create one program object to rule them all */ @@ -482,8 +483,7 @@ CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data) return ctx->glGetError() == GL_NO_ERROR; } -static void -DestroyShaderProgram(GL_ShaderContext *ctx, GL_ShaderData *data) +static void DestroyShaderProgram(GL_ShaderContext *ctx, GL_ShaderData *data) { ctx->glDeleteObjectARB(data->vert_shader); ctx->glDeleteObjectARB(data->frag_shader); @@ -514,20 +514,20 @@ GL_CreateShaderContext(void) SDL_GL_ExtensionSupported("GL_ARB_shading_language_100") && SDL_GL_ExtensionSupported("GL_ARB_vertex_shader") && SDL_GL_ExtensionSupported("GL_ARB_fragment_shader")) { - ctx->glGetError = (GLenum (*)(void)) SDL_GL_GetProcAddress("glGetError"); - ctx->glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) SDL_GL_GetProcAddress("glAttachObjectARB"); - ctx->glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) SDL_GL_GetProcAddress("glCompileShaderARB"); - ctx->glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glCreateProgramObjectARB"); - ctx->glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) SDL_GL_GetProcAddress("glCreateShaderObjectARB"); - ctx->glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) SDL_GL_GetProcAddress("glDeleteObjectARB"); - ctx->glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) SDL_GL_GetProcAddress("glGetInfoLogARB"); - ctx->glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) SDL_GL_GetProcAddress("glGetObjectParameterivARB"); - ctx->glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) SDL_GL_GetProcAddress("glGetUniformLocationARB"); - ctx->glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) SDL_GL_GetProcAddress("glLinkProgramARB"); - ctx->glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) SDL_GL_GetProcAddress("glShaderSourceARB"); - ctx->glUniform1iARB = (PFNGLUNIFORM1IARBPROC) SDL_GL_GetProcAddress("glUniform1iARB"); - ctx->glUniform1fARB = (PFNGLUNIFORM1FARBPROC) SDL_GL_GetProcAddress("glUniform1fARB"); - ctx->glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glUseProgramObjectARB"); + ctx->glGetError = (GLenum(*)(void))SDL_GL_GetProcAddress("glGetError"); + ctx->glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)SDL_GL_GetProcAddress("glAttachObjectARB"); + ctx->glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)SDL_GL_GetProcAddress("glCompileShaderARB"); + ctx->glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glCreateProgramObjectARB"); + ctx->glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)SDL_GL_GetProcAddress("glCreateShaderObjectARB"); + ctx->glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)SDL_GL_GetProcAddress("glDeleteObjectARB"); + ctx->glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)SDL_GL_GetProcAddress("glGetInfoLogARB"); + ctx->glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)SDL_GL_GetProcAddress("glGetObjectParameterivARB"); + ctx->glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)SDL_GL_GetProcAddress("glGetUniformLocationARB"); + ctx->glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)SDL_GL_GetProcAddress("glLinkProgramARB"); + ctx->glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)SDL_GL_GetProcAddress("glShaderSourceARB"); + ctx->glUniform1iARB = (PFNGLUNIFORM1IARBPROC)SDL_GL_GetProcAddress("glUniform1iARB"); + ctx->glUniform1fARB = (PFNGLUNIFORM1FARBPROC)SDL_GL_GetProcAddress("glUniform1fARB"); + ctx->glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glUseProgramObjectARB"); if (ctx->glGetError && ctx->glAttachObjectARB && ctx->glCompileShaderARB && @@ -563,14 +563,12 @@ GL_CreateShaderContext(void) return ctx; } -void -GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader) +void GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader) { ctx->glUseProgramObjectARB(ctx->shaders[shader].program); } -void -GL_DestroyShaderContext(GL_ShaderContext *ctx) +void GL_DestroyShaderContext(GL_ShaderContext *ctx) { int i; diff --git a/src/render/opengl/SDL_shaders_gl.h b/src/render/opengl/SDL_shaders_gl.h index d3e6c398a..466e8eca7 100644 --- a/src/render/opengl/SDL_shaders_gl.h +++ b/src/render/opengl/SDL_shaders_gl.h @@ -26,7 +26,8 @@ /* OpenGL shader implementation */ -typedef enum { +typedef enum +{ SHADER_INVALID = -1, SHADER_NONE, SHADER_SOLID, @@ -50,7 +51,7 @@ typedef enum { typedef struct GL_ShaderContext GL_ShaderContext; -extern GL_ShaderContext * GL_CreateShaderContext(void); +extern GL_ShaderContext *GL_CreateShaderContext(void); extern void GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader); extern void GL_DestroyShaderContext(GL_ShaderContext *ctx); diff --git a/src/render/opengles/SDL_glesfuncs.h b/src/render/opengles/SDL_glesfuncs.h index 40a656455..22dfc6a95 100644 --- a/src/render/opengles/SDL_glesfuncs.h +++ b/src/render/opengles/SDL_glesfuncs.h @@ -44,7 +44,7 @@ SDL_PROC(void, glLoadIdentity, (void)) SDL_PROC(void, glMatrixMode, (GLenum)) SDL_PROC(void, glOrthof, (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat)) SDL_PROC(void, glPixelStorei, (GLenum, GLint)) -SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*)) +SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *)) SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei)) SDL_PROC(void, glTexCoordPointer, (GLint, GLenum, GLsizei, const GLvoid *)) SDL_PROC(void, glTexEnvf, (GLenum, GLenum, GLfloat)) @@ -57,6 +57,6 @@ SDL_PROC(void, glViewport, (GLint, GLint, GLsizei, GLsizei)) SDL_PROC_OES(void, glBindFramebufferOES, (GLenum, GLuint)) SDL_PROC_OES(void, glFramebufferTexture2DOES, (GLenum, GLenum, GLenum, GLuint, GLint)) SDL_PROC_OES(GLenum, glCheckFramebufferStatusOES, (GLenum)) -SDL_PROC_OES(void, glDeleteFramebuffersOES, (GLsizei, const GLuint*)) +SDL_PROC_OES(void, glDeleteFramebuffersOES, (GLsizei, const GLuint *)) /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index 462b3fef3..72cf67369 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -50,7 +50,7 @@ glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height) /* OpenGL ES 1.1 renderer implementation, based on the OpenGL renderer */ /* Used to re-create the window with OpenGL ES capability */ -extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags); +extern int SDL_RecreateWindow(SDL_Window *window, Uint32 flags); static const float inv255f = 1.0f / 255.0f; @@ -58,9 +58,9 @@ typedef struct GLES_FBOList GLES_FBOList; struct GLES_FBOList { - Uint32 w, h; - GLuint FBO; - GLES_FBOList *next; + Uint32 w, h; + GLuint FBO; + GLES_FBOList *next; }; typedef struct @@ -85,8 +85,8 @@ typedef struct { SDL_GLContext context; -#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; -#define SDL_PROC_OES SDL_PROC +#define SDL_PROC(ret, func, params) ret(APIENTRY *func) params; +#define SDL_PROC_OES SDL_PROC #include "SDL_glesfuncs.h" #undef SDL_PROC #undef SDL_PROC_OES @@ -114,8 +114,7 @@ typedef struct GLES_FBOList *fbo; } GLES_TextureData; -static int -GLES_SetError(const char *prefix, GLenum result) +static int GLES_SetError(const char *prefix, GLenum result) { const char *error; @@ -148,7 +147,7 @@ GLES_SetError(const char *prefix, GLenum result) return SDL_SetError("%s: %s", prefix, error); } -static int GLES_LoadFunctions(GLES_RenderData * data) +static int GLES_LoadFunctions(GLES_RenderData *data) { #if SDL_VIDEO_DRIVER_UIKIT #define __SDL_NOGETPROCADDR__ @@ -159,20 +158,20 @@ static int GLES_LoadFunctions(GLES_RenderData * data) #endif #ifdef __SDL_NOGETPROCADDR__ -#define SDL_PROC(ret,func,params) data->func=func; -#define SDL_PROC_OES(ret,func,params) data->func=func; +#define SDL_PROC(ret, func, params) data->func = func; +#define SDL_PROC_OES(ret, func, params) data->func = func; #else -#define SDL_PROC(ret,func,params) \ - do { \ - data->func = SDL_GL_GetProcAddress(#func); \ - if ( ! data->func ) { \ +#define SDL_PROC(ret, func, params) \ + do { \ + data->func = SDL_GL_GetProcAddress(#func); \ + if (!data->func) { \ return SDL_SetError("Couldn't load GLES function %s: %s", #func, SDL_GetError()); \ - } \ - } while ( 0 ); -#define SDL_PROC_OES(ret,func,params) \ - do { \ + } \ + } while (0); +#define SDL_PROC_OES(ret, func, params) \ + do { \ data->func = SDL_GL_GetProcAddress(#func); \ - } while ( 0 ); + } while (0); #endif /* __SDL_NOGETPROCADDR__ */ #include "SDL_glesfuncs.h" @@ -181,29 +180,26 @@ static int GLES_LoadFunctions(GLES_RenderData * data) return 0; } -static GLES_FBOList * -GLES_GetFBO(GLES_RenderData *data, Uint32 w, Uint32 h) +static GLES_FBOList *GLES_GetFBO(GLES_RenderData *data, Uint32 w, Uint32 h) { - GLES_FBOList *result = data->framebuffers; - while ((result) && ((result->w != w) || (result->h != h)) ) { - result = result->next; - } - if (result == NULL) { - result = SDL_malloc(sizeof(GLES_FBOList)); - result->w = w; - result->h = h; - data->glGenFramebuffersOES(1, &result->FBO); - result->next = data->framebuffers; - data->framebuffers = result; - } - return result; + GLES_FBOList *result = data->framebuffers; + while ((result) && ((result->w != w) || (result->h != h))) { + result = result->next; + } + if (result == NULL) { + result = SDL_malloc(sizeof(GLES_FBOList)); + result->w = w; + result->h = h; + data->glGenFramebuffersOES(1, &result->FBO); + result->next = data->framebuffers; + data->framebuffers = result; + } + return result; } - -static int -GLES_ActivateRenderer(SDL_Renderer * renderer) +static int GLES_ActivateRenderer(SDL_Renderer *renderer) { - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + GLES_RenderData *data = (GLES_RenderData *)renderer->driverdata; if (SDL_GL_GetCurrentContext() != data->context) { if (SDL_GL_MakeCurrent(renderer->window, data->context) < 0) { @@ -214,10 +210,9 @@ GLES_ActivateRenderer(SDL_Renderer * renderer) return 0; } -static void -GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +static void GLES_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event) { - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + GLES_RenderData *data = (GLES_RenderData *)renderer->driverdata; if (event->event == SDL_WINDOWEVENT_MINIMIZED) { /* According to Apple documentation, we need to finish drawing NOW! */ @@ -225,8 +220,7 @@ GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) } } -static int -GLES_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) +static int GLES_GetOutputSize(SDL_Renderer *renderer, int *w, int *h) { SDL_GL_GetDrawableSize(renderer->window, w, h); return 0; @@ -274,10 +268,9 @@ static GLenum GetBlendEquation(SDL_BlendOperation operation) } } -static SDL_bool -GLES_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +static SDL_bool GLES_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + GLES_RenderData *data = (GLES_RenderData *)renderer->driverdata; SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode); @@ -305,10 +298,9 @@ GLES_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) return SDL_TRUE; } -static int -GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static int GLES_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata; + GLES_RenderData *renderdata = (GLES_RenderData *)renderer->driverdata; GLES_TextureData *data; GLint internalFormat; GLenum format, type; @@ -328,7 +320,7 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) return SDL_SetError("Texture format not supported"); } - data = (GLES_TextureData *) SDL_calloc(1, sizeof(*data)); + data = (GLES_TextureData *)SDL_calloc(1, sizeof(*data)); if (data == NULL) { return SDL_OutOfMemory(); } @@ -342,7 +334,6 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) } } - if (texture->access == SDL_TEXTUREACCESS_TARGET) { if (!renderdata->GL_OES_framebuffer_object_supported) { SDL_free(data); @@ -353,7 +344,6 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) data->fbo = NULL; } - renderdata->glGetError(); renderdata->glEnable(GL_TEXTURE_2D); renderdata->glGenTextures(1, &data->texture); @@ -370,8 +360,8 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) /* no NPOV textures allowed in OpenGL ES (yet) */ texture_w = SDL_powerof2(texture->w); texture_h = SDL_powerof2(texture->h); - data->texw = (GLfloat) texture->w / texture_w; - data->texh = (GLfloat) texture->h / texture_h; + data->texw = (GLfloat)texture->w / texture_w; + data->texh = (GLfloat)texture->h / texture_h; data->format = format; data->formattype = type; @@ -401,12 +391,11 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) return 0; } -static int -GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, int pitch) +static int GLES_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, const void *pixels, int pitch) { - GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata; - GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + GLES_RenderData *renderdata = (GLES_RenderData *)renderer->driverdata; + GLES_TextureData *data = (GLES_TextureData *)texture->driverdata; Uint8 *blob = NULL; Uint8 *src; int srcPitch; @@ -442,14 +431,14 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, renderdata->glBindTexture(data->type, data->texture); renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); renderdata->glTexSubImage2D(data->type, - 0, - rect->x, - rect->y, - rect->w, - rect->h, - data->format, - data->formattype, - src); + 0, + rect->x, + rect->y, + rect->w, + rect->h, + data->format, + data->formattype, + src); renderdata->glDisable(data->type); SDL_free(blob); @@ -462,23 +451,21 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, return 0; } -static int -GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, void **pixels, int *pitch) +static int GLES_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, void **pixels, int *pitch) { - GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + GLES_TextureData *data = (GLES_TextureData *)texture->driverdata; *pixels = - (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); + (void *)((Uint8 *)data->pixels + rect->y * data->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); *pitch = data->pitch; return 0; } -static void -GLES_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static void GLES_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + GLES_TextureData *data = (GLES_TextureData *)texture->driverdata; SDL_Rect rect; /* We do whole texture updates, at least for now */ @@ -489,11 +476,10 @@ GLES_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) GLES_UpdateTexture(renderer, texture, &rect, data->pixels, data->pitch); } -static void -GLES_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode) +static void GLES_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode) { - GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata; - GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + GLES_RenderData *renderdata = (GLES_RenderData *)renderer->driverdata; + GLES_TextureData *data = (GLES_TextureData *)texture->driverdata; GLenum glScaleMode = (scaleMode == SDL_ScaleModeNearest) ? GL_NEAREST : GL_LINEAR; renderdata->glBindTexture(data->type, data->texture); @@ -501,10 +487,9 @@ GLES_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Sca renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, glScaleMode); } -static int -GLES_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +static int GLES_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) { - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + GLES_RenderData *data = (GLES_RenderData *)renderer->driverdata; GLES_TextureData *texturedata = NULL; GLenum status; @@ -519,7 +504,7 @@ GLES_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) return 0; } - texturedata = (GLES_TextureData *) texture->driverdata; + texturedata = (GLES_TextureData *)texture->driverdata; data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, texturedata->fbo->FBO); /* TODO: check if texture pixel format allows this operation */ data->glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, texturedata->type, texturedata->texture, 0); @@ -531,17 +516,14 @@ GLES_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) return 0; } - -static int -GLES_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd) +static int GLES_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { - return 0; /* nothing to do in this backend. */ + return 0; /* nothing to do in this backend. */ } -static int -GLES_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) +static int GLES_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { - GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, count * 2 * sizeof (GLfloat), 0, &cmd->data.draw.first); + GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(GLfloat), 0, &cmd->data.draw.first); int i; if (verts == NULL) { @@ -557,13 +539,12 @@ GLES_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_ return 0; } -static int -GLES_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) +static int GLES_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { int i; GLfloat prevx, prevy; - const size_t vertlen = (sizeof (GLfloat) * 2) * count; - GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first); + const size_t vertlen = (sizeof(GLfloat) * 2) * count; + GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first); if (verts == NULL) { return -1; @@ -583,7 +564,7 @@ GLES_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F for (i = 1; i < count; i++) { const GLfloat xstart = prevx; const GLfloat ystart = prevy; - const GLfloat xend = points[i].x + 0.5f; /* 0.5f to hit pixel center. */ + const GLfloat xend = points[i].x + 0.5f; /* 0.5f to hit pixel center. */ const GLfloat yend = points[i].y + 0.5f; /* bump a little in the direction we are moving in. */ const GLfloat deltax = xend - xstart; @@ -598,11 +579,10 @@ GLES_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F return 0; } -static int -GLES_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, - const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, - int num_vertices, const void *indices, int num_indices, int size_indices, - float scale_x, float scale_y) +static int GLES_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, + int num_vertices, const void *indices, int num_indices, int size_indices, + float scale_x, float scale_y) { GLES_TextureData *texturedata = NULL; int i; @@ -610,13 +590,13 @@ GLES_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture * GLfloat *verts; int sz = 2 + 4 + (texture ? 2 : 0); - verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, count * sz * sizeof (GLfloat), 0, &cmd->data.draw.first); + verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * sz * sizeof(GLfloat), 0, &cmd->data.draw.first); if (verts == NULL) { return -1; } if (texture) { - texturedata = (GLES_TextureData *) texture->driverdata; + texturedata = (GLES_TextureData *)texture->driverdata; } cmd->data.draw.count = count; @@ -636,8 +616,8 @@ GLES_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture * j = i; } - xy_ = (float *)((char*)xy + j * xy_stride); - col_ = *(SDL_Color *)((char*)color + j * color_stride); + xy_ = (float *)((char *)xy + j * xy_stride); + col_ = *(SDL_Color *)((char *)color + j * color_stride); *(verts++) = xy_[0] * scale_x; *(verts++) = xy_[1] * scale_y; @@ -648,7 +628,7 @@ GLES_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture * *(verts++) = col_.a * inv255f; if (texture) { - float *uv_ = (float *)((char*)uv + j * uv_stride); + float *uv_ = (float *)((char *)uv + j * uv_stride); *(verts++) = uv_[0] * texturedata->texw; *(verts++) = uv_[1] * texturedata->texh; } @@ -656,8 +636,7 @@ GLES_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture * return 0; } -static void -SetDrawState(GLES_RenderData *data, const SDL_RenderCommand *cmd) +static void SetDrawState(GLES_RenderData *data, const SDL_RenderCommand *cmd) { const SDL_BlendMode blend = cmd->data.draw.blend; const Uint8 r = cmd->data.draw.r; @@ -667,10 +646,10 @@ SetDrawState(GLES_RenderData *data, const SDL_RenderCommand *cmd) const Uint32 color = (((Uint32)a << 24) | (r << 16) | (g << 8) | b); if (color != data->drawstate.color) { - const GLfloat fr = ((GLfloat) r) * inv255f; - const GLfloat fg = ((GLfloat) g) * inv255f; - const GLfloat fb = ((GLfloat) b) * inv255f; - const GLfloat fa = ((GLfloat) a) * inv255f; + const GLfloat fr = ((GLfloat)r) * inv255f; + const GLfloat fg = ((GLfloat)g) * inv255f; + const GLfloat fb = ((GLfloat)b) * inv255f; + const GLfloat fa = ((GLfloat)a) * inv255f; data->glColor4f(fr, fg, fb, fa); data->drawstate.color = color; } @@ -684,9 +663,9 @@ SetDrawState(GLES_RenderData *data, const SDL_RenderCommand *cmd) istarget ? viewport->y : (data->drawstate.drawableh - viewport->y - viewport->h), viewport->w, viewport->h); if (viewport->w && viewport->h) { - data->glOrthof((GLfloat) 0, (GLfloat) viewport->w, - (GLfloat) (istarget ? 0 : viewport->h), - (GLfloat) (istarget ? viewport->h : 0), + data->glOrthof((GLfloat)0, (GLfloat)viewport->w, + (GLfloat)(istarget ? 0 : viewport->h), + (GLfloat)(istarget ? viewport->h : 0), 0.0, 1.0); } data->glMatrixMode(GL_MODELVIEW); @@ -749,23 +728,21 @@ SetDrawState(GLES_RenderData *data, const SDL_RenderCommand *cmd) } } -static void -SetCopyState(GLES_RenderData *data, const SDL_RenderCommand *cmd) +static void SetCopyState(GLES_RenderData *data, const SDL_RenderCommand *cmd) { SDL_Texture *texture = cmd->data.draw.texture; SetDrawState(data, cmd); if (texture != data->drawstate.texture) { - GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata; + GLES_TextureData *texturedata = (GLES_TextureData *)texture->driverdata; data->glBindTexture(GL_TEXTURE_2D, texturedata->texture); data->drawstate.texture = texture; } } -static int -GLES_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) +static int GLES_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) { - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + GLES_RenderData *data = (GLES_RenderData *)renderer->driverdata; if (GLES_ActivateRenderer(renderer) < 0) { return -1; @@ -777,123 +754,129 @@ GLES_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vert int w, h; SDL_GL_GetDrawableSize(renderer->window, &w, &h); if ((w != data->drawstate.drawablew) || (h != data->drawstate.drawableh)) { - data->drawstate.viewport_dirty = SDL_TRUE; // if the window dimensions changed, invalidate the current viewport, etc. + data->drawstate.viewport_dirty = SDL_TRUE; // if the window dimensions changed, invalidate the current viewport, etc. data->drawstate.cliprect_dirty = SDL_TRUE; data->drawstate.drawablew = w; data->drawstate.drawableh = h; } - } while (cmd) { switch (cmd->command) { - case SDL_RENDERCMD_SETDRAWCOLOR: { - break; /* not used in this render backend. */ + case SDL_RENDERCMD_SETDRAWCOLOR: + { + break; /* not used in this render backend. */ + } + + case SDL_RENDERCMD_SETVIEWPORT: + { + SDL_Rect *viewport = &data->drawstate.viewport; + if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { + SDL_copyp(viewport, &cmd->data.viewport.rect); + data->drawstate.viewport_dirty = SDL_TRUE; + } + break; + } + + case SDL_RENDERCMD_SETCLIPRECT: + { + const SDL_Rect *rect = &cmd->data.cliprect.rect; + if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) { + data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled; + data->drawstate.cliprect_enabled_dirty = SDL_TRUE; + } + if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) { + SDL_copyp(&data->drawstate.cliprect, rect); + data->drawstate.cliprect_dirty = SDL_TRUE; + } + break; + } + + case SDL_RENDERCMD_CLEAR: + { + const Uint8 r = cmd->data.color.r; + const Uint8 g = cmd->data.color.g; + const Uint8 b = cmd->data.color.b; + const Uint8 a = cmd->data.color.a; + const Uint32 color = (((Uint32)a << 24) | (r << 16) | (g << 8) | b); + if (color != data->drawstate.clear_color) { + const GLfloat fr = ((GLfloat)r) * inv255f; + const GLfloat fg = ((GLfloat)g) * inv255f; + const GLfloat fb = ((GLfloat)b) * inv255f; + const GLfloat fa = ((GLfloat)a) * inv255f; + data->glClearColor(fr, fg, fb, fa); + data->drawstate.clear_color = color; } - case SDL_RENDERCMD_SETVIEWPORT: { - SDL_Rect *viewport = &data->drawstate.viewport; - if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { - SDL_copyp(viewport, &cmd->data.viewport.rect); - data->drawstate.viewport_dirty = SDL_TRUE; - } - break; + if (data->drawstate.cliprect_enabled || data->drawstate.cliprect_enabled_dirty) { + data->glDisable(GL_SCISSOR_TEST); + data->drawstate.cliprect_enabled_dirty = data->drawstate.cliprect_enabled; } - case SDL_RENDERCMD_SETCLIPRECT: { - const SDL_Rect *rect = &cmd->data.cliprect.rect; - if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) { - data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled; - data->drawstate.cliprect_enabled_dirty = SDL_TRUE; - } - if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) { - SDL_copyp(&data->drawstate.cliprect, rect); - data->drawstate.cliprect_dirty = SDL_TRUE; - } - break; - } + data->glClear(GL_COLOR_BUFFER_BIT); - case SDL_RENDERCMD_CLEAR: { - const Uint8 r = cmd->data.color.r; - const Uint8 g = cmd->data.color.g; - const Uint8 b = cmd->data.color.b; - const Uint8 a = cmd->data.color.a; - const Uint32 color = (((Uint32)a << 24) | (r << 16) | (g << 8) | b); - if (color != data->drawstate.clear_color) { - const GLfloat fr = ((GLfloat) r) * inv255f; - const GLfloat fg = ((GLfloat) g) * inv255f; - const GLfloat fb = ((GLfloat) b) * inv255f; - const GLfloat fa = ((GLfloat) a) * inv255f; - data->glClearColor(fr, fg, fb, fa); - data->drawstate.clear_color = color; - } + break; + } - if (data->drawstate.cliprect_enabled || data->drawstate.cliprect_enabled_dirty) { - data->glDisable(GL_SCISSOR_TEST); - data->drawstate.cliprect_enabled_dirty = data->drawstate.cliprect_enabled; - } + case SDL_RENDERCMD_DRAW_POINTS: + { + const size_t count = cmd->data.draw.count; + const GLfloat *verts = (GLfloat *)(((Uint8 *)vertices) + cmd->data.draw.first); + SetDrawState(data, cmd); + data->glVertexPointer(2, GL_FLOAT, 0, verts); + data->glDrawArrays(GL_POINTS, 0, (GLsizei)count); + break; + } - data->glClear(GL_COLOR_BUFFER_BIT); + case SDL_RENDERCMD_DRAW_LINES: + { + const GLfloat *verts = (GLfloat *)(((Uint8 *)vertices) + cmd->data.draw.first); + const size_t count = cmd->data.draw.count; + SDL_assert(count >= 2); + SetDrawState(data, cmd); + data->glVertexPointer(2, GL_FLOAT, 0, verts); + data->glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)count); + break; + } - break; - } + case SDL_RENDERCMD_FILL_RECTS: /* unused */ + break; - case SDL_RENDERCMD_DRAW_POINTS: { - const size_t count = cmd->data.draw.count; - const GLfloat *verts = (GLfloat *) (((Uint8 *) vertices) + cmd->data.draw.first); + case SDL_RENDERCMD_COPY: /* unused */ + break; + + case SDL_RENDERCMD_COPY_EX: /* unused */ + break; + + case SDL_RENDERCMD_GEOMETRY: + { + const GLfloat *verts = (GLfloat *)(((Uint8 *)vertices) + cmd->data.draw.first); + SDL_Texture *texture = cmd->data.draw.texture; + const size_t count = cmd->data.draw.count; + int stride = (2 + 4 + (texture ? 2 : 0)) * sizeof(float); + + if (texture) { + SetCopyState(data, cmd); + } else { SetDrawState(data, cmd); - data->glVertexPointer(2, GL_FLOAT, 0, verts); - data->glDrawArrays(GL_POINTS, 0, (GLsizei) count); - break; } - case SDL_RENDERCMD_DRAW_LINES: { - const GLfloat *verts = (GLfloat *) (((Uint8 *) vertices) + cmd->data.draw.first); - const size_t count = cmd->data.draw.count; - SDL_assert(count >= 2); - SetDrawState(data, cmd); - data->glVertexPointer(2, GL_FLOAT, 0, verts); - data->glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) count); - break; + data->glEnableClientState(GL_COLOR_ARRAY); + + data->glVertexPointer(2, GL_FLOAT, stride, verts); + data->glColorPointer(4, GL_FLOAT, stride, verts + 2); + if (texture) { + data->glTexCoordPointer(2, GL_FLOAT, stride, verts + 2 + 4); } - case SDL_RENDERCMD_FILL_RECTS: /* unused */ - break; + data->glDrawArrays(GL_TRIANGLES, 0, (GLsizei)count); - case SDL_RENDERCMD_COPY: /* unused */ - break; + data->glDisableClientState(GL_COLOR_ARRAY); + break; + } - case SDL_RENDERCMD_COPY_EX: /* unused */ - break; - - case SDL_RENDERCMD_GEOMETRY: { - const GLfloat *verts = (GLfloat *) (((Uint8 *) vertices) + cmd->data.draw.first); - SDL_Texture *texture = cmd->data.draw.texture; - const size_t count = cmd->data.draw.count; - int stride = (2 + 4 + (texture ? 2 : 0)) * sizeof (float); - - if (texture) { - SetCopyState(data, cmd); - } else { - SetDrawState(data, cmd); - } - - data->glEnableClientState(GL_COLOR_ARRAY); - - data->glVertexPointer(2, GL_FLOAT, stride, verts); - data->glColorPointer(4, GL_FLOAT, stride, verts + 2); - if (texture) { - data->glTexCoordPointer(2, GL_FLOAT, stride, verts + 2 + 4); - } - - data->glDrawArrays(GL_TRIANGLES, 0, (GLsizei) count); - - data->glDisableClientState(GL_COLOR_ARRAY); - break; - } - - case SDL_RENDERCMD_NO_OP: - break; + case SDL_RENDERCMD_NO_OP: + break; } cmd = cmd->next; @@ -902,11 +885,10 @@ GLES_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vert return 0; } -static int -GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 pixel_format, void * pixels, int pitch) +static int GLES_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, + Uint32 pixel_format, void *pixels, int pitch) { - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + GLES_RenderData *data = (GLES_RenderData *)renderer->driverdata; Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ABGR8888; void *temp_pixels; int temp_pitch; @@ -926,15 +908,15 @@ GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, data->glPixelStorei(GL_PACK_ALIGNMENT, 1); - data->glReadPixels(rect->x, renderer->target ? rect->y : (h-rect->y)-rect->h, + data->glReadPixels(rect->x, renderer->target ? rect->y : (h - rect->y) - rect->h, rect->w, rect->h, GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels); /* Flip the rows to be top-down if necessary */ if (!renderer->target) { SDL_bool isstack; length = rect->w * SDL_BYTESPERPIXEL(temp_format); - src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch; - dst = (Uint8*)temp_pixels; + src = (Uint8 *)temp_pixels + (rect->h - 1) * temp_pitch; + dst = (Uint8 *)temp_pixels; tmp = SDL_small_alloc(Uint8, length, &isstack); rows = rect->h / 2; while (rows--) { @@ -955,20 +937,18 @@ GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, return status; } -static int -GLES_RenderPresent(SDL_Renderer * renderer) +static int GLES_RenderPresent(SDL_Renderer *renderer) { GLES_ActivateRenderer(renderer); return SDL_GL_SwapWindowWithResult(renderer->window); } -static void -GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static void GLES_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata; + GLES_RenderData *renderdata = (GLES_RenderData *)renderer->driverdata; - GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + GLES_TextureData *data = (GLES_TextureData *)texture->driverdata; GLES_ActivateRenderer(renderer); @@ -990,18 +970,17 @@ GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) texture->driverdata = NULL; } -static void -GLES_DestroyRenderer(SDL_Renderer * renderer) +static void GLES_DestroyRenderer(SDL_Renderer *renderer) { - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + GLES_RenderData *data = (GLES_RenderData *)renderer->driverdata; if (data) { if (data->context) { while (data->framebuffers) { - GLES_FBOList *nextnode = data->framebuffers->next; - data->glDeleteFramebuffersOES(1, &data->framebuffers->FBO); - SDL_free(data->framebuffers); - data->framebuffers = nextnode; + GLES_FBOList *nextnode = data->framebuffers->next; + data->glDeleteFramebuffersOES(1, &data->framebuffers->FBO); + SDL_free(data->framebuffers); + data->framebuffers = nextnode; } SDL_GL_DeleteContext(data->context); } @@ -1010,10 +989,10 @@ GLES_DestroyRenderer(SDL_Renderer * renderer) SDL_free(renderer); } -static int GLES_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh) +static int GLES_BindTexture(SDL_Renderer *renderer, SDL_Texture *texture, float *texw, float *texh) { - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; - GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata; + GLES_RenderData *data = (GLES_RenderData *)renderer->driverdata; + GLES_TextureData *texturedata = (GLES_TextureData *)texture->driverdata; GLES_ActivateRenderer(renderer); data->glEnable(GL_TEXTURE_2D); @@ -1032,10 +1011,10 @@ static int GLES_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, floa return 0; } -static int GLES_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) +static int GLES_UnbindTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; - GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata; + GLES_RenderData *data = (GLES_RenderData *)renderer->driverdata; + GLES_TextureData *texturedata = (GLES_TextureData *)texture->driverdata; GLES_ActivateRenderer(renderer); data->glDisable(texturedata->type); @@ -1045,8 +1024,7 @@ static int GLES_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) return 0; } -static int -GLES_SetVSync(SDL_Renderer * renderer, const int vsync) +static int GLES_SetVSync(SDL_Renderer *renderer, const int vsync) { int retval; if (vsync) { @@ -1065,9 +1043,7 @@ GLES_SetVSync(SDL_Renderer * renderer, const int vsync) return retval; } - -static SDL_Renderer * -GLES_CreateRenderer(SDL_Window * window, Uint32 flags) +static SDL_Renderer *GLES_CreateRenderer(SDL_Window *window, Uint32 flags) { SDL_Renderer *renderer; GLES_RenderData *data; @@ -1094,13 +1070,13 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags) } } - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); if (renderer == NULL) { SDL_OutOfMemory(); goto error; } - data = (GLES_RenderData *) SDL_calloc(1, sizeof(*data)); + data = (GLES_RenderData *)SDL_calloc(1, sizeof(*data)); if (data == NULL) { GLES_DestroyRenderer(renderer); SDL_OutOfMemory(); @@ -1117,7 +1093,7 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->SetTextureScaleMode = GLES_SetTextureScaleMode; renderer->SetRenderTarget = GLES_SetRenderTarget; renderer->QueueSetViewport = GLES_QueueSetViewport; - renderer->QueueSetDrawColor = GLES_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */ + renderer->QueueSetDrawColor = GLES_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */ renderer->QueueDrawPoints = GLES_QueueDrawPoints; renderer->QueueDrawLines = GLES_QueueDrawLines; renderer->QueueGeometry = GLES_QueueGeometry; @@ -1217,14 +1193,12 @@ error: SDL_RenderDriver GLES_RenderDriver = { GLES_CreateRenderer, - { - "opengles", - (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), - 1, - {SDL_PIXELFORMAT_ABGR8888}, - 0, - 0 - } + { "opengles", + (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), + 1, + { SDL_PIXELFORMAT_ABGR8888 }, + 0, + 0 } }; #endif /* SDL_VIDEO_RENDER_OGL_ES && !SDL_RENDER_DISABLED */ diff --git a/src/render/opengles2/SDL_gles2funcs.h b/src/render/opengles2/SDL_gles2funcs.h index ab8bf85bb..408cfe362 100644 --- a/src/render/opengles2/SDL_gles2funcs.h +++ b/src/render/opengles2/SDL_gles2funcs.h @@ -50,7 +50,7 @@ SDL_PROC(void, glGetShaderiv, (GLuint, GLenum, GLint *)) SDL_PROC(GLint, glGetUniformLocation, (GLuint, const char *)) SDL_PROC(void, glLinkProgram, (GLuint)) SDL_PROC(void, glPixelStorei, (GLenum, GLint)) -SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*)) +SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *)) SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei)) SDL_PROC(void, glShaderBinary, (GLsizei, const GLuint *, GLenum, const void *, GLsizei)) #if __NACL__ @@ -72,7 +72,7 @@ SDL_PROC(void, glFramebufferTexture2D, (GLenum, GLenum, GLenum, GLuint, GLint)) SDL_PROC(GLenum, glCheckFramebufferStatus, (GLenum)) SDL_PROC(void, glDeleteFramebuffers, (GLsizei, const GLuint *)) SDL_PROC(GLint, glGetAttribLocation, (GLuint, const GLchar *)) -SDL_PROC(void, glGetProgramInfoLog, (GLuint, GLsizei, GLsizei*, GLchar*)) +SDL_PROC(void, glGetProgramInfoLog, (GLuint, GLsizei, GLsizei *, GLchar *)) SDL_PROC(void, glGenBuffers, (GLsizei, GLuint *)) SDL_PROC(void, glDeleteBuffers, (GLsizei, const GLuint *)) SDL_PROC(void, glBindBuffer, (GLenum, GLuint)) diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index c5cfae6a9..eebb985f8 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -47,7 +47,7 @@ #define RENDERER_CONTEXT_MINOR 0 /* Used to re-create the window with OpenGL ES capability */ -extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags); +extern int SDL_RecreateWindow(SDL_Window *window, Uint32 flags); /************************************************************************************************* * Context structures * @@ -57,9 +57,9 @@ typedef struct GLES2_FBOList GLES2_FBOList; struct GLES2_FBOList { - Uint32 w, h; - GLuint FBO; - GLES2_FBOList *next; + Uint32 w, h; + GLuint FBO; + GLES2_FBOList *next; }; typedef struct GLES2_TextureData @@ -152,7 +152,7 @@ typedef struct GLES2_RenderData SDL_bool debug_enabled; -#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; +#define SDL_PROC(ret, func, params) ret(APIENTRY *func) params; #include "SDL_gles2funcs.h" #undef SDL_PROC GLES2_FBOList *framebuffers; @@ -177,27 +177,28 @@ typedef struct GLES2_RenderData static const float inv255f = 1.0f / 255.0f; - -SDL_FORCE_INLINE const char* -GL_TranslateError (GLenum error) +SDL_FORCE_INLINE const char * +GL_TranslateError(GLenum error) { -#define GL_ERROR_TRANSLATE(e) case e: return #e; +#define GL_ERROR_TRANSLATE(e) \ + case e: \ + return #e; switch (error) { - GL_ERROR_TRANSLATE(GL_INVALID_ENUM) - GL_ERROR_TRANSLATE(GL_INVALID_VALUE) - GL_ERROR_TRANSLATE(GL_INVALID_OPERATION) - GL_ERROR_TRANSLATE(GL_OUT_OF_MEMORY) - GL_ERROR_TRANSLATE(GL_NO_ERROR) + GL_ERROR_TRANSLATE(GL_INVALID_ENUM) + GL_ERROR_TRANSLATE(GL_INVALID_VALUE) + GL_ERROR_TRANSLATE(GL_INVALID_OPERATION) + GL_ERROR_TRANSLATE(GL_OUT_OF_MEMORY) + GL_ERROR_TRANSLATE(GL_NO_ERROR) default: return "UNKNOWN"; -} + } #undef GL_ERROR_TRANSLATE } SDL_FORCE_INLINE void GL_ClearErrors(SDL_Renderer *renderer) { - GLES2_RenderData *data = (GLES2_RenderData *) renderer->driverdata; + GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata; if (!data->debug_enabled) { return; @@ -208,9 +209,9 @@ GL_ClearErrors(SDL_Renderer *renderer) } SDL_FORCE_INLINE int -GL_CheckAllErrors (const char *prefix, SDL_Renderer *renderer, const char *file, int line, const char *function) +GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const char *file, int line, const char *function) { - GLES2_RenderData *data = (GLES2_RenderData *) renderer->driverdata; + GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata; int ret = 0; if (!data->debug_enabled) { @@ -238,12 +239,11 @@ GL_CheckAllErrors (const char *prefix, SDL_Renderer *renderer, const char *file, #define GL_CheckError(prefix, renderer) GL_CheckAllErrors(prefix, renderer, SDL_FILE, SDL_LINE, SDL_FUNCTION) #endif - /************************************************************************************************* * Renderer state APIs * *************************************************************************************************/ -static int GLES2_LoadFunctions(GLES2_RenderData * data) +static int GLES2_LoadFunctions(GLES2_RenderData *data) { #if SDL_VIDEO_DRIVER_UIKIT #define __SDL_NOGETPROCADDR__ @@ -254,15 +254,15 @@ static int GLES2_LoadFunctions(GLES2_RenderData * data) #endif #if defined __SDL_NOGETPROCADDR__ -#define SDL_PROC(ret,func,params) data->func=func; +#define SDL_PROC(ret, func, params) data->func = func; #else -#define SDL_PROC(ret,func,params) \ - do { \ - data->func = SDL_GL_GetProcAddress(#func); \ - if ( ! data->func ) { \ +#define SDL_PROC(ret, func, params) \ + do { \ + data->func = SDL_GL_GetProcAddress(#func); \ + if (!data->func) { \ return SDL_SetError("Couldn't load GLES2 function %s: %s", #func, SDL_GetError()); \ - } \ - } while ( 0 ); + } \ + } while (0); #endif /* __SDL_NOGETPROCADDR__ */ #include "SDL_gles2funcs.h" @@ -270,26 +270,24 @@ static int GLES2_LoadFunctions(GLES2_RenderData * data) return 0; } -static GLES2_FBOList * -GLES2_GetFBO(GLES2_RenderData *data, Uint32 w, Uint32 h) +static GLES2_FBOList *GLES2_GetFBO(GLES2_RenderData *data, Uint32 w, Uint32 h) { - GLES2_FBOList *result = data->framebuffers; - while ((result) && ((result->w != w) || (result->h != h)) ) { - result = result->next; - } - if (result == NULL) { - result = SDL_malloc(sizeof(GLES2_FBOList)); - result->w = w; - result->h = h; - data->glGenFramebuffers(1, &result->FBO); - result->next = data->framebuffers; - data->framebuffers = result; - } - return result; + GLES2_FBOList *result = data->framebuffers; + while ((result) && ((result->w != w) || (result->h != h))) { + result = result->next; + } + if (result == NULL) { + result = SDL_malloc(sizeof(GLES2_FBOList)); + result->w = w; + result->h = h; + data->glGenFramebuffers(1, &result->FBO); + result->next = data->framebuffers; + data->framebuffers = result; + } + return result; } -static int -GLES2_ActivateRenderer(SDL_Renderer * renderer) +static int GLES2_ActivateRenderer(SDL_Renderer *renderer) { GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata; @@ -307,8 +305,7 @@ GLES2_ActivateRenderer(SDL_Renderer * renderer) return 0; } -static void -GLES2_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +static void GLES2_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event) { GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata; @@ -318,8 +315,7 @@ GLES2_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) } } -static int -GLES2_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) +static int GLES2_GetOutputSize(SDL_Renderer *renderer, int *w, int *h) { SDL_GL_GetDrawableSize(renderer->window, w, h); return 0; @@ -367,8 +363,7 @@ static GLenum GetBlendEquation(SDL_BlendOperation operation) } } -static SDL_bool -GLES2_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +static SDL_bool GLES2_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); @@ -388,9 +383,7 @@ GLES2_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) return SDL_TRUE; } - -static GLES2_ProgramCacheEntry * -GLES2_CacheProgram(GLES2_RenderData *data, GLuint vertex, GLuint fragment) +static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuint vertex, GLuint fragment) { GLES2_ProgramCacheEntry *entry; GLint linkSuccessful; @@ -456,13 +449,13 @@ GLES2_CacheProgram(GLES2_RenderData *data, GLuint vertex, GLuint fragment) data->glUseProgram(entry->id); if (entry->uniform_locations[GLES2_UNIFORM_TEXTURE_V] != -1) { - data->glUniform1i(entry->uniform_locations[GLES2_UNIFORM_TEXTURE_V], 2); /* always texture unit 2. */ + data->glUniform1i(entry->uniform_locations[GLES2_UNIFORM_TEXTURE_V], 2); /* always texture unit 2. */ } if (entry->uniform_locations[GLES2_UNIFORM_TEXTURE_U] != -1) { - data->glUniform1i(entry->uniform_locations[GLES2_UNIFORM_TEXTURE_U], 1); /* always texture unit 1. */ + data->glUniform1i(entry->uniform_locations[GLES2_UNIFORM_TEXTURE_U], 1); /* always texture unit 1. */ } if (entry->uniform_locations[GLES2_UNIFORM_TEXTURE] != -1) { - data->glUniform1i(entry->uniform_locations[GLES2_UNIFORM_TEXTURE], 0); /* always texture unit 0. */ + data->glUniform1i(entry->uniform_locations[GLES2_UNIFORM_TEXTURE], 0); /* always texture unit 0. */ } if (entry->uniform_locations[GLES2_UNIFORM_PROJECTION] != -1) { data->glUniformMatrix4fv(entry->uniform_locations[GLES2_UNIFORM_PROJECTION], 1, GL_FALSE, (GLfloat *)entry->projection); @@ -491,8 +484,7 @@ GLES2_CacheProgram(GLES2_RenderData *data, GLuint vertex, GLuint fragment) return entry; } -static GLuint -GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, GLenum shader_type) +static GLuint GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, GLenum shader_type) { GLuint id = 0; GLint compileSuccessful = GL_FALSE; @@ -573,7 +565,7 @@ GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, GLenum shader_t return id; } -static int GLES2_CacheShaders(GLES2_RenderData * data) +static int GLES2_CacheShaders(GLES2_RenderData *data) { int shader; @@ -587,15 +579,14 @@ static int GLES2_CacheShaders(GLES2_RenderData * data) } else { shader_type = GL_FRAGMENT_SHADER; } - if (!GLES2_CacheShader(data, (GLES2_ShaderType) shader, shader_type)) { + if (!GLES2_CacheShader(data, (GLES2_ShaderType)shader, shader_type)) { return -1; } } return 0; } -static int -GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, int w, int h) +static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, int w, int h) { GLuint vertex; GLuint fragment; @@ -728,17 +719,15 @@ fault: return -1; } -static int -GLES2_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd) +static int GLES2_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { - return 0; /* nothing to do in this backend. */ + return 0; /* nothing to do in this backend. */ } -static int -GLES2_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) +static int GLES2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888)); - SDL_VertexSolid *verts = (SDL_VertexSolid *) SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first); + SDL_VertexSolid *verts = (SDL_VertexSolid *)SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first); int i; SDL_Color color; color.r = cmd->data.draw.r; @@ -767,13 +756,12 @@ GLES2_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL return 0; } -static int -GLES2_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) +static int GLES2_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888)); int i; GLfloat prevx, prevy; - SDL_VertexSolid *verts = (SDL_VertexSolid *) SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first); + SDL_VertexSolid *verts = (SDL_VertexSolid *)SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first); SDL_Color color; color.r = cmd->data.draw.r; color.g = cmd->data.draw.g; @@ -807,7 +795,7 @@ GLES2_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_ for (i = 1; i < count; i++) { const GLfloat xstart = prevx; const GLfloat ystart = prevy; - const GLfloat xend = points[i].x + 0.5f; /* 0.5f to hit pixel center. */ + const GLfloat xend = points[i].x + 0.5f; /* 0.5f to hit pixel center. */ const GLfloat yend = points[i].y + 0.5f; /* bump a little in the direction we are moving in. */ const GLfloat deltax = xend - xstart; @@ -824,11 +812,10 @@ GLES2_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_ return 0; } -static int -GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, - const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, - int num_vertices, const void *indices, int num_indices, int size_indices, - float scale_x, float scale_y) +static int GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, + int num_vertices, const void *indices, int num_indices, int size_indices, + float scale_x, float scale_y) { int i; const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888)); @@ -838,7 +825,7 @@ GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture size_indices = indices ? size_indices : 0; if (texture) { - SDL_Vertex *verts = (SDL_Vertex *) SDL_AllocateRenderVertices(renderer, count * sizeof (*verts), 0, &cmd->data.draw.first); + SDL_Vertex *verts = (SDL_Vertex *)SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first); if (verts == NULL) { return -1; } @@ -858,9 +845,9 @@ GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture j = i; } - xy_ = (float *)((char*)xy + j * xy_stride); - col_ = *(SDL_Color *)((char*)color + j * color_stride); - uv_ = (float *)((char*)uv + j * uv_stride); + xy_ = (float *)((char *)xy + j * xy_stride); + col_ = *(SDL_Color *)((char *)color + j * color_stride); + uv_ = (float *)((char *)uv + j * uv_stride); verts->position.x = xy_[0] * scale_x; verts->position.y = xy_[1] * scale_y; @@ -878,7 +865,7 @@ GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture } } else { - SDL_VertexSolid *verts = (SDL_VertexSolid *) SDL_AllocateRenderVertices(renderer, count * sizeof (*verts), 0, &cmd->data.draw.first); + SDL_VertexSolid *verts = (SDL_VertexSolid *)SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first); if (verts == NULL) { return -1; } @@ -898,8 +885,8 @@ GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture j = i; } - xy_ = (float *)((char*)xy + j * xy_stride); - col_ = *(SDL_Color *)((char*)color + j * color_stride); + xy_ = (float *)((char *)xy + j * xy_stride); + col_ = *(SDL_Color *)((char *)color + j * color_stride); verts->position.x = xy_[0] * scale_x; verts->position.y = xy_[1] * scale_y; @@ -918,8 +905,7 @@ GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture return 0; } -static int -SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_ImageSource imgsrc, void *vertices) +static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_ImageSource imgsrc, void *vertices) { SDL_Texture *texture = cmd->data.draw.texture; const SDL_BlendMode blend = cmd->data.draw.blend; @@ -961,10 +947,10 @@ SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_I if ((texture != NULL) != data->drawstate.texturing) { if (texture == NULL) { - data->glDisableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_TEXCOORD); + data->glDisableVertexAttribArray((GLenum)GLES2_ATTRIBUTE_TEXCOORD); data->drawstate.texturing = SDL_FALSE; } else { - data->glEnableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_TEXCOORD); + data->glEnableVertexAttribArray((GLenum)GLES2_ATTRIBUTE_TEXCOORD); data->drawstate.texturing = SDL_TRUE; } } @@ -976,7 +962,7 @@ SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_I } if (texture) { - SDL_Vertex *verts = (SDL_Vertex *) (((Uint8 *) vertices) + cmd->data.draw.first); + SDL_Vertex *verts = (SDL_Vertex *)(((Uint8 *)vertices) + cmd->data.draw.first); data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, stride, (const GLvoid *)&verts->tex_coord); } @@ -987,9 +973,9 @@ SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_I program = data->drawstate.program; if (program->uniform_locations[GLES2_UNIFORM_PROJECTION] != -1) { - if (SDL_memcmp(program->projection, data->drawstate.projection, sizeof (data->drawstate.projection)) != 0) { + if (SDL_memcmp(program->projection, data->drawstate.projection, sizeof(data->drawstate.projection)) != 0) { data->glUniformMatrix4fv(program->uniform_locations[GLES2_UNIFORM_PROJECTION], 1, GL_FALSE, (GLfloat *)data->drawstate.projection); - SDL_memcpy(program->projection, data->drawstate.projection, sizeof (data->drawstate.projection)); + SDL_memcpy(program->projection, data->drawstate.projection, sizeof(data->drawstate.projection)); } } @@ -1010,18 +996,17 @@ SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_I /* all drawing commands use this */ { - SDL_VertexSolid *verts = (SDL_VertexSolid *) (((Uint8 *) vertices) + cmd->data.draw.first); - data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, stride, (const GLvoid *) &verts->position); - data->glVertexAttribPointer(GLES2_ATTRIBUTE_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE /* Normalized */, stride, (const GLvoid *) &verts->color); + SDL_VertexSolid *verts = (SDL_VertexSolid *)(((Uint8 *)vertices) + cmd->data.draw.first); + data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, stride, (const GLvoid *)&verts->position); + data->glVertexAttribPointer(GLES2_ATTRIBUTE_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE /* Normalized */, stride, (const GLvoid *)&verts->color); } return 0; } -static int -SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, void *vertices) +static int SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, void *vertices) { - GLES2_RenderData *data = (GLES2_RenderData *) renderer->driverdata; + GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata; GLES2_ImageSource sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; SDL_Texture *texture = cmd->data.draw.texture; int ret; @@ -1098,46 +1083,46 @@ SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, void *vertice return SDL_SetError("Unsupported texture format"); } } else { - sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */ + sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */ } } else { switch (texture->format) { - case SDL_PIXELFORMAT_ARGB8888: - sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; - break; - case SDL_PIXELFORMAT_ABGR8888: - sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; - break; - case SDL_PIXELFORMAT_RGB888: - sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB; - break; - case SDL_PIXELFORMAT_BGR888: - sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR; - break; + case SDL_PIXELFORMAT_ARGB8888: + sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; + break; + case SDL_PIXELFORMAT_ABGR8888: + sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; + break; + case SDL_PIXELFORMAT_RGB888: + sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB; + break; + case SDL_PIXELFORMAT_BGR888: + sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR; + break; #if SDL_HAVE_YUV - case SDL_PIXELFORMAT_IYUV: - case SDL_PIXELFORMAT_YV12: - sourceType = GLES2_IMAGESOURCE_TEXTURE_YUV; - break; - case SDL_PIXELFORMAT_NV12: - sourceType = GLES2_IMAGESOURCE_TEXTURE_NV12; - break; - case SDL_PIXELFORMAT_NV21: - sourceType = GLES2_IMAGESOURCE_TEXTURE_NV21; - break; + case SDL_PIXELFORMAT_IYUV: + case SDL_PIXELFORMAT_YV12: + sourceType = GLES2_IMAGESOURCE_TEXTURE_YUV; + break; + case SDL_PIXELFORMAT_NV12: + sourceType = GLES2_IMAGESOURCE_TEXTURE_NV12; + break; + case SDL_PIXELFORMAT_NV21: + sourceType = GLES2_IMAGESOURCE_TEXTURE_NV21; + break; #endif - case SDL_PIXELFORMAT_EXTERNAL_OES: - sourceType = GLES2_IMAGESOURCE_TEXTURE_EXTERNAL_OES; - break; - default: - return SDL_SetError("Unsupported texture format"); + case SDL_PIXELFORMAT_EXTERNAL_OES: + sourceType = GLES2_IMAGESOURCE_TEXTURE_EXTERNAL_OES; + break; + default: + return SDL_SetError("Unsupported texture format"); } } ret = SetDrawState(data, cmd, sourceType, vertices); if (texture != data->drawstate.texture) { - GLES2_TextureData *tdata = (GLES2_TextureData *) texture->driverdata; + GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; #if SDL_HAVE_YUV if (tdata->yuv) { data->glActiveTexture(GL_TEXTURE2); @@ -1161,10 +1146,9 @@ SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, void *vertice return ret; } -static int -GLES2_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) +static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) { - GLES2_RenderData *data = (GLES2_RenderData *) renderer->driverdata; + GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata; const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888)); #if USE_VERTEX_BUFFER_OBJECTS @@ -1181,7 +1165,7 @@ GLES2_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *ver int w, h; SDL_GL_GetDrawableSize(renderer->window, &w, &h); if ((w != data->drawstate.drawablew) || (h != data->drawstate.drawableh)) { - data->drawstate.viewport_dirty = SDL_TRUE; // if the window dimensions changed, invalidate the current viewport, etc. + data->drawstate.viewport_dirty = SDL_TRUE; // if the window dimensions changed, invalidate the current viewport, etc. data->drawstate.cliprect_dirty = SDL_TRUE; data->drawstate.drawablew = w; data->drawstate.drawableh = h; @@ -1203,149 +1187,155 @@ GLES2_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *ver if (data->current_vertex_buffer >= SDL_arraysize(data->vertex_buffers)) { data->current_vertex_buffer = 0; } - vertices = NULL; /* attrib pointers will be offsets into the VBO. */ + vertices = NULL; /* attrib pointers will be offsets into the VBO. */ #endif while (cmd) { switch (cmd->command) { - case SDL_RENDERCMD_SETDRAWCOLOR: { - break; + case SDL_RENDERCMD_SETDRAWCOLOR: + { + break; + } + + case SDL_RENDERCMD_SETVIEWPORT: + { + SDL_Rect *viewport = &data->drawstate.viewport; + if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { + SDL_copyp(viewport, &cmd->data.viewport.rect); + data->drawstate.viewport_dirty = SDL_TRUE; + } + break; + } + + case SDL_RENDERCMD_SETCLIPRECT: + { + const SDL_Rect *rect = &cmd->data.cliprect.rect; + if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) { + data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled; + data->drawstate.cliprect_enabled_dirty = SDL_TRUE; } - case SDL_RENDERCMD_SETVIEWPORT: { - SDL_Rect *viewport = &data->drawstate.viewport; - if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { - SDL_copyp(viewport, &cmd->data.viewport.rect); - data->drawstate.viewport_dirty = SDL_TRUE; - } - break; + if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) { + SDL_copyp(&data->drawstate.cliprect, rect); + data->drawstate.cliprect_dirty = SDL_TRUE; + } + break; + } + + case SDL_RENDERCMD_CLEAR: + { + const Uint8 r = colorswap ? cmd->data.color.b : cmd->data.color.r; + const Uint8 g = cmd->data.color.g; + const Uint8 b = colorswap ? cmd->data.color.r : cmd->data.color.b; + const Uint8 a = cmd->data.color.a; + const Uint32 color = (((Uint32)a << 24) | (r << 16) | (g << 8) | b); + if (color != data->drawstate.clear_color) { + const GLfloat fr = ((GLfloat)r) * inv255f; + const GLfloat fg = ((GLfloat)g) * inv255f; + const GLfloat fb = ((GLfloat)b) * inv255f; + const GLfloat fa = ((GLfloat)a) * inv255f; + data->glClearColor(fr, fg, fb, fa); + data->drawstate.clear_color = color; } - case SDL_RENDERCMD_SETCLIPRECT: { - const SDL_Rect *rect = &cmd->data.cliprect.rect; - if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) { - data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled; - data->drawstate.cliprect_enabled_dirty = SDL_TRUE; - } - - if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) { - SDL_copyp(&data->drawstate.cliprect, rect); - data->drawstate.cliprect_dirty = SDL_TRUE; - } - break; + if (data->drawstate.cliprect_enabled || data->drawstate.cliprect_enabled_dirty) { + data->glDisable(GL_SCISSOR_TEST); + data->drawstate.cliprect_enabled_dirty = data->drawstate.cliprect_enabled; } - case SDL_RENDERCMD_CLEAR: { - const Uint8 r = colorswap ? cmd->data.color.b : cmd->data.color.r; - const Uint8 g = cmd->data.color.g; - const Uint8 b = colorswap ? cmd->data.color.r : cmd->data.color.b; - const Uint8 a = cmd->data.color.a; - const Uint32 color = (((Uint32)a << 24) | (r << 16) | (g << 8) | b); - if (color != data->drawstate.clear_color) { - const GLfloat fr = ((GLfloat) r) * inv255f; - const GLfloat fg = ((GLfloat) g) * inv255f; - const GLfloat fb = ((GLfloat) b) * inv255f; - const GLfloat fa = ((GLfloat) a) * inv255f; - data->glClearColor(fr, fg, fb, fa); - data->drawstate.clear_color = color; - } + data->glClear(GL_COLOR_BUFFER_BIT); + break; + } - if (data->drawstate.cliprect_enabled || data->drawstate.cliprect_enabled_dirty) { - data->glDisable(GL_SCISSOR_TEST); - data->drawstate.cliprect_enabled_dirty = data->drawstate.cliprect_enabled; - } + case SDL_RENDERCMD_FILL_RECTS: /* unused */ + break; - data->glClear(GL_COLOR_BUFFER_BIT); - break; - } + case SDL_RENDERCMD_COPY: /* unused */ + break; - case SDL_RENDERCMD_FILL_RECTS: /* unused */ - break; + case SDL_RENDERCMD_COPY_EX: /* unused */ + break; - case SDL_RENDERCMD_COPY: /* unused */ - break; - - case SDL_RENDERCMD_COPY_EX: /* unused */ - break; - - case SDL_RENDERCMD_DRAW_LINES: { - if (SetDrawState(data, cmd, GLES2_IMAGESOURCE_SOLID, vertices) == 0) { - size_t count = cmd->data.draw.count; - if (count > 2) { - /* joined lines cannot be grouped */ - data->glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)count); - } else { - /* let's group non joined lines */ - SDL_RenderCommand *finalcmd = cmd; - SDL_RenderCommand *nextcmd = cmd->next; - SDL_BlendMode thisblend = cmd->data.draw.blend; - - while (nextcmd != NULL) { - const SDL_RenderCommandType nextcmdtype = nextcmd->command; - if (nextcmdtype != SDL_RENDERCMD_DRAW_LINES) { - break; /* can't go any further on this draw call, different render command up next. */ - } else if (nextcmd->data.draw.count != 2) { - break; /* can't go any further on this draw call, those are joined lines */ - } else if (nextcmd->data.draw.blend != thisblend) { - break; /* can't go any further on this draw call, different blendmode copy up next. */ - } else { - finalcmd = nextcmd; /* we can combine copy operations here. Mark this one as the furthest okay command. */ - count += nextcmd->data.draw.count; - } - nextcmd = nextcmd->next; - } - - data->glDrawArrays(GL_LINES, 0, (GLsizei)count); - cmd = finalcmd; /* skip any copy commands we just combined in here. */ - } - } - break; - } - - case SDL_RENDERCMD_DRAW_POINTS: - case SDL_RENDERCMD_GEOMETRY: { - /* as long as we have the same copy command in a row, with the - same texture, we can combine them all into a single draw call. */ - SDL_Texture *thistexture = cmd->data.draw.texture; - SDL_BlendMode thisblend = cmd->data.draw.blend; - const SDL_RenderCommandType thiscmdtype = cmd->command; - SDL_RenderCommand *finalcmd = cmd; - SDL_RenderCommand *nextcmd = cmd->next; + case SDL_RENDERCMD_DRAW_LINES: + { + if (SetDrawState(data, cmd, GLES2_IMAGESOURCE_SOLID, vertices) == 0) { size_t count = cmd->data.draw.count; - int ret; - while (nextcmd != NULL) { - const SDL_RenderCommandType nextcmdtype = nextcmd->command; - if (nextcmdtype != thiscmdtype) { - break; /* can't go any further on this draw call, different render command up next. */ - } else if (nextcmd->data.draw.texture != thistexture || nextcmd->data.draw.blend != thisblend) { - break; /* can't go any further on this draw call, different texture/blendmode copy up next. */ - } else { - finalcmd = nextcmd; /* we can combine copy operations here. Mark this one as the furthest okay command. */ - count += nextcmd->data.draw.count; - } - nextcmd = nextcmd->next; - } - - if (thistexture) { - ret = SetCopyState(renderer, cmd, vertices); + if (count > 2) { + /* joined lines cannot be grouped */ + data->glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)count); } else { - ret = SetDrawState(data, cmd, GLES2_IMAGESOURCE_SOLID, vertices); - } + /* let's group non joined lines */ + SDL_RenderCommand *finalcmd = cmd; + SDL_RenderCommand *nextcmd = cmd->next; + SDL_BlendMode thisblend = cmd->data.draw.blend; - if (ret == 0) { - int op = GL_TRIANGLES; /* SDL_RENDERCMD_GEOMETRY */ - if (thiscmdtype == SDL_RENDERCMD_DRAW_POINTS) { - op = GL_POINTS; + while (nextcmd != NULL) { + const SDL_RenderCommandType nextcmdtype = nextcmd->command; + if (nextcmdtype != SDL_RENDERCMD_DRAW_LINES) { + break; /* can't go any further on this draw call, different render command up next. */ + } else if (nextcmd->data.draw.count != 2) { + break; /* can't go any further on this draw call, those are joined lines */ + } else if (nextcmd->data.draw.blend != thisblend) { + break; /* can't go any further on this draw call, different blendmode copy up next. */ + } else { + finalcmd = nextcmd; /* we can combine copy operations here. Mark this one as the furthest okay command. */ + count += nextcmd->data.draw.count; + } + nextcmd = nextcmd->next; } - data->glDrawArrays(op, 0, (GLsizei) count); - } - cmd = finalcmd; /* skip any copy commands we just combined in here. */ - break; + data->glDrawArrays(GL_LINES, 0, (GLsizei)count); + cmd = finalcmd; /* skip any copy commands we just combined in here. */ + } + } + break; + } + + case SDL_RENDERCMD_DRAW_POINTS: + case SDL_RENDERCMD_GEOMETRY: + { + /* as long as we have the same copy command in a row, with the + same texture, we can combine them all into a single draw call. */ + SDL_Texture *thistexture = cmd->data.draw.texture; + SDL_BlendMode thisblend = cmd->data.draw.blend; + const SDL_RenderCommandType thiscmdtype = cmd->command; + SDL_RenderCommand *finalcmd = cmd; + SDL_RenderCommand *nextcmd = cmd->next; + size_t count = cmd->data.draw.count; + int ret; + while (nextcmd != NULL) { + const SDL_RenderCommandType nextcmdtype = nextcmd->command; + if (nextcmdtype != thiscmdtype) { + break; /* can't go any further on this draw call, different render command up next. */ + } else if (nextcmd->data.draw.texture != thistexture || nextcmd->data.draw.blend != thisblend) { + break; /* can't go any further on this draw call, different texture/blendmode copy up next. */ + } else { + finalcmd = nextcmd; /* we can combine copy operations here. Mark this one as the furthest okay command. */ + count += nextcmd->data.draw.count; + } + nextcmd = nextcmd->next; } - case SDL_RENDERCMD_NO_OP: - break; + if (thistexture) { + ret = SetCopyState(renderer, cmd, vertices); + } else { + ret = SetDrawState(data, cmd, GLES2_IMAGESOURCE_SOLID, vertices); + } + + if (ret == 0) { + int op = GL_TRIANGLES; /* SDL_RENDERCMD_GEOMETRY */ + if (thiscmdtype == SDL_RENDERCMD_DRAW_POINTS) { + op = GL_POINTS; + } + data->glDrawArrays(op, 0, (GLsizei)count); + } + + cmd = finalcmd; /* skip any copy commands we just combined in here. */ + break; + } + + case SDL_RENDERCMD_NO_OP: + break; } cmd = cmd->next; @@ -1354,8 +1344,7 @@ GLES2_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *ver return GL_CheckError("", renderer); } -static void -GLES2_DestroyRenderer(SDL_Renderer *renderer) +static void GLES2_DestroyRenderer(SDL_Renderer *renderer) { GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata; @@ -1406,8 +1395,7 @@ GLES2_DestroyRenderer(SDL_Renderer *renderer) SDL_free(renderer); } -static int -GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) +static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) { GLES2_RenderData *renderdata = (GLES2_RenderData *)renderer->driverdata; GLES2_TextureData *data; @@ -1417,11 +1405,10 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) GLES2_ActivateRenderer(renderer); - renderdata->drawstate.texture = NULL; /* we trash this state. */ + renderdata->drawstate.texture = NULL; /* we trash this state. */ /* Determine the corresponding GLES texture format params */ - switch (texture->format) - { + switch (texture->format) { case SDL_PIXELFORMAT_ARGB8888: case SDL_PIXELFORMAT_ABGR8888: case SDL_PIXELFORMAT_RGB888: @@ -1563,16 +1550,15 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) } if (texture->access == SDL_TEXTUREACCESS_TARGET) { - data->fbo = GLES2_GetFBO(renderer->driverdata, texture->w, texture->h); + data->fbo = GLES2_GetFBO(renderer->driverdata, texture->w, texture->h); } else { - data->fbo = NULL; + data->fbo = NULL; } return GL_CheckError("", renderer); } -static int -GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels, GLint pitch, GLint bpp) +static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels, GLint pitch, GLint bpp) { Uint8 *blob = NULL; #if SDL_BYTEORDER == SDL_BIG_ENDIAN @@ -1583,7 +1569,7 @@ GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoffset, GLint int y; if ((width == 0) || (height == 0) || (bpp == 0)) { - return 0; /* nothing to do */ + return 0; /* nothing to do */ } /* Reformat the texture data into a tightly packed array */ @@ -1617,7 +1603,7 @@ GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoffset, GLint for (i = 0; i < (src_pitch * height) / 4; i++) { blob2[i] = SDL_Swap32(src32[i]); } - src = (Uint8 *) blob2; + src = (Uint8 *)blob2; } #endif @@ -1633,9 +1619,8 @@ GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoffset, GLint return 0; } -static int -GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, - const void *pixels, int pitch) +static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, + const void *pixels, int pitch) { GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata; GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; @@ -1647,65 +1632,64 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect return 0; } - data->drawstate.texture = NULL; /* we trash this state. */ + data->drawstate.texture = NULL; /* we trash this state. */ /* Create a texture subimage with the supplied data */ data->glBindTexture(tdata->texture_type, tdata->texture); GLES2_TexSubImage2D(data, tdata->texture_type, - rect->x, - rect->y, - rect->w, - rect->h, - tdata->pixel_format, - tdata->pixel_type, - pixels, pitch, SDL_BYTESPERPIXEL(texture->format)); + rect->x, + rect->y, + rect->w, + rect->h, + tdata->pixel_format, + tdata->pixel_type, + pixels, pitch, SDL_BYTESPERPIXEL(texture->format)); #if SDL_HAVE_YUV if (tdata->yuv) { /* Skip to the correct offset into the next texture */ - pixels = (const void*)((const Uint8*)pixels + rect->h * pitch); + pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch); if (texture->format == SDL_PIXELFORMAT_YV12) { data->glBindTexture(tdata->texture_type, tdata->texture_v); } else { data->glBindTexture(tdata->texture_type, tdata->texture_u); } GLES2_TexSubImage2D(data, tdata->texture_type, - rect->x / 2, - rect->y / 2, - (rect->w + 1) / 2, - (rect->h + 1) / 2, - tdata->pixel_format, - tdata->pixel_type, - pixels, (pitch + 1) / 2, 1); - + rect->x / 2, + rect->y / 2, + (rect->w + 1) / 2, + (rect->h + 1) / 2, + tdata->pixel_format, + tdata->pixel_type, + pixels, (pitch + 1) / 2, 1); /* Skip to the correct offset into the next texture */ - pixels = (const void*)((const Uint8*)pixels + ((rect->h + 1) / 2) * ((pitch + 1)/2)); + pixels = (const void *)((const Uint8 *)pixels + ((rect->h + 1) / 2) * ((pitch + 1) / 2)); if (texture->format == SDL_PIXELFORMAT_YV12) { data->glBindTexture(tdata->texture_type, tdata->texture_u); } else { data->glBindTexture(tdata->texture_type, tdata->texture_v); } GLES2_TexSubImage2D(data, tdata->texture_type, - rect->x / 2, - rect->y / 2, - (rect->w + 1) / 2, - (rect->h + 1) / 2, - tdata->pixel_format, - tdata->pixel_type, - pixels, (pitch + 1) / 2, 1); + rect->x / 2, + rect->y / 2, + (rect->w + 1) / 2, + (rect->h + 1) / 2, + tdata->pixel_format, + tdata->pixel_type, + pixels, (pitch + 1) / 2, 1); } else if (tdata->nv12) { /* Skip to the correct offset into the next texture */ - pixels = (const void*)((const Uint8*)pixels + rect->h * pitch); + pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch); data->glBindTexture(tdata->texture_type, tdata->texture_u); GLES2_TexSubImage2D(data, tdata->texture_type, - rect->x / 2, - rect->y / 2, - (rect->w + 1) / 2, - (rect->h + 1) / 2, - GL_LUMINANCE_ALPHA, - GL_UNSIGNED_BYTE, - pixels, 2 * ((pitch + 1) / 2), 2); + rect->x / 2, + rect->y / 2, + (rect->w + 1) / 2, + (rect->h + 1) / 2, + GL_LUMINANCE_ALPHA, + GL_UNSIGNED_BYTE, + pixels, 2 * ((pitch + 1) / 2), 2); } #endif @@ -1713,12 +1697,11 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect } #if SDL_HAVE_YUV -static int -GLES2_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *Uplane, int Upitch, - const Uint8 *Vplane, int Vpitch) +static int GLES2_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) { GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata; GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; @@ -1730,46 +1713,45 @@ GLES2_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, return 0; } - data->drawstate.texture = NULL; /* we trash this state. */ + data->drawstate.texture = NULL; /* we trash this state. */ data->glBindTexture(tdata->texture_type, tdata->texture_v); GLES2_TexSubImage2D(data, tdata->texture_type, - rect->x / 2, - rect->y / 2, - (rect->w + 1) / 2, - (rect->h + 1) / 2, - tdata->pixel_format, - tdata->pixel_type, - Vplane, Vpitch, 1); + rect->x / 2, + rect->y / 2, + (rect->w + 1) / 2, + (rect->h + 1) / 2, + tdata->pixel_format, + tdata->pixel_type, + Vplane, Vpitch, 1); data->glBindTexture(tdata->texture_type, tdata->texture_u); GLES2_TexSubImage2D(data, tdata->texture_type, - rect->x / 2, - rect->y / 2, - (rect->w + 1) / 2, - (rect->h + 1) / 2, - tdata->pixel_format, - tdata->pixel_type, - Uplane, Upitch, 1); + rect->x / 2, + rect->y / 2, + (rect->w + 1) / 2, + (rect->h + 1) / 2, + tdata->pixel_format, + tdata->pixel_type, + Uplane, Upitch, 1); data->glBindTexture(tdata->texture_type, tdata->texture); GLES2_TexSubImage2D(data, tdata->texture_type, - rect->x, - rect->y, - rect->w, - rect->h, - tdata->pixel_format, - tdata->pixel_type, - Yplane, Ypitch, 1); + rect->x, + rect->y, + rect->w, + rect->h, + tdata->pixel_format, + tdata->pixel_type, + Yplane, Ypitch, 1); return GL_CheckError("glTexSubImage2D()", renderer); } -static int -GLES2_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *UVplane, int UVpitch) +static int GLES2_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch) { GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata; GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; @@ -1781,35 +1763,34 @@ GLES2_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, return 0; } - data->drawstate.texture = NULL; /* we trash this state. */ + data->drawstate.texture = NULL; /* we trash this state. */ data->glBindTexture(tdata->texture_type, tdata->texture_u); GLES2_TexSubImage2D(data, tdata->texture_type, - rect->x / 2, - rect->y / 2, - (rect->w + 1) / 2, - (rect->h + 1) / 2, - GL_LUMINANCE_ALPHA, - GL_UNSIGNED_BYTE, - UVplane, UVpitch, 2); + rect->x / 2, + rect->y / 2, + (rect->w + 1) / 2, + (rect->h + 1) / 2, + GL_LUMINANCE_ALPHA, + GL_UNSIGNED_BYTE, + UVplane, UVpitch, 2); data->glBindTexture(tdata->texture_type, tdata->texture); GLES2_TexSubImage2D(data, tdata->texture_type, - rect->x, - rect->y, - rect->w, - rect->h, - tdata->pixel_format, - tdata->pixel_type, - Yplane, Ypitch, 1); + rect->x, + rect->y, + rect->w, + rect->h, + tdata->pixel_format, + tdata->pixel_type, + Yplane, Ypitch, 1); return GL_CheckError("glTexSubImage2D()", renderer); } #endif -static int -GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, - void **pixels, int *pitch) +static int GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, + void **pixels, int *pitch) { GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; @@ -1822,8 +1803,7 @@ GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect * return 0; } -static void -GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) +static void GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) { GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; SDL_Rect rect; @@ -1836,11 +1816,10 @@ GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) GLES2_UpdateTexture(renderer, texture, &rect, tdata->pixel_data, tdata->pitch); } -static void -GLES2_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode) +static void GLES2_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode) { - GLES2_RenderData *renderdata = (GLES2_RenderData *) renderer->driverdata; - GLES2_TextureData *data = (GLES2_TextureData *) texture->driverdata; + GLES2_RenderData *renderdata = (GLES2_RenderData *)renderer->driverdata; + GLES2_TextureData *data = (GLES2_TextureData *)texture->driverdata; GLenum glScaleMode = (scaleMode == SDL_ScaleModeNearest) ? GL_NEAREST : GL_LINEAR; #if SDL_HAVE_YUV @@ -1868,10 +1847,9 @@ GLES2_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Sc renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, glScaleMode); } -static int -GLES2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +static int GLES2_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) { - GLES2_RenderData *data = (GLES2_RenderData *) renderer->driverdata; + GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata; GLES2_TextureData *texturedata = NULL; GLenum status; @@ -1880,7 +1858,7 @@ GLES2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) if (texture == NULL) { data->glBindFramebuffer(GL_FRAMEBUFFER, data->window_framebuffer); } else { - texturedata = (GLES2_TextureData *) texture->driverdata; + texturedata = (GLES2_TextureData *)texture->driverdata; data->glBindFramebuffer(GL_FRAMEBUFFER, texturedata->fbo->FBO); /* TODO: check if texture pixel format allows this operation */ data->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texturedata->texture_type, texturedata->texture, 0); @@ -1893,8 +1871,7 @@ GLES2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) return 0; } -static void -GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) +static void GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) { GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata; GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; @@ -1925,9 +1902,8 @@ GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) } } -static int -GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 pixel_format, void * pixels, int pitch) +static int GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, + Uint32 pixel_format, void *pixels, int pitch) { GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata; Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ABGR8888; @@ -1941,7 +1917,7 @@ GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format); buflen = rect->h * temp_pitch; if (buflen == 0) { - return 0; /* nothing to do. */ + return 0; /* nothing to do. */ } temp_pixels = SDL_malloc(buflen); @@ -1951,7 +1927,7 @@ GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, SDL_GetRendererOutputSize(renderer, &w, &h); - data->glReadPixels(rect->x, renderer->target ? rect->y : (h-rect->y)-rect->h, + data->glReadPixels(rect->x, renderer->target ? rect->y : (h - rect->y) - rect->h, rect->w, rect->h, GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels); if (GL_CheckError("glReadPixels()", renderer) < 0) { return -1; @@ -1961,8 +1937,8 @@ GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, if (!renderer->target) { SDL_bool isstack; length = rect->w * SDL_BYTESPERPIXEL(temp_format); - src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch; - dst = (Uint8*)temp_pixels; + src = (Uint8 *)temp_pixels + (rect->h - 1) * temp_pitch; + dst = (Uint8 *)temp_pixels; tmp = SDL_small_alloc(Uint8, length, &isstack); rows = rect->h / 2; while (rows--) { @@ -1983,15 +1959,13 @@ GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, return status; } -static int -GLES2_RenderPresent(SDL_Renderer *renderer) +static int GLES2_RenderPresent(SDL_Renderer *renderer) { /* Tell the video driver to swap buffers */ return SDL_GL_SwapWindowWithResult(renderer->window); } -static int -GLES2_SetVSync(SDL_Renderer * renderer, const int vsync) +static int GLES2_SetVSync(SDL_Renderer *renderer, const int vsync) { int retval; if (vsync) { @@ -2010,14 +1984,13 @@ GLES2_SetVSync(SDL_Renderer * renderer, const int vsync) return retval; } - /************************************************************************************************* * Bind/unbinding of textures *************************************************************************************************/ -static int GLES2_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh); -static int GLES2_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture); +static int GLES2_BindTexture(SDL_Renderer *renderer, SDL_Texture *texture, float *texw, float *texh); +static int GLES2_UnbindTexture(SDL_Renderer *renderer, SDL_Texture *texture); -static int GLES2_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh) +static int GLES2_BindTexture(SDL_Renderer *renderer, SDL_Texture *texture, float *texw, float *texh) { GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata; GLES2_TextureData *texturedata = (GLES2_TextureData *)texture->driverdata; @@ -2053,7 +2026,7 @@ static int GLES2_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, flo return 0; } -static int GLES2_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) +static int GLES2_UnbindTexture(SDL_Renderer *renderer, SDL_Texture *texture) { GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata; GLES2_TextureData *texturedata = (GLES2_TextureData *)texture->driverdata; @@ -2065,13 +2038,11 @@ static int GLES2_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) return 0; } - /************************************************************************************************* * Renderer instantiation * *************************************************************************************************/ -static SDL_Renderer * -GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) +static SDL_Renderer *GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) { SDL_Renderer *renderer; GLES2_RenderData *data; @@ -2193,32 +2164,32 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) data->window_framebuffer = (GLuint)window_framebuffer; /* Populate the function pointers for the module */ - renderer->WindowEvent = GLES2_WindowEvent; - renderer->GetOutputSize = GLES2_GetOutputSize; - renderer->SupportsBlendMode = GLES2_SupportsBlendMode; - renderer->CreateTexture = GLES2_CreateTexture; - renderer->UpdateTexture = GLES2_UpdateTexture; + renderer->WindowEvent = GLES2_WindowEvent; + renderer->GetOutputSize = GLES2_GetOutputSize; + renderer->SupportsBlendMode = GLES2_SupportsBlendMode; + renderer->CreateTexture = GLES2_CreateTexture; + renderer->UpdateTexture = GLES2_UpdateTexture; #if SDL_HAVE_YUV - renderer->UpdateTextureYUV = GLES2_UpdateTextureYUV; - renderer->UpdateTextureNV = GLES2_UpdateTextureNV; + renderer->UpdateTextureYUV = GLES2_UpdateTextureYUV; + renderer->UpdateTextureNV = GLES2_UpdateTextureNV; #endif - renderer->LockTexture = GLES2_LockTexture; - renderer->UnlockTexture = GLES2_UnlockTexture; + renderer->LockTexture = GLES2_LockTexture; + renderer->UnlockTexture = GLES2_UnlockTexture; renderer->SetTextureScaleMode = GLES2_SetTextureScaleMode; - renderer->SetRenderTarget = GLES2_SetRenderTarget; - renderer->QueueSetViewport = GLES2_QueueSetViewport; - renderer->QueueSetDrawColor = GLES2_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */ - renderer->QueueDrawPoints = GLES2_QueueDrawPoints; - renderer->QueueDrawLines = GLES2_QueueDrawLines; - renderer->QueueGeometry = GLES2_QueueGeometry; - renderer->RunCommandQueue = GLES2_RunCommandQueue; - renderer->RenderReadPixels = GLES2_RenderReadPixels; - renderer->RenderPresent = GLES2_RenderPresent; - renderer->DestroyTexture = GLES2_DestroyTexture; - renderer->DestroyRenderer = GLES2_DestroyRenderer; - renderer->SetVSync = GLES2_SetVSync; - renderer->GL_BindTexture = GLES2_BindTexture; - renderer->GL_UnbindTexture = GLES2_UnbindTexture; + renderer->SetRenderTarget = GLES2_SetRenderTarget; + renderer->QueueSetViewport = GLES2_QueueSetViewport; + renderer->QueueSetDrawColor = GLES2_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */ + renderer->QueueDrawPoints = GLES2_QueueDrawPoints; + renderer->QueueDrawLines = GLES2_QueueDrawLines; + renderer->QueueGeometry = GLES2_QueueGeometry; + renderer->RunCommandQueue = GLES2_RunCommandQueue; + renderer->RenderReadPixels = GLES2_RenderReadPixels; + renderer->RenderPresent = GLES2_RenderPresent; + renderer->DestroyTexture = GLES2_DestroyTexture; + renderer->DestroyRenderer = GLES2_DestroyRenderer; + renderer->SetVSync = GLES2_SetVSync; + renderer->GL_BindTexture = GLES2_BindTexture; + renderer->GL_UnbindTexture = GLES2_UnbindTexture; #if SDL_HAVE_YUV renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12; renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV; @@ -2271,22 +2242,17 @@ error: SDL_RenderDriver GLES2_RenderDriver = { GLES2_CreateRenderer, - { - "opengles2", - (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE), - 4, - { - SDL_PIXELFORMAT_ARGB8888, + { "opengles2", + (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE), + 4, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, - SDL_PIXELFORMAT_BGR888 - }, - 0, - 0 - } + SDL_PIXELFORMAT_BGR888 }, + 0, + 0 } }; #endif /* SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/render/opengles2/SDL_shaders_gles2.c b/src/render/opengles2/SDL_shaders_gles2.c index e59b73389..f9dbbf001 100644 --- a/src/render/opengles2/SDL_shaders_gles2.c +++ b/src/render/opengles2/SDL_shaders_gles2.c @@ -28,6 +28,8 @@ #include "SDL_shaders_gles2.h" #include "SDL_stdinc.h" +/* *INDENT-OFF* */ /* clang-format off */ + /************************************************************************************************* * Vertex/fragment shader source * *************************************************************************************************/ @@ -346,6 +348,7 @@ static const char GLES2_Fragment_TextureExternalOES[] = \ "}\n" \ ; +/* *INDENT-ON* */ /* clang-format on */ /************************************************************************************************* * Shader selector * @@ -444,4 +447,3 @@ const char *GLES2_GetShader(GLES2_ShaderType type) #endif /* SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/render/ps2/SDL_render_ps2.c b/src/render/ps2/SDL_render_ps2.c index 6070523f4..75924da66 100644 --- a/src/render/ps2/SDL_render_ps2.c +++ b/src/render/ps2/SDL_render_ps2.c @@ -51,43 +51,40 @@ typedef struct uint8_t vsync; /* 0 (Disabled), 1 (Enabled), 2 (Dynamic) */ } PS2_RenderData; - static int vsync_sema_id = 0; /* PRIVATE METHODS */ static int vsync_handler() { - iSignalSema(vsync_sema_id); + iSignalSema(vsync_sema_id); - ExitHandler(); - return 0; + ExitHandler(); + return 0; } /* Copy of gsKit_sync_flip, but without the 'flip' */ static void gsKit_sync(GSGLOBAL *gsGlobal) { - if (!gsGlobal->FirstFrame) { - WaitSema(vsync_sema_id); - } - while (PollSema(vsync_sema_id) >= 0) - ; + if (!gsGlobal->FirstFrame) { + WaitSema(vsync_sema_id); + } + while (PollSema(vsync_sema_id) >= 0) + ; } /* Copy of gsKit_sync_flip, but without the 'sync' */ static void gsKit_flip(GSGLOBAL *gsGlobal) { - if (!gsGlobal->FirstFrame) { - if (gsGlobal->DoubleBuffering == GS_SETTING_ON) { - GS_SET_DISPFB2( gsGlobal->ScreenBuffer[ - gsGlobal->ActiveBuffer & 1] / 8192, - gsGlobal->Width / 64, gsGlobal->PSM, 0, 0 ); + if (!gsGlobal->FirstFrame) { + if (gsGlobal->DoubleBuffering == GS_SETTING_ON) { + GS_SET_DISPFB2(gsGlobal->ScreenBuffer[gsGlobal->ActiveBuffer & 1] / 8192, + gsGlobal->Width / 64, gsGlobal->PSM, 0, 0); - gsGlobal->ActiveBuffer ^= 1; - } + gsGlobal->ActiveBuffer ^= 1; + } + } - } - - gsKit_setactive(gsGlobal); + gsKit_setactive(gsGlobal); } static int PixelFormatToPS2PSM(Uint32 format) @@ -100,16 +97,13 @@ static int PixelFormatToPS2PSM(Uint32 format) } } -static void -PS2_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +static void PS2_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event) { - } -static int -PS2_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static int PS2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - GSTEXTURE* ps2_tex = (GSTEXTURE*) SDL_calloc(1, sizeof(GSTEXTURE)); + GSTEXTURE *ps2_tex = (GSTEXTURE *)SDL_calloc(1, sizeof(GSTEXTURE)); if (ps2_tex == NULL) { return SDL_OutOfMemory(); @@ -130,41 +124,38 @@ PS2_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) return 0; } -static int -PS2_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, void **pixels, int *pitch) +static int PS2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, void **pixels, int *pitch) { - GSTEXTURE *ps2_texture = (GSTEXTURE *) texture->driverdata; + GSTEXTURE *ps2_texture = (GSTEXTURE *)texture->driverdata; *pixels = - (void *) ((Uint8 *) ps2_texture->Mem + rect->y * ps2_texture->Width * SDL_BYTESPERPIXEL(texture->format) + - rect->x * SDL_BYTESPERPIXEL(texture->format)); + (void *)((Uint8 *)ps2_texture->Mem + rect->y * ps2_texture->Width * SDL_BYTESPERPIXEL(texture->format) + + rect->x * SDL_BYTESPERPIXEL(texture->format)); *pitch = ps2_texture->Width * SDL_BYTESPERPIXEL(texture->format); return 0; } -static void -PS2_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static void PS2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - GSTEXTURE *ps2_texture = (GSTEXTURE *) texture->driverdata; - PS2_RenderData *data = (PS2_RenderData *) renderer->driverdata; + GSTEXTURE *ps2_texture = (GSTEXTURE *)texture->driverdata; + PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; gsKit_TexManager_invalidate(data->gsGlobal, ps2_texture); } -static int -PS2_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, int pitch) +static int PS2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, const void *pixels, int pitch) { const Uint8 *src; Uint8 *dst; - int row, length,dpitch; + int row, length, dpitch; src = pixels; PS2_LockTexture(renderer, texture, rect, (void **)&dst, &dpitch); length = rect->w * SDL_BYTESPERPIXEL(texture->format); if (length == pitch && length == dpitch) { - SDL_memcpy(dst, src, length*rect->h); + SDL_memcpy(dst, src, length * rect->h); } else { for (row = 0; row < rect->h; ++row) { SDL_memcpy(dst, src, length); @@ -178,10 +169,9 @@ PS2_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, return 0; } -static void -PS2_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode) +static void PS2_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode) { - GSTEXTURE *ps2_texture = (GSTEXTURE *) texture->driverdata; + GSTEXTURE *ps2_texture = (GSTEXTURE *)texture->driverdata; /* set texture filtering according to scaleMode suported hint values are nearest (0, default) or linear (1) @@ -189,28 +179,25 @@ PS2_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Scal or GS_FILTER_LINEAR (good for scaling) */ uint32_t gsKitScaleMode = (scaleMode == SDL_ScaleModeNearest - ? GS_FILTER_NEAREST - : GS_FILTER_LINEAR); + ? GS_FILTER_NEAREST + : GS_FILTER_LINEAR); ps2_texture->Filter = gsKitScaleMode; } -static int -PS2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +static int PS2_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) { return 0; } -static int -PS2_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd) +static int PS2_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { - return 0; /* nothing to do in this backend. */ + return 0; /* nothing to do in this backend. */ } -static int -PS2_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) +static int PS2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { - PS2_RenderData *data = (PS2_RenderData *) renderer->driverdata; - GSPRIMPOINT *vertices = (GSPRIMPOINT *) SDL_AllocateRenderVertices(renderer, count * sizeof (GSPRIMPOINT), 4, &cmd->data.draw.first); + PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; + GSPRIMPOINT *vertices = (GSPRIMPOINT *)SDL_AllocateRenderVertices(renderer, count * sizeof(GSPRIMPOINT), 4, &cmd->data.draw.first); uint8_t colorR, colorG, colorB, colorA; gs_rgbaq rgbaq; int i; @@ -234,11 +221,10 @@ PS2_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F return 0; } -static int -PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, - const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, - int num_vertices, const void *indices, int num_indices, int size_indices, - float scale_x, float scale_y) +static int PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, + int num_vertices, const void *indices, int num_indices, int size_indices, + float scale_x, float scale_y) { int i; int count = indices ? num_indices : num_vertices; @@ -248,8 +234,8 @@ PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t size_indices = indices ? size_indices : 0; if (texture) { - GSPRIMSTQPOINT *vertices = (GSPRIMSTQPOINT *) SDL_AllocateRenderVertices(renderer, count * sizeof (GSPRIMSTQPOINT), 4, &cmd->data.draw.first); - + GSPRIMSTQPOINT *vertices = (GSPRIMSTQPOINT *)SDL_AllocateRenderVertices(renderer, count * sizeof(GSPRIMSTQPOINT), 4, &cmd->data.draw.first); + if (vertices == NULL) { return -1; } @@ -269,9 +255,9 @@ PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t j = i; } - xy_ = (float *)((char*)xy + j * xy_stride); - col_ = *(SDL_Color *)((char*)color + j * color_stride); - uv_ = (float *)((char*)uv + j * uv_stride); + xy_ = (float *)((char *)xy + j * xy_stride); + col_ = *(SDL_Color *)((char *)color + j * color_stride); + uv_ = (float *)((char *)uv + j * uv_stride); vertices->xyz2 = vertex_to_XYZ2(data->gsGlobal, xy_[0] * scale_x, xy_[1] * scale_y, 0); vertices->stq = vertex_to_STQ(uv_[0], uv_[1]); @@ -279,9 +265,9 @@ PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t vertices++; } - + } else { - GSPRIMPOINT *vertices = (GSPRIMPOINT *) SDL_AllocateRenderVertices(renderer, count * sizeof (GSPRIMPOINT), 4, &cmd->data.draw.first); + GSPRIMPOINT *vertices = (GSPRIMPOINT *)SDL_AllocateRenderVertices(renderer, count * sizeof(GSPRIMPOINT), 4, &cmd->data.draw.first); if (vertices == NULL) { return -1; @@ -301,8 +287,8 @@ PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t j = i; } - xy_ = (float *)((char*)xy + j * xy_stride); - col_ = *(SDL_Color *)((char*)color + j * color_stride); + xy_ = (float *)((char *)xy + j * xy_stride); + col_ = *(SDL_Color *)((char *)color + j * color_stride); vertices->xyz2 = vertex_to_XYZ2(data->gsGlobal, xy_[0] * scale_x, xy_[1] * scale_y, 0); vertices->rgbaq = color_to_RGBAQ(col_.r >> 1, col_.g >> 1, col_.b >> 1, col_.a >> 1, 0.0f); @@ -314,8 +300,7 @@ PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t return 0; } -static int -PS2_RenderSetViewPort(SDL_Renderer *renderer, SDL_RenderCommand *cmd) +static int PS2_RenderSetViewPort(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; const SDL_Rect *viewport = &cmd->data.viewport.rect; @@ -326,8 +311,7 @@ PS2_RenderSetViewPort(SDL_Renderer *renderer, SDL_RenderCommand *cmd) return 0; } -static int -PS2_RenderSetClipRect(SDL_Renderer *renderer, SDL_RenderCommand *cmd) +static int PS2_RenderSetClipRect(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; @@ -342,14 +326,12 @@ PS2_RenderSetClipRect(SDL_Renderer *renderer, SDL_RenderCommand *cmd) return 0; } - -static int -PS2_RenderSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd) +static int PS2_RenderSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { int colorR, colorG, colorB, colorA; PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; - + colorR = (cmd->data.color.r) >> 1; colorG = (cmd->data.color.g) >> 1; colorB = (cmd->data.color.b) >> 1; @@ -358,60 +340,60 @@ PS2_RenderSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd) return 0; } -static int -PS2_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd) +static int PS2_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { int colorR, colorG, colorB, colorA; PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; - + colorR = (cmd->data.color.r) >> 1; colorG = (cmd->data.color.g) >> 1; colorB = (cmd->data.color.b) >> 1; colorA = (cmd->data.color.a) >> 1; gsKit_clear(data->gsGlobal, GS_SETREG_RGBAQ(colorR, colorG, colorB, colorA, 0x00)); - + return 0; } -static void -PS2_SetBlendMode(PS2_RenderData *data, int blendMode) +static void PS2_SetBlendMode(PS2_RenderData *data, int blendMode) { - #define A_COLOR_SOURCE 0 - #define A_COLOR_DEST 1 - #define A_COLOR_NULL 2 - #define A_ALPHA_SOURCE 0 - #define A_ALPHA_DEST 1 - #define A_ALPHA_FIX 2 +#define A_COLOR_SOURCE 0 +#define A_COLOR_DEST 1 +#define A_COLOR_NULL 2 +#define A_ALPHA_SOURCE 0 +#define A_ALPHA_DEST 1 +#define A_ALPHA_FIX 2 - switch (blendMode) + switch (blendMode) { + case SDL_BLENDMODE_NONE: { - case SDL_BLENDMODE_NONE: { - data->gsGlobal->PrimAlphaEnable = GS_SETTING_OFF; - break; - } - case SDL_BLENDMODE_BLEND:{ - gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_SOURCE, A_COLOR_DEST, A_ALPHA_SOURCE, A_COLOR_DEST, 0), 0); - data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON; - break; - } - case SDL_BLENDMODE_ADD: { - gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_SOURCE, A_COLOR_NULL, A_ALPHA_FIX, A_COLOR_DEST, 0x80), 0); - data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON; - break; - } - case SDL_BLENDMODE_MUL: - case SDL_BLENDMODE_MOD: { - /* We don't fully support MOD and MUL, however this is the best we can do */ - gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_DEST, A_COLOR_NULL, A_ALPHA_SOURCE, A_COLOR_SOURCE, 0x80), 0); - data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON; - break; - } + data->gsGlobal->PrimAlphaEnable = GS_SETTING_OFF; + break; + } + case SDL_BLENDMODE_BLEND: + { + gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_SOURCE, A_COLOR_DEST, A_ALPHA_SOURCE, A_COLOR_DEST, 0), 0); + data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON; + break; + } + case SDL_BLENDMODE_ADD: + { + gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_SOURCE, A_COLOR_NULL, A_ALPHA_FIX, A_COLOR_DEST, 0x80), 0); + data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON; + break; + } + case SDL_BLENDMODE_MUL: + case SDL_BLENDMODE_MOD: + { + /* We don't fully support MOD and MUL, however this is the best we can do */ + gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_DEST, A_COLOR_NULL, A_ALPHA_SOURCE, A_COLOR_SOURCE, 0x80), 0); + data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON; + break; + } } } -static int -PS2_RenderGeometry(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cmd) +static int PS2_RenderGeometry(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cmd) { PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; const size_t count = cmd->data.draw.count; @@ -419,26 +401,24 @@ PS2_RenderGeometry(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cm PS2_SetBlendMode(data, cmd->data.draw.blend); if (cmd->data.draw.texture) { - const GSPRIMSTQPOINT *verts = (GSPRIMSTQPOINT *) (vertices + cmd->data.draw.first); - GSTEXTURE *ps2_tex = (GSTEXTURE *) cmd->data.draw.texture->driverdata; + const GSPRIMSTQPOINT *verts = (GSPRIMSTQPOINT *)(vertices + cmd->data.draw.first); + GSTEXTURE *ps2_tex = (GSTEXTURE *)cmd->data.draw.texture->driverdata; gsKit_TexManager_bind(data->gsGlobal, ps2_tex); gsKit_prim_list_triangle_goraud_texture_stq_3d(data->gsGlobal, ps2_tex, count, verts); } else { - const GSPRIMPOINT *verts = (GSPRIMPOINT *) (vertices + cmd->data.draw.first); + const GSPRIMPOINT *verts = (GSPRIMPOINT *)(vertices + cmd->data.draw.first); gsKit_prim_list_triangle_gouraud_3d(data->gsGlobal, count, verts); - } - + } + return 0; } - -int -PS2_RenderLines(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand * cmd) +int PS2_RenderLines(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cmd) { PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; const size_t count = cmd->data.draw.count; - const GSPRIMPOINT *verts = (GSPRIMPOINT *) (vertices + cmd->data.draw.first); + const GSPRIMPOINT *verts = (GSPRIMPOINT *)(vertices + cmd->data.draw.first); PS2_SetBlendMode(data, cmd->data.draw.blend); gsKit_prim_list_line_goraud_3d(data->gsGlobal, count, verts); @@ -447,12 +427,11 @@ PS2_RenderLines(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand * cmd) return 0; } -int -PS2_RenderPoints(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand * cmd) +int PS2_RenderPoints(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cmd) { PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; const size_t count = cmd->data.draw.count; - const GSPRIMPOINT *verts = (GSPRIMPOINT *) (vertices + cmd->data.draw.first); + const GSPRIMPOINT *verts = (GSPRIMPOINT *)(vertices + cmd->data.draw.first); PS2_SetBlendMode(data, cmd->data.draw.blend); gsKit_prim_list_points(data->gsGlobal, count, verts); @@ -461,91 +440,94 @@ PS2_RenderPoints(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand * cmd return 0; } -static int -PS2_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) +static int PS2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) { while (cmd) { switch (cmd->command) { - case SDL_RENDERCMD_SETVIEWPORT: { - PS2_RenderSetViewPort(renderer, cmd); - break; - } - case SDL_RENDERCMD_SETCLIPRECT: { - PS2_RenderSetClipRect(renderer, cmd); - break; - } - case SDL_RENDERCMD_SETDRAWCOLOR: { - PS2_RenderSetDrawColor(renderer, cmd); - break; - } - case SDL_RENDERCMD_CLEAR: { - PS2_RenderClear(renderer, cmd); - break; - } - case SDL_RENDERCMD_DRAW_POINTS: { - PS2_RenderPoints(renderer, vertices, cmd); - break; - } - case SDL_RENDERCMD_DRAW_LINES: { - PS2_RenderLines(renderer, vertices, cmd); - break; - } - case SDL_RENDERCMD_FILL_RECTS: /* unused */ - break; - case SDL_RENDERCMD_COPY: /* unused */ - break; - case SDL_RENDERCMD_COPY_EX: /* unused */ - break; - case SDL_RENDERCMD_GEOMETRY: { - PS2_RenderGeometry(renderer, vertices, cmd); - break; - } - case SDL_RENDERCMD_NO_OP: - break; + case SDL_RENDERCMD_SETVIEWPORT: + { + PS2_RenderSetViewPort(renderer, cmd); + break; + } + case SDL_RENDERCMD_SETCLIPRECT: + { + PS2_RenderSetClipRect(renderer, cmd); + break; + } + case SDL_RENDERCMD_SETDRAWCOLOR: + { + PS2_RenderSetDrawColor(renderer, cmd); + break; + } + case SDL_RENDERCMD_CLEAR: + { + PS2_RenderClear(renderer, cmd); + break; + } + case SDL_RENDERCMD_DRAW_POINTS: + { + PS2_RenderPoints(renderer, vertices, cmd); + break; + } + case SDL_RENDERCMD_DRAW_LINES: + { + PS2_RenderLines(renderer, vertices, cmd); + break; + } + case SDL_RENDERCMD_FILL_RECTS: /* unused */ + break; + case SDL_RENDERCMD_COPY: /* unused */ + break; + case SDL_RENDERCMD_COPY_EX: /* unused */ + break; + case SDL_RENDERCMD_GEOMETRY: + { + PS2_RenderGeometry(renderer, vertices, cmd); + break; + } + case SDL_RENDERCMD_NO_OP: + break; } cmd = cmd->next; } return 0; } -static int -PS2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, void * pixels, int pitch) +static int PS2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, + Uint32 format, void *pixels, int pitch) { return SDL_Unsupported(); } -static int -PS2_RenderPresent(SDL_Renderer * renderer) +static int PS2_RenderPresent(SDL_Renderer *renderer) { - PS2_RenderData *data = (PS2_RenderData *) renderer->driverdata; + PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; if (data->gsGlobal->DoubleBuffering == GS_SETTING_OFF) { - if (data->vsync == 2) { // Dynamic + if (data->vsync == 2) { // Dynamic gsKit_sync(data->gsGlobal); } else if (data->vsync == 1) { gsKit_vsync_wait(); } - gsKit_queue_exec(data->gsGlobal); + gsKit_queue_exec(data->gsGlobal); } else { - gsKit_queue_exec(data->gsGlobal); - gsKit_finish(); - if (data->vsync == 2) { // Dynamic + gsKit_queue_exec(data->gsGlobal); + gsKit_finish(); + if (data->vsync == 2) { // Dynamic gsKit_sync(data->gsGlobal); } else if (data->vsync == 1) { gsKit_vsync_wait(); } - gsKit_flip(data->gsGlobal); - } - gsKit_TexManager_nextFrame(data->gsGlobal); + gsKit_flip(data->gsGlobal); + } + gsKit_TexManager_nextFrame(data->gsGlobal); gsKit_clear(data->gsGlobal, GS_BLACK); return 0; } -static void -PS2_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static void PS2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - GSTEXTURE *ps2_texture = (GSTEXTURE *) texture->driverdata; + GSTEXTURE *ps2_texture = (GSTEXTURE *)texture->driverdata; PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; if (data == NULL) { @@ -558,14 +540,13 @@ PS2_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) // Free from vram gsKit_TexManager_free(data->gsGlobal, ps2_texture); - + SDL_free(ps2_texture->Mem); SDL_free(ps2_texture); texture->driverdata = NULL; } -static void -PS2_DestroyRenderer(SDL_Renderer * renderer) +static void PS2_DestroyRenderer(SDL_Renderer *renderer) { PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; @@ -585,8 +566,7 @@ PS2_DestroyRenderer(SDL_Renderer * renderer) SDL_free(renderer); } -static int -PS2_SetVSync(SDL_Renderer * renderer, const int vsync) +static int PS2_SetVSync(SDL_Renderer *renderer, const int vsync) { PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; SDL_bool dynamicVsync = SDL_GetHintBoolean(SDL_HINT_PS2_DYNAMIC_VSYNC, SDL_FALSE); @@ -594,8 +574,7 @@ PS2_SetVSync(SDL_Renderer * renderer, const int vsync) return 0; } -static SDL_Renderer * -PS2_CreateRenderer(SDL_Window * window, Uint32 flags) +static SDL_Renderer *PS2_CreateRenderer(SDL_Window *window, Uint32 flags) { SDL_Renderer *renderer; PS2_RenderData *data; @@ -603,13 +582,13 @@ PS2_CreateRenderer(SDL_Window * window, Uint32 flags) ee_sema_t sema; SDL_bool dynamicVsync; - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); if (renderer == NULL) { SDL_OutOfMemory(); return NULL; } - data = (PS2_RenderData *) SDL_calloc(1, sizeof(*data)); + data = (PS2_RenderData *)SDL_calloc(1, sizeof(*data)); if (data == NULL) { PS2_DestroyRenderer(renderer); SDL_OutOfMemory(); @@ -621,35 +600,35 @@ PS2_CreateRenderer(SDL_Window * window, Uint32 flags) sema.max_count = 1; sema.option = 0; vsync_sema_id = CreateSema(&sema); - + gsGlobal = gsKit_init_global_custom(RENDER_QUEUE_OS_POOLSIZE, RENDER_QUEUE_PER_POOLSIZE); - gsGlobal->Mode = GS_MODE_NTSC; + gsGlobal->Mode = GS_MODE_NTSC; gsGlobal->Height = 448; - gsGlobal->PSM = GS_PSM_CT24; - gsGlobal->PSMZ = GS_PSMZ_16S; - gsGlobal->ZBuffering = GS_SETTING_OFF; - gsGlobal->DoubleBuffering = GS_SETTING_ON; - gsGlobal->PrimAlphaEnable = GS_SETTING_ON; - gsGlobal->Dithering = GS_SETTING_OFF; + gsGlobal->PSM = GS_PSM_CT24; + gsGlobal->PSMZ = GS_PSMZ_16S; + gsGlobal->ZBuffering = GS_SETTING_OFF; + gsGlobal->DoubleBuffering = GS_SETTING_ON; + gsGlobal->PrimAlphaEnable = GS_SETTING_ON; + gsGlobal->Dithering = GS_SETTING_OFF; - gsKit_set_primalpha(gsGlobal, GS_SETREG_ALPHA(0, 1, 0, 1, 0), 0); + gsKit_set_primalpha(gsGlobal, GS_SETREG_ALPHA(0, 1, 0, 1, 0), 0); - dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC, D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF); - dmaKit_chan_init(DMA_CHANNEL_GIF); + dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC, D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF); + dmaKit_chan_init(DMA_CHANNEL_GIF); - gsKit_set_clamp(gsGlobal, GS_CMODE_REPEAT); + gsKit_set_clamp(gsGlobal, GS_CMODE_REPEAT); - gsKit_vram_clear(gsGlobal); + gsKit_vram_clear(gsGlobal); - gsKit_init_screen(gsGlobal); + gsKit_init_screen(gsGlobal); - gsKit_TexManager_init(gsGlobal); + gsKit_TexManager_init(gsGlobal); - data->vsync_callback_id = gsKit_add_vsync_handler(vsync_handler); + data->vsync_callback_id = gsKit_add_vsync_handler(vsync_handler); - gsKit_mode_switch(gsGlobal, GS_ONESHOT); + gsKit_mode_switch(gsGlobal, GS_ONESHOT); gsKit_clear(gsGlobal, GS_BLACK); @@ -688,7 +667,7 @@ SDL_RenderDriver PS2_RenderDriver = { .name = "PS2 gsKit", .flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE, .num_texture_formats = 2, - .texture_formats = { + .texture_formats = { [0] = SDL_PIXELFORMAT_ABGR1555, [1] = SDL_PIXELFORMAT_ABGR8888, }, diff --git a/src/render/psp/SDL_render_psp.c b/src/render/psp/SDL_render_psp.c index 8c199acb3..a26ab875a 100644 --- a/src/render/psp/SDL_render_psp.c +++ b/src/render/psp/SDL_render_psp.c @@ -37,24 +37,20 @@ #include #include - - - /* PSP renderer implementation, based on the PGE */ -#define PSP_SCREEN_WIDTH 480 -#define PSP_SCREEN_HEIGHT 272 +#define PSP_SCREEN_WIDTH 480 +#define PSP_SCREEN_HEIGHT 272 -#define PSP_FRAME_BUFFER_WIDTH 512 -#define PSP_FRAME_BUFFER_SIZE (PSP_FRAME_BUFFER_WIDTH*PSP_SCREEN_HEIGHT) +#define PSP_FRAME_BUFFER_WIDTH 512 +#define PSP_FRAME_BUFFER_SIZE (PSP_FRAME_BUFFER_WIDTH * PSP_SCREEN_HEIGHT) static unsigned int __attribute__((aligned(16))) DisplayList[262144]; - -#define COL5650(r,g,b,a) ((r>>3) | ((g>>2)<<5) | ((b>>3)<<11)) -#define COL5551(r,g,b,a) ((r>>3) | ((g>>3)<<5) | ((b>>3)<<10) | (a>0?0x7000:0)) -#define COL4444(r,g,b,a) ((r>>4) | ((g>>4)<<4) | ((b>>4)<<8) | ((a>>4)<<12)) -#define COL8888(r,g,b,a) ((r) | ((g)<<8) | ((b)<<16) | ((a)<<24)) +#define COL5650(r, g, b, a) ((r >> 3) | ((g >> 2) << 5) | ((b >> 3) << 11)) +#define COL5551(r, g, b, a) ((r >> 3) | ((g >> 3) << 5) | ((b >> 3) << 10) | (a > 0 ? 0x7000 : 0)) +#define COL4444(r, g, b, a) ((r >> 4) | ((g >> 4) << 4) | ((b >> 4) << 8) | ((a >> 4) << 12)) +#define COL8888(r, g, b, a) ((r) | ((g) << 8) | ((b) << 16) | ((a) << 24)) /** * Holds psp specific texture data @@ -64,18 +60,18 @@ static unsigned int __attribute__((aligned(16))) DisplayList[262144]; */ typedef struct PSP_TextureData { - void *data; /**< Image data. */ - unsigned int size; /**< Size of data in bytes. */ - unsigned int width; /**< Image width. */ - unsigned int height; /**< Image height. */ - unsigned int textureWidth; /**< Texture width (power of two). */ - unsigned int textureHeight; /**< Texture height (power of two). */ - unsigned int bits; /**< Image bits per pixel. */ - unsigned int format; /**< Image format - one of ::pgePixelFormat. */ - unsigned int pitch; - SDL_bool swizzled; /**< Is image swizzled. */ - struct PSP_TextureData* prevhotw; /**< More recently used render target */ - struct PSP_TextureData* nexthotw; /**< Less recently used render target */ + void *data; /**< Image data. */ + unsigned int size; /**< Size of data in bytes. */ + unsigned int width; /**< Image width. */ + unsigned int height; /**< Image height. */ + unsigned int textureWidth; /**< Texture width (power of two). */ + unsigned int textureHeight; /**< Texture height (power of two). */ + unsigned int bits; /**< Image bits per pixel. */ + unsigned int format; /**< Image format - one of ::pgePixelFormat. */ + unsigned int pitch; + SDL_bool swizzled; /**< Is image swizzled. */ + struct PSP_TextureData *prevhotw; /**< More recently used render target */ + struct PSP_TextureData *nexthotw; /**< Less recently used render target */ } PSP_TextureData; typedef struct @@ -83,103 +79,97 @@ typedef struct SDL_BlendMode mode; unsigned int color; int shadeModel; - SDL_Texture* texture; + SDL_Texture *texture; } PSP_BlendState; typedef struct { - void* frontbuffer; /**< main screen buffer */ - void* backbuffer; /**< buffer presented to display */ - SDL_Texture* boundTarget; /**< currently bound rendertarget */ - SDL_bool initialized; /**< is driver initialized */ - SDL_bool displayListAvail; /**< is the display list already initialized for this frame */ - unsigned int psm; /**< format of the display buffers */ - unsigned int bpp; /**< bits per pixel of the main display */ + void *frontbuffer; /**< main screen buffer */ + void *backbuffer; /**< buffer presented to display */ + SDL_Texture *boundTarget; /**< currently bound rendertarget */ + SDL_bool initialized; /**< is driver initialized */ + SDL_bool displayListAvail; /**< is the display list already initialized for this frame */ + unsigned int psm; /**< format of the display buffers */ + unsigned int bpp; /**< bits per pixel of the main display */ - SDL_bool vsync; /**< whether we do vsync */ - PSP_BlendState blendState; /**< current blend mode */ - PSP_TextureData* most_recent_target; /**< start of render target LRU double linked list */ - PSP_TextureData* least_recent_target; /**< end of the LRU list */ + SDL_bool vsync; /**< whether we do vsync */ + PSP_BlendState blendState; /**< current blend mode */ + PSP_TextureData *most_recent_target; /**< start of render target LRU double linked list */ + PSP_TextureData *least_recent_target; /**< end of the LRU list */ - SDL_bool vblank_not_reached; /**< whether vblank wasn't reached */ + SDL_bool vblank_not_reached; /**< whether vblank wasn't reached */ } PSP_RenderData; - typedef struct { - float x, y, z; + float x, y, z; } VertV; - typedef struct { - float u, v; - float x, y, z; + float u, v; + float x, y, z; } VertTV; typedef struct { SDL_Color col; - float x, y, z; + float x, y, z; } VertCV; - typedef struct { - float u, v; + float u, v; SDL_Color col; - float x, y, z; + float x, y, z; } VertTCV; -#define PI 3.14159265358979f +#define PI 3.14159265358979f -#define radToDeg(x) ((x)*180.f/PI) -#define degToRad(x) ((x)*PI/180.f) +#define radToDeg(x) ((x)*180.f / PI) +#define degToRad(x) ((x)*PI / 180.f) -static float -MathAbs(float x) +static float MathAbs(float x) { float result; - __asm__ volatile ( + __asm__ volatile( "mtv %1, S000\n" "vabs.s S000, S000\n" "mfv %0, S000\n" - : "=r"(result) : "r"(x)); + : "=r"(result) + : "r"(x)); return result; } -static void -MathSincos(float r, float *s, float *c) +static void MathSincos(float r, float *s, float *c) { - __asm__ volatile ( + __asm__ volatile( "mtv %2, S002\n" "vcst.s S003, VFPU_2_PI\n" "vmul.s S002, S002, S003\n" "vrot.p C000, S002, [s, c]\n" "mfv %0, S000\n" "mfv %1, S001\n" - : "=r"(*s), "=r"(*c): "r"(r)); + : "=r"(*s), "=r"(*c) + : "r"(r)); } -static void -Swap(float *a, float *b) +static void Swap(float *a, float *b) { - float n=*a; + float n = *a; *a = *b; *b = n; } -static inline int -InVram(void* data) +static inline int InVram(void *data) { - return data < (void*)0x04200000; + return data < (void *)0x04200000; } /* Return next power of 2 */ -static int -TextureNextPow2(unsigned int w) +static int TextureNextPow2(unsigned int w) { unsigned int n = 2; if (w == 0) { @@ -195,14 +185,12 @@ TextureNextPow2(unsigned int w) static void psp_on_vblank(u32 sub, PSP_RenderData *data) { - if (data) { - data->vblank_not_reached = SDL_FALSE; - } + if (data) { + data->vblank_not_reached = SDL_FALSE; + } } - -static int -PixelFormatToPSPFMT(Uint32 format) +static int PixelFormatToPSPFMT(Uint32 format) { switch (format) { case SDL_PIXELFORMAT_BGR565: @@ -218,9 +206,9 @@ PixelFormatToPSPFMT(Uint32 format) } } -///SECTION render target LRU management -static void -LRUTargetRelink(PSP_TextureData* psp_texture) { +/// SECTION render target LRU management +static void LRUTargetRelink(PSP_TextureData *psp_texture) +{ if (psp_texture->prevhotw) { psp_texture->prevhotw->nexthotw = psp_texture->nexthotw; } @@ -229,8 +217,8 @@ LRUTargetRelink(PSP_TextureData* psp_texture) { } } -static void -LRUTargetPushFront(PSP_RenderData* data, PSP_TextureData* psp_texture) { +static void LRUTargetPushFront(PSP_RenderData *data, PSP_TextureData *psp_texture) +{ psp_texture->nexthotw = data->most_recent_target; if (data->most_recent_target) { data->most_recent_target->prevhotw = psp_texture; @@ -241,8 +229,8 @@ LRUTargetPushFront(PSP_RenderData* data, PSP_TextureData* psp_texture) { } } -static void -LRUTargetRemove(PSP_RenderData* data, PSP_TextureData* psp_texture) { +static void LRUTargetRemove(PSP_RenderData *data, PSP_TextureData *psp_texture) +{ LRUTargetRelink(psp_texture); if (data->most_recent_target == psp_texture) { data->most_recent_target = psp_texture->nexthotw; @@ -254,17 +242,17 @@ LRUTargetRemove(PSP_RenderData* data, PSP_TextureData* psp_texture) { psp_texture->nexthotw = NULL; } -static void -LRUTargetBringFront(PSP_RenderData* data, PSP_TextureData* psp_texture) { +static void LRUTargetBringFront(PSP_RenderData *data, PSP_TextureData *psp_texture) +{ if (data->most_recent_target == psp_texture) { - return; //nothing to do + return; // nothing to do } LRUTargetRemove(data, psp_texture); LRUTargetPushFront(data, psp_texture); } -static void -TextureStorageFree(void* storage) { +static void TextureStorageFree(void *storage) +{ if (InVram(storage)) { vfree(storage); } else { @@ -272,8 +260,7 @@ TextureStorageFree(void* storage) { } } -static int -TextureSwizzle(PSP_TextureData *psp_texture, void* dst) +static int TextureSwizzle(PSP_TextureData *psp_texture, void *dst) { int bytewidth, height; int rowblocks, rowblocksadd; @@ -286,13 +273,13 @@ TextureSwizzle(PSP_TextureData *psp_texture, void* dst) return 1; } - bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3); + bytewidth = psp_texture->textureWidth * (psp_texture->bits >> 3); height = psp_texture->size / bytewidth; - rowblocks = (bytewidth>>4); - rowblocksadd = (rowblocks-1)<<7; + rowblocks = (bytewidth >> 4); + rowblocksadd = (rowblocks - 1) << 7; - src = (unsigned int*) psp_texture->data; + src = (unsigned int *)psp_texture->data; data = dst; if (data == NULL) { @@ -303,14 +290,12 @@ TextureSwizzle(PSP_TextureData *psp_texture, void* dst) return SDL_OutOfMemory(); } - for (j = 0; j < height; j++, blockaddress += 16) - { + for (j = 0; j < height; j++, blockaddress += 16) { unsigned int *block; - block = (unsigned int*)&data[blockaddress]; + block = (unsigned int *)&data[blockaddress]; - for (i = 0; i < rowblocks; i++) - { + for (i = 0; i < rowblocks; i++) { *block++ = *src++; *block++ = *src++; *block++ = *src++; @@ -331,8 +316,7 @@ TextureSwizzle(PSP_TextureData *psp_texture, void* dst) return 1; } -static int -TextureUnswizzle(PSP_TextureData *psp_texture, void* dst) +static int TextureUnswizzle(PSP_TextureData *psp_texture, void *dst) { int bytewidth, height; int widthblocks, heightblocks; @@ -347,16 +331,16 @@ TextureUnswizzle(PSP_TextureData *psp_texture, void* dst) return 1; } - bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3); + bytewidth = psp_texture->textureWidth * (psp_texture->bits >> 3); height = psp_texture->size / bytewidth; - widthblocks = bytewidth/16; - heightblocks = height/8; + widthblocks = bytewidth / 16; + heightblocks = height / 8; - dstpitch = (bytewidth - 16)/4; + dstpitch = (bytewidth - 16) / 4; dstrow = bytewidth * 8; - src = (unsigned int*) psp_texture->data; + src = (unsigned int *)psp_texture->data; data = dst; @@ -370,18 +354,15 @@ TextureUnswizzle(PSP_TextureData *psp_texture, void* dst) ydst = (unsigned char *)data; - for (blocky = 0; blocky < heightblocks; ++blocky) - { + for (blocky = 0; blocky < heightblocks; ++blocky) { unsigned char *xdst = ydst; - for (blockx = 0; blockx < widthblocks; ++blockx) - { + for (blockx = 0; blockx < widthblocks; ++blockx) { unsigned int *block; - block = (unsigned int*)xdst; + block = (unsigned int *)xdst; - for (j = 0; j < 8; ++j) - { + for (j = 0; j < 8; ++j) { *(block++) = *(src++); *(block++) = *(src++); *(block++) = *(src++); @@ -405,13 +386,12 @@ TextureUnswizzle(PSP_TextureData *psp_texture, void* dst) return 1; } -static int -TextureSpillToSram(PSP_RenderData* data, PSP_TextureData* psp_texture) +static int TextureSpillToSram(PSP_RenderData *data, PSP_TextureData *psp_texture) { // Assumes the texture is in VRAM if (psp_texture->swizzled) { - //Texture was swizzled in vram, just copy to system memory - void* sdata = SDL_malloc(psp_texture->size); + // Texture was swizzled in vram, just copy to system memory + void *sdata = SDL_malloc(psp_texture->size); if (sdata == NULL) { return SDL_OutOfMemory(); } @@ -421,15 +401,14 @@ TextureSpillToSram(PSP_RenderData* data, PSP_TextureData* psp_texture) psp_texture->data = sdata; return 0; } else { - return TextureSwizzle(psp_texture, NULL); //Will realloc in sysram + return TextureSwizzle(psp_texture, NULL); // Will realloc in sysram } } -static int -TexturePromoteToVram(PSP_RenderData* data, PSP_TextureData* psp_texture, SDL_bool target) +static int TexturePromoteToVram(PSP_RenderData *data, PSP_TextureData *psp_texture, SDL_bool target) { // Assumes texture in sram and a large enough continuous block in vram - void* tdata = vramalloc(psp_texture->size); + void *tdata = vramalloc(psp_texture->size); if (psp_texture->swizzled && target) { return TextureUnswizzle(psp_texture, tdata); } else { @@ -440,9 +419,9 @@ TexturePromoteToVram(PSP_RenderData* data, PSP_TextureData* psp_texture, SDL_boo } } -static int -TextureSpillLRU(PSP_RenderData* data, size_t wanted) { - PSP_TextureData* lru = data->least_recent_target; +static int TextureSpillLRU(PSP_RenderData *data, size_t wanted) +{ + PSP_TextureData *lru = data->least_recent_target; if (lru) { if (TextureSpillToSram(data, lru) < 0) { return -1; @@ -450,13 +429,12 @@ TextureSpillLRU(PSP_RenderData* data, size_t wanted) { LRUTargetRemove(data, lru); } else { // Asked to spill but there nothing to spill - return SDL_SetError("Could not spill more VRAM to system memory. VRAM : %dKB,(%dKB), wanted %dKB", vmemavail()/1024, vlargestblock()/1024, wanted/1024); + return SDL_SetError("Could not spill more VRAM to system memory. VRAM : %dKB,(%dKB), wanted %dKB", vmemavail() / 1024, vlargestblock() / 1024, wanted / 1024); } return 0; } -static int -TextureSpillTargetsForSpace(PSP_RenderData* data, size_t size) +static int TextureSpillTargetsForSpace(PSP_RenderData *data, size_t size) { while (vlargestblock() < size) { if (TextureSpillLRU(data, size) < 0) { @@ -466,8 +444,8 @@ TextureSpillTargetsForSpace(PSP_RenderData* data, size_t size) return 0; } -static int -TextureBindAsTarget(PSP_RenderData* data, PSP_TextureData* psp_texture) { +static int TextureBindAsTarget(PSP_RenderData *data, PSP_TextureData *psp_texture) +{ unsigned int dstFormat; if (!InVram(psp_texture->data)) { @@ -497,17 +475,14 @@ TextureBindAsTarget(PSP_RenderData* data, PSP_TextureData* psp_texture) { return 0; } -static void -PSP_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +static void PSP_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event) { } - -static int -PSP_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static int PSP_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) { PSP_RenderData *data = renderer->driverdata; - PSP_TextureData* psp_texture = (PSP_TextureData*) SDL_calloc(1, sizeof(*psp_texture)); + PSP_TextureData *psp_texture = (PSP_TextureData *)SDL_calloc(1, sizeof(*psp_texture)); if (psp_texture == NULL) { return SDL_OutOfMemory(); @@ -520,25 +495,24 @@ PSP_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) psp_texture->textureWidth = TextureNextPow2(texture->w); psp_texture->format = PixelFormatToPSPFMT(texture->format); - switch(psp_texture->format) - { - case GU_PSM_5650: - case GU_PSM_5551: - case GU_PSM_4444: - psp_texture->bits = 16; - break; + switch (psp_texture->format) { + case GU_PSM_5650: + case GU_PSM_5551: + case GU_PSM_4444: + psp_texture->bits = 16; + break; - case GU_PSM_8888: - psp_texture->bits = 32; - break; + case GU_PSM_8888: + psp_texture->bits = 32; + break; - default: - SDL_free(psp_texture); - return -1; + default: + SDL_free(psp_texture); + return -1; } psp_texture->pitch = psp_texture->textureWidth * SDL_BYTESPERPIXEL(texture->format); - psp_texture->size = psp_texture->textureHeight*psp_texture->pitch; + psp_texture->size = psp_texture->textureHeight * psp_texture->pitch; if (texture->access & SDL_TEXTUREACCESS_TARGET) { if (TextureSpillTargetsForSpace(renderer->driverdata, psp_texture->size) < 0) { SDL_free(psp_texture); @@ -561,18 +535,14 @@ PSP_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) return 0; } -static int -TextureShouldSwizzle(PSP_TextureData* psp_texture, SDL_Texture *texture) +static int TextureShouldSwizzle(PSP_TextureData *psp_texture, SDL_Texture *texture) { - return !((texture->access == SDL_TEXTUREACCESS_TARGET) && InVram(psp_texture->data)) - && texture->access != SDL_TEXTUREACCESS_STREAMING - && (texture->w >= 16 || texture->h >= 16); + return !((texture->access == SDL_TEXTUREACCESS_TARGET) && InVram(psp_texture->data)) && texture->access != SDL_TEXTUREACCESS_STREAMING && (texture->w >= 16 || texture->h >= 16); } -static void -TextureActivate(SDL_Texture * texture) +static void TextureActivate(SDL_Texture *texture) { - PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; + PSP_TextureData *psp_texture = (PSP_TextureData *)texture->driverdata; int scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? GU_NEAREST : GU_LINEAR; /* Swizzling is useless with small textures. */ @@ -583,28 +553,26 @@ TextureActivate(SDL_Texture * texture) sceGuTexWrap(GU_REPEAT, GU_REPEAT); sceGuTexMode(psp_texture->format, 0, 0, psp_texture->swizzled); sceGuTexFilter(scaleMode, scaleMode); /* GU_NEAREST good for tile-map */ - /* GU_LINEAR good for scaling */ + /* GU_LINEAR good for scaling */ sceGuTexImage(0, psp_texture->textureWidth, psp_texture->textureHeight, psp_texture->textureWidth, psp_texture->data); } -static int -PSP_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, void **pixels, int *pitch); +static int PSP_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, void **pixels, int *pitch); -static int -PSP_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, int pitch) +static int PSP_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, const void *pixels, int pitch) { -/* PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; */ + /* PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; */ const Uint8 *src; Uint8 *dst; - int row, length,dpitch; + int row, length, dpitch; src = pixels; - PSP_LockTexture(renderer, texture,rect,(void **)&dst, &dpitch); + PSP_LockTexture(renderer, texture, rect, (void **)&dst, &dpitch); length = rect->w * SDL_BYTESPERPIXEL(texture->format); if (length == pitch && length == dpitch) { - SDL_memcpy(dst, src, length*rect->h); + SDL_memcpy(dst, src, length * rect->h); } else { for (row = 0; row < rect->h; ++row) { SDL_memcpy(dst, src, length); @@ -617,23 +585,21 @@ PSP_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, return 0; } -static int -PSP_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, void **pixels, int *pitch) +static int PSP_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, void **pixels, int *pitch) { - PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; + PSP_TextureData *psp_texture = (PSP_TextureData *)texture->driverdata; *pixels = - (void *) ((Uint8 *) psp_texture->data + rect->y * psp_texture->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); + (void *)((Uint8 *)psp_texture->data + rect->y * psp_texture->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); *pitch = psp_texture->pitch; return 0; } -static void -PSP_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static void PSP_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; + PSP_TextureData *psp_texture = (PSP_TextureData *)texture->driverdata; SDL_Rect rect; /* We do whole texture updates, at least for now */ @@ -644,28 +610,24 @@ PSP_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) PSP_UpdateTexture(renderer, texture, &rect, psp_texture->data, psp_texture->pitch); } -static void -PSP_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode) +static void PSP_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode) { /* Nothing to do because TextureActivate takes care of it */ } -static int -PSP_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +static int PSP_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) { return 0; } -static int -PSP_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd) +static int PSP_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { - return 0; /* nothing to do in this backend. */ + return 0; /* nothing to do in this backend. */ } -static int -PSP_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) +static int PSP_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { - VertV *verts = (VertV *) SDL_AllocateRenderVertices(renderer, count * sizeof (VertV), 4, &cmd->data.draw.first); + VertV *verts = (VertV *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertV), 4, &cmd->data.draw.first); int i; if (verts == NULL) { @@ -683,11 +645,10 @@ PSP_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F return 0; } -static int -PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, - const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, - int num_vertices, const void *indices, int num_indices, int size_indices, - float scale_x, float scale_y) +static int PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, + int num_vertices, const void *indices, int num_indices, int size_indices, + float scale_x, float scale_y) { int i; int count = indices ? num_indices : num_vertices; @@ -697,7 +658,7 @@ PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t if (texture == NULL) { VertCV *verts; - verts = (VertCV *) SDL_AllocateRenderVertices(renderer, count * sizeof (VertCV), 4, &cmd->data.draw.first); + verts = (VertCV *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertCV), 4, &cmd->data.draw.first); if (verts == NULL) { return -1; } @@ -716,8 +677,8 @@ PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t j = i; } - xy_ = (float *)((char*)xy + j * xy_stride); - col_ = *(SDL_Color *)((char*)color + j * color_stride); + xy_ = (float *)((char *)xy + j * xy_stride); + col_ = *(SDL_Color *)((char *)color + j * color_stride); verts->x = xy_[0] * scale_x; verts->y = xy_[1] * scale_y; @@ -728,9 +689,9 @@ PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t verts++; } } else { - PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; + PSP_TextureData *psp_texture = (PSP_TextureData *)texture->driverdata; VertTCV *verts; - verts = (VertTCV *) SDL_AllocateRenderVertices(renderer, count * sizeof (VertTCV), 4, &cmd->data.draw.first); + verts = (VertTCV *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertTCV), 4, &cmd->data.draw.first); if (verts == NULL) { return -1; } @@ -751,9 +712,9 @@ PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t j = i; } - xy_ = (float *)((char*)xy + j * xy_stride); - col_ = *(SDL_Color *)((char*)color + j * color_stride); - uv_ = (float *)((char*)uv + j * uv_stride); + xy_ = (float *)((char *)xy + j * xy_stride); + col_ = *(SDL_Color *)((char *)color + j * color_stride); + uv_ = (float *)((char *)uv + j * uv_stride); verts->x = xy_[0] * scale_x; verts->y = xy_[1] * scale_y; @@ -771,10 +732,9 @@ PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t return 0; } -static int -PSP_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count) +static int PSP_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FRect *rects, int count) { - VertV *verts = (VertV *) SDL_AllocateRenderVertices(renderer, count * 2 * sizeof (VertV), 4, &cmd->data.draw.first); + VertV *verts = (VertV *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(VertV), 4, &cmd->data.draw.first); int i; if (verts == NULL) { @@ -797,9 +757,8 @@ PSP_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FR return 0; } -static int -PSP_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_FRect * dstrect) +static int PSP_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const SDL_Rect *srcrect, const SDL_FRect *dstrect) { VertTV *verts; const float x = dstrect->x; @@ -813,7 +772,7 @@ PSP_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * tex const float v1 = srcrect->y + srcrect->h; if ((MathAbs(u1) - MathAbs(u0)) < 64.0f) { - verts = (VertTV *) SDL_AllocateRenderVertices(renderer, 2 * sizeof (VertTV), 4, &cmd->data.draw.first); + verts = (VertTV *)SDL_AllocateRenderVertices(renderer, 2 * sizeof(VertTV), 4, &cmd->data.draw.first); if (verts == NULL) { return -1; } @@ -841,7 +800,7 @@ PSP_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * tex const float slice = 64.0f; const size_t count = SDL_ceilf(width / slice); size_t i; - float ustep = (u1 - u0)/width * slice; + float ustep = (u1 - u0) / width * slice; if (ustep < 0.0f) { ustep = -ustep; @@ -849,14 +808,12 @@ PSP_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * tex cmd->data.draw.count = count; - verts = (VertTV *) SDL_AllocateRenderVertices(renderer, count * 2 * sizeof (VertTV), 4, &cmd->data.draw.first); + verts = (VertTV *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(VertTV), 4, &cmd->data.draw.first); if (verts == NULL) { return -1; } - - for (i = 0, start = 0, end = width; i < count; i++, start += slice) - { + for (i = 0, start = 0, end = width; i < count; i++, start += slice) { const float polyWidth = ((curX + slice) > endX) ? (endX - curX) : slice; const float sourceWidth = ((curU + ustep) > u1) ? (u1 - curU) : ustep; @@ -884,12 +841,11 @@ PSP_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * tex return 0; } -static int -PSP_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_FRect * dstrect, - const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip, float scale_x, float scale_y) +static int PSP_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const SDL_Rect *srcrect, const SDL_FRect *dstrect, + const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip, float scale_x, float scale_y) { - VertTV *verts = (VertTV *) SDL_AllocateRenderVertices(renderer, 4 * sizeof (VertTV), 4, &cmd->data.draw.first); + VertTV *verts = (VertTV *)SDL_AllocateRenderVertices(renderer, 4 * sizeof(VertTV), 4, &cmd->data.draw.first); const float centerx = center->x; const float centery = center->y; const float x = dstrect->x + centerx; @@ -910,7 +866,7 @@ PSP_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * t cmd->data.draw.count = 1; - MathSincos(degToRad(360-angle), &s, &c); + MathSincos(degToRad(360 - angle), &s, &c); cw1 = c * -centerx; sw1 = s * -centerx; @@ -973,8 +929,8 @@ PSP_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * t return 0; } -static void -ResetBlendState(PSP_BlendState* state) { +static void ResetBlendState(PSP_BlendState *state) +{ sceGuColor(0xffffffff); state->color = 0xffffffff; state->mode = SDL_BLENDMODE_INVALID; @@ -984,23 +940,22 @@ ResetBlendState(PSP_BlendState* state) { state->shadeModel = GU_SMOOTH; } -static void -StartDrawing(SDL_Renderer * renderer) +static void StartDrawing(SDL_Renderer *renderer) { - PSP_RenderData *data = (PSP_RenderData *) renderer->driverdata; + PSP_RenderData *data = (PSP_RenderData *)renderer->driverdata; // Check if we need to start GU displaylist if (!data->displayListAvail) { sceGuStart(GU_DIRECT, DisplayList); data->displayListAvail = SDL_TRUE; - //ResetBlendState(&data->blendState); + // ResetBlendState(&data->blendState); } // Check if we need a draw buffer change if (renderer->target != data->boundTarget) { - SDL_Texture* texture = renderer->target; + SDL_Texture *texture = renderer->target; if (texture) { - PSP_TextureData* psp_texture = (PSP_TextureData*) texture->driverdata; + PSP_TextureData *psp_texture = (PSP_TextureData *)texture->driverdata; // Set target, registering LRU TextureBindAsTarget(data, psp_texture); } else { @@ -1011,11 +966,9 @@ StartDrawing(SDL_Renderer * renderer) } } - -static void -PSP_SetBlendState(PSP_RenderData* data, PSP_BlendState* state) +static void PSP_SetBlendState(PSP_RenderData *data, PSP_BlendState *state) { - PSP_BlendState* current = &data->blendState; + PSP_BlendState *current = &data->blendState; if (state->mode != current->mode) { switch (state->mode) { @@ -1025,21 +978,21 @@ PSP_SetBlendState(PSP_RenderData* data, PSP_BlendState* state) break; case SDL_BLENDMODE_BLEND: sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA); - sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0 ); + sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); sceGuEnable(GU_BLEND); break; case SDL_BLENDMODE_ADD: - sceGuTexFunc(GU_TFX_MODULATE , GU_TCC_RGBA); - sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_FIX, 0, 0x00FFFFFF ); + sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA); + sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_FIX, 0, 0x00FFFFFF); sceGuEnable(GU_BLEND); break; case SDL_BLENDMODE_MOD: - sceGuTexFunc(GU_TFX_MODULATE , GU_TCC_RGBA); + sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA); sceGuBlendFunc(GU_ADD, GU_FIX, GU_SRC_COLOR, 0, 0); sceGuEnable(GU_BLEND); break; case SDL_BLENDMODE_MUL: - sceGuTexFunc(GU_TFX_MODULATE , GU_TCC_RGBA); + sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA); sceGuBlendFunc(GU_ADD, GU_DST_COLOR, GU_ONE_MINUS_SRC_ALPHA, 0, 0); sceGuEnable(GU_BLEND); break; @@ -1068,10 +1021,9 @@ PSP_SetBlendState(PSP_RenderData* data, PSP_BlendState* state) *current = *state; } -static int -PSP_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) +static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) { - PSP_RenderData *data = (PSP_RenderData *) renderer->driverdata; + PSP_RenderData *data = (PSP_RenderData *)renderer->driverdata; Uint8 *gpumem = NULL; StartDrawing(renderer); @@ -1081,166 +1033,176 @@ PSP_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti I don't know what the limits on PSP hardware are. It might be useful to have rendering backends report a reasonable maximum, so the higher level can flush if we appear to be exceeding that. */ - gpumem = (Uint8 *) sceGuGetMemory(vertsize); + gpumem = (Uint8 *)sceGuGetMemory(vertsize); if (gpumem == NULL) { - return SDL_SetError("Couldn't obtain a %d-byte vertex buffer!", (int) vertsize); + return SDL_SetError("Couldn't obtain a %d-byte vertex buffer!", (int)vertsize); } SDL_memcpy(gpumem, vertices, vertsize); while (cmd) { switch (cmd->command) { - case SDL_RENDERCMD_SETDRAWCOLOR: { - break; /* !!! FIXME: we could cache drawstate like color */ - } + case SDL_RENDERCMD_SETDRAWCOLOR: + { + break; /* !!! FIXME: we could cache drawstate like color */ + } - case SDL_RENDERCMD_SETVIEWPORT: { - SDL_Rect *viewport = &cmd->data.viewport.rect; - sceGuOffset(2048 - (viewport->w >> 1), 2048 - (viewport->h >> 1)); - sceGuViewport(2048, 2048, viewport->w, viewport->h); - sceGuScissor(viewport->x, viewport->y, viewport->w, viewport->h); - break; - } + case SDL_RENDERCMD_SETVIEWPORT: + { + SDL_Rect *viewport = &cmd->data.viewport.rect; + sceGuOffset(2048 - (viewport->w >> 1), 2048 - (viewport->h >> 1)); + sceGuViewport(2048, 2048, viewport->w, viewport->h); + sceGuScissor(viewport->x, viewport->y, viewport->w, viewport->h); + break; + } - case SDL_RENDERCMD_SETCLIPRECT: { - const SDL_Rect *rect = &cmd->data.cliprect.rect; - if (cmd->data.cliprect.enabled) { - sceGuEnable(GU_SCISSOR_TEST); - sceGuScissor(rect->x, rect->y, rect->w, rect->h); - } else { - sceGuDisable(GU_SCISSOR_TEST); - } - break; + case SDL_RENDERCMD_SETCLIPRECT: + { + const SDL_Rect *rect = &cmd->data.cliprect.rect; + if (cmd->data.cliprect.enabled) { + sceGuEnable(GU_SCISSOR_TEST); + sceGuScissor(rect->x, rect->y, rect->w, rect->h); + } else { + sceGuDisable(GU_SCISSOR_TEST); } + break; + } - case SDL_RENDERCMD_CLEAR: { - const Uint8 r = cmd->data.color.r; - const Uint8 g = cmd->data.color.g; - const Uint8 b = cmd->data.color.b; - const Uint8 a = cmd->data.color.a; - sceGuClearColor(GU_RGBA(r,g,b,a)); - sceGuClearStencil(a); - sceGuClear(GU_COLOR_BUFFER_BIT | GU_STENCIL_BUFFER_BIT); - break; - } + case SDL_RENDERCMD_CLEAR: + { + const Uint8 r = cmd->data.color.r; + const Uint8 g = cmd->data.color.g; + const Uint8 b = cmd->data.color.b; + const Uint8 a = cmd->data.color.a; + sceGuClearColor(GU_RGBA(r, g, b, a)); + sceGuClearStencil(a); + sceGuClear(GU_COLOR_BUFFER_BIT | GU_STENCIL_BUFFER_BIT); + break; + } - case SDL_RENDERCMD_DRAW_POINTS: { - const size_t count = cmd->data.draw.count; - const VertV *verts = (VertV *) (gpumem + cmd->data.draw.first); + case SDL_RENDERCMD_DRAW_POINTS: + { + const size_t count = cmd->data.draw.count; + const VertV *verts = (VertV *)(gpumem + cmd->data.draw.first); + const Uint8 r = cmd->data.draw.r; + const Uint8 g = cmd->data.draw.g; + const Uint8 b = cmd->data.draw.b; + const Uint8 a = cmd->data.draw.a; + PSP_BlendState state = { + .color = GU_RGBA(r, g, b, a), + .texture = NULL, + .mode = cmd->data.draw.blend, + .shadeModel = GU_FLAT + }; + PSP_SetBlendState(data, &state); + sceGuDrawArray(GU_POINTS, GU_VERTEX_32BITF | GU_TRANSFORM_2D, count, 0, verts); + break; + } + + case SDL_RENDERCMD_DRAW_LINES: + { + const size_t count = cmd->data.draw.count; + const VertV *verts = (VertV *)(gpumem + cmd->data.draw.first); + const Uint8 r = cmd->data.draw.r; + const Uint8 g = cmd->data.draw.g; + const Uint8 b = cmd->data.draw.b; + const Uint8 a = cmd->data.draw.a; + PSP_BlendState state = { + .color = GU_RGBA(r, g, b, a), + .texture = NULL, + .mode = cmd->data.draw.blend, + .shadeModel = GU_FLAT + }; + PSP_SetBlendState(data, &state); + sceGuDrawArray(GU_LINE_STRIP, GU_VERTEX_32BITF | GU_TRANSFORM_2D, count, 0, verts); + break; + } + + case SDL_RENDERCMD_FILL_RECTS: + { + const size_t count = cmd->data.draw.count; + const VertV *verts = (VertV *)(gpumem + cmd->data.draw.first); + const Uint8 r = cmd->data.draw.r; + const Uint8 g = cmd->data.draw.g; + const Uint8 b = cmd->data.draw.b; + const Uint8 a = cmd->data.draw.a; + PSP_BlendState state = { + .color = GU_RGBA(r, g, b, a), + .texture = NULL, + .mode = cmd->data.draw.blend, + .shadeModel = GU_FLAT + }; + PSP_SetBlendState(data, &state); + sceGuDrawArray(GU_SPRITES, GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2 * count, 0, verts); + break; + } + + case SDL_RENDERCMD_COPY: + { + const size_t count = cmd->data.draw.count; + const VertTV *verts = (VertTV *)(gpumem + cmd->data.draw.first); + const Uint8 a = cmd->data.draw.a; + const Uint8 r = cmd->data.draw.r; + const Uint8 g = cmd->data.draw.g; + const Uint8 b = cmd->data.draw.b; + PSP_BlendState state = { + .color = GU_RGBA(r, g, b, a), + .texture = cmd->data.draw.texture, + .mode = cmd->data.draw.blend, + .shadeModel = GU_SMOOTH + }; + PSP_SetBlendState(data, &state); + sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2 * count, 0, verts); + break; + } + + case SDL_RENDERCMD_COPY_EX: + { + const VertTV *verts = (VertTV *)(gpumem + cmd->data.draw.first); + const Uint8 a = cmd->data.draw.a; + const Uint8 r = cmd->data.draw.r; + const Uint8 g = cmd->data.draw.g; + const Uint8 b = cmd->data.draw.b; + PSP_BlendState state = { + .color = GU_RGBA(r, g, b, a), + .texture = cmd->data.draw.texture, + .mode = cmd->data.draw.blend, + .shadeModel = GU_SMOOTH + }; + PSP_SetBlendState(data, &state); + sceGuDrawArray(GU_TRIANGLE_FAN, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 4, 0, verts); + break; + } + + case SDL_RENDERCMD_GEOMETRY: + { + const size_t count = cmd->data.draw.count; + if (cmd->data.draw.texture == NULL) { + const VertCV *verts = (VertCV *)(gpumem + cmd->data.draw.first); + sceGuDisable(GU_TEXTURE_2D); + /* In GU_SMOOTH mode */ + sceGuDrawArray(GU_TRIANGLES, GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_2D, count, 0, verts); + sceGuEnable(GU_TEXTURE_2D); + } else { + const VertTCV *verts = (VertTCV *)(gpumem + cmd->data.draw.first); + const Uint8 a = cmd->data.draw.a; const Uint8 r = cmd->data.draw.r; const Uint8 g = cmd->data.draw.g; const Uint8 b = cmd->data.draw.b; - const Uint8 a = cmd->data.draw.a; PSP_BlendState state = { - .color = GU_RGBA(r,g,b,a), + .color = GU_RGBA(r, g, b, a), .texture = NULL, .mode = cmd->data.draw.blend, .shadeModel = GU_FLAT }; + TextureActivate(cmd->data.draw.texture); PSP_SetBlendState(data, &state); - sceGuDrawArray(GU_POINTS, GU_VERTEX_32BITF|GU_TRANSFORM_2D, count, 0, verts); - break; + sceGuDrawArray(GU_TRIANGLES, GU_TEXTURE_32BITF | GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_2D, count, 0, verts); } + break; + } - case SDL_RENDERCMD_DRAW_LINES: { - const size_t count = cmd->data.draw.count; - const VertV *verts = (VertV *) (gpumem + cmd->data.draw.first); - const Uint8 r = cmd->data.draw.r; - const Uint8 g = cmd->data.draw.g; - const Uint8 b = cmd->data.draw.b; - const Uint8 a = cmd->data.draw.a; - PSP_BlendState state = { - .color = GU_RGBA(r,g,b,a), - .texture = NULL, - .mode = cmd->data.draw.blend, - .shadeModel = GU_FLAT - }; - PSP_SetBlendState(data, &state); - sceGuDrawArray(GU_LINE_STRIP, GU_VERTEX_32BITF|GU_TRANSFORM_2D, count, 0, verts); - break; - } - - case SDL_RENDERCMD_FILL_RECTS: { - const size_t count = cmd->data.draw.count; - const VertV *verts = (VertV *) (gpumem + cmd->data.draw.first); - const Uint8 r = cmd->data.draw.r; - const Uint8 g = cmd->data.draw.g; - const Uint8 b = cmd->data.draw.b; - const Uint8 a = cmd->data.draw.a; - PSP_BlendState state = { - .color = GU_RGBA(r,g,b,a), - .texture = NULL, - .mode = cmd->data.draw.blend, - .shadeModel = GU_FLAT - }; - PSP_SetBlendState(data, &state); - sceGuDrawArray(GU_SPRITES, GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2 * count, 0, verts); - break; - } - - case SDL_RENDERCMD_COPY: { - const size_t count = cmd->data.draw.count; - const VertTV *verts = (VertTV *) (gpumem + cmd->data.draw.first); - const Uint8 a = cmd->data.draw.a; - const Uint8 r = cmd->data.draw.r; - const Uint8 g = cmd->data.draw.g; - const Uint8 b = cmd->data.draw.b; - PSP_BlendState state = { - .color = GU_RGBA(r,g,b,a), - .texture = cmd->data.draw.texture, - .mode = cmd->data.draw.blend, - .shadeModel = GU_SMOOTH - }; - PSP_SetBlendState(data, &state); - sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2 * count, 0, verts); - break; - } - - case SDL_RENDERCMD_COPY_EX: { - const VertTV *verts = (VertTV *) (gpumem + cmd->data.draw.first); - const Uint8 a = cmd->data.draw.a; - const Uint8 r = cmd->data.draw.r; - const Uint8 g = cmd->data.draw.g; - const Uint8 b = cmd->data.draw.b; - PSP_BlendState state = { - .color = GU_RGBA(r,g,b,a), - .texture = cmd->data.draw.texture, - .mode = cmd->data.draw.blend, - .shadeModel = GU_SMOOTH - }; - PSP_SetBlendState(data, &state); - sceGuDrawArray(GU_TRIANGLE_FAN, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 4, 0, verts); - break; - } - - case SDL_RENDERCMD_GEOMETRY: { - const size_t count = cmd->data.draw.count; - if (cmd->data.draw.texture == NULL) { - const VertCV *verts = (VertCV *) (gpumem + cmd->data.draw.first); - sceGuDisable(GU_TEXTURE_2D); - /* In GU_SMOOTH mode */ - sceGuDrawArray(GU_TRIANGLES, GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_2D, count, 0, verts); - sceGuEnable(GU_TEXTURE_2D); - } else { - const VertTCV *verts = (VertTCV *) (gpumem + cmd->data.draw.first); - const Uint8 a = cmd->data.draw.a; - const Uint8 r = cmd->data.draw.r; - const Uint8 g = cmd->data.draw.g; - const Uint8 b = cmd->data.draw.b; - PSP_BlendState state = { - .color = GU_RGBA(r,g,b,a), - .texture = NULL, - .mode = cmd->data.draw.blend, - .shadeModel = GU_FLAT - }; - TextureActivate(cmd->data.draw.texture); - PSP_SetBlendState(data, &state); - sceGuDrawArray(GU_TRIANGLES, GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_2D, count, 0, verts); - } - break; - } - - case SDL_RENDERCMD_NO_OP: - break; + case SDL_RENDERCMD_NO_OP: + break; } cmd = cmd->next; @@ -1249,24 +1211,22 @@ PSP_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti return 0; } -static int -PSP_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 pixel_format, void * pixels, int pitch) +static int PSP_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, + Uint32 pixel_format, void *pixels, int pitch) { return SDL_Unsupported(); } -static int -PSP_RenderPresent(SDL_Renderer * renderer) +static int PSP_RenderPresent(SDL_Renderer *renderer) { - PSP_RenderData *data = (PSP_RenderData *) renderer->driverdata; + PSP_RenderData *data = (PSP_RenderData *)renderer->driverdata; if (!data->displayListAvail) { return -1; } data->displayListAvail = SDL_FALSE; sceGuFinish(); - sceGuSync(0,0); + sceGuSync(0, 0); if ((data->vsync) && (data->vblank_not_reached)) { sceDisplayWaitVblankStart(); @@ -1279,11 +1239,10 @@ PSP_RenderPresent(SDL_Renderer * renderer) return 0; } -static void -PSP_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static void PSP_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - PSP_RenderData *renderdata = (PSP_RenderData *) renderer->driverdata; - PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; + PSP_RenderData *renderdata = (PSP_RenderData *)renderer->driverdata; + PSP_TextureData *psp_texture = (PSP_TextureData *)texture->driverdata; if (renderdata == NULL) { return; @@ -1299,10 +1258,9 @@ PSP_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) texture->driverdata = NULL; } -static void -PSP_DestroyRenderer(SDL_Renderer * renderer) +static void PSP_DestroyRenderer(SDL_Renderer *renderer) { - PSP_RenderData *data = (PSP_RenderData *) renderer->driverdata; + PSP_RenderData *data = (PSP_RenderData *)renderer->driverdata; if (data) { if (!data->initialized) { return; @@ -1311,7 +1269,7 @@ PSP_DestroyRenderer(SDL_Renderer * renderer) StartDrawing(renderer); sceKernelDisableSubIntr(PSP_VBLANK_INT, 0); - sceKernelReleaseSubIntrHandler(PSP_VBLANK_INT,0); + sceKernelReleaseSubIntrHandler(PSP_VBLANK_INT, 0); sceDisplayWaitVblankStart(); sceGuDisplay(GU_FALSE); sceGuTerm(); @@ -1325,8 +1283,7 @@ PSP_DestroyRenderer(SDL_Renderer * renderer) SDL_free(renderer); } -static int -PSP_SetVSync(SDL_Renderer * renderer, const int vsync) +static int PSP_SetVSync(SDL_Renderer *renderer, const int vsync) { PSP_RenderData *data = renderer->driverdata; data->vsync = vsync; @@ -1334,28 +1291,27 @@ PSP_SetVSync(SDL_Renderer * renderer, const int vsync) } SDL_Renderer * -PSP_CreateRenderer(SDL_Window * window, Uint32 flags) +PSP_CreateRenderer(SDL_Window *window, Uint32 flags) { SDL_Renderer *renderer; PSP_RenderData *data; int pixelformat; - void* doublebuffer = NULL; + void *doublebuffer = NULL; - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); if (renderer == NULL) { SDL_OutOfMemory(); return NULL; } - data = (PSP_RenderData *) SDL_calloc(1, sizeof(*data)); + data = (PSP_RenderData *)SDL_calloc(1, sizeof(*data)); if (data == NULL) { PSP_DestroyRenderer(renderer); SDL_OutOfMemory(); return NULL; } - renderer->WindowEvent = PSP_WindowEvent; renderer->CreateTexture = PSP_CreateTexture; renderer->UpdateTexture = PSP_UpdateTexture; @@ -1364,9 +1320,9 @@ PSP_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->SetTextureScaleMode = PSP_SetTextureScaleMode; renderer->SetRenderTarget = PSP_SetRenderTarget; renderer->QueueSetViewport = PSP_QueueSetViewport; - renderer->QueueSetDrawColor = PSP_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */ + renderer->QueueSetDrawColor = PSP_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */ renderer->QueueDrawPoints = PSP_QueueDrawPoints; - renderer->QueueDrawLines = PSP_QueueDrawPoints; /* lines and points queue vertices the same way. */ + renderer->QueueDrawLines = PSP_QueueDrawPoints; /* lines and points queue vertices the same way. */ renderer->QueueGeometry = PSP_QueueGeometry; renderer->QueueFillRects = PSP_QueueFillRects; renderer->QueueCopy = PSP_QueueCopy; @@ -1392,24 +1348,23 @@ PSP_CreateRenderer(SDL_Window * window, Uint32 flags) data->vsync = SDL_FALSE; } - pixelformat=PixelFormatToPSPFMT(SDL_GetWindowPixelFormat(window)); - switch(pixelformat) - { - case GU_PSM_4444: - case GU_PSM_5650: - case GU_PSM_5551: - data->bpp = 2; - data->psm = pixelformat; - break; - default: - data->bpp = 4; - data->psm = GU_PSM_8888; - break; + pixelformat = PixelFormatToPSPFMT(SDL_GetWindowPixelFormat(window)); + switch (pixelformat) { + case GU_PSM_4444: + case GU_PSM_5650: + case GU_PSM_5551: + data->bpp = 2; + data->psm = pixelformat; + break; + default: + data->bpp = 4; + data->psm = GU_PSM_8888; + break; } - doublebuffer = vramalloc(PSP_FRAME_BUFFER_SIZE*data->bpp*2); + doublebuffer = vramalloc(PSP_FRAME_BUFFER_SIZE * data->bpp * 2); data->backbuffer = doublebuffer; - data->frontbuffer = ((uint8_t*)doublebuffer)+PSP_FRAME_BUFFER_SIZE*data->bpp; + data->frontbuffer = ((uint8_t *)doublebuffer) + PSP_FRAME_BUFFER_SIZE * data->bpp; sceGuInit(); /* setup GU */ @@ -1417,11 +1372,9 @@ PSP_CreateRenderer(SDL_Window * window, Uint32 flags) sceGuDrawBuffer(data->psm, vrelptr(data->frontbuffer), PSP_FRAME_BUFFER_WIDTH); sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, vrelptr(data->backbuffer), PSP_FRAME_BUFFER_WIDTH); - - sceGuOffset(2048 - (PSP_SCREEN_WIDTH>>1), 2048 - (PSP_SCREEN_HEIGHT>>1)); + sceGuOffset(2048 - (PSP_SCREEN_WIDTH >> 1), 2048 - (PSP_SCREEN_HEIGHT >> 1)); sceGuViewport(2048, 2048, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); - sceGuDisable(GU_DEPTH_TEST); /* Scissoring */ @@ -1435,11 +1388,11 @@ PSP_CreateRenderer(SDL_Window * window, Uint32 flags) sceGuEnable(GU_CULL_FACE); */ - //Setup initial blend state + // Setup initial blend state ResetBlendState(&data->blendState); sceGuFinish(); - sceGuSync(0,0); + sceGuSync(0, 0); sceDisplayWaitVblankStartCB(); sceGuDisplay(GU_TRUE); @@ -1457,17 +1410,17 @@ SDL_RenderDriver PSP_RenderDriver = { .name = "PSP", .flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE, .num_texture_formats = 4, - .texture_formats = { [0] = SDL_PIXELFORMAT_BGR565, - [1] = SDL_PIXELFORMAT_ABGR1555, - [2] = SDL_PIXELFORMAT_ABGR4444, - [3] = SDL_PIXELFORMAT_ABGR8888, + .texture_formats = { + [0] = SDL_PIXELFORMAT_BGR565, + [1] = SDL_PIXELFORMAT_ABGR1555, + [2] = SDL_PIXELFORMAT_ABGR4444, + [3] = SDL_PIXELFORMAT_ABGR8888, }, .max_texture_width = 512, .max_texture_height = 512, - } + } }; #endif /* SDL_VIDEO_RENDER_PSP */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/render/software/SDL_blendfillrect.c b/src/render/software/SDL_blendfillrect.c index d06823243..3f8a0454b 100644 --- a/src/render/software/SDL_blendfillrect.c +++ b/src/render/software/SDL_blendfillrect.c @@ -25,10 +25,8 @@ #include "SDL_draw.h" #include "SDL_blendfillrect.h" - -static int -SDL_BlendFillRect_RGB555(SDL_Surface * dst, const SDL_Rect * rect, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +static int SDL_BlendFillRect_RGB555(SDL_Surface *dst, const SDL_Rect *rect, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { unsigned inva = 0xff - a; @@ -52,9 +50,8 @@ SDL_BlendFillRect_RGB555(SDL_Surface * dst, const SDL_Rect * rect, return 0; } -static int -SDL_BlendFillRect_RGB565(SDL_Surface * dst, const SDL_Rect * rect, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +static int SDL_BlendFillRect_RGB565(SDL_Surface *dst, const SDL_Rect *rect, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { unsigned inva = 0xff - a; @@ -78,9 +75,8 @@ SDL_BlendFillRect_RGB565(SDL_Surface * dst, const SDL_Rect * rect, return 0; } -static int -SDL_BlendFillRect_RGB888(SDL_Surface * dst, const SDL_Rect * rect, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +static int SDL_BlendFillRect_RGB888(SDL_Surface *dst, const SDL_Rect *rect, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { unsigned inva = 0xff - a; @@ -104,9 +100,8 @@ SDL_BlendFillRect_RGB888(SDL_Surface * dst, const SDL_Rect * rect, return 0; } -static int -SDL_BlendFillRect_ARGB8888(SDL_Surface * dst, const SDL_Rect * rect, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +static int SDL_BlendFillRect_ARGB8888(SDL_Surface *dst, const SDL_Rect *rect, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { unsigned inva = 0xff - a; @@ -130,9 +125,8 @@ SDL_BlendFillRect_ARGB8888(SDL_Surface * dst, const SDL_Rect * rect, return 0; } -static int -SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +static int SDL_BlendFillRect_RGB(SDL_Surface *dst, const SDL_Rect *rect, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { SDL_PixelFormat *fmt = dst->format; unsigned inva = 0xff - a; @@ -181,9 +175,8 @@ SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect, } } -static int -SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +static int SDL_BlendFillRect_RGBA(SDL_Surface *dst, const SDL_Rect *rect, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { SDL_PixelFormat *fmt = dst->format; unsigned inva = 0xff - a; @@ -213,9 +206,8 @@ SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect, } } -int -SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { SDL_Rect clipped; @@ -280,13 +272,12 @@ SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect, } } -int -SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect * rects, int count, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { SDL_Rect rect; int i; - int (*func)(SDL_Surface * dst, const SDL_Rect * rect, + int (*func)(SDL_Surface * dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL; int status = 0; diff --git a/src/render/software/SDL_blendfillrect.h b/src/render/software/SDL_blendfillrect.h index 8ee62b198..85145c3df 100644 --- a/src/render/software/SDL_blendfillrect.h +++ b/src/render/software/SDL_blendfillrect.h @@ -24,9 +24,8 @@ #include "../../SDL_internal.h" - -extern int SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); -extern int SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect * rects, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); +extern int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); +extern int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); #endif /* SDL_blendfillrect_h_ */ diff --git a/src/render/software/SDL_blendline.c b/src/render/software/SDL_blendline.c index f7631c292..1b0057f72 100644 --- a/src/render/software/SDL_blendline.c +++ b/src/render/software/SDL_blendline.c @@ -26,11 +26,9 @@ #include "SDL_blendline.h" #include "SDL_blendpoint.h" - -static void -SDL_BlendLine_RGB2(SDL_Surface * dst, int x1, int y1, int x2, int y2, - SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, - SDL_bool draw_end) +static void SDL_BlendLine_RGB2(SDL_Surface *dst, int x1, int y1, int x2, int y2, + SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, + SDL_bool draw_end) { const SDL_PixelFormat *fmt = dst->format; unsigned r, g, b, a, inva; @@ -133,10 +131,9 @@ SDL_BlendLine_RGB2(SDL_Surface * dst, int x1, int y1, int x2, int y2, } } -static void -SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2, - SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, - SDL_bool draw_end) +static void SDL_BlendLine_RGB555(SDL_Surface *dst, int x1, int y1, int x2, int y2, + SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, + SDL_bool draw_end) { unsigned r, g, b, a, inva; @@ -238,10 +235,9 @@ SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2, } } -static void -SDL_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2, - SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, - SDL_bool draw_end) +static void SDL_BlendLine_RGB565(SDL_Surface *dst, int x1, int y1, int x2, int y2, + SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, + SDL_bool draw_end) { unsigned r, g, b, a, inva; @@ -343,10 +339,9 @@ SDL_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2, } } -static void -SDL_BlendLine_RGB4(SDL_Surface * dst, int x1, int y1, int x2, int y2, - SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, - SDL_bool draw_end) +static void SDL_BlendLine_RGB4(SDL_Surface *dst, int x1, int y1, int x2, int y2, + SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, + SDL_bool draw_end) { const SDL_PixelFormat *fmt = dst->format; unsigned r, g, b, a, inva; @@ -449,10 +444,9 @@ SDL_BlendLine_RGB4(SDL_Surface * dst, int x1, int y1, int x2, int y2, } } -static void -SDL_BlendLine_RGBA4(SDL_Surface * dst, int x1, int y1, int x2, int y2, - SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, - SDL_bool draw_end) +static void SDL_BlendLine_RGBA4(SDL_Surface *dst, int x1, int y1, int x2, int y2, + SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, + SDL_bool draw_end) { const SDL_PixelFormat *fmt = dst->format; unsigned r, g, b, a, inva; @@ -555,10 +549,9 @@ SDL_BlendLine_RGBA4(SDL_Surface * dst, int x1, int y1, int x2, int y2, } } -static void -SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2, - SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, - SDL_bool draw_end) +static void SDL_BlendLine_RGB888(SDL_Surface *dst, int x1, int y1, int x2, int y2, + SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, + SDL_bool draw_end) { unsigned r, g, b, a, inva; @@ -660,10 +653,9 @@ SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2, } } -static void -SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2, - SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, - SDL_bool draw_end) +static void SDL_BlendLine_ARGB8888(SDL_Surface *dst, int x1, int y1, int x2, int y2, + SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, + SDL_bool draw_end) { unsigned r, g, b, a, inva; @@ -765,14 +757,13 @@ SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2, } } -typedef void (*BlendLineFunc) (SDL_Surface * dst, - int x1, int y1, int x2, int y2, - SDL_BlendMode blendMode, - Uint8 r, Uint8 g, Uint8 b, Uint8 a, - SDL_bool draw_end); +typedef void (*BlendLineFunc)(SDL_Surface *dst, + int x1, int y1, int x2, int y2, + SDL_BlendMode blendMode, + Uint8 r, Uint8 g, Uint8 b, Uint8 a, + SDL_bool draw_end); -static BlendLineFunc -SDL_CalculateBlendLineFunc(const SDL_PixelFormat * fmt) +static BlendLineFunc SDL_CalculateBlendLineFunc(const SDL_PixelFormat *fmt) { switch (fmt->BytesPerPixel) { case 2: @@ -802,9 +793,8 @@ SDL_CalculateBlendLineFunc(const SDL_PixelFormat * fmt) return NULL; } -int -SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +int SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { BlendLineFunc func; @@ -827,9 +817,8 @@ SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, return 0; } -int -SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { int i; int x1, y1; @@ -847,8 +836,8 @@ SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count, } for (i = 1; i < count; ++i) { - x1 = points[i-1].x; - y1 = points[i-1].y; + x1 = points[i - 1].x; + y1 = points[i - 1].y; x2 = points[i].x; y2 = points[i].y; @@ -863,8 +852,8 @@ SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count, func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, draw_end); } - if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) { - SDL_BlendPoint(dst, points[count-1].x, points[count-1].y, + if (points[0].x != points[count - 1].x || points[0].y != points[count - 1].y) { + SDL_BlendPoint(dst, points[count - 1].x, points[count - 1].y, blendMode, r, g, b, a); } return 0; diff --git a/src/render/software/SDL_blendline.h b/src/render/software/SDL_blendline.h index a844110c4..8490b244d 100644 --- a/src/render/software/SDL_blendline.h +++ b/src/render/software/SDL_blendline.h @@ -24,9 +24,8 @@ #include "../../SDL_internal.h" - -extern int SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); -extern int SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); +extern int SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); +extern int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); #endif /* SDL_blendline_h_ */ diff --git a/src/render/software/SDL_blendpoint.c b/src/render/software/SDL_blendpoint.c index ffbf86677..aae9a307a 100644 --- a/src/render/software/SDL_blendpoint.c +++ b/src/render/software/SDL_blendpoint.c @@ -25,10 +25,8 @@ #include "SDL_draw.h" #include "SDL_blendpoint.h" - -static int -SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, - Uint8 g, Uint8 b, Uint8 a) +static int SDL_BlendPoint_RGB555(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, + Uint8 g, Uint8 b, Uint8 a) { unsigned inva = 0xff - a; @@ -52,9 +50,8 @@ SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, return 0; } -static int -SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, - Uint8 g, Uint8 b, Uint8 a) +static int SDL_BlendPoint_RGB565(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, + Uint8 g, Uint8 b, Uint8 a) { unsigned inva = 0xff - a; @@ -78,9 +75,8 @@ SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, return 0; } -static int -SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, - Uint8 g, Uint8 b, Uint8 a) +static int SDL_BlendPoint_RGB888(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, + Uint8 g, Uint8 b, Uint8 a) { unsigned inva = 0xff - a; @@ -104,9 +100,8 @@ SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, return 0; } -static int -SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, - Uint8 r, Uint8 g, Uint8 b, Uint8 a) +static int SDL_BlendPoint_ARGB8888(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, + Uint8 r, Uint8 g, Uint8 b, Uint8 a) { unsigned inva = 0xff - a; @@ -130,9 +125,8 @@ SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode return 0; } -static int -SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, - Uint8 g, Uint8 b, Uint8 a) +static int SDL_BlendPoint_RGB(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, + Uint8 g, Uint8 b, Uint8 a) { SDL_PixelFormat *fmt = dst->format; unsigned inva = 0xff - a; @@ -181,9 +175,8 @@ SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uin } } -static int -SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, - Uint8 g, Uint8 b, Uint8 a) +static int SDL_BlendPoint_RGBA(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, + Uint8 g, Uint8 b, Uint8 a) { SDL_PixelFormat *fmt = dst->format; unsigned inva = 0xff - a; @@ -213,9 +206,8 @@ SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Ui } } -int -SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, - Uint8 g, Uint8 b, Uint8 a) +int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, + Uint8 g, Uint8 b, Uint8 a) { if (dst == NULL) { return SDL_InvalidParamError("SDL_BlendPoint(): dst"); @@ -274,9 +266,8 @@ SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r } } -int -SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, + SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { int minx, miny; int maxx, maxy; diff --git a/src/render/software/SDL_blendpoint.h b/src/render/software/SDL_blendpoint.h index bf6ddec07..33dbc9c2a 100644 --- a/src/render/software/SDL_blendpoint.h +++ b/src/render/software/SDL_blendpoint.h @@ -24,9 +24,8 @@ #include "../../SDL_internal.h" - -extern int SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); -extern int SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); +extern int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); +extern int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); #endif /* SDL_blendpoint_h_ */ diff --git a/src/render/software/SDL_draw.h b/src/render/software/SDL_draw.h index 2acb3d3a1..5159013df 100644 --- a/src/render/software/SDL_draw.h +++ b/src/render/software/SDL_draw.h @@ -26,77 +26,93 @@ * and in the blend and add case, the RGB values are premultiplied by a. */ -#define DRAW_MUL(_a, _b) (((unsigned)(_a)*(_b))/255) +#define DRAW_MUL(_a, _b) (((unsigned)(_a) * (_b)) / 255) #define DRAW_FASTSETPIXEL(type) \ - *pixel = (type) color + *pixel = (type)color #define DRAW_FASTSETPIXEL1 DRAW_FASTSETPIXEL(Uint8) #define DRAW_FASTSETPIXEL2 DRAW_FASTSETPIXEL(Uint16) #define DRAW_FASTSETPIXEL4 DRAW_FASTSETPIXEL(Uint32) #define DRAW_FASTSETPIXELXY(x, y, type, bpp, color) \ - *(type *)((Uint8 *)dst->pixels + (y) * dst->pitch \ - + (x) * bpp) = (type) color + *(type *)((Uint8 *)dst->pixels + (y)*dst->pitch + (x)*bpp) = (type)color #define DRAW_FASTSETPIXELXY1(x, y) DRAW_FASTSETPIXELXY(x, y, Uint8, 1, color) #define DRAW_FASTSETPIXELXY2(x, y) DRAW_FASTSETPIXELXY(x, y, Uint16, 2, color) #define DRAW_FASTSETPIXELXY4(x, y) DRAW_FASTSETPIXELXY(x, y, Uint32, 4, color) -#define DRAW_SETPIXEL(setpixel) \ -do { \ - unsigned sr = r, sg = g, sb = b, sa = a; (void) sa; \ - setpixel; \ -} while (0) +#define DRAW_SETPIXEL(setpixel) \ + do { \ + unsigned sr = r, sg = g, sb = b, sa = a; \ + (void)sa; \ + setpixel; \ + } while (0) #define DRAW_SETPIXEL_BLEND(getpixel, setpixel) \ -do { \ - unsigned sr, sg, sb, sa = 0xFF; \ - getpixel; \ - sr = DRAW_MUL(inva, sr) + r; \ - sg = DRAW_MUL(inva, sg) + g; \ - sb = DRAW_MUL(inva, sb) + b; \ - sa = DRAW_MUL(inva, sa) + a; \ - setpixel; \ -} while (0) + do { \ + unsigned sr, sg, sb, sa = 0xFF; \ + getpixel; \ + sr = DRAW_MUL(inva, sr) + r; \ + sg = DRAW_MUL(inva, sg) + g; \ + sb = DRAW_MUL(inva, sb) + b; \ + sa = DRAW_MUL(inva, sa) + a; \ + setpixel; \ + } while (0) #define DRAW_SETPIXEL_ADD(getpixel, setpixel) \ -do { \ - unsigned sr, sg, sb, sa; (void) sa; \ - getpixel; \ - sr += r; if (sr > 0xff) sr = 0xff; \ - sg += g; if (sg > 0xff) sg = 0xff; \ - sb += b; if (sb > 0xff) sb = 0xff; \ - setpixel; \ -} while (0) + do { \ + unsigned sr, sg, sb, sa; \ + (void)sa; \ + getpixel; \ + sr += r; \ + if (sr > 0xff) \ + sr = 0xff; \ + sg += g; \ + if (sg > 0xff) \ + sg = 0xff; \ + sb += b; \ + if (sb > 0xff) \ + sb = 0xff; \ + setpixel; \ + } while (0) #define DRAW_SETPIXEL_MOD(getpixel, setpixel) \ -do { \ - unsigned sr, sg, sb, sa; (void) sa; \ - getpixel; \ - sr = DRAW_MUL(sr, r); \ - sg = DRAW_MUL(sg, g); \ - sb = DRAW_MUL(sb, b); \ - setpixel; \ -} while (0) + do { \ + unsigned sr, sg, sb, sa; \ + (void)sa; \ + getpixel; \ + sr = DRAW_MUL(sr, r); \ + sg = DRAW_MUL(sg, g); \ + sb = DRAW_MUL(sb, b); \ + setpixel; \ + } while (0) -#define DRAW_SETPIXEL_MUL(getpixel, setpixel) \ -do { \ - unsigned sr, sg, sb, sa; sa = 0xFF; \ - getpixel; \ - sr = DRAW_MUL(sr, r) + DRAW_MUL(inva, sr); if (sr > 0xff) sr = 0xff; \ - sg = DRAW_MUL(sg, g) + DRAW_MUL(inva, sg); if (sg > 0xff) sg = 0xff; \ - sb = DRAW_MUL(sb, b) + DRAW_MUL(inva, sb); if (sb > 0xff) sb = 0xff; \ - sa = DRAW_MUL(sa, a) + DRAW_MUL(inva, sa); if (sa > 0xff) sa = 0xff; \ - setpixel; \ -} while (0) +#define DRAW_SETPIXEL_MUL(getpixel, setpixel) \ + do { \ + unsigned sr, sg, sb, sa; \ + sa = 0xFF; \ + getpixel; \ + sr = DRAW_MUL(sr, r) + DRAW_MUL(inva, sr); \ + if (sr > 0xff) \ + sr = 0xff; \ + sg = DRAW_MUL(sg, g) + DRAW_MUL(inva, sg); \ + if (sg > 0xff) \ + sg = 0xff; \ + sb = DRAW_MUL(sb, b) + DRAW_MUL(inva, sb); \ + if (sb > 0xff) \ + sb = 0xff; \ + sa = DRAW_MUL(sa, a) + DRAW_MUL(inva, sa); \ + if (sa > 0xff) \ + sa = 0xff; \ + setpixel; \ + } while (0) -#define DRAW_SETPIXELXY(x, y, type, bpp, op) \ -do { \ - type *pixel = (type *)((Uint8 *)dst->pixels + (y) * dst->pitch \ - + (x) * bpp); \ - op; \ -} while (0) +#define DRAW_SETPIXELXY(x, y, type, bpp, op) \ + do { \ + type *pixel = (type *)((Uint8 *)dst->pixels + (y)*dst->pitch + (x)*bpp); \ + op; \ + } while (0) /* * Define draw operators for RGB555 @@ -105,19 +121,19 @@ do { \ #define DRAW_SETPIXEL_RGB555 \ DRAW_SETPIXEL(RGB555_FROM_RGB(*pixel, sr, sg, sb)) -#define DRAW_SETPIXEL_BLEND_RGB555 \ +#define DRAW_SETPIXEL_BLEND_RGB555 \ DRAW_SETPIXEL_BLEND(RGB_FROM_RGB555(*pixel, sr, sg, sb), \ RGB555_FROM_RGB(*pixel, sr, sg, sb)) -#define DRAW_SETPIXEL_ADD_RGB555 \ +#define DRAW_SETPIXEL_ADD_RGB555 \ DRAW_SETPIXEL_ADD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \ RGB555_FROM_RGB(*pixel, sr, sg, sb)) -#define DRAW_SETPIXEL_MOD_RGB555 \ +#define DRAW_SETPIXEL_MOD_RGB555 \ DRAW_SETPIXEL_MOD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \ RGB555_FROM_RGB(*pixel, sr, sg, sb)) -#define DRAW_SETPIXEL_MUL_RGB555 \ +#define DRAW_SETPIXEL_MUL_RGB555 \ DRAW_SETPIXEL_MUL(RGB_FROM_RGB555(*pixel, sr, sg, sb), \ RGB555_FROM_RGB(*pixel, sr, sg, sb)) @@ -143,19 +159,19 @@ do { \ #define DRAW_SETPIXEL_RGB565 \ DRAW_SETPIXEL(RGB565_FROM_RGB(*pixel, sr, sg, sb)) -#define DRAW_SETPIXEL_BLEND_RGB565 \ +#define DRAW_SETPIXEL_BLEND_RGB565 \ DRAW_SETPIXEL_BLEND(RGB_FROM_RGB565(*pixel, sr, sg, sb), \ RGB565_FROM_RGB(*pixel, sr, sg, sb)) -#define DRAW_SETPIXEL_ADD_RGB565 \ +#define DRAW_SETPIXEL_ADD_RGB565 \ DRAW_SETPIXEL_ADD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \ RGB565_FROM_RGB(*pixel, sr, sg, sb)) -#define DRAW_SETPIXEL_MOD_RGB565 \ +#define DRAW_SETPIXEL_MOD_RGB565 \ DRAW_SETPIXEL_MOD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \ RGB565_FROM_RGB(*pixel, sr, sg, sb)) -#define DRAW_SETPIXEL_MUL_RGB565 \ +#define DRAW_SETPIXEL_MUL_RGB565 \ DRAW_SETPIXEL_MUL(RGB_FROM_RGB565(*pixel, sr, sg, sb), \ RGB565_FROM_RGB(*pixel, sr, sg, sb)) @@ -181,19 +197,19 @@ do { \ #define DRAW_SETPIXEL_RGB888 \ DRAW_SETPIXEL(RGB888_FROM_RGB(*pixel, sr, sg, sb)) -#define DRAW_SETPIXEL_BLEND_RGB888 \ +#define DRAW_SETPIXEL_BLEND_RGB888 \ DRAW_SETPIXEL_BLEND(RGB_FROM_RGB888(*pixel, sr, sg, sb), \ RGB888_FROM_RGB(*pixel, sr, sg, sb)) -#define DRAW_SETPIXEL_ADD_RGB888 \ +#define DRAW_SETPIXEL_ADD_RGB888 \ DRAW_SETPIXEL_ADD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \ RGB888_FROM_RGB(*pixel, sr, sg, sb)) -#define DRAW_SETPIXEL_MOD_RGB888 \ +#define DRAW_SETPIXEL_MOD_RGB888 \ DRAW_SETPIXEL_MOD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \ RGB888_FROM_RGB(*pixel, sr, sg, sb)) -#define DRAW_SETPIXEL_MUL_RGB888 \ +#define DRAW_SETPIXEL_MUL_RGB888 \ DRAW_SETPIXEL_MUL(RGB_FROM_RGB888(*pixel, sr, sg, sb), \ RGB888_FROM_RGB(*pixel, sr, sg, sb)) @@ -219,19 +235,19 @@ do { \ #define DRAW_SETPIXEL_ARGB8888 \ DRAW_SETPIXEL(ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa)) -#define DRAW_SETPIXEL_BLEND_ARGB8888 \ +#define DRAW_SETPIXEL_BLEND_ARGB8888 \ DRAW_SETPIXEL_BLEND(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \ ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa)) -#define DRAW_SETPIXEL_ADD_ARGB8888 \ +#define DRAW_SETPIXEL_ADD_ARGB8888 \ DRAW_SETPIXEL_ADD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \ ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa)) -#define DRAW_SETPIXEL_MOD_ARGB8888 \ +#define DRAW_SETPIXEL_MOD_ARGB8888 \ DRAW_SETPIXEL_MOD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \ ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa)) -#define DRAW_SETPIXEL_MUL_ARGB8888 \ +#define DRAW_SETPIXEL_MUL_ARGB8888 \ DRAW_SETPIXEL_MUL(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \ ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa)) @@ -257,19 +273,19 @@ do { \ #define DRAW_SETPIXEL_RGB \ DRAW_SETPIXEL(PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb)) -#define DRAW_SETPIXEL_BLEND_RGB \ +#define DRAW_SETPIXEL_BLEND_RGB \ DRAW_SETPIXEL_BLEND(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \ PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb)) -#define DRAW_SETPIXEL_ADD_RGB \ +#define DRAW_SETPIXEL_ADD_RGB \ DRAW_SETPIXEL_ADD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \ PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb)) -#define DRAW_SETPIXEL_MOD_RGB \ +#define DRAW_SETPIXEL_MOD_RGB \ DRAW_SETPIXEL_MOD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \ PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb)) -#define DRAW_SETPIXEL_MUL_RGB \ +#define DRAW_SETPIXEL_MUL_RGB \ DRAW_SETPIXEL_MUL(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \ PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb)) @@ -303,7 +319,6 @@ do { \ #define DRAW_SETPIXELXY4_MUL_RGB(x, y) \ DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MUL_RGB) - /* * Define draw operators for general RGBA */ @@ -311,19 +326,19 @@ do { \ #define DRAW_SETPIXEL_RGBA \ DRAW_SETPIXEL(PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa)) -#define DRAW_SETPIXEL_BLEND_RGBA \ +#define DRAW_SETPIXEL_BLEND_RGBA \ DRAW_SETPIXEL_BLEND(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \ PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa)) -#define DRAW_SETPIXEL_ADD_RGBA \ +#define DRAW_SETPIXEL_ADD_RGBA \ DRAW_SETPIXEL_ADD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \ PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa)) -#define DRAW_SETPIXEL_MOD_RGBA \ +#define DRAW_SETPIXEL_MOD_RGBA \ DRAW_SETPIXEL_MOD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \ PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa)) -#define DRAW_SETPIXEL_MUL_RGBA \ +#define DRAW_SETPIXEL_MUL_RGBA \ DRAW_SETPIXEL_MUL(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \ PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa)) @@ -349,284 +364,301 @@ do { \ #define ABS(_x) ((_x) < 0 ? -(_x) : (_x)) /* Horizontal line */ -#define HLINE(type, op, draw_end) \ -{ \ - int length; \ - int pitch = (dst->pitch / dst->format->BytesPerPixel); \ - type *pixel; \ - if (x1 <= x2) { \ - pixel = (type *)dst->pixels + y1 * pitch + x1; \ - length = draw_end ? (x2-x1+1) : (x2-x1); \ - } else { \ - pixel = (type *)dst->pixels + y1 * pitch + x2; \ - if (!draw_end) { \ - ++pixel; \ - } \ - length = draw_end ? (x1-x2+1) : (x1-x2); \ - } \ - while (length--) { \ - op; \ - ++pixel; \ - } \ -} +#define HLINE(type, op, draw_end) \ + { \ + int length; \ + int pitch = (dst->pitch / dst->format->BytesPerPixel); \ + type *pixel; \ + if (x1 <= x2) { \ + pixel = (type *)dst->pixels + y1 * pitch + x1; \ + length = draw_end ? (x2 - x1 + 1) : (x2 - x1); \ + } else { \ + pixel = (type *)dst->pixels + y1 * pitch + x2; \ + if (!draw_end) { \ + ++pixel; \ + } \ + length = draw_end ? (x1 - x2 + 1) : (x1 - x2); \ + } \ + while (length--) { \ + op; \ + ++pixel; \ + } \ + } /* Vertical line */ -#define VLINE(type, op, draw_end) \ -{ \ - int length; \ - int pitch = (dst->pitch / dst->format->BytesPerPixel); \ - type *pixel; \ - if (y1 <= y2) { \ - pixel = (type *)dst->pixels + y1 * pitch + x1; \ - length = draw_end ? (y2-y1+1) : (y2-y1); \ - } else { \ - pixel = (type *)dst->pixels + y2 * pitch + x1; \ - if (!draw_end) { \ - pixel += pitch; \ - } \ - length = draw_end ? (y1-y2+1) : (y1-y2); \ - } \ - while (length--) { \ - op; \ - pixel += pitch; \ - } \ -} +#define VLINE(type, op, draw_end) \ + { \ + int length; \ + int pitch = (dst->pitch / dst->format->BytesPerPixel); \ + type *pixel; \ + if (y1 <= y2) { \ + pixel = (type *)dst->pixels + y1 * pitch + x1; \ + length = draw_end ? (y2 - y1 + 1) : (y2 - y1); \ + } else { \ + pixel = (type *)dst->pixels + y2 * pitch + x1; \ + if (!draw_end) { \ + pixel += pitch; \ + } \ + length = draw_end ? (y1 - y2 + 1) : (y1 - y2); \ + } \ + while (length--) { \ + op; \ + pixel += pitch; \ + } \ + } /* Diagonal line */ -#define DLINE(type, op, draw_end) \ -{ \ - int length; \ - int pitch = (dst->pitch / dst->format->BytesPerPixel); \ - type *pixel; \ - if (y1 <= y2) { \ - pixel = (type *)dst->pixels + y1 * pitch + x1; \ - if (x1 <= x2) { \ - ++pitch; \ - } else { \ - --pitch; \ - } \ - length = (y2-y1); \ - } else { \ - pixel = (type *)dst->pixels + y2 * pitch + x2; \ - if (x2 <= x1) { \ - ++pitch; \ - } else { \ - --pitch; \ - } \ - if (!draw_end) { \ - pixel += pitch; \ - } \ - length = (y1-y2); \ - } \ - if (draw_end) { \ - ++length; \ - } \ - while (length--) { \ - op; \ - pixel += pitch; \ - } \ -} +#define DLINE(type, op, draw_end) \ + { \ + int length; \ + int pitch = (dst->pitch / dst->format->BytesPerPixel); \ + type *pixel; \ + if (y1 <= y2) { \ + pixel = (type *)dst->pixels + y1 * pitch + x1; \ + if (x1 <= x2) { \ + ++pitch; \ + } else { \ + --pitch; \ + } \ + length = (y2 - y1); \ + } else { \ + pixel = (type *)dst->pixels + y2 * pitch + x2; \ + if (x2 <= x1) { \ + ++pitch; \ + } else { \ + --pitch; \ + } \ + if (!draw_end) { \ + pixel += pitch; \ + } \ + length = (y1 - y2); \ + } \ + if (draw_end) { \ + ++length; \ + } \ + while (length--) { \ + op; \ + pixel += pitch; \ + } \ + } /* Bresenham's line algorithm */ #define BLINE(x1, y1, x2, y2, op, draw_end) \ -{ \ - int i, deltax, deltay, numpixels; \ - int d, dinc1, dinc2; \ - int x, xinc1, xinc2; \ - int y, yinc1, yinc2; \ - \ - deltax = ABS(x2 - x1); \ - deltay = ABS(y2 - y1); \ - \ - if (deltax >= deltay) { \ - numpixels = deltax + 1; \ - d = (2 * deltay) - deltax; \ - dinc1 = deltay * 2; \ - dinc2 = (deltay - deltax) * 2; \ - xinc1 = 1; \ - xinc2 = 1; \ - yinc1 = 0; \ - yinc2 = 1; \ - } else { \ - numpixels = deltay + 1; \ - d = (2 * deltax) - deltay; \ - dinc1 = deltax * 2; \ - dinc2 = (deltax - deltay) * 2; \ - xinc1 = 0; \ - xinc2 = 1; \ - yinc1 = 1; \ - yinc2 = 1; \ - } \ - \ - if (x1 > x2) { \ - xinc1 = -xinc1; \ - xinc2 = -xinc2; \ - } \ - if (y1 > y2) { \ - yinc1 = -yinc1; \ - yinc2 = -yinc2; \ - } \ - \ - x = x1; \ - y = y1; \ - \ - if (!draw_end) { \ - --numpixels; \ - } \ - for (i = 0; i < numpixels; ++i) { \ - op(x, y); \ - if (d < 0) { \ - d += dinc1; \ - x += xinc1; \ - y += yinc1; \ - } else { \ - d += dinc2; \ - x += xinc2; \ - y += yinc2; \ - } \ - } \ -} + { \ + int i, deltax, deltay, numpixels; \ + int d, dinc1, dinc2; \ + int x, xinc1, xinc2; \ + int y, yinc1, yinc2; \ + \ + deltax = ABS(x2 - x1); \ + deltay = ABS(y2 - y1); \ + \ + if (deltax >= deltay) { \ + numpixels = deltax + 1; \ + d = (2 * deltay) - deltax; \ + dinc1 = deltay * 2; \ + dinc2 = (deltay - deltax) * 2; \ + xinc1 = 1; \ + xinc2 = 1; \ + yinc1 = 0; \ + yinc2 = 1; \ + } else { \ + numpixels = deltay + 1; \ + d = (2 * deltax) - deltay; \ + dinc1 = deltax * 2; \ + dinc2 = (deltax - deltay) * 2; \ + xinc1 = 0; \ + xinc2 = 1; \ + yinc1 = 1; \ + yinc2 = 1; \ + } \ + \ + if (x1 > x2) { \ + xinc1 = -xinc1; \ + xinc2 = -xinc2; \ + } \ + if (y1 > y2) { \ + yinc1 = -yinc1; \ + yinc2 = -yinc2; \ + } \ + \ + x = x1; \ + y = y1; \ + \ + if (!draw_end) { \ + --numpixels; \ + } \ + for (i = 0; i < numpixels; ++i) { \ + op(x, y); \ + if (d < 0) { \ + d += dinc1; \ + x += xinc1; \ + y += yinc1; \ + } else { \ + d += dinc2; \ + x += xinc2; \ + y += yinc2; \ + } \ + } \ + } /* Xiaolin Wu's line algorithm, based on Michael Abrash's implementation */ -#define WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \ -{ \ - Uint16 ErrorAdj, ErrorAcc; \ - Uint16 ErrorAccTemp, Weighting; \ - int DeltaX, DeltaY, Temp, XDir; \ - unsigned r, g, b, a, inva; \ - \ - /* Draw the initial pixel, which is always exactly intersected by \ - the line and so needs no weighting */ \ - opaque_op(x1, y1); \ - \ - /* Draw the final pixel, which is always exactly intersected by the line \ - and so needs no weighting */ \ - if (draw_end) { \ - opaque_op(x2, y2); \ - } \ - \ - /* Make sure the line runs top to bottom */ \ - if (y1 > y2) { \ - Temp = y1; y1 = y2; y2 = Temp; \ - Temp = x1; x1 = x2; x2 = Temp; \ - } \ - DeltaY = y2 - y1; \ - \ - if ((DeltaX = x2 - x1) >= 0) { \ - XDir = 1; \ - } else { \ - XDir = -1; \ - DeltaX = -DeltaX; /* make DeltaX positive */ \ - } \ - \ - /* line is not horizontal, diagonal, or vertical */ \ - ErrorAcc = 0; /* initialize the line error accumulator to 0 */ \ - \ - /* Is this an X-major or Y-major line? */ \ - if (DeltaY > DeltaX) { \ - /* Y-major line; calculate 16-bit fixed-point fractional part of a \ - pixel that X advances each time Y advances 1 pixel, truncating the \ - result so that we won't overrun the endpoint along the X axis */ \ - ErrorAdj = ((unsigned long) DeltaX << 16) / (unsigned long) DeltaY; \ - /* Draw all pixels other than the first and last */ \ - while (--DeltaY) { \ - ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \ - ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \ - if (ErrorAcc <= ErrorAccTemp) { \ - /* The error accumulator turned over, so advance the X coord */ \ - x1 += XDir; \ - } \ - y1++; /* Y-major, so always advance Y */ \ - /* The IntensityBits most significant bits of ErrorAcc give us the \ - intensity weighting for this pixel, and the complement of the \ - weighting for the paired pixel */ \ - Weighting = ErrorAcc >> 8; \ - { \ - a = DRAW_MUL(_a, (Weighting ^ 255)); \ - r = DRAW_MUL(_r, a); \ - g = DRAW_MUL(_g, a); \ - b = DRAW_MUL(_b, a); \ - inva = (a ^ 0xFF); \ - blend_op(x1, y1); \ - } \ - { \ - a = DRAW_MUL(_a, Weighting); \ - r = DRAW_MUL(_r, a); \ - g = DRAW_MUL(_g, a); \ - b = DRAW_MUL(_b, a); \ - inva = (a ^ 0xFF); \ - blend_op(x1 + XDir, y1); \ - } \ - } \ - } else { \ - /* X-major line; calculate 16-bit fixed-point fractional part of a \ - pixel that Y advances each time X advances 1 pixel, truncating the \ - result to avoid overrunning the endpoint along the X axis */ \ - ErrorAdj = ((unsigned long) DeltaY << 16) / (unsigned long) DeltaX; \ - /* Draw all pixels other than the first and last */ \ - while (--DeltaX) { \ - ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \ - ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \ - if (ErrorAcc <= ErrorAccTemp) { \ - /* The error accumulator turned over, so advance the Y coord */ \ - y1++; \ - } \ - x1 += XDir; /* X-major, so always advance X */ \ - /* The IntensityBits most significant bits of ErrorAcc give us the \ - intensity weighting for this pixel, and the complement of the \ - weighting for the paired pixel */ \ - Weighting = ErrorAcc >> 8; \ - { \ - a = DRAW_MUL(_a, (Weighting ^ 255)); \ - r = DRAW_MUL(_r, a); \ - g = DRAW_MUL(_g, a); \ - b = DRAW_MUL(_b, a); \ - inva = (a ^ 0xFF); \ - blend_op(x1, y1); \ - } \ - { \ - a = DRAW_MUL(_a, Weighting); \ - r = DRAW_MUL(_r, a); \ - g = DRAW_MUL(_g, a); \ - b = DRAW_MUL(_b, a); \ - inva = (a ^ 0xFF); \ - blend_op(x1, y1 + 1); \ - } \ - } \ - } \ -} +#define WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \ + { \ + Uint16 ErrorAdj, ErrorAcc; \ + Uint16 ErrorAccTemp, Weighting; \ + int DeltaX, DeltaY, Temp, XDir; \ + unsigned r, g, b, a, inva; \ + \ + /* Draw the initial pixel, which is always exactly intersected by \ + the line and so needs no weighting */ \ + opaque_op(x1, y1); \ + \ + /* Draw the final pixel, which is always exactly intersected by the line \ + and so needs no weighting */ \ + if (draw_end) { \ + opaque_op(x2, y2); \ + } \ + \ + /* Make sure the line runs top to bottom */ \ + if (y1 > y2) { \ + Temp = y1; \ + y1 = y2; \ + y2 = Temp; \ + Temp = x1; \ + x1 = x2; \ + x2 = Temp; \ + } \ + DeltaY = y2 - y1; \ + \ + if ((DeltaX = x2 - x1) >= 0) { \ + XDir = 1; \ + } else { \ + XDir = -1; \ + DeltaX = -DeltaX; /* make DeltaX positive */ \ + } \ + \ + /* line is not horizontal, diagonal, or vertical */ \ + ErrorAcc = 0; /* initialize the line error accumulator to 0 */ \ + \ + /* Is this an X-major or Y-major line? */ \ + if (DeltaY > DeltaX) { \ + /* Y-major line; calculate 16-bit fixed-point fractional part of a \ + pixel that X advances each time Y advances 1 pixel, truncating the \ + result so that we won't overrun the endpoint along the X axis */ \ + ErrorAdj = ((unsigned long)DeltaX << 16) / (unsigned long)DeltaY; \ + /* Draw all pixels other than the first and last */ \ + while (--DeltaY) { \ + ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \ + ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \ + if (ErrorAcc <= ErrorAccTemp) { \ + /* The error accumulator turned over, so advance the X coord */ \ + x1 += XDir; \ + } \ + y1++; /* Y-major, so always advance Y */ \ + /* The IntensityBits most significant bits of ErrorAcc give us the \ + intensity weighting for this pixel, and the complement of the \ + weighting for the paired pixel */ \ + Weighting = ErrorAcc >> 8; \ + { \ + a = DRAW_MUL(_a, (Weighting ^ 255)); \ + r = DRAW_MUL(_r, a); \ + g = DRAW_MUL(_g, a); \ + b = DRAW_MUL(_b, a); \ + inva = (a ^ 0xFF); \ + blend_op(x1, y1); \ + } \ + { \ + a = DRAW_MUL(_a, Weighting); \ + r = DRAW_MUL(_r, a); \ + g = DRAW_MUL(_g, a); \ + b = DRAW_MUL(_b, a); \ + inva = (a ^ 0xFF); \ + blend_op(x1 + XDir, y1); \ + } \ + } \ + } else { \ + /* X-major line; calculate 16-bit fixed-point fractional part of a \ + pixel that Y advances each time X advances 1 pixel, truncating the \ + result to avoid overrunning the endpoint along the X axis */ \ + ErrorAdj = ((unsigned long)DeltaY << 16) / (unsigned long)DeltaX; \ + /* Draw all pixels other than the first and last */ \ + while (--DeltaX) { \ + ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \ + ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \ + if (ErrorAcc <= ErrorAccTemp) { \ + /* The error accumulator turned over, so advance the Y coord */ \ + y1++; \ + } \ + x1 += XDir; /* X-major, so always advance X */ \ + /* The IntensityBits most significant bits of ErrorAcc give us the \ + intensity weighting for this pixel, and the complement of the \ + weighting for the paired pixel */ \ + Weighting = ErrorAcc >> 8; \ + { \ + a = DRAW_MUL(_a, (Weighting ^ 255)); \ + r = DRAW_MUL(_r, a); \ + g = DRAW_MUL(_g, a); \ + b = DRAW_MUL(_b, a); \ + inva = (a ^ 0xFF); \ + blend_op(x1, y1); \ + } \ + { \ + a = DRAW_MUL(_a, Weighting); \ + r = DRAW_MUL(_r, a); \ + g = DRAW_MUL(_g, a); \ + b = DRAW_MUL(_b, a); \ + inva = (a ^ 0xFF); \ + blend_op(x1, y1 + 1); \ + } \ + } \ + } \ + } #ifdef AA_LINES #define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \ - WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) + WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) #else #define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \ - BLINE(x1, y1, x2, y2, opaque_op, draw_end) + BLINE(x1, y1, x2, y2, opaque_op, draw_end) #endif /* * Define fill rect macro */ -#define FILLRECT(type, op) \ -do { \ - int width = rect->w; \ - int height = rect->h; \ - int pitch = (dst->pitch / dst->format->BytesPerPixel); \ - int skip = pitch - width; \ - type *pixel = (type *)dst->pixels + rect->y * pitch + rect->x; \ - while (height--) { \ - { int n = (width+3)/4; \ - switch (width & 3) { \ - case 0: do { op; pixel++; SDL_FALLTHROUGH; \ - case 3: op; pixel++; SDL_FALLTHROUGH; \ - case 2: op; pixel++; SDL_FALLTHROUGH; \ - case 1: op; pixel++; \ - } while ( --n > 0 ); \ - } \ - } \ - pixel += skip; \ - } \ -} while (0) +#define FILLRECT(type, op) \ + do { \ + int width = rect->w; \ + int height = rect->h; \ + int pitch = (dst->pitch / dst->format->BytesPerPixel); \ + int skip = pitch - width; \ + type *pixel = (type *)dst->pixels + rect->y * pitch + rect->x; \ + while (height--) { \ + { \ + int n = (width + 3) / 4; \ + switch (width & 3) { \ + case 0: \ + do { \ + op; \ + pixel++; \ + SDL_FALLTHROUGH; \ + case 3: \ + op; \ + pixel++; \ + SDL_FALLTHROUGH; \ + case 2: \ + op; \ + pixel++; \ + SDL_FALLTHROUGH; \ + case 1: \ + op; \ + pixel++; \ + } while (--n > 0); \ + } \ + } \ + pixel += skip; \ + } \ + } while (0) /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/software/SDL_drawline.c b/src/render/software/SDL_drawline.c index 76f4b600b..8e4491cf9 100644 --- a/src/render/software/SDL_drawline.c +++ b/src/render/software/SDL_drawline.c @@ -26,10 +26,8 @@ #include "SDL_drawline.h" #include "SDL_drawpoint.h" - -static void -SDL_DrawLine1(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color, - SDL_bool draw_end) +static void SDL_DrawLine1(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color, + SDL_bool draw_end) { if (y1 == y2) { int length; @@ -37,13 +35,13 @@ SDL_DrawLine1(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color, Uint8 *pixel; if (x1 <= x2) { pixel = (Uint8 *)dst->pixels + y1 * pitch + x1; - length = draw_end ? (x2-x1+1) : (x2-x1); + length = draw_end ? (x2 - x1 + 1) : (x2 - x1); } else { pixel = (Uint8 *)dst->pixels + y1 * pitch + x2; if (!draw_end) { ++pixel; } - length = draw_end ? (x1-x2+1) : (x1-x2); + length = draw_end ? (x1 - x2 + 1) : (x1 - x2); } SDL_memset(pixel, color, length); } else if (x1 == x2) { @@ -55,9 +53,8 @@ SDL_DrawLine1(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color, } } -static void -SDL_DrawLine2(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color, - SDL_bool draw_end) +static void SDL_DrawLine2(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color, + SDL_bool draw_end) { if (y1 == y2) { HLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end); @@ -67,7 +64,7 @@ SDL_DrawLine2(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color, DLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end); } else { Uint8 _r, _g, _b, _a; - const SDL_PixelFormat * fmt = dst->format; + const SDL_PixelFormat *fmt = dst->format; SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a); if (fmt->Rmask == 0x7C00) { AALINE(x1, y1, x2, y2, @@ -85,9 +82,8 @@ SDL_DrawLine2(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color, } } -static void -SDL_DrawLine4(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color, - SDL_bool draw_end) +static void SDL_DrawLine4(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color, + SDL_bool draw_end) { if (y1 == y2) { HLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end); @@ -97,7 +93,7 @@ SDL_DrawLine4(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color, DLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end); } else { Uint8 _r, _g, _b, _a; - const SDL_PixelFormat * fmt = dst->format; + const SDL_PixelFormat *fmt = dst->format; SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a); if (fmt->Rmask == 0x00FF0000) { if (!fmt->Amask) { @@ -117,12 +113,11 @@ SDL_DrawLine4(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color, } } -typedef void (*DrawLineFunc) (SDL_Surface * dst, - int x1, int y1, int x2, int y2, - Uint32 color, SDL_bool draw_end); +typedef void (*DrawLineFunc)(SDL_Surface *dst, + int x1, int y1, int x2, int y2, + Uint32 color, SDL_bool draw_end); -static DrawLineFunc -SDL_CalculateDrawLineFunc(const SDL_PixelFormat * fmt) +static DrawLineFunc SDL_CalculateDrawLineFunc(const SDL_PixelFormat *fmt) { switch (fmt->BytesPerPixel) { case 1: @@ -138,8 +133,7 @@ SDL_CalculateDrawLineFunc(const SDL_PixelFormat * fmt) return NULL; } -int -SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color) +int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color) { DrawLineFunc func; @@ -162,9 +156,8 @@ SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color) return 0; } -int -SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count, - Uint32 color) +int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count, + Uint32 color) { int i; int x1, y1; @@ -182,8 +175,8 @@ SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count, } for (i = 1; i < count; ++i) { - x1 = points[i-1].x; - y1 = points[i-1].y; + x1 = points[i - 1].x; + y1 = points[i - 1].y; x2 = points[i].x; y2 = points[i].y; @@ -198,8 +191,8 @@ SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count, func(dst, x1, y1, x2, y2, color, draw_end); } - if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) { - SDL_DrawPoint(dst, points[count-1].x, points[count-1].y, color); + if (points[0].x != points[count - 1].x || points[0].y != points[count - 1].y) { + SDL_DrawPoint(dst, points[count - 1].x, points[count - 1].y, color); } return 0; } diff --git a/src/render/software/SDL_drawline.h b/src/render/software/SDL_drawline.h index 186119e8e..116020439 100644 --- a/src/render/software/SDL_drawline.h +++ b/src/render/software/SDL_drawline.h @@ -24,9 +24,8 @@ #include "../../SDL_internal.h" - -extern int SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color); -extern int SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color); +extern int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color); +extern int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count, Uint32 color); #endif /* SDL_drawline_h_ */ diff --git a/src/render/software/SDL_drawpoint.c b/src/render/software/SDL_drawpoint.c index 5c1607543..0d5e0f118 100644 --- a/src/render/software/SDL_drawpoint.c +++ b/src/render/software/SDL_drawpoint.c @@ -25,9 +25,7 @@ #include "SDL_draw.h" #include "SDL_drawpoint.h" - -int -SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color) +int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color) { if (dst == NULL) { return SDL_InvalidParamError("SDL_DrawPoint(): dst"); @@ -61,9 +59,8 @@ SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color) return 0; } -int -SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count, - Uint32 color) +int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count, + Uint32 color) { int minx, miny; int maxx, maxy; diff --git a/src/render/software/SDL_drawpoint.h b/src/render/software/SDL_drawpoint.h index 4c019e014..16a62311f 100644 --- a/src/render/software/SDL_drawpoint.h +++ b/src/render/software/SDL_drawpoint.h @@ -24,9 +24,8 @@ #include "../../SDL_internal.h" - -extern int SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color); -extern int SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color); +extern int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color); +extern int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count, Uint32 color); #endif /* SDL_drawpoint_h_ */ diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c index 9141a7ad2..3d7f2087d 100644 --- a/src/render/software/SDL_render_sw.c +++ b/src/render/software/SDL_render_sw.c @@ -50,11 +50,9 @@ typedef struct SDL_Surface *window; } SW_RenderData; - -static SDL_Surface * -SW_ActivateRenderer(SDL_Renderer * renderer) +static SDL_Surface *SW_ActivateRenderer(SDL_Renderer *renderer) { - SW_RenderData *data = (SW_RenderData *) renderer->driverdata; + SW_RenderData *data = (SW_RenderData *)renderer->driverdata; if (!data->surface) { data->surface = data->window; @@ -68,10 +66,9 @@ SW_ActivateRenderer(SDL_Renderer * renderer) return data->surface; } -static void -SW_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +static void SW_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event) { - SW_RenderData *data = (SW_RenderData *) renderer->driverdata; + SW_RenderData *data = (SW_RenderData *)renderer->driverdata; if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { data->surface = NULL; @@ -79,10 +76,9 @@ SW_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) } } -static int -SW_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) +static int SW_GetOutputSize(SDL_Renderer *renderer, int *w, int *h) { - SW_RenderData *data = (SW_RenderData *) renderer->driverdata; + SW_RenderData *data = (SW_RenderData *)renderer->driverdata; if (data->surface) { if (w) { @@ -102,14 +98,12 @@ SW_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) return SDL_SetError("Software renderer doesn't have an output surface"); } -static int -SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static int SW_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) { int bpp; Uint32 Rmask, Gmask, Bmask, Amask; - if (!SDL_PixelFormatEnumToMasks - (texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { + if (!SDL_PixelFormatEnumToMasks(texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { return SDL_SetError("Unknown texture format"); } @@ -133,11 +127,10 @@ SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) return 0; } -static int -SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, int pitch) +static int SW_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, const void *pixels, int pitch) { - SDL_Surface *surface = (SDL_Surface *) texture->driverdata; + SDL_Surface *surface = (SDL_Surface *)texture->driverdata; Uint8 *src, *dst; int row; size_t length; @@ -145,10 +138,10 @@ SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, if (SDL_MUSTLOCK(surface)) { SDL_LockSurface(surface); } - src = (Uint8 *) pixels; - dst = (Uint8 *) surface->pixels + - rect->y * surface->pitch + - rect->x * surface->format->BytesPerPixel; + src = (Uint8 *)pixels; + dst = (Uint8 *)surface->pixels + + rect->y * surface->pitch + + rect->x * surface->format->BytesPerPixel; length = rect->w * surface->format->BytesPerPixel; for (row = 0; row < rect->h; ++row) { SDL_memcpy(dst, src, length); @@ -161,52 +154,46 @@ SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, return 0; } -static int -SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, void **pixels, int *pitch) +static int SW_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, void **pixels, int *pitch) { - SDL_Surface *surface = (SDL_Surface *) texture->driverdata; + SDL_Surface *surface = (SDL_Surface *)texture->driverdata; *pixels = - (void *) ((Uint8 *) surface->pixels + rect->y * surface->pitch + - rect->x * surface->format->BytesPerPixel); + (void *)((Uint8 *)surface->pixels + rect->y * surface->pitch + + rect->x * surface->format->BytesPerPixel); *pitch = surface->pitch; return 0; } -static void -SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static void SW_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) { } -static void -SW_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode) +static void SW_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode) { } -static int -SW_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +static int SW_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) { - SW_RenderData *data = (SW_RenderData *) renderer->driverdata; + SW_RenderData *data = (SW_RenderData *)renderer->driverdata; if (texture) { - data->surface = (SDL_Surface *) texture->driverdata; + data->surface = (SDL_Surface *)texture->driverdata; } else { data->surface = data->window; } return 0; } -static int -SW_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd) +static int SW_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { - return 0; /* nothing to do in this backend. */ + return 0; /* nothing to do in this backend. */ } -static int -SW_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) +static int SW_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { - SDL_Point *verts = (SDL_Point *) SDL_AllocateRenderVertices(renderer, count * sizeof (SDL_Point), 0, &cmd->data.draw.first); + SDL_Point *verts = (SDL_Point *)SDL_AllocateRenderVertices(renderer, count * sizeof(SDL_Point), 0, &cmd->data.draw.first); int i; if (verts == NULL) { @@ -223,10 +210,9 @@ SW_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FP return 0; } -static int -SW_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count) +static int SW_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FRect *rects, int count) { - SDL_Rect *verts = (SDL_Rect *) SDL_AllocateRenderVertices(renderer, count * sizeof (SDL_Rect), 0, &cmd->data.draw.first); + SDL_Rect *verts = (SDL_Rect *)SDL_AllocateRenderVertices(renderer, count * sizeof(SDL_Rect), 0, &cmd->data.draw.first); int i; if (verts == NULL) { @@ -245,11 +231,10 @@ SW_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRe return 0; } -static int -SW_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_FRect * dstrect) +static int SW_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const SDL_Rect *srcrect, const SDL_FRect *dstrect) { - SDL_Rect *verts = (SDL_Rect *) SDL_AllocateRenderVertices(renderer, 2 * sizeof (SDL_Rect), 0, &cmd->data.draw.first); + SDL_Rect *verts = (SDL_Rect *)SDL_AllocateRenderVertices(renderer, 2 * sizeof(SDL_Rect), 0, &cmd->data.draw.first); if (verts == NULL) { return -1; @@ -279,12 +264,11 @@ typedef struct CopyExData float scale_y; } CopyExData; -static int -SW_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_FRect * dstrect, - const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip, float scale_x, float scale_y) +static int SW_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const SDL_Rect *srcrect, const SDL_FRect *dstrect, + const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip, float scale_x, float scale_y) { - CopyExData *verts = (CopyExData *) SDL_AllocateRenderVertices(renderer, sizeof (CopyExData), 0, &cmd->data.draw.first); + CopyExData *verts = (CopyExData *)SDL_AllocateRenderVertices(renderer, sizeof(CopyExData), 0, &cmd->data.draw.first); if (verts == NULL) { return -1; @@ -307,18 +291,17 @@ SW_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * te return 0; } -static int -Blit_to_Screen(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *surface, SDL_Rect *dstrect, - float scale_x, float scale_y, SDL_ScaleMode scaleMode) +static int Blit_to_Screen(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *surface, SDL_Rect *dstrect, + float scale_x, float scale_y, SDL_ScaleMode scaleMode) { int retval; /* Renderer scaling, if needed */ if (scale_x != 1.0f || scale_y != 1.0f) { SDL_Rect r; - r.x = (int)((float) dstrect->x * scale_x); - r.y = (int)((float) dstrect->y * scale_y); - r.w = (int)((float) dstrect->w * scale_x); - r.h = (int)((float) dstrect->h * scale_y); + r.x = (int)((float)dstrect->x * scale_x); + r.y = (int)((float)dstrect->y * scale_y); + r.w = (int)((float)dstrect->w * scale_x); + r.h = (int)((float)dstrect->h * scale_y); retval = SDL_PrivateUpperBlitScaled(src, srcrect, surface, &r, scaleMode); } else { retval = SDL_BlitSurface(src, srcrect, surface, dstrect); @@ -326,12 +309,11 @@ Blit_to_Screen(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *surface, SDL_Re return retval; } -static int -SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * final_rect, - const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip, float scale_x, float scale_y) +static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Texture *texture, + const SDL_Rect *srcrect, const SDL_Rect *final_rect, + const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip, float scale_x, float scale_y) { - SDL_Surface *src = (SDL_Surface *) texture->driverdata; + SDL_Surface *src = (SDL_Surface *)texture->driverdata; SDL_Rect tmp_rect; SDL_Surface *src_clone, *src_rotated, *src_scaled; SDL_Surface *mask = NULL, *mask_rotated = NULL; @@ -441,18 +423,18 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * tex double cangle, sangle; SDLgfx_rotozoomSurfaceSizeTrig(tmp_rect.w, tmp_rect.h, angle, center, - &rect_dest, &cangle, &sangle); + &rect_dest, &cangle, &sangle); src_rotated = SDLgfx_rotateSurface(src_clone, angle, - (texture->scaleMode == SDL_ScaleModeNearest) ? 0 : 1, flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, - &rect_dest, cangle, sangle, center); + (texture->scaleMode == SDL_ScaleModeNearest) ? 0 : 1, flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, + &rect_dest, cangle, sangle, center); if (src_rotated == NULL) { retval = -1; } if (!retval && mask != NULL) { /* The mask needed for the NONE blend mode gets rotated with the same parameters. */ mask_rotated = SDLgfx_rotateSurface(mask, angle, - SDL_FALSE, 0, 0, - &rect_dest, cangle, sangle, center); + SDL_FALSE, 0, 0, + &rect_dest, cangle, sangle, center); if (mask_rotated == NULL) { retval = -1; } @@ -535,7 +517,6 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * tex return retval; } - typedef struct GeometryFillData { SDL_Point dst; @@ -549,18 +530,17 @@ typedef struct GeometryCopyData SDL_Color color; } GeometryCopyData; -static int -SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, - const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, - int num_vertices, const void *indices, int num_indices, int size_indices, - float scale_x, float scale_y) +static int SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, + int num_vertices, const void *indices, int num_indices, int size_indices, + float scale_x, float scale_y) { int i; int count = indices ? num_indices : num_vertices; void *verts; - int sz = texture ? sizeof (GeometryCopyData) : sizeof (GeometryFillData); + int sz = texture ? sizeof(GeometryCopyData) : sizeof(GeometryFillData); - verts = (void *) SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first); + verts = (void *)SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first); if (verts == NULL) { return -1; } @@ -569,7 +549,7 @@ SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te size_indices = indices ? size_indices : 0; if (texture) { - GeometryCopyData *ptr = (GeometryCopyData *) verts; + GeometryCopyData *ptr = (GeometryCopyData *)verts; for (i = 0; i < count; i++) { int j; float *xy_; @@ -585,10 +565,10 @@ SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te j = i; } - xy_ = (float *)((char*)xy + j * xy_stride); - col_ = *(SDL_Color *)((char*)color + j * color_stride); + xy_ = (float *)((char *)xy + j * xy_stride); + col_ = *(SDL_Color *)((char *)color + j * color_stride); - uv_ = (float *)((char*)uv + j * uv_stride); + uv_ = (float *)((char *)uv + j * uv_stride); ptr->src.x = (int)(uv_[0] * texture->w); ptr->src.y = (int)(uv_[1] * texture->h); @@ -600,9 +580,9 @@ SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te ptr->color = col_; ptr++; - } + } } else { - GeometryFillData *ptr = (GeometryFillData *) verts; + GeometryFillData *ptr = (GeometryFillData *)verts; for (i = 0; i < count; i++) { int j; @@ -618,8 +598,8 @@ SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te j = i; } - xy_ = (float *)((char*)xy + j * xy_stride); - col_ = *(SDL_Color *)((char*)color + j * color_stride); + xy_ = (float *)((char *)xy + j * xy_stride); + col_ = *(SDL_Color *)((char *)color + j * color_stride); ptr->dst.x = (int)(xy_[0] * scale_x); ptr->dst.y = (int)(xy_[1] * scale_y); @@ -628,13 +608,12 @@ SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te ptr->color = col_; ptr++; - } + } } return 0; } -static void -PrepTextureForCopy(const SDL_RenderCommand *cmd) +static void PrepTextureForCopy(const SDL_RenderCommand *cmd) { const Uint8 r = cmd->data.draw.r; const Uint8 g = cmd->data.draw.g; @@ -642,7 +621,7 @@ PrepTextureForCopy(const SDL_RenderCommand *cmd) const Uint8 a = cmd->data.draw.a; const SDL_BlendMode blend = cmd->data.draw.blend; SDL_Texture *texture = cmd->data.draw.texture; - SDL_Surface *surface = (SDL_Surface *) texture->driverdata; + SDL_Surface *surface = (SDL_Surface *)texture->driverdata; const SDL_bool colormod = ((r & g & b) != 0xFF); const SDL_bool alphamod = (a != 0xFF); const SDL_bool blending = ((blend == SDL_BLENDMODE_ADD) || (blend == SDL_BLENDMODE_MOD) || (blend == SDL_BLENDMODE_MUL)); @@ -657,13 +636,12 @@ PrepTextureForCopy(const SDL_RenderCommand *cmd) SDL_SetSurfaceBlendMode(surface, blend); } -static void -SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate) +static void SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate) { if (drawstate->surface_cliprect_dirty) { const SDL_Rect *viewport = drawstate->viewport; const SDL_Rect *cliprect = drawstate->cliprect; - SDL_assert(viewport != NULL); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */ + SDL_assert(viewport != NULL); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */ if (cliprect != NULL) { SDL_Rect clip_rect; @@ -680,8 +658,7 @@ SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate) } } -static int -SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) +static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) { SDL_Surface *surface = SW_ActivateRenderer(renderer); SW_DrawStateCache drawstate; @@ -696,43 +673,48 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic while (cmd) { switch (cmd->command) { - case SDL_RENDERCMD_SETDRAWCOLOR: { - break; /* Not used in this backend. */ - } + case SDL_RENDERCMD_SETDRAWCOLOR: + { + break; /* Not used in this backend. */ + } - case SDL_RENDERCMD_SETVIEWPORT: { - drawstate.viewport = &cmd->data.viewport.rect; - drawstate.surface_cliprect_dirty = SDL_TRUE; - break; - } + case SDL_RENDERCMD_SETVIEWPORT: + { + drawstate.viewport = &cmd->data.viewport.rect; + drawstate.surface_cliprect_dirty = SDL_TRUE; + break; + } - case SDL_RENDERCMD_SETCLIPRECT: { - drawstate.cliprect = cmd->data.cliprect.enabled ? &cmd->data.cliprect.rect : NULL; - drawstate.surface_cliprect_dirty = SDL_TRUE; - break; - } + case SDL_RENDERCMD_SETCLIPRECT: + { + drawstate.cliprect = cmd->data.cliprect.enabled ? &cmd->data.cliprect.rect : NULL; + drawstate.surface_cliprect_dirty = SDL_TRUE; + break; + } - case SDL_RENDERCMD_CLEAR: { - const Uint8 r = cmd->data.color.r; - const Uint8 g = cmd->data.color.g; - const Uint8 b = cmd->data.color.b; - const Uint8 a = cmd->data.color.a; - /* By definition the clear ignores the clip rect */ - SDL_SetClipRect(surface, NULL); - SDL_FillRect(surface, NULL, SDL_MapRGBA(surface->format, r, g, b, a)); - drawstate.surface_cliprect_dirty = SDL_TRUE; - break; - } + case SDL_RENDERCMD_CLEAR: + { + const Uint8 r = cmd->data.color.r; + const Uint8 g = cmd->data.color.g; + const Uint8 b = cmd->data.color.b; + const Uint8 a = cmd->data.color.a; + /* By definition the clear ignores the clip rect */ + SDL_SetClipRect(surface, NULL); + SDL_FillRect(surface, NULL, SDL_MapRGBA(surface->format, r, g, b, a)); + drawstate.surface_cliprect_dirty = SDL_TRUE; + break; + } - case SDL_RENDERCMD_DRAW_POINTS: { - const Uint8 r = cmd->data.draw.r; - const Uint8 g = cmd->data.draw.g; - const Uint8 b = cmd->data.draw.b; - const Uint8 a = cmd->data.draw.a; - const int count = (int) cmd->data.draw.count; - SDL_Point *verts = (SDL_Point *) (((Uint8 *) vertices) + cmd->data.draw.first); - const SDL_BlendMode blend = cmd->data.draw.blend; - SetDrawState(surface, &drawstate); + case SDL_RENDERCMD_DRAW_POINTS: + { + const Uint8 r = cmd->data.draw.r; + const Uint8 g = cmd->data.draw.g; + const Uint8 b = cmd->data.draw.b; + const Uint8 a = cmd->data.draw.a; + const int count = (int)cmd->data.draw.count; + SDL_Point *verts = (SDL_Point *)(((Uint8 *)vertices) + cmd->data.draw.first); + const SDL_BlendMode blend = cmd->data.draw.blend; + SetDrawState(surface, &drawstate); /* Apply viewport */ if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { @@ -888,64 +870,220 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic case SDL_RENDERCMD_GEOMETRY: { int i; - SDL_Rect *verts = (SDL_Rect *) (((Uint8 *) vertices) + cmd->data.draw.first); - const int count = (int) cmd->data.draw.count; - SDL_Texture *texture = cmd->data.draw.texture; - const SDL_BlendMode blend = cmd->data.draw.blend; - - SetDrawState(surface, &drawstate); - - if (texture) { - SDL_Surface *src = (SDL_Surface *) texture->driverdata; - - GeometryCopyData *ptr = (GeometryCopyData *) verts; - - PrepTextureForCopy(cmd); - - /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { - SDL_Point vp; - vp.x = drawstate.viewport->x; - vp.y = drawstate.viewport->y; - trianglepoint_2_fixedpoint(&vp); - for (i = 0; i < count; i++) { - ptr[i].dst.x += vp.x; - ptr[i].dst.y += vp.y; - } - } - - for (i = 0; i < count; i += 3, ptr += 3) { - SDL_SW_BlitTriangle( - src, - &(ptr[0].src), &(ptr[1].src), &(ptr[2].src), - surface, - &(ptr[0].dst), &(ptr[1].dst), &(ptr[2].dst), - ptr[0].color, ptr[1].color, ptr[2].color); - } - } else { - GeometryFillData *ptr = (GeometryFillData *) verts; - - /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { - SDL_Point vp; - vp.x = drawstate.viewport->x; - vp.y = drawstate.viewport->y; - trianglepoint_2_fixedpoint(&vp); - for (i = 0; i < count; i++) { - ptr[i].dst.x += vp.x; - ptr[i].dst.y += vp.y; - } - } - - for (i = 0; i < count; i += 3, ptr += 3) { - SDL_SW_FillTriangle(surface, &(ptr[0].dst), &(ptr[1].dst), &(ptr[2].dst), blend, ptr[0].color, ptr[1].color, ptr[2].color); - } + for (i = 0; i < count; i++) { + verts[i].x += drawstate.viewport->x; + verts[i].y += drawstate.viewport->y; } - break; } - case SDL_RENDERCMD_NO_OP: - break; + if (blend == SDL_BLENDMODE_NONE) { + SDL_DrawPoints(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a)); + } else { + SDL_BlendPoints(surface, verts, count, blend, r, g, b, a); + } + break; + } + + case SDL_RENDERCMD_DRAW_LINES: + { + const Uint8 r = cmd->data.draw.r; + const Uint8 g = cmd->data.draw.g; + const Uint8 b = cmd->data.draw.b; + const Uint8 a = cmd->data.draw.a; + const int count = (int)cmd->data.draw.count; + SDL_Point *verts = (SDL_Point *)(((Uint8 *)vertices) + cmd->data.draw.first); + const SDL_BlendMode blend = cmd->data.draw.blend; + SetDrawState(surface, &drawstate); + + /* Apply viewport */ + if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + int i; + for (i = 0; i < count; i++) { + verts[i].x += drawstate.viewport->x; + verts[i].y += drawstate.viewport->y; + } + } + + if (blend == SDL_BLENDMODE_NONE) { + SDL_DrawLines(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a)); + } else { + SDL_BlendLines(surface, verts, count, blend, r, g, b, a); + } + break; + } + + case SDL_RENDERCMD_FILL_RECTS: + { + const Uint8 r = cmd->data.draw.r; + const Uint8 g = cmd->data.draw.g; + const Uint8 b = cmd->data.draw.b; + const Uint8 a = cmd->data.draw.a; + const int count = (int)cmd->data.draw.count; + SDL_Rect *verts = (SDL_Rect *)(((Uint8 *)vertices) + cmd->data.draw.first); + const SDL_BlendMode blend = cmd->data.draw.blend; + SetDrawState(surface, &drawstate); + + /* Apply viewport */ + if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + int i; + for (i = 0; i < count; i++) { + verts[i].x += drawstate.viewport->x; + verts[i].y += drawstate.viewport->y; + } + } + + if (blend == SDL_BLENDMODE_NONE) { + SDL_FillRects(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a)); + } else { + SDL_BlendFillRects(surface, verts, count, blend, r, g, b, a); + } + break; + } + + case SDL_RENDERCMD_COPY: + { + SDL_Rect *verts = (SDL_Rect *)(((Uint8 *)vertices) + cmd->data.draw.first); + const SDL_Rect *srcrect = verts; + SDL_Rect *dstrect = verts + 1; + SDL_Texture *texture = cmd->data.draw.texture; + SDL_Surface *src = (SDL_Surface *)texture->driverdata; + + SetDrawState(surface, &drawstate); + + PrepTextureForCopy(cmd); + + /* Apply viewport */ + if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + dstrect->x += drawstate.viewport->x; + dstrect->y += drawstate.viewport->y; + } + + if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) { + SDL_BlitSurface(src, srcrect, surface, dstrect); + } else { + /* If scaling is ever done, permanently disable RLE (which doesn't support scaling) + * to avoid potentially frequent RLE encoding/decoding. + */ + SDL_SetSurfaceRLE(surface, 0); + + /* Prevent to do scaling + clipping on viewport boundaries as it may lose proportion */ + if (dstrect->x < 0 || dstrect->y < 0 || dstrect->x + dstrect->w > surface->w || dstrect->y + dstrect->h > surface->h) { + SDL_Surface *tmp = SDL_CreateRGBSurfaceWithFormat(dstrect->w, dstrect->h, src->format->format); + /* Scale to an intermediate surface, then blit */ + if (tmp) { + SDL_Rect r; + SDL_BlendMode blendmode; + Uint8 alphaMod, rMod, gMod, bMod; + + SDL_GetSurfaceBlendMode(src, &blendmode); + SDL_GetSurfaceAlphaMod(src, &alphaMod); + SDL_GetSurfaceColorMod(src, &rMod, &gMod, &bMod); + + r.x = 0; + r.y = 0; + r.w = dstrect->w; + r.h = dstrect->h; + + SDL_SetSurfaceBlendMode(src, SDL_BLENDMODE_NONE); + SDL_SetSurfaceColorMod(src, 255, 255, 255); + SDL_SetSurfaceAlphaMod(src, 255); + + SDL_PrivateUpperBlitScaled(src, srcrect, tmp, &r, texture->scaleMode); + + SDL_SetSurfaceColorMod(tmp, rMod, gMod, bMod); + SDL_SetSurfaceAlphaMod(tmp, alphaMod); + SDL_SetSurfaceBlendMode(tmp, blendmode); + + SDL_BlitSurface(tmp, NULL, surface, dstrect); + SDL_FreeSurface(tmp); + /* No need to set back r/g/b/a/blendmode to 'src' since it's done in PrepTextureForCopy() */ + } + } else { + SDL_PrivateUpperBlitScaled(src, srcrect, surface, dstrect, texture->scaleMode); + } + } + break; + } + + case SDL_RENDERCMD_COPY_EX: + { + CopyExData *copydata = (CopyExData *)(((Uint8 *)vertices) + cmd->data.draw.first); + SetDrawState(surface, &drawstate); + PrepTextureForCopy(cmd); + + /* Apply viewport */ + if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + copydata->dstrect.x += drawstate.viewport->x; + copydata->dstrect.y += drawstate.viewport->y; + } + + SW_RenderCopyEx(renderer, surface, cmd->data.draw.texture, ©data->srcrect, + ©data->dstrect, copydata->angle, ©data->center, copydata->flip, + copydata->scale_x, copydata->scale_y); + break; + } + + case SDL_RENDERCMD_GEOMETRY: + { + int i; + SDL_Rect *verts = (SDL_Rect *)(((Uint8 *)vertices) + cmd->data.draw.first); + const int count = (int)cmd->data.draw.count; + SDL_Texture *texture = cmd->data.draw.texture; + const SDL_BlendMode blend = cmd->data.draw.blend; + + SetDrawState(surface, &drawstate); + + if (texture) { + SDL_Surface *src = (SDL_Surface *)texture->driverdata; + + GeometryCopyData *ptr = (GeometryCopyData *)verts; + + PrepTextureForCopy(cmd); + + /* Apply viewport */ + if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + SDL_Point vp; + vp.x = drawstate.viewport->x; + vp.y = drawstate.viewport->y; + trianglepoint_2_fixedpoint(&vp); + for (i = 0; i < count; i++) { + ptr[i].dst.x += vp.x; + ptr[i].dst.y += vp.y; + } + } + + for (i = 0; i < count; i += 3, ptr += 3) { + SDL_SW_BlitTriangle( + src, + &(ptr[0].src), &(ptr[1].src), &(ptr[2].src), + surface, + &(ptr[0].dst), &(ptr[1].dst), &(ptr[2].dst), + ptr[0].color, ptr[1].color, ptr[2].color); + } + } else { + GeometryFillData *ptr = (GeometryFillData *)verts; + + /* Apply viewport */ + if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + SDL_Point vp; + vp.x = drawstate.viewport->x; + vp.y = drawstate.viewport->y; + trianglepoint_2_fixedpoint(&vp); + for (i = 0; i < count; i++) { + ptr[i].dst.x += vp.x; + ptr[i].dst.y += vp.y; + } + } + + for (i = 0; i < count; i += 3, ptr += 3) { + SDL_SW_FillTriangle(surface, &(ptr[0].dst), &(ptr[1].dst), &(ptr[2].dst), blend, ptr[0].color, ptr[1].color, ptr[2].color); + } + } + break; + } + + case SDL_RENDERCMD_NO_OP: + break; } cmd = cmd->next; @@ -954,9 +1092,8 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic return 0; } -static int -SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, void * pixels, int pitch) +static int SW_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, + Uint32 format, void *pixels, int pitch) { SDL_Surface *surface = SW_ActivateRenderer(renderer); Uint32 src_format; @@ -970,23 +1107,22 @@ SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, * SDL_RenderReadPixels. */ - if (rect->x < 0 || rect->x+rect->w > surface->w || - rect->y < 0 || rect->y+rect->h > surface->h) { + if (rect->x < 0 || rect->x + rect->w > surface->w || + rect->y < 0 || rect->y + rect->h > surface->h) { return SDL_SetError("Tried to read outside of surface bounds"); } src_format = surface->format->format; - src_pixels = (void*)((Uint8 *) surface->pixels + - rect->y * surface->pitch + - rect->x * surface->format->BytesPerPixel); + src_pixels = (void *)((Uint8 *)surface->pixels + + rect->y * surface->pitch + + rect->x * surface->format->BytesPerPixel); return SDL_ConvertPixels(rect->w, rect->h, src_format, src_pixels, surface->pitch, format, pixels, pitch); } -static int -SW_RenderPresent(SDL_Renderer * renderer) +static int SW_RenderPresent(SDL_Renderer *renderer) { SDL_Window *window = renderer->window; @@ -996,25 +1132,23 @@ SW_RenderPresent(SDL_Renderer * renderer) return SDL_UpdateWindowSurface(window); } -static void -SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) +static void SW_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - SDL_Surface *surface = (SDL_Surface *) texture->driverdata; + SDL_Surface *surface = (SDL_Surface *)texture->driverdata; SDL_FreeSurface(surface); } -static void -SW_DestroyRenderer(SDL_Renderer * renderer) +static void SW_DestroyRenderer(SDL_Renderer *renderer) { - SW_RenderData *data = (SW_RenderData *) renderer->driverdata; + SW_RenderData *data = (SW_RenderData *)renderer->driverdata; SDL_free(data); SDL_free(renderer); } SDL_Renderer * -SW_CreateRendererForSurface(SDL_Surface * surface) +SW_CreateRendererForSurface(SDL_Surface *surface) { SDL_Renderer *renderer; SW_RenderData *data; @@ -1024,13 +1158,13 @@ SW_CreateRendererForSurface(SDL_Surface * surface) return NULL; } - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); if (renderer == NULL) { SDL_OutOfMemory(); return NULL; } - data = (SW_RenderData *) SDL_calloc(1, sizeof(*data)); + data = (SW_RenderData *)SDL_calloc(1, sizeof(*data)); if (data == NULL) { SW_DestroyRenderer(renderer); SDL_OutOfMemory(); @@ -1048,9 +1182,9 @@ SW_CreateRendererForSurface(SDL_Surface * surface) renderer->SetTextureScaleMode = SW_SetTextureScaleMode; renderer->SetRenderTarget = SW_SetRenderTarget; renderer->QueueSetViewport = SW_QueueSetViewport; - renderer->QueueSetDrawColor = SW_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */ + renderer->QueueSetDrawColor = SW_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */ renderer->QueueDrawPoints = SW_QueueDrawPoints; - renderer->QueueDrawLines = SW_QueueDrawPoints; /* lines and points queue vertices the same way. */ + renderer->QueueDrawLines = SW_QueueDrawPoints; /* lines and points queue vertices the same way. */ renderer->QueueFillRects = SW_QueueFillRects; renderer->QueueCopy = SW_QueueCopy; renderer->QueueCopyEx = SW_QueueCopyEx; @@ -1068,8 +1202,7 @@ SW_CreateRendererForSurface(SDL_Surface * surface) return renderer; } -static SDL_Renderer * -SW_CreateRenderer(SDL_Window * window, Uint32 flags) +static SDL_Renderer *SW_CreateRenderer(SDL_Window *window, Uint32 flags) { const char *hint; SDL_Surface *surface; diff --git a/src/render/software/SDL_render_sw_c.h b/src/render/software/SDL_render_sw_c.h index 4962ea6c0..f20849bcd 100644 --- a/src/render/software/SDL_render_sw_c.h +++ b/src/render/software/SDL_render_sw_c.h @@ -22,7 +22,7 @@ #ifndef SDL_render_sw_c_h_ #define SDL_render_sw_c_h_ -extern SDL_Renderer * SW_CreateRendererForSurface(SDL_Surface * surface); +extern SDL_Renderer *SW_CreateRendererForSurface(SDL_Surface *surface); #endif /* SDL_render_sw_c_h_ */ diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c index c3d6ebde8..1b918ce08 100644 --- a/src/render/software/SDL_rotate.c +++ b/src/render/software/SDL_rotate.c @@ -47,7 +47,8 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net /* ! \brief A 32 bit RGBA pixel. */ -typedef struct tColorRGBA { +typedef struct tColorRGBA +{ Uint8 r; Uint8 g; Uint8 b; @@ -57,7 +58,8 @@ typedef struct tColorRGBA { /* ! \brief A 8bit Y/palette pixel. */ -typedef struct tColorY { +typedef struct tColorY +{ Uint8 y; } tColorY; @@ -76,8 +78,7 @@ to a situation where the program can segfault. /* ! \brief Returns colorkey info for a surface */ -static Uint32 -get_colorkey(SDL_Surface *src) +static Uint32 get_colorkey(SDL_Surface *src) { Uint32 key = 0; if (SDL_HasColorKey(src)) { @@ -87,8 +88,8 @@ get_colorkey(SDL_Surface *src) } /* rotate (sx, sy) by (angle, center) into (dx, dy) */ -static void -rotate(double sx, double sy, double sinangle, double cosangle, const SDL_FPoint *center, double *dx, double *dy) { +static void rotate(double sx, double sy, double sinangle, double cosangle, const SDL_FPoint *center, double *dx, double *dy) +{ sx -= center->x; sy -= center->y; @@ -111,9 +112,8 @@ rotate(double sx, double sy, double sinangle, double cosangle, const SDL_FPoint \param sangle The cosine of the angle */ -void -SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FPoint *center, - SDL_Rect *rect_dest, double *cangle, double *sangle) +void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FPoint *center, + SDL_Rect *rect_dest, double *cangle, double *sangle) { int minx, maxx, miny, maxy; double radangle; @@ -129,16 +129,16 @@ SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FP /* * Determine destination width and height by rotating a source box, at pixel center */ - rotate(0.5, 0.5, sinangle, cosangle, center, &x0, &y0); - rotate(width - 0.5, 0.5, sinangle, cosangle, center, &x1, &y1); - rotate(0.5, height - 0.5, sinangle, cosangle, center, &x2, &y2); + rotate(0.5, 0.5, sinangle, cosangle, center, &x0, &y0); + rotate(width - 0.5, 0.5, sinangle, cosangle, center, &x1, &y1); + rotate(0.5, height - 0.5, sinangle, cosangle, center, &x2, &y2); rotate(width - 0.5, height - 0.5, sinangle, cosangle, center, &x3, &y3); - minx = (int)SDL_floor( SDL_min( SDL_min(x0, x1), SDL_min(x2, x3) ) ); - maxx = (int)SDL_ceil( SDL_max( SDL_max(x0, x1), SDL_max(x2, x3) ) ); + minx = (int)SDL_floor(SDL_min(SDL_min(x0, x1), SDL_min(x2, x3))); + maxx = (int)SDL_ceil(SDL_max(SDL_max(x0, x1), SDL_max(x2, x3))); - miny = (int)SDL_floor( SDL_min( SDL_min(y0, y1), SDL_min(y2, y3) ) ); - maxy = (int)SDL_ceil( SDL_max( SDL_max(y0, y1), SDL_max(y2, y3) ) ); + miny = (int)SDL_floor(SDL_min(SDL_min(y0, y1), SDL_min(y2, y3))); + maxy = (int)SDL_ceil(SDL_max(SDL_max(y0, y1), SDL_max(y2, y3))); rect_dest->w = maxx - minx; rect_dest->h = maxy - miny; @@ -151,20 +151,20 @@ SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FP { /* The trig code below gets the wrong size (due to FP inaccuracy?) when angle is a multiple of 90 degrees */ - int angle90 = (int)(angle/90); - if (angle90 == angle/90) { /* if the angle is a multiple of 90 degrees */ + int angle90 = (int)(angle / 90); + if (angle90 == angle / 90) { /* if the angle is a multiple of 90 degrees */ angle90 %= 4; if (angle90 < 0) { angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */ } if (angle90 & 1) { - rect_dest->w = height; + rect_dest->w = height; rect_dest->h = width; *cangle = 0; *sangle = angle90 == 1 ? -1 : 1; /* reversed because our rotations are clockwise */ } else { - rect_dest->w = width; + rect_dest->w = width; rect_dest->h = height; *cangle = angle90 == 0 ? 1 : -1; *sangle = 0; @@ -174,19 +174,37 @@ SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FP } /* Computes source pointer X/Y increments for a rotation that's a multiple of 90 degrees. */ -static void -computeSourceIncrements90(SDL_Surface * src, int bpp, int angle, int flipx, int flipy, - int *sincx, int *sincy, int *signx, int *signy) +static void computeSourceIncrements90(SDL_Surface *src, int bpp, int angle, int flipx, int flipy, + int *sincx, int *sincy, int *signx, int *signy) { int pitch = flipy ? -src->pitch : src->pitch; if (flipx) { bpp = -bpp; } switch (angle) { /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */ - case 0: *sincx = bpp; *sincy = pitch - src->w * *sincx; *signx = *signy = 1; break; - case 1: *sincx = -pitch; *sincy = bpp - *sincx * src->h; *signx = 1; *signy = -1; break; - case 2: *sincx = -bpp; *sincy = -src->w * *sincx - pitch; *signx = *signy = -1; break; - case 3: default: *sincx = pitch; *sincy = -*sincx * src->h - bpp; *signx = -1; *signy = 1; break; + case 0: + *sincx = bpp; + *sincy = pitch - src->w * *sincx; + *signx = *signy = 1; + break; + case 1: + *sincx = -pitch; + *sincy = bpp - *sincx * src->h; + *signx = 1; + *signy = -1; + break; + case 2: + *sincx = -bpp; + *sincy = -src->w * *sincx - pitch; + *signx = *signy = -1; + break; + case 3: + default: + *sincx = pitch; + *sincy = -*sincx * src->h - bpp; + *signx = -1; + *signy = 1; + break; } if (flipx) { *signx = -*signx; @@ -197,34 +215,34 @@ computeSourceIncrements90(SDL_Surface * src, int bpp, int angle, int flipx, int } /* Performs a relatively fast rotation/flip when the angle is a multiple of 90 degrees. */ -#define TRANSFORM_SURFACE_90(pixelType) \ - int dy, dincy = dst->pitch - dst->w*sizeof(pixelType), sincx, sincy, signx, signy; \ - Uint8 *sp = (Uint8*)src->pixels, *dp = (Uint8*)dst->pixels, *de; \ +#define TRANSFORM_SURFACE_90(pixelType) \ + int dy, dincy = dst->pitch - dst->w * sizeof(pixelType), sincx, sincy, signx, signy; \ + Uint8 *sp = (Uint8 *)src->pixels, *dp = (Uint8 *)dst->pixels, *de; \ \ computeSourceIncrements90(src, sizeof(pixelType), angle, flipx, flipy, &sincx, &sincy, &signx, &signy); \ - if (signx < 0) sp += (src->w-1)*sizeof(pixelType); \ - if (signy < 0) sp += (src->h-1)*src->pitch; \ + if (signx < 0) \ + sp += (src->w - 1) * sizeof(pixelType); \ + if (signy < 0) \ + sp += (src->h - 1) * src->pitch; \ \ for (dy = 0; dy < dst->h; sp += sincy, dp += dincy, dy++) { \ if (sincx == sizeof(pixelType)) { /* if advancing src and dest equally, use SDL_memcpy */ \ - SDL_memcpy(dp, sp, dst->w*sizeof(pixelType)); \ - sp += dst->w*sizeof(pixelType); \ - dp += dst->w*sizeof(pixelType); \ + SDL_memcpy(dp, sp, dst->w * sizeof(pixelType)); \ + sp += dst->w * sizeof(pixelType); \ + dp += dst->w * sizeof(pixelType); \ } else { \ - for (de = dp + dst->w*sizeof(pixelType); dp != de; sp += sincx, dp += sizeof(pixelType)) { \ - *(pixelType*)dp = *(pixelType*)sp; \ + for (de = dp + dst->w * sizeof(pixelType); dp != de; sp += sincx, dp += sizeof(pixelType)) { \ + *(pixelType *)dp = *(pixelType *)sp; \ } \ } \ } -static void -transformSurfaceRGBA90(SDL_Surface * src, SDL_Surface * dst, int angle, int flipx, int flipy) +static void transformSurfaceRGBA90(SDL_Surface *src, SDL_Surface *dst, int angle, int flipx, int flipy) { TRANSFORM_SURFACE_90(tColorRGBA); } -static void -transformSurfaceY90(SDL_Surface * src, SDL_Surface * dst, int angle, int flipx, int flipy) +static void transformSurfaceY90(SDL_Surface *src, SDL_Surface *dst, int angle, int flipx, int flipy) { TRANSFORM_SURFACE_90(tColorY); } @@ -250,32 +268,31 @@ Assumes dst surface was allocated with the correct dimensions. \param dst_rect destination coordinates \param center true center. */ -static void -transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int isin, int icos, - int flipx, int flipy, int smooth, - const SDL_Rect *rect_dest, - const SDL_FPoint *center) +static void transformSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst, int isin, int icos, + int flipx, int flipy, int smooth, + const SDL_Rect *rect_dest, + const SDL_FPoint *center) { int sw, sh; int cx, cy; tColorRGBA c00, c01, c10, c11, cswap; tColorRGBA *pc, *sp; int gap; - const int fp_half = (1<<15); + const int fp_half = (1 << 15); /* - * Variable setup - */ + * Variable setup + */ sw = src->w - 1; sh = src->h - 1; - pc = (tColorRGBA*) dst->pixels; + pc = (tColorRGBA *)dst->pixels; gap = dst->pitch - dst->w * 4; cx = (int)(center->x * 65536.0); cy = (int)(center->y * 65536.0); /* - * Switch between interpolating and non-interpolating code - */ + * Switch between interpolating and non-interpolating code + */ if (smooth) { int y; for (y = 0; y < dst->h; y++) { @@ -293,28 +310,36 @@ transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int isin, int icos, if (flipy) { dy = sh - dy; } - if ((dx > -1) && (dy > -1) && (dx < (src->w-1)) && (dy < (src->h-1))) { + if ((dx > -1) && (dy > -1) && (dx < (src->w - 1)) && (dy < (src->h - 1))) { int ex, ey; int t1, t2; - sp = (tColorRGBA *) ((Uint8 *) src->pixels + src->pitch * dy) + dx; + sp = (tColorRGBA *)((Uint8 *)src->pixels + src->pitch * dy) + dx; c00 = *sp; sp += 1; c01 = *sp; - sp += (src->pitch/4); + sp += (src->pitch / 4); c11 = *sp; sp -= 1; c10 = *sp; if (flipx) { - cswap = c00; c00=c01; c01=cswap; - cswap = c10; c10=c11; c11=cswap; + cswap = c00; + c00 = c01; + c01 = cswap; + cswap = c10; + c10 = c11; + c11 = cswap; } if (flipy) { - cswap = c00; c00=c10; c10=cswap; - cswap = c01; c01=c11; c11=cswap; + cswap = c00; + c00 = c10; + c10 = cswap; + cswap = c01; + c01 = c11; + c11 = cswap; } /* - * Interpolate colors - */ + * Interpolate colors + */ ex = (sdx & 0xffff); ey = (sdy & 0xffff); t1 = ((((c01.r - c00.r) * ex) >> 16) + c00.r) & 0xff; @@ -334,7 +359,7 @@ transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int isin, int icos, sdy += isin; pc++; } - pc = (tColorRGBA *) ((Uint8 *) pc + gap); + pc = (tColorRGBA *)((Uint8 *)pc + gap); } } else { int y; @@ -360,7 +385,7 @@ transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int isin, int icos, sdy += isin; pc++; } - pc = (tColorRGBA *) ((Uint8 *) pc + gap); + pc = (tColorRGBA *)((Uint8 *)pc + gap); } } } @@ -383,35 +408,34 @@ Assumes dst surface was allocated with the correct dimensions. \param dst_rect destination coordinates \param center true center. */ -static void -transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int isin, int icos, int flipx, int flipy, - const SDL_Rect *rect_dest, - const SDL_FPoint *center) +static void transformSurfaceY(SDL_Surface *src, SDL_Surface *dst, int isin, int icos, int flipx, int flipy, + const SDL_Rect *rect_dest, + const SDL_FPoint *center) { int sw, sh; int cx, cy; tColorY *pc; int gap; - const int fp_half = (1<<15); + const int fp_half = (1 << 15); int y; /* - * Variable setup - */ + * Variable setup + */ sw = src->w - 1; sh = src->h - 1; - pc = (tColorY*) dst->pixels; + pc = (tColorY *)dst->pixels; gap = dst->pitch - dst->w; cx = (int)(center->x * 65536.0); cy = (int)(center->y * 65536.0); /* - * Clear surface to colorkey - */ + * Clear surface to colorkey + */ SDL_memset(pc, (int)(get_colorkey(src) & 0xff), dst->pitch * dst->h); /* - * Iterate through destination surface - */ + * Iterate through destination surface + */ for (y = 0; y < dst->h; y++) { int x; double src_x = (rect_dest->x + 0 + 0.5 - center->x); @@ -438,7 +462,6 @@ transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int isin, int icos, int } } - /* ! \brief Rotates and zooms a surface with different horizontal and vertival scaling factors and optional anti-aliasing. @@ -466,8 +489,8 @@ When using the NONE and MOD modes, color and alpha modulation must be applied be */ SDL_Surface * -SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int flipy, - const SDL_Rect *rect_dest, double cangle, double sangle, const SDL_FPoint *center) +SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, int flipx, int flipy, + const SDL_Rect *rect_dest, double cangle, double sangle, const SDL_FPoint *center) { SDL_Surface *rz_dst; int is8bit, angle90; @@ -494,8 +517,8 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int } /* Calculate target factors from sine/cosine and zoom */ - sangleinv = sangle*65536.0; - cangleinv = cangle*65536.0; + sangleinv = sangle * 65536.0; + cangleinv = cangle * 65536.0; /* Alloc space to completely contain the rotated surface */ rz_dst = NULL; @@ -557,8 +580,8 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int * the off-by-one problem in transformSurfaceRGBA that expresses itself when the rotation is near * multiples of 90 degrees. */ - angle90 = (int)(angle/90); - if (angle90 == angle/90) { + angle90 = (int)(angle / 90); + if (angle90 == angle / 90) { angle90 %= 4; if (angle90 < 0) { angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */ @@ -582,7 +605,7 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int transformSurfaceRGBA90(src, rz_dst, angle90, flipx, flipy); } else { transformSurfaceRGBA(src, rz_dst, (int)sangleinv, (int)cangleinv, - flipx, flipy, smooth, rect_dest, center); + flipx, flipy, smooth, rect_dest, center); } } diff --git a/src/render/software/SDL_rotate.h b/src/render/software/SDL_rotate.h index 8d7ec9d28..eecc7df0a 100644 --- a/src/render/software/SDL_rotate.h +++ b/src/render/software/SDL_rotate.h @@ -22,9 +22,9 @@ #ifndef SDL_rotate_h_ #define SDL_rotate_h_ -extern SDL_Surface *SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int flipy, - const SDL_Rect *rect_dest, double cangle, double sangle, const SDL_FPoint *center); +extern SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, int flipx, int flipy, + const SDL_Rect *rect_dest, double cangle, double sangle, const SDL_FPoint *center); extern void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FPoint *center, - SDL_Rect *rect_dest, double *cangle, double *sangle); + SDL_Rect *rect_dest, double *cangle, double *sangle); #endif /* SDL_rotate_h_ */ diff --git a/src/render/software/SDL_triangle.c b/src/render/software/SDL_triangle.c index 38e2e2d0d..f924427c9 100644 --- a/src/render/software/SDL_triangle.c +++ b/src/render/software/SDL_triangle.c @@ -33,16 +33,15 @@ * But, if increased too much, it overflows (srcx, srcy) coordinates used for filling with texture. * (which could be turned to int64). */ -#define FP_BITS 1 +#define FP_BITS 1 +#define COLOR_EQ(c1, c2) ((c1).r == (c2).r && (c1).g == (c2).g && (c1).b == (c2).b && (c1).a == (c2).a) -#define COLOR_EQ(c1, c2) ((c1).r == (c2).r && (c1).g == (c2).g && (c1).b == (c2).b && (c1).a == (c2).a) - -static void SDL_BlitTriangle_Slow(SDL_BlitInfo * info, - SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2, - int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x, - int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row, - SDL_Color c0, SDL_Color c1, SDL_Color c2, int is_uniform); +static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info, + SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2, + int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x, + int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row, + SDL_Color c0, SDL_Color c1, SDL_Color c2, int is_uniform); #if 0 int SDL_BlitTriangle(SDL_Surface *src, const SDL_Point srcpoints[3], SDL_Surface *dst, const SDL_Point dstpoints[3]) @@ -114,7 +113,8 @@ static int is_top_left(const SDL_Point *a, const SDL_Point *b, int is_clockwise) return 0; } -void trianglepoint_2_fixedpoint(SDL_Point *a) { +void trianglepoint_2_fixedpoint(SDL_Point *a) +{ a->x <<= FP_BITS; a->y <<= FP_BITS; } @@ -146,7 +146,6 @@ static void bounding_rect(const SDL_Point *a, const SDL_Point *b, const SDL_Poin r->h = (max_y - min_y); } - /* Triangle rendering, using Barycentric coordinates (w0, w1, w2) * * The cross product isn't computed from scratch at each iteration, @@ -154,53 +153,51 @@ static void bounding_rect(const SDL_Point *a, const SDL_Point *b, const SDL_Poin * */ -#define TRIANGLE_BEGIN_LOOP \ - { \ - int x, y; \ - for (y = 0; y < dstrect.h; y++) { \ - /* y start */ \ - int w0 = w0_row; \ - int w1 = w1_row; \ - int w2 = w2_row; \ - for (x = 0; x < dstrect.w; x++) { \ - /* In triangle */ \ - if (w0 + bias_w0 >= 0 && w1 + bias_w1 >= 0 && w2 + bias_w2 >= 0) { \ - Uint8 *dptr = (Uint8 *) dst_ptr + x * dstbpp; \ - +#define TRIANGLE_BEGIN_LOOP \ + { \ + int x, y; \ + for (y = 0; y < dstrect.h; y++) { \ + /* y start */ \ + int w0 = w0_row; \ + int w1 = w1_row; \ + int w2 = w2_row; \ + for (x = 0; x < dstrect.w; x++) { \ + /* In triangle */ \ + if (w0 + bias_w0 >= 0 && w1 + bias_w1 >= 0 && w2 + bias_w2 >= 0) { \ + Uint8 *dptr = (Uint8 *)dst_ptr + x * dstbpp; /* Use 64 bits precision to prevent overflow when interpolating color / texture with wide triangles */ -#define TRIANGLE_GET_TEXTCOORD \ - int srcx = (int)(((Sint64)w0 * s2s0_x + (Sint64)w1 * s2s1_x + s2_x_area.x) / area); \ - int srcy = (int)(((Sint64)w0 * s2s0_y + (Sint64)w1 * s2s1_y + s2_x_area.y) / area); \ +#define TRIANGLE_GET_TEXTCOORD \ + int srcx = (int)(((Sint64)w0 * s2s0_x + (Sint64)w1 * s2s1_x + s2_x_area.x) / area); \ + int srcy = (int)(((Sint64)w0 * s2s0_y + (Sint64)w1 * s2s1_y + s2_x_area.y) / area); -#define TRIANGLE_GET_MAPPED_COLOR \ - int r = (int)(((Sint64)w0 * c0.r + (Sint64)w1 * c1.r + (Sint64)w2 * c2.r) / area); \ - int g = (int)(((Sint64)w0 * c0.g + (Sint64)w1 * c1.g + (Sint64)w2 * c2.g) / area); \ - int b = (int)(((Sint64)w0 * c0.b + (Sint64)w1 * c1.b + (Sint64)w2 * c2.b) / area); \ - int a = (int)(((Sint64)w0 * c0.a + (Sint64)w1 * c1.a + (Sint64)w2 * c2.a) / area); \ - int color = SDL_MapRGBA(format, r, g, b, a); \ +#define TRIANGLE_GET_MAPPED_COLOR \ + int r = (int)(((Sint64)w0 * c0.r + (Sint64)w1 * c1.r + (Sint64)w2 * c2.r) / area); \ + int g = (int)(((Sint64)w0 * c0.g + (Sint64)w1 * c1.g + (Sint64)w2 * c2.g) / area); \ + int b = (int)(((Sint64)w0 * c0.b + (Sint64)w1 * c1.b + (Sint64)w2 * c2.b) / area); \ + int a = (int)(((Sint64)w0 * c0.a + (Sint64)w1 * c1.a + (Sint64)w2 * c2.a) / area); \ + int color = SDL_MapRGBA(format, r, g, b, a); -#define TRIANGLE_GET_COLOR \ - int r = (int)(((Sint64)w0 * c0.r + (Sint64)w1 * c1.r + (Sint64)w2 * c2.r) / area); \ - int g = (int)(((Sint64)w0 * c0.g + (Sint64)w1 * c1.g + (Sint64)w2 * c2.g) / area); \ - int b = (int)(((Sint64)w0 * c0.b + (Sint64)w1 * c1.b + (Sint64)w2 * c2.b) / area); \ - int a = (int)(((Sint64)w0 * c0.a + (Sint64)w1 * c1.a + (Sint64)w2 * c2.a) / area); \ +#define TRIANGLE_GET_COLOR \ + int r = (int)(((Sint64)w0 * c0.r + (Sint64)w1 * c1.r + (Sint64)w2 * c2.r) / area); \ + int g = (int)(((Sint64)w0 * c0.g + (Sint64)w1 * c1.g + (Sint64)w2 * c2.g) / area); \ + int b = (int)(((Sint64)w0 * c0.b + (Sint64)w1 * c1.b + (Sint64)w2 * c2.b) / area); \ + int a = (int)(((Sint64)w0 * c0.a + (Sint64)w1 * c1.a + (Sint64)w2 * c2.a) / area); - -#define TRIANGLE_END_LOOP \ - } \ - /* x += 1 */ \ - w0 += d2d1_y; \ - w1 += d0d2_y; \ - w2 += d1d0_y; \ - } \ - /* y += 1 */ \ - w0_row += d1d2_x; \ - w1_row += d2d0_x; \ - w2_row += d0d1_x; \ - dst_ptr += dst_pitch; \ - } \ - } \ +#define TRIANGLE_END_LOOP \ + } \ + /* x += 1 */ \ + w0 += d2d1_y; \ + w1 += d0d2_y; \ + w2 += d1d0_y; \ + } \ + /* y += 1 */ \ + w0_row += d1d2_x; \ + w1_row += d2d0_x; \ + w2_row += d0d1_x; \ + dst_ptr += dst_pitch; \ + } \ + } int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Point *d2, SDL_BlendMode blend, SDL_Color c0, SDL_Color c1, SDL_Color c2) { @@ -265,12 +262,11 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin SDL_IntersectRect(&dstrect, &rect, &dstrect); } - if (blend != SDL_BLENDMODE_NONE) { int format = dst->format->format; /* need an alpha format */ - if (! dst->format->Amask) { + if (!dst->format->Amask) { format = SDL_PIXELFORMAT_ARGB8888; } @@ -323,7 +319,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin } /* Handle anti-clockwise triangles */ - if (! is_clockwise) { + if (!is_clockwise) { d2d1_y *= -1; d0d2_y *= -1; d1d0_y *= -1; @@ -346,7 +342,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin if (dst->format->Amask) { color = SDL_MapRGBA(tmp->format, c0.r, c0.g, c0.b, c0.a); } else { - //color = SDL_MapRGB(tmp->format, c0.r, c0.g, c0.b); + // color = SDL_MapRGB(tmp->format, c0.r, c0.g, c0.b); color = SDL_MapRGBA(tmp->format, c0.r, c0.g, c0.b, c0.a); } } else { @@ -362,7 +358,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin } else if (dstbpp == 3) { TRIANGLE_BEGIN_LOOP { - Uint8 *s = (Uint8*)&color; + Uint8 *s = (Uint8 *)&color; dptr[0] = s[0]; dptr[1] = s[1]; dptr[2] = s[2]; @@ -397,7 +393,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin TRIANGLE_BEGIN_LOOP { TRIANGLE_GET_MAPPED_COLOR - Uint8 *s = (Uint8*)&color; + Uint8 *s = (Uint8 *)&color; dptr[0] = s[0]; dptr[1] = s[1]; dptr[2] = s[2]; @@ -433,18 +429,12 @@ end: return ret; } - - - - - - int SDL_SW_BlitTriangle( - SDL_Surface *src, - SDL_Point *s0, SDL_Point *s1, SDL_Point *s2, - SDL_Surface *dst, - SDL_Point *d0, SDL_Point *d1, SDL_Point *d2, - SDL_Color c0, SDL_Color c1, SDL_Color c2) + SDL_Surface *src, + SDL_Point *s0, SDL_Point *s1, SDL_Point *s2, + SDL_Surface *dst, + SDL_Point *d0, SDL_Point *d1, SDL_Point *d2, + SDL_Color c0, SDL_Color c1, SDL_Color c2) { int ret = 0; int src_locked = 0; @@ -584,7 +574,6 @@ int SDL_SW_BlitTriangle( d0d2_y = (d2->y - d0->y) << FP_BITS; d1d0_y = (d0->y - d1->y) << FP_BITS; - d1d2_x = (d2->x - d1->x) << FP_BITS; d2d0_x = (d0->x - d2->x) << FP_BITS; d0d1_x = (d1->x - d0->x) << FP_BITS; @@ -608,7 +597,7 @@ int SDL_SW_BlitTriangle( } /* Handle anti-clockwise triangles */ - if (! is_clockwise) { + if (!is_clockwise) { d2d1_y *= -1; d0d2_y *= -1; d1d0_y *= -1; @@ -629,7 +618,7 @@ int SDL_SW_BlitTriangle( s2_x_area.x = s2->x * area; s2_x_area.y = s2->y * area; - if (blend != SDL_BLENDMODE_NONE || src->format->format != dst->format->format || has_modulation || ! is_uniform) { + if (blend != SDL_BLENDMODE_NONE || src->format->format != dst->format->format || has_modulation || !is_uniform) { /* Use SDL_BlitTriangle_Slow */ SDL_BlitInfo *info = &src->map->info; @@ -651,12 +640,11 @@ int SDL_SW_BlitTriangle( tmp_info.b = c0.b; tmp_info.a = c0.a; - tmp_info.flags &= ~(SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA); - if (c0.r != 255 || c1.r != 255 || c2.r != 255 || - c0.g != 255 || c1.g != 255 || c2.g != 255 || - c0.b != 255 || c1.b != 255 || c2.b != 255) { + if (c0.r != 255 || c1.r != 255 || c2.r != 255 || + c0.g != 255 || c1.g != 255 || c2.g != 255 || + c0.b != 255 || c1.b != 255 || c2.b != 255) { tmp_info.flags |= SDL_COPY_MODULATE_COLOR; } @@ -667,17 +655,17 @@ int SDL_SW_BlitTriangle( tmp_info.colorkey = info->colorkey; /* src */ - tmp_info.src = (Uint8 *) src_ptr; + tmp_info.src = (Uint8 *)src_ptr; tmp_info.src_pitch = src_pitch; /* dst */ - tmp_info.dst = (Uint8 *) dst_ptr; + tmp_info.dst = (Uint8 *)dst_ptr; tmp_info.dst_pitch = dst_pitch; SDL_BlitTriangle_Slow(&tmp_info, s2_x_area, dstrect, area, bias_w0, bias_w1, bias_w2, - d2d1_y, d1d2_x, d0d2_y, d2d0_x, d1d0_y, d0d1_x, - s2s0_x, s2s1_x, s2s0_y, s2s1_y, w0_row, w1_row, w2_row, - c0, c1, c2, is_uniform); + d2d1_y, d1d2_x, d0d2_y, d2d0_x, d1d0_y, d0d1_x, + s2s0_x, s2s1_x, s2s0_y, s2s1_y, w0_row, w1_row, w2_row, + c0, c1, c2, is_uniform); goto end; } @@ -686,7 +674,7 @@ int SDL_SW_BlitTriangle( TRIANGLE_BEGIN_LOOP { TRIANGLE_GET_TEXTCOORD - Uint32 *sptr = (Uint32 *)((Uint8 *) src_ptr + srcy * src_pitch); + Uint32 *sptr = (Uint32 *)((Uint8 *)src_ptr + srcy * src_pitch); *(Uint32 *)dptr = sptr[srcx]; } TRIANGLE_END_LOOP @@ -694,7 +682,7 @@ int SDL_SW_BlitTriangle( TRIANGLE_BEGIN_LOOP { TRIANGLE_GET_TEXTCOORD - Uint8 *sptr = (Uint8 *)((Uint8 *) src_ptr + srcy * src_pitch); + Uint8 *sptr = (Uint8 *)((Uint8 *)src_ptr + srcy * src_pitch); dptr[0] = sptr[3 * srcx]; dptr[1] = sptr[3 * srcx + 1]; dptr[2] = sptr[3 * srcx + 2]; @@ -704,7 +692,7 @@ int SDL_SW_BlitTriangle( TRIANGLE_BEGIN_LOOP { TRIANGLE_GET_TEXTCOORD - Uint16 *sptr = (Uint16 *)((Uint8 *) src_ptr + srcy * src_pitch); + Uint16 *sptr = (Uint16 *)((Uint8 *)src_ptr + srcy * src_pitch); *(Uint16 *)dptr = sptr[srcx]; } TRIANGLE_END_LOOP @@ -712,7 +700,7 @@ int SDL_SW_BlitTriangle( TRIANGLE_BEGIN_LOOP { TRIANGLE_GET_TEXTCOORD - Uint8 *sptr = (Uint8 *)((Uint8 *) src_ptr + srcy * src_pitch); + Uint8 *sptr = (Uint8 *)((Uint8 *)src_ptr + srcy * src_pitch); *dptr = sptr[srcx]; } TRIANGLE_END_LOOP @@ -729,13 +717,13 @@ end: return ret; } - -#define FORMAT_ALPHA 0 -#define FORMAT_NO_ALPHA -1 -#define FORMAT_2101010 1 -#define FORMAT_HAS_ALPHA(format) format == 0 -#define FORMAT_HAS_NO_ALPHA(format) format < 0 -static int SDL_INLINE detect_format(SDL_PixelFormat *pf) { +#define FORMAT_ALPHA 0 +#define FORMAT_NO_ALPHA -1 +#define FORMAT_2101010 1 +#define FORMAT_HAS_ALPHA(format) format == 0 +#define FORMAT_HAS_NO_ALPHA(format) format < 0 +static int SDL_INLINE detect_format(SDL_PixelFormat *pf) +{ if (pf->format == SDL_PIXELFORMAT_ARGB2101010) { return FORMAT_2101010; } else if (pf->Amask) { @@ -745,12 +733,11 @@ static int SDL_INLINE detect_format(SDL_PixelFormat *pf) { } } -static void -SDL_BlitTriangle_Slow(SDL_BlitInfo *info, - SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2, - int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x, - int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row, - SDL_Color c0, SDL_Color c1, SDL_Color c2, int is_uniform) +static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info, + SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2, + int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x, + int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row, + SDL_Color c0, SDL_Color c1, SDL_Color c2, int is_uniform) { const int flags = info->flags; Uint32 modulateR = info->r; @@ -796,7 +783,7 @@ SDL_BlitTriangle_Slow(SDL_BlitInfo *info, /* srcpixel isn't set for 24 bpp */ if (srcbpp == 3) { srcpixel = (srcR << src_fmt->Rshift) | - (srcG << src_fmt->Gshift) | (srcB << src_fmt->Bshift); + (srcG << src_fmt->Gshift) | (srcB << src_fmt->Bshift); } if ((srcpixel & rgbmask) == ckey) { continue; @@ -813,7 +800,7 @@ SDL_BlitTriangle_Slow(SDL_BlitInfo *info, RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA); } - if (! is_uniform) { + if (!is_uniform) { TRIANGLE_GET_COLOR modulateR = r; modulateG = g; diff --git a/src/render/software/SDL_triangle.h b/src/render/software/SDL_triangle.h index c120b39cf..5cc040742 100644 --- a/src/render/software/SDL_triangle.h +++ b/src/render/software/SDL_triangle.h @@ -25,15 +25,15 @@ #include "../../SDL_internal.h" extern int SDL_SW_FillTriangle(SDL_Surface *dst, - SDL_Point *d0, SDL_Point *d1, SDL_Point *d2, - SDL_BlendMode blend, SDL_Color c0, SDL_Color c1, SDL_Color c2); + SDL_Point *d0, SDL_Point *d1, SDL_Point *d2, + SDL_BlendMode blend, SDL_Color c0, SDL_Color c1, SDL_Color c2); extern int SDL_SW_BlitTriangle( - SDL_Surface *src, - SDL_Point *s0, SDL_Point *s1, SDL_Point *s2, - SDL_Surface *dst, - SDL_Point *d0, SDL_Point *d1, SDL_Point *d2, - SDL_Color c0, SDL_Color c1, SDL_Color c2); + SDL_Surface *src, + SDL_Point *s0, SDL_Point *s1, SDL_Point *s2, + SDL_Surface *dst, + SDL_Point *d0, SDL_Point *d1, SDL_Point *d2, + SDL_Color c0, SDL_Color c1, SDL_Color c2); extern void trianglepoint_2_fixedpoint(SDL_Point *a); diff --git a/src/render/vitagxm/SDL_render_vita_gxm.c b/src/render/vitagxm/SDL_render_vita_gxm.c index 745617983..c657b0fa2 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm.c +++ b/src/render/vitagxm/SDL_render_vita_gxm.c @@ -48,63 +48,58 @@ static SDL_Renderer *VITA_GXM_CreateRenderer(SDL_Window *window, Uint32 flags); static void VITA_GXM_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event); -static SDL_bool VITA_GXM_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode); +static SDL_bool VITA_GXM_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode); static int VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture); static int VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, - const SDL_Rect *rect, const void *pixels, int pitch); + const SDL_Rect *rect, const void *pixels, int pitch); -static int VITA_GXM_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *Uplane, int Upitch, - const Uint8 *Vplane, int Vpitch); +static int VITA_GXM_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); -static int VITA_GXM_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *UVplane, int UVpitch); +static int VITA_GXM_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch); static int VITA_GXM_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, - const SDL_Rect *rect, void **pixels, int *pitch); + const SDL_Rect *rect, void **pixels, int *pitch); static void VITA_GXM_UnlockTexture(SDL_Renderer *renderer, - SDL_Texture *texture); + SDL_Texture *texture); -static void VITA_GXM_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode); +static void VITA_GXM_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode); static int VITA_GXM_SetRenderTarget(SDL_Renderer *renderer, - SDL_Texture *texture); + SDL_Texture *texture); +static int VITA_GXM_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd); -static int VITA_GXM_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd); +static int VITA_GXM_QueueSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd); -static int VITA_GXM_QueueSetDrawColor(SDL_Renderer * renderer, SDL_RenderCommand *cmd); +static int VITA_GXM_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count); +static int VITA_GXM_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count); - -static int VITA_GXM_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count); -static int VITA_GXM_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count); - -static int -VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, - const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, - int num_vertices, const void *indices, int num_indices, int size_indices, - float scale_x, float scale_y); +static int VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, + int num_vertices, const void *indices, int num_indices, int size_indices, + float scale_x, float scale_y); static int VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd); -static int VITA_GXM_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize); +static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize); static int VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, - Uint32 pixel_format, void *pixels, int pitch); - + Uint32 pixel_format, void *pixels, int pitch); static int VITA_GXM_RenderPresent(SDL_Renderer *renderer); static void VITA_GXM_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture); static void VITA_GXM_DestroyRenderer(SDL_Renderer *renderer); - SDL_RenderDriver VITA_GXM_RenderDriver = { .CreateRenderer = VITA_GXM_CreateRenderer, .info = { @@ -123,11 +118,10 @@ SDL_RenderDriver VITA_GXM_RenderDriver = { }, .max_texture_width = 4096, .max_texture_height = 4096, - } + } }; -static int -PixelFormatToVITAFMT(Uint32 format) +static int PixelFormatToVITAFMT(Uint32 format) { switch (format) { case SDL_PIXELFORMAT_ARGB8888: @@ -156,10 +150,9 @@ PixelFormatToVITAFMT(Uint32 format) } } -void -StartDrawing(SDL_Renderer *renderer) +void StartDrawing(SDL_Renderer *renderer) { - VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata; if (data->drawing) { return; } @@ -171,10 +164,10 @@ StartDrawing(SDL_Renderer *renderer) data->drawstate.viewport_dirty = SDL_TRUE; // reset blend mode -// data->currentBlendMode = SDL_BLENDMODE_BLEND; -// fragment_programs *in = &data->blendFragmentPrograms.blend_mode_blend; -// data->colorFragmentProgram = in->color; -// data->textureFragmentProgram = in->texture; + // data->currentBlendMode = SDL_BLENDMODE_BLEND; + // fragment_programs *in = &data->blendFragmentPrograms.blend_mode_blend; + // data->colorFragmentProgram = in->color; + // data->textureFragmentProgram = in->texture; if (renderer->target == NULL) { sceGxmBeginScene( @@ -185,10 +178,9 @@ StartDrawing(SDL_Renderer *renderer) NULL, data->displayBufferSync[data->backBufferIndex], &data->displaySurface[data->backBufferIndex], - &data->depthSurface - ); + &data->depthSurface); } else { - VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *) renderer->target->driverdata; + VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)renderer->target->driverdata; sceGxmBeginScene( data->gxm_context, @@ -198,17 +190,15 @@ StartDrawing(SDL_Renderer *renderer) NULL, NULL, &vita_texture->tex->gxm_colorsurface, - &vita_texture->tex->gxm_depthstencil - ); + &vita_texture->tex->gxm_depthstencil); } -// unset_clip_rectangle(data); + // unset_clip_rectangle(data); data->drawing = SDL_TRUE; } -static int -VITA_GXM_SetVSync(SDL_Renderer * renderer, const int vsync) +static int VITA_GXM_SetVSync(SDL_Renderer *renderer, const int vsync) { VITA_GXM_RenderData *data = renderer->driverdata; if (vsync) { @@ -227,13 +217,13 @@ VITA_GXM_CreateRenderer(SDL_Window *window, Uint32 flags) SDL_Renderer *renderer; VITA_GXM_RenderData *data; - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); if (renderer == NULL) { SDL_OutOfMemory(); return NULL; } - data = (VITA_GXM_RenderData *) SDL_calloc(1, sizeof(VITA_GXM_RenderData)); + data = (VITA_GXM_RenderData *)SDL_calloc(1, sizeof(VITA_GXM_RenderData)); if (data == NULL) { SDL_free(renderer); SDL_OutOfMemory(); @@ -278,8 +268,8 @@ VITA_GXM_CreateRenderer(SDL_Window *window, Uint32 flags) } #if DEBUG_RAZOR - sceSysmoduleLoadModule( SCE_SYSMODULE_RAZOR_HUD ); - sceSysmoduleLoadModule( SCE_SYSMODULE_RAZOR_CAPTURE ); + sceSysmoduleLoadModule(SCE_SYSMODULE_RAZOR_HUD); + sceSysmoduleLoadModule(SCE_SYSMODULE_RAZOR_CAPTURE); #endif if (gxm_init(renderer) != 0) { @@ -291,23 +281,20 @@ VITA_GXM_CreateRenderer(SDL_Window *window, Uint32 flags) return renderer; } -static void -VITA_GXM_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event) +static void VITA_GXM_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event) { } -static SDL_bool -VITA_GXM_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +static SDL_bool VITA_GXM_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { // only for custom modes. we build all modes on init, so no custom modes, sorry return SDL_FALSE; } -static int -VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) +static int VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; - VITA_GXM_TextureData* vita_texture = (VITA_GXM_TextureData*) SDL_calloc(1, sizeof(VITA_GXM_TextureData)); + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata; + VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)SDL_calloc(1, sizeof(VITA_GXM_TextureData)); if (vita_texture == NULL) { return SDL_OutOfMemory(); @@ -322,8 +309,7 @@ VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) &(vita_texture->w), &(vita_texture->h), &(vita_texture->pitch), - &(vita_texture->wscale) - ); + &(vita_texture->wscale)); if (!vita_texture->tex) { SDL_free(vita_texture); @@ -342,9 +328,9 @@ VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) return 0; } -static void VITA_GXM_SetYUVProfile(SDL_Renderer * renderer, SDL_Texture *texture) +static void VITA_GXM_SetYUVProfile(SDL_Renderer *renderer, SDL_Texture *texture) { - VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata; int ret = 0; switch (SDL_GetYUVConversionModeForResolution(texture->w, texture->h)) { case SDL_YUV_CONVERSION_BT601: @@ -357,18 +343,17 @@ static void VITA_GXM_SetYUVProfile(SDL_Renderer * renderer, SDL_Texture *texture default: SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Unsupported YUV profile: %d\n", SDL_GetYUVConversionModeForResolution(texture->w, texture->h)); break; - } + } - if (ret < 0) { - SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Setting YUV profile failed: %x\n", ret); - } + if (ret < 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Setting YUV profile failed: %x\n", ret); + } } -static int -VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, - const SDL_Rect *rect, const void *pixels, int pitch) +static int VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, const void *pixels, int pitch) { - VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *) texture->driverdata; + VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)texture->driverdata; Uint8 *dst; int row, length, dpitch; @@ -381,7 +366,7 @@ VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, VITA_GXM_LockTexture(renderer, texture, rect, (void **)&dst, &dpitch); length = rect->w * SDL_BYTESPERPIXEL(texture->format); if (length == pitch && length == dpitch) { - SDL_memcpy(dst, pixels, length*rect->h); + SDL_memcpy(dst, pixels, length * rect->h); } else { for (row = 0; row < rect->h; ++row) { SDL_memcpy(dst, pixels, length); @@ -394,9 +379,9 @@ VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, if (vita_texture->yuv) { void *Udst; void *Vdst; - int uv_pitch = (dpitch+1) / 2; - int uv_src_pitch = (pitch+1) / 2; - SDL_Rect UVrect = {rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2}; + int uv_pitch = (dpitch + 1) / 2; + int uv_src_pitch = (pitch + 1) / 2; + SDL_Rect UVrect = { rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2 }; // skip Y plane Uint8 *Dpixels = gxm_texture_get_datap(vita_texture->tex) + (vita_texture->pitch * vita_texture->h); @@ -408,7 +393,7 @@ VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, // U plane if (length == uv_src_pitch && length == uv_pitch) { - SDL_memcpy(Udst, pixels, length*UVrect.h); + SDL_memcpy(Udst, pixels, length * UVrect.h); } else { for (row = 0; row < UVrect.h; ++row) { SDL_memcpy(Udst, pixels, length); @@ -419,7 +404,7 @@ VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, // V plane if (length == uv_src_pitch && length == uv_pitch) { - SDL_memcpy(Vdst, pixels, length*UVrect.h); + SDL_memcpy(Vdst, pixels, length * UVrect.h); } else { for (row = 0; row < UVrect.h; ++row) { SDL_memcpy(Vdst, pixels, length); @@ -430,19 +415,19 @@ VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, } else if (vita_texture->nv12) { void *UVdst; - int uv_pitch = 2 * ((dpitch+1) / 2); - int uv_src_pitch = 2 * ((pitch+1) / 2); - SDL_Rect UVrect = {rect->x / 2, rect->y / 2, (rect->w + 1) / 2 , (rect->h + 1) / 2}; + int uv_pitch = 2 * ((dpitch + 1) / 2); + int uv_src_pitch = 2 * ((pitch + 1) / 2); + SDL_Rect UVrect = { rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2 }; // skip Y plane - void *Dpixels = (void *) ((Uint8 *) gxm_texture_get_datap(vita_texture->tex) + (vita_texture->pitch * vita_texture->h)); + void *Dpixels = (void *)((Uint8 *)gxm_texture_get_datap(vita_texture->tex) + (vita_texture->pitch * vita_texture->h)); UVdst = Dpixels + (UVrect.y * uv_pitch) + UVrect.x; - length = UVrect.w*2; + length = UVrect.w * 2; // UV plane if (length == uv_src_pitch && length == uv_pitch) { - SDL_memcpy(UVdst, pixels, length*UVrect.h); + SDL_memcpy(UVdst, pixels, length * UVrect.h); } else { for (row = 0; row < UVrect.h; ++row) { SDL_memcpy(UVdst, pixels, length); @@ -457,16 +442,15 @@ VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, } #if SDL_HAVE_YUV -static int -VITA_GXM_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *Uplane, int Upitch, - const Uint8 *Vplane, int Vpitch) +static int VITA_GXM_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) { Uint8 *dst; int row, length, dpitch; - SDL_Rect UVrect = {rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2}; + SDL_Rect UVrect = { rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2 }; VITA_GXM_SetYUVProfile(renderer, texture); @@ -477,7 +461,7 @@ VITA_GXM_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, length = rect->w; if (length == Ypitch && length == dpitch) { - SDL_memcpy(dst, Yplane, length*rect->h); + SDL_memcpy(dst, Yplane, length * rect->h); } else { for (row = 0; row < rect->h; ++row) { SDL_memcpy(dst, Yplane, length); @@ -490,11 +474,11 @@ VITA_GXM_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, { void *Udst; void *Vdst; - VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *) texture->driverdata; - int uv_pitch = (dpitch+1) / 2; + VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)texture->driverdata; + int uv_pitch = (dpitch + 1) / 2; // skip Y plane - void *pixels = (void *) ((Uint8 *) gxm_texture_get_datap(vita_texture->tex) + (vita_texture->pitch * vita_texture->h)); + void *pixels = (void *)((Uint8 *)gxm_texture_get_datap(vita_texture->tex) + (vita_texture->pitch * vita_texture->h)); if (texture->format == SDL_PIXELFORMAT_YV12) { // YVU Vdst = pixels + (UVrect.y * uv_pitch) + UVrect.x; @@ -508,7 +492,7 @@ VITA_GXM_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, // U plane if (length == Upitch && length == uv_pitch) { - SDL_memcpy(Udst, Uplane, length*UVrect.h); + SDL_memcpy(Udst, Uplane, length * UVrect.h); } else { for (row = 0; row < UVrect.h; ++row) { SDL_memcpy(Udst, Uplane, length); @@ -519,7 +503,7 @@ VITA_GXM_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, // V plane if (length == Vpitch && length == uv_pitch) { - SDL_memcpy(Vdst, Vplane, length*UVrect.h); + SDL_memcpy(Vdst, Vplane, length * UVrect.h); } else { for (row = 0; row < UVrect.h; ++row) { SDL_memcpy(Vdst, Vplane, length); @@ -527,22 +511,20 @@ VITA_GXM_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, Vdst += uv_pitch; } } - } return 0; } -static int -VITA_GXM_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *UVplane, int UVpitch) +static int VITA_GXM_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch) { Uint8 *dst; int row, length, dpitch; - SDL_Rect UVrect = {rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2}; + SDL_Rect UVrect = { rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2 }; VITA_GXM_SetYUVProfile(renderer, texture); @@ -552,10 +534,10 @@ VITA_GXM_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, length = rect->w * SDL_BYTESPERPIXEL(texture->format); if (length == Ypitch && length == dpitch) { - SDL_memcpy(dst, Yplane, length*rect->h); + SDL_memcpy(dst, Yplane, length * rect->h); } else { for (row = 0; row < rect->h; ++row) { - SDL_memcpy(dst, Yplane, length); + SDL_memcpy(dst, Yplane, length); Yplane += Ypitch; dst += dpitch; } @@ -564,11 +546,11 @@ VITA_GXM_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, // UV plane { void *UVdst; - VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *) texture->driverdata; - int uv_pitch = 2 * ((dpitch+1) / 2); + VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)texture->driverdata; + int uv_pitch = 2 * ((dpitch + 1) / 2); // skip Y plane - void *pixels = (void *) ((Uint8 *) gxm_texture_get_datap(vita_texture->tex) + (vita_texture->pitch * vita_texture->h)); + void *pixels = (void *)((Uint8 *)gxm_texture_get_datap(vita_texture->tex) + (vita_texture->pitch * vita_texture->h)); UVdst = pixels + (UVrect.y * uv_pitch) + UVrect.x; @@ -576,7 +558,7 @@ VITA_GXM_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, // UV plane if (length == UVpitch && length == uv_pitch) { - SDL_memcpy(UVdst, UVplane, length*UVrect.h); + SDL_memcpy(UVdst, UVplane, length * UVrect.h); } else { for (row = 0; row < UVrect.h; ++row) { SDL_memcpy(UVdst, UVplane, length); @@ -591,16 +573,14 @@ VITA_GXM_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, #endif -static int -VITA_GXM_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, - const SDL_Rect *rect, void **pixels, int *pitch) +static int VITA_GXM_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, void **pixels, int *pitch) { - VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; - VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *) texture->driverdata; + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata; + VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)texture->driverdata; *pixels = - (void *) ((Uint8 *) gxm_texture_get_datap(vita_texture->tex) - + (rect->y * vita_texture->pitch) + rect->x * SDL_BYTESPERPIXEL(texture->format)); + (void *)((Uint8 *)gxm_texture_get_datap(vita_texture->tex) + (rect->y * vita_texture->pitch) + rect->x * SDL_BYTESPERPIXEL(texture->format)); *pitch = vita_texture->pitch; // make sure that rendering is finished on render target textures @@ -611,18 +591,16 @@ VITA_GXM_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, return 0; } -static void -VITA_GXM_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) +static void VITA_GXM_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) { // No need to update texture data on ps vita. // VITA_GXM_LockTexture already returns a pointer to the texture pixels buffer. // This really improves framerate when using lock/unlock. } -static void -VITA_GXM_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode) +static void VITA_GXM_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode) { - VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *) texture->driverdata; + VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)texture->driverdata; /* set texture filtering according to scaleMode @@ -632,42 +610,39 @@ VITA_GXM_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL */ int vitaScaleMode = (scaleMode == SDL_ScaleModeNearest - ? SCE_GXM_TEXTURE_FILTER_POINT - : SCE_GXM_TEXTURE_FILTER_LINEAR); + ? SCE_GXM_TEXTURE_FILTER_POINT + : SCE_GXM_TEXTURE_FILTER_LINEAR); gxm_texture_set_filters(vita_texture->tex, vitaScaleMode, vitaScaleMode); return; } -static int -VITA_GXM_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) +static int VITA_GXM_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) { return 0; } -static void -VITA_GXM_SetBlendMode(VITA_GXM_RenderData *data, int blendMode) +static void VITA_GXM_SetBlendMode(VITA_GXM_RenderData *data, int blendMode) { if (blendMode != data->currentBlendMode) { fragment_programs *in = &data->blendFragmentPrograms.blend_mode_blend; - switch (blendMode) - { - case SDL_BLENDMODE_NONE: - in = &data->blendFragmentPrograms.blend_mode_none; - break; - case SDL_BLENDMODE_BLEND: - in = &data->blendFragmentPrograms.blend_mode_blend; - break; - case SDL_BLENDMODE_ADD: - in = &data->blendFragmentPrograms.blend_mode_add; - break; - case SDL_BLENDMODE_MOD: - in = &data->blendFragmentPrograms.blend_mode_mod; - break; - case SDL_BLENDMODE_MUL: - in = &data->blendFragmentPrograms.blend_mode_mul; - break; + switch (blendMode) { + case SDL_BLENDMODE_NONE: + in = &data->blendFragmentPrograms.blend_mode_none; + break; + case SDL_BLENDMODE_BLEND: + in = &data->blendFragmentPrograms.blend_mode_blend; + break; + case SDL_BLENDMODE_ADD: + in = &data->blendFragmentPrograms.blend_mode_add; + break; + case SDL_BLENDMODE_MOD: + in = &data->blendFragmentPrograms.blend_mode_mod; + break; + case SDL_BLENDMODE_MUL: + in = &data->blendFragmentPrograms.blend_mode_mul; + break; } data->colorFragmentProgram = in->color; data->textureFragmentProgram = in->texture; @@ -675,16 +650,14 @@ VITA_GXM_SetBlendMode(VITA_GXM_RenderData *data, int blendMode) } } -static int -VITA_GXM_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd) +static int VITA_GXM_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { return 0; } -static int -VITA_GXM_QueueSetDrawColor(SDL_Renderer * renderer, SDL_RenderCommand *cmd) +static int VITA_GXM_QueueSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { - VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata; data->drawstate.color.r = cmd->data.color.r; data->drawstate.color.g = cmd->data.color.g; @@ -694,17 +667,15 @@ VITA_GXM_QueueSetDrawColor(SDL_Renderer * renderer, SDL_RenderCommand *cmd) return 0; } -static int -VITA_GXM_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) +static int VITA_GXM_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { - VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata; SDL_Color color = data->drawstate.color; color_vertex *vertex = (color_vertex *)pool_malloc( data, - count * sizeof(color_vertex) - ); + count * sizeof(color_vertex)); cmd->data.draw.first = (size_t)vertex; cmd->data.draw.count = count; @@ -718,40 +689,37 @@ VITA_GXM_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const return 0; } -static int -VITA_GXM_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) +static int VITA_GXM_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { - VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata; SDL_Color color = data->drawstate.color; color_vertex *vertex = (color_vertex *)pool_malloc( data, - (count-1) * 2 * sizeof(color_vertex) - ); + (count - 1) * 2 * sizeof(color_vertex)); cmd->data.draw.first = (size_t)vertex; - cmd->data.draw.count = (count-1) * 2; + cmd->data.draw.count = (count - 1) * 2; for (int i = 0; i < count - 1; i++) { - vertex[i*2].x = points[i].x; - vertex[i*2].y = points[i].y; - vertex[i*2].color = color; + vertex[i * 2].x = points[i].x; + vertex[i * 2].y = points[i].y; + vertex[i * 2].color = color; - vertex[i*2+1].x = points[i+1].x; - vertex[i*2+1].y = points[i+1].y; - vertex[i*2+1].color = color; + vertex[i * 2 + 1].x = points[i + 1].x; + vertex[i * 2 + 1].y = points[i + 1].y; + vertex[i * 2 + 1].color = color; } return 0; } -static int -VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, - const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, - int num_vertices, const void *indices, int num_indices, int size_indices, - float scale_x, float scale_y) +static int VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, + int num_vertices, const void *indices, int num_indices, int size_indices, + float scale_x, float scale_y) { - VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata; int i; int count = indices ? num_indices : num_vertices; @@ -759,18 +727,17 @@ VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Textu size_indices = indices ? size_indices : 0; if (texture) { - VITA_GXM_TextureData* vita_texture = (VITA_GXM_TextureData*) texture->driverdata; + VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)texture->driverdata; texture_vertex *vertices; vertices = (texture_vertex *)pool_malloc( - data, - count * sizeof(texture_vertex)); + data, + count * sizeof(texture_vertex)); if (vertices == NULL) { return -1; } - for (i = 0; i < count; i++) { int j; float *xy_; @@ -786,9 +753,9 @@ VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Textu j = i; } - xy_ = (float *)((char*)xy + j * xy_stride); - col_ = *(SDL_Color *)((char*)color + j * color_stride); - uv_ = (float *)((char*)uv + j * uv_stride); + xy_ = (float *)((char *)xy + j * xy_stride); + col_ = *(SDL_Color *)((char *)color + j * color_stride); + uv_ = (float *)((char *)uv + j * uv_stride); vertices[i].x = xy_[0] * scale_x; vertices[i].y = xy_[1] * scale_y; @@ -803,14 +770,13 @@ VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Textu color_vertex *vertices; vertices = (color_vertex *)pool_malloc( - data, - count * sizeof(color_vertex)); + data, + count * sizeof(color_vertex)); if (vertices == NULL) { return -1; } - for (i = 0; i < count; i++) { int j; float *xy_; @@ -825,8 +791,8 @@ VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Textu j = i; } - xy_ = (float *)((char*)xy + j * xy_stride); - col_ = *(SDL_Color *)((char*)color + j * color_stride); + xy_ = (float *)((char *)xy + j * xy_stride); + col_ = *(SDL_Color *)((char *)color + j * color_stride); vertices[i].x = xy_[0] * scale_x; vertices[i].y = xy_[1] * scale_y; @@ -835,23 +801,21 @@ VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Textu cmd->data.draw.first = (size_t)vertices; } - return 0; } -static int -VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd) +static int VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { void *color_buffer; float clear_color[4]; - VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata; unset_clip_rectangle(data); - clear_color[0] = (cmd->data.color.r)/255.0f; - clear_color[1] = (cmd->data.color.g)/255.0f; - clear_color[2] = (cmd->data.color.b)/255.0f; - clear_color[3] = (cmd->data.color.a)/255.0f; + clear_color[0] = (cmd->data.color.r) / 255.0f; + clear_color[1] = (cmd->data.color.g) / 255.0f; + clear_color[2] = (cmd->data.color.b) / 255.0f; + clear_color[3] = (cmd->data.color.a) / 255.0f; // set clear shaders data->drawstate.fragment_program = data->clearFragmentProgram; @@ -871,9 +835,7 @@ VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd) return 0; } - -static int -SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd) +static int SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd) { SDL_Texture *texture = cmd->data.draw.texture; const SDL_BlendMode blend = cmd->data.draw.blend; @@ -885,8 +847,7 @@ SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd) if (data->drawstate.viewport_dirty) { const SDL_Rect *viewport = &data->drawstate.viewport; - - float sw = viewport->w / 2.; + float sw = viewport->w / 2.; float sh = viewport->h / 2.; float x_scale = sw; @@ -898,11 +859,11 @@ SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd) if (viewport->w && viewport->h) { init_orthographic_matrix(data->ortho_matrix, - (float) 0, - (float) viewport->w, - (float) viewport->h, - (float) 0, - 0.0f, 1.0f); + (float)0, + (float)viewport->w, + (float)viewport->h, + (float)0, + 0.0f, 1.0f); matrix_updated = SDL_TRUE; } @@ -944,7 +905,6 @@ SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd) program_updated = SDL_TRUE; } - if (program_updated || matrix_updated) { if (data->drawstate.fragment_program == data->textureFragmentProgram) { void *vertex_wvp_buffer; @@ -959,22 +919,21 @@ SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd) if (texture != data->drawstate.texture) { if (texture) { - VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *) cmd->data.draw.texture->driverdata; + VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)cmd->data.draw.texture->driverdata; sceGxmSetFragmentTexture(data->gxm_context, 0, &vita_texture->tex->gxm_tex); } data->drawstate.texture = texture; } /* all drawing commands use this */ - sceGxmSetVertexStream(data->gxm_context, 0, (const void*)cmd->data.draw.first); + sceGxmSetVertexStream(data->gxm_context, 0, (const void *)cmd->data.draw.first); return 0; } -static int -VITA_GXM_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) +static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) { - VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata; StartDrawing(renderer); data->drawstate.target = renderer->target; @@ -982,108 +941,111 @@ VITA_GXM_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void * int w, h; SDL_GL_GetDrawableSize(renderer->window, &w, &h); if ((w != data->drawstate.drawablew) || (h != data->drawstate.drawableh)) { - data->drawstate.viewport_dirty = SDL_TRUE; // if the window dimensions changed, invalidate the current viewport, etc. + data->drawstate.viewport_dirty = SDL_TRUE; // if the window dimensions changed, invalidate the current viewport, etc. data->drawstate.cliprect_dirty = SDL_TRUE; data->drawstate.drawablew = w; data->drawstate.drawableh = h; } - } while (cmd) { switch (cmd->command) { - case SDL_RENDERCMD_SETVIEWPORT: { - SDL_Rect *viewport = &data->drawstate.viewport; - if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { - SDL_copyp(viewport, &cmd->data.viewport.rect); - data->drawstate.viewport_dirty = SDL_TRUE; - } - break; + case SDL_RENDERCMD_SETVIEWPORT: + { + SDL_Rect *viewport = &data->drawstate.viewport; + if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { + SDL_copyp(viewport, &cmd->data.viewport.rect); + data->drawstate.viewport_dirty = SDL_TRUE; + } + break; + } + + case SDL_RENDERCMD_SETCLIPRECT: + { + const SDL_Rect *rect = &cmd->data.cliprect.rect; + if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) { + data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled; + data->drawstate.cliprect_enabled_dirty = SDL_TRUE; } - case SDL_RENDERCMD_SETCLIPRECT: { - const SDL_Rect *rect = &cmd->data.cliprect.rect; - if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) { - data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled; - data->drawstate.cliprect_enabled_dirty = SDL_TRUE; - } + if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) { + SDL_copyp(&data->drawstate.cliprect, rect); + data->drawstate.cliprect_dirty = SDL_TRUE; + } + break; + } - if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) { - SDL_copyp(&data->drawstate.cliprect, rect); - data->drawstate.cliprect_dirty = SDL_TRUE; + case SDL_RENDERCMD_SETDRAWCOLOR: + { + break; + } + + case SDL_RENDERCMD_CLEAR: + { + VITA_GXM_RenderClear(renderer, cmd); + break; + } + + case SDL_RENDERCMD_FILL_RECTS: /* unused */ + break; + + case SDL_RENDERCMD_COPY: /* unused */ + break; + + case SDL_RENDERCMD_COPY_EX: /* unused */ + break; + + case SDL_RENDERCMD_DRAW_POINTS: + case SDL_RENDERCMD_DRAW_LINES: + case SDL_RENDERCMD_GEOMETRY: + { + SDL_Texture *thistexture = cmd->data.draw.texture; + SDL_BlendMode thisblend = cmd->data.draw.blend; + const SDL_RenderCommandType thiscmdtype = cmd->command; + SDL_RenderCommand *finalcmd = cmd; + SDL_RenderCommand *nextcmd = cmd->next; + size_t count = cmd->data.draw.count; + int ret; + while (nextcmd != NULL) { + const SDL_RenderCommandType nextcmdtype = nextcmd->command; + if (nextcmdtype != thiscmdtype) { + break; /* can't go any further on this draw call, different render command up next. */ + } else if (nextcmd->data.draw.texture != thistexture || nextcmd->data.draw.blend != thisblend) { + break; /* can't go any further on this draw call, different texture/blendmode copy up next. */ + } else { + finalcmd = nextcmd; /* we can combine copy operations here. Mark this one as the furthest okay command. */ + count += nextcmd->data.draw.count; } - break; + nextcmd = nextcmd->next; } - case SDL_RENDERCMD_SETDRAWCOLOR: { - break; - } + ret = SetDrawState(data, cmd); - case SDL_RENDERCMD_CLEAR: { - VITA_GXM_RenderClear(renderer, cmd); - break; - } + if (ret == 0) { + int op = SCE_GXM_PRIMITIVE_TRIANGLES; - case SDL_RENDERCMD_FILL_RECTS: /* unused */ - break; - - case SDL_RENDERCMD_COPY: /* unused */ - break; - - case SDL_RENDERCMD_COPY_EX: /* unused */ - break; - - case SDL_RENDERCMD_DRAW_POINTS: - case SDL_RENDERCMD_DRAW_LINES: - case SDL_RENDERCMD_GEOMETRY: { - SDL_Texture *thistexture = cmd->data.draw.texture; - SDL_BlendMode thisblend = cmd->data.draw.blend; - const SDL_RenderCommandType thiscmdtype = cmd->command; - SDL_RenderCommand *finalcmd = cmd; - SDL_RenderCommand *nextcmd = cmd->next; - size_t count = cmd->data.draw.count; - int ret; - while (nextcmd != NULL) { - const SDL_RenderCommandType nextcmdtype = nextcmd->command; - if (nextcmdtype != thiscmdtype) { - break; /* can't go any further on this draw call, different render command up next. */ - } else if (nextcmd->data.draw.texture != thistexture || nextcmd->data.draw.blend != thisblend) { - break; /* can't go any further on this draw call, different texture/blendmode copy up next. */ - } else { - finalcmd = nextcmd; /* we can combine copy operations here. Mark this one as the furthest okay command. */ - count += nextcmd->data.draw.count; - } - nextcmd = nextcmd->next; + if (thiscmdtype == SDL_RENDERCMD_DRAW_POINTS) { + sceGxmSetFrontPolygonMode(data->gxm_context, SCE_GXM_POLYGON_MODE_POINT); + op = SCE_GXM_PRIMITIVE_POINTS; + } else if (thiscmdtype == SDL_RENDERCMD_DRAW_LINES) { + sceGxmSetFrontPolygonMode(data->gxm_context, SCE_GXM_POLYGON_MODE_LINE); + op = SCE_GXM_PRIMITIVE_LINES; } - ret = SetDrawState(data, cmd); - - if (ret == 0) { - int op = SCE_GXM_PRIMITIVE_TRIANGLES; - - if (thiscmdtype == SDL_RENDERCMD_DRAW_POINTS) { - sceGxmSetFrontPolygonMode(data->gxm_context, SCE_GXM_POLYGON_MODE_POINT); - op = SCE_GXM_PRIMITIVE_POINTS; - } else if (thiscmdtype == SDL_RENDERCMD_DRAW_LINES) { - sceGxmSetFrontPolygonMode(data->gxm_context, SCE_GXM_POLYGON_MODE_LINE); - op = SCE_GXM_PRIMITIVE_LINES; - } - - sceGxmDraw(data->gxm_context, op, SCE_GXM_INDEX_FORMAT_U16, data->linearIndices, count); - - if (thiscmdtype == SDL_RENDERCMD_DRAW_POINTS || thiscmdtype == SDL_RENDERCMD_DRAW_LINES) { - sceGxmSetFrontPolygonMode(data->gxm_context, SCE_GXM_POLYGON_MODE_TRIANGLE_FILL); - } + sceGxmDraw(data->gxm_context, op, SCE_GXM_INDEX_FORMAT_U16, data->linearIndices, count); + if (thiscmdtype == SDL_RENDERCMD_DRAW_POINTS || thiscmdtype == SDL_RENDERCMD_DRAW_LINES) { + sceGxmSetFrontPolygonMode(data->gxm_context, SCE_GXM_POLYGON_MODE_TRIANGLE_FILL); } - - cmd = finalcmd; /* skip any copy commands we just combined in here. */ - break; } - case SDL_RENDERCMD_NO_OP: - break; + cmd = finalcmd; /* skip any copy commands we just combined in here. */ + break; + } + + case SDL_RENDERCMD_NO_OP: + break; } data->drawstate.last_command = cmd->command; cmd = cmd->next; @@ -1095,7 +1057,8 @@ VITA_GXM_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void * return 0; } -void read_pixels(int x, int y, size_t width, size_t height, void *data) { +void read_pixels(int x, int y, size_t width, size_t height, void *data) +{ SceDisplayFrameBuf pParam; int i, j; Uint32 *out32; @@ -1118,10 +1081,8 @@ void read_pixels(int x, int y, size_t width, size_t height, void *data) { } } - -static int -VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, - Uint32 pixel_format, void *pixels, int pitch) +static int VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, + Uint32 pixel_format, void *pixels, int pitch) { Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ABGR8888; size_t buflen; @@ -1136,11 +1097,10 @@ VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, return SDL_Unsupported(); } - temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format); buflen = rect->h * temp_pitch; if (buflen == 0) { - return 0; /* nothing to do. */ + return 0; /* nothing to do. */ } temp_pixels = SDL_malloc(buflen); @@ -1150,16 +1110,16 @@ VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, SDL_GetRendererOutputSize(renderer, &w, &h); - read_pixels(rect->x, renderer->target ? rect->y : (h-rect->y)-rect->h, - rect->w, rect->h, temp_pixels); + read_pixels(rect->x, renderer->target ? rect->y : (h - rect->y) - rect->h, + rect->w, rect->h, temp_pixels); /* Flip the rows to be top-down if necessary */ if (!renderer->target) { SDL_bool isstack; length = rect->w * SDL_BYTESPERPIXEL(temp_format); - src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch; - dst = (Uint8*)temp_pixels; + src = (Uint8 *)temp_pixels + (rect->h - 1) * temp_pitch; + dst = (Uint8 *)temp_pixels; tmp = SDL_small_alloc(Uint8, length, &isstack); rows = rect->h / 2; while (rows--) { @@ -1180,21 +1140,19 @@ VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, return status; } - -static int -VITA_GXM_RenderPresent(SDL_Renderer *renderer) +static int VITA_GXM_RenderPresent(SDL_Renderer *renderer) { - VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata; SceCommonDialogUpdateParam updateParam; data->displayData.address = data->displayBufferData[data->backBufferIndex]; SDL_memset(&updateParam, 0, sizeof(updateParam)); - updateParam.renderTarget.colorFormat = VITA_GXM_COLOR_FORMAT; - updateParam.renderTarget.surfaceType = SCE_GXM_COLOR_SURFACE_LINEAR; - updateParam.renderTarget.width = VITA_GXM_SCREEN_WIDTH; - updateParam.renderTarget.height = VITA_GXM_SCREEN_HEIGHT; + updateParam.renderTarget.colorFormat = VITA_GXM_COLOR_FORMAT; + updateParam.renderTarget.surfaceType = SCE_GXM_COLOR_SURFACE_LINEAR; + updateParam.renderTarget.width = VITA_GXM_SCREEN_WIDTH; + updateParam.renderTarget.height = VITA_GXM_SCREEN_HEIGHT; updateParam.renderTarget.strideInPixels = VITA_GXM_SCREEN_STRIDE; updateParam.renderTarget.colorSurfaceData = data->displayBufferData[data->backBufferIndex]; @@ -1207,15 +1165,13 @@ VITA_GXM_RenderPresent(SDL_Renderer *renderer) #if DEBUG_RAZOR sceGxmPadHeartbeat( (const SceGxmColorSurface *)&data->displaySurface[data->backBufferIndex], - (SceGxmSyncObject *)data->displayBufferSync[data->backBufferIndex] - ); + (SceGxmSyncObject *)data->displayBufferSync[data->backBufferIndex]); #endif sceGxmDisplayQueueAddEntry( - data->displayBufferSync[data->frontBufferIndex], // OLD fb - data->displayBufferSync[data->backBufferIndex], // NEW fb - &data->displayData - ); + data->displayBufferSync[data->frontBufferIndex], // OLD fb + data->displayBufferSync[data->backBufferIndex], // NEW fb + &data->displayData); // update buffer indices data->frontBufferIndex = data->backBufferIndex; @@ -1226,11 +1182,10 @@ VITA_GXM_RenderPresent(SDL_Renderer *renderer) return 0; } -static void -VITA_GXM_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) +static void VITA_GXM_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; - VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *) texture->driverdata; + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata; + VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)texture->driverdata; if (data == NULL) { return; @@ -1253,10 +1208,9 @@ VITA_GXM_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) texture->driverdata = NULL; } -static void -VITA_GXM_DestroyRenderer(SDL_Renderer *renderer) +static void VITA_GXM_DestroyRenderer(SDL_Renderer *renderer) { - VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata; if (data) { if (!data->initialized) { return; diff --git a/src/render/vitagxm/SDL_render_vita_gxm_memory.c b/src/render/vitagxm/SDL_render_vita_gxm_memory.c index dee8d600b..90f874b8f 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm_memory.c +++ b/src/render/vitagxm/SDL_render_vita_gxm_memory.c @@ -31,9 +31,9 @@ vita_mem_alloc(unsigned int type, unsigned int size, unsigned int alignment, uns void *mem; if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW) { - size = ALIGN(size, 256*1024); + size = ALIGN(size, 256 * 1024); } else { - size = ALIGN(size, 4*1024); + size = ALIGN(size, 4 * 1024); } *uid = sceKernelAllocMemBlock("gpu_mem", type, size, NULL); @@ -53,8 +53,7 @@ vita_mem_alloc(unsigned int type, unsigned int size, unsigned int alignment, uns return mem; } -void -vita_mem_free(SceUID uid) +void vita_mem_free(SceUID uid) { void *mem = NULL; if (sceKernelGetMemBlockBase(uid, &mem) < 0) { @@ -76,9 +75,9 @@ vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size) info.size = sizeof(SceKernelFreeMemorySizeInfo); sceKernelGetFreeMemorySize(&info); - poolsize = ALIGN(info.size_cdram, 256*1024); + poolsize = ALIGN(info.size_cdram, 256 * 1024); if (poolsize > info.size_cdram) { - poolsize = ALIGN(info.size_cdram - 256*1024, 256*1024); + poolsize = ALIGN(info.size_cdram - 256 * 1024, 256 * 1024); } data->texturePoolUID = sceKernelAllocMemBlock("gpu_texture_pool", SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, poolsize, NULL); if (data->texturePoolUID < 0) { @@ -86,7 +85,7 @@ vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size) } ret = sceKernelGetMemBlockBase(data->texturePoolUID, &mem); - if ( ret < 0) { + if (ret < 0) { return NULL; } data->texturePool = sceClibMspaceCreate(mem, poolsize); @@ -102,16 +101,14 @@ vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size) return sceClibMspaceMemalign(data->texturePool, SCE_GXM_TEXTURE_ALIGNMENT, size); } -void -vita_gpu_mem_free(VITA_GXM_RenderData *data, void* ptr) +void vita_gpu_mem_free(VITA_GXM_RenderData *data, void *ptr) { if (data->texturePool != NULL) { sceClibMspaceFree(data->texturePool, ptr); } } -void -vita_gpu_mem_destroy(VITA_GXM_RenderData *data) +void vita_gpu_mem_destroy(VITA_GXM_RenderData *data) { void *mem = NULL; if (data->texturePool != NULL) { @@ -143,8 +140,7 @@ vita_mem_vertex_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_of return mem; } -void -vita_mem_vertex_usse_free(SceUID uid) +void vita_mem_vertex_usse_free(SceUID uid) { void *mem = NULL; if (sceKernelGetMemBlockBase(uid, &mem) < 0) { @@ -172,8 +168,7 @@ vita_mem_fragment_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_ return mem; } -void -vita_mem_fragment_usse_free(SceUID uid) +void vita_mem_fragment_usse_free(SceUID uid) { void *mem = NULL; if (sceKernelGetMemBlockBase(uid, &mem) < 0) { diff --git a/src/render/vitagxm/SDL_render_vita_gxm_memory.h b/src/render/vitagxm/SDL_render_vita_gxm_memory.h index 93b9f3498..861ec5b73 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm_memory.h +++ b/src/render/vitagxm/SDL_render_vita_gxm_memory.h @@ -27,12 +27,12 @@ #include #include "SDL_render_vita_gxm_types.h" -#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) +#define ALIGN(x, a) (((x) + ((a)-1)) & ~((a)-1)) void *vita_mem_alloc(unsigned int type, unsigned int size, unsigned int alignment, unsigned int attribs, SceUID *uid); void vita_mem_free(SceUID uid); void *vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size); -void vita_gpu_mem_free(VITA_GXM_RenderData *data, void* ptr); +void vita_gpu_mem_free(VITA_GXM_RenderData *data, void *ptr); void vita_gpu_mem_destroy(VITA_GXM_RenderData *data); void *vita_mem_vertex_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset); void vita_mem_vertex_usse_free(SceUID uid); diff --git a/src/render/vitagxm/SDL_render_vita_gxm_shaders.h b/src/render/vitagxm/SDL_render_vita_gxm_shaders.h index f60ad1d55..eb00184c8 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm_shaders.h +++ b/src/render/vitagxm/SDL_render_vita_gxm_shaders.h @@ -24,6 +24,8 @@ #include +/* *INDENT-OFF* */ /* clang-format off */ + #define gxm_shader_clear_f_size 232 static const unsigned char gxm_shader_clear_f[gxm_shader_clear_f_size] = { 0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03, @@ -268,12 +270,14 @@ static const unsigned char gxm_shader_texture_v[gxm_shader_texture_v_size] = { 0x6f, 0x72, 0x00, 0x77, 0x76, 0x70, 0x00, 0x00, }; -static const SceGxmProgram *const clearVertexProgramGxp = (const SceGxmProgram *)gxm_shader_clear_v; -static const SceGxmProgram *const clearFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_clear_f; -static const SceGxmProgram *const colorVertexProgramGxp = (const SceGxmProgram *)gxm_shader_color_v; -static const SceGxmProgram *const colorFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_color_f; -static const SceGxmProgram *const textureVertexProgramGxp = (const SceGxmProgram *)gxm_shader_texture_v; -static const SceGxmProgram *const textureFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_texture_f; +/* *INDENT-ON* */ /* clang-format on */ + +static const SceGxmProgram *const clearVertexProgramGxp = (const SceGxmProgram *)gxm_shader_clear_v; +static const SceGxmProgram *const clearFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_clear_f; +static const SceGxmProgram *const colorVertexProgramGxp = (const SceGxmProgram *)gxm_shader_color_v; +static const SceGxmProgram *const colorFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_color_f; +static const SceGxmProgram *const textureVertexProgramGxp = (const SceGxmProgram *)gxm_shader_texture_v; +static const SceGxmProgram *const textureFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_texture_f; #endif // SDL_RENDER_VITA_GXM_SHADERS_H diff --git a/src/render/vitagxm/SDL_render_vita_gxm_tools.c b/src/render/vitagxm/SDL_render_vita_gxm_tools.c index 1151a5d82..85ead6db0 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm_tools.c +++ b/src/render/vitagxm/SDL_render_vita_gxm_tools.c @@ -45,23 +45,22 @@ #include "SDL_render_vita_gxm_memory.h" #include "SDL_render_vita_gxm_shaders.h" -void -init_orthographic_matrix(float *m, float left, float right, float bottom, float top, float near, float far) +void init_orthographic_matrix(float *m, float left, float right, float bottom, float top, float near, float far) { - m[0x0] = 2.0f/(right-left); + m[0x0] = 2.0f / (right - left); m[0x4] = 0.0f; m[0x8] = 0.0f; - m[0xC] = -(right+left)/(right-left); + m[0xC] = -(right + left) / (right - left); m[0x1] = 0.0f; - m[0x5] = 2.0f/(top-bottom); + m[0x5] = 2.0f / (top - bottom); m[0x9] = 0.0f; - m[0xD] = -(top+bottom)/(top-bottom); + m[0xD] = -(top + bottom) / (top - bottom); m[0x2] = 0.0f; m[0x6] = 0.0f; - m[0xA] = -2.0f/(far-near); - m[0xE] = (far+near)/(far-near); + m[0xA] = -2.0f / (far - near); + m[0xE] = (far + near) / (far - near); m[0x3] = 0.0f; m[0x7] = 0.0f; @@ -69,16 +68,14 @@ init_orthographic_matrix(float *m, float left, float right, float bottom, float m[0xF] = 1.0f; } -static void * -patcher_host_alloc(void *user_data, unsigned int size) +static void *patcher_host_alloc(void *user_data, unsigned int size) { void *mem = SDL_malloc(size); (void)user_data; return mem; } -static void -patcher_host_free(void *user_data, void *mem) +static void patcher_host_free(void *user_data, void *mem) { (void)user_data; SDL_free(mem); @@ -110,8 +107,7 @@ pool_memalign(VITA_GXM_RenderData *data, unsigned int size, unsigned int alignme return NULL; } -static int -tex_format_to_bytespp(SceGxmTextureFormat format) +static int tex_format_to_bytespp(SceGxmTextureFormat format) { switch (format & 0x9f000000U) { case SCE_GXM_TEXTURE_BASE_FORMAT_U8: @@ -141,19 +137,18 @@ tex_format_to_bytespp(SceGxmTextureFormat format) } } -static void -display_callback(const void *callback_data) +static void display_callback(const void *callback_data) { SceDisplayFrameBuf framebuf; const VITA_GXM_DisplayData *display_data = (const VITA_GXM_DisplayData *)callback_data; SDL_memset(&framebuf, 0x00, sizeof(SceDisplayFrameBuf)); - framebuf.size = sizeof(SceDisplayFrameBuf); - framebuf.base = display_data->address; - framebuf.pitch = VITA_GXM_SCREEN_STRIDE; + framebuf.size = sizeof(SceDisplayFrameBuf); + framebuf.base = display_data->address; + framebuf.pitch = VITA_GXM_SCREEN_STRIDE; framebuf.pixelformat = VITA_GXM_PIXEL_FORMAT; - framebuf.width = VITA_GXM_SCREEN_WIDTH; - framebuf.height = VITA_GXM_SCREEN_HEIGHT; + framebuf.width = VITA_GXM_SCREEN_WIDTH; + framebuf.height = VITA_GXM_SCREEN_HEIGHT; sceDisplaySetFrameBuf(&framebuf, SCE_DISPLAY_SETBUF_NEXTFRAME); if (display_data->wait_vblank) { @@ -161,16 +156,14 @@ display_callback(const void *callback_data) } } -static void -free_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out) +static void free_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out) { sceGxmShaderPatcherReleaseFragmentProgram(data->shaderPatcher, out->color); sceGxmShaderPatcherReleaseFragmentProgram(data->shaderPatcher, out->texture); } -static void -make_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out, - const SceGxmBlendInfo *blend_info) +static void make_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out, + const SceGxmBlendInfo *blend_info) { int err; @@ -181,8 +174,7 @@ make_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out, 0, blend_info, colorVertexProgramGxp, - &out->color - ); + &out->color); if (err != 0) { SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Patcher create fragment failed: %d\n", err); @@ -196,8 +188,7 @@ make_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out, 0, blend_info, textureVertexProgramGxp, - &out->texture - ); + &out->texture); if (err != 0) { SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Patcher create fragment failed: %d\n", err); @@ -205,16 +196,13 @@ make_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out, } } - -static void -set_stencil_mask(VITA_GXM_RenderData *data, float x, float y, float w, float h) +static void set_stencil_mask(VITA_GXM_RenderData *data, float x, float y, float w, float h) { void *vertexDefaultBuffer; color_vertex *vertices = (color_vertex *)pool_memalign( data, 4 * sizeof(color_vertex), // 4 vertices - sizeof(color_vertex) - ); + sizeof(color_vertex)); vertices[0].x = x; vertices[0].y = y; @@ -256,9 +244,7 @@ set_stencil_mask(VITA_GXM_RenderData *data, float x, float y, float w, float h) sceGxmDraw(data->gxm_context, SCE_GXM_PRIMITIVE_TRIANGLE_STRIP, SCE_GXM_INDEX_FORMAT_U16, data->linearIndices, 4); } - -void -set_clip_rectangle(VITA_GXM_RenderData *data, int x_min, int y_min, int x_max, int y_max) +void set_clip_rectangle(VITA_GXM_RenderData *data, int x_min, int y_min, int x_max, int y_max) { if (data->drawing) { // clear the stencil buffer to 0 @@ -269,8 +255,7 @@ set_clip_rectangle(VITA_GXM_RenderData *data, int x_min, int y_min, int x_max, i SCE_GXM_STENCIL_OP_ZERO, SCE_GXM_STENCIL_OP_ZERO, 0xFF, - 0xFF - ); + 0xFF); set_stencil_mask(data, 0, 0, VITA_GXM_SCREEN_WIDTH, VITA_GXM_SCREEN_HEIGHT); @@ -282,8 +267,7 @@ set_clip_rectangle(VITA_GXM_RenderData *data, int x_min, int y_min, int x_max, i SCE_GXM_STENCIL_OP_REPLACE, SCE_GXM_STENCIL_OP_REPLACE, 0xFF, - 0xFF - ); + 0xFF); set_stencil_mask(data, x_min, y_min, x_max - x_min, y_max - y_min); @@ -295,13 +279,11 @@ set_clip_rectangle(VITA_GXM_RenderData *data, int x_min, int y_min, int x_max, i SCE_GXM_STENCIL_OP_KEEP, SCE_GXM_STENCIL_OP_KEEP, 0xFF, - 0xFF - ); + 0xFF); } } -void -unset_clip_rectangle(VITA_GXM_RenderData *data) +void unset_clip_rectangle(VITA_GXM_RenderData *data) { sceGxmSetFrontStencilFunc( data->gxm_context, @@ -310,12 +292,10 @@ unset_clip_rectangle(VITA_GXM_RenderData *data) SCE_GXM_STENCIL_OP_KEEP, SCE_GXM_STENCIL_OP_KEEP, 0xFF, - 0xFF - ); + 0xFF); } -int -gxm_init(SDL_Renderer *renderer) +int gxm_init(SDL_Renderer *renderer) { unsigned int i, x, y; int err; @@ -341,38 +321,38 @@ gxm_init(SDL_Renderer *renderer) unsigned int depthStrideInSamples = alignedWidth; // set buffer sizes for this sample - const unsigned int patcherBufferSize = 64*1024; - const unsigned int patcherVertexUsseSize = 64*1024; - const unsigned int patcherFragmentUsseSize = 64*1024; + const unsigned int patcherBufferSize = 64 * 1024; + const unsigned int patcherVertexUsseSize = 64 * 1024; + const unsigned int patcherFragmentUsseSize = 64 * 1024; // Fill SceGxmBlendInfo static const SceGxmBlendInfo blend_info_none = { .colorFunc = SCE_GXM_BLEND_FUNC_NONE, .alphaFunc = SCE_GXM_BLEND_FUNC_NONE, - .colorSrc = SCE_GXM_BLEND_FACTOR_ZERO, - .colorDst = SCE_GXM_BLEND_FACTOR_ZERO, - .alphaSrc = SCE_GXM_BLEND_FACTOR_ZERO, - .alphaDst = SCE_GXM_BLEND_FACTOR_ZERO, + .colorSrc = SCE_GXM_BLEND_FACTOR_ZERO, + .colorDst = SCE_GXM_BLEND_FACTOR_ZERO, + .alphaSrc = SCE_GXM_BLEND_FACTOR_ZERO, + .alphaDst = SCE_GXM_BLEND_FACTOR_ZERO, .colorMask = SCE_GXM_COLOR_MASK_ALL }; static const SceGxmBlendInfo blend_info_blend = { .colorFunc = SCE_GXM_BLEND_FUNC_ADD, .alphaFunc = SCE_GXM_BLEND_FUNC_ADD, - .colorSrc = SCE_GXM_BLEND_FACTOR_SRC_ALPHA, - .colorDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, - .alphaSrc = SCE_GXM_BLEND_FACTOR_ONE, - .alphaDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, + .colorSrc = SCE_GXM_BLEND_FACTOR_SRC_ALPHA, + .colorDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, + .alphaSrc = SCE_GXM_BLEND_FACTOR_ONE, + .alphaDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, .colorMask = SCE_GXM_COLOR_MASK_ALL }; static const SceGxmBlendInfo blend_info_add = { .colorFunc = SCE_GXM_BLEND_FUNC_ADD, .alphaFunc = SCE_GXM_BLEND_FUNC_ADD, - .colorSrc = SCE_GXM_BLEND_FACTOR_SRC_ALPHA, - .colorDst = SCE_GXM_BLEND_FACTOR_ONE, - .alphaSrc = SCE_GXM_BLEND_FACTOR_ZERO, - .alphaDst = SCE_GXM_BLEND_FACTOR_ONE, + .colorSrc = SCE_GXM_BLEND_FACTOR_SRC_ALPHA, + .colorDst = SCE_GXM_BLEND_FACTOR_ONE, + .alphaSrc = SCE_GXM_BLEND_FACTOR_ZERO, + .alphaDst = SCE_GXM_BLEND_FACTOR_ONE, .colorMask = SCE_GXM_COLOR_MASK_ALL }; @@ -380,33 +360,33 @@ gxm_init(SDL_Renderer *renderer) .colorFunc = SCE_GXM_BLEND_FUNC_ADD, .alphaFunc = SCE_GXM_BLEND_FUNC_ADD, - .colorSrc = SCE_GXM_BLEND_FACTOR_ZERO, - .colorDst = SCE_GXM_BLEND_FACTOR_SRC_COLOR, + .colorSrc = SCE_GXM_BLEND_FACTOR_ZERO, + .colorDst = SCE_GXM_BLEND_FACTOR_SRC_COLOR, - .alphaSrc = SCE_GXM_BLEND_FACTOR_ZERO, - .alphaDst = SCE_GXM_BLEND_FACTOR_ONE, + .alphaSrc = SCE_GXM_BLEND_FACTOR_ZERO, + .alphaDst = SCE_GXM_BLEND_FACTOR_ONE, .colorMask = SCE_GXM_COLOR_MASK_ALL }; static const SceGxmBlendInfo blend_info_mul = { .colorFunc = SCE_GXM_BLEND_FUNC_ADD, .alphaFunc = SCE_GXM_BLEND_FUNC_ADD, - .colorSrc = SCE_GXM_BLEND_FACTOR_DST_COLOR, - .colorDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, - .alphaSrc = SCE_GXM_BLEND_FACTOR_DST_ALPHA, - .alphaDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, + .colorSrc = SCE_GXM_BLEND_FACTOR_DST_COLOR, + .colorDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, + .alphaSrc = SCE_GXM_BLEND_FACTOR_DST_ALPHA, + .alphaDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, .colorMask = SCE_GXM_COLOR_MASK_ALL }; - VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata; SceGxmInitializeParams initializeParams; SDL_memset(&initializeParams, 0, sizeof(SceGxmInitializeParams)); - initializeParams.flags = 0; - initializeParams.displayQueueMaxPendingCount = VITA_GXM_PENDING_SWAPS; - initializeParams.displayQueueCallback = display_callback; - initializeParams.displayQueueCallbackDataSize = sizeof(VITA_GXM_DisplayData); - initializeParams.parameterBufferSize = SCE_GXM_DEFAULT_PARAMETER_BUFFER_SIZE; + initializeParams.flags = 0; + initializeParams.displayQueueMaxPendingCount = VITA_GXM_PENDING_SWAPS; + initializeParams.displayQueueCallback = display_callback; + initializeParams.displayQueueCallbackDataSize = sizeof(VITA_GXM_DisplayData); + initializeParams.parameterBufferSize = SCE_GXM_DEFAULT_PARAMETER_BUFFER_SIZE; err = sceGxmInitialize(&initializeParams); @@ -443,17 +423,17 @@ gxm_init(SDL_Renderer *renderer) &fragmentUsseRingBufferOffset); SDL_memset(&data->contextParams, 0, sizeof(SceGxmContextParams)); - data->contextParams.hostMem = SDL_malloc(SCE_GXM_MINIMUM_CONTEXT_HOST_MEM_SIZE); - data->contextParams.hostMemSize = SCE_GXM_MINIMUM_CONTEXT_HOST_MEM_SIZE; - data->contextParams.vdmRingBufferMem = vdmRingBuffer; - data->contextParams.vdmRingBufferMemSize = SCE_GXM_DEFAULT_VDM_RING_BUFFER_SIZE; - data->contextParams.vertexRingBufferMem = vertexRingBuffer; - data->contextParams.vertexRingBufferMemSize = SCE_GXM_DEFAULT_VERTEX_RING_BUFFER_SIZE; - data->contextParams.fragmentRingBufferMem = fragmentRingBuffer; - data->contextParams.fragmentRingBufferMemSize = SCE_GXM_DEFAULT_FRAGMENT_RING_BUFFER_SIZE; - data->contextParams.fragmentUsseRingBufferMem = fragmentUsseRingBuffer; + data->contextParams.hostMem = SDL_malloc(SCE_GXM_MINIMUM_CONTEXT_HOST_MEM_SIZE); + data->contextParams.hostMemSize = SCE_GXM_MINIMUM_CONTEXT_HOST_MEM_SIZE; + data->contextParams.vdmRingBufferMem = vdmRingBuffer; + data->contextParams.vdmRingBufferMemSize = SCE_GXM_DEFAULT_VDM_RING_BUFFER_SIZE; + data->contextParams.vertexRingBufferMem = vertexRingBuffer; + data->contextParams.vertexRingBufferMemSize = SCE_GXM_DEFAULT_VERTEX_RING_BUFFER_SIZE; + data->contextParams.fragmentRingBufferMem = fragmentRingBuffer; + data->contextParams.fragmentRingBufferMemSize = SCE_GXM_DEFAULT_FRAGMENT_RING_BUFFER_SIZE; + data->contextParams.fragmentUsseRingBufferMem = fragmentUsseRingBuffer; data->contextParams.fragmentUsseRingBufferMemSize = SCE_GXM_DEFAULT_FRAGMENT_USSE_RING_BUFFER_SIZE; - data->contextParams.fragmentUsseRingBufferOffset = fragmentUsseRingBufferOffset; + data->contextParams.fragmentUsseRingBufferOffset = fragmentUsseRingBufferOffset; err = sceGxmCreateContext(&data->contextParams, &data->gxm_context); if (err != 0) { @@ -463,13 +443,13 @@ gxm_init(SDL_Renderer *renderer) // set up parameters SDL_memset(&renderTargetParams, 0, sizeof(SceGxmRenderTargetParams)); - renderTargetParams.flags = 0; - renderTargetParams.width = VITA_GXM_SCREEN_WIDTH; - renderTargetParams.height = VITA_GXM_SCREEN_HEIGHT; - renderTargetParams.scenesPerFrame = 1; - renderTargetParams.multisampleMode = 0; + renderTargetParams.flags = 0; + renderTargetParams.width = VITA_GXM_SCREEN_WIDTH; + renderTargetParams.height = VITA_GXM_SCREEN_HEIGHT; + renderTargetParams.scenesPerFrame = 1; + renderTargetParams.multisampleMode = 0; renderTargetParams.multisampleLocations = 0; - renderTargetParams.driverMemBlock = -1; // Invalid UID + renderTargetParams.driverMemBlock = -1; // Invalid UID // create the render target err = sceGxmCreateRenderTarget(&renderTargetParams, &data->renderTarget); @@ -507,25 +487,21 @@ gxm_init(SDL_Renderer *renderer) VITA_GXM_SCREEN_WIDTH, VITA_GXM_SCREEN_HEIGHT, VITA_GXM_SCREEN_STRIDE, - data->displayBufferData[i] - ); + data->displayBufferData[i]); if (err != 0) { SDL_LogError(SDL_LOG_CATEGORY_RENDER, "color surface init failed: %d\n", err); return err; } - // create a sync object that we will associate with this buffer err = sceGxmSyncObjectCreate(&data->displayBufferSync[i]); if (err != 0) { SDL_LogError(SDL_LOG_CATEGORY_RENDER, "sync object creation failed: %d\n", err); return err; } - } - // allocate the depth buffer data->depthBufferData = vita_mem_alloc( SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, @@ -554,7 +530,6 @@ gxm_init(SDL_Renderer *renderer) // set the stencil test reference (this is currently assumed to always remain 1 after here for region clipping) sceGxmSetFrontStencilRef(data->gxm_context, 1); - // set the stencil function (this wouldn't actually be needed, as the set clip rectangle function has to call this at the begginning of every scene) sceGxmSetFrontStencilFunc( data->gxm_context, @@ -565,7 +540,6 @@ gxm_init(SDL_Renderer *renderer) 0xFF, 0xFF); - // allocate memory for buffers and USSE code patcherBuffer = vita_mem_alloc( SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, @@ -586,23 +560,23 @@ gxm_init(SDL_Renderer *renderer) // create a shader patcher SDL_memset(&patcherParams, 0, sizeof(SceGxmShaderPatcherParams)); - patcherParams.userData = NULL; - patcherParams.hostAllocCallback = &patcher_host_alloc; - patcherParams.hostFreeCallback = &patcher_host_free; - patcherParams.bufferAllocCallback = NULL; - patcherParams.bufferFreeCallback = NULL; - patcherParams.bufferMem = patcherBuffer; - patcherParams.bufferMemSize = patcherBufferSize; - patcherParams.vertexUsseAllocCallback = NULL; - patcherParams.vertexUsseFreeCallback = NULL; - patcherParams.vertexUsseMem = patcherVertexUsse; - patcherParams.vertexUsseMemSize = patcherVertexUsseSize; - patcherParams.vertexUsseOffset = patcherVertexUsseOffset; + patcherParams.userData = NULL; + patcherParams.hostAllocCallback = &patcher_host_alloc; + patcherParams.hostFreeCallback = &patcher_host_free; + patcherParams.bufferAllocCallback = NULL; + patcherParams.bufferFreeCallback = NULL; + patcherParams.bufferMem = patcherBuffer; + patcherParams.bufferMemSize = patcherBufferSize; + patcherParams.vertexUsseAllocCallback = NULL; + patcherParams.vertexUsseFreeCallback = NULL; + patcherParams.vertexUsseMem = patcherVertexUsse; + patcherParams.vertexUsseMemSize = patcherVertexUsseSize; + patcherParams.vertexUsseOffset = patcherVertexUsseOffset; patcherParams.fragmentUsseAllocCallback = NULL; - patcherParams.fragmentUsseFreeCallback = NULL; - patcherParams.fragmentUsseMem = patcherFragmentUsse; - patcherParams.fragmentUsseMemSize = patcherFragmentUsseSize; - patcherParams.fragmentUsseOffset = patcherFragmentUsseOffset; + patcherParams.fragmentUsseFreeCallback = NULL; + patcherParams.fragmentUsseMem = patcherFragmentUsse; + patcherParams.fragmentUsseMemSize = patcherFragmentUsseSize; + patcherParams.fragmentUsseOffset = patcherFragmentUsseOffset; err = sceGxmShaderPatcherCreate(&patcherParams, &data->shaderPatcher); if (err != 0) { @@ -610,7 +584,6 @@ gxm_init(SDL_Renderer *renderer) return err; } - // check the shaders err = sceGxmProgramCheck(clearVertexProgramGxp); if (err != 0) { @@ -692,13 +665,13 @@ gxm_init(SDL_Renderer *renderer) // create clear vertex format SceGxmVertexAttribute clearVertexAttributes[1]; SceGxmVertexStream clearVertexStreams[1]; - clearVertexAttributes[0].streamIndex = 0; - clearVertexAttributes[0].offset = 0; - clearVertexAttributes[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32; + clearVertexAttributes[0].streamIndex = 0; + clearVertexAttributes[0].offset = 0; + clearVertexAttributes[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32; clearVertexAttributes[0].componentCount = 2; - clearVertexAttributes[0].regIndex = sceGxmProgramParameterGetResourceIndex(paramClearPositionAttribute); - clearVertexStreams[0].stride = sizeof(clear_vertex); - clearVertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT; + clearVertexAttributes[0].regIndex = sceGxmProgramParameterGetResourceIndex(paramClearPositionAttribute); + clearVertexStreams[0].stride = sizeof(clear_vertex); + clearVertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT; // create clear programs err = sceGxmShaderPatcherCreateVertexProgram( @@ -708,8 +681,7 @@ gxm_init(SDL_Renderer *renderer) 1, clearVertexStreams, 1, - &data->clearVertexProgram - ); + &data->clearVertexProgram); if (err != 0) { SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create program (clear vertex) failed: %d\n", err); return err; @@ -722,8 +694,7 @@ gxm_init(SDL_Renderer *renderer) 0, NULL, clearVertexProgramGxp, - &data->clearFragmentProgram - ); + &data->clearFragmentProgram); if (err != 0) { SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create program (clear fragment) failed: %d\n", err); return err; @@ -732,11 +703,10 @@ gxm_init(SDL_Renderer *renderer) // create the clear triangle vertex/index data data->clearVertices = (clear_vertex *)vita_mem_alloc( SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, - 3*sizeof(clear_vertex), + 3 * sizeof(clear_vertex), 4, SCE_GXM_MEMORY_ATTRIB_READ, - &data->clearVerticesUid - ); + &data->clearVerticesUid); } // Allocate a 64k * 2 bytes = 128 KiB buffer and store all possible @@ -744,11 +714,10 @@ gxm_init(SDL_Renderer *renderer) // all drawing operations where we don't want to use indexing. data->linearIndices = (uint16_t *)vita_mem_alloc( SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, - UINT16_MAX*sizeof(uint16_t), + UINT16_MAX * sizeof(uint16_t), sizeof(uint16_t), SCE_GXM_MEMORY_ATTRIB_READ, - &data->linearIndicesUid - ); + &data->linearIndicesUid); for (i = 0; i <= UINT16_MAX; ++i) { data->linearIndices[i] = i; @@ -756,10 +725,10 @@ gxm_init(SDL_Renderer *renderer) data->clearVertices[0].x = -1.0f; data->clearVertices[0].y = -1.0f; - data->clearVertices[1].x = 3.0f; + data->clearVertices[1].x = 3.0f; data->clearVertices[1].y = -1.0f; data->clearVertices[2].x = -1.0f; - data->clearVertices[2].y = 3.0f; + data->clearVertices[2].y = 3.0f; { const SceGxmProgramParameter *paramColorPositionAttribute = sceGxmProgramFindParameterByName(colorVertexProgramGxp, "aPosition"); @@ -793,16 +762,13 @@ gxm_init(SDL_Renderer *renderer) 2, colorVertexStreams, 1, - &data->colorVertexProgram - ); + &data->colorVertexProgram); if (err != 0) { SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create program (color vertex) failed: %d\n", err); return err; } - } - { const SceGxmProgramParameter *paramTexturePositionAttribute = sceGxmProgramFindParameterByName(textureVertexProgramGxp, "aPosition"); const SceGxmProgramParameter *paramTextureTexcoordAttribute = sceGxmProgramFindParameterByName(textureVertexProgramGxp, "aTexcoord"); @@ -841,13 +807,11 @@ gxm_init(SDL_Renderer *renderer) 3, textureVertexStreams, 1, - &data->textureVertexProgram - ); + &data->textureVertexProgram); if (err != 0) { SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create program (texture vertex) failed: %x\n", err); return err; } - } // Create variations of the fragment program based on blending mode @@ -863,7 +827,6 @@ gxm_init(SDL_Renderer *renderer) data->colorFragmentProgram = in->color; data->textureFragmentProgram = in->texture; - } // find vertex uniforms by name and cache parameter information @@ -877,16 +840,14 @@ gxm_init(SDL_Renderer *renderer) VITA_GXM_POOL_SIZE, sizeof(void *), SCE_GXM_MEMORY_ATTRIB_READ, - &data->poolUid[0] - ); + &data->poolUid[0]); data->pool_addr[1] = vita_mem_alloc( SCE_KERNEL_MEMBLOCK_TYPE_USER_RW, VITA_GXM_POOL_SIZE, sizeof(void *), SCE_GXM_MEMORY_ATTRIB_READ, - &data->poolUid[1] - ); + &data->poolUid[1]); init_orthographic_matrix(data->ortho_matrix, 0.0f, VITA_GXM_SCREEN_WIDTH, VITA_GXM_SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f); @@ -901,7 +862,7 @@ gxm_init(SDL_Renderer *renderer) void gxm_finish(SDL_Renderer *renderer) { - VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata; // wait until rendering is done sceGxmFinish(data->gxm_context); @@ -912,7 +873,6 @@ void gxm_finish(SDL_Renderer *renderer) sceGxmShaderPatcherReleaseVertexProgram(data->shaderPatcher, data->colorVertexProgram); sceGxmShaderPatcherReleaseVertexProgram(data->shaderPatcher, data->textureVertexProgram); - free_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_none); free_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_blend); free_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_add); @@ -975,8 +935,7 @@ void gxm_finish(SDL_Renderer *renderer) // textures -void -free_gxm_texture(VITA_GXM_RenderData *data, gxm_texture *texture) +void free_gxm_texture(VITA_GXM_RenderData *data, gxm_texture *texture) { if (texture) { if (texture->gxm_rendertarget) { @@ -1032,18 +991,18 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc gxm_texture *texture = SDL_calloc(1, sizeof(gxm_texture)); int aligned_w = ALIGN(w, 8); int texture_w = w; - int tex_size = aligned_w * h * tex_format_to_bytespp(format); + int tex_size = aligned_w * h * tex_format_to_bytespp(format); void *texture_data; int ret; *return_wscale = 1.0f; // SCE_GXM_TEXTURE_BASE_FORMAT_YUV420P3/P2 based formats require width aligned to 16 - if ( (format & 0x9f000000U) == SCE_GXM_TEXTURE_BASE_FORMAT_YUV420P3 || (format & 0x9f000000U) == SCE_GXM_TEXTURE_BASE_FORMAT_YUV420P2) { + if ((format & 0x9f000000U) == SCE_GXM_TEXTURE_BASE_FORMAT_YUV420P3 || (format & 0x9f000000U) == SCE_GXM_TEXTURE_BASE_FORMAT_YUV420P2) { aligned_w = ALIGN(w, 16); texture_w = aligned_w; - tex_size = aligned_w * h * tex_format_to_bytespp(format); - *return_wscale = (float) (w) / texture_w; + tex_size = aligned_w * h * tex_format_to_bytespp(format); + *return_wscale = (float)(w) / texture_w; // add storage for UV planes tex_size += (((aligned_w + 1) / 2) * ((h + 1) / 2)) * 2; } @@ -1059,8 +1018,7 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc /* Allocate a GPU buffer for the texture */ texture_data = vita_gpu_mem_alloc( data, - tex_size - ); + tex_size); /* Try SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE in case we're out of VRAM */ if (texture_data == NULL) { @@ -1070,8 +1028,7 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc tex_size, SCE_GXM_TEXTURE_ALIGNMENT, SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE, - &texture->data_UID - ); + &texture->data_UID); texture->cdram = 0; } else { texture->cdram = 1; @@ -1086,22 +1043,21 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc SDL_memset(texture_data, 0, tex_size); /* Create the gxm texture */ - ret = sceGxmTextureInitLinear( &texture->gxm_tex, texture_data, format, texture_w, h, 0); + ret = sceGxmTextureInitLinear(&texture->gxm_tex, texture_data, format, texture_w, h, 0); if (ret < 0) { - free_gxm_texture(data, texture); - SDL_LogError(SDL_LOG_CATEGORY_RENDER, "texture init failed: %x\n", ret); - return NULL; + free_gxm_texture(data, texture); + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "texture init failed: %x\n", ret); + return NULL; } if (isRenderTarget) { void *depthBufferData; const uint32_t alignedWidth = ALIGN(w, SCE_GXM_TILE_SIZEX); const uint32_t alignedHeight = ALIGN(h, SCE_GXM_TILE_SIZEY); - uint32_t sampleCount = alignedWidth*alignedHeight; + uint32_t sampleCount = alignedWidth * alignedHeight; uint32_t depthStrideInSamples = alignedWidth; const uint32_t alignedColorSurfaceStride = ALIGN(w, 8); - int err = sceGxmColorSurfaceInit( &texture->gxm_colorsurface, tex_format_to_color_format(format), @@ -1111,8 +1067,7 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc w, h, alignedColorSurfaceStride, - texture_data - ); + texture_data); if (err < 0) { free_gxm_texture(data, texture); @@ -1123,7 +1078,7 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc // allocate it depthBufferData = vita_mem_alloc( SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, - 4*sampleCount, + 4 * sampleCount, SCE_GXM_DEPTHSTENCIL_SURFACE_ALIGNMENT, SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE, &texture->depth_UID); @@ -1168,14 +1123,12 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc return NULL; } } - } return texture; } -void -gxm_texture_set_filters(gxm_texture *texture, SceGxmTextureFilter min_filter, SceGxmTextureFilter mag_filter) +void gxm_texture_set_filters(gxm_texture *texture, SceGxmTextureFilter min_filter, SceGxmTextureFilter mag_filter) { sceGxmTextureSetMinFilter(&texture->gxm_tex, min_filter); sceGxmTextureSetMagFilter(&texture->gxm_tex, mag_filter); @@ -1186,7 +1139,7 @@ static unsigned int front_buffer_index_for_common_dialog = 0; struct { VITA_GXM_DisplayData displayData; - SceGxmSyncObject* sync; + SceGxmSyncObject *sync; SceGxmColorSurface surf; SceUID uid; } buffer_for_common_dialog[VITA_GXM_BUFFERS]; @@ -1195,11 +1148,11 @@ void gxm_minimal_init_for_common_dialog(void) { SceGxmInitializeParams initializeParams; SDL_zero(initializeParams); - initializeParams.flags = 0; - initializeParams.displayQueueMaxPendingCount = VITA_GXM_PENDING_SWAPS; - initializeParams.displayQueueCallback = display_callback; - initializeParams.displayQueueCallbackDataSize = sizeof(VITA_GXM_DisplayData); - initializeParams.parameterBufferSize = SCE_GXM_DEFAULT_PARAMETER_BUFFER_SIZE; + initializeParams.flags = 0; + initializeParams.displayQueueMaxPendingCount = VITA_GXM_PENDING_SWAPS; + initializeParams.displayQueueCallback = display_callback; + initializeParams.displayQueueCallbackDataSize = sizeof(VITA_GXM_DisplayData); + initializeParams.parameterBufferSize = SCE_GXM_DEFAULT_PARAMETER_BUFFER_SIZE; sceGxmInitialize(&initializeParams); } @@ -1227,8 +1180,7 @@ void gxm_init_for_common_dialog(void) VITA_GXM_SCREEN_WIDTH, VITA_GXM_SCREEN_HEIGHT, VITA_GXM_SCREEN_STRIDE, - buffer_for_common_dialog[i].displayData.address - ); + buffer_for_common_dialog[i].displayData.address); sceGxmSyncObjectCreate(&buffer_for_common_dialog[i].sync); } sceGxmDisplayQueueFinish(); @@ -1238,10 +1190,10 @@ void gxm_swap_for_common_dialog(void) { SceCommonDialogUpdateParam updateParam; SDL_zero(updateParam); - updateParam.renderTarget.colorFormat = VITA_GXM_PIXEL_FORMAT; - updateParam.renderTarget.surfaceType = SCE_GXM_COLOR_SURFACE_LINEAR; - updateParam.renderTarget.width = VITA_GXM_SCREEN_WIDTH; - updateParam.renderTarget.height = VITA_GXM_SCREEN_HEIGHT; + updateParam.renderTarget.colorFormat = VITA_GXM_PIXEL_FORMAT; + updateParam.renderTarget.surfaceType = SCE_GXM_COLOR_SURFACE_LINEAR; + updateParam.renderTarget.width = VITA_GXM_SCREEN_WIDTH; + updateParam.renderTarget.height = VITA_GXM_SCREEN_HEIGHT; updateParam.renderTarget.strideInPixels = VITA_GXM_SCREEN_STRIDE; updateParam.renderTarget.colorSurfaceData = buffer_for_common_dialog[back_buffer_index_for_common_dialog].displayData.address; diff --git a/src/render/vitagxm/SDL_render_vita_gxm_tools.h b/src/render/vitagxm/SDL_render_vita_gxm_tools.h index 67659889d..71acd2424 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm_tools.h +++ b/src/render/vitagxm/SDL_render_vita_gxm_tools.h @@ -36,8 +36,7 @@ #include "SDL_render_vita_gxm_types.h" -void -init_orthographic_matrix(float *m, float left, float right, float bottom, float top, float near, float far); +void init_orthographic_matrix(float *m, float left, float right, float bottom, float top, float near, float far); void *pool_malloc(VITA_GXM_RenderData *data, unsigned int size); void *pool_memalign(VITA_GXM_RenderData *data, unsigned int size, unsigned int alignment); diff --git a/src/render/vitagxm/SDL_render_vita_gxm_types.h b/src/render/vitagxm/SDL_render_vita_gxm_types.h index c5cbf5898..20df6b509 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm_types.h +++ b/src/render/vitagxm/SDL_render_vita_gxm_types.h @@ -37,35 +37,38 @@ #include -#define VITA_GXM_SCREEN_WIDTH 960 -#define VITA_GXM_SCREEN_HEIGHT 544 -#define VITA_GXM_SCREEN_STRIDE 960 +#define VITA_GXM_SCREEN_WIDTH 960 +#define VITA_GXM_SCREEN_HEIGHT 544 +#define VITA_GXM_SCREEN_STRIDE 960 -#define VITA_GXM_COLOR_FORMAT SCE_GXM_COLOR_FORMAT_A8B8G8R8 -#define VITA_GXM_PIXEL_FORMAT SCE_DISPLAY_PIXELFORMAT_A8B8G8R8 +#define VITA_GXM_COLOR_FORMAT SCE_GXM_COLOR_FORMAT_A8B8G8R8 +#define VITA_GXM_PIXEL_FORMAT SCE_DISPLAY_PIXELFORMAT_A8B8G8R8 -#define VITA_GXM_BUFFERS 3 -#define VITA_GXM_PENDING_SWAPS 2 -#define VITA_GXM_POOL_SIZE 2 * 1024 * 1024 +#define VITA_GXM_BUFFERS 3 +#define VITA_GXM_PENDING_SWAPS 2 +#define VITA_GXM_POOL_SIZE 2 * 1024 * 1024 typedef struct { - void *address; - Uint8 wait_vblank; + void *address; + Uint8 wait_vblank; } VITA_GXM_DisplayData; -typedef struct clear_vertex { +typedef struct clear_vertex +{ float x; float y; } clear_vertex; -typedef struct color_vertex { +typedef struct color_vertex +{ float x; float y; SDL_Color color; } color_vertex; -typedef struct texture_vertex { +typedef struct texture_vertex +{ float x; float y; float u; @@ -73,7 +76,8 @@ typedef struct texture_vertex { SDL_Color color; } texture_vertex; -typedef struct gxm_texture { +typedef struct gxm_texture +{ SceGxmTexture gxm_tex; SceUID data_UID; SceGxmRenderTarget *gxm_rendertarget; @@ -83,12 +87,14 @@ typedef struct gxm_texture { SDL_bool cdram; } gxm_texture; -typedef struct fragment_programs { +typedef struct fragment_programs +{ SceGxmFragmentProgram *color; SceGxmFragmentProgram *texture; } fragment_programs; -typedef struct blend_fragment_programs { +typedef struct blend_fragment_programs +{ fragment_programs blend_mode_none; fragment_programs blend_mode_blend; fragment_programs blend_mode_add; @@ -119,13 +125,13 @@ typedef struct typedef struct { - SDL_bool initialized; - SDL_bool drawing; + SDL_bool initialized; + SDL_bool drawing; - unsigned int psm; - unsigned int bpp; + unsigned int psm; + unsigned int bpp; - int currentBlendMode; + int currentBlendMode; VITA_GXM_DisplayData displayData; @@ -150,12 +156,12 @@ typedef struct unsigned int backBufferIndex; unsigned int frontBufferIndex; - void* pool_addr[2]; + void *pool_addr[2]; SceUID poolUid[2]; unsigned int pool_index; unsigned int current_pool; - float ortho_matrix[4*4]; + float ortho_matrix[4 * 4]; SceGxmVertexProgram *colorVertexProgram; SceGxmFragmentProgram *colorFragmentProgram; @@ -194,13 +200,13 @@ typedef struct typedef struct { - gxm_texture *tex; + gxm_texture *tex; unsigned int pitch; unsigned int w; unsigned int h; float wscale; - SDL_bool yuv; - SDL_bool nv12; + SDL_bool yuv; + SDL_bool nv12; } VITA_GXM_TextureData; #endif /* SDL_RENDER_VITA_GXM_TYPES_H */ diff --git a/src/sensor/SDL_sensor.c b/src/sensor/SDL_sensor.c index 6237498f2..2b73f1ced 100644 --- a/src/sensor/SDL_sensor.c +++ b/src/sensor/SDL_sensor.c @@ -56,25 +56,21 @@ static SDL_bool SDL_updating_sensor = SDL_FALSE; static SDL_mutex *SDL_sensor_lock = NULL; /* This needs to support recursive locks */ static SDL_atomic_t SDL_next_sensor_instance_id; -void -SDL_LockSensors(void) +void SDL_LockSensors(void) { if (SDL_sensor_lock) { SDL_LockMutex(SDL_sensor_lock); } } -void -SDL_UnlockSensors(void) +void SDL_UnlockSensors(void) { if (SDL_sensor_lock) { SDL_UnlockMutex(SDL_sensor_lock); } } - -int -SDL_SensorInit(void) +int SDL_SensorInit(void) { int i, status; @@ -101,8 +97,7 @@ SDL_SensorInit(void) /* * Count the number of sensors attached to the system */ -int -SDL_NumSensors(void) +int SDL_NumSensors(void) { int i, total_sensors = 0; SDL_LockSensors(); @@ -126,8 +121,7 @@ SDL_SensorID SDL_GetNextSensorInstanceID() * Get the driver and device index for an API device index * This should be called while the sensor lock is held, to prevent another thread from updating the list */ -static SDL_bool -SDL_GetDriverAndSensorIndex(int device_index, SDL_SensorDriver **driver, int *driver_index) +static SDL_bool SDL_GetDriverAndSensorIndex(int device_index, SDL_SensorDriver **driver, int *driver_index) { int i, num_sensors, total_sensors = 0; @@ -182,8 +176,7 @@ SDL_SensorGetDeviceType(int device_index) return type; } -int -SDL_SensorGetDeviceNonPortableType(int device_index) +int SDL_SensorGetDeviceNonPortableType(int device_index) { SDL_SensorDriver *driver; int type = -1; @@ -242,16 +235,16 @@ SDL_SensorOpen(int device_index) instance_id = driver->GetDeviceInstanceID(device_index); while (sensorlist) { if (instance_id == sensorlist->instance_id) { - sensor = sensorlist; - ++sensor->ref_count; - SDL_UnlockSensors(); - return sensor; + sensor = sensorlist; + ++sensor->ref_count; + SDL_UnlockSensors(); + return sensor; } sensorlist = sensorlist->next; } /* Create and initialize the sensor */ - sensor = (SDL_Sensor *) SDL_calloc(sizeof(*sensor), 1); + sensor = (SDL_Sensor *)SDL_calloc(sizeof(*sensor), 1); if (sensor == NULL) { SDL_OutOfMemory(); SDL_UnlockSensors(); @@ -309,8 +302,7 @@ SDL_SensorFromInstanceID(SDL_SensorID instance_id) /* * Checks to make sure the sensor is valid. */ -static int -SDL_PrivateSensorValid(SDL_Sensor *sensor) +static int SDL_PrivateSensorValid(SDL_Sensor *sensor) { int valid; @@ -353,8 +345,7 @@ SDL_SensorGetType(SDL_Sensor *sensor) /* * Get the platform dependent type of this sensor */ -int -SDL_SensorGetNonPortableType(SDL_Sensor *sensor) +int SDL_SensorGetNonPortableType(SDL_Sensor *sensor) { if (!SDL_PrivateSensorValid(sensor)) { return -1; @@ -379,8 +370,7 @@ SDL_SensorGetInstanceID(SDL_Sensor *sensor) /* * Get the current state of this sensor */ -int -SDL_SensorGetData(SDL_Sensor *sensor, float *data, int num_values) +int SDL_SensorGetData(SDL_Sensor *sensor, float *data, int num_values) { return SDL_SensorGetDataWithTimestamp(sensor, NULL, data, num_values); } @@ -388,15 +378,14 @@ SDL_SensorGetData(SDL_Sensor *sensor, float *data, int num_values) /* * Get the current state of this sensor */ -int -SDL_SensorGetDataWithTimestamp(SDL_Sensor *sensor, Uint64 *timestamp, float *data, int num_values) +int SDL_SensorGetDataWithTimestamp(SDL_Sensor *sensor, Uint64 *timestamp, float *data, int num_values) { if (!SDL_PrivateSensorValid(sensor)) { return -1; } num_values = SDL_min(num_values, SDL_arraysize(sensor->data)); - SDL_memcpy(data, sensor->data, num_values*sizeof(*data)); + SDL_memcpy(data, sensor->data, num_values * sizeof(*data)); if (timestamp) { *timestamp = sensor->timestamp_us; } @@ -406,8 +395,7 @@ SDL_SensorGetDataWithTimestamp(SDL_Sensor *sensor, Uint64 *timestamp, float *dat /* * Close a sensor previously opened with SDL_SensorOpen() */ -void -SDL_SensorClose(SDL_Sensor *sensor) +void SDL_SensorClose(SDL_Sensor *sensor) { SDL_Sensor *sensorlist; SDL_Sensor *sensorlistprev; @@ -456,8 +444,7 @@ SDL_SensorClose(SDL_Sensor *sensor) SDL_UnlockSensors(); } -void -SDL_SensorQuit(void) +void SDL_SensorQuit(void) { int i; @@ -474,7 +461,7 @@ SDL_SensorQuit(void) /* Quit the sensor setup */ for (i = 0; i < SDL_arraysize(SDL_sensor_drivers); ++i) { - SDL_sensor_drivers[i]->Quit(); + SDL_sensor_drivers[i]->Quit(); } SDL_UnlockSensors(); @@ -489,11 +476,9 @@ SDL_SensorQuit(void) } } - /* These are global for SDL_syssensor.c and SDL_events.c */ -int -SDL_PrivateSensorUpdate(SDL_Sensor *sensor, Uint64 timestamp_us, float *data, int num_values) +int SDL_PrivateSensorUpdate(SDL_Sensor *sensor, Uint64 timestamp_us, float *data, int num_values) { int posted; @@ -501,7 +486,7 @@ SDL_PrivateSensorUpdate(SDL_Sensor *sensor, Uint64 timestamp_us, float *data, in /* Update internal sensor state */ num_values = SDL_min(num_values, SDL_arraysize(sensor->data)); - SDL_memcpy(sensor->data, data, num_values*sizeof(*data)); + SDL_memcpy(sensor->data, data, num_values * sizeof(*data)); sensor->timestamp_us = timestamp_us; /* Post the event, if desired */ @@ -513,7 +498,7 @@ SDL_PrivateSensorUpdate(SDL_Sensor *sensor, Uint64 timestamp_us, float *data, in event.sensor.which = sensor->instance_id; num_values = SDL_min(num_values, SDL_arraysize(event.sensor.data)); SDL_memset(event.sensor.data, 0, sizeof(event.sensor.data)); - SDL_memcpy(event.sensor.data, data, num_values*sizeof(*data)); + SDL_memcpy(event.sensor.data, data, num_values * sizeof(*data)); event.sensor.timestamp_us = timestamp_us; posted = SDL_PushEvent(&event) == 1; } @@ -521,8 +506,7 @@ SDL_PrivateSensorUpdate(SDL_Sensor *sensor, Uint64 timestamp_us, float *data, in return posted; } -void -SDL_SensorUpdate(void) +void SDL_SensorUpdate(void) { int i; SDL_Sensor *sensor, *next; diff --git a/src/sensor/SDL_syssensor.h b/src/sensor/SDL_syssensor.h index 30d44009a..8e56ca0f6 100644 --- a/src/sensor/SDL_syssensor.h +++ b/src/sensor/SDL_syssensor.h @@ -32,21 +32,21 @@ /* The SDL sensor structure */ struct _SDL_Sensor { - SDL_SensorID instance_id; /* Device instance, monotonically increasing from 0 */ - char *name; /* Sensor name - system dependent */ - SDL_SensorType type; /* Type of the sensor */ - int non_portable_type; /* Platform dependent type of the sensor */ + SDL_SensorID instance_id; /* Device instance, monotonically increasing from 0 */ + char *name; /* Sensor name - system dependent */ + SDL_SensorType type; /* Type of the sensor */ + int non_portable_type; /* Platform dependent type of the sensor */ - Uint64 timestamp_us; /* The timestamp of the last sensor update */ - float data[16]; /* The current state of the sensor */ + Uint64 timestamp_us; /* The timestamp of the last sensor update */ + float data[16]; /* The current state of the sensor */ struct _SDL_SensorDriver *driver; - struct sensor_hwdata *hwdata; /* Driver dependent information */ + struct sensor_hwdata *hwdata; /* Driver dependent information */ - int ref_count; /* Reference count for multiple opens */ + int ref_count; /* Reference count for multiple opens */ - struct _SDL_Sensor *next; /* pointer to next sensor we have allocated */ + struct _SDL_Sensor *next; /* pointer to next sensor we have allocated */ }; typedef struct _SDL_SensorDriver @@ -79,17 +79,17 @@ typedef struct _SDL_SensorDriver The sensor to open is specified by the device index. It returns 0, or -1 if there is an error. */ - int (*Open)(SDL_Sensor * sensor, int device_index); + int (*Open)(SDL_Sensor *sensor, int device_index); /* Function to update the state of a sensor - called as a device poll. * This function shouldn't update the sensor structure directly, * but instead should call SDL_PrivateSensorUpdate() to deliver events * and update sensor device state. */ - void (*Update)(SDL_Sensor * sensor); + void (*Update)(SDL_Sensor *sensor); /* Function to close a sensor after use */ - void (*Close)(SDL_Sensor * sensor); + void (*Close)(SDL_Sensor *sensor); /* Function to perform any system-specific sensor related cleanup */ void (*Quit)(void); diff --git a/src/sensor/android/SDL_androidsensor.c b/src/sensor/android/SDL_androidsensor.c index 69c3f28fa..d8fb8e99d 100644 --- a/src/sensor/android/SDL_androidsensor.c +++ b/src/sensor/android/SDL_androidsensor.c @@ -35,7 +35,7 @@ //#include "../../core/android/SDL_android.h" #ifndef LOOPER_ID_USER -#define LOOPER_ID_USER 3 +#define LOOPER_ID_USER 3 #endif typedef struct @@ -44,13 +44,12 @@ typedef struct SDL_SensorID instance_id; } SDL_AndroidSensor; -static ASensorManager* SDL_sensor_manager; -static ALooper* SDL_sensor_looper; +static ASensorManager *SDL_sensor_manager; +static ALooper *SDL_sensor_looper; static SDL_AndroidSensor *SDL_sensors; static int SDL_sensors_count; -static int -SDL_ANDROID_SensorInit(void) +static int SDL_ANDROID_SensorInit(void) { int i, sensors_count; ASensorList sensors; @@ -85,25 +84,21 @@ SDL_ANDROID_SensorInit(void) return 0; } -static int -SDL_ANDROID_SensorGetCount(void) +static int SDL_ANDROID_SensorGetCount(void) { return SDL_sensors_count; } -static void -SDL_ANDROID_SensorDetect(void) +static void SDL_ANDROID_SensorDetect(void) { } -static const char * -SDL_ANDROID_SensorGetDeviceName(int device_index) +static const char *SDL_ANDROID_SensorGetDeviceName(int device_index) { return ASensor_getName(SDL_sensors[device_index].asensor); } -static SDL_SensorType -SDL_ANDROID_SensorGetDeviceType(int device_index) +static SDL_SensorType SDL_ANDROID_SensorGetDeviceType(int device_index) { switch (ASensor_getType(SDL_sensors[device_index].asensor)) { case 0x00000001: @@ -115,20 +110,17 @@ SDL_ANDROID_SensorGetDeviceType(int device_index) } } -static int -SDL_ANDROID_SensorGetDeviceNonPortableType(int device_index) +static int SDL_ANDROID_SensorGetDeviceNonPortableType(int device_index) { return ASensor_getType(SDL_sensors[device_index].asensor); } -static SDL_SensorID -SDL_ANDROID_SensorGetDeviceInstanceID(int device_index) +static SDL_SensorID SDL_ANDROID_SensorGetDeviceInstanceID(int device_index) { return SDL_sensors[device_index].instance_id; } -static int -SDL_ANDROID_SensorOpen(SDL_Sensor *sensor, int device_index) +static int SDL_ANDROID_SensorOpen(SDL_Sensor *sensor, int device_index) { struct sensor_hwdata *hwdata; int delay_us, min_delay_us; @@ -163,15 +155,14 @@ SDL_ANDROID_SensorOpen(SDL_Sensor *sensor, int device_index) sensor->hwdata = hwdata; return 0; } - -static void -SDL_ANDROID_SensorUpdate(SDL_Sensor *sensor) + +static void SDL_ANDROID_SensorUpdate(SDL_Sensor *sensor) { int events; ASensorEvent event; - struct android_poll_source* source; + struct android_poll_source *source; - if (ALooper_pollAll(0, NULL, &events, (void**)&source) == LOOPER_ID_USER) { + if (ALooper_pollAll(0, NULL, &events, (void **)&source) == LOOPER_ID_USER) { SDL_zero(event); while (ASensorEventQueue_getEvents(sensor->hwdata->eventqueue, &event, 1) > 0) { SDL_PrivateSensorUpdate(sensor, 0, event.data, SDL_arraysize(event.data)); @@ -179,8 +170,7 @@ SDL_ANDROID_SensorUpdate(SDL_Sensor *sensor) } } -static void -SDL_ANDROID_SensorClose(SDL_Sensor *sensor) +static void SDL_ANDROID_SensorClose(SDL_Sensor *sensor) { if (sensor->hwdata) { ASensorEventQueue_disableSensor(sensor->hwdata->eventqueue, sensor->hwdata->asensor); @@ -190,8 +180,7 @@ SDL_ANDROID_SensorClose(SDL_Sensor *sensor) } } -static void -SDL_ANDROID_SensorQuit(void) +static void SDL_ANDROID_SensorQuit(void) { if (SDL_sensors) { SDL_free(SDL_sensors); @@ -200,8 +189,7 @@ SDL_ANDROID_SensorQuit(void) } } -SDL_SensorDriver SDL_ANDROID_SensorDriver = -{ +SDL_SensorDriver SDL_ANDROID_SensorDriver = { SDL_ANDROID_SensorInit, SDL_ANDROID_SensorGetCount, SDL_ANDROID_SensorDetect, diff --git a/src/sensor/android/SDL_androidsensor.h b/src/sensor/android/SDL_androidsensor.h index 4fc5e6526..bfe9333be 100644 --- a/src/sensor/android/SDL_androidsensor.h +++ b/src/sensor/android/SDL_androidsensor.h @@ -27,5 +27,4 @@ struct sensor_hwdata ASensorEventQueue *eventqueue; }; - /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/sensor/coremotion/SDL_coremotionsensor.h b/src/sensor/coremotion/SDL_coremotionsensor.h index 664bf3bf1..c0018bf9f 100644 --- a/src/sensor/coremotion/SDL_coremotionsensor.h +++ b/src/sensor/coremotion/SDL_coremotionsensor.h @@ -26,5 +26,4 @@ struct sensor_hwdata float data[3]; }; - /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/sensor/coremotion/SDL_coremotionsensor.m b/src/sensor/coremotion/SDL_coremotionsensor.m index 735ecf54d..199c172e9 100644 --- a/src/sensor/coremotion/SDL_coremotionsensor.m +++ b/src/sensor/coremotion/SDL_coremotionsensor.m @@ -42,8 +42,7 @@ static CMMotionManager *SDL_motion_manager; static SDL_CoreMotionSensor *SDL_sensors; static int SDL_sensors_count; -static int -SDL_COREMOTION_SensorInit(void) +static int SDL_COREMOTION_SensorInit(void) { int i, sensors_count = 0; @@ -80,19 +79,16 @@ SDL_COREMOTION_SensorInit(void) return 0; } -static int -SDL_COREMOTION_SensorGetCount(void) +static int SDL_COREMOTION_SensorGetCount(void) { return SDL_sensors_count; } -static void -SDL_COREMOTION_SensorDetect(void) +static void SDL_COREMOTION_SensorDetect(void) { } -static const char * -SDL_COREMOTION_SensorGetDeviceName(int device_index) +static const char *SDL_COREMOTION_SensorGetDeviceName(int device_index) { switch (SDL_sensors[device_index].type) { case SDL_SENSOR_ACCEL: @@ -104,26 +100,22 @@ SDL_COREMOTION_SensorGetDeviceName(int device_index) } } -static SDL_SensorType -SDL_COREMOTION_SensorGetDeviceType(int device_index) +static SDL_SensorType SDL_COREMOTION_SensorGetDeviceType(int device_index) { return SDL_sensors[device_index].type; } -static int -SDL_COREMOTION_SensorGetDeviceNonPortableType(int device_index) +static int SDL_COREMOTION_SensorGetDeviceNonPortableType(int device_index) { return SDL_sensors[device_index].type; } -static SDL_SensorID -SDL_COREMOTION_SensorGetDeviceInstanceID(int device_index) +static SDL_SensorID SDL_COREMOTION_SensorGetDeviceInstanceID(int device_index) { return SDL_sensors[device_index].instance_id; } -static int -SDL_COREMOTION_SensorOpen(SDL_Sensor *sensor, int device_index) +static int SDL_COREMOTION_SensorOpen(SDL_Sensor *sensor, int device_index) { struct sensor_hwdata *hwdata; @@ -133,8 +125,7 @@ SDL_COREMOTION_SensorOpen(SDL_Sensor *sensor, int device_index) } sensor->hwdata = hwdata; - switch (sensor->type) - { + switch (sensor->type) { case SDL_SENSOR_ACCEL: [SDL_motion_manager startAccelerometerUpdates]; break; @@ -146,55 +137,49 @@ SDL_COREMOTION_SensorOpen(SDL_Sensor *sensor, int device_index) } return 0; } - -static void -SDL_COREMOTION_SensorUpdate(SDL_Sensor *sensor) + +static void SDL_COREMOTION_SensorUpdate(SDL_Sensor *sensor) { - switch (sensor->type) - { + switch (sensor->type) { case SDL_SENSOR_ACCEL: - { - CMAccelerometerData *accelerometerData = SDL_motion_manager.accelerometerData; - if (accelerometerData) { - CMAcceleration acceleration = accelerometerData.acceleration; - float data[3]; - data[0] = -acceleration.x * SDL_STANDARD_GRAVITY; - data[1] = -acceleration.y * SDL_STANDARD_GRAVITY; - data[2] = -acceleration.z * SDL_STANDARD_GRAVITY; - if (SDL_memcmp(data, sensor->hwdata->data, sizeof(data)) != 0) { - SDL_PrivateSensorUpdate(sensor, 0, data, SDL_arraysize(data)); - SDL_memcpy(sensor->hwdata->data, data, sizeof(data)); - } + { + CMAccelerometerData *accelerometerData = SDL_motion_manager.accelerometerData; + if (accelerometerData) { + CMAcceleration acceleration = accelerometerData.acceleration; + float data[3]; + data[0] = -acceleration.x * SDL_STANDARD_GRAVITY; + data[1] = -acceleration.y * SDL_STANDARD_GRAVITY; + data[2] = -acceleration.z * SDL_STANDARD_GRAVITY; + if (SDL_memcmp(data, sensor->hwdata->data, sizeof(data)) != 0) { + SDL_PrivateSensorUpdate(sensor, 0, data, SDL_arraysize(data)); + SDL_memcpy(sensor->hwdata->data, data, sizeof(data)); } } - break; + } break; case SDL_SENSOR_GYRO: - { - CMGyroData *gyroData = SDL_motion_manager.gyroData; - if (gyroData) { - CMRotationRate rotationRate = gyroData.rotationRate; - float data[3]; - data[0] = rotationRate.x; - data[1] = rotationRate.y; - data[2] = rotationRate.z; - if (SDL_memcmp(data, sensor->hwdata->data, sizeof(data)) != 0) { - SDL_PrivateSensorUpdate(sensor, 0, data, SDL_arraysize(data)); - SDL_memcpy(sensor->hwdata->data, data, sizeof(data)); - } + { + CMGyroData *gyroData = SDL_motion_manager.gyroData; + if (gyroData) { + CMRotationRate rotationRate = gyroData.rotationRate; + float data[3]; + data[0] = rotationRate.x; + data[1] = rotationRate.y; + data[2] = rotationRate.z; + if (SDL_memcmp(data, sensor->hwdata->data, sizeof(data)) != 0) { + SDL_PrivateSensorUpdate(sensor, 0, data, SDL_arraysize(data)); + SDL_memcpy(sensor->hwdata->data, data, sizeof(data)); } } - break; + } break; default: break; } } -static void -SDL_COREMOTION_SensorClose(SDL_Sensor *sensor) +static void SDL_COREMOTION_SensorClose(SDL_Sensor *sensor) { if (sensor->hwdata) { - switch (sensor->type) - { + switch (sensor->type) { case SDL_SENSOR_ACCEL: [SDL_motion_manager stopAccelerometerUpdates]; break; @@ -209,13 +194,11 @@ SDL_COREMOTION_SensorClose(SDL_Sensor *sensor) } } -static void -SDL_COREMOTION_SensorQuit(void) +static void SDL_COREMOTION_SensorQuit(void) { } -SDL_SensorDriver SDL_COREMOTION_SensorDriver = -{ +SDL_SensorDriver SDL_COREMOTION_SensorDriver = { SDL_COREMOTION_SensorInit, SDL_COREMOTION_SensorGetCount, SDL_COREMOTION_SensorDetect, diff --git a/src/sensor/dummy/SDL_dummysensor.c b/src/sensor/dummy/SDL_dummysensor.c index 469d35dc1..386410110 100644 --- a/src/sensor/dummy/SDL_dummysensor.c +++ b/src/sensor/dummy/SDL_dummysensor.c @@ -29,70 +29,58 @@ #include "SDL_dummysensor.h" #include "../SDL_syssensor.h" -static int -SDL_DUMMY_SensorInit(void) +static int SDL_DUMMY_SensorInit(void) { return 0; } -static int -SDL_DUMMY_SensorGetCount(void) +static int SDL_DUMMY_SensorGetCount(void) { return 0; } -static void -SDL_DUMMY_SensorDetect(void) +static void SDL_DUMMY_SensorDetect(void) { } -static const char * -SDL_DUMMY_SensorGetDeviceName(int device_index) +static const char *SDL_DUMMY_SensorGetDeviceName(int device_index) { return NULL; } -static SDL_SensorType -SDL_DUMMY_SensorGetDeviceType(int device_index) +static SDL_SensorType SDL_DUMMY_SensorGetDeviceType(int device_index) { return SDL_SENSOR_INVALID; } -static int -SDL_DUMMY_SensorGetDeviceNonPortableType(int device_index) +static int SDL_DUMMY_SensorGetDeviceNonPortableType(int device_index) { return -1; } -static SDL_SensorID -SDL_DUMMY_SensorGetDeviceInstanceID(int device_index) +static SDL_SensorID SDL_DUMMY_SensorGetDeviceInstanceID(int device_index) { return -1; } -static int -SDL_DUMMY_SensorOpen(SDL_Sensor *sensor, int device_index) +static int SDL_DUMMY_SensorOpen(SDL_Sensor *sensor, int device_index) { return SDL_Unsupported(); } - -static void -SDL_DUMMY_SensorUpdate(SDL_Sensor *sensor) + +static void SDL_DUMMY_SensorUpdate(SDL_Sensor *sensor) { } -static void -SDL_DUMMY_SensorClose(SDL_Sensor *sensor) +static void SDL_DUMMY_SensorClose(SDL_Sensor *sensor) { } -static void -SDL_DUMMY_SensorQuit(void) +static void SDL_DUMMY_SensorQuit(void) { } -SDL_SensorDriver SDL_DUMMY_SensorDriver = -{ +SDL_SensorDriver SDL_DUMMY_SensorDriver = { SDL_DUMMY_SensorInit, SDL_DUMMY_SensorGetCount, SDL_DUMMY_SensorDetect, diff --git a/src/sensor/n3ds/SDL_n3dssensor.c b/src/sensor/n3ds/SDL_n3dssensor.c index ea22ef247..775327908 100644 --- a/src/sensor/n3ds/SDL_n3dssensor.c +++ b/src/sensor/n3ds/SDL_n3dssensor.c @@ -48,8 +48,7 @@ IsDeviceIndexValid(int device_index) return device_index >= 0 && device_index < N3DS_SENSOR_COUNT; } -static int -N3DS_SensorInit(void) +static int N3DS_SensorInit(void) { if (InitN3DSServices() < 0) { return SDL_SetError("Failed to initialise N3DS services"); @@ -79,19 +78,16 @@ InitN3DSServices(void) return 0; } -static int -N3DS_SensorGetCount(void) +static int N3DS_SensorGetCount(void) { return N3DS_SENSOR_COUNT; } -static void -N3DS_SensorDetect(void) +static void N3DS_SensorDetect(void) { } -static const char * -N3DS_SensorGetDeviceName(int device_index) +static const char *N3DS_SensorGetDeviceName(int device_index) { if (IsDeviceIndexValid(device_index)) { switch (N3DS_sensors[device_index].type) { @@ -107,8 +103,7 @@ N3DS_SensorGetDeviceName(int device_index) return NULL; } -static SDL_SensorType -N3DS_SensorGetDeviceType(int device_index) +static SDL_SensorType N3DS_SensorGetDeviceType(int device_index) { if (IsDeviceIndexValid(device_index)) { return N3DS_sensors[device_index].type; @@ -116,14 +111,12 @@ N3DS_SensorGetDeviceType(int device_index) return SDL_SENSOR_INVALID; } -static int -N3DS_SensorGetDeviceNonPortableType(int device_index) +static int N3DS_SensorGetDeviceNonPortableType(int device_index) { - return (int) N3DS_SensorGetDeviceType(device_index); + return (int)N3DS_SensorGetDeviceType(device_index); } -static SDL_SensorID -N3DS_SensorGetDeviceInstanceID(int device_index) +static SDL_SensorID N3DS_SensorGetDeviceInstanceID(int device_index) { if (IsDeviceIndexValid(device_index)) { return N3DS_sensors[device_index].instance_id; @@ -131,14 +124,12 @@ N3DS_SensorGetDeviceInstanceID(int device_index) return -1; } -static int -N3DS_SensorOpen(SDL_Sensor *sensor, int device_index) +static int N3DS_SensorOpen(SDL_Sensor *sensor, int device_index) { return 0; } -static void -N3DS_SensorUpdate(SDL_Sensor *sensor) +static void N3DS_SensorUpdate(SDL_Sensor *sensor) { switch (sensor->type) { case SDL_SENSOR_ACCEL: @@ -162,9 +153,9 @@ UpdateN3DSAccelerometer(SDL_Sensor *sensor) hidAccelRead(¤t_state); if (SDL_memcmp(&previous_state, ¤t_state, sizeof(accelVector)) != 0) { SDL_memcpy(&previous_state, ¤t_state, sizeof(accelVector)); - data[0] = (float) current_state.x * SDL_STANDARD_GRAVITY; - data[1] = (float) current_state.y * SDL_STANDARD_GRAVITY; - data[2] = (float) current_state.z * SDL_STANDARD_GRAVITY; + data[0] = (float)current_state.x * SDL_STANDARD_GRAVITY; + data[1] = (float)current_state.y * SDL_STANDARD_GRAVITY; + data[2] = (float)current_state.z * SDL_STANDARD_GRAVITY; SDL_PrivateSensorUpdate(sensor, 0, data, sizeof data); } } @@ -179,20 +170,18 @@ UpdateN3DSGyroscope(SDL_Sensor *sensor) hidGyroRead(¤t_state); if (SDL_memcmp(&previous_state, ¤t_state, sizeof(angularRate)) != 0) { SDL_memcpy(&previous_state, ¤t_state, sizeof(angularRate)); - data[0] = (float) current_state.x; - data[1] = (float) current_state.y; - data[2] = (float) current_state.z; + data[0] = (float)current_state.x; + data[1] = (float)current_state.y; + data[2] = (float)current_state.z; SDL_PrivateSensorUpdate(sensor, 0, data, sizeof data); } } -static void -N3DS_SensorClose(SDL_Sensor *sensor) +static void N3DS_SensorClose(SDL_Sensor *sensor) { } -static void -N3DS_SensorQuit(void) +static void N3DS_SensorQuit(void) { HIDUSER_DisableGyroscope(); HIDUSER_DisableAccelerometer(); diff --git a/src/sensor/vita/SDL_vitasensor.c b/src/sensor/vita/SDL_vitasensor.c index c1f28b4a7..a21d9d732 100644 --- a/src/sensor/vita/SDL_vitasensor.c +++ b/src/sensor/vita/SDL_vitasensor.c @@ -42,8 +42,7 @@ typedef struct static SDL_VitaSensor *SDL_sensors; static int SDL_sensors_count; -static int -SDL_VITA_SensorInit(void) +static int SDL_VITA_SensorInit(void) { sceMotionReset(); sceMotionStartSampling(); @@ -67,36 +66,32 @@ SDL_VITA_SensorInit(void) return 0; } -static int -SDL_VITA_SensorGetCount(void) +static int SDL_VITA_SensorGetCount(void) { return SDL_sensors_count; } -static void -SDL_VITA_SensorDetect(void) +static void SDL_VITA_SensorDetect(void) { } -static const char * -SDL_VITA_SensorGetDeviceName(int device_index) +static const char *SDL_VITA_SensorGetDeviceName(int device_index) { if (device_index < SDL_sensors_count) { switch (SDL_sensors[device_index].type) { - case SDL_SENSOR_ACCEL: - return "Accelerometer"; - case SDL_SENSOR_GYRO: - return "Gyro"; - default: - return "Unknown"; + case SDL_SENSOR_ACCEL: + return "Accelerometer"; + case SDL_SENSOR_GYRO: + return "Gyro"; + default: + return "Unknown"; } } return NULL; } -static SDL_SensorType -SDL_VITA_SensorGetDeviceType(int device_index) +static SDL_SensorType SDL_VITA_SensorGetDeviceType(int device_index) { if (device_index < SDL_sensors_count) { return SDL_sensors[device_index].type; @@ -105,8 +100,7 @@ SDL_VITA_SensorGetDeviceType(int device_index) return SDL_SENSOR_INVALID; } -static int -SDL_VITA_SensorGetDeviceNonPortableType(int device_index) +static int SDL_VITA_SensorGetDeviceNonPortableType(int device_index) { if (device_index < SDL_sensors_count) { return SDL_sensors[device_index].type; @@ -114,8 +108,7 @@ SDL_VITA_SensorGetDeviceNonPortableType(int device_index) return -1; } -static SDL_SensorID -SDL_VITA_SensorGetDeviceInstanceID(int device_index) +static SDL_SensorID SDL_VITA_SensorGetDeviceInstanceID(int device_index) { if (device_index < SDL_sensors_count) { return SDL_sensors[device_index].instance_id; @@ -123,8 +116,7 @@ SDL_VITA_SensorGetDeviceInstanceID(int device_index) return -1; } -static int -SDL_VITA_SensorOpen(SDL_Sensor *sensor, int device_index) +static int SDL_VITA_SensorOpen(SDL_Sensor *sensor, int device_index) { struct sensor_hwdata *hwdata; @@ -137,8 +129,7 @@ SDL_VITA_SensorOpen(SDL_Sensor *sensor, int device_index) return 0; } -static void -SDL_VITA_SensorUpdate(SDL_Sensor *sensor) +static void SDL_VITA_SensorUpdate(SDL_Sensor *sensor) { int err = 0; SceMotionSensorState motionState[SCE_MOTION_MAX_NUM_STATES]; @@ -169,46 +160,40 @@ SDL_VITA_SensorUpdate(SDL_Sensor *sensor) } sensor->hwdata->last_timestamp = timestamp; - switch (sensor->type) + switch (sensor->type) { + case SDL_SENSOR_ACCEL: { - case SDL_SENSOR_ACCEL: - { - float data[3]; - data[0] = motionState[i].accelerometer.x * SDL_STANDARD_GRAVITY; - data[1] = motionState[i].accelerometer.y * SDL_STANDARD_GRAVITY; - data[2] = motionState[i].accelerometer.z * SDL_STANDARD_GRAVITY; - SDL_PrivateSensorUpdate(sensor, sensor->hwdata->timestamp_us, data, SDL_arraysize(data)); - } - break; - case SDL_SENSOR_GYRO: - { - float data[3]; - data[0] = motionState[i].gyro.x; - data[1] = motionState[i].gyro.y; - data[2] = motionState[i].gyro.z; - SDL_PrivateSensorUpdate(sensor, sensor->hwdata->timestamp_us, data, SDL_arraysize(data)); - } - break; - default: + float data[3]; + data[0] = motionState[i].accelerometer.x * SDL_STANDARD_GRAVITY; + data[1] = motionState[i].accelerometer.y * SDL_STANDARD_GRAVITY; + data[2] = motionState[i].accelerometer.z * SDL_STANDARD_GRAVITY; + SDL_PrivateSensorUpdate(sensor, sensor->hwdata->timestamp_us, data, SDL_arraysize(data)); + } break; + case SDL_SENSOR_GYRO: + { + float data[3]; + data[0] = motionState[i].gyro.x; + data[1] = motionState[i].gyro.y; + data[2] = motionState[i].gyro.z; + SDL_PrivateSensorUpdate(sensor, sensor->hwdata->timestamp_us, data, SDL_arraysize(data)); + } break; + default: break; } } } } -static void -SDL_VITA_SensorClose(SDL_Sensor *sensor) +static void SDL_VITA_SensorClose(SDL_Sensor *sensor) { } -static void -SDL_VITA_SensorQuit(void) +static void SDL_VITA_SensorQuit(void) { sceMotionStopSampling(); } -SDL_SensorDriver SDL_VITA_SensorDriver = -{ +SDL_SensorDriver SDL_VITA_SensorDriver = { SDL_VITA_SensorInit, SDL_VITA_SensorGetCount, SDL_VITA_SensorDetect, diff --git a/src/sensor/windows/SDL_windowssensor.c b/src/sensor/windows/SDL_windowssensor.c index 2a974b0df..35e910bc0 100644 --- a/src/sensor/windows/SDL_windowssensor.c +++ b/src/sensor/windows/SDL_windowssensor.c @@ -65,7 +65,7 @@ static SDL_Windows_Sensor *SDL_sensors; static int ConnectSensor(ISensor *sensor); static int DisconnectSensor(ISensor *sensor); -static HRESULT STDMETHODCALLTYPE ISensorManagerEventsVtbl_QueryInterface(ISensorManagerEvents * This, REFIID riid, void **ppvObject) +static HRESULT STDMETHODCALLTYPE ISensorManagerEventsVtbl_QueryInterface(ISensorManagerEvents *This, REFIID riid, void **ppvObject) { if (ppvObject == NULL) { return E_INVALIDARG; @@ -79,17 +79,17 @@ static HRESULT STDMETHODCALLTYPE ISensorManagerEventsVtbl_QueryInterface(ISensor return E_NOINTERFACE; } -static ULONG STDMETHODCALLTYPE ISensorManagerEventsVtbl_AddRef(ISensorManagerEvents * This) +static ULONG STDMETHODCALLTYPE ISensorManagerEventsVtbl_AddRef(ISensorManagerEvents *This) { return 1; } -static ULONG STDMETHODCALLTYPE ISensorManagerEventsVtbl_Release(ISensorManagerEvents * This) +static ULONG STDMETHODCALLTYPE ISensorManagerEventsVtbl_Release(ISensorManagerEvents *This) { return 1; } -static HRESULT STDMETHODCALLTYPE ISensorManagerEventsVtbl_OnSensorEnter(ISensorManagerEvents * This, ISensor *pSensor, SensorState state) +static HRESULT STDMETHODCALLTYPE ISensorManagerEventsVtbl_OnSensorEnter(ISensorManagerEvents *This, ISensor *pSensor, SensorState state) { ConnectSensor(pSensor); return S_OK; @@ -105,7 +105,7 @@ static ISensorManagerEvents sensor_manager_events = { &sensor_manager_events_vtbl }; -static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_QueryInterface(ISensorEvents * This, REFIID riid, void **ppvObject) +static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_QueryInterface(ISensorEvents *This, REFIID riid, void **ppvObject) { if (ppvObject == NULL) { return E_INVALIDARG; @@ -119,17 +119,17 @@ static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_QueryInterface(ISensorEvents return E_NOINTERFACE; } -static ULONG STDMETHODCALLTYPE ISensorEventsVtbl_AddRef(ISensorEvents * This) +static ULONG STDMETHODCALLTYPE ISensorEventsVtbl_AddRef(ISensorEvents *This) { return 1; } -static ULONG STDMETHODCALLTYPE ISensorEventsVtbl_Release(ISensorEvents * This) +static ULONG STDMETHODCALLTYPE ISensorEventsVtbl_Release(ISensorEvents *This) { return 1; } -static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_OnStateChanged(ISensorEvents * This, ISensor *pSensor, SensorState state) +static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_OnStateChanged(ISensorEvents *This, ISensor *pSensor, SensorState state) { #ifdef DEBUG_SENSORS int i; @@ -145,7 +145,7 @@ static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_OnStateChanged(ISensorEvents return S_OK; } -static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_OnDataUpdated(ISensorEvents * This, ISensor *pSensor, ISensorDataReport *pNewData) +static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_OnDataUpdated(ISensorEvents *This, ISensor *pSensor, ISensorDataReport *pNewData) { int i; @@ -202,7 +202,7 @@ static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_OnDataUpdated(ISensorEvents * return S_OK; } -static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_OnEvent(ISensorEvents * This, ISensor *pSensor, REFGUID eventID, IPortableDeviceValues *pEventData) +static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_OnEvent(ISensorEvents *This, ISensor *pSensor, REFGUID eventID, IPortableDeviceValues *pEventData) { #ifdef DEBUG_SENSORS int i; @@ -218,7 +218,7 @@ static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_OnEvent(ISensorEvents * This, return S_OK; } -static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_OnLeave(ISensorEvents * This, REFSENSOR_ID ID) +static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_OnLeave(ISensorEvents *This, REFSENSOR_ID ID) { int i; @@ -343,8 +343,7 @@ static int DisconnectSensor(ISensor *sensor) return 0; } -static int -SDL_WINDOWS_SensorInit(void) +static int SDL_WINDOWS_SensorInit(void) { HRESULT hr; ISensorCollection *sensor_collection = NULL; @@ -353,7 +352,7 @@ SDL_WINDOWS_SensorInit(void) SDL_windowscoinit = SDL_TRUE; } - hr = CoCreateInstance(&SDL_CLSID_SensorManager, NULL, CLSCTX_INPROC_SERVER, &SDL_IID_SensorManager, (LPVOID *) &SDL_sensor_manager); + hr = CoCreateInstance(&SDL_CLSID_SensorManager, NULL, CLSCTX_INPROC_SERVER, &SDL_IID_SensorManager, (LPVOID *)&SDL_sensor_manager); if (FAILED(hr)) { /* If we can't create a sensor manager (i.e. on Wine), we won't have any sensors, but don't fail the init */ return 0; /* WIN_SetErrorFromHRESULT("Couldn't create the sensor manager", hr); */ @@ -392,55 +391,46 @@ SDL_WINDOWS_SensorInit(void) return 0; } -static int -SDL_WINDOWS_SensorGetCount(void) +static int SDL_WINDOWS_SensorGetCount(void) { return SDL_num_sensors; } -static void -SDL_WINDOWS_SensorDetect(void) +static void SDL_WINDOWS_SensorDetect(void) { } -static const char * -SDL_WINDOWS_SensorGetDeviceName(int device_index) +static const char *SDL_WINDOWS_SensorGetDeviceName(int device_index) { return SDL_sensors[device_index].name; } -static SDL_SensorType -SDL_WINDOWS_SensorGetDeviceType(int device_index) +static SDL_SensorType SDL_WINDOWS_SensorGetDeviceType(int device_index) { return SDL_sensors[device_index].type; } -static int -SDL_WINDOWS_SensorGetDeviceNonPortableType(int device_index) +static int SDL_WINDOWS_SensorGetDeviceNonPortableType(int device_index) { return -1; } -static SDL_SensorID -SDL_WINDOWS_SensorGetDeviceInstanceID(int device_index) +static SDL_SensorID SDL_WINDOWS_SensorGetDeviceInstanceID(int device_index) { return SDL_sensors[device_index].id; } -static int -SDL_WINDOWS_SensorOpen(SDL_Sensor *sensor, int device_index) +static int SDL_WINDOWS_SensorOpen(SDL_Sensor *sensor, int device_index) { SDL_sensors[device_index].sensor_opened = sensor; return 0; } -static void -SDL_WINDOWS_SensorUpdate(SDL_Sensor *sensor) +static void SDL_WINDOWS_SensorUpdate(SDL_Sensor *sensor) { } -static void -SDL_WINDOWS_SensorClose(SDL_Sensor *sensor) +static void SDL_WINDOWS_SensorClose(SDL_Sensor *sensor) { int i; @@ -452,8 +442,7 @@ SDL_WINDOWS_SensorClose(SDL_Sensor *sensor) } } -static void -SDL_WINDOWS_SensorQuit(void) +static void SDL_WINDOWS_SensorQuit(void) { while (SDL_num_sensors > 0) { DisconnectSensor(SDL_sensors[0].sensor); @@ -470,8 +459,7 @@ SDL_WINDOWS_SensorQuit(void) } } -SDL_SensorDriver SDL_WINDOWS_SensorDriver = -{ +SDL_SensorDriver SDL_WINDOWS_SensorDriver = { SDL_WINDOWS_SensorInit, SDL_WINDOWS_SensorGetCount, SDL_WINDOWS_SensorDetect, diff --git a/src/stdlib/SDL_crc16.c b/src/stdlib/SDL_crc16.c index c73dad653..cc61e8b2c 100644 --- a/src/stdlib/SDL_crc16.c +++ b/src/stdlib/SDL_crc16.c @@ -38,7 +38,7 @@ static Uint16 crc16_for_byte(Uint8 r) Uint16 crc = 0; int i; for (i = 0; i < 8; ++i) { - crc = ((crc ^ r) & 1? 0xA001 : 0) ^ crc >> 1; + crc = ((crc ^ r) & 1 ? 0xA001 : 0) ^ crc >> 1; r >>= 1; } return crc; @@ -49,7 +49,7 @@ Uint16 SDL_crc16(Uint16 crc, const void *data, size_t len) /* As an optimization we can precalculate a 256 entry table for each byte */ size_t i; for (i = 0; i < len; ++i) { - crc = crc16_for_byte((Uint8)crc ^ ((const Uint8*)data)[i]) ^ crc >> 8; + crc = crc16_for_byte((Uint8)crc ^ ((const Uint8 *)data)[i]) ^ crc >> 8; } return crc; } diff --git a/src/stdlib/SDL_crc32.c b/src/stdlib/SDL_crc32.c index be2144a7d..f8e08924c 100644 --- a/src/stdlib/SDL_crc32.c +++ b/src/stdlib/SDL_crc32.c @@ -37,7 +37,7 @@ static Uint32 crc32_for_byte(Uint32 r) { int i; for (i = 0; i < 8; ++i) { - r = (r & 1? 0: (Uint32)0xEDB88320L) ^ r >> 1; + r = (r & 1 ? 0 : (Uint32)0xEDB88320L) ^ r >> 1; } return r ^ (Uint32)0xFF000000L; } @@ -47,7 +47,7 @@ Uint32 SDL_crc32(Uint32 crc, const void *data, size_t len) /* As an optimization we can precalculate a 256 entry table for each byte */ size_t i; for (i = 0; i < len; ++i) { - crc = crc32_for_byte((Uint8)crc ^ ((const Uint8*)data)[i]) ^ crc >> 8; + crc = crc32_for_byte((Uint8)crc ^ ((const Uint8 *)data)[i]) ^ crc >> 8; } return crc; } diff --git a/src/stdlib/SDL_getenv.c b/src/stdlib/SDL_getenv.c index 737eb9bca..fe7197f51 100644 --- a/src/stdlib/SDL_getenv.c +++ b/src/stdlib/SDL_getenv.c @@ -44,28 +44,26 @@ static size_t SDL_envmemlen = 0; /* Put a variable into the environment */ /* Note: Name may not contain a '=' character. (Reference: http://www.unix.com/man-page/Linux/3/setenv/) */ #if defined(HAVE_SETENV) -int -SDL_setenv(const char *name, const char *value, int overwrite) +int SDL_setenv(const char *name, const char *value, int overwrite) { /* Input validation */ if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) { return -1; } - + return setenv(name, value, overwrite); } #elif defined(__WIN32__) || defined(__WINGDK__) -int -SDL_setenv(const char *name, const char *value, int overwrite) +int SDL_setenv(const char *name, const char *value, int overwrite) { /* Input validation */ if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) { return -1; } - + if (!overwrite) { if (GetEnvironmentVariableA(name, NULL, 0) > 0) { - return 0; /* asked not to overwrite existing value. */ + return 0; /* asked not to overwrite existing value. */ } } if (!SetEnvironmentVariableA(name, *value ? value : NULL)) { @@ -75,8 +73,7 @@ SDL_setenv(const char *name, const char *value, int overwrite) } /* We have a real environment table, but no real setenv? Fake it w/ putenv. */ #elif (defined(HAVE_GETENV) && defined(HAVE_PUTENV) && !defined(HAVE_SETENV)) -int -SDL_setenv(const char *name, const char *value, int overwrite) +int SDL_setenv(const char *name, const char *value, int overwrite) { size_t len; char *new_variable; @@ -85,18 +82,18 @@ SDL_setenv(const char *name, const char *value, int overwrite) if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) { return -1; } - + if (getenv(name) != NULL) { if (overwrite) { unsetenv(name); } else { - return 0; /* leave the existing one there. */ + return 0; /* leave the existing one there. */ } } /* This leaks. Sorry. Get a better OS so we don't have to do this. */ len = SDL_strlen(name) + SDL_strlen(value) + 2; - new_variable = (char *) SDL_malloc(len); + new_variable = (char *)SDL_malloc(len); if (new_variable == NULL) { return -1; } @@ -105,9 +102,8 @@ SDL_setenv(const char *name, const char *value, int overwrite) return putenv(new_variable); } #else /* roll our own */ -static char **SDL_env = (char **) 0; -int -SDL_setenv(const char *name, const char *value, int overwrite) +static char **SDL_env = (char **)0; +int SDL_setenv(const char *name, const char *value, int overwrite) { int added; size_t len, i; @@ -126,7 +122,7 @@ SDL_setenv(const char *name, const char *value, int overwrite) /* Allocate memory for the variable */ len = SDL_strlen(name) + SDL_strlen(value) + 2; - new_variable = (char *) SDL_malloc(len); + new_variable = (char *)SDL_malloc(len); if (new_variable == NULL) { return -1; } @@ -160,7 +156,7 @@ SDL_setenv(const char *name, const char *value, int overwrite) if (new_env) { SDL_env = new_env; SDL_env[i++] = new_variable; - SDL_env[i++] = (char *) 0; + SDL_env[i++] = (char *)0; added = 1; } else { SDL_free(new_variable); @@ -197,20 +193,20 @@ SDL_getenv(const char *name) if (name == NULL || *name == '\0') { return NULL; } - + bufferlen = - GetEnvironmentVariableA(name, SDL_envmem, (DWORD) SDL_envmemlen); + GetEnvironmentVariableA(name, SDL_envmem, (DWORD)SDL_envmemlen); if (bufferlen == 0) { return NULL; } if (bufferlen > SDL_envmemlen) { - char *newmem = (char *) SDL_realloc(SDL_envmem, bufferlen); + char *newmem = (char *)SDL_realloc(SDL_envmem, bufferlen); if (newmem == NULL) { return NULL; } SDL_envmem = newmem; SDL_envmemlen = bufferlen; - GetEnvironmentVariableA(name, SDL_envmem, (DWORD) SDL_envmemlen); + GetEnvironmentVariableA(name, SDL_envmem, (DWORD)SDL_envmemlen); } return SDL_envmem; } @@ -225,8 +221,8 @@ SDL_getenv(const char *name) if (name == NULL || *name == '\0') { return NULL; } - - value = (char *) 0; + + value = (char *)0; if (SDL_env) { len = SDL_strlen(name); for (i = 0; SDL_env[i] && value == NULL; ++i) { @@ -240,12 +236,10 @@ SDL_getenv(const char *name) } #endif - #ifdef TEST_MAIN #include -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { char *value; diff --git a/src/stdlib/SDL_iconv.c b/src/stdlib/SDL_iconv.c index cb30ba705..5b8728bf4 100644 --- a/src/stdlib/SDL_iconv.c +++ b/src/stdlib/SDL_iconv.c @@ -38,29 +38,28 @@ #include #include -SDL_COMPILE_TIME_ASSERT(iconv_t, sizeof (iconv_t) <= sizeof (SDL_iconv_t)); +SDL_COMPILE_TIME_ASSERT(iconv_t, sizeof(iconv_t) <= sizeof(SDL_iconv_t)); SDL_iconv_t SDL_iconv_open(const char *tocode, const char *fromcode) { - return (SDL_iconv_t) ((uintptr_t) iconv_open(tocode, fromcode)); + return (SDL_iconv_t)((uintptr_t)iconv_open(tocode, fromcode)); } -int -SDL_iconv_close(SDL_iconv_t cd) +int SDL_iconv_close(SDL_iconv_t cd) { - return iconv_close((iconv_t) ((uintptr_t) cd)); + return iconv_close((iconv_t)((uintptr_t)cd)); } size_t SDL_iconv(SDL_iconv_t cd, - const char **inbuf, size_t * inbytesleft, - char **outbuf, size_t * outbytesleft) + const char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft) { /* iconv's second parameter may or may not be `const char const *` depending on the C runtime's whims. Casting to void * seems to make everyone happy, though. */ - const size_t retCode = iconv((iconv_t) ((uintptr_t) cd), (void *) inbuf, inbytesleft, outbuf, outbytesleft); - if (retCode == (size_t) - 1) { + const size_t retCode = iconv((iconv_t)((uintptr_t)cd), (void *)inbuf, inbytesleft, outbuf, outbytesleft); + if (retCode == (size_t)-1) { switch (errno) { case E2BIG: return SDL_ICONV_E2BIG; @@ -81,10 +80,10 @@ SDL_iconv(SDL_iconv_t cd, http://www.cl.cam.ac.uk/~mgk25/unicode.html */ -#define UNICODE_BOM 0xFEFF +#define UNICODE_BOM 0xFEFF -#define UNKNOWN_ASCII '?' -#define UNKNOWN_UNICODE 0xFFFD +#define UNKNOWN_ASCII '?' +#define UNKNOWN_UNICODE 0xFFFD enum { @@ -92,10 +91,10 @@ enum ENCODING_ASCII, ENCODING_LATIN1, ENCODING_UTF8, - ENCODING_UTF16, /* Needs byte order marker */ + ENCODING_UTF16, /* Needs byte order marker */ ENCODING_UTF16BE, ENCODING_UTF16LE, - ENCODING_UTF32, /* Needs byte order marker */ + ENCODING_UTF32, /* Needs byte order marker */ ENCODING_UTF32BE, ENCODING_UTF32LE, ENCODING_UCS2BE, @@ -104,15 +103,15 @@ enum ENCODING_UCS4LE, }; #if SDL_BYTEORDER == SDL_BIG_ENDIAN -#define ENCODING_UTF16NATIVE ENCODING_UTF16BE -#define ENCODING_UTF32NATIVE ENCODING_UTF32BE -#define ENCODING_UCS2NATIVE ENCODING_UCS2BE -#define ENCODING_UCS4NATIVE ENCODING_UCS4BE +#define ENCODING_UTF16NATIVE ENCODING_UTF16BE +#define ENCODING_UTF32NATIVE ENCODING_UTF32BE +#define ENCODING_UCS2NATIVE ENCODING_UCS2BE +#define ENCODING_UCS4NATIVE ENCODING_UCS4BE #else -#define ENCODING_UTF16NATIVE ENCODING_UTF16LE -#define ENCODING_UTF32NATIVE ENCODING_UTF32LE -#define ENCODING_UCS2NATIVE ENCODING_UCS2LE -#define ENCODING_UCS4NATIVE ENCODING_UCS4LE +#define ENCODING_UTF16NATIVE ENCODING_UTF16LE +#define ENCODING_UTF32NATIVE ENCODING_UTF32LE +#define ENCODING_UCS2NATIVE ENCODING_UCS2LE +#define ENCODING_UCS4NATIVE ENCODING_UCS4LE #endif struct _SDL_iconv_t @@ -126,7 +125,7 @@ static struct const char *name; int format; } encodings[] = { -/* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ /* clang-format off */ { "ASCII", ENCODING_ASCII }, { "US-ASCII", ENCODING_ASCII }, { "8859-1", ENCODING_LATIN1 }, @@ -163,8 +162,7 @@ static struct /* *INDENT-ON* */ /* clang-format on */ }; -static const char * -getlocale(char *buffer, size_t bufsize) +static const char *getlocale(char *buffer, size_t bufsize) { const char *lang; char *ptr; @@ -192,7 +190,7 @@ getlocale(char *buffer, size_t bufsize) SDL_strlcpy(buffer, lang, bufsize); ptr = SDL_strchr(buffer, '@'); if (ptr != NULL) { - *ptr = '\0'; /* chop end of string. */ + *ptr = '\0'; /* chop end of string. */ } return buffer; @@ -228,20 +226,20 @@ SDL_iconv_open(const char *tocode, const char *fromcode) } } if (src_fmt != ENCODING_UNKNOWN && dst_fmt != ENCODING_UNKNOWN) { - SDL_iconv_t cd = (SDL_iconv_t) SDL_malloc(sizeof(*cd)); + SDL_iconv_t cd = (SDL_iconv_t)SDL_malloc(sizeof(*cd)); if (cd) { cd->src_fmt = src_fmt; cd->dst_fmt = dst_fmt; return cd; } } - return (SDL_iconv_t) - 1; + return (SDL_iconv_t)-1; } size_t SDL_iconv(SDL_iconv_t cd, - const char **inbuf, size_t * inbytesleft, - char **outbuf, size_t * outbytesleft) + const char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft) { /* For simplicity, we'll convert everything to and from UCS-4 */ const char *src; @@ -266,7 +264,7 @@ SDL_iconv(SDL_iconv_t cd, case ENCODING_UTF16: /* Scan for a byte order marker */ { - Uint8 *p = (Uint8 *) src; + Uint8 *p = (Uint8 *)src; size_t n = srclen / 2; while (n) { if (p[0] == 0xFF && p[1] == 0xFE) { @@ -288,7 +286,7 @@ SDL_iconv(SDL_iconv_t cd, case ENCODING_UTF32: /* Scan for a byte order marker */ { - Uint8 *p = (Uint8 *) src; + Uint8 *p = (Uint8 *)src; size_t n = srclen / 4; while (n) { if (p[0] == 0xFF && p[1] == 0xFE && @@ -317,7 +315,7 @@ SDL_iconv(SDL_iconv_t cd, if (dstlen < 2) { return SDL_ICONV_E2BIG; } - *(Uint16 *) dst = UNICODE_BOM; + *(Uint16 *)dst = UNICODE_BOM; dst += 2; dstlen -= 2; cd->dst_fmt = ENCODING_UTF16NATIVE; @@ -327,7 +325,7 @@ SDL_iconv(SDL_iconv_t cd, if (dstlen < 4) { return SDL_ICONV_E2BIG; } - *(Uint32 *) dst = UNICODE_BOM; + *(Uint32 *)dst = UNICODE_BOM; dst += 4; dstlen -= 4; cd->dst_fmt = ENCODING_UTF32NATIVE; @@ -339,406 +337,392 @@ SDL_iconv(SDL_iconv_t cd, /* Decode a character */ switch (cd->src_fmt) { case ENCODING_ASCII: - { - Uint8 *p = (Uint8 *) src; - ch = (Uint32) (p[0] & 0x7F); - ++src; - --srclen; - } - break; + { + Uint8 *p = (Uint8 *)src; + ch = (Uint32)(p[0] & 0x7F); + ++src; + --srclen; + } break; case ENCODING_LATIN1: - { - Uint8 *p = (Uint8 *) src; - ch = (Uint32) p[0]; - ++src; - --srclen; - } - break; - case ENCODING_UTF8: /* RFC 3629 */ - { - Uint8 *p = (Uint8 *) src; - size_t left = 0; - SDL_bool overlong = SDL_FALSE; - if (p[0] >= 0xF0) { - if ((p[0] & 0xF8) != 0xF0) { - /* Skip illegal sequences - return SDL_ICONV_EILSEQ; - */ - ch = UNKNOWN_UNICODE; - } else { - if (p[0] == 0xF0 && srclen > 1 && (p[1] & 0xF0) == 0x80) { - overlong = SDL_TRUE; - } - ch = (Uint32) (p[0] & 0x07); - left = 3; - } - } else if (p[0] >= 0xE0) { - if ((p[0] & 0xF0) != 0xE0) { - /* Skip illegal sequences - return SDL_ICONV_EILSEQ; - */ - ch = UNKNOWN_UNICODE; - } else { - if (p[0] == 0xE0 && srclen > 1 && (p[1] & 0xE0) == 0x80) { - overlong = SDL_TRUE; - } - ch = (Uint32) (p[0] & 0x0F); - left = 2; - } - } else if (p[0] >= 0xC0) { - if ((p[0] & 0xE0) != 0xC0) { - /* Skip illegal sequences - return SDL_ICONV_EILSEQ; - */ - ch = UNKNOWN_UNICODE; - } else { - if ((p[0] & 0xDE) == 0xC0) { - overlong = SDL_TRUE; - } - ch = (Uint32) (p[0] & 0x1F); - left = 1; - } + { + Uint8 *p = (Uint8 *)src; + ch = (Uint32)p[0]; + ++src; + --srclen; + } break; + case ENCODING_UTF8: /* RFC 3629 */ + { + Uint8 *p = (Uint8 *)src; + size_t left = 0; + SDL_bool overlong = SDL_FALSE; + if (p[0] >= 0xF0) { + if ((p[0] & 0xF8) != 0xF0) { + /* Skip illegal sequences + return SDL_ICONV_EILSEQ; + */ + ch = UNKNOWN_UNICODE; } else { - if ((p[0] & 0x80) != 0x00) { - /* Skip illegal sequences - return SDL_ICONV_EILSEQ; - */ - ch = UNKNOWN_UNICODE; - } else { - ch = (Uint32) p[0]; + if (p[0] == 0xF0 && srclen > 1 && (p[1] & 0xF0) == 0x80) { + overlong = SDL_TRUE; } + ch = (Uint32)(p[0] & 0x07); + left = 3; } + } else if (p[0] >= 0xE0) { + if ((p[0] & 0xF0) != 0xE0) { + /* Skip illegal sequences + return SDL_ICONV_EILSEQ; + */ + ch = UNKNOWN_UNICODE; + } else { + if (p[0] == 0xE0 && srclen > 1 && (p[1] & 0xE0) == 0x80) { + overlong = SDL_TRUE; + } + ch = (Uint32)(p[0] & 0x0F); + left = 2; + } + } else if (p[0] >= 0xC0) { + if ((p[0] & 0xE0) != 0xC0) { + /* Skip illegal sequences + return SDL_ICONV_EILSEQ; + */ + ch = UNKNOWN_UNICODE; + } else { + if ((p[0] & 0xDE) == 0xC0) { + overlong = SDL_TRUE; + } + ch = (Uint32)(p[0] & 0x1F); + left = 1; + } + } else { + if ((p[0] & 0x80) != 0x00) { + /* Skip illegal sequences + return SDL_ICONV_EILSEQ; + */ + ch = UNKNOWN_UNICODE; + } else { + ch = (Uint32)p[0]; + } + } + ++src; + --srclen; + if (srclen < left) { + return SDL_ICONV_EINVAL; + } + while (left--) { + ++p; + if ((p[0] & 0xC0) != 0x80) { + /* Skip illegal sequences + return SDL_ICONV_EILSEQ; + */ + ch = UNKNOWN_UNICODE; + break; + } + ch <<= 6; + ch |= (p[0] & 0x3F); ++src; --srclen; - if (srclen < left) { - return SDL_ICONV_EINVAL; - } - while (left--) { - ++p; - if ((p[0] & 0xC0) != 0x80) { - /* Skip illegal sequences - return SDL_ICONV_EILSEQ; - */ - ch = UNKNOWN_UNICODE; - break; - } - ch <<= 6; - ch |= (p[0] & 0x3F); - ++src; - --srclen; - } - if (overlong) { - /* Potential security risk - return SDL_ICONV_EILSEQ; - */ - ch = UNKNOWN_UNICODE; - } - if ((ch >= 0xD800 && ch <= 0xDFFF) || - (ch == 0xFFFE || ch == 0xFFFF) || ch > 0x10FFFF) { - /* Skip illegal sequences - return SDL_ICONV_EILSEQ; - */ - ch = UNKNOWN_UNICODE; - } } - break; + if (overlong) { + /* Potential security risk + return SDL_ICONV_EILSEQ; + */ + ch = UNKNOWN_UNICODE; + } + if ((ch >= 0xD800 && ch <= 0xDFFF) || + (ch == 0xFFFE || ch == 0xFFFF) || ch > 0x10FFFF) { + /* Skip illegal sequences + return SDL_ICONV_EILSEQ; + */ + ch = UNKNOWN_UNICODE; + } + } break; case ENCODING_UTF16BE: /* RFC 2781 */ - { - Uint8 *p = (Uint8 *) src; - Uint16 W1, W2; - if (srclen < 2) { - return SDL_ICONV_EINVAL; - } - W1 = ((Uint16) p[0] << 8) | (Uint16) p[1]; - src += 2; - srclen -= 2; - if (W1 < 0xD800 || W1 > 0xDFFF) { - ch = (Uint32) W1; - break; - } - if (W1 > 0xDBFF) { - /* Skip illegal sequences - return SDL_ICONV_EILSEQ; - */ - ch = UNKNOWN_UNICODE; - break; - } - if (srclen < 2) { - return SDL_ICONV_EINVAL; - } - p = (Uint8 *) src; - W2 = ((Uint16) p[0] << 8) | (Uint16) p[1]; - src += 2; - srclen -= 2; - if (W2 < 0xDC00 || W2 > 0xDFFF) { - /* Skip illegal sequences - return SDL_ICONV_EILSEQ; - */ - ch = UNKNOWN_UNICODE; - break; - } - ch = (((Uint32) (W1 & 0x3FF) << 10) | - (Uint32) (W2 & 0x3FF)) + 0x10000; + { + Uint8 *p = (Uint8 *)src; + Uint16 W1, W2; + if (srclen < 2) { + return SDL_ICONV_EINVAL; } - break; + W1 = ((Uint16)p[0] << 8) | (Uint16)p[1]; + src += 2; + srclen -= 2; + if (W1 < 0xD800 || W1 > 0xDFFF) { + ch = (Uint32)W1; + break; + } + if (W1 > 0xDBFF) { + /* Skip illegal sequences + return SDL_ICONV_EILSEQ; + */ + ch = UNKNOWN_UNICODE; + break; + } + if (srclen < 2) { + return SDL_ICONV_EINVAL; + } + p = (Uint8 *)src; + W2 = ((Uint16)p[0] << 8) | (Uint16)p[1]; + src += 2; + srclen -= 2; + if (W2 < 0xDC00 || W2 > 0xDFFF) { + /* Skip illegal sequences + return SDL_ICONV_EILSEQ; + */ + ch = UNKNOWN_UNICODE; + break; + } + ch = (((Uint32)(W1 & 0x3FF) << 10) | + (Uint32)(W2 & 0x3FF)) + + 0x10000; + } break; case ENCODING_UTF16LE: /* RFC 2781 */ - { - Uint8 *p = (Uint8 *) src; - Uint16 W1, W2; - if (srclen < 2) { - return SDL_ICONV_EINVAL; - } - W1 = ((Uint16) p[1] << 8) | (Uint16) p[0]; - src += 2; - srclen -= 2; - if (W1 < 0xD800 || W1 > 0xDFFF) { - ch = (Uint32) W1; - break; - } - if (W1 > 0xDBFF) { - /* Skip illegal sequences - return SDL_ICONV_EILSEQ; - */ - ch = UNKNOWN_UNICODE; - break; - } - if (srclen < 2) { - return SDL_ICONV_EINVAL; - } - p = (Uint8 *) src; - W2 = ((Uint16) p[1] << 8) | (Uint16) p[0]; - src += 2; - srclen -= 2; - if (W2 < 0xDC00 || W2 > 0xDFFF) { - /* Skip illegal sequences - return SDL_ICONV_EILSEQ; - */ - ch = UNKNOWN_UNICODE; - break; - } - ch = (((Uint32) (W1 & 0x3FF) << 10) | - (Uint32) (W2 & 0x3FF)) + 0x10000; + { + Uint8 *p = (Uint8 *)src; + Uint16 W1, W2; + if (srclen < 2) { + return SDL_ICONV_EINVAL; } - break; + W1 = ((Uint16)p[1] << 8) | (Uint16)p[0]; + src += 2; + srclen -= 2; + if (W1 < 0xD800 || W1 > 0xDFFF) { + ch = (Uint32)W1; + break; + } + if (W1 > 0xDBFF) { + /* Skip illegal sequences + return SDL_ICONV_EILSEQ; + */ + ch = UNKNOWN_UNICODE; + break; + } + if (srclen < 2) { + return SDL_ICONV_EINVAL; + } + p = (Uint8 *)src; + W2 = ((Uint16)p[1] << 8) | (Uint16)p[0]; + src += 2; + srclen -= 2; + if (W2 < 0xDC00 || W2 > 0xDFFF) { + /* Skip illegal sequences + return SDL_ICONV_EILSEQ; + */ + ch = UNKNOWN_UNICODE; + break; + } + ch = (((Uint32)(W1 & 0x3FF) << 10) | + (Uint32)(W2 & 0x3FF)) + + 0x10000; + } break; case ENCODING_UCS2LE: - { - Uint8 *p = (Uint8 *) src; - if (srclen < 2) { - return SDL_ICONV_EINVAL; - } - ch = ((Uint32) p[1] << 8) | (Uint32) p[0]; - src += 2; - srclen -= 2; + { + Uint8 *p = (Uint8 *)src; + if (srclen < 2) { + return SDL_ICONV_EINVAL; } - break; + ch = ((Uint32)p[1] << 8) | (Uint32)p[0]; + src += 2; + srclen -= 2; + } break; case ENCODING_UCS2BE: - { - Uint8 *p = (Uint8 *) src; - if (srclen < 2) { - return SDL_ICONV_EINVAL; - } - ch = ((Uint32) p[0] << 8) | (Uint32) p[1]; - src += 2; - srclen -= 2; + { + Uint8 *p = (Uint8 *)src; + if (srclen < 2) { + return SDL_ICONV_EINVAL; } - break; + ch = ((Uint32)p[0] << 8) | (Uint32)p[1]; + src += 2; + srclen -= 2; + } break; case ENCODING_UCS4BE: case ENCODING_UTF32BE: - { - Uint8 *p = (Uint8 *) src; - if (srclen < 4) { - return SDL_ICONV_EINVAL; - } - ch = ((Uint32) p[0] << 24) | - ((Uint32) p[1] << 16) | - ((Uint32) p[2] << 8) | (Uint32) p[3]; - src += 4; - srclen -= 4; + { + Uint8 *p = (Uint8 *)src; + if (srclen < 4) { + return SDL_ICONV_EINVAL; } - break; + ch = ((Uint32)p[0] << 24) | + ((Uint32)p[1] << 16) | + ((Uint32)p[2] << 8) | (Uint32)p[3]; + src += 4; + srclen -= 4; + } break; case ENCODING_UCS4LE: case ENCODING_UTF32LE: - { - Uint8 *p = (Uint8 *) src; - if (srclen < 4) { - return SDL_ICONV_EINVAL; - } - ch = ((Uint32) p[3] << 24) | - ((Uint32) p[2] << 16) | - ((Uint32) p[1] << 8) | (Uint32) p[0]; - src += 4; - srclen -= 4; + { + Uint8 *p = (Uint8 *)src; + if (srclen < 4) { + return SDL_ICONV_EINVAL; } - break; + ch = ((Uint32)p[3] << 24) | + ((Uint32)p[2] << 16) | + ((Uint32)p[1] << 8) | (Uint32)p[0]; + src += 4; + srclen -= 4; + } break; } /* Encode a character */ switch (cd->dst_fmt) { case ENCODING_ASCII: - { - Uint8 *p = (Uint8 *) dst; - if (dstlen < 1) { - return SDL_ICONV_E2BIG; - } - if (ch > 0x7F) { - *p = UNKNOWN_ASCII; - } else { - *p = (Uint8) ch; - } - ++dst; - --dstlen; + { + Uint8 *p = (Uint8 *)dst; + if (dstlen < 1) { + return SDL_ICONV_E2BIG; } - break; + if (ch > 0x7F) { + *p = UNKNOWN_ASCII; + } else { + *p = (Uint8)ch; + } + ++dst; + --dstlen; + } break; case ENCODING_LATIN1: - { - Uint8 *p = (Uint8 *) dst; + { + Uint8 *p = (Uint8 *)dst; + if (dstlen < 1) { + return SDL_ICONV_E2BIG; + } + if (ch > 0xFF) { + *p = UNKNOWN_ASCII; + } else { + *p = (Uint8)ch; + } + ++dst; + --dstlen; + } break; + case ENCODING_UTF8: /* RFC 3629 */ + { + Uint8 *p = (Uint8 *)dst; + if (ch > 0x10FFFF) { + ch = UNKNOWN_UNICODE; + } + if (ch <= 0x7F) { if (dstlen < 1) { return SDL_ICONV_E2BIG; } - if (ch > 0xFF) { - *p = UNKNOWN_ASCII; - } else { - *p = (Uint8) ch; - } + *p = (Uint8)ch; ++dst; --dstlen; - } - break; - case ENCODING_UTF8: /* RFC 3629 */ - { - Uint8 *p = (Uint8 *) dst; - if (ch > 0x10FFFF) { - ch = UNKNOWN_UNICODE; + } else if (ch <= 0x7FF) { + if (dstlen < 2) { + return SDL_ICONV_E2BIG; } - if (ch <= 0x7F) { - if (dstlen < 1) { - return SDL_ICONV_E2BIG; - } - *p = (Uint8) ch; - ++dst; - --dstlen; - } else if (ch <= 0x7FF) { - if (dstlen < 2) { - return SDL_ICONV_E2BIG; - } - p[0] = 0xC0 | (Uint8) ((ch >> 6) & 0x1F); - p[1] = 0x80 | (Uint8) (ch & 0x3F); - dst += 2; - dstlen -= 2; - } else if (ch <= 0xFFFF) { - if (dstlen < 3) { - return SDL_ICONV_E2BIG; - } - p[0] = 0xE0 | (Uint8) ((ch >> 12) & 0x0F); - p[1] = 0x80 | (Uint8) ((ch >> 6) & 0x3F); - p[2] = 0x80 | (Uint8) (ch & 0x3F); - dst += 3; - dstlen -= 3; - } else { - if (dstlen < 4) { - return SDL_ICONV_E2BIG; - } - p[0] = 0xF0 | (Uint8) ((ch >> 18) & 0x07); - p[1] = 0x80 | (Uint8) ((ch >> 12) & 0x3F); - p[2] = 0x80 | (Uint8) ((ch >> 6) & 0x3F); - p[3] = 0x80 | (Uint8) (ch & 0x3F); - dst += 4; - dstlen -= 4; + p[0] = 0xC0 | (Uint8)((ch >> 6) & 0x1F); + p[1] = 0x80 | (Uint8)(ch & 0x3F); + dst += 2; + dstlen -= 2; + } else if (ch <= 0xFFFF) { + if (dstlen < 3) { + return SDL_ICONV_E2BIG; } + p[0] = 0xE0 | (Uint8)((ch >> 12) & 0x0F); + p[1] = 0x80 | (Uint8)((ch >> 6) & 0x3F); + p[2] = 0x80 | (Uint8)(ch & 0x3F); + dst += 3; + dstlen -= 3; + } else { + if (dstlen < 4) { + return SDL_ICONV_E2BIG; + } + p[0] = 0xF0 | (Uint8)((ch >> 18) & 0x07); + p[1] = 0x80 | (Uint8)((ch >> 12) & 0x3F); + p[2] = 0x80 | (Uint8)((ch >> 6) & 0x3F); + p[3] = 0x80 | (Uint8)(ch & 0x3F); + dst += 4; + dstlen -= 4; } - break; + } break; case ENCODING_UTF16BE: /* RFC 2781 */ - { - Uint8 *p = (Uint8 *) dst; - if (ch > 0x10FFFF) { - ch = UNKNOWN_UNICODE; - } - if (ch < 0x10000) { - if (dstlen < 2) { - return SDL_ICONV_E2BIG; - } - p[0] = (Uint8) (ch >> 8); - p[1] = (Uint8) ch; - dst += 2; - dstlen -= 2; - } else { - Uint16 W1, W2; - if (dstlen < 4) { - return SDL_ICONV_E2BIG; - } - ch = ch - 0x10000; - W1 = 0xD800 | (Uint16) ((ch >> 10) & 0x3FF); - W2 = 0xDC00 | (Uint16) (ch & 0x3FF); - p[0] = (Uint8) (W1 >> 8); - p[1] = (Uint8) W1; - p[2] = (Uint8) (W2 >> 8); - p[3] = (Uint8) W2; - dst += 4; - dstlen -= 4; - } + { + Uint8 *p = (Uint8 *)dst; + if (ch > 0x10FFFF) { + ch = UNKNOWN_UNICODE; } - break; + if (ch < 0x10000) { + if (dstlen < 2) { + return SDL_ICONV_E2BIG; + } + p[0] = (Uint8)(ch >> 8); + p[1] = (Uint8)ch; + dst += 2; + dstlen -= 2; + } else { + Uint16 W1, W2; + if (dstlen < 4) { + return SDL_ICONV_E2BIG; + } + ch = ch - 0x10000; + W1 = 0xD800 | (Uint16)((ch >> 10) & 0x3FF); + W2 = 0xDC00 | (Uint16)(ch & 0x3FF); + p[0] = (Uint8)(W1 >> 8); + p[1] = (Uint8)W1; + p[2] = (Uint8)(W2 >> 8); + p[3] = (Uint8)W2; + dst += 4; + dstlen -= 4; + } + } break; case ENCODING_UTF16LE: /* RFC 2781 */ - { - Uint8 *p = (Uint8 *) dst; - if (ch > 0x10FFFF) { - ch = UNKNOWN_UNICODE; - } - if (ch < 0x10000) { - if (dstlen < 2) { - return SDL_ICONV_E2BIG; - } - p[1] = (Uint8) (ch >> 8); - p[0] = (Uint8) ch; - dst += 2; - dstlen -= 2; - } else { - Uint16 W1, W2; - if (dstlen < 4) { - return SDL_ICONV_E2BIG; - } - ch = ch - 0x10000; - W1 = 0xD800 | (Uint16) ((ch >> 10) & 0x3FF); - W2 = 0xDC00 | (Uint16) (ch & 0x3FF); - p[1] = (Uint8) (W1 >> 8); - p[0] = (Uint8) W1; - p[3] = (Uint8) (W2 >> 8); - p[2] = (Uint8) W2; - dst += 4; - dstlen -= 4; - } + { + Uint8 *p = (Uint8 *)dst; + if (ch > 0x10FFFF) { + ch = UNKNOWN_UNICODE; } - break; + if (ch < 0x10000) { + if (dstlen < 2) { + return SDL_ICONV_E2BIG; + } + p[1] = (Uint8)(ch >> 8); + p[0] = (Uint8)ch; + dst += 2; + dstlen -= 2; + } else { + Uint16 W1, W2; + if (dstlen < 4) { + return SDL_ICONV_E2BIG; + } + ch = ch - 0x10000; + W1 = 0xD800 | (Uint16)((ch >> 10) & 0x3FF); + W2 = 0xDC00 | (Uint16)(ch & 0x3FF); + p[1] = (Uint8)(W1 >> 8); + p[0] = (Uint8)W1; + p[3] = (Uint8)(W2 >> 8); + p[2] = (Uint8)W2; + dst += 4; + dstlen -= 4; + } + } break; case ENCODING_UCS2BE: - { - Uint8 *p = (Uint8 *) dst; - if (ch > 0xFFFF) { - ch = UNKNOWN_UNICODE; - } - if (dstlen < 2) { - return SDL_ICONV_E2BIG; - } - p[0] = (Uint8) (ch >> 8); - p[1] = (Uint8) ch; - dst += 2; - dstlen -= 2; + { + Uint8 *p = (Uint8 *)dst; + if (ch > 0xFFFF) { + ch = UNKNOWN_UNICODE; } - break; + if (dstlen < 2) { + return SDL_ICONV_E2BIG; + } + p[0] = (Uint8)(ch >> 8); + p[1] = (Uint8)ch; + dst += 2; + dstlen -= 2; + } break; case ENCODING_UCS2LE: - { - Uint8 *p = (Uint8 *) dst; - if (ch > 0xFFFF) { - ch = UNKNOWN_UNICODE; - } - if (dstlen < 2) { - return SDL_ICONV_E2BIG; - } - p[1] = (Uint8) (ch >> 8); - p[0] = (Uint8) ch; - dst += 2; - dstlen -= 2; + { + Uint8 *p = (Uint8 *)dst; + if (ch > 0xFFFF) { + ch = UNKNOWN_UNICODE; } - break; + if (dstlen < 2) { + return SDL_ICONV_E2BIG; + } + p[1] = (Uint8)(ch >> 8); + p[0] = (Uint8)ch; + dst += 2; + dstlen -= 2; + } break; case ENCODING_UTF32BE: if (ch > 0x10FFFF) { ch = UNKNOWN_UNICODE; @@ -749,14 +733,14 @@ SDL_iconv(SDL_iconv_t cd, ch = UNKNOWN_UNICODE; } { - Uint8 *p = (Uint8 *) dst; + Uint8 *p = (Uint8 *)dst; if (dstlen < 4) { return SDL_ICONV_E2BIG; } - p[0] = (Uint8) (ch >> 24); - p[1] = (Uint8) (ch >> 16); - p[2] = (Uint8) (ch >> 8); - p[3] = (Uint8) ch; + p[0] = (Uint8)(ch >> 24); + p[1] = (Uint8)(ch >> 16); + p[2] = (Uint8)(ch >> 8); + p[3] = (Uint8)ch; dst += 4; dstlen -= 4; } @@ -771,14 +755,14 @@ SDL_iconv(SDL_iconv_t cd, ch = UNKNOWN_UNICODE; } { - Uint8 *p = (Uint8 *) dst; + Uint8 *p = (Uint8 *)dst; if (dstlen < 4) { return SDL_ICONV_E2BIG; } - p[3] = (Uint8) (ch >> 24); - p[2] = (Uint8) (ch >> 16); - p[1] = (Uint8) (ch >> 8); - p[0] = (Uint8) ch; + p[3] = (Uint8)(ch >> 24); + p[2] = (Uint8)(ch >> 16); + p[1] = (Uint8)(ch >> 8); + p[0] = (Uint8)ch; dst += 4; dstlen -= 4; } @@ -795,8 +779,7 @@ SDL_iconv(SDL_iconv_t cd, return total; } -int -SDL_iconv_close(SDL_iconv_t cd) +int SDL_iconv_close(SDL_iconv_t cd) { if (cd != (SDL_iconv_t)-1) { SDL_free(cd); @@ -818,7 +801,7 @@ SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t retCode = 0; cd = SDL_iconv_open(tocode, fromcode); - if (cd == (SDL_iconv_t) - 1) { + if (cd == (SDL_iconv_t)-1) { /* See if we can recover here (fixes iconv on Solaris 11) */ if (tocode == NULL || !*tocode) { tocode = "UTF-8"; @@ -828,12 +811,12 @@ SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, } cd = SDL_iconv_open(tocode, fromcode); } - if (cd == (SDL_iconv_t) - 1) { + if (cd == (SDL_iconv_t)-1) { return NULL; } stringsize = inbytesleft > 4 ? inbytesleft : 4; - string = (char *) SDL_malloc(stringsize); + string = (char *)SDL_malloc(stringsize); if (string == NULL) { SDL_iconv_close(cd); return NULL; @@ -847,20 +830,19 @@ SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, retCode = SDL_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); switch (retCode) { case SDL_ICONV_E2BIG: - { - char *oldstring = string; - stringsize *= 2; - string = (char *) SDL_realloc(string, stringsize); - if (string == NULL) { - SDL_free(oldstring); - SDL_iconv_close(cd); - return NULL; - } - outbuf = string + (outbuf - oldstring); - outbytesleft = stringsize - (outbuf - string); - SDL_memset(outbuf, 0, 4); + { + char *oldstring = string; + stringsize *= 2; + string = (char *)SDL_realloc(string, stringsize); + if (string == NULL) { + SDL_free(oldstring); + SDL_iconv_close(cd); + return NULL; } - break; + outbuf = string + (outbuf - oldstring); + outbytesleft = stringsize - (outbuf - string); + SDL_memset(outbuf, 0, 4); + } break; case SDL_ICONV_EILSEQ: /* Try skipping some input data - not perfect, but... */ ++inbuf; diff --git a/src/stdlib/SDL_mslibc.c b/src/stdlib/SDL_mslibc.c index 8f92463b1..84f8169ae 100644 --- a/src/stdlib/SDL_mslibc.c +++ b/src/stdlib/SDL_mslibc.c @@ -41,26 +41,24 @@ __declspec(selectany) int _fltused = 1; /* The optimizer on Visual Studio 2005 and later generates memcpy() and memset() calls. Always provide it for the SDL2 DLL, but skip it when building static lib w/ static runtime. */ #if (_MSC_VER >= 1400) && (!defined(_MT) || defined(DLL_EXPORT)) -extern void *memcpy(void* dst, const void* src, size_t len); +extern void *memcpy(void *dst, const void *src, size_t len); #pragma intrinsic(memcpy) #if !defined(__clang__) #pragma function(memcpy) #endif -void * -memcpy(void *dst, const void *src, size_t len) +void *memcpy(void *dst, const void *src, size_t len) { return SDL_memcpy(dst, src, len); } -extern void *memset(void* dst, int c, size_t len); +extern void *memset(void *dst, int c, size_t len); #pragma intrinsic(memset) #if !defined(__clang__) #pragma function(memset) #endif -void * -memset(void *dst, int c, size_t len) +void *memset(void *dst, int c, size_t len) { return SDL_memset(dst, c, len); } @@ -69,9 +67,7 @@ memset(void *dst, int c, size_t len) #ifdef _M_IX86 /* Float to long */ -void -__declspec(naked) -_ftol() +void __declspec(naked) _ftol() { /* *INDENT-OFF* */ __asm { @@ -120,22 +116,18 @@ localexit: /* *INDENT-ON* */ } -void -_ftol2_sse() +void _ftol2_sse() { _ftol(); } -void -_ftol2() +void _ftol2() { _ftol(); } /* 64-bit math operators for 32-bit systems */ -void -__declspec(naked) -_allmul() +void __declspec(naked) _allmul() { /* *INDENT-OFF* */ __asm { @@ -163,9 +155,7 @@ hard: /* *INDENT-ON* */ } -void -__declspec(naked) -_alldiv() +void __declspec(naked) _alldiv() { /* *INDENT-OFF* */ __asm { @@ -251,9 +241,7 @@ L8: /* *INDENT-ON* */ } -void -__declspec(naked) -_aulldiv() +void __declspec(naked) _aulldiv() { /* *INDENT-OFF* */ __asm { @@ -309,9 +297,7 @@ L2: /* *INDENT-ON* */ } -void -__declspec(naked) -_allrem() +void __declspec(naked) _allrem() { /* *INDENT-OFF* */ __asm { @@ -396,9 +382,7 @@ L8: /* *INDENT-ON* */ } -void -__declspec(naked) -_aullrem() +void __declspec(naked) _aullrem() { /* *INDENT-OFF* */ __asm { @@ -455,9 +439,7 @@ L2: /* *INDENT-ON* */ } -void -__declspec(naked) -_alldvrm() +void __declspec(naked) _alldvrm() { /* *INDENT-OFF* */ __asm { @@ -565,9 +547,7 @@ L8: /* *INDENT-ON* */ } -void -__declspec(naked) -_aulldvrm() +void __declspec(naked) _aulldvrm() { /* *INDENT-OFF* */ __asm { @@ -638,9 +618,7 @@ L2: /* *INDENT-ON* */ } -void -__declspec(naked) -_allshl() +void __declspec(naked) _allshl() { /* *INDENT-OFF* */ __asm { @@ -665,9 +643,7 @@ RETZERO: /* *INDENT-ON* */ } -void -__declspec(naked) -_allshr() +void __declspec(naked) _allshr() { /* *INDENT-OFF* */ __asm { @@ -692,9 +668,7 @@ RETSIGN: /* *INDENT-ON* */ } -void -__declspec(naked) -_aullshr() +void __declspec(naked) _aullshr() { /* *INDENT-OFF* */ __asm { diff --git a/src/stdlib/SDL_stdlib.c b/src/stdlib/SDL_stdlib.c index 2af18b1f0..08c6fc764 100644 --- a/src/stdlib/SDL_stdlib.c +++ b/src/stdlib/SDL_stdlib.c @@ -30,7 +30,6 @@ #include "SDL_stdinc.h" #include "../libm/math_libm.h" - double SDL_atan(double x) { @@ -41,8 +40,7 @@ SDL_atan(double x) #endif } -float -SDL_atanf(float x) +float SDL_atanf(float x) { #if defined(HAVE_ATANF) return atanf(x); @@ -61,8 +59,7 @@ SDL_atan2(double y, double x) #endif } -float -SDL_atan2f(float y, float x) +float SDL_atan2f(float y, float x) { #if defined(HAVE_ATAN2F) return atan2f(y, x); @@ -91,8 +88,7 @@ SDL_acos(double val) #endif } -float -SDL_acosf(float val) +float SDL_acosf(float val) { #if defined(HAVE_ACOSF) return acosf(val); @@ -117,8 +113,7 @@ SDL_asin(double val) #endif } -float -SDL_asinf(float val) +float SDL_asinf(float val) { #if defined(HAVE_ASINF) return asinf(val); @@ -142,8 +137,7 @@ SDL_ceil(double x) #endif /* HAVE_CEIL */ } -float -SDL_ceilf(float x) +float SDL_ceilf(float x) { #if defined(HAVE_CEILF) return ceilf(x); @@ -161,8 +155,8 @@ SDL_copysign(double x, double y) return _copysign(x, y); #elif defined(__WATCOMC__) && defined(__386__) /* this is nasty as hell, but it works.. */ - unsigned int *xi = (unsigned int *) &x, - *yi = (unsigned int *) &y; + unsigned int *xi = (unsigned int *)&x, + *yi = (unsigned int *)&y; xi[1] = (yi[1] & 0x80000000) | (xi[1] & 0x7fffffff); return x; #else @@ -170,8 +164,7 @@ SDL_copysign(double x, double y) #endif /* HAVE_COPYSIGN */ } -float -SDL_copysignf(float x, float y) +float SDL_copysignf(float x, float y) { #if defined(HAVE_COPYSIGNF) return copysignf(x, y); @@ -190,8 +183,7 @@ SDL_cos(double x) #endif } -float -SDL_cosf(float x) +float SDL_cosf(float x) { #if defined(HAVE_COSF) return cosf(x); @@ -210,8 +202,7 @@ SDL_exp(double x) #endif } -float -SDL_expf(float x) +float SDL_expf(float x) { #if defined(HAVE_EXPF) return expf(x); @@ -230,8 +221,7 @@ SDL_fabs(double x) #endif } -float -SDL_fabsf(float x) +float SDL_fabsf(float x) { #if defined(HAVE_FABSF) return fabsf(x); @@ -250,8 +240,7 @@ SDL_floor(double x) #endif } -float -SDL_floorf(float x) +float SDL_floorf(float x) { #if defined(HAVE_FLOORF) return floorf(x); @@ -274,8 +263,7 @@ SDL_trunc(double x) #endif } -float -SDL_truncf(float x) +float SDL_truncf(float x) { #if defined(HAVE_TRUNCF) return truncf(x); @@ -294,8 +282,7 @@ SDL_fmod(double x, double y) #endif } -float -SDL_fmodf(float x, float y) +float SDL_fmodf(float x, float y) { #if defined(HAVE_FMODF) return fmodf(x, y); @@ -314,8 +301,7 @@ SDL_log(double x) #endif } -float -SDL_logf(float x) +float SDL_logf(float x) { #if defined(HAVE_LOGF) return logf(x); @@ -334,8 +320,7 @@ SDL_log10(double x) #endif } -float -SDL_log10f(float x) +float SDL_log10f(float x) { #if defined(HAVE_LOG10F) return log10f(x); @@ -354,8 +339,7 @@ SDL_pow(double x, double y) #endif } -float -SDL_powf(float x, float y) +float SDL_powf(float x, float y) { #if defined(HAVE_POWF) return powf(x, y); @@ -378,8 +362,7 @@ SDL_round(double arg) #endif } -float -SDL_roundf(float arg) +float SDL_roundf(float arg) { #if defined HAVE_ROUNDF return roundf(arg); @@ -388,8 +371,7 @@ SDL_roundf(float arg) #endif } -long -SDL_lround(double arg) +long SDL_lround(double arg) { #if defined HAVE_LROUND return lround(arg); @@ -398,8 +380,7 @@ SDL_lround(double arg) #endif } -long -SDL_lroundf(float arg) +long SDL_lroundf(float arg) { #if defined HAVE_LROUNDF return lroundf(arg); @@ -416,16 +397,15 @@ SDL_scalbn(double x, int n) #elif defined(HAVE__SCALB) return _scalb(x, n); #elif defined(HAVE_LIBC) && defined(HAVE_FLOAT_H) && (FLT_RADIX == 2) -/* from scalbn(3): If FLT_RADIX equals 2 (which is - * usual), then scalbn() is equivalent to ldexp(3). */ + /* from scalbn(3): If FLT_RADIX equals 2 (which is + * usual), then scalbn() is equivalent to ldexp(3). */ return ldexp(x, n); #else return SDL_uclibc_scalbn(x, n); #endif } -float -SDL_scalbnf(float x, int n) +float SDL_scalbnf(float x, int n) { #if defined(HAVE_SCALBNF) return scalbnf(x, n); @@ -444,8 +424,7 @@ SDL_sin(double x) #endif } -float -SDL_sinf(float x) +float SDL_sinf(float x) { #if defined(HAVE_SINF) return sinf(x); @@ -464,8 +443,7 @@ SDL_sqrt(double x) #endif } -float -SDL_sqrtf(float x) +float SDL_sqrtf(float x) { #if defined(HAVE_SQRTF) return sqrtf(x); @@ -484,8 +462,7 @@ SDL_tan(double x) #endif } -float -SDL_tanf(float x) +float SDL_tanf(float x) { #if defined(HAVE_TANF) return tanf(x); @@ -504,7 +481,10 @@ int SDL_abs(int x) } #if defined(HAVE_CTYPE_H) -int SDL_isalpha(int x) { return isalpha(x); } +int SDL_isalpha(int x) +{ + return isalpha(x); +} int SDL_isalnum(int x) { return isalnum(x); } int SDL_isdigit(int x) { return isdigit(x); } int SDL_isxdigit(int x) { return isxdigit(x); } @@ -518,7 +498,10 @@ int SDL_iscntrl(int x) { return iscntrl(x); } int SDL_toupper(int x) { return toupper(x); } int SDL_tolower(int x) { return tolower(x); } #else -int SDL_isalpha(int x) { return (SDL_isupper(x)) || (SDL_islower(x)); } +int SDL_isalpha(int x) +{ + return (SDL_isupper(x)) || (SDL_islower(x)); +} int SDL_isalnum(int x) { return (SDL_isalpha(x)) || (SDL_isdigit(x)); } int SDL_isdigit(int x) { return ((x) >= '0') && ((x) <= '9'); } int SDL_isxdigit(int x) { return (((x) >= 'A') && ((x) <= 'F')) || (((x) >= 'a') && ((x) <= 'f')) || (SDL_isdigit(x)); } @@ -529,8 +512,8 @@ int SDL_islower(int x) { return ((x) >= 'a') && ((x) <= 'z'); } int SDL_isprint(int x) { return ((x) >= ' ') && ((x) < '\x7f'); } int SDL_isgraph(int x) { return (SDL_isprint(x)) && ((x) != ' '); } int SDL_iscntrl(int x) { return (((x) >= '\0') && ((x) <= '\x1f')) || ((x) == '\x7f'); } -int SDL_toupper(int x) { return ((x) >= 'a') && ((x) <= 'z') ? ('A'+((x)-'a')) : (x); } -int SDL_tolower(int x) { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) : (x); } +int SDL_toupper(int x) { return ((x) >= 'a') && ((x) <= 'z') ? ('A' + ((x) - 'a')) : (x); } +int SDL_tolower(int x) { return ((x) >= 'A') && ((x) <= 'Z') ? ('a' + ((x) - 'A')) : (x); } #endif /* This file contains a portable memcpy manipulation function for SDL */ @@ -566,15 +549,15 @@ SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, Uint32 *srcp4, *dstp4; Uint8 *srcp1, *dstp1; - srcp4 = (Uint32 *) src; - dstp4 = (Uint32 *) dst; + srcp4 = (Uint32 *)src; + dstp4 = (Uint32 *)dst; len /= 4; while (len--) { *dstp4++ = *srcp4++; } - srcp1 = (Uint8 *) srcp4; - dstp1 = (Uint8 *) dstp4; + srcp1 = (Uint8 *)srcp4; + dstp1 = (Uint8 *)dstp4; switch (left) { case 3: *dstp1++ = *srcp1++; @@ -596,7 +579,7 @@ SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len) #else size_t left; Uint32 *dstp4; - Uint8 *dstp1 = (Uint8 *) dst; + Uint8 *dstp1 = (Uint8 *)dst; Uint8 value1; Uint32 value4; @@ -616,14 +599,14 @@ SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len) } value4 = ((Uint32)c | ((Uint32)c << 8) | ((Uint32)c << 16) | ((Uint32)c << 24)); - dstp4 = (Uint32 *) dstp1; + dstp4 = (Uint32 *)dstp1; left = (len % 4); len /= 4; while (len--) { *dstp4++ = value4; } - dstp1 = (Uint8 *) dstp4; + dstp1 = (Uint8 *)dstp4; switch (left) { case 3: *dstp1++ = value1; @@ -638,9 +621,15 @@ SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len) } #if defined(HAVE_CTYPE_H) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -int SDL_isblank(int x) { return isblank(x); } +int SDL_isblank(int x) +{ + return isblank(x); +} #else -int SDL_isblank(int x) { return ((x) == ' ') || ((x) == '\t'); } +int SDL_isblank(int x) +{ + return ((x) == ' ') || ((x) == '\t'); +} #endif /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c index 1bfc13b4c..97971a97a 100644 --- a/src/stdlib/SDL_string.c +++ b/src/stdlib/SDL_string.c @@ -34,11 +34,11 @@ #endif #if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOL) || !defined(HAVE_STRTOUL) || !defined(HAVE_STRTOD) || !defined(HAVE_STRTOLL) || !defined(HAVE_STRTOULL) -#define SDL_isupperhex(X) (((X) >= 'A') && ((X) <= 'F')) -#define SDL_islowerhex(X) (((X) >= 'a') && ((X) <= 'f')) +#define SDL_isupperhex(X) (((X) >= 'A') && ((X) <= 'F')) +#define SDL_islowerhex(X) (((X) >= 'a') && ((X) <= 'f')) #endif -#define UTF8_IsLeadByte(c) ((c) >= 0xC0 && (c) <= 0xF4) +#define UTF8_IsLeadByte(c) ((c) >= 0xC0 && (c) <= 0xF4) #define UTF8_IsTrailingByte(c) ((c) >= 0x80 && (c) <= 0xBF) static unsigned UTF8_TrailingBytes(unsigned char c) @@ -70,7 +70,7 @@ SDL_ScanLong(const char *text, int count, int radix, long *valuep) } for (;;) { int v; - if (SDL_isdigit((unsigned char) *text)) { + if (SDL_isdigit((unsigned char)*text)) { v = *text - '0'; } else if (radix == 16 && SDL_isupperhex(*text)) { v = 10 + (*text - 'A'); @@ -114,7 +114,7 @@ SDL_ScanUnsignedLong(const char *text, int count, int radix, unsigned long *valu } for (;;) { int v; - if (SDL_isdigit((unsigned char) *text)) { + if (SDL_isdigit((unsigned char)*text)) { v = *text - '0'; } else if (radix == 16 && SDL_isupperhex(*text)) { v = 10 + (*text - 'A'); @@ -140,7 +140,7 @@ SDL_ScanUnsignedLong(const char *text, int count, int radix, unsigned long *valu #ifndef HAVE_VSSCANF static size_t -SDL_ScanUintPtrT(const char *text, int radix, uintptr_t * valuep) +SDL_ScanUintPtrT(const char *text, int radix, uintptr_t *valuep) { const char *textstart = text; uintptr_t value = 0; @@ -150,7 +150,7 @@ SDL_ScanUintPtrT(const char *text, int radix, uintptr_t * valuep) } for (;;) { int v; - if (SDL_isdigit((unsigned char) *text)) { + if (SDL_isdigit((unsigned char)*text)) { v = *text - '0'; } else if (radix == 16 && SDL_isupperhex(*text)) { v = 10 + (*text - 'A'); @@ -172,7 +172,7 @@ SDL_ScanUintPtrT(const char *text, int radix, uintptr_t * valuep) #if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOLL) || !defined(HAVE_STRTOULL) static size_t -SDL_ScanLongLong(const char *text, int count, int radix, Sint64 * valuep) +SDL_ScanLongLong(const char *text, int count, int radix, Sint64 *valuep) { const char *textstart = text; Sint64 value = 0; @@ -187,7 +187,7 @@ SDL_ScanLongLong(const char *text, int count, int radix, Sint64 * valuep) } for (;;) { int v; - if (SDL_isdigit((unsigned char) *text)) { + if (SDL_isdigit((unsigned char)*text)) { v = *text - '0'; } else if (radix == 16 && SDL_isupperhex(*text)) { v = 10 + (*text - 'A'); @@ -217,7 +217,7 @@ SDL_ScanLongLong(const char *text, int count, int radix, Sint64 * valuep) #if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOULL) static size_t -SDL_ScanUnsignedLongLong(const char *text, int count, int radix, Uint64 * valuep) +SDL_ScanUnsignedLongLong(const char *text, int count, int radix, Uint64 *valuep) { const char *textstart = text; Uint64 value = 0; @@ -231,7 +231,7 @@ SDL_ScanUnsignedLongLong(const char *text, int count, int radix, Uint64 * valuep } for (;;) { int v; - if (SDL_isdigit((unsigned char) *text)) { + if (SDL_isdigit((unsigned char)*text)) { v = *text - '0'; } else if (radix == 16 && SDL_isupperhex(*text)) { v = 10 + (*text - 'A'); @@ -273,9 +273,9 @@ SDL_ScanFloat(const char *text, double *valuep) if (*text == '.') { int mult = 10; ++text; - while (SDL_isdigit((unsigned char) *text)) { + while (SDL_isdigit((unsigned char)*text)) { lvalue = *text - '0'; - value += (double) lvalue / mult; + value += (double)lvalue / mult; mult *= 10; ++text; } @@ -297,8 +297,8 @@ SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, #if defined(HAVE_MEMMOVE) return memmove(dst, src, len); #else - char *srcp = (char *) src; - char *dstp = (char *) dst; + char *srcp = (char *)src; + char *dstp = (char *)dst; if (src < dst) { srcp += len - 1; @@ -315,8 +315,7 @@ SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, #endif /* HAVE_MEMMOVE */ } -int -SDL_memcmp(const void *s1, const void *s2, size_t len) +int SDL_memcmp(const void *s1, const void *s2, size_t len) { #if defined(__vita__) /* @@ -332,8 +331,8 @@ SDL_memcmp(const void *s1, const void *s2, size_t len) #elif defined(HAVE_MEMCMP) return memcmp(s1, s2, len); #else - char *s1p = (char *) s1; - char *s2p = (char *) s2; + char *s1p = (char *)s1; + char *s2p = (char *)s2; while (len--) { if (*s1p != *s2p) { return *s1p - *s2p; @@ -360,7 +359,7 @@ SDL_strlen(const char *string) } size_t -SDL_wcslen(const wchar_t * string) +SDL_wcslen(const wchar_t *string) { #if defined(HAVE_WCSLEN) return wcslen(string); @@ -432,8 +431,7 @@ SDL_wcsstr(const wchar_t *haystack, const wchar_t *needle) #endif /* HAVE_WCSSTR */ } -int -SDL_wcscmp(const wchar_t *str1, const wchar_t *str2) +int SDL_wcscmp(const wchar_t *str1, const wchar_t *str2) { #if defined(HAVE_WCSCMP) return wcscmp(str1, str2); @@ -449,8 +447,7 @@ SDL_wcscmp(const wchar_t *str1, const wchar_t *str2) #endif /* HAVE_WCSCMP */ } -int -SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen) +int SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen) { #if defined(HAVE_WCSNCMP) return wcsncmp(str1, str2, maxlen); @@ -471,8 +468,7 @@ SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen) #endif /* HAVE_WCSNCMP */ } -int -SDL_wcscasecmp(const wchar_t *str1, const wchar_t *str2) +int SDL_wcscasecmp(const wchar_t *str1, const wchar_t *str2) { #if defined(HAVE_WCSCASECMP) return wcscasecmp(str1, str2); @@ -487,8 +483,8 @@ SDL_wcscasecmp(const wchar_t *str1, const wchar_t *str2) a = *str1; b = *str2; } else { - a = SDL_toupper((unsigned char) *str1); - b = SDL_toupper((unsigned char) *str2); + a = SDL_toupper((unsigned char)*str1); + b = SDL_toupper((unsigned char)*str2); } if (a != b) { break; @@ -502,15 +498,14 @@ SDL_wcscasecmp(const wchar_t *str1, const wchar_t *str2) a = *str1; b = *str2; } else { - a = SDL_toupper((unsigned char) *str1); - b = SDL_toupper((unsigned char) *str2); + a = SDL_toupper((unsigned char)*str1); + b = SDL_toupper((unsigned char)*str2); } return (int)((unsigned int)a - (unsigned int)b); #endif /* HAVE__WCSICMP */ } -int -SDL_wcsncasecmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen) +int SDL_wcsncasecmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen) { #if defined(HAVE_WCSNCASECMP) return wcsncasecmp(str1, str2, maxlen); @@ -525,8 +520,8 @@ SDL_wcsncasecmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen) a = *str1; b = *str2; } else { - a = SDL_toupper((unsigned char) *str1); - b = SDL_toupper((unsigned char) *str2); + a = SDL_toupper((unsigned char)*str1); + b = SDL_toupper((unsigned char)*str2); } if (a != b) { break; @@ -544,8 +539,8 @@ SDL_wcsncasecmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen) a = *str1; b = *str2; } else { - a = SDL_toupper((unsigned char) *str1); - b = SDL_toupper((unsigned char) *str2); + a = SDL_toupper((unsigned char)*str1); + b = SDL_toupper((unsigned char)*str2); } return (int)((unsigned int)a - (unsigned int)b); } @@ -613,7 +608,7 @@ SDL_utf8strlen(const char *str) retval++; } } - + return retval; } @@ -687,7 +682,7 @@ SDL_strupr(char *string) #else char *bufp = string; while (*bufp) { - *bufp = SDL_toupper((unsigned char) *bufp); + *bufp = SDL_toupper((unsigned char)*bufp); ++bufp; } return string; @@ -702,7 +697,7 @@ SDL_strlwr(char *string) #else char *bufp = string; while (*bufp) { - *bufp = SDL_tolower((unsigned char) *bufp); + *bufp = SDL_tolower((unsigned char)*bufp); ++bufp; } return string; @@ -919,8 +914,7 @@ double SDL_atof(const char *string) #endif /* HAVE_ATOF */ } -long -SDL_strtol(const char *string, char **endp, int base) +long SDL_strtol(const char *string, char **endp, int base) { #if defined(HAVE_STRTOL) return strtol(string, endp, base); @@ -938,7 +932,7 @@ SDL_strtol(const char *string, char **endp, int base) len = SDL_ScanLong(string, 0, base, &value); if (endp) { - *endp = (char *) string + len; + *endp = (char *)string + len; } return value; #endif /* HAVE_STRTOL */ @@ -963,7 +957,7 @@ SDL_strtoul(const char *string, char **endp, int base) len = SDL_ScanUnsignedLong(string, 0, base, &value); if (endp) { - *endp = (char *) string + len; + *endp = (char *)string + len; } return value; #endif /* HAVE_STRTOUL */ @@ -988,7 +982,7 @@ SDL_strtoll(const char *string, char **endp, int base) len = SDL_ScanLongLong(string, 0, base, &value); if (endp) { - *endp = (char *) string + len; + *endp = (char *)string + len; } return value; #endif /* HAVE_STRTOLL */ @@ -1013,7 +1007,7 @@ SDL_strtoull(const char *string, char **endp, int base) len = SDL_ScanUnsignedLongLong(string, 0, base, &value); if (endp) { - *endp = (char *) string + len; + *endp = (char *)string + len; } return value; #endif /* HAVE_STRTOULL */ @@ -1030,14 +1024,13 @@ SDL_strtod(const char *string, char **endp) len = SDL_ScanFloat(string, &value); if (endp) { - *endp = (char *) string + len; + *endp = (char *)string + len; } return value; #endif /* HAVE_STRTOD */ } -int -SDL_strcmp(const char *str1, const char *str2) +int SDL_strcmp(const char *str1, const char *str2) { #if defined(HAVE_STRCMP) return strcmp(str1, str2); @@ -1045,8 +1038,8 @@ SDL_strcmp(const char *str1, const char *str2) int result; while (1) { - result = (int)((unsigned char) *str1 - (unsigned char) *str2); - if (result != 0 || (*str1 == '\0'/* && *str2 == '\0'*/)) { + result = (int)((unsigned char)*str1 - (unsigned char)*str2); + if (result != 0 || (*str1 == '\0' /* && *str2 == '\0'*/)) { break; } ++str1; @@ -1056,8 +1049,7 @@ SDL_strcmp(const char *str1, const char *str2) #endif /* HAVE_STRCMP */ } -int -SDL_strncmp(const char *str1, const char *str2, size_t maxlen) +int SDL_strncmp(const char *str1, const char *str2, size_t maxlen) { #if defined(HAVE_STRNCMP) return strncmp(str1, str2, maxlen); @@ -1065,8 +1057,8 @@ SDL_strncmp(const char *str1, const char *str2, size_t maxlen) int result; while (maxlen) { - result = (int) (unsigned char) *str1 - (unsigned char) *str2; - if (result != 0 || *str1 == '\0'/* && *str2 == '\0'*/) { + result = (int)(unsigned char)*str1 - (unsigned char)*str2; + if (result != 0 || *str1 == '\0' /* && *str2 == '\0'*/) { break; } ++str1; @@ -1080,8 +1072,7 @@ SDL_strncmp(const char *str1, const char *str2, size_t maxlen) #endif /* HAVE_STRNCMP */ } -int -SDL_strcasecmp(const char *str1, const char *str2) +int SDL_strcasecmp(const char *str1, const char *str2) { #ifdef HAVE_STRCASECMP return strcasecmp(str1, str2); @@ -1091,8 +1082,8 @@ SDL_strcasecmp(const char *str1, const char *str2) int a, b, result; while (1) { - a = SDL_toupper((unsigned char) *str1); - b = SDL_toupper((unsigned char) *str2); + a = SDL_toupper((unsigned char)*str1); + b = SDL_toupper((unsigned char)*str2); result = a - b; if (result != 0 || a == 0 /*&& b == 0*/) { break; @@ -1104,8 +1095,7 @@ SDL_strcasecmp(const char *str1, const char *str2) #endif /* HAVE_STRCASECMP */ } -int -SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen) +int SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen) { #ifdef HAVE_STRNCASECMP return strncasecmp(str1, str2, maxlen); @@ -1115,8 +1105,8 @@ SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen) int a, b, result; while (maxlen) { - a = SDL_tolower((unsigned char) *str1); - b = SDL_tolower((unsigned char) *str2); + a = SDL_tolower((unsigned char)*str1); + b = SDL_tolower((unsigned char)*str2); result = a - b; if (result != 0 || a == 0 /*&& b == 0*/) { break; @@ -1132,8 +1122,7 @@ SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen) #endif /* HAVE_STRNCASECMP */ } -int -SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, ...) +int SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, ...) { int rc; va_list ap; @@ -1144,14 +1133,12 @@ SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, ...) } #ifdef HAVE_VSSCANF -int -SDL_vsscanf(const char *text, const char *fmt, va_list ap) +int SDL_vsscanf(const char *text, const char *fmt, va_list ap) { return vsscanf(text, fmt, ap); } #else -int -SDL_vsscanf(const char *text, const char *fmt, va_list ap) +int SDL_vsscanf(const char *text, const char *fmt, va_list ap) { int retval = 0; @@ -1161,7 +1148,7 @@ SDL_vsscanf(const char *text, const char *fmt, va_list ap) while (*fmt) { if (*fmt == ' ') { - while (SDL_isspace((unsigned char) *text)) { + while (SDL_isspace((unsigned char)*text)) { ++text; } ++fmt; @@ -1215,7 +1202,7 @@ SDL_vsscanf(const char *text, const char *fmt, va_list ap) continue; } - while (SDL_isspace((unsigned char) *text)) { + while (SDL_isspace((unsigned char)*text)) { ++text; } @@ -1245,19 +1232,19 @@ SDL_vsscanf(const char *text, const char *fmt, va_list ap) inttype = DO_SIZE_T; break; case 'i': - { - int index = 0; - if (text[index] == '-') { - ++index; - } - if (text[index] == '0') { - if (SDL_tolower((unsigned char) text[index + 1]) == 'x') { - radix = 16; - } else { - radix = 8; - } + { + int index = 0; + if (text[index] == '-') { + ++index; + } + if (text[index] == '0') { + if (SDL_tolower((unsigned char)text[index + 1]) == 'x') { + radix = 16; + } else { + radix = 8; } } + } SDL_FALLTHROUGH; case 'd': if (inttype == DO_LONGLONG) { @@ -1285,23 +1272,20 @@ SDL_vsscanf(const char *text, const char *fmt, va_list ap) if (advance && !suppress) { switch (inttype) { case DO_SHORT: - { - short *valuep = va_arg(ap, short *); - *valuep = (short) value; - } - break; + { + short *valuep = va_arg(ap, short *); + *valuep = (short)value; + } break; case DO_INT: - { - int *valuep = va_arg(ap, int *); - *valuep = (int) value; - } - break; + { + int *valuep = va_arg(ap, int *); + *valuep = (int)value; + } break; case DO_LONG: - { - long *valuep = va_arg(ap, long *); - *valuep = value; - } - break; + { + long *valuep = va_arg(ap, long *); + *valuep = value; + } break; case DO_LONGLONG: case DO_SIZE_T: /* Handled above */ @@ -1349,23 +1333,20 @@ SDL_vsscanf(const char *text, const char *fmt, va_list ap) if (advance && !suppress) { switch (inttype) { case DO_SHORT: - { - short *valuep = va_arg(ap, short *); - *valuep = (short) value; - } - break; + { + short *valuep = va_arg(ap, short *); + *valuep = (short)value; + } break; case DO_INT: - { - int *valuep = va_arg(ap, int *); - *valuep = (int) value; - } - break; + { + int *valuep = va_arg(ap, int *); + *valuep = (int)value; + } break; case DO_LONG: - { - long *valuep = va_arg(ap, long *); - *valuep = value; - } - break; + { + long *valuep = va_arg(ap, long *); + *valuep = value; + } break; case DO_LONGLONG: case DO_SIZE_T: /* Handled above */ @@ -1377,34 +1358,34 @@ SDL_vsscanf(const char *text, const char *fmt, va_list ap) done = SDL_TRUE; break; case 'p': - { - uintptr_t value = 0; - advance = SDL_ScanUintPtrT(text, 16, &value); - text += advance; - if (advance && !suppress) { - void **valuep = va_arg(ap, void **); - *valuep = (void *) value; - ++retval; - } + { + uintptr_t value = 0; + advance = SDL_ScanUintPtrT(text, 16, &value); + text += advance; + if (advance && !suppress) { + void **valuep = va_arg(ap, void **); + *valuep = (void *)value; + ++retval; } + } done = SDL_TRUE; break; case 'f': - { - double value = 0.0; - advance = SDL_ScanFloat(text, &value); - text += advance; - if (advance && !suppress) { - float *valuep = va_arg(ap, float *); - *valuep = (float) value; - ++retval; - } + { + double value = 0.0; + advance = SDL_ScanFloat(text, &value); + text += advance; + if (advance && !suppress) { + float *valuep = va_arg(ap, float *); + *valuep = (float)value; + ++retval; } + } done = SDL_TRUE; break; case 's': if (suppress) { - while (!SDL_isspace((unsigned char) *text)) { + while (!SDL_isspace((unsigned char)*text)) { ++text; if (count) { if (--count == 0) { @@ -1414,7 +1395,7 @@ SDL_vsscanf(const char *text, const char *fmt, va_list ap) } } else { char *valuep = va_arg(ap, char *); - while (!SDL_isspace((unsigned char) *text)) { + while (!SDL_isspace((unsigned char)*text)) { *valuep++ = *text++; if (count) { if (--count == 0) { @@ -1448,8 +1429,7 @@ SDL_vsscanf(const char *text, const char *fmt, va_list ap) } #endif /* HAVE_VSSCANF */ -int -SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) +int SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { va_list ap; int retval; @@ -1487,9 +1467,9 @@ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *f return vsnprintf(text, maxlen, fmt, ap); } #else -#define TEXT_AND_LEN_ARGS (length < maxlen) ? &text[length] : NULL, (length < maxlen) ? (maxlen - length) : 0 +#define TEXT_AND_LEN_ARGS (length < maxlen) ? &text[length] : NULL, (length < maxlen) ? (maxlen - length) : 0 - /* FIXME: implement more of the format specifiers */ +/* FIXME: implement more of the format specifiers */ typedef enum { SDL_CASE_NOCHANGE, @@ -1501,7 +1481,7 @@ typedef struct { SDL_bool left_justify; /* for now: ignored. */ SDL_bool force_sign; - SDL_bool force_type; /* for now: used only by float printer, ignored otherwise. */ + SDL_bool force_type; /* for now: used only by float printer, ignored otherwise. */ SDL_bool pad_zeroes; SDL_letter_case force_case; int width; @@ -1558,9 +1538,8 @@ SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *str return length; } -static void -SDL_IntPrecisionAdjust(char *num, size_t maxlen, SDL_FormatInfo *info) -{/* left-pad num with zeroes. */ +static void SDL_IntPrecisionAdjust(char *num, size_t maxlen, SDL_FormatInfo *info) +{ /* left-pad num with zeroes. */ size_t sz, pad, have_sign; if (info == NULL) { @@ -1581,12 +1560,12 @@ SDL_IntPrecisionAdjust(char *num, size_t maxlen, SDL_FormatInfo *info) SDL_memset(num, '0', pad); } } - info->precision = -1;/* so that SDL_PrintString() doesn't make a mess. */ + info->precision = -1; /* so that SDL_PrintString() doesn't make a mess. */ if (info->pad_zeroes && info->width > 0 && (size_t)info->width > sz + have_sign) { - /* handle here: spaces are added before the sign - but zeroes must be placed _after_ the sign. */ - /* sz hasn't changed: we ignore pad_zeroes if a precision is given. */ + /* handle here: spaces are added before the sign + but zeroes must be placed _after_ the sign. */ + /* sz hasn't changed: we ignore pad_zeroes if a precision is given. */ pad = (size_t)info->width - sz - have_sign; if (pad + sz + 1 <= maxlen) { SDL_memmove(num + pad, num, sz + 1); @@ -1664,7 +1643,7 @@ SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg) } ++length; } - value = (unsigned long) arg; + value = (unsigned long)arg; length += SDL_PrintUnsignedLong(TEXT_AND_LEN_ARGS, NULL, value); arg -= value; if (info->precision < 0) { @@ -1677,9 +1656,9 @@ SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg) } ++length; while (info->precision-- > 0) { - value = (unsigned long) (arg * mult); + value = (unsigned long)(arg * mult); length += SDL_PrintUnsignedLong(TEXT_AND_LEN_ARGS, NULL, value); - arg -= (double) value / mult; + arg -= (double)value / mult; mult *= 10; } } @@ -1699,8 +1678,7 @@ SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg) return length; } -int -SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap) +int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap) { size_t length = 0; @@ -1783,7 +1761,7 @@ SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, case 'c': /* char is promoted to int when passed through (...) */ if (length < maxlen) { - text[length] = (char) va_arg(ap, int); + text[length] = (char)va_arg(ap, int); } ++length; done = SDL_TRUE; @@ -1813,15 +1791,15 @@ SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, switch (inttype) { case DO_INT: length += SDL_PrintLong(TEXT_AND_LEN_ARGS, &info, - (long) va_arg(ap, int)); + (long)va_arg(ap, int)); break; case DO_LONG: length += SDL_PrintLong(TEXT_AND_LEN_ARGS, &info, - va_arg(ap, long)); + va_arg(ap, long)); break; case DO_LONGLONG: length += SDL_PrintLongLong(TEXT_AND_LEN_ARGS, &info, - va_arg(ap, Sint64)); + va_arg(ap, Sint64)); break; case DO_SIZE_T: length += SDL_PrintLongLong(TEXT_AND_LEN_ARGS, &info, @@ -1858,16 +1836,16 @@ SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, switch (inttype) { case DO_INT: length += SDL_PrintUnsignedLong(TEXT_AND_LEN_ARGS, &info, - (unsigned long) - va_arg(ap, unsigned int)); + (unsigned long) + va_arg(ap, unsigned int)); break; case DO_LONG: length += SDL_PrintUnsignedLong(TEXT_AND_LEN_ARGS, &info, - va_arg(ap, unsigned long)); + va_arg(ap, unsigned long)); break; case DO_LONGLONG: length += SDL_PrintUnsignedLongLong(TEXT_AND_LEN_ARGS, &info, - va_arg(ap, Uint64)); + va_arg(ap, Uint64)); break; case DO_SIZE_T: length += SDL_PrintUnsignedLongLong(TEXT_AND_LEN_ARGS, &info, @@ -1881,21 +1859,20 @@ SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, done = SDL_TRUE; break; case 'S': - { - /* In practice this is used on Windows for WCHAR strings */ - wchar_t *wide_arg = va_arg(ap, wchar_t *); - if (wide_arg) { - char *arg = SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(wide_arg), (SDL_wcslen(wide_arg)+1)*sizeof(*wide_arg)); - info.pad_zeroes = SDL_FALSE; - length += SDL_PrintString(TEXT_AND_LEN_ARGS, &info, arg); - SDL_free(arg); - } else { - info.pad_zeroes = SDL_FALSE; - length += SDL_PrintString(TEXT_AND_LEN_ARGS, &info, NULL); - } - done = SDL_TRUE; + { + /* In practice this is used on Windows for WCHAR strings */ + wchar_t *wide_arg = va_arg(ap, wchar_t *); + if (wide_arg) { + char *arg = SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(wide_arg), (SDL_wcslen(wide_arg) + 1) * sizeof(*wide_arg)); + info.pad_zeroes = SDL_FALSE; + length += SDL_PrintString(TEXT_AND_LEN_ARGS, &info, arg); + SDL_free(arg); + } else { + info.pad_zeroes = SDL_FALSE; + length += SDL_PrintString(TEXT_AND_LEN_ARGS, &info, NULL); } - break; + done = SDL_TRUE; + } break; case 's': info.pad_zeroes = SDL_FALSE; length += SDL_PrintString(TEXT_AND_LEN_ARGS, &info, va_arg(ap, char *)); @@ -1921,14 +1898,12 @@ SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, text[maxlen - 1] = '\0'; } return (int)length; - } #undef TEXT_AND_LEN_ARGS #endif /* HAVE_VSNPRINTF */ -int -SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) +int SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { va_list ap; int retval; @@ -1940,11 +1915,10 @@ SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) return retval; } -int -SDL_vasprintf(char **strp, const char *fmt, va_list ap) +int SDL_vasprintf(char **strp, const char *fmt, va_list ap) { int retval; - int size = 100; /* Guess we need no more than 100 bytes */ + int size = 100; /* Guess we need no more than 100 bytes */ char *p, *np; va_list aq; @@ -1973,7 +1947,7 @@ SDL_vasprintf(char **strp, const char *fmt, va_list ap) } /* Else try again with more space */ - size = retval + 1; /* Precisely what is needed */ + size = retval + 1; /* Precisely what is needed */ np = (char *)SDL_realloc(p, size); if (np == NULL) { diff --git a/src/stdlib/SDL_vacopy.h b/src/stdlib/SDL_vacopy.h index ab6004695..6bb05a5e7 100644 --- a/src/stdlib/SDL_vacopy.h +++ b/src/stdlib/SDL_vacopy.h @@ -22,15 +22,15 @@ /* Do our best to make sure va_copy is working */ #if defined(__NGAGE__) #undef va_copy -#define va_copy(dst, src) dst = src +#define va_copy(dst, src) dst = src #elif defined(_MSC_VER) && _MSC_VER <= 1800 /* Visual Studio 2013 tries to link with _vacopy in the C runtime. Newer versions do an inline assignment */ #undef va_copy -#define va_copy(dst, src) dst = src +#define va_copy(dst, src) dst = src #elif defined(__GNUC__) && (__GNUC__ < 3) -#define va_copy(dst, src) __va_copy(dst, src) +#define va_copy(dst, src) __va_copy(dst, src) #endif /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/test/SDL_test_assert.c b/src/test/SDL_test_assert.c index 7737ca2b0..95d8911b6 100644 --- a/src/test/SDL_test_assert.c +++ b/src/test/SDL_test_assert.c @@ -99,7 +99,7 @@ void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription, SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list); va_end(list); - /* Log pass message */ + /* Log pass message */ SDLTest_AssertsPassed++; SDLTest_Log(SDLTEST_ASSERT_CHECK_FORMAT, logMessage, "Passed"); } diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index 1f6adfc5b..6b1687504 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -46,7 +46,7 @@ static const char *audio_usage[] = { "[--channels N]", "[--samples N]" }; -static void SDL_snprintfcat(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ... ) +static void SDL_snprintfcat(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { size_t length = SDL_strlen(text); va_list ap; @@ -116,18 +116,16 @@ SDLTest_CommonCreateState(char **argv, Uint32 flags) return state; } -#define SEARCHARG(dim) \ - while (*dim && *dim != ',') { \ - ++dim; \ - } \ - if (!*dim) { \ - return -1; \ - } \ +#define SEARCHARG(dim) \ + while (*dim && *dim != ',') { \ + ++dim; \ + } \ + if (!*dim) { \ + return -1; \ + } \ *dim++ = '\0'; - -int -SDLTest_CommonArg(SDLTest_CommonState * state, int index) +int SDLTest_CommonArg(SDLTest_CommonState *state, int index) { char **argv = state->argv; @@ -263,7 +261,7 @@ SDLTest_CommonArg(SDLTest_CommonState * state, int index) } if (SDL_strcasecmp(argv[index], "--windows") == 0) { ++index; - if (!argv[index] || !SDL_isdigit((unsigned char) *argv[index])) { + if (!argv[index] || !SDL_isdigit((unsigned char)*argv[index])) { return -1; } if (!(state->window_flags & SDL_WINDOW_FULLSCREEN)) { @@ -539,7 +537,7 @@ SDLTest_CommonArg(SDLTest_CommonState * state, int index) if (!argv[index]) { return -1; } - state->audiospec.channels = (Uint8) SDL_atoi(argv[index]); + state->audiospec.channels = (Uint8)SDL_atoi(argv[index]); return 2; } if (SDL_strcasecmp(argv[index], "--samples") == 0) { @@ -547,27 +545,25 @@ SDLTest_CommonArg(SDLTest_CommonState * state, int index) if (!argv[index]) { return -1; } - state->audiospec.samples = (Uint16) SDL_atoi(argv[index]); + state->audiospec.samples = (Uint16)SDL_atoi(argv[index]); return 2; } if (SDL_strcasecmp(argv[index], "--trackmem") == 0) { /* Already handled in SDLTest_CommonCreateState() */ return 1; } - if ((SDL_strcasecmp(argv[index], "-h") == 0) - || (SDL_strcasecmp(argv[index], "--help") == 0)) { + if ((SDL_strcasecmp(argv[index], "-h") == 0) || (SDL_strcasecmp(argv[index], "--help") == 0)) { /* Print the usage message */ return -1; } if (SDL_strcmp(argv[index], "-NSDocumentRevisionsDebugMode") == 0) { - /* Debug flag sent by Xcode */ + /* Debug flag sent by Xcode */ return 2; } return 0; } -void -SDLTest_CommonLogUsage(SDLTest_CommonState * state, const char *argv0, const char **options) +void SDLTest_CommonLogUsage(SDLTest_CommonState *state, const char *argv0, const char **options) { int i; @@ -593,8 +589,7 @@ SDLTest_CommonLogUsage(SDLTest_CommonState * state, const char *argv0, const cha } } -static const char * -BuildCommonUsageString(char **pstr, const char **strlist, const int numitems, const char **strlist2, const int numitems2) +static const char *BuildCommonUsageString(char **pstr, const char **strlist, const int numitems, const char **strlist2, const int numitems2) { char *str = *pstr; if (str == NULL) { @@ -608,19 +603,19 @@ BuildCommonUsageString(char **pstr, const char **strlist, const int numitems, co len += SDL_strlen(strlist2[i]) + 1; } } - str = (char *) SDL_calloc(1, len); + str = (char *)SDL_calloc(1, len); if (str == NULL) { - return ""; /* oh well. */ + return ""; /* oh well. */ } SDL_strlcat(str, "[--trackmem] ", len); - for (i = 0; i < numitems-1; i++) { + for (i = 0; i < numitems - 1; i++) { SDL_strlcat(str, strlist[i], len); SDL_strlcat(str, " ", len); } SDL_strlcat(str, strlist[i], len); if (strlist2) { SDL_strlcat(str, " ", len); - for (i = 0; i < numitems2-1; i++) { + for (i = 0; i < numitems2 - 1; i++) { SDL_strlcat(str, strlist2[i], len); SDL_strlcat(str, " ", len); } @@ -636,22 +631,21 @@ static char *common_usage_audio = NULL; static char *common_usage_videoaudio = NULL; const char * -SDLTest_CommonUsage(SDLTest_CommonState * state) +SDLTest_CommonUsage(SDLTest_CommonState *state) { switch (state->flags & (SDL_INIT_VIDEO | SDL_INIT_AUDIO)) { - case SDL_INIT_VIDEO: - return BuildCommonUsageString(&common_usage_video, video_usage, SDL_arraysize(video_usage), NULL, 0); - case SDL_INIT_AUDIO: - return BuildCommonUsageString(&common_usage_audio, audio_usage, SDL_arraysize(audio_usage), NULL, 0); - case (SDL_INIT_VIDEO | SDL_INIT_AUDIO): - return BuildCommonUsageString(&common_usage_videoaudio, video_usage, SDL_arraysize(video_usage), audio_usage, SDL_arraysize(audio_usage)); - default: - return "[--trackmem]"; + case SDL_INIT_VIDEO: + return BuildCommonUsageString(&common_usage_video, video_usage, SDL_arraysize(video_usage), NULL, 0); + case SDL_INIT_AUDIO: + return BuildCommonUsageString(&common_usage_audio, audio_usage, SDL_arraysize(audio_usage), NULL, 0); + case (SDL_INIT_VIDEO | SDL_INIT_AUDIO): + return BuildCommonUsageString(&common_usage_videoaudio, video_usage, SDL_arraysize(video_usage), audio_usage, SDL_arraysize(audio_usage)); + default: + return "[--trackmem]"; } } - SDL_bool SDLTest_CommonDefaultArgs(SDLTest_CommonState *state, const int argc, char **argv) { @@ -667,8 +661,7 @@ SDLTest_CommonDefaultArgs(SDLTest_CommonState *state, const int argc, char **arg return SDL_TRUE; } -static void -SDLTest_PrintDisplayOrientation(char* text, size_t maxlen, SDL_DisplayOrientation orientation) +static void SDLTest_PrintDisplayOrientation(char *text, size_t maxlen, SDL_DisplayOrientation orientation) { switch (orientation) { case SDL_ORIENTATION_UNKNOWN: @@ -692,8 +685,7 @@ SDLTest_PrintDisplayOrientation(char* text, size_t maxlen, SDL_DisplayOrientatio } } -static void -SDLTest_PrintWindowFlag(char* text, size_t maxlen, Uint32 flag) +static void SDLTest_PrintWindowFlag(char *text, size_t maxlen, Uint32 flag) { switch (flag) { case SDL_WINDOW_FULLSCREEN: @@ -771,8 +763,7 @@ SDLTest_PrintWindowFlag(char* text, size_t maxlen, Uint32 flag) } } -static void -SDLTest_PrintWindowFlags(char* text, size_t maxlen, Uint32 flags) +static void SDLTest_PrintWindowFlags(char *text, size_t maxlen, Uint32 flags) { const Uint32 window_flags[] = { SDL_WINDOW_FULLSCREEN, @@ -814,8 +805,7 @@ SDLTest_PrintWindowFlags(char* text, size_t maxlen, Uint32 flags) } } -static void -SDLTest_PrintButtonMask(char* text, size_t maxlen, Uint32 flags) +static void SDLTest_PrintButtonMask(char *text, size_t maxlen, Uint32 flags) { int i; int count = 0; @@ -831,8 +821,7 @@ SDLTest_PrintButtonMask(char* text, size_t maxlen, Uint32 flags) } } -static void -SDLTest_PrintRendererFlag(char *text, size_t maxlen, Uint32 flag) +static void SDLTest_PrintRendererFlag(char *text, size_t maxlen, Uint32 flag) { switch (flag) { case SDL_RENDERER_SOFTWARE: @@ -853,8 +842,7 @@ SDLTest_PrintRendererFlag(char *text, size_t maxlen, Uint32 flag) } } -static void -SDLTest_PrintPixelFormat(char *text, size_t maxlen, Uint32 format) +static void SDLTest_PrintPixelFormat(char *text, size_t maxlen, Uint32 format) { switch (format) { case SDL_PIXELFORMAT_UNKNOWN: @@ -962,8 +950,7 @@ SDLTest_PrintPixelFormat(char *text, size_t maxlen, Uint32 format) } } -static void -SDLTest_PrintRenderer(SDL_RendererInfo * info) +static void SDLTest_PrintRenderer(SDL_RendererInfo *info) { int i, count; char text[1024]; @@ -987,7 +974,7 @@ SDLTest_PrintRenderer(SDL_RendererInfo * info) SDL_Log("%s\n", text); SDL_snprintf(text, sizeof(text), " Texture formats (%" SDL_PRIu32 "): ", info->num_texture_formats); - for (i = 0; i < (int) info->num_texture_formats; ++i) { + for (i = 0; i < (int)info->num_texture_formats; ++i) { if (i > 0) { SDL_snprintfcat(text, sizeof(text), ", "); } @@ -1001,8 +988,7 @@ SDLTest_PrintRenderer(SDL_RendererInfo * info) } } -static SDL_Surface * -SDLTest_LoadIcon(const char *file) +static SDL_Surface *SDLTest_LoadIcon(const char *file) { SDL_Surface *icon; @@ -1015,14 +1001,13 @@ SDLTest_LoadIcon(const char *file) if (icon->format->palette) { /* Set the colorkey */ - SDL_SetColorKey(icon, 1, *((Uint8 *) icon->pixels)); + SDL_SetColorKey(icon, 1, *((Uint8 *)icon->pixels)); } return icon; } -static SDL_HitTestResult SDLCALL -SDLTest_ExampleHitTestCallback(SDL_Window *win, const SDL_Point *area, void *data) +static SDL_HitTestResult SDLCALL SDLTest_ExampleHitTestCallback(SDL_Window *win, const SDL_Point *area, void *data) { int w, h; const int RESIZE_BORDER = 8; @@ -1036,25 +1021,25 @@ SDLTest_ExampleHitTestCallback(SDL_Window *win, const SDL_Point *area, void *dat if (area->y < RESIZE_BORDER) { SDL_Log("SDL_HITTEST_RESIZE_TOPLEFT\n"); return SDL_HITTEST_RESIZE_TOPLEFT; - } else if (area->y >= (h-RESIZE_BORDER)) { + } else if (area->y >= (h - RESIZE_BORDER)) { SDL_Log("SDL_HITTEST_RESIZE_BOTTOMLEFT\n"); return SDL_HITTEST_RESIZE_BOTTOMLEFT; } else { SDL_Log("SDL_HITTEST_RESIZE_LEFT\n"); return SDL_HITTEST_RESIZE_LEFT; } - } else if (area->x >= (w-RESIZE_BORDER)) { + } else if (area->x >= (w - RESIZE_BORDER)) { if (area->y < RESIZE_BORDER) { SDL_Log("SDL_HITTEST_RESIZE_TOPRIGHT\n"); return SDL_HITTEST_RESIZE_TOPRIGHT; - } else if (area->y >= (h-RESIZE_BORDER)) { + } else if (area->y >= (h - RESIZE_BORDER)) { SDL_Log("SDL_HITTEST_RESIZE_BOTTOMRIGHT\n"); return SDL_HITTEST_RESIZE_BOTTOMRIGHT; } else { SDL_Log("SDL_HITTEST_RESIZE_RIGHT\n"); return SDL_HITTEST_RESIZE_RIGHT; } - } else if (area->y >= (h-RESIZE_BORDER)) { + } else if (area->y >= (h - RESIZE_BORDER)) { SDL_Log("SDL_HITTEST_RESIZE_BOTTOM\n"); return SDL_HITTEST_RESIZE_BOTTOM; } else if (area->y < RESIZE_BORDER) { @@ -1068,7 +1053,7 @@ SDLTest_ExampleHitTestCallback(SDL_Window *win, const SDL_Point *area, void *dat } SDL_bool -SDLTest_CommonInit(SDLTest_CommonState * state) +SDLTest_CommonInit(SDLTest_CommonState *state) { int i, j, m, n, w, h; SDL_DisplayMode fullscreen_mode; @@ -1204,7 +1189,7 @@ SDLTest_CommonInit(SDLTest_CommonState * state) #if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* Print the D3D9 adapter index */ - adapterIndex = SDL_Direct3D9GetAdapterIndex( i ); + adapterIndex = SDL_Direct3D9GetAdapterIndex(i); SDL_Log("D3D9 Adapter Index: %d", adapterIndex); /* Print the DXGI adapter and output indices */ @@ -1250,14 +1235,14 @@ SDLTest_CommonInit(SDLTest_CommonState * state) fullscreen_mode.refresh_rate = state->refresh_rate; state->windows = - (SDL_Window **) SDL_calloc(state->num_windows, - sizeof(*state->windows)); + (SDL_Window **)SDL_calloc(state->num_windows, + sizeof(*state->windows)); state->renderers = - (SDL_Renderer **) SDL_calloc(state->num_windows, + (SDL_Renderer **)SDL_calloc(state->num_windows, sizeof(*state->renderers)); state->targets = - (SDL_Texture **) SDL_calloc(state->num_windows, - sizeof(*state->targets)); + (SDL_Texture **)SDL_calloc(state->num_windows, + sizeof(*state->targets)); if (!state->windows || !state->renderers) { SDL_Log("Out of memory!\n"); return SDL_FALSE; @@ -1309,8 +1294,8 @@ SDLTest_CommonInit(SDLTest_CommonState * state) } /* Add resize/drag areas for windows that are borderless and resizable */ - if ((state->window_flags & (SDL_WINDOW_RESIZABLE|SDL_WINDOW_BORDERLESS)) == - (SDL_WINDOW_RESIZABLE|SDL_WINDOW_BORDERLESS)) { + if ((state->window_flags & (SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS)) == + (SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS)) { SDL_SetWindowHitTest(state->windows[i], SDLTest_ExampleHitTestCallback, NULL); } @@ -1328,9 +1313,7 @@ SDLTest_CommonInit(SDLTest_CommonState * state) SDL_SetWindowMouseRect(state->windows[i], &state->confine); } - if (!state->skip_renderer - && (state->renderdriver - || !(state->window_flags & (SDL_WINDOW_OPENGL | SDL_WINDOW_VULKAN | SDL_WINDOW_METAL)))) { + if (!state->skip_renderer && (state->renderdriver || !(state->window_flags & (SDL_WINDOW_OPENGL | SDL_WINDOW_VULKAN | SDL_WINDOW_METAL)))) { m = -1; if (state->renderdriver) { SDL_RendererInfo info; @@ -1349,7 +1332,7 @@ SDLTest_CommonInit(SDLTest_CommonState * state) } } state->renderers[i] = SDL_CreateRenderer(state->windows[i], - m, state->render_flags); + m, state->render_flags); if (!state->renderers[i]) { SDL_Log("Couldn't create renderer: %s\n", SDL_GetError()); @@ -1406,28 +1389,29 @@ SDLTest_CommonInit(SDLTest_CommonState * state) return SDL_TRUE; } -static const char * -DisplayOrientationName(int orientation) +static const char *DisplayOrientationName(int orientation) { - switch (orientation) - { -#define CASE(X) case SDL_ORIENTATION_##X: return #X + switch (orientation) { +#define CASE(X) \ + case SDL_ORIENTATION_##X: \ + return #X CASE(UNKNOWN); CASE(LANDSCAPE); CASE(LANDSCAPE_FLIPPED); CASE(PORTRAIT); CASE(PORTRAIT_FLIPPED); #undef CASE -default: return "???"; + default: + return "???"; } } -static const char * -ControllerAxisName(const SDL_GameControllerAxis axis) +static const char *ControllerAxisName(const SDL_GameControllerAxis axis) { - switch (axis) - { -#define AXIS_CASE(ax) case SDL_CONTROLLER_AXIS_##ax: return #ax + switch (axis) { +#define AXIS_CASE(ax) \ + case SDL_CONTROLLER_AXIS_##ax: \ + return #ax AXIS_CASE(INVALID); AXIS_CASE(LEFTX); AXIS_CASE(LEFTY); @@ -1436,16 +1420,17 @@ ControllerAxisName(const SDL_GameControllerAxis axis) AXIS_CASE(TRIGGERLEFT); AXIS_CASE(TRIGGERRIGHT); #undef AXIS_CASE -default: return "???"; + default: + return "???"; } } -static const char * -ControllerButtonName(const SDL_GameControllerButton button) +static const char *ControllerButtonName(const SDL_GameControllerButton button) { - switch (button) - { -#define BUTTON_CASE(btn) case SDL_CONTROLLER_BUTTON_##btn: return #btn + switch (button) { +#define BUTTON_CASE(btn) \ + case SDL_CONTROLLER_BUTTON_##btn: \ + return #btn BUTTON_CASE(INVALID); BUTTON_CASE(A); BUTTON_CASE(B); @@ -1463,12 +1448,12 @@ ControllerButtonName(const SDL_GameControllerButton button) BUTTON_CASE(DPAD_LEFT); BUTTON_CASE(DPAD_RIGHT); #undef BUTTON_CASE -default: return "???"; + default: + return "???"; } } -static void -SDLTest_PrintEvent(SDL_Event * event) +static void SDLTest_PrintEvent(SDL_Event *event) { switch (event->type) { case SDL_DISPLAYEVENT: @@ -1600,11 +1585,11 @@ SDLTest_PrintEvent(SDL_Event * event) break; case SDL_JOYDEVICEADDED: SDL_Log("SDL EVENT: Joystick index %" SDL_PRIs32 " attached", - event->jdevice.which); + event->jdevice.which); break; case SDL_JOYDEVICEREMOVED: SDL_Log("SDL EVENT: Joystick %" SDL_PRIs32 " removed", - event->jdevice.which); + event->jdevice.which); break; case SDL_JOYBALLMOTION: SDL_Log("SDL EVENT: Joystick %" SDL_PRIs32 ": ball %d moved by %d,%d", @@ -1612,41 +1597,40 @@ SDLTest_PrintEvent(SDL_Event * event) event->jball.yrel); break; case SDL_JOYHATMOTION: - { - const char *position = "UNKNOWN"; - switch (event->jhat.value) { - case SDL_HAT_CENTERED: - position = "CENTER"; - break; - case SDL_HAT_UP: - position = "UP"; - break; - case SDL_HAT_RIGHTUP: - position = "RIGHTUP"; - break; - case SDL_HAT_RIGHT: - position = "RIGHT"; - break; - case SDL_HAT_RIGHTDOWN: - position = "RIGHTDOWN"; - break; - case SDL_HAT_DOWN: - position = "DOWN"; - break; - case SDL_HAT_LEFTDOWN: - position = "LEFTDOWN"; - break; - case SDL_HAT_LEFT: - position = "LEFT"; - break; - case SDL_HAT_LEFTUP: - position = "LEFTUP"; - break; - } - SDL_Log("SDL EVENT: Joystick %" SDL_PRIs32 ": hat %d moved to %s", - event->jhat.which, event->jhat.hat, position); + { + const char *position = "UNKNOWN"; + switch (event->jhat.value) { + case SDL_HAT_CENTERED: + position = "CENTER"; + break; + case SDL_HAT_UP: + position = "UP"; + break; + case SDL_HAT_RIGHTUP: + position = "RIGHTUP"; + break; + case SDL_HAT_RIGHT: + position = "RIGHT"; + break; + case SDL_HAT_RIGHTDOWN: + position = "RIGHTDOWN"; + break; + case SDL_HAT_DOWN: + position = "DOWN"; + break; + case SDL_HAT_LEFTDOWN: + position = "LEFTDOWN"; + break; + case SDL_HAT_LEFT: + position = "LEFT"; + break; + case SDL_HAT_LEFTUP: + position = "LEFTUP"; + break; } - break; + SDL_Log("SDL EVENT: Joystick %" SDL_PRIs32 ": hat %d moved to %s", + event->jhat.which, event->jhat.hat, position); + } break; case SDL_JOYBUTTONDOWN: SDL_Log("SDL EVENT: Joystick %" SDL_PRIs32 ": button %d pressed", event->jbutton.which, event->jbutton.button); @@ -1657,28 +1641,28 @@ SDLTest_PrintEvent(SDL_Event * event) break; case SDL_CONTROLLERDEVICEADDED: SDL_Log("SDL EVENT: Controller index %" SDL_PRIs32 " attached", - event->cdevice.which); + event->cdevice.which); break; case SDL_CONTROLLERDEVICEREMOVED: SDL_Log("SDL EVENT: Controller %" SDL_PRIs32 " removed", - event->cdevice.which); + event->cdevice.which); break; case SDL_CONTROLLERAXISMOTION: SDL_Log("SDL EVENT: Controller %" SDL_PRIs32 " axis %d ('%s') value: %d", - event->caxis.which, - event->caxis.axis, - ControllerAxisName((SDL_GameControllerAxis)event->caxis.axis), - event->caxis.value); + event->caxis.which, + event->caxis.axis, + ControllerAxisName((SDL_GameControllerAxis)event->caxis.axis), + event->caxis.value); break; case SDL_CONTROLLERBUTTONDOWN: SDL_Log("SDL EVENT: Controller %" SDL_PRIs32 "button %d ('%s') down", - event->cbutton.which, event->cbutton.button, - ControllerButtonName((SDL_GameControllerButton)event->cbutton.button)); + event->cbutton.which, event->cbutton.button, + ControllerButtonName((SDL_GameControllerButton)event->cbutton.button)); break; case SDL_CONTROLLERBUTTONUP: SDL_Log("SDL EVENT: Controller %" SDL_PRIs32 " button %d ('%s') up", - event->cbutton.which, event->cbutton.button, - ControllerButtonName((SDL_GameControllerButton)event->cbutton.button)); + event->cbutton.which, event->cbutton.button, + ControllerButtonName((SDL_GameControllerButton)event->cbutton.button)); break; case SDL_CLIPBOARDUPDATE: SDL_Log("SDL EVENT: Clipboard updated"); @@ -1686,8 +1670,8 @@ SDLTest_PrintEvent(SDL_Event * event) case SDL_FINGERMOTION: SDL_Log("SDL EVENT: Finger: motion touch=%ld, finger=%ld, x=%f, y=%f, dx=%f, dy=%f, pressure=%f", - (long) event->tfinger.touchId, - (long) event->tfinger.fingerId, + (long)event->tfinger.touchId, + (long)event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure); break; @@ -1695,16 +1679,16 @@ SDLTest_PrintEvent(SDL_Event * event) case SDL_FINGERUP: SDL_Log("SDL EVENT: Finger: %s touch=%ld, finger=%ld, x=%f, y=%f, dx=%f, dy=%f, pressure=%f", (event->type == SDL_FINGERDOWN) ? "down" : "up", - (long) event->tfinger.touchId, - (long) event->tfinger.fingerId, + (long)event->tfinger.touchId, + (long)event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure); break; case SDL_DOLLARGESTURE: - SDL_Log("SDL_EVENT: Dollar gesture detect: %ld", (long) event->dgesture.gestureId); + SDL_Log("SDL_EVENT: Dollar gesture detect: %ld", (long)event->dgesture.gestureId); break; case SDL_DOLLARRECORD: - SDL_Log("SDL_EVENT: Dollar gesture record: %ld", (long) event->dgesture.gestureId); + SDL_Log("SDL_EVENT: Dollar gesture record: %ld", (long)event->dgesture.gestureId); break; case SDL_MULTIGESTURE: SDL_Log("SDL_EVENT: Multi gesture fingers: %d", event->mgesture.numFingers); @@ -1759,8 +1743,7 @@ SDLTest_PrintEvent(SDL_Event * event) } } -static void -SDLTest_ScreenShot(SDL_Renderer *renderer) +static void SDLTest_ScreenShot(SDL_Renderer *renderer) { SDL_Rect viewport; SDL_Surface *surface; @@ -1772,11 +1755,11 @@ SDLTest_ScreenShot(SDL_Renderer *renderer) SDL_RenderGetViewport(renderer, &viewport); surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, #if SDL_BYTEORDER == SDL_LIL_ENDIAN - 0x00FF0000, 0x0000FF00, 0x000000FF, + 0x00FF0000, 0x0000FF00, 0x000000FF, #else - 0x000000FF, 0x0000FF00, 0x00FF0000, + 0x000000FF, 0x0000FF00, 0x00FF0000, #endif - 0x00000000); + 0x00000000); if (surface == NULL) { SDL_Log("Couldn't create surface: %s\n", SDL_GetError()); return; @@ -1796,8 +1779,7 @@ SDLTest_ScreenShot(SDL_Renderer *renderer) } } -static void -FullscreenTo(int index, int windowId) +static void FullscreenTo(int index, int windowId) { Uint32 flags; struct SDL_Rect rect = { 0, 0, 0, 0 }; @@ -1806,20 +1788,19 @@ FullscreenTo(int index, int windowId) return; } - SDL_GetDisplayBounds( index, &rect ); + SDL_GetDisplayBounds(index, &rect); flags = SDL_GetWindowFlags(window); if (flags & SDL_WINDOW_FULLSCREEN) { - SDL_SetWindowFullscreen( window, 0); - SDL_Delay( 15 ); + SDL_SetWindowFullscreen(window, 0); + SDL_Delay(15); } - SDL_SetWindowPosition( window, rect.x, rect.y ); - SDL_SetWindowFullscreen( window, SDL_WINDOW_FULLSCREEN ); + SDL_SetWindowPosition(window, rect.x, rect.y); + SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN); } -void -SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done) +void SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done) { int i; static SDL_MouseMotionEvent lastEvent; @@ -1836,27 +1817,26 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done) case SDL_WINDOWEVENT: switch (event->window.event) { case SDL_WINDOWEVENT_CLOSE: - { - SDL_Window *window = SDL_GetWindowFromID(event->window.windowID); - if (window) { - for (i = 0; i < state->num_windows; ++i) { - if (window == state->windows[i]) { - if (state->targets[i]) { - SDL_DestroyTexture(state->targets[i]); - state->targets[i] = NULL; - } - if (state->renderers[i]) { - SDL_DestroyRenderer(state->renderers[i]); - state->renderers[i] = NULL; - } - SDL_DestroyWindow(state->windows[i]); - state->windows[i] = NULL; - break; + { + SDL_Window *window = SDL_GetWindowFromID(event->window.windowID); + if (window) { + for (i = 0; i < state->num_windows; ++i) { + if (window == state->windows[i]) { + if (state->targets[i]) { + SDL_DestroyTexture(state->targets[i]); + state->targets[i] = NULL; } + if (state->renderers[i]) { + SDL_DestroyRenderer(state->renderers[i]); + state->renderers[i] = NULL; + } + SDL_DestroyWindow(state->windows[i]); + state->windows[i] = NULL; + break; } } } - break; + } break; case SDL_WINDOWEVENT_FOCUS_LOST: if (state->flash_on_focus_loss) { SDL_Window *window = SDL_GetWindowFromID(event->window.windowID); @@ -1869,24 +1849,25 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done) break; } break; - case SDL_KEYDOWN: { + case SDL_KEYDOWN: + { SDL_bool withControl = !!(event->key.keysym.mod & KMOD_CTRL); SDL_bool withShift = !!(event->key.keysym.mod & KMOD_SHIFT); SDL_bool withAlt = !!(event->key.keysym.mod & KMOD_ALT); switch (event->key.keysym.sym) { /* Add hotkeys here */ - case SDLK_PRINTSCREEN: { - SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); - if (window) { - for (i = 0; i < state->num_windows; ++i) { - if (window == state->windows[i]) { - SDLTest_ScreenShot(state->renderers[i]); - } + case SDLK_PRINTSCREEN: + { + SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); + if (window) { + for (i = 0; i < state->num_windows; ++i) { + if (window == state->windows[i]) { + SDLTest_ScreenShot(state->renderers[i]); } } } - break; + } break; case SDLK_EQUALS: if (withControl) { /* Ctrl-+ double the size of the window */ @@ -1894,7 +1875,7 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done) if (window) { int w, h; SDL_GetWindowSize(window, &w, &h); - SDL_SetWindowSize(window, w*2, h*2); + SDL_SetWindowSize(window, w * 2, h * 2); } } break; @@ -1905,7 +1886,7 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done) if (window) { int w, h; SDL_GetWindowSize(window, &w, &h); - SDL_SetWindowSize(window, w/2, h/2); + SDL_SetWindowSize(window, w / 2, h / 2); } } break; @@ -1929,8 +1910,8 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done) } SDL_Log("Centering on display %d\n", dest); SDL_SetWindowPosition(window, - SDL_WINDOWPOS_CENTERED_DISPLAY(dest), - SDL_WINDOWPOS_CENTERED_DISPLAY(dest)); + SDL_WINDOWPOS_CENTERED_DISPLAY(dest), + SDL_WINDOWPOS_CENTERED_DISPLAY(dest)); } } } @@ -1993,10 +1974,10 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done) SDL_GetWindowSize(state->windows[i], &w, &h); SDL_RenderGetClipRect(state->renderers[i], &clip); if (SDL_RectEmpty(&clip)) { - clip.x = w/4; - clip.y = h/4; - clip.w = w/2; - clip.h = h/2; + clip.x = w / 4; + clip.y = h / 4; + clip.w = w / 2; + clip.h = h / 2; SDL_RenderSetClipRect(state->renderers[i], &clip); } else { SDL_RenderSetClipRect(state->renderers[i], NULL); @@ -2046,7 +2027,7 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done) case SDLK_k: if (withControl) { /* Ctrl-K toggle keyboard grab */ - SDL_Window* window = SDL_GetWindowFromID(event->key.windowID); + SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { SDL_SetWindowKeyboardGrab(window, !SDL_GetWindowKeyboardGrab(window) ? SDL_TRUE : SDL_FALSE); } @@ -2181,7 +2162,7 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done) SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); SDL_snprintf(message, sizeof(message), "(%" SDL_PRIs32 ", %" SDL_PRIs32 "), rel (%" SDL_PRIs32 ", %" SDL_PRIs32 ")\n", - lastEvent.x, lastEvent.y, lastEvent.xrel, lastEvent.yrel); + lastEvent.x, lastEvent.y, lastEvent.xrel, lastEvent.yrel); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Last mouse position", message, window); break; } @@ -2204,8 +2185,7 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done) } } -void -SDLTest_CommonQuit(SDLTest_CommonState * state) +void SDLTest_CommonQuit(SDLTest_CommonState *state) { int i; @@ -2244,8 +2224,7 @@ SDLTest_CommonQuit(SDLTest_CommonState * state) SDLTest_LogAllocations(); } -void -SDLTest_CommonDrawWindowInfo(SDL_Renderer * renderer, SDL_Window * window, int * usedHeight) +void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, int *usedHeight) { char text[1024]; int textY = 0; @@ -2333,7 +2312,7 @@ SDLTest_CommonDrawWindowInfo(SDL_Renderer * renderer, SDL_Window * window, int * if (0 == SDL_GetWindowDisplayMode(window, &mode)) { SDL_snprintf(text, sizeof(text), "SDL_GetWindowDisplayMode: %dx%d@%dHz (%s)", - mode.w, mode.h, mode.refresh_rate, SDL_GetPixelFormatName(mode.format)); + mode.w, mode.h, mode.refresh_rate, SDL_GetPixelFormatName(mode.format)); SDLTest_DrawString(renderer, 0, textY, text); textY += lineHeight; } diff --git a/src/test/SDL_test_compare.c b/src/test/SDL_test_compare.c index 157bd2ff8..78f7406f3 100644 --- a/src/test/SDL_test_compare.c +++ b/src/test/SDL_test_compare.c @@ -31,87 +31,86 @@ #include "SDL_test.h" - /* Counter for _CompareSurface calls; used for filename creation when comparisons fail */ static int _CompareSurfaceCount = 0; /* Compare surfaces */ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error) { - int ret; - int i,j; - int bpp, bpp_reference; - Uint8 *p, *p_reference; - int dist; - int sampleErrorX = 0, sampleErrorY = 0, sampleDist = 0; - Uint8 R, G, B, A; - Uint8 Rd, Gd, Bd, Ad; - char imageFilename[128]; - char referenceFilename[128]; + int ret; + int i, j; + int bpp, bpp_reference; + Uint8 *p, *p_reference; + int dist; + int sampleErrorX = 0, sampleErrorY = 0, sampleDist = 0; + Uint8 R, G, B, A; + Uint8 Rd, Gd, Bd, Ad; + char imageFilename[128]; + char referenceFilename[128]; - /* Validate input surfaces */ - if (surface == NULL || referenceSurface == NULL) { - return -1; - } + /* Validate input surfaces */ + if (surface == NULL || referenceSurface == NULL) { + return -1; + } - /* Make sure surface size is the same. */ - if ((surface->w != referenceSurface->w) || (surface->h != referenceSurface->h)) { - return -2; - } + /* Make sure surface size is the same. */ + if ((surface->w != referenceSurface->w) || (surface->h != referenceSurface->h)) { + return -2; + } - /* Sanitize input value */ - if (allowable_error<0) { - allowable_error = 0; - } + /* Sanitize input value */ + if (allowable_error < 0) { + allowable_error = 0; + } - SDL_LockSurface( surface ); - SDL_LockSurface( referenceSurface ); + SDL_LockSurface(surface); + SDL_LockSurface(referenceSurface); - ret = 0; - bpp = surface->format->BytesPerPixel; - bpp_reference = referenceSurface->format->BytesPerPixel; - /* Compare image - should be same format. */ - for (j=0; jh; j++) { - for (i=0; iw; i++) { - p = (Uint8 *)surface->pixels + j * surface->pitch + i * bpp; - p_reference = (Uint8 *)referenceSurface->pixels + j * referenceSurface->pitch + i * bpp_reference; + ret = 0; + bpp = surface->format->BytesPerPixel; + bpp_reference = referenceSurface->format->BytesPerPixel; + /* Compare image - should be same format. */ + for (j = 0; j < surface->h; j++) { + for (i = 0; i < surface->w; i++) { + p = (Uint8 *)surface->pixels + j * surface->pitch + i * bpp; + p_reference = (Uint8 *)referenceSurface->pixels + j * referenceSurface->pitch + i * bpp_reference; - SDL_GetRGBA(*(Uint32*)p, surface->format, &R, &G, &B, &A); - SDL_GetRGBA(*(Uint32*)p_reference, referenceSurface->format, &Rd, &Gd, &Bd, &Ad); + SDL_GetRGBA(*(Uint32 *)p, surface->format, &R, &G, &B, &A); + SDL_GetRGBA(*(Uint32 *)p_reference, referenceSurface->format, &Rd, &Gd, &Bd, &Ad); - dist = 0; - dist += (R-Rd)*(R-Rd); - dist += (G-Gd)*(G-Gd); - dist += (B-Bd)*(B-Bd); + dist = 0; + dist += (R - Rd) * (R - Rd); + dist += (G - Gd) * (G - Gd); + dist += (B - Bd) * (B - Bd); - /* Allow some difference in blending accuracy */ - if (dist > allowable_error) { - ret++; - if (ret == 1) { - sampleErrorX = i; - sampleErrorY = j; - sampleDist = dist; + /* Allow some difference in blending accuracy */ + if (dist > allowable_error) { + ret++; + if (ret == 1) { + sampleErrorX = i; + sampleErrorY = j; + sampleDist = dist; + } } - } - } - } + } + } - SDL_UnlockSurface( surface ); - SDL_UnlockSurface( referenceSurface ); + SDL_UnlockSurface(surface); + SDL_UnlockSurface(referenceSurface); - /* Save test image and reference for analysis on failures */ - _CompareSurfaceCount++; - if (ret != 0) { - SDLTest_LogError("Comparison of pixels with allowable error of %i failed %i times.", allowable_error, ret); - SDLTest_LogError("First detected occurrence at position %i,%i with a squared RGB-difference of %i.", sampleErrorX, sampleErrorY, sampleDist); - SDL_snprintf(imageFilename, 127, "CompareSurfaces%04d_TestOutput.bmp", _CompareSurfaceCount); - SDL_SaveBMP(surface, imageFilename); - SDL_snprintf(referenceFilename, 127, "CompareSurfaces%04d_Reference.bmp", _CompareSurfaceCount); - SDL_SaveBMP(referenceSurface, referenceFilename); - SDLTest_LogError("Surfaces from failed comparison saved as '%s' and '%s'", imageFilename, referenceFilename); - } + /* Save test image and reference for analysis on failures */ + _CompareSurfaceCount++; + if (ret != 0) { + SDLTest_LogError("Comparison of pixels with allowable error of %i failed %i times.", allowable_error, ret); + SDLTest_LogError("First detected occurrence at position %i,%i with a squared RGB-difference of %i.", sampleErrorX, sampleErrorY, sampleDist); + SDL_snprintf(imageFilename, 127, "CompareSurfaces%04d_TestOutput.bmp", _CompareSurfaceCount); + SDL_SaveBMP(surface, imageFilename); + SDL_snprintf(referenceFilename, 127, "CompareSurfaces%04d_Reference.bmp", _CompareSurfaceCount); + SDL_SaveBMP(referenceSurface, referenceFilename); + SDLTest_LogError("Surfaces from failed comparison saved as '%s' and '%s'", imageFilename, referenceFilename); + } - return ret; + return ret; } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/test/SDL_test_crc32.c b/src/test/SDL_test_crc32.c index cfc5a641c..a9639107f 100644 --- a/src/test/SDL_test_crc32.c +++ b/src/test/SDL_test_crc32.c @@ -30,137 +30,136 @@ #include "SDL_test.h" - int SDLTest_Crc32Init(SDLTest_Crc32Context *crcContext) { - int i,j; - CrcUint32 c; + int i, j; + CrcUint32 c; - /* Sanity check context pointer */ - if (crcContext==NULL) { - return -1; - } + /* Sanity check context pointer */ + if (crcContext == NULL) { + return -1; + } - /* - * Build auxiliary table for parallel byte-at-a-time CRC-32 - */ + /* + * Build auxiliary table for parallel byte-at-a-time CRC-32 + */ #ifdef ORIGINAL_METHOD - for (i = 0; i < 256; ++i) { - for (c = i << 24, j = 8; j > 0; --j) { - c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1); + for (i = 0; i < 256; ++i) { + for (c = i << 24, j = 8; j > 0; --j) { + c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1); + } + crcContext->crc32_table[i] = c; } - crcContext->crc32_table[i] = c; - } #else - for (i=0; i<256; i++) { - c = i; - for (j=8; j>0; j--) { - if (c & 1) { - c = (c >> 1) ^ CRC32_POLY; - } else { - c >>= 1; + for (i = 0; i < 256; i++) { + c = i; + for (j = 8; j > 0; j--) { + if (c & 1) { + c = (c >> 1) ^ CRC32_POLY; + } else { + c >>= 1; + } + } + crcContext->crc32_table[i] = c; } - } - crcContext->crc32_table[i] = c; - } #endif - return 0; + return 0; } /* Complete CRC32 calculation on a memory block */ -int SDLTest_Crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32) +int SDLTest_Crc32Calc(SDLTest_Crc32Context *crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32) { - if (SDLTest_Crc32CalcStart(crcContext,crc32)) { - return -1; - } + if (SDLTest_Crc32CalcStart(crcContext, crc32)) { + return -1; + } - if (SDLTest_Crc32CalcBuffer(crcContext, inBuf, inLen, crc32)) { - return -1; - } + if (SDLTest_Crc32CalcBuffer(crcContext, inBuf, inLen, crc32)) { + return -1; + } - if (SDLTest_Crc32CalcEnd(crcContext, crc32)) { - return -1; - } + if (SDLTest_Crc32CalcEnd(crcContext, crc32)) { + return -1; + } - return 0; + return 0; } /* Start crc calculation */ -int SDLTest_Crc32CalcStart(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32) +int SDLTest_Crc32CalcStart(SDLTest_Crc32Context *crcContext, CrcUint32 *crc32) { - /* Sanity check pointers */ - if (crcContext==NULL) { - *crc32=0; - return -1; - } + /* Sanity check pointers */ + if (crcContext == NULL) { + *crc32 = 0; + return -1; + } - /* - * Preload shift register, per CRC-32 spec - */ - *crc32 = 0xffffffff; + /* + * Preload shift register, per CRC-32 spec + */ + *crc32 = 0xffffffff; - return 0; + return 0; } /* Finish crc calculation */ -int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32) +int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context *crcContext, CrcUint32 *crc32) { - /* Sanity check pointers */ - if (crcContext==NULL) { - *crc32=0; - return -1; - } + /* Sanity check pointers */ + if (crcContext == NULL) { + *crc32 = 0; + return -1; + } - /* - * Return complement, per CRC-32 spec - */ - *crc32 = (~(*crc32)); + /* + * Return complement, per CRC-32 spec + */ + *crc32 = (~(*crc32)); - return 0; + return 0; } /* Include memory block in crc */ -int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32) +int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context *crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32) { - CrcUint8 *p; - register CrcUint32 crc; + CrcUint8 *p; + register CrcUint32 crc; - if (crcContext==NULL) { - *crc32=0; - return -1; - } + if (crcContext == NULL) { + *crc32 = 0; + return -1; + } - if (inBuf==NULL) { - return -1; - } + if (inBuf == NULL) { + return -1; + } - /* - * Calculate CRC from data - */ - crc = *crc32; - for (p = inBuf; inLen > 0; ++p, --inLen) { + /* + * Calculate CRC from data + */ + crc = *crc32; + for (p = inBuf; inLen > 0; ++p, --inLen) { #ifdef ORIGINAL_METHOD - crc = (crc << 8) ^ crcContext->crc32_table[(crc >> 24) ^ *p]; + crc = (crc << 8) ^ crcContext->crc32_table[(crc >> 24) ^ *p]; #else - crc = ((crc >> 8) & 0x00FFFFFF) ^ crcContext->crc32_table[ (crc ^ *p) & 0xFF ]; + crc = ((crc >> 8) & 0x00FFFFFF) ^ crcContext->crc32_table[(crc ^ *p) & 0xFF]; #endif - } - *crc32 = crc; + } + *crc32 = crc; - return 0; + return 0; } -int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext) +int SDLTest_Crc32Done(SDLTest_Crc32Context *crcContext) { - if (crcContext==NULL) { - return -1; - } + if (crcContext == NULL) { + return -1; + } - return 0; + return 0; } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/test/SDL_test_font.c b/src/test/SDL_test_font.c index bbf0f2f40..1355d559e 100644 --- a/src/test/SDL_test_font.c +++ b/src/test/SDL_test_font.c @@ -42,3085 +42,3085 @@ static unsigned char SDLTest_FontData[] = { /* * 0 0x00 '^@' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 1 0x01 '^A' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 2 0x02 '^B' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 3 0x03 '^C' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 4 0x04 '^D' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 5 0x05 '^E' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 6 0x06 '^F' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 7 0x07 '^G' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 8 0x08 '^H' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 9 0x09 '^I' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 10 0x0a '^J' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 11 0x0b '^K' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 12 0x0c '^L' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 13 0x0d '^M' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 14 0x0e '^N' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 15 0x0f '^O' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 16 0x10 '^P' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 17 0x11 '^Q' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 18 0x12 '^R' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 19 0x13 '^S' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 20 0x14 '^T' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 21 0x15 '^U' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 22 0x16 '^V' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 23 0x17 '^W' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 24 0x18 '^X' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 25 0x19 '^Y' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 26 0x1a '^Z' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 27 0x1b '^[' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 28 0x1c '^\' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 29 0x1d '^]' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 30 0x1e '^^' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 31 0x1f '^_' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 32 0x20 ' ' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 33 0x21 '!' */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ /* * 34 0x22 '"' */ - 0x36, /* 01101100 */ - 0x36, /* 01101100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x36, /* 01101100 */ + 0x36, /* 01101100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 35 0x23 '#' */ - 0x36, /* 01101100 */ - 0x36, /* 01101100 */ - 0x7f, /* 11111110 */ - 0x36, /* 01101100 */ - 0x7f, /* 11111110 */ - 0x36, /* 01101100 */ - 0x36, /* 01101100 */ - 0x00, /* 00000000 */ + 0x36, /* 01101100 */ + 0x36, /* 01101100 */ + 0x7f, /* 11111110 */ + 0x36, /* 01101100 */ + 0x7f, /* 11111110 */ + 0x36, /* 01101100 */ + 0x36, /* 01101100 */ + 0x00, /* 00000000 */ /* * 36 0x24 '$' */ - 0x0c, /* 00110000 */ - 0x3e, /* 01111100 */ - 0x03, /* 11000000 */ - 0x1e, /* 01111000 */ - 0x30, /* 00001100 */ - 0x1f, /* 11111000 */ - 0x0c, /* 00110000 */ - 0x00, /* 00000000 */ + 0x0c, /* 00110000 */ + 0x3e, /* 01111100 */ + 0x03, /* 11000000 */ + 0x1e, /* 01111000 */ + 0x30, /* 00001100 */ + 0x1f, /* 11111000 */ + 0x0c, /* 00110000 */ + 0x00, /* 00000000 */ /* * 37 0x25 '%' */ - 0x00, /* 00000000 */ - 0x63, /* 11000110 */ - 0x33, /* 11001100 */ - 0x18, /* 00011000 */ - 0x0c, /* 00110000 */ - 0x66, /* 01100110 */ - 0x63, /* 11000110 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x63, /* 11000110 */ + 0x33, /* 11001100 */ + 0x18, /* 00011000 */ + 0x0c, /* 00110000 */ + 0x66, /* 01100110 */ + 0x63, /* 11000110 */ + 0x00, /* 00000000 */ /* * 38 0x26 '&' */ - 0x1c, /* 00111000 */ - 0x36, /* 01101100 */ - 0x1c, /* 00111000 */ - 0x6e, /* 01110110 */ - 0x3b, /* 11011100 */ - 0x33, /* 11001100 */ - 0x6e, /* 01110110 */ - 0x00, /* 00000000 */ + 0x1c, /* 00111000 */ + 0x36, /* 01101100 */ + 0x1c, /* 00111000 */ + 0x6e, /* 01110110 */ + 0x3b, /* 11011100 */ + 0x33, /* 11001100 */ + 0x6e, /* 01110110 */ + 0x00, /* 00000000 */ /* * 39 0x27 ''' */ - 0x06, /* 01100000 */ - 0x06, /* 01100000 */ - 0x03, /* 11000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x06, /* 01100000 */ + 0x06, /* 01100000 */ + 0x03, /* 11000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 40 0x28 '(' */ - 0x18, /* 00011000 */ - 0x0c, /* 00110000 */ - 0x06, /* 01100000 */ - 0x06, /* 01100000 */ - 0x06, /* 01100000 */ - 0x0c, /* 00110000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00110000 */ + 0x06, /* 01100000 */ + 0x06, /* 01100000 */ + 0x06, /* 01100000 */ + 0x0c, /* 00110000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ /* * 41 0x29 ')' */ - 0x06, /* 01100000 */ - 0x0c, /* 00110000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00110000 */ - 0x06, /* 01100000 */ - 0x00, /* 00000000 */ + 0x06, /* 01100000 */ + 0x0c, /* 00110000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00110000 */ + 0x06, /* 01100000 */ + 0x00, /* 00000000 */ /* * 42 0x2a '*' */ - 0x00, /* 00000000 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0xff, /* 11111111 */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0xff, /* 11111111 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 43 0x2b '+' */ - 0x00, /* 00000000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x3f, /* 11111100 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x3f, /* 11111100 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 44 0x2c ',' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x06, /* 01100000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x06, /* 01100000 */ /* * 45 0x2d '-' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x3f, /* 11111100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x3f, /* 11111100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 46 0x2e '.' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x00, /* 00000000 */ /* * 47 0x2f '/' */ - 0x60, /* 00000110 */ - 0x30, /* 00001100 */ - 0x18, /* 00011000 */ - 0x0c, /* 00110000 */ - 0x06, /* 01100000 */ - 0x03, /* 11000000 */ - 0x01, /* 10000000 */ - 0x00, /* 00000000 */ + 0x60, /* 00000110 */ + 0x30, /* 00001100 */ + 0x18, /* 00011000 */ + 0x0c, /* 00110000 */ + 0x06, /* 01100000 */ + 0x03, /* 11000000 */ + 0x01, /* 10000000 */ + 0x00, /* 00000000 */ /* * 48 0x30 '0' */ - 0x3e, /* 01111100 */ - 0x63, /* 11000110 */ - 0x73, /* 11001110 */ - 0x7b, /* 11011110 */ - 0x6f, /* 11110110 */ - 0x67, /* 11100110 */ - 0x3e, /* 01111100 */ - 0x00, /* 00000000 */ + 0x3e, /* 01111100 */ + 0x63, /* 11000110 */ + 0x73, /* 11001110 */ + 0x7b, /* 11011110 */ + 0x6f, /* 11110110 */ + 0x67, /* 11100110 */ + 0x3e, /* 01111100 */ + 0x00, /* 00000000 */ /* * 49 0x31 '1' */ - 0x0c, /* 00110000 */ - 0x0e, /* 01110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x3f, /* 11111100 */ - 0x00, /* 00000000 */ + 0x0c, /* 00110000 */ + 0x0e, /* 01110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x3f, /* 11111100 */ + 0x00, /* 00000000 */ /* * 50 0x32 '2' */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x30, /* 00001100 */ - 0x1c, /* 00111000 */ - 0x06, /* 01100000 */ - 0x33, /* 11001100 */ - 0x3f, /* 11111100 */ - 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x30, /* 00001100 */ + 0x1c, /* 00111000 */ + 0x06, /* 01100000 */ + 0x33, /* 11001100 */ + 0x3f, /* 11111100 */ + 0x00, /* 00000000 */ /* * 51 0x33 '3' */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x30, /* 00001100 */ - 0x1c, /* 00111000 */ - 0x30, /* 00001100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x30, /* 00001100 */ + 0x1c, /* 00111000 */ + 0x30, /* 00001100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 52 0x34 '4' */ - 0x38, /* 00011100 */ - 0x3c, /* 00111100 */ - 0x36, /* 01101100 */ - 0x33, /* 11001100 */ - 0x7f, /* 11111110 */ - 0x30, /* 00001100 */ - 0x78, /* 00011110 */ - 0x00, /* 00000000 */ + 0x38, /* 00011100 */ + 0x3c, /* 00111100 */ + 0x36, /* 01101100 */ + 0x33, /* 11001100 */ + 0x7f, /* 11111110 */ + 0x30, /* 00001100 */ + 0x78, /* 00011110 */ + 0x00, /* 00000000 */ /* * 53 0x35 '5' */ - 0x3f, /* 11111100 */ - 0x03, /* 11000000 */ - 0x1f, /* 11111000 */ - 0x30, /* 00001100 */ - 0x30, /* 00001100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x3f, /* 11111100 */ + 0x03, /* 11000000 */ + 0x1f, /* 11111000 */ + 0x30, /* 00001100 */ + 0x30, /* 00001100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 54 0x36 '6' */ - 0x1c, /* 00111000 */ - 0x06, /* 01100000 */ - 0x03, /* 11000000 */ - 0x1f, /* 11111000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x1c, /* 00111000 */ + 0x06, /* 01100000 */ + 0x03, /* 11000000 */ + 0x1f, /* 11111000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 55 0x37 '7' */ - 0x3f, /* 11111100 */ - 0x33, /* 11001100 */ - 0x30, /* 00001100 */ - 0x18, /* 00011000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x00, /* 00000000 */ + 0x3f, /* 11111100 */ + 0x33, /* 11001100 */ + 0x30, /* 00001100 */ + 0x18, /* 00011000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x00, /* 00000000 */ /* * 56 0x38 '8' */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 57 0x39 '9' */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x3e, /* 01111100 */ - 0x30, /* 00001100 */ - 0x18, /* 00011000 */ - 0x0e, /* 01110000 */ - 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x3e, /* 01111100 */ + 0x30, /* 00001100 */ + 0x18, /* 00011000 */ + 0x0e, /* 01110000 */ + 0x00, /* 00000000 */ /* * 58 0x3a ':' */ - 0x00, /* 00000000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x00, /* 00000000 */ /* * 59 0x3b ';' */ - 0x00, /* 00000000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x06, /* 01100000 */ + 0x00, /* 00000000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x06, /* 01100000 */ /* * 60 0x3c '<' */ - 0x18, /* 00011000 */ - 0x0c, /* 00110000 */ - 0x06, /* 01100000 */ - 0x03, /* 11000000 */ - 0x06, /* 01100000 */ - 0x0c, /* 00110000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00110000 */ + 0x06, /* 01100000 */ + 0x03, /* 11000000 */ + 0x06, /* 01100000 */ + 0x0c, /* 00110000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ /* * 61 0x3d '=' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x3f, /* 11111100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x3f, /* 11111100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x3f, /* 11111100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x3f, /* 11111100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 62 0x3e '>' */ - 0x06, /* 01100000 */ - 0x0c, /* 00110000 */ - 0x18, /* 00011000 */ - 0x30, /* 00001100 */ - 0x18, /* 00011000 */ - 0x0c, /* 00110000 */ - 0x06, /* 01100000 */ - 0x00, /* 00000000 */ + 0x06, /* 01100000 */ + 0x0c, /* 00110000 */ + 0x18, /* 00011000 */ + 0x30, /* 00001100 */ + 0x18, /* 00011000 */ + 0x0c, /* 00110000 */ + 0x06, /* 01100000 */ + 0x00, /* 00000000 */ /* * 63 0x3f '?' */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x30, /* 00001100 */ - 0x18, /* 00011000 */ - 0x0c, /* 00110000 */ - 0x00, /* 00000000 */ - 0x0c, /* 00110000 */ - 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x30, /* 00001100 */ + 0x18, /* 00011000 */ + 0x0c, /* 00110000 */ + 0x00, /* 00000000 */ + 0x0c, /* 00110000 */ + 0x00, /* 00000000 */ /* * 64 0x40 '@' */ - 0x3e, /* 01111100 */ - 0x63, /* 11000110 */ - 0x7b, /* 11011110 */ - 0x7b, /* 11011110 */ - 0x7b, /* 11011110 */ - 0x03, /* 11000000 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x3e, /* 01111100 */ + 0x63, /* 11000110 */ + 0x7b, /* 11011110 */ + 0x7b, /* 11011110 */ + 0x7b, /* 11011110 */ + 0x03, /* 11000000 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 65 0x41 'A' */ - 0x0c, /* 00110000 */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x3f, /* 11111100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x00, /* 00000000 */ + 0x0c, /* 00110000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x3f, /* 11111100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x00, /* 00000000 */ /* * 66 0x42 'B' */ - 0x3f, /* 11111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3e, /* 01111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3f, /* 11111100 */ - 0x00, /* 00000000 */ + 0x3f, /* 11111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3e, /* 01111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3f, /* 11111100 */ + 0x00, /* 00000000 */ /* * 67 0x43 'C' */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x03, /* 11000000 */ - 0x03, /* 11000000 */ - 0x03, /* 11000000 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x03, /* 11000000 */ + 0x03, /* 11000000 */ + 0x03, /* 11000000 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ /* * 68 0x44 'D' */ - 0x1f, /* 11111000 */ - 0x36, /* 01101100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x36, /* 01101100 */ - 0x1f, /* 11111000 */ - 0x00, /* 00000000 */ + 0x1f, /* 11111000 */ + 0x36, /* 01101100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x36, /* 01101100 */ + 0x1f, /* 11111000 */ + 0x00, /* 00000000 */ /* * 69 0x45 'E' */ - 0x7f, /* 11111110 */ - 0x46, /* 01100010 */ - 0x16, /* 01101000 */ - 0x1e, /* 01111000 */ - 0x16, /* 01101000 */ - 0x46, /* 01100010 */ - 0x7f, /* 11111110 */ - 0x00, /* 00000000 */ + 0x7f, /* 11111110 */ + 0x46, /* 01100010 */ + 0x16, /* 01101000 */ + 0x1e, /* 01111000 */ + 0x16, /* 01101000 */ + 0x46, /* 01100010 */ + 0x7f, /* 11111110 */ + 0x00, /* 00000000 */ /* * 70 0x46 'F' */ - 0x7f, /* 11111110 */ - 0x46, /* 01100010 */ - 0x16, /* 01101000 */ - 0x1e, /* 01111000 */ - 0x16, /* 01101000 */ - 0x06, /* 01100000 */ - 0x0f, /* 11110000 */ - 0x00, /* 00000000 */ + 0x7f, /* 11111110 */ + 0x46, /* 01100010 */ + 0x16, /* 01101000 */ + 0x1e, /* 01111000 */ + 0x16, /* 01101000 */ + 0x06, /* 01100000 */ + 0x0f, /* 11110000 */ + 0x00, /* 00000000 */ /* * 71 0x47 'G' */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x03, /* 11000000 */ - 0x03, /* 11000000 */ - 0x73, /* 11001110 */ - 0x66, /* 01100110 */ - 0x7c, /* 00111110 */ - 0x00, /* 00000000 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x03, /* 11000000 */ + 0x03, /* 11000000 */ + 0x73, /* 11001110 */ + 0x66, /* 01100110 */ + 0x7c, /* 00111110 */ + 0x00, /* 00000000 */ /* * 72 0x48 'H' */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x3f, /* 11111100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x3f, /* 11111100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x00, /* 00000000 */ /* * 73 0x49 'I' */ - 0x1e, /* 01111000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 74 0x4a 'J' */ - 0x78, /* 00011110 */ - 0x30, /* 00001100 */ - 0x30, /* 00001100 */ - 0x30, /* 00001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x78, /* 00011110 */ + 0x30, /* 00001100 */ + 0x30, /* 00001100 */ + 0x30, /* 00001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 75 0x4b 'K' */ - 0x67, /* 11100110 */ - 0x66, /* 01100110 */ - 0x36, /* 01101100 */ - 0x1e, /* 01111000 */ - 0x36, /* 01101100 */ - 0x66, /* 01100110 */ - 0x67, /* 11100110 */ - 0x00, /* 00000000 */ + 0x67, /* 11100110 */ + 0x66, /* 01100110 */ + 0x36, /* 01101100 */ + 0x1e, /* 01111000 */ + 0x36, /* 01101100 */ + 0x66, /* 01100110 */ + 0x67, /* 11100110 */ + 0x00, /* 00000000 */ /* * 76 0x4c 'L' */ - 0x0f, /* 11110000 */ - 0x06, /* 01100000 */ - 0x06, /* 01100000 */ - 0x06, /* 01100000 */ - 0x46, /* 01100010 */ - 0x66, /* 01100110 */ - 0x7f, /* 11111110 */ - 0x00, /* 00000000 */ + 0x0f, /* 11110000 */ + 0x06, /* 01100000 */ + 0x06, /* 01100000 */ + 0x06, /* 01100000 */ + 0x46, /* 01100010 */ + 0x66, /* 01100110 */ + 0x7f, /* 11111110 */ + 0x00, /* 00000000 */ /* * 77 0x4d 'M' */ - 0x63, /* 11000110 */ - 0x77, /* 11101110 */ - 0x7f, /* 11111110 */ - 0x7f, /* 11111110 */ - 0x6b, /* 11010110 */ - 0x63, /* 11000110 */ - 0x63, /* 11000110 */ - 0x00, /* 00000000 */ + 0x63, /* 11000110 */ + 0x77, /* 11101110 */ + 0x7f, /* 11111110 */ + 0x7f, /* 11111110 */ + 0x6b, /* 11010110 */ + 0x63, /* 11000110 */ + 0x63, /* 11000110 */ + 0x00, /* 00000000 */ /* * 78 0x4e 'N' */ - 0x63, /* 11000110 */ - 0x67, /* 11100110 */ - 0x6f, /* 11110110 */ - 0x7b, /* 11011110 */ - 0x73, /* 11001110 */ - 0x63, /* 11000110 */ - 0x63, /* 11000110 */ - 0x00, /* 00000000 */ + 0x63, /* 11000110 */ + 0x67, /* 11100110 */ + 0x6f, /* 11110110 */ + 0x7b, /* 11011110 */ + 0x73, /* 11001110 */ + 0x63, /* 11000110 */ + 0x63, /* 11000110 */ + 0x00, /* 00000000 */ /* * 79 0x4f 'O' */ - 0x1c, /* 00111000 */ - 0x36, /* 01101100 */ - 0x63, /* 11000110 */ - 0x63, /* 11000110 */ - 0x63, /* 11000110 */ - 0x36, /* 01101100 */ - 0x1c, /* 00111000 */ - 0x00, /* 00000000 */ + 0x1c, /* 00111000 */ + 0x36, /* 01101100 */ + 0x63, /* 11000110 */ + 0x63, /* 11000110 */ + 0x63, /* 11000110 */ + 0x36, /* 01101100 */ + 0x1c, /* 00111000 */ + 0x00, /* 00000000 */ /* * 80 0x50 'P' */ - 0x3f, /* 11111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3e, /* 01111100 */ - 0x06, /* 01100000 */ - 0x06, /* 01100000 */ - 0x0f, /* 11110000 */ - 0x00, /* 00000000 */ + 0x3f, /* 11111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3e, /* 01111100 */ + 0x06, /* 01100000 */ + 0x06, /* 01100000 */ + 0x0f, /* 11110000 */ + 0x00, /* 00000000 */ /* * 81 0x51 'Q' */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x3b, /* 11011100 */ - 0x1e, /* 01111000 */ - 0x38, /* 00011100 */ - 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x3b, /* 11011100 */ + 0x1e, /* 01111000 */ + 0x38, /* 00011100 */ + 0x00, /* 00000000 */ /* * 82 0x52 'R' */ - 0x3f, /* 11111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3e, /* 01111100 */ - 0x36, /* 01101100 */ - 0x66, /* 01100110 */ - 0x67, /* 11100110 */ - 0x00, /* 00000000 */ + 0x3f, /* 11111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3e, /* 01111100 */ + 0x36, /* 01101100 */ + 0x66, /* 01100110 */ + 0x67, /* 11100110 */ + 0x00, /* 00000000 */ /* * 83 0x53 'S' */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x07, /* 11100000 */ - 0x0e, /* 01110000 */ - 0x38, /* 00011100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x07, /* 11100000 */ + 0x0e, /* 01110000 */ + 0x38, /* 00011100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 84 0x54 'T' */ - 0x3f, /* 11111100 */ - 0x2d, /* 10110100 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x3f, /* 11111100 */ + 0x2d, /* 10110100 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 85 0x55 'U' */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x3f, /* 11111100 */ - 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x3f, /* 11111100 */ + 0x00, /* 00000000 */ /* * 86 0x56 'V' */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x0c, /* 00110000 */ - 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x0c, /* 00110000 */ + 0x00, /* 00000000 */ /* * 87 0x57 'W' */ - 0x63, /* 11000110 */ - 0x63, /* 11000110 */ - 0x63, /* 11000110 */ - 0x6b, /* 11010110 */ - 0x7f, /* 11111110 */ - 0x77, /* 11101110 */ - 0x63, /* 11000110 */ - 0x00, /* 00000000 */ + 0x63, /* 11000110 */ + 0x63, /* 11000110 */ + 0x63, /* 11000110 */ + 0x6b, /* 11010110 */ + 0x7f, /* 11111110 */ + 0x77, /* 11101110 */ + 0x63, /* 11000110 */ + 0x00, /* 00000000 */ /* * 88 0x58 'X' */ - 0x63, /* 11000110 */ - 0x63, /* 11000110 */ - 0x36, /* 01101100 */ - 0x1c, /* 00111000 */ - 0x1c, /* 00111000 */ - 0x36, /* 01101100 */ - 0x63, /* 11000110 */ - 0x00, /* 00000000 */ + 0x63, /* 11000110 */ + 0x63, /* 11000110 */ + 0x36, /* 01101100 */ + 0x1c, /* 00111000 */ + 0x1c, /* 00111000 */ + 0x36, /* 01101100 */ + 0x63, /* 11000110 */ + 0x00, /* 00000000 */ /* * 89 0x59 'Y' */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 90 0x5a 'Z' */ - 0x7f, /* 11111110 */ - 0x63, /* 11000110 */ - 0x31, /* 10001100 */ - 0x18, /* 00011000 */ - 0x4c, /* 00110010 */ - 0x66, /* 01100110 */ - 0x7f, /* 11111110 */ - 0x00, /* 00000000 */ + 0x7f, /* 11111110 */ + 0x63, /* 11000110 */ + 0x31, /* 10001100 */ + 0x18, /* 00011000 */ + 0x4c, /* 00110010 */ + 0x66, /* 01100110 */ + 0x7f, /* 11111110 */ + 0x00, /* 00000000 */ /* * 91 0x5b '[' */ - 0x1e, /* 01111000 */ - 0x06, /* 01100000 */ - 0x06, /* 01100000 */ - 0x06, /* 01100000 */ - 0x06, /* 01100000 */ - 0x06, /* 01100000 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x06, /* 01100000 */ + 0x06, /* 01100000 */ + 0x06, /* 01100000 */ + 0x06, /* 01100000 */ + 0x06, /* 01100000 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 92 0x5c '\' */ - 0x03, /* 11000000 */ - 0x06, /* 01100000 */ - 0x0c, /* 00110000 */ - 0x18, /* 00011000 */ - 0x30, /* 00001100 */ - 0x60, /* 00000110 */ - 0x40, /* 00000010 */ - 0x00, /* 00000000 */ + 0x03, /* 11000000 */ + 0x06, /* 01100000 */ + 0x0c, /* 00110000 */ + 0x18, /* 00011000 */ + 0x30, /* 00001100 */ + 0x60, /* 00000110 */ + 0x40, /* 00000010 */ + 0x00, /* 00000000 */ /* * 93 0x5d ']' */ - 0x1e, /* 01111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 94 0x5e '^' */ - 0x08, /* 00010000 */ - 0x1c, /* 00111000 */ - 0x36, /* 01101100 */ - 0x63, /* 11000110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x08, /* 00010000 */ + 0x1c, /* 00111000 */ + 0x36, /* 01101100 */ + 0x63, /* 11000110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 95 0x5f '_' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ /* * 96 0x60 '`' */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 97 0x61 'a' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x30, /* 00001100 */ - 0x3e, /* 01111100 */ - 0x33, /* 11001100 */ - 0x6e, /* 01110110 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x30, /* 00001100 */ + 0x3e, /* 01111100 */ + 0x33, /* 11001100 */ + 0x6e, /* 01110110 */ + 0x00, /* 00000000 */ /* * 98 0x62 'b' */ - 0x07, /* 11100000 */ - 0x06, /* 01100000 */ - 0x06, /* 01100000 */ - 0x3e, /* 01111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3b, /* 11011100 */ - 0x00, /* 00000000 */ + 0x07, /* 11100000 */ + 0x06, /* 01100000 */ + 0x06, /* 01100000 */ + 0x3e, /* 01111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3b, /* 11011100 */ + 0x00, /* 00000000 */ /* * 99 0x63 'c' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x03, /* 11000000 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x03, /* 11000000 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 100 0x64 'd' */ - 0x38, /* 00011100 */ - 0x30, /* 00001100 */ - 0x30, /* 00001100 */ - 0x3e, /* 01111100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x6e, /* 01110110 */ - 0x00, /* 00000000 */ + 0x38, /* 00011100 */ + 0x30, /* 00001100 */ + 0x30, /* 00001100 */ + 0x3e, /* 01111100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x6e, /* 01110110 */ + 0x00, /* 00000000 */ /* * 101 0x65 'e' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x3f, /* 11111100 */ - 0x03, /* 11000000 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x3f, /* 11111100 */ + 0x03, /* 11000000 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 102 0x66 'f' */ - 0x1c, /* 00111000 */ - 0x36, /* 01101100 */ - 0x06, /* 01100000 */ - 0x0f, /* 11110000 */ - 0x06, /* 01100000 */ - 0x06, /* 01100000 */ - 0x0f, /* 11110000 */ - 0x00, /* 00000000 */ + 0x1c, /* 00111000 */ + 0x36, /* 01101100 */ + 0x06, /* 01100000 */ + 0x0f, /* 11110000 */ + 0x06, /* 01100000 */ + 0x06, /* 01100000 */ + 0x0f, /* 11110000 */ + 0x00, /* 00000000 */ /* * 103 0x67 'g' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x6e, /* 01110110 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x3e, /* 01111100 */ - 0x30, /* 00001100 */ - 0x1f, /* 11111000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x6e, /* 01110110 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x3e, /* 01111100 */ + 0x30, /* 00001100 */ + 0x1f, /* 11111000 */ /* * 104 0x68 'h' */ - 0x07, /* 11100000 */ - 0x06, /* 01100000 */ - 0x36, /* 01101100 */ - 0x6e, /* 01110110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x67, /* 11100110 */ - 0x00, /* 00000000 */ + 0x07, /* 11100000 */ + 0x06, /* 01100000 */ + 0x36, /* 01101100 */ + 0x6e, /* 01110110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x67, /* 11100110 */ + 0x00, /* 00000000 */ /* * 105 0x69 'i' */ - 0x0c, /* 00110000 */ - 0x00, /* 00000000 */ - 0x0e, /* 01110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x0c, /* 00110000 */ + 0x00, /* 00000000 */ + 0x0e, /* 01110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 106 0x6a 'j' */ - 0x30, /* 00001100 */ - 0x00, /* 00000000 */ - 0x30, /* 00001100 */ - 0x30, /* 00001100 */ - 0x30, /* 00001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ + 0x30, /* 00001100 */ + 0x00, /* 00000000 */ + 0x30, /* 00001100 */ + 0x30, /* 00001100 */ + 0x30, /* 00001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ /* * 107 0x6b 'k' */ - 0x07, /* 11100000 */ - 0x06, /* 01100000 */ - 0x66, /* 01100110 */ - 0x36, /* 01101100 */ - 0x1e, /* 01111000 */ - 0x36, /* 01101100 */ - 0x67, /* 11100110 */ - 0x00, /* 00000000 */ + 0x07, /* 11100000 */ + 0x06, /* 01100000 */ + 0x66, /* 01100110 */ + 0x36, /* 01101100 */ + 0x1e, /* 01111000 */ + 0x36, /* 01101100 */ + 0x67, /* 11100110 */ + 0x00, /* 00000000 */ /* * 108 0x6c 'l' */ - 0x0e, /* 01110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x0e, /* 01110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 109 0x6d 'm' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x33, /* 11001100 */ - 0x7f, /* 11111110 */ - 0x7f, /* 11111110 */ - 0x6b, /* 11010110 */ - 0x63, /* 11000110 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x7f, /* 11111110 */ + 0x7f, /* 11111110 */ + 0x6b, /* 11010110 */ + 0x63, /* 11000110 */ + 0x00, /* 00000000 */ /* * 110 0x6e 'n' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x1f, /* 11111000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x1f, /* 11111000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x00, /* 00000000 */ /* * 111 0x6f 'o' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 112 0x70 'p' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x3b, /* 11011100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3e, /* 01111100 */ - 0x06, /* 01100000 */ - 0x0f, /* 11110000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x3b, /* 11011100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3e, /* 01111100 */ + 0x06, /* 01100000 */ + 0x0f, /* 11110000 */ /* * 113 0x71 'q' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x6e, /* 01110110 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x3e, /* 01111100 */ - 0x30, /* 00001100 */ - 0x78, /* 00011110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x6e, /* 01110110 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x3e, /* 01111100 */ + 0x30, /* 00001100 */ + 0x78, /* 00011110 */ /* * 114 0x72 'r' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x3b, /* 11011100 */ - 0x6e, /* 01110110 */ - 0x66, /* 01100110 */ - 0x06, /* 01100000 */ - 0x0f, /* 11110000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x3b, /* 11011100 */ + 0x6e, /* 01110110 */ + 0x66, /* 01100110 */ + 0x06, /* 01100000 */ + 0x0f, /* 11110000 */ + 0x00, /* 00000000 */ /* * 115 0x73 's' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x3e, /* 01111100 */ - 0x03, /* 11000000 */ - 0x1e, /* 01111000 */ - 0x30, /* 00001100 */ - 0x1f, /* 11111000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x3e, /* 01111100 */ + 0x03, /* 11000000 */ + 0x1e, /* 01111000 */ + 0x30, /* 00001100 */ + 0x1f, /* 11111000 */ + 0x00, /* 00000000 */ /* * 116 0x74 't' */ - 0x08, /* 00010000 */ - 0x0c, /* 00110000 */ - 0x3e, /* 01111100 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x2c, /* 00110100 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ + 0x08, /* 00010000 */ + 0x0c, /* 00110000 */ + 0x3e, /* 01111100 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x2c, /* 00110100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ /* * 117 0x75 'u' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x6e, /* 01110110 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x6e, /* 01110110 */ + 0x00, /* 00000000 */ /* * 118 0x76 'v' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x0c, /* 00110000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x0c, /* 00110000 */ + 0x00, /* 00000000 */ /* * 119 0x77 'w' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x63, /* 11000110 */ - 0x6b, /* 11010110 */ - 0x7f, /* 11111110 */ - 0x7f, /* 11111110 */ - 0x36, /* 01101100 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x63, /* 11000110 */ + 0x6b, /* 11010110 */ + 0x7f, /* 11111110 */ + 0x7f, /* 11111110 */ + 0x36, /* 01101100 */ + 0x00, /* 00000000 */ /* * 120 0x78 'x' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x63, /* 11000110 */ - 0x36, /* 01101100 */ - 0x1c, /* 00111000 */ - 0x36, /* 01101100 */ - 0x63, /* 11000110 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x63, /* 11000110 */ + 0x36, /* 01101100 */ + 0x1c, /* 00111000 */ + 0x36, /* 01101100 */ + 0x63, /* 11000110 */ + 0x00, /* 00000000 */ /* * 121 0x79 'y' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x3e, /* 01111100 */ - 0x30, /* 00001100 */ - 0x1f, /* 11111000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x3e, /* 01111100 */ + 0x30, /* 00001100 */ + 0x1f, /* 11111000 */ /* * 122 0x7a 'z' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x3f, /* 11111100 */ - 0x19, /* 10011000 */ - 0x0c, /* 00110000 */ - 0x26, /* 01100100 */ - 0x3f, /* 11111100 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x3f, /* 11111100 */ + 0x19, /* 10011000 */ + 0x0c, /* 00110000 */ + 0x26, /* 01100100 */ + 0x3f, /* 11111100 */ + 0x00, /* 00000000 */ /* * 123 0x7b '{' */ - 0x38, /* 00011100 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x07, /* 11100000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x38, /* 00011100 */ - 0x00, /* 00000000 */ + 0x38, /* 00011100 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x07, /* 11100000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x38, /* 00011100 */ + 0x00, /* 00000000 */ /* * 124 0x7c '|' */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ /* * 125 0x7d '}' */ - 0x07, /* 11100000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x38, /* 00011100 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x07, /* 11100000 */ - 0x00, /* 00000000 */ + 0x07, /* 11100000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x38, /* 00011100 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x07, /* 11100000 */ + 0x00, /* 00000000 */ /* * 126 0x7e '~' */ - 0x6e, /* 01110110 */ - 0x3b, /* 11011100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x6e, /* 01110110 */ + 0x3b, /* 11011100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 127 0x7f '^?' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 128 0x80 '€' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 129 0x81 '' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 130 0x82 '‚' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 131 0x83 'ƒ' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 132 0x84 '„' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 133 0x85 ' ' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 134 0x86 '†' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 135 0x87 '‡' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 136 0x88 'ˆ' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 137 0x89 '‰' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 138 0x8a 'Š' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 139 0x8b '‹' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 140 0x8c 'Œ' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 141 0x8d '' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 142 0x8e 'Ž' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 143 0x8f '' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 144 0x90 '' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 145 0x91 '‘' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 146 0x92 '’' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 147 0x93 '“' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 148 0x94 '”' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 149 0x95 '•' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 150 0x96 '–' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 151 0x97 '—' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 152 0x98 '˜' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 153 0x99 '™' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 154 0x9a 'š' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 155 0x9b '›' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 156 0x9c 'œ' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 157 0x9d '' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 158 0x9e 'ž' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 159 0x9f 'Ÿ' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 160 0xa0 ' ' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 161 0xa1 '¡' */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ /* * 162 0xa2 '¢' */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0x03, /* 11000000 */ - 0x03, /* 11000000 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x03, /* 11000000 */ + 0x03, /* 11000000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ /* * 163 0xa3 '£' */ - 0x1c, /* 00111000 */ - 0x36, /* 01101100 */ - 0x26, /* 01100100 */ - 0x0f, /* 11110000 */ - 0x06, /* 01100000 */ - 0x67, /* 11100110 */ - 0x3f, /* 11111100 */ - 0x00, /* 00000000 */ + 0x1c, /* 00111000 */ + 0x36, /* 01101100 */ + 0x26, /* 01100100 */ + 0x0f, /* 11110000 */ + 0x06, /* 01100000 */ + 0x67, /* 11100110 */ + 0x3f, /* 11111100 */ + 0x00, /* 00000000 */ /* * 164 0xa4 '¤' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x63, /* 11000110 */ - 0x3e, /* 01111100 */ - 0x36, /* 01101100 */ - 0x3e, /* 01111100 */ - 0x63, /* 11000110 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x63, /* 11000110 */ + 0x3e, /* 01111100 */ + 0x36, /* 01101100 */ + 0x3e, /* 01111100 */ + 0x63, /* 11000110 */ + 0x00, /* 00000000 */ /* * 165 0xa5 '¥' */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x3f, /* 11111100 */ - 0x0c, /* 00110000 */ - 0x3f, /* 11111100 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x3f, /* 11111100 */ + 0x0c, /* 00110000 */ + 0x3f, /* 11111100 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ /* * 166 0xa6 '¦' */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ /* * 167 0xa7 '§' */ - 0x7c, /* 00111110 */ - 0xc6, /* 01100011 */ - 0x1c, /* 00111000 */ - 0x36, /* 01101100 */ - 0x36, /* 01101100 */ - 0x1c, /* 00111000 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ + 0x7c, /* 00111110 */ + 0xc6, /* 01100011 */ + 0x1c, /* 00111000 */ + 0x36, /* 01101100 */ + 0x36, /* 01101100 */ + 0x1c, /* 00111000 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ /* * 168 0xa8 '¨' */ - 0x33, /* 11001100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 169 0xa9 '©' */ - 0x3c, /* 00111100 */ - 0x42, /* 01000010 */ - 0x99, /* 10011001 */ - 0x85, /* 10100001 */ - 0x85, /* 10100001 */ - 0x99, /* 10011001 */ - 0x42, /* 01000010 */ - 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x42, /* 01000010 */ + 0x99, /* 10011001 */ + 0x85, /* 10100001 */ + 0x85, /* 10100001 */ + 0x99, /* 10011001 */ + 0x42, /* 01000010 */ + 0x3c, /* 00111100 */ /* * 170 0xaa 'ª' */ - 0x3c, /* 00111100 */ - 0x36, /* 01101100 */ - 0x36, /* 01101100 */ - 0x7c, /* 00111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x3c, /* 00111100 */ + 0x36, /* 01101100 */ + 0x36, /* 01101100 */ + 0x7c, /* 00111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 171 0xab '«' */ - 0x00, /* 00000000 */ - 0xcc, /* 00110011 */ - 0x66, /* 01100110 */ - 0x33, /* 11001100 */ - 0x66, /* 01100110 */ - 0xcc, /* 00110011 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xcc, /* 00110011 */ + 0x66, /* 01100110 */ + 0x33, /* 11001100 */ + 0x66, /* 01100110 */ + 0xcc, /* 00110011 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 172 0xac '¬' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x3f, /* 11111100 */ - 0x30, /* 00001100 */ - 0x30, /* 00001100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x3f, /* 11111100 */ + 0x30, /* 00001100 */ + 0x30, /* 00001100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 173 0xad '­' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 174 0xae '®' */ - 0x3c, /* 00111100 */ - 0x42, /* 01000010 */ - 0x9d, /* 10111001 */ - 0xa5, /* 10100101 */ - 0x9d, /* 10111001 */ - 0xa5, /* 10100101 */ - 0x42, /* 01000010 */ - 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x42, /* 01000010 */ + 0x9d, /* 10111001 */ + 0xa5, /* 10100101 */ + 0x9d, /* 10111001 */ + 0xa5, /* 10100101 */ + 0x42, /* 01000010 */ + 0x3c, /* 00111100 */ /* * 175 0xaf '¯' */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 176 0xb0 '°' */ - 0x1c, /* 00111000 */ - 0x36, /* 01101100 */ - 0x36, /* 01101100 */ - 0x1c, /* 00111000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x1c, /* 00111000 */ + 0x36, /* 01101100 */ + 0x36, /* 01101100 */ + 0x1c, /* 00111000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 177 0xb1 '±' */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ /* * 178 0xb2 '²' */ - 0x1c, /* 00111000 */ - 0x30, /* 00001100 */ - 0x18, /* 00011000 */ - 0x0c, /* 00110000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x1c, /* 00111000 */ + 0x30, /* 00001100 */ + 0x18, /* 00011000 */ + 0x0c, /* 00110000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 179 0xb3 '³' */ - 0x1c, /* 00111000 */ - 0x30, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00001100 */ - 0x1c, /* 00111000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x1c, /* 00111000 */ + 0x30, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00001100 */ + 0x1c, /* 00111000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 180 0xb4 '´' */ - 0x18, /* 00011000 */ - 0x0c, /* 00110000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00110000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 181 0xb5 'µ' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3e, /* 01111100 */ - 0x06, /* 01100000 */ - 0x03, /* 11000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3e, /* 01111100 */ + 0x06, /* 01100000 */ + 0x03, /* 11000000 */ /* * 182 0xb6 '¶' */ - 0xfe, /* 01111111 */ - 0xdb, /* 11011011 */ - 0xdb, /* 11011011 */ - 0xde, /* 01111011 */ - 0xd8, /* 00011011 */ - 0xd8, /* 00011011 */ - 0xd8, /* 00011011 */ - 0x00, /* 00000000 */ + 0xfe, /* 01111111 */ + 0xdb, /* 11011011 */ + 0xdb, /* 11011011 */ + 0xde, /* 01111011 */ + 0xd8, /* 00011011 */ + 0xd8, /* 00011011 */ + 0xd8, /* 00011011 */ + 0x00, /* 00000000 */ /* * 183 0xb7 '·' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 184 0xb8 '¸' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x30, /* 00001100 */ - 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x30, /* 00001100 */ + 0x1e, /* 01111000 */ /* * 185 0xb9 '¹' */ - 0x08, /* 00010000 */ - 0x0c, /* 00110000 */ - 0x08, /* 00010000 */ - 0x1c, /* 00111000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x08, /* 00010000 */ + 0x0c, /* 00110000 */ + 0x08, /* 00010000 */ + 0x1c, /* 00111000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 186 0xba 'º' */ - 0x1c, /* 00111000 */ - 0x36, /* 01101100 */ - 0x36, /* 01101100 */ - 0x1c, /* 00111000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x1c, /* 00111000 */ + 0x36, /* 01101100 */ + 0x36, /* 01101100 */ + 0x1c, /* 00111000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 187 0xbb '»' */ - 0x00, /* 00000000 */ - 0x33, /* 11001100 */ - 0x66, /* 01100110 */ - 0xcc, /* 00110011 */ - 0x66, /* 01100110 */ - 0x33, /* 11001100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x66, /* 01100110 */ + 0xcc, /* 00110011 */ + 0x66, /* 01100110 */ + 0x33, /* 11001100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 188 0xbc '¼' */ - 0xc3, /* 11000011 */ - 0x63, /* 11000110 */ - 0x33, /* 11001100 */ - 0xbd, /* 10111101 */ - 0xec, /* 00110111 */ - 0xf6, /* 01101111 */ - 0xf3, /* 11001111 */ - 0x03, /* 11000000 */ + 0xc3, /* 11000011 */ + 0x63, /* 11000110 */ + 0x33, /* 11001100 */ + 0xbd, /* 10111101 */ + 0xec, /* 00110111 */ + 0xf6, /* 01101111 */ + 0xf3, /* 11001111 */ + 0x03, /* 11000000 */ /* * 189 0xbd '½' */ - 0xc3, /* 11000011 */ - 0x63, /* 11000110 */ - 0x33, /* 11001100 */ - 0x7b, /* 11011110 */ - 0xcc, /* 00110011 */ - 0x66, /* 01100110 */ - 0x33, /* 11001100 */ - 0xf0, /* 00001111 */ + 0xc3, /* 11000011 */ + 0x63, /* 11000110 */ + 0x33, /* 11001100 */ + 0x7b, /* 11011110 */ + 0xcc, /* 00110011 */ + 0x66, /* 01100110 */ + 0x33, /* 11001100 */ + 0xf0, /* 00001111 */ /* * 190 0xbe '¾' */ - 0x03, /* 11000000 */ - 0xc4, /* 00100011 */ - 0x63, /* 11000110 */ - 0xb4, /* 00101101 */ - 0xdb, /* 11011011 */ - 0xac, /* 00110101 */ - 0xe6, /* 01100111 */ - 0x80, /* 00000001 */ + 0x03, /* 11000000 */ + 0xc4, /* 00100011 */ + 0x63, /* 11000110 */ + 0xb4, /* 00101101 */ + 0xdb, /* 11011011 */ + 0xac, /* 00110101 */ + 0xe6, /* 01100111 */ + 0x80, /* 00000001 */ /* * 191 0xbf '¿' */ - 0x0c, /* 00110000 */ - 0x00, /* 00000000 */ - 0x0c, /* 00110000 */ - 0x06, /* 01100000 */ - 0x03, /* 11000000 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x0c, /* 00110000 */ + 0x00, /* 00000000 */ + 0x0c, /* 00110000 */ + 0x06, /* 01100000 */ + 0x03, /* 11000000 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 192 0xc0 'À' */ - 0x07, /* 11100000 */ - 0x00, /* 00000000 */ - 0x1c, /* 00111000 */ - 0x36, /* 01101100 */ - 0x63, /* 11000110 */ - 0x7f, /* 11111110 */ - 0x63, /* 11000110 */ - 0x00, /* 00000000 */ + 0x07, /* 11100000 */ + 0x00, /* 00000000 */ + 0x1c, /* 00111000 */ + 0x36, /* 01101100 */ + 0x63, /* 11000110 */ + 0x7f, /* 11111110 */ + 0x63, /* 11000110 */ + 0x00, /* 00000000 */ /* * 193 0xc1 'Á' */ - 0x70, /* 00001110 */ - 0x00, /* 00000000 */ - 0x1c, /* 00111000 */ - 0x36, /* 01101100 */ - 0x63, /* 11000110 */ - 0x7f, /* 11111110 */ - 0x63, /* 11000110 */ - 0x00, /* 00000000 */ + 0x70, /* 00001110 */ + 0x00, /* 00000000 */ + 0x1c, /* 00111000 */ + 0x36, /* 01101100 */ + 0x63, /* 11000110 */ + 0x7f, /* 11111110 */ + 0x63, /* 11000110 */ + 0x00, /* 00000000 */ /* * 194 0xc2 'Â' */ - 0x1c, /* 00111000 */ - 0x36, /* 01101100 */ - 0x00, /* 00000000 */ - 0x3e, /* 01111100 */ - 0x63, /* 11000110 */ - 0x7f, /* 11111110 */ - 0x63, /* 11000110 */ - 0x00, /* 00000000 */ + 0x1c, /* 00111000 */ + 0x36, /* 01101100 */ + 0x00, /* 00000000 */ + 0x3e, /* 01111100 */ + 0x63, /* 11000110 */ + 0x7f, /* 11111110 */ + 0x63, /* 11000110 */ + 0x00, /* 00000000 */ /* * 195 0xc3 'Ã' */ - 0x6e, /* 01110110 */ - 0x3b, /* 11011100 */ - 0x00, /* 00000000 */ - 0x3e, /* 01111100 */ - 0x63, /* 11000110 */ - 0x7f, /* 11111110 */ - 0x63, /* 11000110 */ - 0x00, /* 00000000 */ + 0x6e, /* 01110110 */ + 0x3b, /* 11011100 */ + 0x00, /* 00000000 */ + 0x3e, /* 01111100 */ + 0x63, /* 11000110 */ + 0x7f, /* 11111110 */ + 0x63, /* 11000110 */ + 0x00, /* 00000000 */ /* * 196 0xc4 'Ä' */ - 0x63, /* 11000110 */ - 0x1c, /* 00111000 */ - 0x36, /* 01101100 */ - 0x63, /* 11000110 */ - 0x7f, /* 11111110 */ - 0x63, /* 11000110 */ - 0x63, /* 11000110 */ - 0x00, /* 00000000 */ + 0x63, /* 11000110 */ + 0x1c, /* 00111000 */ + 0x36, /* 01101100 */ + 0x63, /* 11000110 */ + 0x7f, /* 11111110 */ + 0x63, /* 11000110 */ + 0x63, /* 11000110 */ + 0x00, /* 00000000 */ /* * 197 0xc5 'Å' */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x3f, /* 11111100 */ - 0x33, /* 11001100 */ - 0x00, /* 00000000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x3f, /* 11111100 */ + 0x33, /* 11001100 */ + 0x00, /* 00000000 */ /* * 198 0xc6 'Æ' */ - 0x7c, /* 00111110 */ - 0x36, /* 01101100 */ - 0x33, /* 11001100 */ - 0x7f, /* 11111110 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x73, /* 11001110 */ - 0x00, /* 00000000 */ + 0x7c, /* 00111110 */ + 0x36, /* 01101100 */ + 0x33, /* 11001100 */ + 0x7f, /* 11111110 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x73, /* 11001110 */ + 0x00, /* 00000000 */ /* * 199 0xc7 'Ç' */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x03, /* 11000000 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x18, /* 00011000 */ - 0x30, /* 00001100 */ - 0x1e, /* 01111000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x03, /* 11000000 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x18, /* 00011000 */ + 0x30, /* 00001100 */ + 0x1e, /* 01111000 */ /* * 200 0xc8 'È' */ - 0x07, /* 11100000 */ - 0x00, /* 00000000 */ - 0x3f, /* 11111100 */ - 0x06, /* 01100000 */ - 0x1e, /* 01111000 */ - 0x06, /* 01100000 */ - 0x3f, /* 11111100 */ - 0x00, /* 00000000 */ + 0x07, /* 11100000 */ + 0x00, /* 00000000 */ + 0x3f, /* 11111100 */ + 0x06, /* 01100000 */ + 0x1e, /* 01111000 */ + 0x06, /* 01100000 */ + 0x3f, /* 11111100 */ + 0x00, /* 00000000 */ /* * 201 0xc9 'É' */ - 0x38, /* 00011100 */ - 0x00, /* 00000000 */ - 0x3f, /* 11111100 */ - 0x06, /* 01100000 */ - 0x1e, /* 01111000 */ - 0x06, /* 01100000 */ - 0x3f, /* 11111100 */ - 0x00, /* 00000000 */ + 0x38, /* 00011100 */ + 0x00, /* 00000000 */ + 0x3f, /* 11111100 */ + 0x06, /* 01100000 */ + 0x1e, /* 01111000 */ + 0x06, /* 01100000 */ + 0x3f, /* 11111100 */ + 0x00, /* 00000000 */ /* * 202 0xca 'Ê' */ - 0x0c, /* 00110000 */ - 0x12, /* 01001000 */ - 0x3f, /* 11111100 */ - 0x06, /* 01100000 */ - 0x1e, /* 01111000 */ - 0x06, /* 01100000 */ - 0x3f, /* 11111100 */ - 0x00, /* 00000000 */ + 0x0c, /* 00110000 */ + 0x12, /* 01001000 */ + 0x3f, /* 11111100 */ + 0x06, /* 01100000 */ + 0x1e, /* 01111000 */ + 0x06, /* 01100000 */ + 0x3f, /* 11111100 */ + 0x00, /* 00000000 */ /* * 203 0xcb 'Ë' */ - 0x36, /* 01101100 */ - 0x00, /* 00000000 */ - 0x3f, /* 11111100 */ - 0x06, /* 01100000 */ - 0x1e, /* 01111000 */ - 0x06, /* 01100000 */ - 0x3f, /* 11111100 */ - 0x00, /* 00000000 */ + 0x36, /* 01101100 */ + 0x00, /* 00000000 */ + 0x3f, /* 11111100 */ + 0x06, /* 01100000 */ + 0x1e, /* 01111000 */ + 0x06, /* 01100000 */ + 0x3f, /* 11111100 */ + 0x00, /* 00000000 */ /* * 204 0xcc 'Ì' */ - 0x07, /* 11100000 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x07, /* 11100000 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 205 0xcd 'Í' */ - 0x38, /* 00011100 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x38, /* 00011100 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 206 0xce 'Î' */ - 0x0c, /* 00110000 */ - 0x12, /* 01001000 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x0c, /* 00110000 */ + 0x12, /* 01001000 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 207 0xcf 'Ï' */ - 0x33, /* 11001100 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 208 0xd0 'Ð' */ - 0x3f, /* 11111100 */ - 0x66, /* 01100110 */ - 0x6f, /* 11110110 */ - 0x6f, /* 11110110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3f, /* 11111100 */ - 0x00, /* 00000000 */ + 0x3f, /* 11111100 */ + 0x66, /* 01100110 */ + 0x6f, /* 11110110 */ + 0x6f, /* 11110110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3f, /* 11111100 */ + 0x00, /* 00000000 */ /* * 209 0xd1 'Ñ' */ - 0x3f, /* 11111100 */ - 0x00, /* 00000000 */ - 0x33, /* 11001100 */ - 0x37, /* 11101100 */ - 0x3f, /* 11111100 */ - 0x3b, /* 11011100 */ - 0x33, /* 11001100 */ - 0x00, /* 00000000 */ + 0x3f, /* 11111100 */ + 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x37, /* 11101100 */ + 0x3f, /* 11111100 */ + 0x3b, /* 11011100 */ + 0x33, /* 11001100 */ + 0x00, /* 00000000 */ /* * 210 0xd2 'Ò' */ - 0x0e, /* 01110000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ + 0x0e, /* 01110000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ /* * 211 0xd3 'Ó' */ - 0x70, /* 00001110 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ + 0x70, /* 00001110 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ /* * 212 0xd4 'Ô' */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ /* * 213 0xd5 'Õ' */ - 0x6e, /* 01110110 */ - 0x3b, /* 11011100 */ - 0x00, /* 00000000 */ - 0x3e, /* 01111100 */ - 0x63, /* 11000110 */ - 0x63, /* 11000110 */ - 0x3e, /* 01111100 */ - 0x00, /* 00000000 */ + 0x6e, /* 01110110 */ + 0x3b, /* 11011100 */ + 0x00, /* 00000000 */ + 0x3e, /* 01111100 */ + 0x63, /* 11000110 */ + 0x63, /* 11000110 */ + 0x3e, /* 01111100 */ + 0x00, /* 00000000 */ /* * 214 0xd6 'Ö' */ - 0xc3, /* 11000011 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ + 0xc3, /* 11000011 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ /* * 215 0xd7 '×' */ - 0x00, /* 00000000 */ - 0x36, /* 01101100 */ - 0x1c, /* 00111000 */ - 0x08, /* 00010000 */ - 0x1c, /* 00111000 */ - 0x36, /* 01101100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x36, /* 01101100 */ + 0x1c, /* 00111000 */ + 0x08, /* 00010000 */ + 0x1c, /* 00111000 */ + 0x36, /* 01101100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ /* * 216 0xd8 'Ø' */ - 0x5c, /* 00111010 */ - 0x36, /* 01101100 */ - 0x73, /* 11001110 */ - 0x7b, /* 11011110 */ - 0x6f, /* 11110110 */ - 0x36, /* 01101100 */ - 0x1d, /* 10111000 */ - 0x00, /* 00000000 */ + 0x5c, /* 00111010 */ + 0x36, /* 01101100 */ + 0x73, /* 11001110 */ + 0x7b, /* 11011110 */ + 0x6f, /* 11110110 */ + 0x36, /* 01101100 */ + 0x1d, /* 10111000 */ + 0x00, /* 00000000 */ /* * 217 0xd9 'Ù' */ - 0x0e, /* 01110000 */ - 0x00, /* 00000000 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ + 0x0e, /* 01110000 */ + 0x00, /* 00000000 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ /* * 218 0xda 'Ú' */ - 0x70, /* 00001110 */ - 0x00, /* 00000000 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ + 0x70, /* 00001110 */ + 0x00, /* 00000000 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ /* * 219 0xdb 'Û' */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x00, /* 00000000 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x00, /* 00000000 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ /* * 220 0xdc 'Ü' */ - 0x33, /* 11001100 */ - 0x00, /* 00000000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 221 0xdd 'Ý' */ - 0x70, /* 00001110 */ - 0x00, /* 00000000 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ + 0x70, /* 00001110 */ + 0x00, /* 00000000 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ /* * 222 0xde 'Þ' */ - 0x0f, /* 11110000 */ - 0x06, /* 01100000 */ - 0x3e, /* 01111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3e, /* 01111100 */ - 0x06, /* 01100000 */ - 0x0f, /* 11110000 */ + 0x0f, /* 11110000 */ + 0x06, /* 01100000 */ + 0x3e, /* 01111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3e, /* 01111100 */ + 0x06, /* 01100000 */ + 0x0f, /* 11110000 */ /* * 223 0xdf 'ß' */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x1f, /* 11111000 */ - 0x33, /* 11001100 */ - 0x1f, /* 11111000 */ - 0x03, /* 11000000 */ - 0x03, /* 11000000 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x1f, /* 11111000 */ + 0x33, /* 11001100 */ + 0x1f, /* 11111000 */ + 0x03, /* 11000000 */ + 0x03, /* 11000000 */ /* * 224 0xe0 'à' */ - 0x07, /* 11100000 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x30, /* 00001100 */ - 0x3e, /* 01111100 */ - 0x33, /* 11001100 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ + 0x07, /* 11100000 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x30, /* 00001100 */ + 0x3e, /* 01111100 */ + 0x33, /* 11001100 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ /* * 225 0xe1 'á' */ - 0x38, /* 00011100 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x30, /* 00001100 */ - 0x3e, /* 01111100 */ - 0x33, /* 11001100 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ + 0x38, /* 00011100 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x30, /* 00001100 */ + 0x3e, /* 01111100 */ + 0x33, /* 11001100 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ /* * 226 0xe2 'â' */ - 0x7e, /* 01111110 */ - 0xc3, /* 11000011 */ - 0x3c, /* 00111100 */ - 0x60, /* 00000110 */ - 0x7c, /* 00111110 */ - 0x66, /* 01100110 */ - 0xfc, /* 00111111 */ - 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0xc3, /* 11000011 */ + 0x3c, /* 00111100 */ + 0x60, /* 00000110 */ + 0x7c, /* 00111110 */ + 0x66, /* 01100110 */ + 0xfc, /* 00111111 */ + 0x00, /* 00000000 */ /* * 227 0xe3 'ã' */ - 0x6e, /* 01110110 */ - 0x3b, /* 11011100 */ - 0x1e, /* 01111000 */ - 0x30, /* 00001100 */ - 0x3e, /* 01111100 */ - 0x33, /* 11001100 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ + 0x6e, /* 01110110 */ + 0x3b, /* 11011100 */ + 0x1e, /* 01111000 */ + 0x30, /* 00001100 */ + 0x3e, /* 01111100 */ + 0x33, /* 11001100 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ /* * 228 0xe4 'ä' */ - 0x33, /* 11001100 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x30, /* 00001100 */ - 0x3e, /* 01111100 */ - 0x33, /* 11001100 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x30, /* 00001100 */ + 0x3e, /* 01111100 */ + 0x33, /* 11001100 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ /* * 229 0xe5 'å' */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x1e, /* 01111000 */ - 0x30, /* 00001100 */ - 0x3e, /* 01111100 */ - 0x33, /* 11001100 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x1e, /* 01111000 */ + 0x30, /* 00001100 */ + 0x3e, /* 01111100 */ + 0x33, /* 11001100 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ /* * 230 0xe6 'æ' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xfe, /* 01111111 */ - 0x30, /* 00001100 */ - 0xfe, /* 01111111 */ - 0x33, /* 11001100 */ - 0xfe, /* 01111111 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfe, /* 01111111 */ + 0x30, /* 00001100 */ + 0xfe, /* 01111111 */ + 0x33, /* 11001100 */ + 0xfe, /* 01111111 */ + 0x00, /* 00000000 */ /* * 231 0xe7 'ç' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x03, /* 11000000 */ - 0x03, /* 11000000 */ - 0x1e, /* 01111000 */ - 0x30, /* 00001100 */ - 0x1c, /* 00111000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x03, /* 11000000 */ + 0x03, /* 11000000 */ + 0x1e, /* 01111000 */ + 0x30, /* 00001100 */ + 0x1c, /* 00111000 */ /* * 232 0xe8 'è' */ - 0x07, /* 11100000 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x3f, /* 11111100 */ - 0x03, /* 11000000 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x07, /* 11100000 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x3f, /* 11111100 */ + 0x03, /* 11000000 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 233 0xe9 'é' */ - 0x38, /* 00011100 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x3f, /* 11111100 */ - 0x03, /* 11000000 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x38, /* 00011100 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x3f, /* 11111100 */ + 0x03, /* 11000000 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 234 0xea 'ê' */ - 0x7e, /* 01111110 */ - 0xc3, /* 11000011 */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x7e, /* 01111110 */ - 0x06, /* 01100000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0xc3, /* 11000011 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x7e, /* 01111110 */ + 0x06, /* 01100000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ /* * 235 0xeb 'ë' */ - 0x33, /* 11001100 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x3f, /* 11111100 */ - 0x03, /* 11000000 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x3f, /* 11111100 */ + 0x03, /* 11000000 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 236 0xec 'ì' */ - 0x07, /* 11100000 */ - 0x00, /* 00000000 */ - 0x0e, /* 01110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x07, /* 11100000 */ + 0x00, /* 00000000 */ + 0x0e, /* 01110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 237 0xed 'í' */ - 0x1c, /* 00111000 */ - 0x00, /* 00000000 */ - 0x0e, /* 01110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x1c, /* 00111000 */ + 0x00, /* 00000000 */ + 0x0e, /* 01110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 238 0xee 'î' */ - 0x3e, /* 01111100 */ - 0x63, /* 11000110 */ - 0x1c, /* 00111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ + 0x3e, /* 01111100 */ + 0x63, /* 11000110 */ + 0x1c, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ /* * 239 0xef 'ï' */ - 0x33, /* 11001100 */ - 0x00, /* 00000000 */ - 0x0e, /* 01110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x0c, /* 00110000 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x00, /* 00000000 */ + 0x0e, /* 01110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x0c, /* 00110000 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 240 0xf0 'ð' */ - 0x1b, /* 11011000 */ - 0x0e, /* 01110000 */ - 0x1b, /* 11011000 */ - 0x30, /* 00001100 */ - 0x3e, /* 01111100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x1b, /* 11011000 */ + 0x0e, /* 01110000 */ + 0x1b, /* 11011000 */ + 0x30, /* 00001100 */ + 0x3e, /* 01111100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 241 0xf1 'ñ' */ - 0x00, /* 00000000 */ - 0x1f, /* 11111000 */ - 0x00, /* 00000000 */ - 0x1f, /* 11111000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x1f, /* 11111000 */ + 0x00, /* 00000000 */ + 0x1f, /* 11111000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x00, /* 00000000 */ /* * 242 0xf2 'ò' */ - 0x00, /* 00000000 */ - 0x07, /* 11100000 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x07, /* 11100000 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 243 0xf3 'ó' */ - 0x00, /* 00000000 */ - 0x38, /* 00011100 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x38, /* 00011100 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 244 0xf4 'ô' */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 245 0xf5 'õ' */ - 0x6e, /* 01110110 */ - 0x3b, /* 11011100 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x6e, /* 01110110 */ + 0x3b, /* 11011100 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 246 0xf6 'ö' */ - 0x00, /* 00000000 */ - 0x33, /* 11001100 */ - 0x00, /* 00000000 */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x1e, /* 01111000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x1e, /* 01111000 */ + 0x00, /* 00000000 */ /* * 247 0xf7 '÷' */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ /* * 248 0xf8 'ø' */ - 0x00, /* 00000000 */ - 0x60, /* 00000110 */ - 0x3c, /* 00111100 */ - 0x76, /* 01101110 */ - 0x7e, /* 01111110 */ - 0x6e, /* 01110110 */ - 0x3c, /* 00111100 */ - 0x06, /* 01100000 */ + 0x00, /* 00000000 */ + 0x60, /* 00000110 */ + 0x3c, /* 00111100 */ + 0x76, /* 01101110 */ + 0x7e, /* 01111110 */ + 0x6e, /* 01110110 */ + 0x3c, /* 00111100 */ + 0x06, /* 01100000 */ /* * 249 0xf9 'ù' */ - 0x00, /* 00000000 */ - 0x07, /* 11100000 */ - 0x00, /* 00000000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x07, /* 11100000 */ + 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ /* * 250 0xfa 'ú' */ - 0x00, /* 00000000 */ - 0x38, /* 00011100 */ - 0x00, /* 00000000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x38, /* 00011100 */ + 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ /* * 251 0xfb 'û' */ - 0x1e, /* 01111000 */ - 0x33, /* 11001100 */ - 0x00, /* 00000000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ + 0x1e, /* 01111000 */ + 0x33, /* 11001100 */ + 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ /* * 252 0xfc 'ü' */ - 0x00, /* 00000000 */ - 0x33, /* 11001100 */ - 0x00, /* 00000000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ /* * 253 0xfd 'ý' */ - 0x00, /* 00000000 */ - 0x38, /* 00011100 */ - 0x00, /* 00000000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x3e, /* 01111100 */ - 0x30, /* 00001100 */ - 0x1f, /* 11111000 */ + 0x00, /* 00000000 */ + 0x38, /* 00011100 */ + 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x3e, /* 01111100 */ + 0x30, /* 00001100 */ + 0x1f, /* 11111000 */ /* * 254 0xfe 'þ' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x06, /* 01100000 */ - 0x3e, /* 01111100 */ - 0x66, /* 01100110 */ - 0x3e, /* 01111100 */ - 0x06, /* 01100000 */ - 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x06, /* 01100000 */ + 0x3e, /* 01111100 */ + 0x66, /* 01100110 */ + 0x3e, /* 01111100 */ + 0x06, /* 01100000 */ + 0x00, /* 00000000 */ /* * 255 0xff 'ÿ' */ - 0x00, /* 00000000 */ - 0x33, /* 11001100 */ - 0x00, /* 00000000 */ - 0x33, /* 11001100 */ - 0x33, /* 11001100 */ - 0x3e, /* 01111100 */ - 0x30, /* 00001100 */ - 0x1f, /* 11111000 */ + 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x00, /* 00000000 */ + 0x33, /* 11001100 */ + 0x33, /* 11001100 */ + 0x3e, /* 01111100 */ + 0x30, /* 00001100 */ + 0x1f, /* 11111000 */ }; - /* ---- Character */ -struct SDLTest_CharTextureCache { - SDL_Renderer* renderer; - SDL_Texture* charTextureCache[256]; - struct SDLTest_CharTextureCache* next; +struct SDLTest_CharTextureCache +{ + SDL_Renderer *renderer; + SDL_Texture *charTextureCache[256]; + struct SDLTest_CharTextureCache *next; }; /*! @@ -3173,8 +3173,8 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, Uint32 c) } /* Allocate a new cache for this renderer if needed */ - if (cache == NULL) { - cache = (struct SDLTest_CharTextureCache*)SDL_calloc(1, sizeof(struct SDLTest_CharTextureCache)); + if (cache == NULL) { + cache = (struct SDLTest_CharTextureCache *)SDL_calloc(1, sizeof(struct SDLTest_CharTextureCache)); cache->renderer = renderer; cache->next = SDLTest_CharTextureCacheList; SDLTest_CharTextureCacheList = cache; @@ -3215,7 +3215,6 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, Uint32 c) ++charpos; } - /* Convert temp surface into texture */ cache->charTextureCache[ci] = SDL_CreateTextureFromSurface(renderer, character); SDL_FreeSurface(character); @@ -3264,7 +3263,7 @@ static Uint32 UTF8_getch(const char *src, size_t srclen, int *inc) if (p[0] == 0xFC && (p[1] & 0xFC) == 0x80) { overlong = SDL_TRUE; } - ch = (Uint32) (p[0] & 0x01); + ch = (Uint32)(p[0] & 0x01); left = 5; } } else if (p[0] >= 0xF8) { @@ -3272,7 +3271,7 @@ static Uint32 UTF8_getch(const char *src, size_t srclen, int *inc) if (p[0] == 0xF8 && (p[1] & 0xF8) == 0x80) { overlong = SDL_TRUE; } - ch = (Uint32) (p[0] & 0x03); + ch = (Uint32)(p[0] & 0x03); left = 4; } } else if (p[0] >= 0xF0) { @@ -3280,7 +3279,7 @@ static Uint32 UTF8_getch(const char *src, size_t srclen, int *inc) if (p[0] == 0xF0 && (p[1] & 0xF0) == 0x80) { overlong = SDL_TRUE; } - ch = (Uint32) (p[0] & 0x07); + ch = (Uint32)(p[0] & 0x07); left = 3; } } else if (p[0] >= 0xE0) { @@ -3288,7 +3287,7 @@ static Uint32 UTF8_getch(const char *src, size_t srclen, int *inc) if (p[0] == 0xE0 && (p[1] & 0xE0) == 0x80) { overlong = SDL_TRUE; } - ch = (Uint32) (p[0] & 0x0F); + ch = (Uint32)(p[0] & 0x0F); left = 2; } } else if (p[0] >= 0xC0) { @@ -3296,12 +3295,12 @@ static Uint32 UTF8_getch(const char *src, size_t srclen, int *inc) if ((p[0] & 0xDE) == 0xC0) { overlong = SDL_TRUE; } - ch = (Uint32) (p[0] & 0x1F); + ch = (Uint32)(p[0] & 0x1F); left = 1; } } else { if ((p[0] & 0x80) == 0x00) { - ch = (Uint32) p[0]; + ch = (Uint32)p[0]; } } --srclen; @@ -3333,7 +3332,7 @@ static Uint32 UTF8_getch(const char *src, size_t srclen, int *inc) #define UTF8_IsTrailingByte(c) ((c) >= 0x80 && (c) <= 0xBF) -int SDLTest_DrawString(SDL_Renderer * renderer, int x, int y, const char *s) +int SDLTest_DrawString(SDL_Renderer *renderer, int x, int y, const char *s) { const Uint32 charWidth = FONT_CHARACTER_SIZE; int result = 0; @@ -3370,7 +3369,7 @@ SDLTest_TextWindow *SDLTest_TextWindowCreate(int x, int y, int w, int h) textwin->current = 0; textwin->numlines = (h / FONT_LINE_HEIGHT); textwin->lines = (char **)SDL_calloc(textwin->numlines, sizeof(*textwin->lines)); - if ( !textwin->lines ) { + if (!textwin->lines) { SDL_free(textwin); return NULL; } @@ -3381,8 +3380,8 @@ void SDLTest_TextWindowDisplay(SDLTest_TextWindow *textwin, SDL_Renderer *render { int i, y; - for ( y = textwin->rect.y, i = 0; i < textwin->numlines; ++i, y += FONT_LINE_HEIGHT ) { - if ( textwin->lines[i] ) { + for (y = textwin->rect.y, i = 0; i < textwin->numlines; ++i, y += FONT_LINE_HEIGHT) { + if (textwin->lines[i]) { SDLTest_DrawString(renderer, textwin->rect.x, y, textwin->lines[i]); } } @@ -3390,12 +3389,12 @@ void SDLTest_TextWindowDisplay(SDLTest_TextWindow *textwin, SDL_Renderer *render void SDLTest_TextWindowAddText(SDLTest_TextWindow *textwin, const char *fmt, ...) { - char text[1024]; - va_list ap; + char text[1024]; + va_list ap; - va_start(ap, fmt); - SDL_vsnprintf(text, sizeof(text), fmt, ap); - va_end(ap); + va_start(ap, fmt); + SDL_vsnprintf(text, sizeof(text), fmt, ap); + va_end(ap); SDLTest_TextWindowAddTextWithLength(textwin, text, SDL_strlen(text)); } @@ -3406,19 +3405,19 @@ void SDLTest_TextWindowAddTextWithLength(SDLTest_TextWindow *textwin, const char SDL_bool newline = SDL_FALSE; char *line; - if ( len > 0 && text[len - 1] == '\n' ) { + if (len > 0 && text[len - 1] == '\n') { --len; newline = SDL_TRUE; } - if ( textwin->lines[textwin->current] ) { + if (textwin->lines[textwin->current]) { existing = SDL_strlen(textwin->lines[textwin->current]); } else { existing = 0; } - if ( *text == '\b' ) { - if ( existing ) { + if (*text == '\b') { + if (existing) { while (existing > 1 && UTF8_IsTrailingByte((Uint8)textwin->lines[textwin->current][existing - 1])) { --existing; } @@ -3433,14 +3432,14 @@ void SDLTest_TextWindowAddTextWithLength(SDLTest_TextWindow *textwin, const char } line = (char *)SDL_realloc(textwin->lines[textwin->current], existing + len + 1); - if ( line ) { + if (line) { SDL_memcpy(&line[existing], text, len); line[existing + len] = '\0'; textwin->lines[textwin->current] = line; - if ( newline ) { + if (newline) { if (textwin->current == textwin->numlines - 1) { SDL_free(textwin->lines[0]); - SDL_memcpy(&textwin->lines[0], &textwin->lines[1], (textwin->numlines-1) * sizeof(textwin->lines[1])); + SDL_memcpy(&textwin->lines[0], &textwin->lines[1], (textwin->numlines - 1) * sizeof(textwin->lines[1])); textwin->lines[textwin->current] = NULL; } else { ++textwin->current; @@ -3453,8 +3452,8 @@ void SDLTest_TextWindowClear(SDLTest_TextWindow *textwin) { int i; - for ( i = 0; i < textwin->numlines; ++i ) { - if ( textwin->lines[i] ) { + for (i = 0; i < textwin->numlines; ++i) { + if (textwin->lines[i]) { SDL_free(textwin->lines[i]); textwin->lines[i] = NULL; } @@ -3464,7 +3463,7 @@ void SDLTest_TextWindowClear(SDLTest_TextWindow *textwin) void SDLTest_TextWindowDestroy(SDLTest_TextWindow *textwin) { - if ( textwin ) { + if (textwin) { SDLTest_TextWindowClear(textwin); SDL_free(textwin->lines); SDL_free(textwin); @@ -3474,7 +3473,7 @@ void SDLTest_TextWindowDestroy(SDLTest_TextWindow *textwin) void SDLTest_CleanupTextDrawing(void) { unsigned int i; - struct SDLTest_CharTextureCache* cache, *next; + struct SDLTest_CharTextureCache *cache, *next; cache = SDLTest_CharTextureCacheList; while (cache) { diff --git a/src/test/SDL_test_fuzzer.c b/src/test/SDL_test_fuzzer.c index 7eda8a075..a41399a70 100644 --- a/src/test/SDL_test_fuzzer.c +++ b/src/test/SDL_test_fuzzer.c @@ -59,8 +59,7 @@ static SDLTest_RandomContext rndContext; * Note: doxygen documentation markup for functions is in the header file. */ -void -SDLTest_FuzzerInit(Uint64 execKey) +void SDLTest_FuzzerInit(Uint64 execKey) { Uint32 a = (execKey >> 32) & 0x00000000FFFFFFFF; Uint32 b = execKey & 0x00000000FFFFFFFF; @@ -69,26 +68,23 @@ SDLTest_FuzzerInit(Uint64 execKey) fuzzerInvocationCounter = 0; } -int -SDLTest_GetFuzzerInvocationCount() +int SDLTest_GetFuzzerInvocationCount() { return fuzzerInvocationCounter; } -Uint8 -SDLTest_RandomUint8() +Uint8 SDLTest_RandomUint8() { fuzzerInvocationCounter++; - return (Uint8) SDLTest_RandomInt(&rndContext) & 0x000000FF; + return (Uint8)SDLTest_RandomInt(&rndContext) & 0x000000FF; } -Sint8 -SDLTest_RandomSint8() +Sint8 SDLTest_RandomSint8() { fuzzerInvocationCounter++; - return (Sint8) SDLTest_RandomInt(&rndContext) & 0x000000FF; + return (Sint8)SDLTest_RandomInt(&rndContext) & 0x000000FF; } Uint16 @@ -96,7 +92,7 @@ SDLTest_RandomUint16() { fuzzerInvocationCounter++; - return (Uint16) SDLTest_RandomInt(&rndContext) & 0x0000FFFF; + return (Uint16)SDLTest_RandomInt(&rndContext) & 0x0000FFFF; } Sint16 @@ -104,7 +100,7 @@ SDLTest_RandomSint16() { fuzzerInvocationCounter++; - return (Sint16) SDLTest_RandomInt(&rndContext) & 0x0000FFFF; + return (Sint16)SDLTest_RandomInt(&rndContext) & 0x0000FFFF; } Sint32 @@ -112,7 +108,7 @@ SDLTest_RandomSint32() { fuzzerInvocationCounter++; - return (Sint32) SDLTest_RandomInt(&rndContext); + return (Sint32)SDLTest_RandomInt(&rndContext); } Uint32 @@ -120,13 +116,14 @@ SDLTest_RandomUint32() { fuzzerInvocationCounter++; - return (Uint32) SDLTest_RandomInt(&rndContext); + return (Uint32)SDLTest_RandomInt(&rndContext); } Uint64 SDLTest_RandomUint64() { - union { + union + { Uint64 v64; Uint32 v32[2]; } value; @@ -143,7 +140,8 @@ SDLTest_RandomUint64() Sint64 SDLTest_RandomSint64() { - union { + union + { Uint64 v64; Uint32 v32[2]; } value; @@ -157,8 +155,6 @@ SDLTest_RandomSint64() return (Sint64)value.v64; } - - Sint32 SDLTest_RandomIntegerInRange(Sint32 pMin, Sint32 pMax) { @@ -204,48 +200,47 @@ SDLTest_RandomIntegerInRange(Sint32 pMin, Sint32 pMax) * * \returns Returns a random boundary value for the domain or 0 in case of error */ -static Uint64 -SDLTest_GenerateUnsignedBoundaryValues(const Uint64 maxValue, Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain) +static Uint64 SDLTest_GenerateUnsignedBoundaryValues(const Uint64 maxValue, Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain) { - Uint64 b1, b2; + Uint64 b1, b2; Uint64 delta; Uint64 tempBuf[4]; Uint8 index; - /* Maybe swap */ + /* Maybe swap */ if (boundary1 > boundary2) { b1 = boundary2; b2 = boundary1; } else { b1 = boundary1; b2 = boundary2; - } + } index = 0; if (validDomain == SDL_TRUE) { - if (b1 == b2) { - return b1; - } + if (b1 == b2) { + return b1; + } - /* Generate up to 4 values within bounds */ - delta = b2 - b1; - if (delta < 4) { - do { + /* Generate up to 4 values within bounds */ + delta = b2 - b1; + if (delta < 4) { + do { tempBuf[index] = b1 + index; index++; - } while (index < delta); - } else { - tempBuf[index] = b1; - index++; - tempBuf[index] = b1 + 1; - index++; - tempBuf[index] = b2 - 1; - index++; - tempBuf[index] = b2; - index++; - } + } while (index < delta); } else { - /* Generate up to 2 values outside of bounds */ + tempBuf[index] = b1; + index++; + tempBuf[index] = b1 + 1; + index++; + tempBuf[index] = b2 - 1; + index++; + tempBuf[index] = b2; + index++; + } + } else { + /* Generate up to 2 values outside of bounds */ if (b1 > 0) { tempBuf[index] = b1 - 1; index++; @@ -266,15 +261,13 @@ SDLTest_GenerateUnsignedBoundaryValues(const Uint64 maxValue, Uint64 boundary1, return tempBuf[SDLTest_RandomUint8() % index]; } - -Uint8 -SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain) +Uint8 SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain) { /* max value for Uint8 */ const Uint64 maxValue = UCHAR_MAX; return (Uint8)SDLTest_GenerateUnsignedBoundaryValues(maxValue, - (Uint64) boundary1, (Uint64) boundary2, - validDomain); + (Uint64)boundary1, (Uint64)boundary2, + validDomain); } Uint16 @@ -283,22 +276,22 @@ SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool v /* max value for Uint16 */ const Uint64 maxValue = USHRT_MAX; return (Uint16)SDLTest_GenerateUnsignedBoundaryValues(maxValue, - (Uint64) boundary1, (Uint64) boundary2, - validDomain); + (Uint64)boundary1, (Uint64)boundary2, + validDomain); } Uint32 SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDomain) { - /* max value for Uint32 */ - #if ((ULONG_MAX) == (UINT_MAX)) - const Uint64 maxValue = ULONG_MAX; - #else - const Uint64 maxValue = UINT_MAX; - #endif +/* max value for Uint32 */ +#if ((ULONG_MAX) == (UINT_MAX)) + const Uint64 maxValue = ULONG_MAX; +#else + const Uint64 maxValue = UINT_MAX; +#endif return (Uint32)SDLTest_GenerateUnsignedBoundaryValues(maxValue, - (Uint64) boundary1, (Uint64) boundary2, - validDomain); + (Uint64)boundary1, (Uint64)boundary2, + validDomain); } Uint64 @@ -307,8 +300,8 @@ SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool v /* max value for Uint64 */ const Uint64 maxValue = UINT64_MAX; return SDLTest_GenerateUnsignedBoundaryValues(maxValue, - boundary1, boundary2, - validDomain); + boundary1, boundary2, + validDomain); } /* ! @@ -336,48 +329,47 @@ SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool v * * \returns Returns a random boundary value for the domain or 0 in case of error */ -static Sint64 -SDLTest_GenerateSignedBoundaryValues(const Sint64 minValue, const Sint64 maxValue, Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain) +static Sint64 SDLTest_GenerateSignedBoundaryValues(const Sint64 minValue, const Sint64 maxValue, Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain) { - Sint64 b1, b2; + Sint64 b1, b2; Sint64 delta; Sint64 tempBuf[4]; Uint8 index; - /* Maybe swap */ + /* Maybe swap */ if (boundary1 > boundary2) { b1 = boundary2; b2 = boundary1; } else { b1 = boundary1; b2 = boundary2; - } + } index = 0; if (validDomain == SDL_TRUE) { - if (b1 == b2) { - return b1; - } + if (b1 == b2) { + return b1; + } - /* Generate up to 4 values within bounds */ - delta = b2 - b1; - if (delta < 4) { - do { + /* Generate up to 4 values within bounds */ + delta = b2 - b1; + if (delta < 4) { + do { tempBuf[index] = b1 + index; index++; - } while (index < delta); - } else { - tempBuf[index] = b1; - index++; - tempBuf[index] = b1 + 1; - index++; - tempBuf[index] = b2 - 1; - index++; - tempBuf[index] = b2; - index++; - } + } while (index < delta); } else { - /* Generate up to 2 values outside of bounds */ + tempBuf[index] = b1; + index++; + tempBuf[index] = b1 + 1; + index++; + tempBuf[index] = b2 - 1; + index++; + tempBuf[index] = b2; + index++; + } + } else { + /* Generate up to 2 values outside of bounds */ if (b1 > minValue) { tempBuf[index] = b1 - 1; index++; @@ -398,16 +390,14 @@ SDLTest_GenerateSignedBoundaryValues(const Sint64 minValue, const Sint64 maxValu return tempBuf[SDLTest_RandomUint8() % index]; } - -Sint8 -SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain) +Sint8 SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain) { /* min & max values for Sint8 */ const Sint64 maxValue = SCHAR_MAX; const Sint64 minValue = SCHAR_MIN; return (Sint8)SDLTest_GenerateSignedBoundaryValues(minValue, maxValue, - (Sint64) boundary1, (Sint64) boundary2, - validDomain); + (Sint64)boundary1, (Sint64)boundary2, + validDomain); } Sint16 @@ -417,24 +407,24 @@ SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool v const Sint64 maxValue = SHRT_MAX; const Sint64 minValue = SHRT_MIN; return (Sint16)SDLTest_GenerateSignedBoundaryValues(minValue, maxValue, - (Sint64) boundary1, (Sint64) boundary2, - validDomain); + (Sint64)boundary1, (Sint64)boundary2, + validDomain); } Sint32 SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDomain) { - /* min & max values for Sint32 */ - #if ((ULONG_MAX) == (UINT_MAX)) - const Sint64 maxValue = LONG_MAX; - const Sint64 minValue = LONG_MIN; - #else - const Sint64 maxValue = INT_MAX; - const Sint64 minValue = INT_MIN; - #endif +/* min & max values for Sint32 */ +#if ((ULONG_MAX) == (UINT_MAX)) + const Sint64 maxValue = LONG_MAX; + const Sint64 minValue = LONG_MIN; +#else + const Sint64 maxValue = INT_MAX; + const Sint64 minValue = INT_MIN; +#endif return (Sint32)SDLTest_GenerateSignedBoundaryValues(minValue, maxValue, - (Sint64) boundary1, (Sint64) boundary2, - validDomain); + (Sint64)boundary1, (Sint64)boundary2, + validDomain); } Sint64 @@ -444,26 +434,24 @@ SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool v const Sint64 maxValue = INT64_MAX; const Sint64 minValue = INT64_MIN; return SDLTest_GenerateSignedBoundaryValues(minValue, maxValue, - boundary1, boundary2, - validDomain); + boundary1, boundary2, + validDomain); } -float -SDLTest_RandomUnitFloat() +float SDLTest_RandomUnitFloat() { - return SDLTest_RandomUint32() / (float) UINT_MAX; + return SDLTest_RandomUint32() / (float)UINT_MAX; } -float -SDLTest_RandomFloat() +float SDLTest_RandomFloat() { - return (float) (SDLTest_RandomUnitDouble() * 2.0 * (double)FLT_MAX - (double)(FLT_MAX)); + return (float)(SDLTest_RandomUnitDouble() * 2.0 * (double)FLT_MAX - (double)(FLT_MAX)); } double SDLTest_RandomUnitDouble() { - return (double) (SDLTest_RandomUint64() >> 11) * (1.0/9007199254740992.0); + return (double)(SDLTest_RandomUint64() >> 11) * (1.0 / 9007199254740992.0); } double @@ -472,8 +460,8 @@ SDLTest_RandomDouble() double r = 0.0; double s = 1.0; do { - s /= UINT_MAX + 1.0; - r += (double)SDLTest_RandomInt(&rndContext) * s; + s /= UINT_MAX + 1.0; + r += (double)SDLTest_RandomInt(&rndContext) * s; } while (s > DBL_EPSILON); fuzzerInvocationCounter++; @@ -481,7 +469,6 @@ SDLTest_RandomDouble() return r; } - char * SDLTest_RandomAsciiString() { @@ -494,7 +481,7 @@ SDLTest_RandomAsciiStringWithMaximumLength(int maxLength) int size; if (maxLength < 1) { - SDL_InvalidParamError("maxLength"); + SDL_InvalidParamError("maxLength"); return NULL; } @@ -509,16 +496,15 @@ SDLTest_RandomAsciiStringOfSize(int size) char *string; int counter; - if (size < 1) { - SDL_InvalidParamError("size"); + SDL_InvalidParamError("size"); return NULL; } string = (char *)SDL_malloc((size + 1) * sizeof(char)); - if (string==NULL) { - return NULL; - } + if (string == NULL) { + return NULL; + } for (counter = 0; counter < size; ++counter) { string[counter] = (char)SDLTest_RandomIntegerInRange(32, 126); diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c index 8057b6ae3..ecb75ee93 100644 --- a/src/test/SDL_test_harness.c +++ b/src/test/SDL_test_harness.c @@ -41,15 +41,15 @@ static Uint32 SDLTest_TestCaseTimeout = 3600; /** -* Generates a random run seed string for the harness. The generated seed -* will contain alphanumeric characters (0-9A-Z). -* -* Note: The returned string needs to be deallocated by the caller. -* -* \param length The length of the seed string to generate -* -* \returns The generated seed string -*/ + * Generates a random run seed string for the harness. The generated seed + * will contain alphanumeric characters (0-9A-Z). + * + * Note: The returned string needs to be deallocated by the caller. + * + * \param length The length of the seed string to generate + * + * \returns The generated seed string + */ char * SDLTest_GenerateRunSeed(const int length) { @@ -75,7 +75,7 @@ SDLTest_GenerateRunSeed(const int length) SDLTest_RandomInitTime(&randomContext); for (counter = 0; counter < length; counter++) { unsigned int number = SDLTest_Random(&randomContext); - char ch = (char) (number % (91 - 48)) + 48; + char ch = (char)(number % (91 - 48)) + 48; if (ch >= 58 && ch <= 64) { ch = 65; } @@ -87,18 +87,17 @@ SDLTest_GenerateRunSeed(const int length) } /** -* Generates an execution key for the fuzzer. -* -* \param runSeed The run seed to use -* \param suiteName The name of the test suite -* \param testName The name of the test -* \param iteration The iteration count -* -* \returns The generated execution key to initialize the fuzzer with. -* -*/ -static Uint64 -SDLTest_GenerateExecKey(const char *runSeed, const char *suiteName, const char *testName, int iteration) + * Generates an execution key for the fuzzer. + * + * \param runSeed The run seed to use + * \param suiteName The name of the test suite + * \param testName The name of the test + * \param iteration The iteration count + * + * \returns The generated execution key to initialize the fuzzer with. + * + */ +static Uint64 SDLTest_GenerateExecKey(const char *runSeed, const char *suiteName, const char *testName, int iteration) { SDLTest_Md5Context md5Context; Uint64 *keys; @@ -139,7 +138,7 @@ SDLTest_GenerateExecKey(const char *runSeed, const char *suiteName, const char * suiteNameLength = SDL_strlen(suiteName); testNameLength = SDL_strlen(testName); iterationStringLength = SDL_strlen(iterationString); - entireStringLength = runSeedLength + suiteNameLength + testNameLength + iterationStringLength + 1; + entireStringLength = runSeedLength + suiteNameLength + testNameLength + iterationStringLength + 1; buffer = (char *)SDL_malloc(entireStringLength); if (buffer == NULL) { SDLTest_LogError("Failed to allocate buffer for execKey generation."); @@ -150,7 +149,7 @@ SDLTest_GenerateExecKey(const char *runSeed, const char *suiteName, const char * /* Hash string and use half of the digest as 64bit exec key */ SDLTest_Md5Init(&md5Context); - SDLTest_Md5Update(&md5Context, (unsigned char *)buffer, (unsigned int) entireStringLength); + SDLTest_Md5Update(&md5Context, (unsigned char *)buffer, (unsigned int)entireStringLength); SDLTest_Md5Final(&md5Context); SDL_free(buffer); keys = (Uint64 *)md5Context.digest; @@ -159,17 +158,16 @@ SDLTest_GenerateExecKey(const char *runSeed, const char *suiteName, const char * } /** -* \brief Set timeout handler for test. -* -* Note: SDL_Init(SDL_INIT_TIMER) will be called if it wasn't done so before. -* -* \param timeout Timeout interval in seconds. -* \param callback Function that will be called after timeout has elapsed. -* -* \return Timer id or -1 on failure. -*/ -static SDL_TimerID -SDLTest_SetTestTimeout(int timeout, void (SDLCALL *callback)(void)) + * \brief Set timeout handler for test. + * + * Note: SDL_Init(SDL_INIT_TIMER) will be called if it wasn't done so before. + * + * \param timeout Timeout interval in seconds. + * \param callback Function that will be called after timeout has elapsed. + * + * \return Timer id or -1 on failure. + */ +static SDL_TimerID SDLTest_SetTestTimeout(int timeout, void(SDLCALL *callback)(void)) { Uint32 timeoutInMilliseconds; SDL_TimerID timerID; @@ -204,37 +202,35 @@ SDLTest_SetTestTimeout(int timeout, void (SDLCALL *callback)(void)) } /** -* \brief Timeout handler. Aborts test run and exits harness process. -*/ + * \brief Timeout handler. Aborts test run and exits harness process. + */ #if defined(__WATCOMC__) #pragma aux SDLTest_BailOut aborts; #endif -static SDL_NORETURN void SDLCALL -SDLTest_BailOut(void) +static SDL_NORETURN void SDLCALL SDLTest_BailOut(void) { SDLTest_LogError("TestCaseTimeout timer expired. Aborting test run."); exit(TEST_ABORTED); /* bail out from the test */ } /** -* \brief Execute a test using the given execution key. -* -* \param testSuite Suite containing the test case. -* \param testCase Case to execute. -* \param execKey Execution key for the fuzzer. -* \param forceTestRun Force test to run even if test was disabled in suite. -* -* \returns Test case result. -*/ -static int -SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, const SDLTest_TestCaseReference *testCase, Uint64 execKey, SDL_bool forceTestRun) + * \brief Execute a test using the given execution key. + * + * \param testSuite Suite containing the test case. + * \param testCase Case to execute. + * \param execKey Execution key for the fuzzer. + * \param forceTestRun Force test to run even if test was disabled in suite. + * + * \returns Test case result. + */ +static int SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, const SDLTest_TestCaseReference *testCase, Uint64 execKey, SDL_bool forceTestRun) { SDL_TimerID timer = 0; int testCaseResult = 0; int testResult = 0; int fuzzerCount; - if (testSuite==NULL || testCase==NULL || testSuite->name==NULL || testCase->name==NULL) { + if (testSuite == NULL || testCase == NULL || testSuite->name == NULL || testCase->name == NULL) { SDLTest_LogError("Setup failure: testSuite or testCase references NULL"); return TEST_RESULT_SETUP_FAILURE; } @@ -346,24 +342,24 @@ static void SDLTest_LogTestSuiteSummary(SDLTest_TestSuiteReference *testSuites) /* Gets a timer value in seconds */ static float GetClock() { - float currentClock = SDL_GetPerformanceCounter() / (float) SDL_GetPerformanceFrequency(); + float currentClock = SDL_GetPerformanceCounter() / (float)SDL_GetPerformanceFrequency(); return currentClock; } /** -* \brief Execute a test suite using the given run seed and execution key. -* -* The filter string is matched to the suite name (full comparison) to select a single suite, -* or if no suite matches, it is matched to the test names (full comparison) to select a single test. -* -* \param testSuites Suites containing the test case. -* \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one. -* \param userExecKey Custom execution key provided by user, or 0 to autogenerate one. -* \param filter Filter specification. NULL disables. Case sensitive. -* \param testIterations Number of iterations to run each test case. -* -* \returns Test run result; 0 when all tests passed, 1 if any tests failed. -*/ + * \brief Execute a test suite using the given run seed and execution key. + * + * The filter string is matched to the suite name (full comparison) to select a single suite, + * or if no suite matches, it is matched to the test names (full comparison) to select a single test. + * + * \param testSuites Suites containing the test case. + * \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one. + * \param userExecKey Custom execution key provided by user, or 0 to autogenerate one. + * \param filter Filter specification. NULL disables. Case sensitive. + * \param testIterations Number of iterations to run each test case. + * + * \returns Test run result; 0 when all tests passed, 1 if any tests failed. + */ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations) { int totalNumberOfTests = 0; @@ -446,10 +442,10 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user /* Pre-allocate an array for tracking failed tests (potentially all test cases) */ failedTests = (const SDLTest_TestCaseReference **)SDL_malloc(totalNumberOfTests * sizeof(SDLTest_TestCaseReference *)); - if (failedTests == NULL) { - SDLTest_LogError("Unable to allocate cache for failed tests"); - SDL_Error(SDL_ENOMEM); - return -1; + if (failedTests == NULL) { + SDLTest_LogError("Unable to allocate cache for failed tests"); + SDL_Error(SDL_ENOMEM); + return -1; } /* Initialize filtering */ @@ -499,7 +495,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user } } SDLTest_Log("Exit code: 2"); - SDL_free((void *) failedTests); + SDL_free((void *)failedTests); return 2; } } @@ -514,10 +510,10 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user /* Filter suite if flag set and we have a name */ if (suiteFilter == 1 && suiteFilterName != NULL && testSuite->name != NULL && SDL_strcasecmp(suiteFilterName, testSuite->name) != 0) { - /* Skip suite */ - SDLTest_Log("===== Test Suite %i: '%s' skipped\n", - suiteCounter, - currentSuiteName); + /* Skip suite */ + SDLTest_Log("===== Test Suite %i: '%s' skipped\n", + suiteCounter, + currentSuiteName); } else { /* Reset per-suite counters */ @@ -530,8 +526,8 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user /* Log suite started */ SDLTest_Log("===== Test Suite %i: '%s' started\n", - suiteCounter, - currentSuiteName); + suiteCounter, + currentSuiteName); /* Loop over all test cases */ testCounter = 0; @@ -543,11 +539,11 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user /* Filter tests if flag set and we have a name */ if (testFilter == 1 && testFilterName != NULL && testCase->name != NULL && SDL_strcasecmp(testFilterName, testCase->name) != 0) { - /* Skip test */ - SDLTest_Log("===== Test Case %i.%i: '%s' skipped\n", - suiteCounter, - testCounter, - currentTestName); + /* Skip test */ + SDLTest_Log("===== Test Case %i.%i: '%s' skipped\n", + suiteCounter, + testCounter, + currentTestName); } else { /* Override 'disabled' flag if we specified a test filter (i.e. force run for debugging) */ if (testFilter == 1 && !testCase->enabled) { @@ -560,12 +556,12 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user /* Log test started */ SDLTest_Log("----- Test Case %i.%i: '%s' started", - suiteCounter, - testCounter, - currentTestName); + suiteCounter, + testCounter, + currentTestName); if (testCase->description != NULL && testCase->description[0] != '\0') { SDLTest_Log("Test Description: '%s'", - (testCase->description) ? testCase->description : SDLTEST_INVALID_NAME_FORMAT); + (testCase->description) ? testCase->description : SDLTEST_INVALID_NAME_FORMAT); } /* Loop over all iterations */ @@ -619,7 +615,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Test", currentTestName, "Failed"); break; case TEST_RESULT_NO_ASSERT: - SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT,"Test", currentTestName, "No Asserts"); + SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Test", currentTestName, "No Asserts"); break; } @@ -650,7 +646,6 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user SDLTest_LogError(SDLTEST_LOG_SUMMARY_FORMAT, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount); SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Suite", currentSuiteName, "Failed"); } - } } @@ -680,10 +675,10 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user if (failedNumberOfTests > 0) { SDLTest_Log("Harness input to repro failures:"); for (testCounter = 0; testCounter < failedNumberOfTests; testCounter++) { - SDLTest_Log(" --seed %s --filter %s", runSeed, failedTests[testCounter]->name); + SDLTest_Log(" --seed %s --filter %s", runSeed, failedTests[testCounter]->name); } } - SDL_free((void *) failedTests); + SDL_free((void *)failedTests); SDLTest_Log("Exit code: %d", runResult); return runResult; diff --git a/src/test/SDL_test_imageBlit.c b/src/test/SDL_test_imageBlit.c index 7a45127a2..94c646929 100644 --- a/src/test/SDL_test_imageBlit.c +++ b/src/test/SDL_test_imageBlit.c @@ -25,514 +25,516 @@ /* GIMP RGB C-Source image dump (blit.c) */ static const SDLTest_SurfaceImage_t SDLTest_imageBlit = { - 80, 60, 3, - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" - "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" - "\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377" - "\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0" - "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" - "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" - "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" - "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" - "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" - "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" - "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" - "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" - "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" - "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" - "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" - "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0" - "\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0" - "\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" - "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" - "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0" - "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0" - "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" - "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" - "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" - "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0" - "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0" - "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" - "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" - "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" - "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0" - "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0" - "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" - "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" - "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" - "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0" - "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0" - "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" - "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" - "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" - "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0" - "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0" - "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" - "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" - "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" - "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0" - "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0" - "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" - "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" - "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" - "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0" - "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\0\0\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" - "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" - "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" - "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" - "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" - "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" - "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" - "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377" - "\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377" - "\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377" - "\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377" - "\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377" - "\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377" - "\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" - "\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" - "\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" - "\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" - "\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" - "\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" - "\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" - "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" - "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" - "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" - "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" - "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0" - "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0" - "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0" - "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0" - "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0" - "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0" - "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" - "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" - "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" - "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" - "\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" - "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" - "\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377" - "\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0" - "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" - "\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" - "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" - "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" - "\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377" - "\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0" - "\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0" - "\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0" - "\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0" - "\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0" - "\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0" - "\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377" - "\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0" - "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" - "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" - "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0", + 80, + 60, + 3, + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" + "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" + "\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377" + "\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0" + "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" + "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" + "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" + "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" + "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" + "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" + "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" + "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" + "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" + "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" + "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" + "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0" + "\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0" + "\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" + "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" + "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0" + "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0" + "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" + "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" + "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" + "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0" + "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0" + "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" + "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" + "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" + "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0" + "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0" + "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" + "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" + "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" + "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0" + "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0" + "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" + "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" + "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" + "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0" + "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0" + "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" + "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" + "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" + "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0" + "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0" + "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" + "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" + "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" + "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0" + "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\0\0\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" + "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" + "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" + "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" + "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" + "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377" + "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" + "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377" + "\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377" + "\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377" + "\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377" + "\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377" + "\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377" + "\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" + "\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" + "\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" + "\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" + "\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" + "\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" + "\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" + "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" + "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" + "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" + "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" + "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0" + "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0" + "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0" + "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0" + "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0" + "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0" + "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" + "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" + "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" + "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" + "\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" + "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" + "\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377" + "\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0" + "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" + "\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" + "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0" + "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377" + "\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377" + "\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0" + "\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0" + "\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0" + "\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0" + "\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0" + "\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0" + "\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377" + "\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0" + "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0" + "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377" + "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0", }; /** @@ -540,482 +542,484 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlit = { */ SDL_Surface *SDLTest_ImageBlit() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( - (void*)SDLTest_imageBlit.pixel_data, + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + (void *)SDLTest_imageBlit.pixel_data, SDLTest_imageBlit.width, SDLTest_imageBlit.height, SDLTest_imageBlit.bytes_per_pixel * 8, SDLTest_imageBlit.width * SDLTest_imageBlit.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ + 0xff000000, /* Red bit mask. */ + 0x00ff0000, /* Green bit mask. */ + 0x0000ff00, /* Blue bit mask. */ + 0x000000ff /* Alpha bit mask. */ #else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ + 0x000000ff, /* Red bit mask. */ + 0x0000ff00, /* Green bit mask. */ + 0x00ff0000, /* Blue bit mask. */ + 0xff000000 /* Alpha bit mask. */ #endif - ); - return surface; + ); + return surface; } static const SDLTest_SurfaceImage_t SDLTest_imageBlitColor = { - 80, 60, 3, - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\0\0\24\0\0\0\0\0\0" - "\0\0(\0\0(\0\0\0\0\0\0\0\0<\0\0<\0\0\0\0\0\0\0\0P\0\0P\0\0\0\0\0\0\0\0d\0" - "\0d\0\0\0\0\0\0\0\0x\0\0x\0\0\0\0\0\0\0\0\214\0\0\214\0\0\0\0\0\0\0\0\240" - "\0\0\240\0\0\0\0\0\0\0\0\264\0\0\264\0\0\0\0\0\0\0\0\310\0\0\310\0\0\0\0" - "\0\0\0\0\334\0\0\334\0\0\0\0\0\0\0\0\360\0\0\360\0\0\360\0\0\360\0\0\360" - "\0\0\360\0\0\360\0\0\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\0\0\24\0\0\24\0\0\0\0\0(\0\0" - "(\0\0(\0\0\0\0\0<\0\0<\0\0<\0\0\0\0\0P\0\0P\0\0P\0\0\0\0\0d\0\0d\0\0d\0\0" - "\0\0\0x\0\0x\0\0x\0\0\0\0\0\214\0\0\214\0\0\214\0\0\0\0\0\240\0\0\240\0\0" - "\240\0\0\0\0\0\264\0\0\264\0\0\264\0\0\0\0\0\310\0\0\310\0\0\310\0\0\0\0" - "\0\334\0\0\334\0\0\334\0\0\0\0\0\360\0\0\360\0\0\360\0\0\360\0\0\360\0\0" - "\360\0\0\360\0\0\360\0\0\360\0\0\360\0\0\360\0\0\360\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\0\0\24\0\0\24\0\0\0" - "\0\0(\0\0(\0\0(\0\0\0\0\0<\0\0<\0\0<\0\0\0\0\0P\0\0P\0\0P\0\0\0\0\0d\0\0" - "d\0\0d\0\0\0\0\0x\0\0x\0\0x\0\0\0\0\0\214\0\0\214\0\0\214\0\0\0\0\0\240\0" - "\0\240\0\0\240\0\0\0\0\0\264\0\0\264\0\0\264\0\0\0\0\0\310\0\0\310\0\0\310" - "\0\0\0\0\0\334\0\0\334\0\0\334\0\0\0\0\0\360\0\0\360\0\0\360\0\0\360\0\0" - "\360\0\0\360\0\0\360\0\0\360\0\0\360\0\0\360\0\0\360\0\0\360\0\0\360\0\0" - "\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\360\0\0\360\0\0\360\0\0\360\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0$\0\0$\0\0\0\0\0\0\0\0$\24\0" - "$\24\0\0\0\0\0\0\0$(\0$(\0\0\0\0\0\0\0$<\0$<\0\0\0\0\0\0\0$P\0$P\0\0\0\0" - "\0\0\0$d\0$d\0\0\0\0\0\0\0$x\0$x\0\0\0\0\0\0\0$\214\0$\214\0\0\0\0\0\0\0" - "$\240\0$\240\0\0\0\0\0\0\0$\264\0$\264\0\0\0\0\0\0\0$\310\0$\310\0\0\0\0" - "\0\0\0$\334\0$\334\0\0\0\0\0\0\0$\360\0$\360\0$\360\0$\360\0$\360\0$\360" - "\0$\360\0$\360\0\0\0\0\0\0\0\0\360\0\0\360\0\0\360\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0$\0\0$\0\0$\0\0\0\0\0$\24\0$\24\0$\24\0\0\0\0$(\0$(\0$(\0\0\0\0" - "$<\0$<\0$<\0\0\0\0$P\0$P\0$P\0\0\0\0$d\0$d\0$d\0\0\0\0$x\0$x\0$x\0\0\0\0" - "$\214\0$\214\0$\214\0\0\0\0$\240\0$\240\0$\240\0\0\0\0$\264\0$\264\0$\264" - "\0\0\0\0$\310\0$\310\0$\310\0\0\0\0$\334\0$\334\0$\334\0\0\0\0$\360\0$\360" - "\0$\360\0$\360\0$\360\0$\360\0$\360\0$\360\0$\360\0$\360\0$\360\0$\360\0" - "\0\0\0\0\360\0\0\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0$\0\0$\0\0$\0\0\0\0\0$\24\0" - "$\24\0$\24\0\0\0\0$(\0$(\0$(\0\0\0\0$<\0$<\0$<\0\0\0\0$P\0$P\0$P\0\0\0\0" - "$d\0$d\0$d\0\0\0\0$x\0$x\0$x\0\0\0\0$\214\0$\214\0$\214\0\0\0\0$\240\0$\240" - "\0$\240\0\0\0\0$\264\0$\264\0$\264\0\0\0\0$\310\0$\310\0$\310\0\0\0\0$\334" - "\0$\334\0$\334\0\0\0\0$\360\0$\360\0$\360\0$\360\0$\360\0$\360\0$\360\0$" - "\360\0$\360\0$\360\0$\360\0$\360\0$\360\0$\360\0\0\0\0\0\360\0\0\360\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0$\0\0$\0\0$\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0$\360\0$\360\0$\360\0$\360\0\0\0\0\0\360\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0$\0\0$\0\0$\0\0\0\0" - "\0\0\0\0H\0\0H\0\0\0\0\0\0\0\0H\24\0H\24\0\0\0\0\0\0\0H(\0H(\0\0\0\0\0\0" - "\0H<\0H<\0\0\0\0\0\0\0HP\0HP\0\0\0\0\0\0\0Hd\0Hd\0\0\0\0\0\0\0Hx\0Hx\0\0" - "\0\0\0\0\0H\214\0H\214\0\0\0\0\0\0\0H\240\0H\240\0\0\0\0\0\0\0H\264\0H\264" - "\0\0\0\0\0\0\0H\310\0H\310\0\0\0\0\0\0\0H\334\0H\334\0\0\0\0\0\0\0H\360\0" - "H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0\0\0\0\0\0\0$\360\0$\360" - "\0$\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0$\0\0$\0\0\0\0\0H\0\0H\0\0H\0\0\0\0\0H\24\0H\24\0H\24" - "\0\0\0\0H(\0H(\0H(\0\0\0\0H<\0H<\0H<\0\0\0\0HP\0HP\0HP\0\0\0\0Hd\0Hd\0Hd" - "\0\0\0\0Hx\0Hx\0Hx\0\0\0\0H\214\0H\214\0H\214\0\0\0\0H\240\0H\240\0H\240" - "\0\0\0\0H\264\0H\264\0H\264\0\0\0\0H\310\0H\310\0H\310\0\0\0\0H\334\0H\334" - "\0H\334\0\0\0\0H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0H" - "\360\0H\360\0H\360\0H\360\0\0\0\0$\360\0$\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0$\0\0$\0\0\0\0\0H\0\0" - "H\0\0H\0\0\0\0\0H\24\0H\24\0H\24\0\0\0\0H(\0H(\0H(\0\0\0\0H<\0H<\0H<\0\0" - "\0\0HP\0HP\0HP\0\0\0\0Hd\0Hd\0Hd\0\0\0\0Hx\0Hx\0Hx\0\0\0\0H\214\0H\214\0" - "H\214\0\0\0\0H\240\0H\240\0H\240\0\0\0\0H\264\0H\264\0H\264\0\0\0\0H\310" - "\0H\310\0H\310\0\0\0\0H\334\0H\334\0H\334\0\0\0\0H\360\0H\360\0H\360\0H\360" - "\0H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0" - "\0\0\0$\360\0$\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0$\0\0\0\0\0H\0\0H\0\0H\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0H\360\0H\360\0H\360\0H\360\0\0\0\0$\360\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0H\0\0H\0\0H\0\0\0\0\0\0\0\0l\0\0l\0\0\0\0\0\0\0\0l\24\0l\24\0\0\0\0\0\0" - "\0l(\0l(\0\0\0\0\0\0\0l<\0l<\0\0\0\0\0\0\0lP\0lP\0\0\0\0\0\0\0ld\0ld\0\0" - "\0\0\0\0\0lx\0lx\0\0\0\0\0\0\0l\214\0l\214\0\0\0\0\0\0\0l\240\0l\240\0\0" - "\0\0\0\0\0l\264\0l\264\0\0\0\0\0\0\0l\310\0l\310\0\0\0\0\0\0\0l\334\0l\334" - "\0\0\0\0\0\0\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360\0\0" - "\0\0\0\0\0H\360\0H\360\0H\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0H\0\0H\0\0\0\0\0l\0\0l\0\0l\0\0" - "\0\0\0l\24\0l\24\0l\24\0\0\0\0l(\0l(\0l(\0\0\0\0l<\0l<\0l<\0\0\0\0lP\0lP" - "\0lP\0\0\0\0ld\0ld\0ld\0\0\0\0lx\0lx\0lx\0\0\0\0l\214\0l\214\0l\214\0\0\0" - "\0l\240\0l\240\0l\240\0\0\0\0l\264\0l\264\0l\264\0\0\0\0l\310\0l\310\0l\310" - "\0\0\0\0l\334\0l\334\0l\334\0\0\0\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360" - "\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360\0\0\0\0H\360\0H\360\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0H\0" - "\0H\0\0\0\0\0l\0\0l\0\0l\0\0\0\0\0l\24\0l\24\0l\24\0\0\0\0l(\0l(\0l(\0\0" - "\0\0l<\0l<\0l<\0\0\0\0lP\0lP\0lP\0\0\0\0ld\0ld\0ld\0\0\0\0lx\0lx\0lx\0\0" - "\0\0l\214\0l\214\0l\214\0\0\0\0l\240\0l\240\0l\240\0\0\0\0l\264\0l\264\0" - "l\264\0\0\0\0l\310\0l\310\0l\310\0\0\0\0l\334\0l\334\0l\334\0\0\0\0l\360" - "\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360\0" - "l\360\0l\360\0l\360\0\0\0\0H\360\0H\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0H\0\0\0\0\0l\0\0l\0\0l\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0l\360\0l\360\0l\360\0l\360" - "\0\0\0\0H\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0l\0\0l\0\0l\0\0\0\0\0\0\0\0\220\0\0\220\0\0\0\0\0\0\0" - "\0\220\24\0\220\24\0\0\0\0\0\0\0\220(\0\220(\0\0\0\0\0\0\0\220<\0\220<\0" - "\0\0\0\0\0\0\220P\0\220P\0\0\0\0\0\0\0\220d\0\220d\0\0\0\0\0\0\0\220x\0\220" - "x\0\0\0\0\0\0\0\220\214\0\220\214\0\0\0\0\0\0\0\220\240\0\220\240\0\0\0\0" - "\0\0\0\220\264\0\220\264\0\0\0\0\0\0\0\220\310\0\220\310\0\0\0\0\0\0\0\220" - "\334\0\220\334\0\0\0\0\0\0\0\220\360\0\220\360\0\220\360\0\220\360\0\220" - "\360\0\220\360\0\220\360\0\220\360\0\0\0\0\0\0\0l\360\0l\360\0l\360\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0l\0\0l\0\0\0\0\0\220\0\0\220\0\0\220\0\0\0\0\0\220\24\0\220\24\0" - "\220\24\0\0\0\0\220(\0\220(\0\220(\0\0\0\0\220<\0\220<\0\220<\0\0\0\0\220" - "P\0\220P\0\220P\0\0\0\0\220d\0\220d\0\220d\0\0\0\0\220x\0\220x\0\220x\0\0" - "\0\0\220\214\0\220\214\0\220\214\0\0\0\0\220\240\0\220\240\0\220\240\0\0" - "\0\0\220\264\0\220\264\0\220\264\0\0\0\0\220\310\0\220\310\0\220\310\0\0" - "\0\0\220\334\0\220\334\0\220\334\0\0\0\0\220\360\0\220\360\0\220\360\0\220" - "\360\0\220\360\0\220\360\0\220\360\0\220\360\0\220\360\0\220\360\0\220\360" - "\0\220\360\0\0\0\0l\360\0l\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0l\0\0l\0\0\0\0\0\220\0\0\220\0\0\220" - "\0\0\0\0\0\220\24\0\220\24\0\220\24\0\0\0\0\220(\0\220(\0\220(\0\0\0\0\220" - "<\0\220<\0\220<\0\0\0\0\220P\0\220P\0\220P\0\0\0\0\220d\0\220d\0\220d\0\0" - "\0\0\220x\0\220x\0\220x\0\0\0\0\220\214\0\220\214\0\220\214\0\0\0\0\220\240" - "\0\220\240\0\220\240\0\0\0\0\220\264\0\220\264\0\220\264\0\0\0\0\220\310" - "\0\220\310\0\220\310\0\0\0\0\220\334\0\220\334\0\220\334\0\0\0\0\220\360" - "\0\220\360\0\220\360\0\220\360\0\220\360\0\220\360\0\220\360\0\220\360\0" - "\220\360\0\220\360\0\220\360\0\220\360\0\220\360\0\220\360\0\0\0\0l\360\0" - "l\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0l\0\0\0\0\0\220\0\0\220\0\0\220\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\220\360\0\220\360\0\220\360\0\220\360\0\0\0\0l\360" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\220\0\0\220\0\0\220\0\0\0\0\0\0\0\0\264\0\0\264\0\0\0\0\0\0\0\0" - "\264\24\0\264\24\0\0\0\0\0\0\0\264(\0\264(\0\0\0\0\0\0\0\264<\0\264<\0\0" - "\0\0\0\0\0\264P\0\264P\0\0\0\0\0\0\0\264d\0\264d\0\0\0\0\0\0\0\264x\0\264" - "x\0\0\0\0\0\0\0\264\214\0\264\214\0\0\0\0\0\0\0\264\240\0\264\240\0\0\0\0" - "\0\0\0\264\264\0\264\264\0\0\0\0\0\0\0\264\310\0\264\310\0\0\0\0\0\0\0\264" - "\334\0\264\334\0\0\0\0\0\0\0\264\360\0\264\360\0\264\360\0\264\360\0\264" - "\360\0\264\360\0\264\360\0\264\360\0\0\0\0\0\0\0\220\360\0\220\360\0\220" - "\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\220\0\0\220\0\0\0\0\0\264\0\0\264\0\0\264\0\0\0\0\0\264" - "\24\0\264\24\0\264\24\0\0\0\0\264(\0\264(\0\264(\0\0\0\0\264<\0\264<\0\264" - "<\0\0\0\0\264P\0\264P\0\264P\0\0\0\0\264d\0\264d\0\264d\0\0\0\0\264x\0\264" - "x\0\264x\0\0\0\0\264\214\0\264\214\0\264\214\0\0\0\0\264\240\0\264\240\0" - "\264\240\0\0\0\0\264\264\0\264\264\0\264\264\0\0\0\0\264\310\0\264\310\0" - "\264\310\0\0\0\0\264\334\0\264\334\0\264\334\0\0\0\0\264\360\0\264\360\0" - "\264\360\0\264\360\0\264\360\0\264\360\0\264\360\0\264\360\0\264\360\0\264" - "\360\0\264\360\0\264\360\0\0\0\0\220\360\0\220\360\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\220\0\0\220\0" - "\0\0\0\0\264\0\0\264\0\0\264\0\0\0\0\0\264\24\0\264\24\0\264\24\0\0\0\0\264" - "(\0\264(\0\264(\0\0\0\0\264<\0\264<\0\264<\0\0\0\0\264P\0\264P\0\264P\0\0" - "\0\0\264d\0\264d\0\264d\0\0\0\0\264x\0\264x\0\264x\0\0\0\0\264\214\0\264" - "\214\0\264\214\0\0\0\0\264\240\0\264\240\0\264\240\0\0\0\0\264\264\0\264" - "\264\0\264\264\0\0\0\0\264\310\0\264\310\0\264\310\0\0\0\0\264\334\0\264" - "\334\0\264\334\0\0\0\0\264\360\0\264\360\0\264\360\0\264\360\0\264\360\0" - "\264\360\0\264\360\0\264\360\0\264\360\0\264\360\0\264\360\0\264\360\0\264" - "\360\0\264\360\0\0\0\0\220\360\0\220\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\220\0\0\0\0\0\264\0\0\264\0\0" - "\264\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\264\360\0" - "\264\360\0\264\360\0\264\360\0\0\0\0\220\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\264\0\0\264\0\0\264" - "\0\0\0\0\0\0\0\0\330\0\0\330\0\0\0\0\0\0\0\0\330\24\0\330\24\0\0\0\0\0\0" - "\0\330(\0\330(\0\0\0\0\0\0\0\330<\0\330<\0\0\0\0\0\0\0\330P\0\330P\0\0\0" - "\0\0\0\0\330d\0\330d\0\0\0\0\0\0\0\330x\0\330x\0\0\0\0\0\0\0\330\214\0\330" - "\214\0\0\0\0\0\0\0\330\240\0\330\240\0\0\0\0\0\0\0\330\264\0\330\264\0\0" - "\0\0\0\0\0\330\310\0\330\310\0\0\0\0\0\0\0\330\334\0\330\334\0\0\0\0\0\0" - "\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0" - "\330\360\0\0\0\0\0\0\0\264\360\0\264\360\0\264\360\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\264\0\0" - "\264\0\0\0\0\0\330\0\0\330\0\0\330\0\0\0\0\0\330\24\0\330\24\0\330\24\0\0" - "\0\0\330(\0\330(\0\330(\0\0\0\0\330<\0\330<\0\330<\0\0\0\0\330P\0\330P\0" - "\330P\0\0\0\0\330d\0\330d\0\330d\0\0\0\0\330x\0\330x\0\330x\0\0\0\0\330\214" - "\0\330\214\0\330\214\0\0\0\0\330\240\0\330\240\0\330\240\0\0\0\0\330\264" - "\0\330\264\0\330\264\0\0\0\0\330\310\0\330\310\0\330\310\0\0\0\0\330\334" - "\0\330\334\0\330\334\0\0\0\0\330\360\0\330\360\0\330\360\0\330\360\0\330" - "\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360" - "\0\0\0\0\264\360\0\264\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\264\0\0\264\0\0\0\0\0\330\0\0\330\0\0" - "\330\0\0\0\0\0\330\24\0\330\24\0\330\24\0\0\0\0\330(\0\330(\0\330(\0\0\0" - "\0\330<\0\330<\0\330<\0\0\0\0\330P\0\330P\0\330P\0\0\0\0\330d\0\330d\0\330" - "d\0\0\0\0\330x\0\330x\0\330x\0\0\0\0\330\214\0\330\214\0\330\214\0\0\0\0" - "\330\240\0\330\240\0\330\240\0\0\0\0\330\264\0\330\264\0\330\264\0\0\0\0" - "\330\310\0\330\310\0\330\310\0\0\0\0\330\334\0\330\334\0\330\334\0\0\0\0" - "\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330" - "\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0\0\0\0" - "\264\360\0\264\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\264\0\0\0\0\0\330\0\0\330\0\0\330\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\330\360\0\330\360\0\330\360\0\330" - "\360\0\0\0\0\264\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\330\0\0\330\0\0\330\0\0\0\0\0\0\0\0\374\0\0" - "\374\0\0\0\0\0\0\0\0\374\24\0\374\24\0\0\0\0\0\0\0\374(\0\374(\0\0\0\0\0" - "\0\0\374<\0\374<\0\0\0\0\0\0\0\374P\0\374P\0\0\0\0\0\0\0\374d\0\374d\0\0" - "\0\0\0\0\0\374x\0\374x\0\0\0\0\0\0\0\374\214\0\374\214\0\0\0\0\0\0\0\374" - "\240\0\374\240\0\0\0\0\0\0\0\374\264\0\374\264\0\0\0\0\0\0\0\374\310\0\374" - "\310\0\0\0\0\0\0\0\374\334\0\374\334\0\0\0\0\0\0\0\374\360\0\374\360\0\374" - "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\330" - "\360\0\330\360\0\330\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\330\0\0\330\0\0\0\0\0\374\0\0\374" - "\0\0\374\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0\374(\0\374(\0" - "\0\0\0\374<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0\0\374d\0\374d" - "\0\374d\0\0\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374\214\0\374\214\0" - "\0\0\0\374\240\0\374\240\0\374\240\0\0\0\0\374\264\0\374\264\0\374\264\0" - "\0\0\0\374\310\0\374\310\0\374\310\0\0\0\0\374\334\0\374\334\0\374\334\0" - "\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" - "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\330\360\0\330" - "\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\330\0\0\330\0\0\0\0\0\374\0\0\374\0\0\374\0\0\0\0\0\374\24\0" - "\374\24\0\374\24\0\0\0\0\374(\0\374(\0\374(\0\0\0\0\374<\0\374<\0\374<\0" - "\0\0\0\374P\0\374P\0\374P\0\0\0\0\374d\0\374d\0\374d\0\0\0\0\374x\0\374x" - "\0\374x\0\0\0\0\374\214\0\374\214\0\374\214\0\0\0\0\374\240\0\374\240\0\374" - "\240\0\0\0\0\374\264\0\374\264\0\374\264\0\0\0\0\374\310\0\374\310\0\374" - "\310\0\0\0\0\374\334\0\374\334\0\374\334\0\0\0\0\374\360\0\374\360\0\374" - "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" - "\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\330\360\0\330\360\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\330" - "\0\0\0\0\0\374\0\0\374\0\0\374\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0" - "\374(\0\374(\0\374(\0\0\0\0\374<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374" - "P\0\0\0\0\374d\0\374d\0\374d\0\0\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0" - "\374\214\0\374\214\0\0\0\0\374\240\0\374\240\0\374\240\0\0\0\0\374\264\0" - "\374\264\0\374\264\0\0\0\0\374\310\0\374\310\0\374\310\0\0\0\0\374\334\0" - "\374\334\0\374\334\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" - "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" - "\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\330\360\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374" - "\0\0\374\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0\374(\0\374(\0" - "\0\0\0\374<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0\0\374d\0\374d" - "\0\374d\0\0\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374\214\0\374\214\0" - "\0\0\0\374\240\0\374\240\0\374\240\0\0\0\0\374\264\0\374\264\0\374\264\0" - "\0\0\0\374\310\0\374\310\0\374\310\0\0\0\0\374\334\0\374\334\0\374\334\0" - "\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" - "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" - "\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374\0\0\374" - "\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0\374(\0\374(\0\0\0\0\374" - "<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0\0\374d\0\374d\0\374d\0\0" - "\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374\214\0\374\214\0\0\0\0\374\240" - "\0\374\240\0\374\240\0\0\0\0\374\264\0\374\264\0\374\264\0\0\0\0\374\310" - "\0\374\310\0\374\310\0\0\0\0\374\334\0\374\334\0\374\334\0\0\0\0\374\360" - "\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360" - "\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\374\0\0\374\0\0\374\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0\374" - "(\0\374(\0\0\0\0\374<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0\0\374" - "d\0\374d\0\374d\0\0\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374\214\0\374" - "\214\0\0\0\0\374\240\0\374\240\0\374\240\0\0\0\0\374\264\0\374\264\0\374" - "\264\0\0\0\0\374\310\0\374\310\0\374\310\0\0\0\0\374\334\0\374\334\0\374" - "\334\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\374\334" - "\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\374\334\0\0" - "\0\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374\0\0\374\0\0\0\0" - "\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0\374(\0\374(\0\0\0\0\374<\0\374" - "<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0\0\374d\0\374d\0\374d\0\0\0\0\374" - "x\0\374x\0\374x\0\0\0\0\374\214\0\374\214\0\374\214\0\0\0\0\374\240\0\374" - "\240\0\374\240\0\0\0\0\374\264\0\374\264\0\374\264\0\0\0\0\374\310\0\374" - "\310\0\374\310\0\0\0\0\374\334\0\374\334\0\374\334\0\0\0\0\374\360\0\374" - "\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360\0\374" - "\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374" - "\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\374\0\0\374\0\0\374\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374" - "(\0\374(\0\374(\0\0\0\0\374<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0" - "\0\0\374d\0\374d\0\374d\0\0\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374" - "\214\0\374\214\0\0\0\0\374\240\0\374\240\0\374\240\0\0\0\0\374\264\0\374" - "\264\0\374\264\0\0\0\0\374\310\0\374\310\0\374\310\0\0\0\0\374\334\0\374" - "\334\0\374\334\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" - "\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374" - "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\374\0\0\374\0\0\374\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0" - "\374(\0\374(\0\0\0\0\374<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0" - "\0\374d\0\374d\0\374d\0\0\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374\214" - "\0\374\214\0\0\0\0\374\240\0\374\240\0\374\240\0\0\0\0\374\264\0\374\264" - "\0\374\264\0\0\0\0\374\310\0\374\310\0\374\310\0\0\0\0\374\334\0\374\334" - "\0\374\334\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374" - "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" - "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\374\0\0\374\0\0\374\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0\374" - "(\0\374(\0\0\0\0\374<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0\0\374" - "d\0\374d\0\374d\0\0\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374\214\0\374" - "\214\0\0\0\0\374\240\0\374\240\0\374\240\0\0\0\0\374\264\0\374\264\0\374" - "\264\0\0\0\0\374\310\0\374\310\0\374\310\0\0\0\0\374\334\0\374\334\0\374" - "\334\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" - "\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0" - "\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374" - "\0\0\374\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0\374(\0\374(\0" - "\0\0\0\374<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0\0\374d\0\374d" - "\0\374d\0\0\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374\214\0\374\214\0" - "\0\0\0\374\240\0\374\240\0\374\240\0\0\0\0\374\264\0\374\264\0\374\264\0" - "\0\0\0\374\310\0\374\310\0\374\310\0\0\0\0\374\334\0\374\334\0\374\334\0" - "\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" - "\0\374\360\0\374\360\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360" - "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374\0\0\374" - "\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0\374(\0\374(\0\0\0\0\374" - "<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0\0\374d\0\374d\0\374d\0\0" - "\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374\214\0\374\214\0\0\0\0\374\240" - "\0\374\240\0\374\240\0\0\0\0\374\264\0\374\264\0\374\264\0\0\0\0\374\310" - "\0\374\310\0\374\310\0\0\0\0\374\334\0\374\334\0\374\334\0\0\0\0\374\360" - "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" - "\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374" - "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374\0\0\374" - "\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0\374(\0\374(\0\0\0\0\374" - "<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0\0\374d\0\374d\0\374d\0\0" - "\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374\214\0\374\214\0\0\0\0\374\240" - "\0\374\240\0\374\240\0\0\0\0\374\264\0\374\264\0\374\264\0\0\0\0\374\310" - "\0\374\310\0\374\310\0\0\0\0\374\334\0\374\334\0\374\334\0\0\0\0\374\360" - "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" - "\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374" - "\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374\0\0\0\0\0\0\0\0\374\24" - "\0\374\24\0\0\0\0\0\0\0\374(\0\374(\0\0\0\0\0\0\0\374<\0\374<\0\0\0\0\0\0" - "\0\374P\0\374P\0\0\0\0\0\0\0\374d\0\374d\0\0\0\0\0\0\0\374x\0\374x\0\0\0" - "\0\0\0\0\374\214\0\374\214\0\0\0\0\0\0\0\374\240\0\374\240\0\0\0\0\0\0\0" - "\374\264\0\374\264\0\0\0\0\0\0\0\374\310\0\374\310\0\0\0\0\0\0\0\374\334" - "\0\374\334\0\0\0\0\0\0\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\374\360\0" - "\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\0" - "\0\0\0\0\0\0\0\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374\0\0\0" - "\0\0\0\0\0\374\24\0\374\24\0\0\0\0\0\0\0\374(\0\374(\0\0\0\0\0\0\0\374<\0" - "\374<\0\0\0\0\0\0\0\374P\0\374P\0\0\0\0\0\0\0\374d\0\374d\0\0\0\0\0\0\0\374" - "x\0\374x\0\0\0\0\0\0\0\374\214\0\374\214\0\0\0\0\0\0\0\374\240\0\374\240" - "\0\0\0\0\0\0\0\374\264\0\374\264\0\0\0\0\0\0\0\374\310\0\374\310\0\0\0\0" - "\0\0\0\374\334\0\374\334\0\0\0\0\0\0\0\374\360\0\374\360\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374" - "\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374\0\0\0\0\0\0\0\0\374\24\0" - "\374\24\0\0\0\0\0\0\0\374(\0\374(\0\0\0\0\0\0\0\374<\0\374<\0\0\0\0\0\0\0" - "\374P\0\374P\0\0\0\0\0\0\0\374d\0\374d\0\0\0\0\0\0\0\374x\0\374x\0\0\0\0" - "\0\0\0\374\214\0\374\214\0\0\0\0\0\0\0\374\240\0\374\240\0\0\0\0\0\0\0\374" - "\264\0\374\264\0\0\0\0\0\0\0\374\310\0\374\310\0\0\0\0\0\0\0\374\334\0\374" - "\334\0\0\0\0\0\0\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\374\0\0\374\0\0\374\0\0\0\0\0\374\24\0\374\24\0\374\24\0" - "\0\0\0\374(\0\374(\0\374(\0\0\0\0\374<\0\374<\0\374<\0\0\0\0\374P\0\374P" - "\0\374P\0\0\0\0\374d\0\374d\0\374d\0\0\0\0\374x\0\374x\0\374x\0\0\0\0\374" - "\214\0\374\214\0\374\214\0\0\0\0\374\240\0\374\240\0\374\240\0\0\0\0\374" - "\264\0\374\264\0\374\264\0\0\0\0\374\310\0\374\310\0\374\310\0\0\0\0\374" - "\334\0\374\334\0\374\334\0\0\0\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374\0\0\0\0\0\0\0\0" - "\374\24\0\374\24\0\0\0\0\0\0\0\374(\0\374(\0\0\0\0\0\0\0\374<\0\374<\0\0" - "\0\0\0\0\0\374P\0\374P\0\0\0\0\0\0\0\374d\0\374d\0\0\0\0\0\0\0\374x\0\374" - "x\0\0\0\0\0\0\0\374\214\0\374\214\0\0\0\0\0\0\0\374\240\0\374\240\0\0\0\0" - "\0\0\0\374\264\0\374\264\0\0\0\0\0\0\0\374\310\0\374\310\0\0\0\0\0\0\0\374" - "\334\0\374\334\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374" - "\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", + 80, + 60, + 3, + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\0\0\24\0\0\0\0\0\0" + "\0\0(\0\0(\0\0\0\0\0\0\0\0<\0\0<\0\0\0\0\0\0\0\0P\0\0P\0\0\0\0\0\0\0\0d\0" + "\0d\0\0\0\0\0\0\0\0x\0\0x\0\0\0\0\0\0\0\0\214\0\0\214\0\0\0\0\0\0\0\0\240" + "\0\0\240\0\0\0\0\0\0\0\0\264\0\0\264\0\0\0\0\0\0\0\0\310\0\0\310\0\0\0\0" + "\0\0\0\0\334\0\0\334\0\0\0\0\0\0\0\0\360\0\0\360\0\0\360\0\0\360\0\0\360" + "\0\0\360\0\0\360\0\0\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\0\0\24\0\0\24\0\0\0\0\0(\0\0" + "(\0\0(\0\0\0\0\0<\0\0<\0\0<\0\0\0\0\0P\0\0P\0\0P\0\0\0\0\0d\0\0d\0\0d\0\0" + "\0\0\0x\0\0x\0\0x\0\0\0\0\0\214\0\0\214\0\0\214\0\0\0\0\0\240\0\0\240\0\0" + "\240\0\0\0\0\0\264\0\0\264\0\0\264\0\0\0\0\0\310\0\0\310\0\0\310\0\0\0\0" + "\0\334\0\0\334\0\0\334\0\0\0\0\0\360\0\0\360\0\0\360\0\0\360\0\0\360\0\0" + "\360\0\0\360\0\0\360\0\0\360\0\0\360\0\0\360\0\0\360\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\0\0\24\0\0\24\0\0\0" + "\0\0(\0\0(\0\0(\0\0\0\0\0<\0\0<\0\0<\0\0\0\0\0P\0\0P\0\0P\0\0\0\0\0d\0\0" + "d\0\0d\0\0\0\0\0x\0\0x\0\0x\0\0\0\0\0\214\0\0\214\0\0\214\0\0\0\0\0\240\0" + "\0\240\0\0\240\0\0\0\0\0\264\0\0\264\0\0\264\0\0\0\0\0\310\0\0\310\0\0\310" + "\0\0\0\0\0\334\0\0\334\0\0\334\0\0\0\0\0\360\0\0\360\0\0\360\0\0\360\0\0" + "\360\0\0\360\0\0\360\0\0\360\0\0\360\0\0\360\0\0\360\0\0\360\0\0\360\0\0" + "\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\360\0\0\360\0\0\360\0\0\360\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0$\0\0$\0\0\0\0\0\0\0\0$\24\0" + "$\24\0\0\0\0\0\0\0$(\0$(\0\0\0\0\0\0\0$<\0$<\0\0\0\0\0\0\0$P\0$P\0\0\0\0" + "\0\0\0$d\0$d\0\0\0\0\0\0\0$x\0$x\0\0\0\0\0\0\0$\214\0$\214\0\0\0\0\0\0\0" + "$\240\0$\240\0\0\0\0\0\0\0$\264\0$\264\0\0\0\0\0\0\0$\310\0$\310\0\0\0\0" + "\0\0\0$\334\0$\334\0\0\0\0\0\0\0$\360\0$\360\0$\360\0$\360\0$\360\0$\360" + "\0$\360\0$\360\0\0\0\0\0\0\0\0\360\0\0\360\0\0\360\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0$\0\0$\0\0$\0\0\0\0\0$\24\0$\24\0$\24\0\0\0\0$(\0$(\0$(\0\0\0\0" + "$<\0$<\0$<\0\0\0\0$P\0$P\0$P\0\0\0\0$d\0$d\0$d\0\0\0\0$x\0$x\0$x\0\0\0\0" + "$\214\0$\214\0$\214\0\0\0\0$\240\0$\240\0$\240\0\0\0\0$\264\0$\264\0$\264" + "\0\0\0\0$\310\0$\310\0$\310\0\0\0\0$\334\0$\334\0$\334\0\0\0\0$\360\0$\360" + "\0$\360\0$\360\0$\360\0$\360\0$\360\0$\360\0$\360\0$\360\0$\360\0$\360\0" + "\0\0\0\0\360\0\0\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0$\0\0$\0\0$\0\0\0\0\0$\24\0" + "$\24\0$\24\0\0\0\0$(\0$(\0$(\0\0\0\0$<\0$<\0$<\0\0\0\0$P\0$P\0$P\0\0\0\0" + "$d\0$d\0$d\0\0\0\0$x\0$x\0$x\0\0\0\0$\214\0$\214\0$\214\0\0\0\0$\240\0$\240" + "\0$\240\0\0\0\0$\264\0$\264\0$\264\0\0\0\0$\310\0$\310\0$\310\0\0\0\0$\334" + "\0$\334\0$\334\0\0\0\0$\360\0$\360\0$\360\0$\360\0$\360\0$\360\0$\360\0$" + "\360\0$\360\0$\360\0$\360\0$\360\0$\360\0$\360\0\0\0\0\0\360\0\0\360\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0$\0\0$\0\0$\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0$\360\0$\360\0$\360\0$\360\0\0\0\0\0\360\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0$\0\0$\0\0$\0\0\0\0" + "\0\0\0\0H\0\0H\0\0\0\0\0\0\0\0H\24\0H\24\0\0\0\0\0\0\0H(\0H(\0\0\0\0\0\0" + "\0H<\0H<\0\0\0\0\0\0\0HP\0HP\0\0\0\0\0\0\0Hd\0Hd\0\0\0\0\0\0\0Hx\0Hx\0\0" + "\0\0\0\0\0H\214\0H\214\0\0\0\0\0\0\0H\240\0H\240\0\0\0\0\0\0\0H\264\0H\264" + "\0\0\0\0\0\0\0H\310\0H\310\0\0\0\0\0\0\0H\334\0H\334\0\0\0\0\0\0\0H\360\0" + "H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0\0\0\0\0\0\0$\360\0$\360" + "\0$\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0$\0\0$\0\0\0\0\0H\0\0H\0\0H\0\0\0\0\0H\24\0H\24\0H\24" + "\0\0\0\0H(\0H(\0H(\0\0\0\0H<\0H<\0H<\0\0\0\0HP\0HP\0HP\0\0\0\0Hd\0Hd\0Hd" + "\0\0\0\0Hx\0Hx\0Hx\0\0\0\0H\214\0H\214\0H\214\0\0\0\0H\240\0H\240\0H\240" + "\0\0\0\0H\264\0H\264\0H\264\0\0\0\0H\310\0H\310\0H\310\0\0\0\0H\334\0H\334" + "\0H\334\0\0\0\0H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0H" + "\360\0H\360\0H\360\0H\360\0\0\0\0$\360\0$\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0$\0\0$\0\0\0\0\0H\0\0" + "H\0\0H\0\0\0\0\0H\24\0H\24\0H\24\0\0\0\0H(\0H(\0H(\0\0\0\0H<\0H<\0H<\0\0" + "\0\0HP\0HP\0HP\0\0\0\0Hd\0Hd\0Hd\0\0\0\0Hx\0Hx\0Hx\0\0\0\0H\214\0H\214\0" + "H\214\0\0\0\0H\240\0H\240\0H\240\0\0\0\0H\264\0H\264\0H\264\0\0\0\0H\310" + "\0H\310\0H\310\0\0\0\0H\334\0H\334\0H\334\0\0\0\0H\360\0H\360\0H\360\0H\360" + "\0H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0H\360\0" + "\0\0\0$\360\0$\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0$\0\0\0\0\0H\0\0H\0\0H\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0H\360\0H\360\0H\360\0H\360\0\0\0\0$\360\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0H\0\0H\0\0H\0\0\0\0\0\0\0\0l\0\0l\0\0\0\0\0\0\0\0l\24\0l\24\0\0\0\0\0\0" + "\0l(\0l(\0\0\0\0\0\0\0l<\0l<\0\0\0\0\0\0\0lP\0lP\0\0\0\0\0\0\0ld\0ld\0\0" + "\0\0\0\0\0lx\0lx\0\0\0\0\0\0\0l\214\0l\214\0\0\0\0\0\0\0l\240\0l\240\0\0" + "\0\0\0\0\0l\264\0l\264\0\0\0\0\0\0\0l\310\0l\310\0\0\0\0\0\0\0l\334\0l\334" + "\0\0\0\0\0\0\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360\0\0" + "\0\0\0\0\0H\360\0H\360\0H\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0H\0\0H\0\0\0\0\0l\0\0l\0\0l\0\0" + "\0\0\0l\24\0l\24\0l\24\0\0\0\0l(\0l(\0l(\0\0\0\0l<\0l<\0l<\0\0\0\0lP\0lP" + "\0lP\0\0\0\0ld\0ld\0ld\0\0\0\0lx\0lx\0lx\0\0\0\0l\214\0l\214\0l\214\0\0\0" + "\0l\240\0l\240\0l\240\0\0\0\0l\264\0l\264\0l\264\0\0\0\0l\310\0l\310\0l\310" + "\0\0\0\0l\334\0l\334\0l\334\0\0\0\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360" + "\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360\0\0\0\0H\360\0H\360\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0H\0" + "\0H\0\0\0\0\0l\0\0l\0\0l\0\0\0\0\0l\24\0l\24\0l\24\0\0\0\0l(\0l(\0l(\0\0" + "\0\0l<\0l<\0l<\0\0\0\0lP\0lP\0lP\0\0\0\0ld\0ld\0ld\0\0\0\0lx\0lx\0lx\0\0" + "\0\0l\214\0l\214\0l\214\0\0\0\0l\240\0l\240\0l\240\0\0\0\0l\264\0l\264\0" + "l\264\0\0\0\0l\310\0l\310\0l\310\0\0\0\0l\334\0l\334\0l\334\0\0\0\0l\360" + "\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360\0l\360\0" + "l\360\0l\360\0l\360\0\0\0\0H\360\0H\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0H\0\0\0\0\0l\0\0l\0\0l\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0l\360\0l\360\0l\360\0l\360" + "\0\0\0\0H\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0l\0\0l\0\0l\0\0\0\0\0\0\0\0\220\0\0\220\0\0\0\0\0\0\0" + "\0\220\24\0\220\24\0\0\0\0\0\0\0\220(\0\220(\0\0\0\0\0\0\0\220<\0\220<\0" + "\0\0\0\0\0\0\220P\0\220P\0\0\0\0\0\0\0\220d\0\220d\0\0\0\0\0\0\0\220x\0\220" + "x\0\0\0\0\0\0\0\220\214\0\220\214\0\0\0\0\0\0\0\220\240\0\220\240\0\0\0\0" + "\0\0\0\220\264\0\220\264\0\0\0\0\0\0\0\220\310\0\220\310\0\0\0\0\0\0\0\220" + "\334\0\220\334\0\0\0\0\0\0\0\220\360\0\220\360\0\220\360\0\220\360\0\220" + "\360\0\220\360\0\220\360\0\220\360\0\0\0\0\0\0\0l\360\0l\360\0l\360\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0l\0\0l\0\0\0\0\0\220\0\0\220\0\0\220\0\0\0\0\0\220\24\0\220\24\0" + "\220\24\0\0\0\0\220(\0\220(\0\220(\0\0\0\0\220<\0\220<\0\220<\0\0\0\0\220" + "P\0\220P\0\220P\0\0\0\0\220d\0\220d\0\220d\0\0\0\0\220x\0\220x\0\220x\0\0" + "\0\0\220\214\0\220\214\0\220\214\0\0\0\0\220\240\0\220\240\0\220\240\0\0" + "\0\0\220\264\0\220\264\0\220\264\0\0\0\0\220\310\0\220\310\0\220\310\0\0" + "\0\0\220\334\0\220\334\0\220\334\0\0\0\0\220\360\0\220\360\0\220\360\0\220" + "\360\0\220\360\0\220\360\0\220\360\0\220\360\0\220\360\0\220\360\0\220\360" + "\0\220\360\0\0\0\0l\360\0l\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0l\0\0l\0\0\0\0\0\220\0\0\220\0\0\220" + "\0\0\0\0\0\220\24\0\220\24\0\220\24\0\0\0\0\220(\0\220(\0\220(\0\0\0\0\220" + "<\0\220<\0\220<\0\0\0\0\220P\0\220P\0\220P\0\0\0\0\220d\0\220d\0\220d\0\0" + "\0\0\220x\0\220x\0\220x\0\0\0\0\220\214\0\220\214\0\220\214\0\0\0\0\220\240" + "\0\220\240\0\220\240\0\0\0\0\220\264\0\220\264\0\220\264\0\0\0\0\220\310" + "\0\220\310\0\220\310\0\0\0\0\220\334\0\220\334\0\220\334\0\0\0\0\220\360" + "\0\220\360\0\220\360\0\220\360\0\220\360\0\220\360\0\220\360\0\220\360\0" + "\220\360\0\220\360\0\220\360\0\220\360\0\220\360\0\220\360\0\0\0\0l\360\0" + "l\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0l\0\0\0\0\0\220\0\0\220\0\0\220\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\220\360\0\220\360\0\220\360\0\220\360\0\0\0\0l\360" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\220\0\0\220\0\0\220\0\0\0\0\0\0\0\0\264\0\0\264\0\0\0\0\0\0\0\0" + "\264\24\0\264\24\0\0\0\0\0\0\0\264(\0\264(\0\0\0\0\0\0\0\264<\0\264<\0\0" + "\0\0\0\0\0\264P\0\264P\0\0\0\0\0\0\0\264d\0\264d\0\0\0\0\0\0\0\264x\0\264" + "x\0\0\0\0\0\0\0\264\214\0\264\214\0\0\0\0\0\0\0\264\240\0\264\240\0\0\0\0" + "\0\0\0\264\264\0\264\264\0\0\0\0\0\0\0\264\310\0\264\310\0\0\0\0\0\0\0\264" + "\334\0\264\334\0\0\0\0\0\0\0\264\360\0\264\360\0\264\360\0\264\360\0\264" + "\360\0\264\360\0\264\360\0\264\360\0\0\0\0\0\0\0\220\360\0\220\360\0\220" + "\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\220\0\0\220\0\0\0\0\0\264\0\0\264\0\0\264\0\0\0\0\0\264" + "\24\0\264\24\0\264\24\0\0\0\0\264(\0\264(\0\264(\0\0\0\0\264<\0\264<\0\264" + "<\0\0\0\0\264P\0\264P\0\264P\0\0\0\0\264d\0\264d\0\264d\0\0\0\0\264x\0\264" + "x\0\264x\0\0\0\0\264\214\0\264\214\0\264\214\0\0\0\0\264\240\0\264\240\0" + "\264\240\0\0\0\0\264\264\0\264\264\0\264\264\0\0\0\0\264\310\0\264\310\0" + "\264\310\0\0\0\0\264\334\0\264\334\0\264\334\0\0\0\0\264\360\0\264\360\0" + "\264\360\0\264\360\0\264\360\0\264\360\0\264\360\0\264\360\0\264\360\0\264" + "\360\0\264\360\0\264\360\0\0\0\0\220\360\0\220\360\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\220\0\0\220\0" + "\0\0\0\0\264\0\0\264\0\0\264\0\0\0\0\0\264\24\0\264\24\0\264\24\0\0\0\0\264" + "(\0\264(\0\264(\0\0\0\0\264<\0\264<\0\264<\0\0\0\0\264P\0\264P\0\264P\0\0" + "\0\0\264d\0\264d\0\264d\0\0\0\0\264x\0\264x\0\264x\0\0\0\0\264\214\0\264" + "\214\0\264\214\0\0\0\0\264\240\0\264\240\0\264\240\0\0\0\0\264\264\0\264" + "\264\0\264\264\0\0\0\0\264\310\0\264\310\0\264\310\0\0\0\0\264\334\0\264" + "\334\0\264\334\0\0\0\0\264\360\0\264\360\0\264\360\0\264\360\0\264\360\0" + "\264\360\0\264\360\0\264\360\0\264\360\0\264\360\0\264\360\0\264\360\0\264" + "\360\0\264\360\0\0\0\0\220\360\0\220\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\220\0\0\0\0\0\264\0\0\264\0\0" + "\264\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\264\360\0" + "\264\360\0\264\360\0\264\360\0\0\0\0\220\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\264\0\0\264\0\0\264" + "\0\0\0\0\0\0\0\0\330\0\0\330\0\0\0\0\0\0\0\0\330\24\0\330\24\0\0\0\0\0\0" + "\0\330(\0\330(\0\0\0\0\0\0\0\330<\0\330<\0\0\0\0\0\0\0\330P\0\330P\0\0\0" + "\0\0\0\0\330d\0\330d\0\0\0\0\0\0\0\330x\0\330x\0\0\0\0\0\0\0\330\214\0\330" + "\214\0\0\0\0\0\0\0\330\240\0\330\240\0\0\0\0\0\0\0\330\264\0\330\264\0\0" + "\0\0\0\0\0\330\310\0\330\310\0\0\0\0\0\0\0\330\334\0\330\334\0\0\0\0\0\0" + "\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0" + "\330\360\0\0\0\0\0\0\0\264\360\0\264\360\0\264\360\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\264\0\0" + "\264\0\0\0\0\0\330\0\0\330\0\0\330\0\0\0\0\0\330\24\0\330\24\0\330\24\0\0" + "\0\0\330(\0\330(\0\330(\0\0\0\0\330<\0\330<\0\330<\0\0\0\0\330P\0\330P\0" + "\330P\0\0\0\0\330d\0\330d\0\330d\0\0\0\0\330x\0\330x\0\330x\0\0\0\0\330\214" + "\0\330\214\0\330\214\0\0\0\0\330\240\0\330\240\0\330\240\0\0\0\0\330\264" + "\0\330\264\0\330\264\0\0\0\0\330\310\0\330\310\0\330\310\0\0\0\0\330\334" + "\0\330\334\0\330\334\0\0\0\0\330\360\0\330\360\0\330\360\0\330\360\0\330" + "\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360" + "\0\0\0\0\264\360\0\264\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\264\0\0\264\0\0\0\0\0\330\0\0\330\0\0" + "\330\0\0\0\0\0\330\24\0\330\24\0\330\24\0\0\0\0\330(\0\330(\0\330(\0\0\0" + "\0\330<\0\330<\0\330<\0\0\0\0\330P\0\330P\0\330P\0\0\0\0\330d\0\330d\0\330" + "d\0\0\0\0\330x\0\330x\0\330x\0\0\0\0\330\214\0\330\214\0\330\214\0\0\0\0" + "\330\240\0\330\240\0\330\240\0\0\0\0\330\264\0\330\264\0\330\264\0\0\0\0" + "\330\310\0\330\310\0\330\310\0\0\0\0\330\334\0\330\334\0\330\334\0\0\0\0" + "\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330" + "\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0\330\360\0\0\0\0" + "\264\360\0\264\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\264\0\0\0\0\0\330\0\0\330\0\0\330\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\330\360\0\330\360\0\330\360\0\330" + "\360\0\0\0\0\264\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\330\0\0\330\0\0\330\0\0\0\0\0\0\0\0\374\0\0" + "\374\0\0\0\0\0\0\0\0\374\24\0\374\24\0\0\0\0\0\0\0\374(\0\374(\0\0\0\0\0" + "\0\0\374<\0\374<\0\0\0\0\0\0\0\374P\0\374P\0\0\0\0\0\0\0\374d\0\374d\0\0" + "\0\0\0\0\0\374x\0\374x\0\0\0\0\0\0\0\374\214\0\374\214\0\0\0\0\0\0\0\374" + "\240\0\374\240\0\0\0\0\0\0\0\374\264\0\374\264\0\0\0\0\0\0\0\374\310\0\374" + "\310\0\0\0\0\0\0\0\374\334\0\374\334\0\0\0\0\0\0\0\374\360\0\374\360\0\374" + "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\330" + "\360\0\330\360\0\330\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\330\0\0\330\0\0\0\0\0\374\0\0\374" + "\0\0\374\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0\374(\0\374(\0" + "\0\0\0\374<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0\0\374d\0\374d" + "\0\374d\0\0\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374\214\0\374\214\0" + "\0\0\0\374\240\0\374\240\0\374\240\0\0\0\0\374\264\0\374\264\0\374\264\0" + "\0\0\0\374\310\0\374\310\0\374\310\0\0\0\0\374\334\0\374\334\0\374\334\0" + "\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" + "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\330\360\0\330" + "\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\330\0\0\330\0\0\0\0\0\374\0\0\374\0\0\374\0\0\0\0\0\374\24\0" + "\374\24\0\374\24\0\0\0\0\374(\0\374(\0\374(\0\0\0\0\374<\0\374<\0\374<\0" + "\0\0\0\374P\0\374P\0\374P\0\0\0\0\374d\0\374d\0\374d\0\0\0\0\374x\0\374x" + "\0\374x\0\0\0\0\374\214\0\374\214\0\374\214\0\0\0\0\374\240\0\374\240\0\374" + "\240\0\0\0\0\374\264\0\374\264\0\374\264\0\0\0\0\374\310\0\374\310\0\374" + "\310\0\0\0\0\374\334\0\374\334\0\374\334\0\0\0\0\374\360\0\374\360\0\374" + "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" + "\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\330\360\0\330\360\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\330" + "\0\0\0\0\0\374\0\0\374\0\0\374\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0" + "\374(\0\374(\0\374(\0\0\0\0\374<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374" + "P\0\0\0\0\374d\0\374d\0\374d\0\0\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0" + "\374\214\0\374\214\0\0\0\0\374\240\0\374\240\0\374\240\0\0\0\0\374\264\0" + "\374\264\0\374\264\0\0\0\0\374\310\0\374\310\0\374\310\0\0\0\0\374\334\0" + "\374\334\0\374\334\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" + "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" + "\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\330\360\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374" + "\0\0\374\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0\374(\0\374(\0" + "\0\0\0\374<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0\0\374d\0\374d" + "\0\374d\0\0\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374\214\0\374\214\0" + "\0\0\0\374\240\0\374\240\0\374\240\0\0\0\0\374\264\0\374\264\0\374\264\0" + "\0\0\0\374\310\0\374\310\0\374\310\0\0\0\0\374\334\0\374\334\0\374\334\0" + "\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" + "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" + "\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374\0\0\374" + "\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0\374(\0\374(\0\0\0\0\374" + "<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0\0\374d\0\374d\0\374d\0\0" + "\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374\214\0\374\214\0\0\0\0\374\240" + "\0\374\240\0\374\240\0\0\0\0\374\264\0\374\264\0\374\264\0\0\0\0\374\310" + "\0\374\310\0\374\310\0\0\0\0\374\334\0\374\334\0\374\334\0\0\0\0\374\360" + "\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360" + "\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\374\0\0\374\0\0\374\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0\374" + "(\0\374(\0\0\0\0\374<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0\0\374" + "d\0\374d\0\374d\0\0\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374\214\0\374" + "\214\0\0\0\0\374\240\0\374\240\0\374\240\0\0\0\0\374\264\0\374\264\0\374" + "\264\0\0\0\0\374\310\0\374\310\0\374\310\0\0\0\0\374\334\0\374\334\0\374" + "\334\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\374\334" + "\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\374\334\0\0" + "\0\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374\0\0\374\0\0\0\0" + "\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0\374(\0\374(\0\0\0\0\374<\0\374" + "<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0\0\374d\0\374d\0\374d\0\0\0\0\374" + "x\0\374x\0\374x\0\0\0\0\374\214\0\374\214\0\374\214\0\0\0\0\374\240\0\374" + "\240\0\374\240\0\0\0\0\374\264\0\374\264\0\374\264\0\0\0\0\374\310\0\374" + "\310\0\374\310\0\0\0\0\374\334\0\374\334\0\374\334\0\0\0\0\374\360\0\374" + "\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360\0\374" + "\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374" + "\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\374\0\0\374\0\0\374\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374" + "(\0\374(\0\374(\0\0\0\0\374<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0" + "\0\0\374d\0\374d\0\374d\0\0\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374" + "\214\0\374\214\0\0\0\0\374\240\0\374\240\0\374\240\0\0\0\0\374\264\0\374" + "\264\0\374\264\0\0\0\0\374\310\0\374\310\0\374\310\0\0\0\0\374\334\0\374" + "\334\0\374\334\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" + "\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374" + "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\374\0\0\374\0\0\374\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0" + "\374(\0\374(\0\0\0\0\374<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0" + "\0\374d\0\374d\0\374d\0\0\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374\214" + "\0\374\214\0\0\0\0\374\240\0\374\240\0\374\240\0\0\0\0\374\264\0\374\264" + "\0\374\264\0\0\0\0\374\310\0\374\310\0\374\310\0\0\0\0\374\334\0\374\334" + "\0\374\334\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374" + "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" + "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\374\0\0\374\0\0\374\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0\374" + "(\0\374(\0\0\0\0\374<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0\0\374" + "d\0\374d\0\374d\0\0\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374\214\0\374" + "\214\0\0\0\0\374\240\0\374\240\0\374\240\0\0\0\0\374\264\0\374\264\0\374" + "\264\0\0\0\0\374\310\0\374\310\0\374\310\0\0\0\0\374\334\0\374\334\0\374" + "\334\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" + "\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0" + "\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374" + "\0\0\374\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0\374(\0\374(\0" + "\0\0\0\374<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0\0\374d\0\374d" + "\0\374d\0\0\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374\214\0\374\214\0" + "\0\0\0\374\240\0\374\240\0\374\240\0\0\0\0\374\264\0\374\264\0\374\264\0" + "\0\0\0\374\310\0\374\310\0\374\310\0\0\0\0\374\334\0\374\334\0\374\334\0" + "\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" + "\0\374\360\0\374\360\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360" + "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374\0\0\374" + "\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0\374(\0\374(\0\0\0\0\374" + "<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0\0\374d\0\374d\0\374d\0\0" + "\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374\214\0\374\214\0\0\0\0\374\240" + "\0\374\240\0\374\240\0\0\0\0\374\264\0\374\264\0\374\264\0\0\0\0\374\310" + "\0\374\310\0\374\310\0\0\0\0\374\334\0\374\334\0\374\334\0\0\0\0\374\360" + "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" + "\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374" + "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374\0\0\374" + "\0\0\0\0\0\374\24\0\374\24\0\374\24\0\0\0\0\374(\0\374(\0\374(\0\0\0\0\374" + "<\0\374<\0\374<\0\0\0\0\374P\0\374P\0\374P\0\0\0\0\374d\0\374d\0\374d\0\0" + "\0\0\374x\0\374x\0\374x\0\0\0\0\374\214\0\374\214\0\374\214\0\0\0\0\374\240" + "\0\374\240\0\374\240\0\0\0\0\374\264\0\374\264\0\374\264\0\0\0\0\374\310" + "\0\374\310\0\374\310\0\0\0\0\374\334\0\374\334\0\374\334\0\0\0\0\374\360" + "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" + "\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374" + "\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374\0\0\0\0\0\0\0\0\374\24" + "\0\374\24\0\0\0\0\0\0\0\374(\0\374(\0\0\0\0\0\0\0\374<\0\374<\0\0\0\0\0\0" + "\0\374P\0\374P\0\0\0\0\0\0\0\374d\0\374d\0\0\0\0\0\0\0\374x\0\374x\0\0\0" + "\0\0\0\0\374\214\0\374\214\0\0\0\0\0\0\0\374\240\0\374\240\0\0\0\0\0\0\0" + "\374\264\0\374\264\0\0\0\0\0\0\0\374\310\0\374\310\0\0\0\0\0\0\0\374\334" + "\0\374\334\0\0\0\0\0\0\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\374\360\0" + "\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\0" + "\0\0\0\0\0\0\0\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374\0\0\0" + "\0\0\0\0\0\374\24\0\374\24\0\0\0\0\0\0\0\374(\0\374(\0\0\0\0\0\0\0\374<\0" + "\374<\0\0\0\0\0\0\0\374P\0\374P\0\0\0\0\0\0\0\374d\0\374d\0\0\0\0\0\0\0\374" + "x\0\374x\0\0\0\0\0\0\0\374\214\0\374\214\0\0\0\0\0\0\0\374\240\0\374\240" + "\0\0\0\0\0\0\0\374\264\0\374\264\0\0\0\0\0\0\0\374\310\0\374\310\0\0\0\0" + "\0\0\0\374\334\0\374\334\0\0\0\0\0\0\0\374\360\0\374\360\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374" + "\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374\0\0\0\0\0\0\0\0\374\24\0" + "\374\24\0\0\0\0\0\0\0\374(\0\374(\0\0\0\0\0\0\0\374<\0\374<\0\0\0\0\0\0\0" + "\374P\0\374P\0\0\0\0\0\0\0\374d\0\374d\0\0\0\0\0\0\0\374x\0\374x\0\0\0\0" + "\0\0\0\374\214\0\374\214\0\0\0\0\0\0\0\374\240\0\374\240\0\0\0\0\0\0\0\374" + "\264\0\374\264\0\0\0\0\0\0\0\374\310\0\374\310\0\0\0\0\0\0\0\374\334\0\374" + "\334\0\0\0\0\0\0\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\374\0\0\374\0\0\374\0\0\0\0\0\374\24\0\374\24\0\374\24\0" + "\0\0\0\374(\0\374(\0\374(\0\0\0\0\374<\0\374<\0\374<\0\0\0\0\374P\0\374P" + "\0\374P\0\0\0\0\374d\0\374d\0\374d\0\0\0\0\374x\0\374x\0\374x\0\0\0\0\374" + "\214\0\374\214\0\374\214\0\0\0\0\374\240\0\374\240\0\374\240\0\0\0\0\374" + "\264\0\374\264\0\374\264\0\0\0\0\374\310\0\374\310\0\374\310\0\0\0\0\374" + "\334\0\374\334\0\374\334\0\0\0\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\0\0\374\0\0\0\0\0\0\0\0" + "\374\24\0\374\24\0\0\0\0\0\0\0\374(\0\374(\0\0\0\0\0\0\0\374<\0\374<\0\0" + "\0\0\0\0\0\374P\0\374P\0\0\0\0\0\0\0\374d\0\374d\0\0\0\0\0\0\0\374x\0\374" + "x\0\0\0\0\0\0\0\374\214\0\374\214\0\0\0\0\0\0\0\374\240\0\374\240\0\0\0\0" + "\0\0\0\374\264\0\374\264\0\0\0\0\0\0\0\374\310\0\374\310\0\0\0\0\0\0\0\374" + "\334\0\374\334\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374" + "\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", }; /** @@ -1023,511 +1027,647 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitColor = { */ SDL_Surface *SDLTest_ImageBlitColor() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( - (void*)SDLTest_imageBlitColor.pixel_data, + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + (void *)SDLTest_imageBlitColor.pixel_data, SDLTest_imageBlitColor.width, SDLTest_imageBlitColor.height, SDLTest_imageBlitColor.bytes_per_pixel * 8, SDLTest_imageBlitColor.width * SDLTest_imageBlitColor.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ + 0xff000000, /* Red bit mask. */ + 0x00ff0000, /* Green bit mask. */ + 0x0000ff00, /* Blue bit mask. */ + 0x000000ff /* Alpha bit mask. */ #else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ + 0x000000ff, /* Red bit mask. */ + 0x0000ff00, /* Green bit mask. */ + 0x00ff0000, /* Blue bit mask. */ + 0xff000000 /* Alpha bit mask. */ #endif - ); - return surface; + ); + return surface; } static const SDLTest_SurfaceImage_t SDLTest_imageBlitAlpha = { - 80, 60, 3, - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0\24\24\0\20\20\0" - "\20\20\0""88\0""88\0**\0**\0ZZ\0ZZ\0==\0==\0yy\0yy\0II\0II\0\224\224\0\224" - "\224\0NN\0NN\0\254\254\0\254\254\0MM\0MM\0\302\302\0\302\302\0HH\0HH\0\324" - "\324\0\324\324\0>>\0>>\0\343\343\0\343\343\0""00\0""00\0\356\356\0\356\356" - "\0\40\40\0\40\40\0\367\367\0\367\367\0\16\16\0\16\16\0\374\374\0\374\374" - "\0\374\374\0\374\374\0\360\360\0\360\360\0\360\360\0\360\360\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\24\24\0\24\24\0\24\24\0\20\20\0""88\0""88\0""88\0**\0ff\0ff\0ff\0FF\0" - "\215\215\0\215\215\0\215\215\0UU\0\255\255\0\255\255\0\255\255\0[[\0\306" - "\306\0\306\306\0\306\306\0YY\0\331\331\0\331\331\0\331\331\0PP\0\350\350" - "\0\350\350\0\350\350\0DD\0\362\362\0\362\362\0\362\362\0""44\0\370\370\0" - "\370\370\0\370\370\0\"\"\0\374\374\0\374\374\0\374\374\0\16\16\0\376\376" - "\0\376\376\0\376\376\0\376\376\0\374\374\0\374\374\0\374\374\0\374\374\0" - "\360\360\0\360\360\0\360\360\0\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0\24\24\0\24\24\0\20\20\0""88\0" - """88\0""88\0**\0ff\0ff\0ff\0FF\0\226\226\0\226\226\0\215\215\0UU\0\271\271" - "\0\271\271\0\255\255\0[[\0\323\323\0\323\323\0\306\306\0YY\0\345\345\0\345" - "\345\0\331\331\0PP\0\360\360\0\360\360\0\350\350\0DD\0\370\370\0\370\370" - "\0\362\362\0""44\0\374\374\0\374\374\0\370\370\0\"\"\0\376\376\0\376\376" - "\0\374\374\0\16\16\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376" - "\376\0\374\374\0\374\374\0\374\374\0\374\374\0\360\360\0\360\360\0\360\360" - "\0\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24" - "\0\24\24\0\24\24\0\20\20\0""33\0""33\0""33\0&&\0OO\0OO\0OO\0""55\0``\0``" - "\0``\0::\0``\0``\0``\0""22\0WW\0WW\0WW\0''\0II\0II\0II\0\33\33\0""99\0""9" - "9\0""99\0\20\20\0))\0))\0))\0\10\10\0\33\33\0\33\33\0\33\33\0\3\3\0\17\17" - "\0\17\17\0\17\17\0\0\0\0\7\7\0\7\7\0\7\7\0\7\7\0\2\2\0\2\2\0\2\2\0\2\2\0" - "\16\16\0\16\16\0\16\16\0\16\16\0\360\360\0\360\360\0\360\360\0\360\360\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0\24\24\0\24\24\0\16\16" - "\0""33\0GG\0GG\0""00\0``\0\210\210\0\210\210\0TT\0\204\204\0\263\263\0\263" - "\263\0ee\0\222\222\0\315\315\0\312\312\0gg\0\216\216\0\331\331\0\327\327" - "\0cc\0\202\202\0\340\340\0\337\337\0YY\0qq\0\345\345\0\344\344\0NN\0^^\0" - "\352\352\0\352\352\0@@\0JJ\0\357\357\0\357\357\0""11\0""66\0\364\364\0\364" - "\364\0\40\40\0\"\"\0\371\371\0\371\371\0\16\16\0\16\16\0\375\375\0\375\375" - "\0\376\376\0\376\376\0\362\362\0\362\362\0\376\376\0\376\376\0\16\16\0\16" - "\16\0\360\360\0\360\360\0\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24" - "\24\0\24\24\0\22\22\0\24\24\0""88\0""88\0//\0BB\0pp\0pp\0UU\0ss\0\242\242" - "\0\242\242\0oo\0\230\230\0\306\306\0\306\306\0ww\0\265\265\0\335\335\0\335" - "\335\0ss\0\313\313\0\353\353\0\353\353\0ii\0\333\333\0\364\364\0\364\364" - "\0ZZ\0\351\351\0\371\371\0\371\371\0II\0\362\362\0\374\374\0\374\374\0""6" - "6\0\370\370\0\376\376\0\376\376\0\"\"\0\374\374\0\376\376\0\376\376\0\16" - "\16\0\376\376\0\376\376\0\376\376\0\376\376\0\375\375\0\376\376\0\376\376" - "\0\376\376\0\360\360\0\360\360\0\360\360\0\360\360\0\16\16\0\360\360\0\360" - "\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0\24\24\0\22\22\0\"\"\0""88\0" - """88\0//\0OO\0pp\0pp\0WW\0\203\203\0\242\242\0\242\242\0qq\0\256\256\0\312" - "\312\0\301\301\0||\0\313\313\0\342\342\0\325\325\0yy\0\336\336\0\360\360" - "\0\342\342\0mm\0\353\353\0\367\367\0\354\354\0\\\\\0\363\363\0\373\373\0" - "\362\362\0JJ\0\371\371\0\375\375\0\367\367\0""66\0\374\374\0\376\376\0\373" - "\373\0\"\"\0\376\376\0\376\376\0\375\375\0\16\16\0\376\376\0\376\376\0\376" - "\376\0\376\376\0\376\376\0\376\376\0\375\375\0\376\376\0\376\376\0\375\375" - "\0\360\360\0\374\374\0\360\360\0\376\376\0\16\16\0\360\360\0\360\360\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\24\24\0\22\22\0&&\0\"\"\0""88\0//\0PP\0HH\0gg\0NN" - "\0pp\0ee\0}}\0VV\0{{\0oo\0\202\202\0NN\0qq\0jj\0vv\0>>\0``\0\\\\\0cc\0,," - "\0MM\0KK\0OO\0\35\35\0::\0""99\0;;\0\21\21\0**\0))\0**\0\10\10\0\33\33\0" - "\33\33\0\33\33\0\3\3\0\17\17\0\17\17\0\17\17\0\0\0\0\7\7\0\7\7\0\7\7\0\7" - "\7\0\2\2\0\2\2\0\2\2\0\2\2\0\16\16\0\16\16\0\16\16\0\16\16\0\360\360\0\360" - "\360\0\376\376\0\376\376\0\16\16\0\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\22\22" - "\0&&\0&&\0\"\"\0""66\0[[\0oo\0ee\0``\0\220\220\0\270\270\0\250\250\0xx\0" - "\250\250\0\327\327\0\311\311\0zz\0\246\246\0\341\341\0\325\325\0rr\0\230" - "\230\0\343\343\0\334\334\0gg\0\205\205\0\344\344\0\340\340\0[[\0rr\0\346" - "\346\0\344\344\0NN\0^^\0\352\352\0\352\352\0AA\0JJ\0\357\357\0\357\357\0" - """11\0""66\0\364\364\0\364\364\0\40\40\0\"\"\0\371\371\0\371\371\0\16\16" - "\0\16\16\0\375\375\0\375\375\0\376\376\0\376\376\0\362\362\0\362\362\0\376" - "\376\0\376\376\0\16\16\0\16\16\0\376\376\0\376\376\0\376\376\0\16\16\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\22\22\0&&\0&&\0\37\37\0;;\0``\0``\0HH\0qq\0\237\237" - "\0\237\237\0nn\0\227\227\0\306\306\0\306\306\0}}\0\254\254\0\334\334\0\334" - "\334\0}}\0\275\275\0\347\347\0\347\347\0vv\0\316\316\0\357\357\0\357\357" - "\0ii\0\334\334\0\365\365\0\365\365\0ZZ\0\351\351\0\371\371\0\371\371\0II" - "\0\362\362\0\374\374\0\374\374\0""66\0\370\370\0\376\376\0\376\376\0\"\"" - "\0\374\374\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376\0\376\376\0\376" - "\376\0\375\375\0\376\376\0\376\376\0\376\376\0\360\360\0\360\360\0\360\360" - "\0\360\360\0\16\16\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "&&\0&&\0##\0--\0``\0``\0TT\0cc\0\237\237\0\231\231\0||\0\223\223\0\306\306" - "\0\301\301\0\217\217\0\267\267\0\336\336\0\322\322\0\220\220\0\317\317\0" - "\352\352\0\334\334\0\202\202\0\337\337\0\362\362\0\345\345\0qq\0\353\353" - "\0\370\370\0\354\354\0^^\0\363\363\0\373\373\0\362\362\0JJ\0\371\371\0\375" - "\375\0\367\367\0""66\0\374\374\0\376\376\0\373\373\0\"\"\0\376\376\0\376" - "\376\0\375\375\0\16\16\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376" - "\0\376\376\0\375\375\0\376\376\0\376\376\0\375\375\0\360\360\0\376\376\0" - "\360\360\0\376\376\0\16\16\0\376\376\0\376\376\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "&&\0##\0""77\0--\0``\0PP\0nn\0[[\0\222\222\0kk\0\211\211\0qq\0\231\231\0" - "ff\0\210\210\0uu\0\217\217\0UU\0vv\0ll\0zz\0@@\0aa\0]]\0dd\0,,\0MM\0KK\0" - "OO\0\35\35\0::\0""99\0;;\0\21\21\0**\0))\0**\0\10\10\0\33\33\0\33\33\0\33" - "\33\0\3\3\0\17\17\0\17\17\0\17\17\0\0\0\0\7\7\0\7\7\0\7\7\0\7\7\0\2\2\0\2" - "\2\0\2\2\0\2\2\0\16\16\0\16\16\0\16\16\0\16\16\0\360\360\0\360\360\0\376" - "\376\0\376\376\0\16\16\0\376\376\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0##\0""77\0""77" - "\0--\0UU\0zz\0\216\216\0ww\0}}\0\254\254\0\324\324\0\264\264\0\207\207\0" - "\266\266\0\345\345\0\316\316\0\177\177\0\254\254\0\346\346\0\326\326\0rr" - "\0\231\231\0\344\344\0\334\334\0gg\0\206\206\0\344\344\0\340\340\0[[\0rr" - "\0\346\346\0\344\344\0NN\0^^\0\352\352\0\352\352\0AA\0JJ\0\357\357\0\357" - "\357\0""11\0""66\0\364\364\0\364\364\0\40\40\0\"\"\0\371\371\0\371\371\0" - "\16\16\0\16\16\0\375\375\0\375\375\0\376\376\0\376\376\0\362\362\0\362\362" - "\0\376\376\0\376\376\0\16\16\0\16\16\0\376\376\0\376\376\0\376\376\0\16\16" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\22\22\0""77\0""77\0--\0CC\0~~\0~~\0\\\\\0||\0" - "\274\274\0\274\274\0||\0\235\235\0\325\325\0\325\325\0\204\204\0\256\256" - "\0\340\340\0\340\340\0\177\177\0\275\275\0\351\351\0\351\351\0vv\0\316\316" - "\0\360\360\0\360\360\0ii\0\334\334\0\365\365\0\365\365\0ZZ\0\351\351\0\371" - "\371\0\371\371\0II\0\362\362\0\374\374\0\374\374\0""66\0\370\370\0\376\376" - "\0\376\376\0\"\"\0\374\374\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376" - "\0\376\376\0\376\376\0\375\375\0\376\376\0\376\376\0\376\376\0\360\360\0" - "\360\360\0\360\360\0\360\360\0\16\16\0\376\376\0\376\376\0\16\16\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0&&\0""77\0""22\0--\0``\0vv\0pp\0gg\0\243\243\0\255\255" - "\0\225\225\0\231\231\0\311\311\0\314\314\0\235\235\0\271\271\0\337\337\0" - "\326\326\0\224\224\0\320\320\0\352\352\0\336\336\0\204\204\0\337\337\0\362" - "\362\0\345\345\0qq\0\353\353\0\370\370\0\354\354\0^^\0\363\363\0\373\373" - "\0\362\362\0JJ\0\371\371\0\375\375\0\367\367\0""66\0\374\374\0\376\376\0" - "\373\373\0\"\"\0\376\376\0\376\376\0\375\375\0\16\16\0\376\376\0\376\376" - "\0\376\376\0\376\376\0\376\376\0\376\376\0\375\375\0\376\376\0\376\376\0" - "\375\375\0\360\360\0\376\376\0\360\360\0\376\376\0\16\16\0\376\376\0\376" - "\376\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0&&\0##\0FF\0""99\0``\0PP\0\200\200\0dd\0\222" - "\222\0kk\0\222\222\0vv\0\231\231\0ff\0\213\213\0ww\0\217\217\0UU\0xx\0mm" - "\0zz\0@@\0bb\0]]\0dd\0,,\0MM\0KK\0OO\0\35\35\0::\0""99\0;;\0\21\21\0**\0" - "))\0**\0\10\10\0\33\33\0\33\33\0\33\33\0\3\3\0\17\17\0\17\17\0\17\17\0\0" - "\0\0\7\7\0\7\7\0\7\7\0\7\7\0\2\2\0\2\2\0\2\2\0\2\2\0\16\16\0\16\16\0\16\16" - "\0\16\16\0\360\360\0\360\360\0\376\376\0\376\376\0\16\16\0\376\376\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0##\0""77\0""77\0""99\0^^\0zz\0\216\216\0\201\201\0\203" - "\203\0\254\254\0\324\324\0\271\271\0\211\211\0\266\266\0\345\345\0\317\317" - "\0\200\200\0\254\254\0\346\346\0\326\326\0ss\0\231\231\0\344\344\0\334\334" - "\0gg\0\206\206\0\344\344\0\340\340\0[[\0rr\0\346\346\0\344\344\0NN\0^^\0" - "\352\352\0\352\352\0AA\0JJ\0\357\357\0\357\357\0""11\0""66\0\364\364\0\364" - "\364\0\40\40\0\"\"\0\371\371\0\371\371\0\16\16\0\16\16\0\375\375\0\375\375" - "\0\376\376\0\376\376\0\362\362\0\362\362\0\376\376\0\376\376\0\16\16\0\16" - "\16\0\376\376\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\22\22" - "\0""77\0""77\0--\0MM\0\210\210\0\210\210\0\\\\\0\202\202\0\302\302\0\302" - "\302\0||\0\240\240\0\330\330\0\330\330\0\204\204\0\257\257\0\341\341\0\341" - "\341\0\177\177\0\275\275\0\351\351\0\351\351\0vv\0\316\316\0\360\360\0\360" - "\360\0ii\0\334\334\0\365\365\0\365\365\0ZZ\0\351\351\0\371\371\0\371\371" - "\0II\0\362\362\0\374\374\0\374\374\0""66\0\370\370\0\376\376\0\376\376\0" - "\"\"\0\374\374\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376\0\376\376" - "\0\376\376\0\375\375\0\376\376\0\376\376\0\376\376\0\360\360\0\360\360\0" - "\360\360\0\360\360\0\16\16\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0&&\0""77\0""22\0--\0``\0vv\0xx\0kk\0\245\245\0\257\257\0\235\235" - "\0\234\234\0\312\312\0\315\315\0\241\241\0\272\272\0\337\337\0\326\326\0" - "\225\225\0\320\320\0\352\352\0\336\336\0\204\204\0\337\337\0\362\362\0\345" - "\345\0qq\0\353\353\0\370\370\0\354\354\0^^\0\363\363\0\373\373\0\362\362" - "\0JJ\0\371\371\0\375\375\0\367\367\0""66\0\374\374\0\376\376\0\373\373\0" - "\"\"\0\376\376\0\376\376\0\375\375\0\16\16\0\376\376\0\376\376\0\376\376" - "\0\376\376\0\376\376\0\376\376\0\375\375\0\376\376\0\376\376\0\375\375\0" - "\360\360\0\376\376\0\360\360\0\376\376\0\16\16\0\376\376\0\376\376\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0&&\0##\0FF\0""99\0``\0PP\0\200\200\0dd\0\222\222\0kk" - "\0\222\222\0vv\0\231\231\0ff\0\213\213\0ww\0\217\217\0UU\0xx\0mm\0zz\0@@" - "\0bb\0]]\0dd\0,,\0MM\0KK\0OO\0\35\35\0::\0""99\0;;\0\21\21\0**\0))\0**\0" - "\10\10\0\33\33\0\33\33\0\33\33\0\3\3\0\17\17\0\17\17\0\17\17\0\0\0\0\7\7" - "\0\7\7\0\7\7\0\7\7\0\2\2\0\2\2\0\2\2\0\2\2\0\16\16\0\16\16\0\16\16\0\16\16" - "\0\360\360\0\360\360\0\376\376\0\376\376\0\16\16\0\376\376\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0##\0""77\0""77\0""99\0^^\0zz\0\216\216\0\201\201\0\203\203\0" - "\254\254\0\324\324\0\271\271\0\211\211\0\266\266\0\345\345\0\317\317\0\200" - "\200\0\254\254\0\346\346\0\326\326\0ss\0\231\231\0\344\344\0\334\334\0gg" - "\0\206\206\0\344\344\0\340\340\0[[\0rr\0\346\346\0\344\344\0NN\0^^\0\352" - "\352\0\352\352\0AA\0JJ\0\357\357\0\357\357\0""11\0""66\0\364\364\0\364\364" - "\0\40\40\0\"\"\0\371\371\0\371\371\0\16\16\0\16\16\0\375\375\0\375\375\0" - "\376\376\0\376\376\0\362\362\0\362\362\0\376\376\0\376\376\0\16\16\0\16\16" - "\0\376\376\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\22\22\0" - """77\0""77\0--\0MM\0\210\210\0\210\210\0\\\\\0\202\202\0\302\302\0\302\302" - "\0||\0\240\240\0\330\330\0\330\330\0\204\204\0\257\257\0\341\341\0\341\341" - "\0\177\177\0\275\275\0\351\351\0\351\351\0vv\0\316\316\0\360\360\0\360\360" - "\0ii\0\334\334\0\365\365\0\365\365\0ZZ\0\351\351\0\371\371\0\371\371\0II" - "\0\362\362\0\374\374\0\374\374\0""66\0\370\370\0\376\376\0\376\376\0\"\"" - "\0\374\374\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376\0\376\376\0\376" - "\376\0\375\375\0\376\376\0\376\376\0\376\376\0\360\360\0\360\360\0\360\360" - "\0\360\360\0\16\16\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "&&\0""77\0""22\0--\0``\0vv\0xx\0kk\0\245\245\0\257\257\0\235\235\0\234\234" - "\0\312\312\0\315\315\0\241\241\0\272\272\0\337\337\0\326\326\0\225\225\0" - "\320\320\0\352\352\0\336\336\0\204\204\0\337\337\0\362\362\0\345\345\0qq" - "\0\353\353\0\370\370\0\354\354\0^^\0\363\363\0\373\373\0\362\362\0JJ\0\371" - "\371\0\375\375\0\367\367\0""66\0\374\374\0\376\376\0\373\373\0\"\"\0\376" - "\376\0\376\376\0\375\375\0\16\16\0\376\376\0\376\376\0\376\376\0\376\376" - "\0\376\376\0\376\376\0\375\375\0\376\376\0\376\376\0\375\375\0\360\360\0" - "\376\376\0\360\360\0\376\376\0\16\16\0\376\376\0\376\376\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0&&\0##\0FF\0""99\0``\0PP\0\200\200\0dd\0\222\222\0kk\0\222\222" - "\0vv\0\231\231\0ff\0\213\213\0ww\0\217\217\0UU\0xx\0mm\0zz\0@@\0bb\0]]\0" - "dd\0,,\0MM\0KK\0OO\0\35\35\0::\0""99\0;;\0\21\21\0**\0))\0**\0\10\10\0\33" - "\33\0\33\33\0\33\33\0\3\3\0\17\17\0\17\17\0\17\17\0\0\0\0\7\7\0\7\7\0\7\7" - "\0\7\7\0\2\2\0\2\2\0\2\2\0\2\2\0\16\16\0\16\16\0\16\16\0\16\16\0\360\360" - "\0\360\360\0\376\376\0\376\376\0\16\16\0\376\376\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0##\0""77\0""77\0""99\0^^\0zz\0\216\216\0\201\201\0\203\203\0\254\254\0" - "\324\324\0\271\271\0\211\211\0\266\266\0\345\345\0\317\317\0\200\200\0\254" - "\254\0\346\346\0\326\326\0ss\0\231\231\0\344\344\0\334\334\0gg\0\206\206" - "\0\344\344\0\340\340\0[[\0rr\0\346\346\0\344\344\0NN\0^^\0\352\352\0\352" - "\352\0AA\0JJ\0\357\357\0\357\357\0""11\0""66\0\364\364\0\364\364\0\40\40" - "\0\"\"\0\371\371\0\371\371\0\16\16\0\16\16\0\375\375\0\375\375\0\376\376" - "\0\376\376\0\362\362\0\362\362\0\376\376\0\376\376\0\16\16\0\16\16\0\376" - "\376\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\22\22\0""77\0" - """77\0--\0MM\0\210\210\0\210\210\0\\\\\0\202\202\0\302\302\0\302\302\0||" - "\0\240\240\0\330\330\0\330\330\0\204\204\0\257\257\0\341\341\0\341\341\0" - "\177\177\0\275\275\0\351\351\0\351\351\0vv\0\316\316\0\360\360\0\360\360" - "\0ii\0\334\334\0\365\365\0\365\365\0ZZ\0\351\351\0\371\371\0\371\371\0II" - "\0\362\362\0\374\374\0\374\374\0""66\0\370\370\0\376\376\0\376\376\0\"\"" - "\0\374\374\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376\0\376\376\0\376" - "\376\0\375\375\0\376\376\0\376\376\0\376\376\0\360\360\0\360\360\0\360\360" - "\0\360\360\0\16\16\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "&&\0""77\0""22\0--\0``\0vv\0xx\0kk\0\245\245\0\257\257\0\235\235\0\234\234" - "\0\312\312\0\315\315\0\241\241\0\272\272\0\337\337\0\326\326\0\225\225\0" - "\320\320\0\352\352\0\336\336\0\204\204\0\337\337\0\362\362\0\345\345\0qq" - "\0\353\353\0\370\370\0\354\354\0^^\0\363\363\0\373\373\0\362\362\0JJ\0\371" - "\371\0\375\375\0\367\367\0""66\0\374\374\0\376\376\0\373\373\0\"\"\0\376" - "\376\0\376\376\0\375\375\0\16\16\0\376\376\0\376\376\0\376\376\0\376\376" - "\0\376\376\0\376\376\0\375\375\0\376\376\0\376\376\0\375\375\0\360\360\0" - "\376\376\0\360\360\0\376\376\0\16\16\0\376\376\0\376\376\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0&&\0##\0FF\0""99\0``\0PP\0\200\200\0dd\0\222\222\0kk\0\222\222" - "\0vv\0\231\231\0ff\0\213\213\0ww\0\217\217\0UU\0xx\0mm\0zz\0@@\0bb\0]]\0" - "dd\0,,\0MM\0KK\0OO\0\35\35\0::\0""99\0;;\0\21\21\0**\0))\0**\0\10\10\0\33" - "\33\0\33\33\0\33\33\0\3\3\0\17\17\0\17\17\0\17\17\0\0\0\0\7\7\0\7\7\0\7\7" - "\0\7\7\0\2\2\0\2\2\0\2\2\0\2\2\0\16\16\0\16\16\0\16\16\0\16\16\0\360\360" - "\0\360\360\0\376\376\0\376\376\0\16\16\0\376\376\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0##\0""77\0""77\0""99\0^^\0zz\0\216\216\0\201\201\0\203\203\0\254\254\0" - "\324\324\0\271\271\0\211\211\0\266\266\0\345\345\0\317\317\0\200\200\0\254" - "\254\0\346\346\0\326\326\0ss\0\231\231\0\344\344\0\334\334\0gg\0\206\206" - "\0\344\344\0\340\340\0[[\0rr\0\346\346\0\344\344\0NN\0^^\0\352\352\0\352" - "\352\0AA\0JJ\0\357\357\0\357\357\0""11\0""66\0\364\364\0\364\364\0\40\40" - "\0\"\"\0\371\371\0\371\371\0\16\16\0\16\16\0\375\375\0\375\375\0\376\376" - "\0\376\376\0\362\362\0\362\362\0\376\376\0\376\376\0\16\16\0\16\16\0\376" - "\376\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\22\22\0""77\0" - """77\0--\0MM\0\210\210\0\210\210\0\\\\\0\202\202\0\302\302\0\302\302\0||" - "\0\240\240\0\330\330\0\330\330\0\204\204\0\257\257\0\341\341\0\341\341\0" - "\177\177\0\275\275\0\351\351\0\351\351\0vv\0\316\316\0\360\360\0\360\360" - "\0ii\0\334\334\0\365\365\0\365\365\0ZZ\0\351\351\0\371\371\0\371\371\0II" - "\0\362\362\0\374\374\0\374\374\0""66\0\370\370\0\376\376\0\376\376\0\"\"" - "\0\374\374\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376\0\376\376\0\376" - "\376\0\375\375\0\376\376\0\376\376\0\376\376\0\360\360\0\360\360\0\360\360" - "\0\360\360\0\16\16\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "&&\0""77\0""22\0--\0``\0vv\0xx\0kk\0\245\245\0\257\257\0\235\235\0\234\234" - "\0\312\312\0\315\315\0\241\241\0\272\272\0\337\337\0\326\326\0\225\225\0" - "\320\320\0\352\352\0\336\336\0\204\204\0\337\337\0\362\362\0\345\345\0qq" - "\0\353\353\0\370\370\0\354\354\0^^\0\363\363\0\373\373\0\362\362\0JJ\0\371" - "\371\0\375\375\0\367\367\0""66\0\374\374\0\376\376\0\373\373\0\"\"\0\376" - "\376\0\376\376\0\375\375\0\16\16\0\376\376\0\376\376\0\376\376\0\376\376" - "\0\376\376\0\376\376\0\375\375\0\376\376\0\376\376\0\375\375\0\360\360\0" - "\376\376\0\360\360\0\376\376\0\16\16\0\376\376\0\376\376\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0&&\0##\0FF\0""99\0``\0PP\0\213\213\0mm\0\237\237\0uu\0\275\275" - "\0\232\232\0\306\306\0\204\204\0\331\331\0\272\272\0\336\336\0\205\205\0" - "\345\345\0\320\320\0\352\352\0{{\0\355\355\0\337\337\0\362\362\0mm\0\363" - "\363\0\353\353\0\370\370\0\\\\\0\367\367\0\363\363\0\373\373\0II\0\373\373" - "\0\371\371\0\375\375\0""66\0\375\375\0\374\374\0\376\376\0\"\"\0\376\376" - "\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376\0\376\376\0\376\376\0\376" - "\376\0\376\376\0\376\376\0\376\376\0\375\375\0\376\376\0\375\375\0\375\375" - "\0\360\360\0\360\360\0\376\376\0\376\376\0\16\16\0\376\376\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0##\0""77\0""77\0""99\0gg\0\205\205\0\205\205\0ww\0\224\224\0" - "\310\310\0\310\310\0\247\247\0\240\240\0\354\354\0\354\354\0\306\306\0\227" - "\227\0\372\372\0\372\372\0\325\325\0\205\205\0\375\375\0\375\375\0\342\342" - "\0rr\0\376\376\0\376\376\0\354\354\0^^\0\376\376\0\376\376\0\363\363\0JJ" - "\0\376\376\0\376\376\0\370\370\0""66\0\376\376\0\376\376\0\374\374\0\"\"" - "\0\376\376\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376\0\376\376\0\376" - "\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\375\375" - "\0\376\376\0\376\376\0\376\376\0\362\362\0\376\376\0\376\376\0\376\376\0" - "\16\16\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\22\22\0""77\0""77\0""11\0>>\0~~\0~~\0bb" - "\0__\0\261\261\0\261\261\0\212\212\0``\0\277\277\0\277\277\0\230\230\0SS" - "\0\275\275\0\275\275\0\233\233\0@@\0\273\273\0\273\273\0\240\240\0//\0\274" - "\274\0\274\274\0\252\252\0!!\0\301\301\0\301\301\0\266\266\0\25\25\0\311" - "\311\0\311\311\0\303\303\0\14\14\0\324\324\0\324\324\0\322\322\0\6\6\0\342" - "\342\0\342\342\0\341\341\0\1\1\0\361\361\0\361\361\0\361\361\0\15\15\0\15" - "\15\0\15\15\0\15\15\0\362\362\0\362\362\0\362\362\0\360\360\0\16\16\0\16" - "\16\0\16\16\0\2\2\0\376\376\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0&&\0""77\0""77\0\34\34\0SS\0kk\0\206\206\0BB\0\214\214\0\232\232" - "\0\302\302\0YY\0\250\250\0\255\255\0\340\340\0XX\0\264\264\0\264\264\0\355" - "\355\0SS\0\265\265\0\266\266\0\364\364\0JJ\0\270\270\0\272\272\0\371\371" - "\0AA\0\277\277\0\300\300\0\374\374\0""66\0\310\310\0\311\311\0\375\375\0" - "**\0\324\324\0\324\324\0\376\376\0\34\34\0\341\341\0\342\342\0\376\376\0" - "\15\15\0\361\361\0\361\361\0\376\376\0\361\361\0\15\15\0\15\15\0\376\376" - "\0\15\15\0\361\361\0\361\361\0\373\373\0\362\362\0\15\15\0\16\16\0\376\376" - "\0\16\16\0\361\361\0\376\376\0\376\376\0\376\376\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0&&\0&&\0""77\0))\0SS\0SS\0kk\0DD\0\205\205\0}}\0\222\222\0WW\0\241\241" - "\0\230\230\0\245\245\0XX\0\261\261\0\252\252\0\261\261\0SS\0\264\264\0\263" - "\263\0\265\265\0JJ\0\270\270\0\271\271\0\272\272\0AA\0\276\276\0\300\300" - "\0\300\300\0""66\0\310\310\0\311\311\0\311\311\0**\0\324\324\0\324\324\0" - "\324\324\0\34\34\0\341\341\0\342\342\0\342\342\0\15\15\0\361\361\0\361\361" - "\0\361\361\0\361\361\0\15\15\0\15\15\0\15\15\0\15\15\0\361\361\0\361\361" - "\0\361\361\0\362\362\0\15\15\0\16\16\0\16\16\0\16\16\0\361\361\0\376\376" - "\0\376\376\0\376\376\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0&&\0&&\0&&\0))\0pp\0cc\0cc" - "\0QQ\0\261\261\0\244\244\0\244\244\0ll\0\335\335\0\323\323\0\323\323\0ww" - "\0\364\364\0\356\356\0\356\356\0ss\0\370\370\0\371\371\0\371\371\0ii\0\372" - "\372\0\375\375\0\375\375\0YY\0\374\374\0\376\376\0\376\376\0HH\0\375\375" - "\0\376\376\0\376\376\0""66\0\376\376\0\376\376\0\376\376\0\"\"\0\376\376" - "\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376\0\376\376\0\376\376\0\376" - "\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376" - "\0\375\375\0\376\376\0\376\376\0\376\376\0\361\361\0\376\376\0\376\376\0" - "\376\376\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0&&\0&&\0\40\40\0QQ\0pp\0pp\0KK" - "\0\215\215\0\261\261\0\261\261\0pp\0\274\274\0\337\337\0\337\337\0\200\200" - "\0\332\332\0\364\364\0\364\364\0}}\0\350\350\0\373\373\0\373\373\0oo\0\361" - "\361\0\375\375\0\375\375\0]]\0\367\367\0\376\376\0\376\376\0JJ\0\373\373" - "\0\376\376\0\376\376\0""66\0\375\375\0\376\376\0\376\376\0\"\"\0\376\376" - "\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376\0\376\376\0\376\376\0\376" - "\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376" - "\0\375\375\0\376\376\0\376\376\0\376\376\0\361\361\0\376\376\0\376\376\0" - "\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0&&\0&&\0\20\20\0""88\0WW\0pp\0" - "==\0ss\0\212\212\0\252\252\0dd\0\250\250\0\264\264\0\312\312\0rr\0\313\313" - "\0\315\315\0\331\331\0rr\0\340\340\0\331\331\0\340\340\0hh\0\355\355\0\341" - "\341\0\345\345\0YY\0\366\366\0\350\350\0\352\352\0HH\0\372\372\0\356\356" - "\0\357\357\0""66\0\375\375\0\364\364\0\364\364\0\"\"\0\376\376\0\371\371" - "\0\371\371\0\16\16\0\376\376\0\375\375\0\375\375\0\376\376\0\376\376\0\361" - "\361\0\362\362\0\376\376\0\376\376\0\16\16\0\16\16\0\376\376\0\375\375\0" - "\376\376\0\375\375\0\374\374\0\360\360\0\376\376\0\376\376\0\360\360\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\24\24\0\24\24\0&&\0\40\40\0""88\0""88\0WW\0BB\0ff" - "\0ZZ\0}}\0^^\0\226\226\0\201\201\0\241\241\0nn\0\301\301\0\246\246\0\277" - "\277\0rr\0\333\333\0\301\301\0\321\321\0ii\0\353\353\0\323\323\0\335\335" - "\0[[\0\365\365\0\341\341\0\346\346\0II\0\372\372\0\353\353\0\356\356\0""6" - "6\0\375\375\0\363\363\0\364\364\0\"\"\0\376\376\0\371\371\0\371\371\0\16" - "\16\0\376\376\0\375\375\0\375\375\0\376\376\0\376\376\0\361\361\0\361\361" - "\0\376\376\0\376\376\0\16\16\0\16\16\0\376\376\0\374\374\0\375\375\0\374" - "\374\0\374\374\0\361\361\0\376\376\0\360\360\0\360\360\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\24\24\0\24\24\0\24\24\0\40\40\0HH\0""88\0""88\0BB\0~~\0ff\0ff\0" - "^^\0\256\256\0\226\226\0\226\226\0qq\0\325\325\0\277\277\0\277\277\0ss\0" - "\350\350\0\331\331\0\331\331\0jj\0\363\363\0\353\353\0\353\353\0[[\0\371" - "\371\0\365\365\0\365\365\0II\0\374\374\0\372\372\0\372\372\0""66\0\375\375" - "\0\375\375\0\375\375\0\"\"\0\376\376\0\376\376\0\376\376\0\16\16\0\376\376" - "\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0" - "\376\376\0\376\376\0\376\376\0\376\376\0\374\374\0\374\374\0\374\374\0\376" - "\376\0\361\361\0\360\360\0\360\360\0\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\24\24\0\24\24\0\24\24\0\40\40\0HH\0HH\0""88\0BB\0~~\0~~\0ff\0^^\0\263" - "\263\0\263\263\0\231\231\0nn\0\330\330\0\330\330\0\274\274\0pp\0\353\353" - "\0\353\353\0\324\324\0hh\0\365\365\0\365\365\0\345\345\0ZZ\0\373\373\0\373" - "\373\0\361\361\0II\0\375\375\0\375\375\0\370\370\0""66\0\376\376\0\376\376" - "\0\374\374\0\"\"\0\376\376\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376" - "\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0" - "\376\376\0\374\374\0\374\374\0\376\376\0\376\376\0\361\361\0\360\360\0\360" - "\360\0\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0\24\24\0\0\0" - "\0\0\0\0((\0HH\0\40\40\0\25\25\0QQ\0\207\207\0KK\0--\0}}\0\262\262\0bb\0" - """44\0\235\235\0\320\320\0ff\0""00\0\257\257\0\341\341\0cc\0))\0\272\272" - "\0\354\354\0ZZ\0\37\37\0\303\303\0\363\363\0OO\0\26\26\0\314\314\0\370\370" - "\0AA\0\15\15\0\326\326\0\373\373\0""22\0\6\6\0\343\343\0\375\375\0!!\0\1" - "\1\0\362\362\0\376\376\0\16\16\0\16\16\0\16\16\0\375\375\0\375\375\0\375" - "\375\0\376\376\0\362\362\0\360\360\0\361\361\0\376\376\0\14\14\0\0\0\0\0" - "\0\0\360\360\0\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24" - "\0\24\24\0\0\0\0\0\0\0((\0((\0\0\0\0\0\0\0<<\0<<\0\0\0\0\0\0\0PP\0PP\0\10" - "\10\0\4\4\0dd\0dd\0\14\14\0\6\6\0xx\0xx\0\14\14\0\5\5\0\214\214\0\214\214" - "\0\13\13\0\4\4\0\240\240\0\240\240\0\10\10\0\2\2\0\264\264\0\264\264\0\5" - "\5\0\1\1\0\310\310\0\310\310\0\3\3\0\0\0\0\334\334\0\334\334\0\1\1\0\0\0" - "\0\360\360\0\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1\0\1\1\0\0\0\0\0\0\0\14" - "\14\0\14\14\0\0\0\0\0\0\0\360\360\0\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0\24\24\0\0\0\0\0\0\0((\0((\0\0\0\0\0\0" - "\0<<\0<<\0\0\0\0\0\0\0XX\0XX\0\0\0\0\0\0\0pp\0pp\0\0\0\0\0\0\0\204\204\0" - "\204\204\0\0\0\0\0\0\0\227\227\0\227\227\0\0\0\0\0\0\0\250\250\0\250\250" - "\0\0\0\0\0\0\0\271\271\0\271\271\0\0\0\0\0\0\0\313\313\0\313\313\0\0\0\0" - "\0\0\0\335\335\0\335\335\0\0\0\0\0\0\0\360\360\0\360\360\0\0\0\0\0\0\0\1" - "\1\0\1\1\0\0\0\0\0\0\0\14\14\0\14\14\0\0\0\0\0\0\0\360\360\0\360\360\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0" - "\24\24\0\24\24\0\0\0\0((\0((\0((\0\0\0\0<<\0HH\0HH\0\10\10\0PP\0dd\0dd\0" - "\14\14\0dd\0||\0||\0\14\14\0xx\0\221\221\0\221\221\0\13\13\0\214\214\0\243" - "\243\0\243\243\0\10\10\0\240\240\0\264\264\0\264\264\0\5\5\0\264\264\0\303" - "\303\0\303\303\0\3\3\0\310\310\0\322\322\0\322\322\0\1\1\0\334\334\0\341" - "\341\0\341\341\0\0\0\0\360\360\0\361\361\0\361\361\0\1\1\0\0\0\0\14\14\0" - "\14\14\0\14\14\0\0\0\0\360\360\0\360\360\0\360\360\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0" - "\24\24\0\20\20\0\20\20\0""88\0""88\0**\0**\0ZZ\0ZZ\0==\0==\0yy\0yy\0II\0" - "II\0\224\224\0\224\224\0NN\0NN\0\254\254\0\254\254\0MM\0MM\0\302\302\0\302" - "\302\0HH\0HH\0\324\324\0\324\324\0>>\0>>\0\343\343\0\343\343\0""00\0""00" - "\0\356\356\0\356\356\0\40\40\0\40\40\0\367\367\0\367\367\0\16\16\0\16\16" - "\0\374\374\0\374\374\0\374\374\0\374\374\0\360\360\0\360\360\0\360\360\0" - "\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", + 80, + 60, + 3, + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0\24\24\0\20\20\0" + "\20\20\0" + "88\0" + "88\0**\0**\0ZZ\0ZZ\0==\0==\0yy\0yy\0II\0II\0\224\224\0\224" + "\224\0NN\0NN\0\254\254\0\254\254\0MM\0MM\0\302\302\0\302\302\0HH\0HH\0\324" + "\324\0\324\324\0>>\0>>\0\343\343\0\343\343\0" + "00\0" + "00\0\356\356\0\356\356" + "\0\40\40\0\40\40\0\367\367\0\367\367\0\16\16\0\16\16\0\374\374\0\374\374" + "\0\374\374\0\374\374\0\360\360\0\360\360\0\360\360\0\360\360\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\24\24\0\24\24\0\24\24\0\20\20\0" + "88\0" + "88\0" + "88\0**\0ff\0ff\0ff\0FF\0" + "\215\215\0\215\215\0\215\215\0UU\0\255\255\0\255\255\0\255\255\0[[\0\306" + "\306\0\306\306\0\306\306\0YY\0\331\331\0\331\331\0\331\331\0PP\0\350\350" + "\0\350\350\0\350\350\0DD\0\362\362\0\362\362\0\362\362\0" + "44\0\370\370\0" + "\370\370\0\370\370\0\"\"\0\374\374\0\374\374\0\374\374\0\16\16\0\376\376" + "\0\376\376\0\376\376\0\376\376\0\374\374\0\374\374\0\374\374\0\374\374\0" + "\360\360\0\360\360\0\360\360\0\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0\24\24\0\24\24\0\20\20\0" + "88\0" + "" + "88\0" + "88\0**\0ff\0ff\0ff\0FF\0\226\226\0\226\226\0\215\215\0UU\0\271\271" + "\0\271\271\0\255\255\0[[\0\323\323\0\323\323\0\306\306\0YY\0\345\345\0\345" + "\345\0\331\331\0PP\0\360\360\0\360\360\0\350\350\0DD\0\370\370\0\370\370" + "\0\362\362\0" + "44\0\374\374\0\374\374\0\370\370\0\"\"\0\376\376\0\376\376" + "\0\374\374\0\16\16\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376" + "\376\0\374\374\0\374\374\0\374\374\0\374\374\0\360\360\0\360\360\0\360\360" + "\0\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24" + "\0\24\24\0\24\24\0\20\20\0" + "33\0" + "33\0" + "33\0&&\0OO\0OO\0OO\0" + "55\0``\0``" + "\0``\0::\0``\0``\0``\0" + "22\0WW\0WW\0WW\0''\0II\0II\0II\0\33\33\0" + "99\0" + "9" + "9\0" + "99\0\20\20\0))\0))\0))\0\10\10\0\33\33\0\33\33\0\33\33\0\3\3\0\17\17" + "\0\17\17\0\17\17\0\0\0\0\7\7\0\7\7\0\7\7\0\7\7\0\2\2\0\2\2\0\2\2\0\2\2\0" + "\16\16\0\16\16\0\16\16\0\16\16\0\360\360\0\360\360\0\360\360\0\360\360\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0\24\24\0\24\24\0\16\16" + "\0" + "33\0GG\0GG\0" + "00\0``\0\210\210\0\210\210\0TT\0\204\204\0\263\263\0\263" + "\263\0ee\0\222\222\0\315\315\0\312\312\0gg\0\216\216\0\331\331\0\327\327" + "\0cc\0\202\202\0\340\340\0\337\337\0YY\0qq\0\345\345\0\344\344\0NN\0^^\0" + "\352\352\0\352\352\0@@\0JJ\0\357\357\0\357\357\0" + "11\0" + "66\0\364\364\0\364" + "\364\0\40\40\0\"\"\0\371\371\0\371\371\0\16\16\0\16\16\0\375\375\0\375\375" + "\0\376\376\0\376\376\0\362\362\0\362\362\0\376\376\0\376\376\0\16\16\0\16" + "\16\0\360\360\0\360\360\0\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24" + "\24\0\24\24\0\22\22\0\24\24\0" + "88\0" + "88\0//\0BB\0pp\0pp\0UU\0ss\0\242\242" + "\0\242\242\0oo\0\230\230\0\306\306\0\306\306\0ww\0\265\265\0\335\335\0\335" + "\335\0ss\0\313\313\0\353\353\0\353\353\0ii\0\333\333\0\364\364\0\364\364" + "\0ZZ\0\351\351\0\371\371\0\371\371\0II\0\362\362\0\374\374\0\374\374\0" + "6" + "6\0\370\370\0\376\376\0\376\376\0\"\"\0\374\374\0\376\376\0\376\376\0\16" + "\16\0\376\376\0\376\376\0\376\376\0\376\376\0\375\375\0\376\376\0\376\376" + "\0\376\376\0\360\360\0\360\360\0\360\360\0\360\360\0\16\16\0\360\360\0\360" + "\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0\24\24\0\22\22\0\"\"\0" + "88\0" + "" + "88\0//\0OO\0pp\0pp\0WW\0\203\203\0\242\242\0\242\242\0qq\0\256\256\0\312" + "\312\0\301\301\0||\0\313\313\0\342\342\0\325\325\0yy\0\336\336\0\360\360" + "\0\342\342\0mm\0\353\353\0\367\367\0\354\354\0\\\\\0\363\363\0\373\373\0" + "\362\362\0JJ\0\371\371\0\375\375\0\367\367\0" + "66\0\374\374\0\376\376\0\373" + "\373\0\"\"\0\376\376\0\376\376\0\375\375\0\16\16\0\376\376\0\376\376\0\376" + "\376\0\376\376\0\376\376\0\376\376\0\375\375\0\376\376\0\376\376\0\375\375" + "\0\360\360\0\374\374\0\360\360\0\376\376\0\16\16\0\360\360\0\360\360\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\24\24\0\22\22\0&&\0\"\"\0" + "88\0//\0PP\0HH\0gg\0NN" + "\0pp\0ee\0}}\0VV\0{{\0oo\0\202\202\0NN\0qq\0jj\0vv\0>>\0``\0\\\\\0cc\0,," + "\0MM\0KK\0OO\0\35\35\0::\0" + "99\0;;\0\21\21\0**\0))\0**\0\10\10\0\33\33\0" + "\33\33\0\33\33\0\3\3\0\17\17\0\17\17\0\17\17\0\0\0\0\7\7\0\7\7\0\7\7\0\7" + "\7\0\2\2\0\2\2\0\2\2\0\2\2\0\16\16\0\16\16\0\16\16\0\16\16\0\360\360\0\360" + "\360\0\376\376\0\376\376\0\16\16\0\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\22\22" + "\0&&\0&&\0\"\"\0" + "66\0[[\0oo\0ee\0``\0\220\220\0\270\270\0\250\250\0xx\0" + "\250\250\0\327\327\0\311\311\0zz\0\246\246\0\341\341\0\325\325\0rr\0\230" + "\230\0\343\343\0\334\334\0gg\0\205\205\0\344\344\0\340\340\0[[\0rr\0\346" + "\346\0\344\344\0NN\0^^\0\352\352\0\352\352\0AA\0JJ\0\357\357\0\357\357\0" + "" + "11\0" + "66\0\364\364\0\364\364\0\40\40\0\"\"\0\371\371\0\371\371\0\16\16" + "\0\16\16\0\375\375\0\375\375\0\376\376\0\376\376\0\362\362\0\362\362\0\376" + "\376\0\376\376\0\16\16\0\16\16\0\376\376\0\376\376\0\376\376\0\16\16\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\22\22\0&&\0&&\0\37\37\0;;\0``\0``\0HH\0qq\0\237\237" + "\0\237\237\0nn\0\227\227\0\306\306\0\306\306\0}}\0\254\254\0\334\334\0\334" + "\334\0}}\0\275\275\0\347\347\0\347\347\0vv\0\316\316\0\357\357\0\357\357" + "\0ii\0\334\334\0\365\365\0\365\365\0ZZ\0\351\351\0\371\371\0\371\371\0II" + "\0\362\362\0\374\374\0\374\374\0" + "66\0\370\370\0\376\376\0\376\376\0\"\"" + "\0\374\374\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376\0\376\376\0\376" + "\376\0\375\375\0\376\376\0\376\376\0\376\376\0\360\360\0\360\360\0\360\360" + "\0\360\360\0\16\16\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "&&\0&&\0##\0--\0``\0``\0TT\0cc\0\237\237\0\231\231\0||\0\223\223\0\306\306" + "\0\301\301\0\217\217\0\267\267\0\336\336\0\322\322\0\220\220\0\317\317\0" + "\352\352\0\334\334\0\202\202\0\337\337\0\362\362\0\345\345\0qq\0\353\353" + "\0\370\370\0\354\354\0^^\0\363\363\0\373\373\0\362\362\0JJ\0\371\371\0\375" + "\375\0\367\367\0" + "66\0\374\374\0\376\376\0\373\373\0\"\"\0\376\376\0\376" + "\376\0\375\375\0\16\16\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376" + "\0\376\376\0\375\375\0\376\376\0\376\376\0\375\375\0\360\360\0\376\376\0" + "\360\360\0\376\376\0\16\16\0\376\376\0\376\376\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "&&\0##\0" + "77\0--\0``\0PP\0nn\0[[\0\222\222\0kk\0\211\211\0qq\0\231\231\0" + "ff\0\210\210\0uu\0\217\217\0UU\0vv\0ll\0zz\0@@\0aa\0]]\0dd\0,,\0MM\0KK\0" + "OO\0\35\35\0::\0" + "99\0;;\0\21\21\0**\0))\0**\0\10\10\0\33\33\0\33\33\0\33" + "\33\0\3\3\0\17\17\0\17\17\0\17\17\0\0\0\0\7\7\0\7\7\0\7\7\0\7\7\0\2\2\0\2" + "\2\0\2\2\0\2\2\0\16\16\0\16\16\0\16\16\0\16\16\0\360\360\0\360\360\0\376" + "\376\0\376\376\0\16\16\0\376\376\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0##\0" + "77\0" + "77" + "\0--\0UU\0zz\0\216\216\0ww\0}}\0\254\254\0\324\324\0\264\264\0\207\207\0" + "\266\266\0\345\345\0\316\316\0\177\177\0\254\254\0\346\346\0\326\326\0rr" + "\0\231\231\0\344\344\0\334\334\0gg\0\206\206\0\344\344\0\340\340\0[[\0rr" + "\0\346\346\0\344\344\0NN\0^^\0\352\352\0\352\352\0AA\0JJ\0\357\357\0\357" + "\357\0" + "11\0" + "66\0\364\364\0\364\364\0\40\40\0\"\"\0\371\371\0\371\371\0" + "\16\16\0\16\16\0\375\375\0\375\375\0\376\376\0\376\376\0\362\362\0\362\362" + "\0\376\376\0\376\376\0\16\16\0\16\16\0\376\376\0\376\376\0\376\376\0\16\16" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\22\22\0" + "77\0" + "77\0--\0CC\0~~\0~~\0\\\\\0||\0" + "\274\274\0\274\274\0||\0\235\235\0\325\325\0\325\325\0\204\204\0\256\256" + "\0\340\340\0\340\340\0\177\177\0\275\275\0\351\351\0\351\351\0vv\0\316\316" + "\0\360\360\0\360\360\0ii\0\334\334\0\365\365\0\365\365\0ZZ\0\351\351\0\371" + "\371\0\371\371\0II\0\362\362\0\374\374\0\374\374\0" + "66\0\370\370\0\376\376" + "\0\376\376\0\"\"\0\374\374\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376" + "\0\376\376\0\376\376\0\375\375\0\376\376\0\376\376\0\376\376\0\360\360\0" + "\360\360\0\360\360\0\360\360\0\16\16\0\376\376\0\376\376\0\16\16\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0&&\0" + "77\0" + "22\0--\0``\0vv\0pp\0gg\0\243\243\0\255\255" + "\0\225\225\0\231\231\0\311\311\0\314\314\0\235\235\0\271\271\0\337\337\0" + "\326\326\0\224\224\0\320\320\0\352\352\0\336\336\0\204\204\0\337\337\0\362" + "\362\0\345\345\0qq\0\353\353\0\370\370\0\354\354\0^^\0\363\363\0\373\373" + "\0\362\362\0JJ\0\371\371\0\375\375\0\367\367\0" + "66\0\374\374\0\376\376\0" + "\373\373\0\"\"\0\376\376\0\376\376\0\375\375\0\16\16\0\376\376\0\376\376" + "\0\376\376\0\376\376\0\376\376\0\376\376\0\375\375\0\376\376\0\376\376\0" + "\375\375\0\360\360\0\376\376\0\360\360\0\376\376\0\16\16\0\376\376\0\376" + "\376\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0&&\0##\0FF\0" + "99\0``\0PP\0\200\200\0dd\0\222" + "\222\0kk\0\222\222\0vv\0\231\231\0ff\0\213\213\0ww\0\217\217\0UU\0xx\0mm" + "\0zz\0@@\0bb\0]]\0dd\0,,\0MM\0KK\0OO\0\35\35\0::\0" + "99\0;;\0\21\21\0**\0" + "))\0**\0\10\10\0\33\33\0\33\33\0\33\33\0\3\3\0\17\17\0\17\17\0\17\17\0\0" + "\0\0\7\7\0\7\7\0\7\7\0\7\7\0\2\2\0\2\2\0\2\2\0\2\2\0\16\16\0\16\16\0\16\16" + "\0\16\16\0\360\360\0\360\360\0\376\376\0\376\376\0\16\16\0\376\376\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0##\0" + "77\0" + "77\0" + "99\0^^\0zz\0\216\216\0\201\201\0\203" + "\203\0\254\254\0\324\324\0\271\271\0\211\211\0\266\266\0\345\345\0\317\317" + "\0\200\200\0\254\254\0\346\346\0\326\326\0ss\0\231\231\0\344\344\0\334\334" + "\0gg\0\206\206\0\344\344\0\340\340\0[[\0rr\0\346\346\0\344\344\0NN\0^^\0" + "\352\352\0\352\352\0AA\0JJ\0\357\357\0\357\357\0" + "11\0" + "66\0\364\364\0\364" + "\364\0\40\40\0\"\"\0\371\371\0\371\371\0\16\16\0\16\16\0\375\375\0\375\375" + "\0\376\376\0\376\376\0\362\362\0\362\362\0\376\376\0\376\376\0\16\16\0\16" + "\16\0\376\376\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\22\22" + "\0" + "77\0" + "77\0--\0MM\0\210\210\0\210\210\0\\\\\0\202\202\0\302\302\0\302" + "\302\0||\0\240\240\0\330\330\0\330\330\0\204\204\0\257\257\0\341\341\0\341" + "\341\0\177\177\0\275\275\0\351\351\0\351\351\0vv\0\316\316\0\360\360\0\360" + "\360\0ii\0\334\334\0\365\365\0\365\365\0ZZ\0\351\351\0\371\371\0\371\371" + "\0II\0\362\362\0\374\374\0\374\374\0" + "66\0\370\370\0\376\376\0\376\376\0" + "\"\"\0\374\374\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376\0\376\376" + "\0\376\376\0\375\375\0\376\376\0\376\376\0\376\376\0\360\360\0\360\360\0" + "\360\360\0\360\360\0\16\16\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0&&\0" + "77\0" + "22\0--\0``\0vv\0xx\0kk\0\245\245\0\257\257\0\235\235" + "\0\234\234\0\312\312\0\315\315\0\241\241\0\272\272\0\337\337\0\326\326\0" + "\225\225\0\320\320\0\352\352\0\336\336\0\204\204\0\337\337\0\362\362\0\345" + "\345\0qq\0\353\353\0\370\370\0\354\354\0^^\0\363\363\0\373\373\0\362\362" + "\0JJ\0\371\371\0\375\375\0\367\367\0" + "66\0\374\374\0\376\376\0\373\373\0" + "\"\"\0\376\376\0\376\376\0\375\375\0\16\16\0\376\376\0\376\376\0\376\376" + "\0\376\376\0\376\376\0\376\376\0\375\375\0\376\376\0\376\376\0\375\375\0" + "\360\360\0\376\376\0\360\360\0\376\376\0\16\16\0\376\376\0\376\376\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0&&\0##\0FF\0" + "99\0``\0PP\0\200\200\0dd\0\222\222\0kk" + "\0\222\222\0vv\0\231\231\0ff\0\213\213\0ww\0\217\217\0UU\0xx\0mm\0zz\0@@" + "\0bb\0]]\0dd\0,,\0MM\0KK\0OO\0\35\35\0::\0" + "99\0;;\0\21\21\0**\0))\0**\0" + "\10\10\0\33\33\0\33\33\0\33\33\0\3\3\0\17\17\0\17\17\0\17\17\0\0\0\0\7\7" + "\0\7\7\0\7\7\0\7\7\0\2\2\0\2\2\0\2\2\0\2\2\0\16\16\0\16\16\0\16\16\0\16\16" + "\0\360\360\0\360\360\0\376\376\0\376\376\0\16\16\0\376\376\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0##\0" + "77\0" + "77\0" + "99\0^^\0zz\0\216\216\0\201\201\0\203\203\0" + "\254\254\0\324\324\0\271\271\0\211\211\0\266\266\0\345\345\0\317\317\0\200" + "\200\0\254\254\0\346\346\0\326\326\0ss\0\231\231\0\344\344\0\334\334\0gg" + "\0\206\206\0\344\344\0\340\340\0[[\0rr\0\346\346\0\344\344\0NN\0^^\0\352" + "\352\0\352\352\0AA\0JJ\0\357\357\0\357\357\0" + "11\0" + "66\0\364\364\0\364\364" + "\0\40\40\0\"\"\0\371\371\0\371\371\0\16\16\0\16\16\0\375\375\0\375\375\0" + "\376\376\0\376\376\0\362\362\0\362\362\0\376\376\0\376\376\0\16\16\0\16\16" + "\0\376\376\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\22\22\0" + "" + "77\0" + "77\0--\0MM\0\210\210\0\210\210\0\\\\\0\202\202\0\302\302\0\302\302" + "\0||\0\240\240\0\330\330\0\330\330\0\204\204\0\257\257\0\341\341\0\341\341" + "\0\177\177\0\275\275\0\351\351\0\351\351\0vv\0\316\316\0\360\360\0\360\360" + "\0ii\0\334\334\0\365\365\0\365\365\0ZZ\0\351\351\0\371\371\0\371\371\0II" + "\0\362\362\0\374\374\0\374\374\0" + "66\0\370\370\0\376\376\0\376\376\0\"\"" + "\0\374\374\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376\0\376\376\0\376" + "\376\0\375\375\0\376\376\0\376\376\0\376\376\0\360\360\0\360\360\0\360\360" + "\0\360\360\0\16\16\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "&&\0" + "77\0" + "22\0--\0``\0vv\0xx\0kk\0\245\245\0\257\257\0\235\235\0\234\234" + "\0\312\312\0\315\315\0\241\241\0\272\272\0\337\337\0\326\326\0\225\225\0" + "\320\320\0\352\352\0\336\336\0\204\204\0\337\337\0\362\362\0\345\345\0qq" + "\0\353\353\0\370\370\0\354\354\0^^\0\363\363\0\373\373\0\362\362\0JJ\0\371" + "\371\0\375\375\0\367\367\0" + "66\0\374\374\0\376\376\0\373\373\0\"\"\0\376" + "\376\0\376\376\0\375\375\0\16\16\0\376\376\0\376\376\0\376\376\0\376\376" + "\0\376\376\0\376\376\0\375\375\0\376\376\0\376\376\0\375\375\0\360\360\0" + "\376\376\0\360\360\0\376\376\0\16\16\0\376\376\0\376\376\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0&&\0##\0FF\0" + "99\0``\0PP\0\200\200\0dd\0\222\222\0kk\0\222\222" + "\0vv\0\231\231\0ff\0\213\213\0ww\0\217\217\0UU\0xx\0mm\0zz\0@@\0bb\0]]\0" + "dd\0,,\0MM\0KK\0OO\0\35\35\0::\0" + "99\0;;\0\21\21\0**\0))\0**\0\10\10\0\33" + "\33\0\33\33\0\33\33\0\3\3\0\17\17\0\17\17\0\17\17\0\0\0\0\7\7\0\7\7\0\7\7" + "\0\7\7\0\2\2\0\2\2\0\2\2\0\2\2\0\16\16\0\16\16\0\16\16\0\16\16\0\360\360" + "\0\360\360\0\376\376\0\376\376\0\16\16\0\376\376\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0##\0" + "77\0" + "77\0" + "99\0^^\0zz\0\216\216\0\201\201\0\203\203\0\254\254\0" + "\324\324\0\271\271\0\211\211\0\266\266\0\345\345\0\317\317\0\200\200\0\254" + "\254\0\346\346\0\326\326\0ss\0\231\231\0\344\344\0\334\334\0gg\0\206\206" + "\0\344\344\0\340\340\0[[\0rr\0\346\346\0\344\344\0NN\0^^\0\352\352\0\352" + "\352\0AA\0JJ\0\357\357\0\357\357\0" + "11\0" + "66\0\364\364\0\364\364\0\40\40" + "\0\"\"\0\371\371\0\371\371\0\16\16\0\16\16\0\375\375\0\375\375\0\376\376" + "\0\376\376\0\362\362\0\362\362\0\376\376\0\376\376\0\16\16\0\16\16\0\376" + "\376\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\22\22\0" + "77\0" + "" + "77\0--\0MM\0\210\210\0\210\210\0\\\\\0\202\202\0\302\302\0\302\302\0||" + "\0\240\240\0\330\330\0\330\330\0\204\204\0\257\257\0\341\341\0\341\341\0" + "\177\177\0\275\275\0\351\351\0\351\351\0vv\0\316\316\0\360\360\0\360\360" + "\0ii\0\334\334\0\365\365\0\365\365\0ZZ\0\351\351\0\371\371\0\371\371\0II" + "\0\362\362\0\374\374\0\374\374\0" + "66\0\370\370\0\376\376\0\376\376\0\"\"" + "\0\374\374\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376\0\376\376\0\376" + "\376\0\375\375\0\376\376\0\376\376\0\376\376\0\360\360\0\360\360\0\360\360" + "\0\360\360\0\16\16\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "&&\0" + "77\0" + "22\0--\0``\0vv\0xx\0kk\0\245\245\0\257\257\0\235\235\0\234\234" + "\0\312\312\0\315\315\0\241\241\0\272\272\0\337\337\0\326\326\0\225\225\0" + "\320\320\0\352\352\0\336\336\0\204\204\0\337\337\0\362\362\0\345\345\0qq" + "\0\353\353\0\370\370\0\354\354\0^^\0\363\363\0\373\373\0\362\362\0JJ\0\371" + "\371\0\375\375\0\367\367\0" + "66\0\374\374\0\376\376\0\373\373\0\"\"\0\376" + "\376\0\376\376\0\375\375\0\16\16\0\376\376\0\376\376\0\376\376\0\376\376" + "\0\376\376\0\376\376\0\375\375\0\376\376\0\376\376\0\375\375\0\360\360\0" + "\376\376\0\360\360\0\376\376\0\16\16\0\376\376\0\376\376\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0&&\0##\0FF\0" + "99\0``\0PP\0\200\200\0dd\0\222\222\0kk\0\222\222" + "\0vv\0\231\231\0ff\0\213\213\0ww\0\217\217\0UU\0xx\0mm\0zz\0@@\0bb\0]]\0" + "dd\0,,\0MM\0KK\0OO\0\35\35\0::\0" + "99\0;;\0\21\21\0**\0))\0**\0\10\10\0\33" + "\33\0\33\33\0\33\33\0\3\3\0\17\17\0\17\17\0\17\17\0\0\0\0\7\7\0\7\7\0\7\7" + "\0\7\7\0\2\2\0\2\2\0\2\2\0\2\2\0\16\16\0\16\16\0\16\16\0\16\16\0\360\360" + "\0\360\360\0\376\376\0\376\376\0\16\16\0\376\376\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0##\0" + "77\0" + "77\0" + "99\0^^\0zz\0\216\216\0\201\201\0\203\203\0\254\254\0" + "\324\324\0\271\271\0\211\211\0\266\266\0\345\345\0\317\317\0\200\200\0\254" + "\254\0\346\346\0\326\326\0ss\0\231\231\0\344\344\0\334\334\0gg\0\206\206" + "\0\344\344\0\340\340\0[[\0rr\0\346\346\0\344\344\0NN\0^^\0\352\352\0\352" + "\352\0AA\0JJ\0\357\357\0\357\357\0" + "11\0" + "66\0\364\364\0\364\364\0\40\40" + "\0\"\"\0\371\371\0\371\371\0\16\16\0\16\16\0\375\375\0\375\375\0\376\376" + "\0\376\376\0\362\362\0\362\362\0\376\376\0\376\376\0\16\16\0\16\16\0\376" + "\376\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\22\22\0" + "77\0" + "" + "77\0--\0MM\0\210\210\0\210\210\0\\\\\0\202\202\0\302\302\0\302\302\0||" + "\0\240\240\0\330\330\0\330\330\0\204\204\0\257\257\0\341\341\0\341\341\0" + "\177\177\0\275\275\0\351\351\0\351\351\0vv\0\316\316\0\360\360\0\360\360" + "\0ii\0\334\334\0\365\365\0\365\365\0ZZ\0\351\351\0\371\371\0\371\371\0II" + "\0\362\362\0\374\374\0\374\374\0" + "66\0\370\370\0\376\376\0\376\376\0\"\"" + "\0\374\374\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376\0\376\376\0\376" + "\376\0\375\375\0\376\376\0\376\376\0\376\376\0\360\360\0\360\360\0\360\360" + "\0\360\360\0\16\16\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "&&\0" + "77\0" + "22\0--\0``\0vv\0xx\0kk\0\245\245\0\257\257\0\235\235\0\234\234" + "\0\312\312\0\315\315\0\241\241\0\272\272\0\337\337\0\326\326\0\225\225\0" + "\320\320\0\352\352\0\336\336\0\204\204\0\337\337\0\362\362\0\345\345\0qq" + "\0\353\353\0\370\370\0\354\354\0^^\0\363\363\0\373\373\0\362\362\0JJ\0\371" + "\371\0\375\375\0\367\367\0" + "66\0\374\374\0\376\376\0\373\373\0\"\"\0\376" + "\376\0\376\376\0\375\375\0\16\16\0\376\376\0\376\376\0\376\376\0\376\376" + "\0\376\376\0\376\376\0\375\375\0\376\376\0\376\376\0\375\375\0\360\360\0" + "\376\376\0\360\360\0\376\376\0\16\16\0\376\376\0\376\376\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0&&\0##\0FF\0" + "99\0``\0PP\0\213\213\0mm\0\237\237\0uu\0\275\275" + "\0\232\232\0\306\306\0\204\204\0\331\331\0\272\272\0\336\336\0\205\205\0" + "\345\345\0\320\320\0\352\352\0{{\0\355\355\0\337\337\0\362\362\0mm\0\363" + "\363\0\353\353\0\370\370\0\\\\\0\367\367\0\363\363\0\373\373\0II\0\373\373" + "\0\371\371\0\375\375\0" + "66\0\375\375\0\374\374\0\376\376\0\"\"\0\376\376" + "\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376\0\376\376\0\376\376\0\376" + "\376\0\376\376\0\376\376\0\376\376\0\375\375\0\376\376\0\375\375\0\375\375" + "\0\360\360\0\360\360\0\376\376\0\376\376\0\16\16\0\376\376\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0##\0" + "77\0" + "77\0" + "99\0gg\0\205\205\0\205\205\0ww\0\224\224\0" + "\310\310\0\310\310\0\247\247\0\240\240\0\354\354\0\354\354\0\306\306\0\227" + "\227\0\372\372\0\372\372\0\325\325\0\205\205\0\375\375\0\375\375\0\342\342" + "\0rr\0\376\376\0\376\376\0\354\354\0^^\0\376\376\0\376\376\0\363\363\0JJ" + "\0\376\376\0\376\376\0\370\370\0" + "66\0\376\376\0\376\376\0\374\374\0\"\"" + "\0\376\376\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376\0\376\376\0\376" + "\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\375\375" + "\0\376\376\0\376\376\0\376\376\0\362\362\0\376\376\0\376\376\0\376\376\0" + "\16\16\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\22\22\0" + "77\0" + "77\0" + "11\0>>\0~~\0~~\0bb" + "\0__\0\261\261\0\261\261\0\212\212\0``\0\277\277\0\277\277\0\230\230\0SS" + "\0\275\275\0\275\275\0\233\233\0@@\0\273\273\0\273\273\0\240\240\0//\0\274" + "\274\0\274\274\0\252\252\0!!\0\301\301\0\301\301\0\266\266\0\25\25\0\311" + "\311\0\311\311\0\303\303\0\14\14\0\324\324\0\324\324\0\322\322\0\6\6\0\342" + "\342\0\342\342\0\341\341\0\1\1\0\361\361\0\361\361\0\361\361\0\15\15\0\15" + "\15\0\15\15\0\15\15\0\362\362\0\362\362\0\362\362\0\360\360\0\16\16\0\16" + "\16\0\16\16\0\2\2\0\376\376\0\376\376\0\376\376\0\16\16\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0&&\0" + "77\0" + "77\0\34\34\0SS\0kk\0\206\206\0BB\0\214\214\0\232\232" + "\0\302\302\0YY\0\250\250\0\255\255\0\340\340\0XX\0\264\264\0\264\264\0\355" + "\355\0SS\0\265\265\0\266\266\0\364\364\0JJ\0\270\270\0\272\272\0\371\371" + "\0AA\0\277\277\0\300\300\0\374\374\0" + "66\0\310\310\0\311\311\0\375\375\0" + "**\0\324\324\0\324\324\0\376\376\0\34\34\0\341\341\0\342\342\0\376\376\0" + "\15\15\0\361\361\0\361\361\0\376\376\0\361\361\0\15\15\0\15\15\0\376\376" + "\0\15\15\0\361\361\0\361\361\0\373\373\0\362\362\0\15\15\0\16\16\0\376\376" + "\0\16\16\0\361\361\0\376\376\0\376\376\0\376\376\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0&&\0&&\0" + "77\0))\0SS\0SS\0kk\0DD\0\205\205\0}}\0\222\222\0WW\0\241\241" + "\0\230\230\0\245\245\0XX\0\261\261\0\252\252\0\261\261\0SS\0\264\264\0\263" + "\263\0\265\265\0JJ\0\270\270\0\271\271\0\272\272\0AA\0\276\276\0\300\300" + "\0\300\300\0" + "66\0\310\310\0\311\311\0\311\311\0**\0\324\324\0\324\324\0" + "\324\324\0\34\34\0\341\341\0\342\342\0\342\342\0\15\15\0\361\361\0\361\361" + "\0\361\361\0\361\361\0\15\15\0\15\15\0\15\15\0\15\15\0\361\361\0\361\361" + "\0\361\361\0\362\362\0\15\15\0\16\16\0\16\16\0\16\16\0\361\361\0\376\376" + "\0\376\376\0\376\376\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0&&\0&&\0&&\0))\0pp\0cc\0cc" + "\0QQ\0\261\261\0\244\244\0\244\244\0ll\0\335\335\0\323\323\0\323\323\0ww" + "\0\364\364\0\356\356\0\356\356\0ss\0\370\370\0\371\371\0\371\371\0ii\0\372" + "\372\0\375\375\0\375\375\0YY\0\374\374\0\376\376\0\376\376\0HH\0\375\375" + "\0\376\376\0\376\376\0" + "66\0\376\376\0\376\376\0\376\376\0\"\"\0\376\376" + "\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376\0\376\376\0\376\376\0\376" + "\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376" + "\0\375\375\0\376\376\0\376\376\0\376\376\0\361\361\0\376\376\0\376\376\0" + "\376\376\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0&&\0&&\0\40\40\0QQ\0pp\0pp\0KK" + "\0\215\215\0\261\261\0\261\261\0pp\0\274\274\0\337\337\0\337\337\0\200\200" + "\0\332\332\0\364\364\0\364\364\0}}\0\350\350\0\373\373\0\373\373\0oo\0\361" + "\361\0\375\375\0\375\375\0]]\0\367\367\0\376\376\0\376\376\0JJ\0\373\373" + "\0\376\376\0\376\376\0" + "66\0\375\375\0\376\376\0\376\376\0\"\"\0\376\376" + "\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376\0\376\376\0\376\376\0\376" + "\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376" + "\0\375\375\0\376\376\0\376\376\0\376\376\0\361\361\0\376\376\0\376\376\0" + "\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0&&\0&&\0\20\20\0" + "88\0WW\0pp\0" + "==\0ss\0\212\212\0\252\252\0dd\0\250\250\0\264\264\0\312\312\0rr\0\313\313" + "\0\315\315\0\331\331\0rr\0\340\340\0\331\331\0\340\340\0hh\0\355\355\0\341" + "\341\0\345\345\0YY\0\366\366\0\350\350\0\352\352\0HH\0\372\372\0\356\356" + "\0\357\357\0" + "66\0\375\375\0\364\364\0\364\364\0\"\"\0\376\376\0\371\371" + "\0\371\371\0\16\16\0\376\376\0\375\375\0\375\375\0\376\376\0\376\376\0\361" + "\361\0\362\362\0\376\376\0\376\376\0\16\16\0\16\16\0\376\376\0\375\375\0" + "\376\376\0\375\375\0\374\374\0\360\360\0\376\376\0\376\376\0\360\360\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\24\24\0\24\24\0&&\0\40\40\0" + "88\0" + "88\0WW\0BB\0ff" + "\0ZZ\0}}\0^^\0\226\226\0\201\201\0\241\241\0nn\0\301\301\0\246\246\0\277" + "\277\0rr\0\333\333\0\301\301\0\321\321\0ii\0\353\353\0\323\323\0\335\335" + "\0[[\0\365\365\0\341\341\0\346\346\0II\0\372\372\0\353\353\0\356\356\0" + "6" + "6\0\375\375\0\363\363\0\364\364\0\"\"\0\376\376\0\371\371\0\371\371\0\16" + "\16\0\376\376\0\375\375\0\375\375\0\376\376\0\376\376\0\361\361\0\361\361" + "\0\376\376\0\376\376\0\16\16\0\16\16\0\376\376\0\374\374\0\375\375\0\374" + "\374\0\374\374\0\361\361\0\376\376\0\360\360\0\360\360\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\24\24\0\24\24\0\24\24\0\40\40\0HH\0" + "88\0" + "88\0BB\0~~\0ff\0ff\0" + "^^\0\256\256\0\226\226\0\226\226\0qq\0\325\325\0\277\277\0\277\277\0ss\0" + "\350\350\0\331\331\0\331\331\0jj\0\363\363\0\353\353\0\353\353\0[[\0\371" + "\371\0\365\365\0\365\365\0II\0\374\374\0\372\372\0\372\372\0" + "66\0\375\375" + "\0\375\375\0\375\375\0\"\"\0\376\376\0\376\376\0\376\376\0\16\16\0\376\376" + "\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0" + "\376\376\0\376\376\0\376\376\0\376\376\0\374\374\0\374\374\0\374\374\0\376" + "\376\0\361\361\0\360\360\0\360\360\0\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\24\24\0\24\24\0\24\24\0\40\40\0HH\0HH\0" + "88\0BB\0~~\0~~\0ff\0^^\0\263" + "\263\0\263\263\0\231\231\0nn\0\330\330\0\330\330\0\274\274\0pp\0\353\353" + "\0\353\353\0\324\324\0hh\0\365\365\0\365\365\0\345\345\0ZZ\0\373\373\0\373" + "\373\0\361\361\0II\0\375\375\0\375\375\0\370\370\0" + "66\0\376\376\0\376\376" + "\0\374\374\0\"\"\0\376\376\0\376\376\0\376\376\0\16\16\0\376\376\0\376\376" + "\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0\376\376\0" + "\376\376\0\374\374\0\374\374\0\376\376\0\376\376\0\361\361\0\360\360\0\360" + "\360\0\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0\24\24\0\0\0" + "\0\0\0\0((\0HH\0\40\40\0\25\25\0QQ\0\207\207\0KK\0--\0}}\0\262\262\0bb\0" + "" + "44\0\235\235\0\320\320\0ff\0" + "00\0\257\257\0\341\341\0cc\0))\0\272\272" + "\0\354\354\0ZZ\0\37\37\0\303\303\0\363\363\0OO\0\26\26\0\314\314\0\370\370" + "\0AA\0\15\15\0\326\326\0\373\373\0" + "22\0\6\6\0\343\343\0\375\375\0!!\0\1" + "\1\0\362\362\0\376\376\0\16\16\0\16\16\0\16\16\0\375\375\0\375\375\0\375" + "\375\0\376\376\0\362\362\0\360\360\0\361\361\0\376\376\0\14\14\0\0\0\0\0" + "\0\0\360\360\0\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24" + "\0\24\24\0\0\0\0\0\0\0((\0((\0\0\0\0\0\0\0<<\0<<\0\0\0\0\0\0\0PP\0PP\0\10" + "\10\0\4\4\0dd\0dd\0\14\14\0\6\6\0xx\0xx\0\14\14\0\5\5\0\214\214\0\214\214" + "\0\13\13\0\4\4\0\240\240\0\240\240\0\10\10\0\2\2\0\264\264\0\264\264\0\5" + "\5\0\1\1\0\310\310\0\310\310\0\3\3\0\0\0\0\334\334\0\334\334\0\1\1\0\0\0" + "\0\360\360\0\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1\0\1\1\0\0\0\0\0\0\0\14" + "\14\0\14\14\0\0\0\0\0\0\0\360\360\0\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0\24\24\0\0\0\0\0\0\0((\0((\0\0\0\0\0\0" + "\0<<\0<<\0\0\0\0\0\0\0XX\0XX\0\0\0\0\0\0\0pp\0pp\0\0\0\0\0\0\0\204\204\0" + "\204\204\0\0\0\0\0\0\0\227\227\0\227\227\0\0\0\0\0\0\0\250\250\0\250\250" + "\0\0\0\0\0\0\0\271\271\0\271\271\0\0\0\0\0\0\0\313\313\0\313\313\0\0\0\0" + "\0\0\0\335\335\0\335\335\0\0\0\0\0\0\0\360\360\0\360\360\0\0\0\0\0\0\0\1" + "\1\0\1\1\0\0\0\0\0\0\0\14\14\0\14\14\0\0\0\0\0\0\0\360\360\0\360\360\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0" + "\24\24\0\24\24\0\0\0\0((\0((\0((\0\0\0\0<<\0HH\0HH\0\10\10\0PP\0dd\0dd\0" + "\14\14\0dd\0||\0||\0\14\14\0xx\0\221\221\0\221\221\0\13\13\0\214\214\0\243" + "\243\0\243\243\0\10\10\0\240\240\0\264\264\0\264\264\0\5\5\0\264\264\0\303" + "\303\0\303\303\0\3\3\0\310\310\0\322\322\0\322\322\0\1\1\0\334\334\0\341" + "\341\0\341\341\0\0\0\0\360\360\0\361\361\0\361\361\0\1\1\0\0\0\0\14\14\0" + "\14\14\0\14\14\0\0\0\0\360\360\0\360\360\0\360\360\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\24\0" + "\24\24\0\20\20\0\20\20\0" + "88\0" + "88\0**\0**\0ZZ\0ZZ\0==\0==\0yy\0yy\0II\0" + "II\0\224\224\0\224\224\0NN\0NN\0\254\254\0\254\254\0MM\0MM\0\302\302\0\302" + "\302\0HH\0HH\0\324\324\0\324\324\0>>\0>>\0\343\343\0\343\343\0" + "00\0" + "00" + "\0\356\356\0\356\356\0\40\40\0\40\40\0\367\367\0\367\367\0\16\16\0\16\16" + "\0\374\374\0\374\374\0\374\374\0\374\374\0\360\360\0\360\360\0\360\360\0" + "\360\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", }; /** @@ -1535,25 +1675,25 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitAlpha = { */ SDL_Surface *SDLTest_ImageBlitAlpha() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( - (void*)SDLTest_imageBlitAlpha.pixel_data, + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + (void *)SDLTest_imageBlitAlpha.pixel_data, SDLTest_imageBlitAlpha.width, SDLTest_imageBlitAlpha.height, SDLTest_imageBlitAlpha.bytes_per_pixel * 8, SDLTest_imageBlitAlpha.width * SDLTest_imageBlitAlpha.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ + 0xff000000, /* Red bit mask. */ + 0x00ff0000, /* Green bit mask. */ + 0x0000ff00, /* Blue bit mask. */ + 0x000000ff /* Alpha bit mask. */ #else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ + 0x000000ff, /* Red bit mask. */ + 0x0000ff00, /* Green bit mask. */ + 0x00ff0000, /* Blue bit mask. */ + 0xff000000 /* Alpha bit mask. */ #endif - ); - return surface; + ); + return surface; } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/test/SDL_test_imageBlitBlend.c b/src/test/SDL_test_imageBlitBlend.c index d57899edb..054a0afdd 100644 --- a/src/test/SDL_test_imageBlitBlend.c +++ b/src/test/SDL_test_imageBlitBlend.c @@ -25,554 +25,556 @@ /* GIMP RGB C-Source image dump (alpha.c) */ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAdd = { - 80, 60, 3, - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310" - "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310" - "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0" - "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310" - "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310" - "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0" - "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310" - "\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310\310\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310" - "\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310\310" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\310\310\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd" - "\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0" - "\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310" - "\310\0\310\310\0\310\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0" - "dd\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0" - "dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd" - "\0\310\310\0\310\310\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310" - "\310\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\310\310\0\310\310" - "\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310" - "\310\0\310\310\0\310\310\0\310\310\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310\310\0\310" - "\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\310\310\0\310\310\0\310\310\0dd\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310" - "\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\310\310\0dd\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310" - "\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310" - "\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310" - "\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310" - "\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310" - "\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310" - "\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310" - "\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\310" - "\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310" - "\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\310\310" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\310\310\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\310\310" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\310\310\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310" - "\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310\310\0\310\310\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310" - "\310\0\310\310\0\310\310\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310\310\0dd\0\310\310\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0" - "dd\0\310\310\0\310\310\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310\310" - "\0\377\377\0\377\377\0\377\377\0\310\310\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\310\310\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\310" - "\310\0\310\310\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0\310\310\0\377\377\0\310\310\0\310\310" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\377\377\0\310\310\0dd" - "\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0dd\0dd\0dd\0\310\310\0\377\377\0\377\377\0\310\310\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\310\310\0\377\377\0\377\377\0\310\310\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd" - "\0\0\0\0\0\0\0dd\0\377\377\0\310\310\0\310\310\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\377\377\0dd\0\0" - "\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0" - "\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0" - "dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0" - "dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0" - "dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\0\0\0" - "\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0" - "\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310" - "\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310" - "\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0" - "\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0" - "\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0\0\0\0dd\0dd\0dd\0\0\0\0dd\0\310\310\0\310" - "\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310" - "\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0" - "dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310" - "\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0" - "\0\0\0dd\0dd\0dd\0\0\0\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310" - "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310" - "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0" - "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310" - "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310" - "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0" - "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310" - "\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", + 80, + 60, + 3, + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310" + "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310" + "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0" + "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310" + "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310" + "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0" + "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310" + "\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310\310\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310" + "\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310\310" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\310\310\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd" + "\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0" + "\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310" + "\310\0\310\310\0\310\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0" + "dd\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0" + "dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd" + "\0\310\310\0\310\310\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310" + "\310\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\310\310\0\310\310" + "\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310" + "\310\0\310\310\0\310\310\0\310\310\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310\310\0\310" + "\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\310\310\0\310\310\0\310\310\0dd\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310" + "\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\310\310\0dd\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310" + "\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310" + "\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310" + "\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310" + "\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310" + "\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310" + "\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310" + "\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\310" + "\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310" + "\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\310\310" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\310\310\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\310\310" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\310\310\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310" + "\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310\310\0\310\310\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310" + "\310\0\310\310\0\310\310\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310\310\0dd\0\310\310\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0" + "dd\0\310\310\0\310\310\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310\310" + "\0\377\377\0\377\377\0\377\377\0\310\310\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\310\310\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\310" + "\310\0\310\310\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0\310\310\0\377\377\0\310\310\0\310\310" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\377\377\0\310\310\0dd" + "\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0dd\0dd\0dd\0\310\310\0\377\377\0\377\377\0\310\310\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\310\310\0\377\377\0\377\377\0\310\310\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd" + "\0\0\0\0\0\0\0dd\0\377\377\0\310\310\0\310\310\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\377\377\0dd\0\0" + "\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0" + "\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0" + "dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0" + "dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0" + "dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\0\0\0" + "\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0" + "\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310" + "\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310" + "\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0" + "\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0" + "\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0\0\0\0dd\0dd\0dd\0\0\0\0dd\0\310\310\0\310" + "\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310" + "\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0" + "dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310" + "\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0" + "\0\0\0dd\0dd\0dd\0\0\0\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310" + "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310" + "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0" + "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310" + "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310" + "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0" + "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310" + "\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", }; /** @@ -580,529 +582,601 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAdd = { */ SDL_Surface *SDLTest_ImageBlitBlendAdd() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( - (void*)SDLTest_imageBlitBlendAdd.pixel_data, + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + (void *)SDLTest_imageBlitBlendAdd.pixel_data, SDLTest_imageBlitBlendAdd.width, SDLTest_imageBlitBlendAdd.height, SDLTest_imageBlitBlendAdd.bytes_per_pixel * 8, SDLTest_imageBlitBlendAdd.width * SDLTest_imageBlitBlendAdd.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ + 0xff000000, /* Red bit mask. */ + 0x00ff0000, /* Green bit mask. */ + 0x0000ff00, /* Blue bit mask. */ + 0x000000ff /* Alpha bit mask. */ #else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ + 0x000000ff, /* Red bit mask. */ + 0x0000ff00, /* Green bit mask. */ + 0x00ff0000, /* Blue bit mask. */ + 0xff000000 /* Alpha bit mask. */ #endif - ); - return surface; + ); + return surface; } static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlend = { - 80, 60, 3, - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0<<\0<<\0\240\240\0\240\240\0aa\0aa\0\240" - "\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0" - "aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240" - "\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0" - "aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240" - "\240\0\240\240\0\240\240\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0<<\0\240\240\0\240\240\0\240\240" - "\0aa\0\305\305\0\305\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww" - "\0\305\305\0\305\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww\0\305" - "\305\0\305\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww\0\305\305" - "\0\305\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww\0\305\305\0\305" - "\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww\0\305\305\0\305\305" - "\0\305\305\0\305\305\0\240\240\0\240\240\0\240\240\0\240\240\0dd\0dd\0dd" - "\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0<<\0\240\240" - "\0\240\240\0\240\240\0aa\0\305\305\0\305\305\0\305\305\0ww\0\333\333\0\333" - "\333\0\305\305\0ww\0\333\333\0\333\333\0\305\305\0ww\0\333\333\0\333\333" - "\0\305\305\0ww\0\333\333\0\333\333\0\305\305\0ww\0\333\333\0\333\333\0\305" - "\305\0ww\0\333\333\0\333\333\0\305\305\0ww\0\333\333\0\333\333\0\305\305" - "\0ww\0\333\333\0\333\333\0\305\305\0ww\0\333\333\0\333\333\0\305\305\0ww" - "\0\333\333\0\333\333\0\305\305\0\305\305\0\305\305\0\305\305\0\240\240\0" - "\240\240\0\240\240\0\240\240\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0dd\0dd\0dd\0<<\0aa\0aa\0aa\0::\0HH\0HH\0HH\0++\0PP\0PP\0PP\0""00\0PP" - "\0PP\0PP\0""00\0PP\0PP\0PP\0""00\0PP\0PP\0PP\0""00\0PP\0PP\0PP\0""00\0PP" - "\0PP\0PP\0""00\0PP\0PP\0PP\0""00\0PP\0PP\0PP\0""00\0PP\0PP\0PP\0""00\0PP" - "\0PP\0PP\0PP\0HH\0HH\0HH\0HH\0aa\0aa\0aa\0aa\0dd\0dd\0dd\0dd\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0dd\0dd\0dd\0$$\0aa\0\305\305\0\305\305\0``\0\205\205\0\351\351\0" - "\351\351\0||\0\222\222\0\321\321\0\321\321\0\177\177\0\225\225\0\324\324" - "\0\321\321\0\177\177\0\225\225\0\324\324\0\321\321\0\177\177\0\225\225\0" - "\324\324\0\321\321\0\177\177\0\225\225\0\324\324\0\321\321\0\177\177\0\225" - "\225\0\324\324\0\321\321\0\177\177\0\225\225\0\324\324\0\321\321\0\177\177" - "\0\225\225\0\324\324\0\321\321\0\177\177\0\225\225\0\324\324\0\321\321\0" - "\177\177\0\225\225\0\324\324\0\321\321\0\222\222\0\222\222\0\321\321\0\314" - "\314\0\351\351\0\351\351\0\254\254\0\236\236\0\305\305\0\305\305\0aa\0<<" - "\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0<<\0dd\0\240\240\0\240\240\0aa\0\255\255" - "\0\322\322\0\322\322\0\177\177\0\315\315\0\343\343\0\343\343\0\211\211\0" - "\313\313\0\346\346\0\346\346\0\211\211\0\313\313\0\346\346\0\346\346\0\211" - "\211\0\313\313\0\346\346\0\346\346\0\211\211\0\313\313\0\346\346\0\346\346" - "\0\211\211\0\313\313\0\346\346\0\346\346\0\211\211\0\313\313\0\346\346\0" - "\346\346\0\211\211\0\313\313\0\346\346\0\346\346\0\211\211\0\313\313\0\346" - "\346\0\346\346\0\211\211\0\313\313\0\346\346\0\346\346\0\211\211\0\320\320" - "\0\327\327\0\327\327\0\322\322\0\276\276\0\322\322\0\322\322\0\305\305\0" - "yy\0\210\210\0\210\210\0dd\0<<\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0<<\0\210\210\0\240" - "\240\0\240\240\0aa\0\266\266\0\322\322\0\322\322\0\205\205\0\327\327\0\343" - "\343\0\343\343\0\215\215\0\346\346\0\357\357\0\331\331\0\222\222\0\347\347" - "\0\357\357\0\331\331\0\222\222\0\347\347\0\357\357\0\331\331\0\222\222\0" - "\347\347\0\357\357\0\331\331\0\222\222\0\347\347\0\357\357\0\331\331\0\222" - "\222\0\347\347\0\357\357\0\331\331\0\222\222\0\347\347\0\357\357\0\331\331" - "\0\222\222\0\347\347\0\357\357\0\331\331\0\222\222\0\347\347\0\357\357\0" - "\331\331\0\222\222\0\357\357\0\346\346\0\320\320\0\351\351\0\327\327\0\343" - "\343\0\276\276\0\333\333\0\322\322\0\266\266\0yy\0\240\240\0\210\210\0\240" - "\240\0<<\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0dd\0<<\0\240\240\0\210\210\0\240\240\0aa\0ww\0nn\0\177" - "\177\0MM\0SS\0OO\0SS\0""22\0WW\0TT\0XX\0""55\0UU\0UU\0XX\0""55\0UU\0UU\0" - "XX\0""55\0UU\0UU\0XX\0""55\0UU\0UU\0XX\0""55\0UU\0UU\0XX\0""55\0UU\0UU\0" - "XX\0""55\0UU\0UU\0XX\0""55\0UU\0UU\0XX\0""55\0UU\0XX\0TT\0TT\0LL\0OO\0SS" - "\0SS\0ss\0\177\177\0nn\0nn\0yy\0\210\210\0\240\240\0\240\240\0<<\0dd\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0<<" - "\0\240\240\0\240\240\0\210\210\0HH\0\205\205\0\351\351\0\333\333\0pp\0\225" - "\225\0\371\371\0\363\363\0\202\202\0\231\231\0\330\330\0\325\325\0\203\203" - "\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0" - "\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324" - "\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331" - "\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0" - "\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\325\325\0\231\231\0\231" - "\231\0\330\330\0\323\323\0\371\371\0\371\371\0\274\274\0\257\257\0\351\351" - "\0\351\351\0\205\205\0``\0\240\240\0\240\240\0\240\240\0<<\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0<<\0\240\240" - "\0\240\240\0RR\0\207\207\0\304\304\0\304\304\0nn\0\275\275\0\343\343\0\343" - "\343\0\205\205\0\324\324\0\352\352\0\352\352\0\214\214\0\316\316\0\352\352" - "\0\352\352\0\213\213\0\316\316\0\352\352\0\352\352\0\213\213\0\316\316\0" - "\352\352\0\352\352\0\213\213\0\316\316\0\352\352\0\352\352\0\213\213\0\316" - "\316\0\352\352\0\352\352\0\213\213\0\316\316\0\352\352\0\352\352\0\213\213" - "\0\316\316\0\352\352\0\352\352\0\213\213\0\316\316\0\352\352\0\352\352\0" - "\213\213\0\316\316\0\352\352\0\352\352\0\214\214\0\324\324\0\336\336\0\336" - "\336\0\331\331\0\310\310\0\343\343\0\343\343\0\325\325\0\217\217\0\254\254" - "\0\254\254\0\207\207\0aa\0\240\240\0\240\240\0<<\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\240\240\0aa" - "\0\225\225\0\304\304\0\304\304\0\205\205\0\276\276\0\343\343\0\340\340\0" - "\222\222\0\333\333\0\352\352\0\351\351\0\226\226\0\347\347\0\362\362\0\333" - "\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361" - "\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0" - "\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351" - "\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230" - "\0\351\351\0\361\361\0\333\333\0\230\230\0\362\362\0\351\351\0\323\323\0" - "\366\366\0\336\336\0\351\351\0\304\304\0\351\351\0\343\343\0\304\304\0\217" - "\217\0\333\333\0\254\254\0\266\266\0aa\0\240\240\0\240\240\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0aa" - "\0\305\305\0\225\225\0\304\304\0ww\0\205\205\0ss\0\211\211\0RR\0VV\0PP\0" - "VV\0""33\0XX\0UU\0YY\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0" - "XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0" - "XX\0""66\0UU\0UU\0XX\0""66\0UU\0YY\0UU\0UU\0MM\0QQ\0UU\0UU\0ww\0\211\211" - "\0ww\0||\0\217\217\0\254\254\0\266\266\0\305\305\0aa\0\240\240\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0aa\0\305" - "\305\0\305\305\0\225\225\0UU\0\222\222\0\366\366\0\340\340\0tt\0\231\231" - "\0\375\375\0\364\364\0\203\203\0\231\231\0\331\331\0\326\326\0\203\203\0" - "\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203" - "\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324" - "\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0" - "\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331" - "\331\0\324\324\0\203\203\0\231\231\0\331\331\0\326\326\0\231\231\0\231\231" - "\0\331\331\0\324\324\0\373\373\0\375\375\0\300\300\0\263\263\0\361\361\0" - "\366\366\0\222\222\0mm\0\266\266\0\305\305\0\305\305\0aa\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0<<\0\305\305\0" - "\305\305\0``\0\214\214\0\321\321\0\321\321\0rr\0\277\277\0\346\346\0\346" - "\346\0\206\206\0\324\324\0\353\353\0\353\353\0\215\215\0\316\316\0\353\353" - "\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0" - "\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316" - "\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213" - "\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0" - "\213\213\0\316\316\0\353\353\0\353\353\0\215\215\0\324\324\0\337\337\0\337" - "\337\0\331\331\0\312\312\0\346\346\0\346\346\0\330\330\0\224\224\0\271\271" - "\0\271\271\0\217\217\0nn\0\305\305\0\305\305\0<<\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\305\305\0ww" - "\0\225\225\0\304\304\0\314\314\0\222\222\0\277\277\0\343\343\0\342\342\0" - "\226\226\0\333\333\0\352\352\0\351\351\0\227\227\0\350\350\0\362\362\0\333" - "\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361" - "\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0" - "\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351" - "\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230" - "\0\351\351\0\361\361\0\333\333\0\230\230\0\362\362\0\351\351\0\323\323\0" - "\370\370\0\336\336\0\352\352\0\306\306\0\354\354\0\344\344\0\305\305\0\227" - "\227\0\343\343\0\254\254\0\266\266\0ww\0\305\305\0\240\240\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0aa" - "\0\333\333\0\236\236\0\304\304\0ww\0\210\210\0tt\0\211\211\0RR\0VV\0PP\0" - "VV\0""33\0XX\0UU\0YY\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0" - "XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0" - "XX\0""66\0UU\0UU\0XX\0""66\0UU\0YY\0UU\0UU\0MM\0QQ\0UU\0UU\0ww\0\211\211" - "\0ww\0}}\0\217\217\0\254\254\0\276\276\0\333\333\0aa\0\240\240\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0aa\0\305" - "\305\0\305\305\0\236\236\0XX\0\222\222\0\366\366\0\341\341\0tt\0\231\231" - "\0\375\375\0\364\364\0\203\203\0\231\231\0\331\331\0\326\326\0\203\203\0" - "\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203" - "\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324" - "\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0" - "\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331" - "\331\0\324\324\0\203\203\0\231\231\0\331\331\0\326\326\0\231\231\0\231\231" - "\0\331\331\0\324\324\0\373\373\0\375\375\0\300\300\0\263\263\0\361\361\0" - "\366\366\0\222\222\0pp\0\276\276\0\305\305\0\305\305\0aa\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0<<\0\305\305\0" - "\305\305\0``\0\217\217\0\324\324\0\324\324\0rr\0\300\300\0\347\347\0\347" - "\347\0\206\206\0\324\324\0\353\353\0\353\353\0\215\215\0\316\316\0\353\353" - "\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0" - "\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316" - "\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213" - "\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0" - "\213\213\0\316\316\0\353\353\0\353\353\0\215\215\0\324\324\0\337\337\0\337" - "\337\0\332\332\0\312\312\0\347\347\0\347\347\0\330\330\0\224\224\0\274\274" - "\0\274\274\0\222\222\0nn\0\305\305\0\305\305\0<<\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\305\305\0ww" - "\0\225\225\0\304\304\0\314\314\0\225\225\0\300\300\0\344\344\0\342\342\0" - "\226\226\0\333\333\0\352\352\0\351\351\0\227\227\0\350\350\0\362\362\0\333" - "\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361" - "\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0" - "\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351" - "\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230" - "\0\351\351\0\361\361\0\333\333\0\230\230\0\362\362\0\351\351\0\323\323\0" - "\370\370\0\337\337\0\352\352\0\306\306\0\355\355\0\345\345\0\306\306\0\231" - "\231\0\343\343\0\254\254\0\266\266\0ww\0\305\305\0\240\240\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0aa" - "\0\333\333\0\236\236\0\304\304\0ww\0\210\210\0tt\0\211\211\0RR\0VV\0PP\0" - "VV\0""33\0XX\0UU\0YY\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0" - "XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0" - "XX\0""66\0UU\0UU\0XX\0""66\0UU\0YY\0UU\0UU\0MM\0QQ\0UU\0UU\0ww\0\211\211" - "\0ww\0}}\0\217\217\0\254\254\0\276\276\0\333\333\0aa\0\240\240\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0aa\0\305" - "\305\0\305\305\0\236\236\0XX\0\222\222\0\366\366\0\341\341\0tt\0\231\231" - "\0\375\375\0\364\364\0\203\203\0\231\231\0\331\331\0\326\326\0\203\203\0" - "\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203" - "\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324" - "\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0" - "\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331" - "\331\0\324\324\0\203\203\0\231\231\0\331\331\0\326\326\0\231\231\0\231\231" - "\0\331\331\0\324\324\0\373\373\0\375\375\0\300\300\0\263\263\0\361\361\0" - "\366\366\0\222\222\0pp\0\276\276\0\305\305\0\305\305\0aa\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0<<\0\305\305\0" - "\305\305\0``\0\217\217\0\324\324\0\324\324\0rr\0\300\300\0\347\347\0\347" - "\347\0\206\206\0\324\324\0\353\353\0\353\353\0\215\215\0\316\316\0\353\353" - "\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0" - "\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316" - "\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213" - "\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0" - "\213\213\0\316\316\0\353\353\0\353\353\0\215\215\0\324\324\0\337\337\0\337" - "\337\0\332\332\0\312\312\0\347\347\0\347\347\0\330\330\0\224\224\0\274\274" - "\0\274\274\0\222\222\0nn\0\305\305\0\305\305\0<<\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\305\305\0ww" - "\0\225\225\0\304\304\0\314\314\0\225\225\0\300\300\0\344\344\0\342\342\0" - "\226\226\0\333\333\0\352\352\0\351\351\0\227\227\0\350\350\0\362\362\0\333" - "\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361" - "\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0" - "\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351" - "\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230" - "\0\351\351\0\361\361\0\333\333\0\230\230\0\362\362\0\351\351\0\323\323\0" - "\370\370\0\337\337\0\352\352\0\306\306\0\355\355\0\345\345\0\306\306\0\231" - "\231\0\343\343\0\254\254\0\266\266\0ww\0\305\305\0\240\240\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0aa" - "\0\333\333\0\236\236\0\304\304\0ww\0\210\210\0tt\0\211\211\0RR\0VV\0PP\0" - "VV\0""33\0XX\0UU\0YY\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0" - "XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0" - "XX\0""66\0UU\0UU\0XX\0""66\0UU\0YY\0UU\0UU\0MM\0QQ\0UU\0UU\0ww\0\211\211" - "\0ww\0}}\0\217\217\0\254\254\0\276\276\0\333\333\0aa\0\240\240\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0aa\0\305" - "\305\0\305\305\0\236\236\0XX\0\222\222\0\366\366\0\341\341\0tt\0\231\231" - "\0\375\375\0\364\364\0\203\203\0\231\231\0\331\331\0\326\326\0\203\203\0" - "\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203" - "\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324" - "\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0" - "\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331" - "\331\0\324\324\0\203\203\0\231\231\0\331\331\0\326\326\0\231\231\0\231\231" - "\0\331\331\0\324\324\0\373\373\0\375\375\0\300\300\0\263\263\0\361\361\0" - "\366\366\0\222\222\0pp\0\276\276\0\305\305\0\305\305\0aa\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0<<\0\305\305\0" - "\305\305\0``\0\217\217\0\324\324\0\324\324\0rr\0\300\300\0\347\347\0\347" - "\347\0\206\206\0\324\324\0\353\353\0\353\353\0\215\215\0\316\316\0\353\353" - "\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0" - "\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316" - "\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213" - "\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0" - "\213\213\0\316\316\0\353\353\0\353\353\0\215\215\0\324\324\0\337\337\0\337" - "\337\0\332\332\0\312\312\0\347\347\0\347\347\0\330\330\0\224\224\0\274\274" - "\0\274\274\0\222\222\0nn\0\305\305\0\305\305\0<<\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\305\305\0ww" - "\0\225\225\0\304\304\0\314\314\0\225\225\0\300\300\0\344\344\0\342\342\0" - "\226\226\0\333\333\0\352\352\0\351\351\0\227\227\0\350\350\0\362\362\0\333" - "\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361" - "\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0" - "\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351" - "\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230" - "\0\351\351\0\361\361\0\333\333\0\230\230\0\362\362\0\351\351\0\323\323\0" - "\370\370\0\337\337\0\352\352\0\306\306\0\355\355\0\345\345\0\306\306\0\231" - "\231\0\343\343\0\254\254\0\266\266\0ww\0\305\305\0\240\240\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0aa" - "\0\333\333\0\236\236\0\304\304\0ww\0\210\210\0tt\0\211\211\0RR\0VV\0PP\0" - "VV\0""33\0XX\0UU\0YY\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0" - "XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0XX\0""66\0UU\0UU\0" - "XX\0""66\0UU\0UU\0XX\0""66\0UU\0YY\0UU\0UU\0MM\0QQ\0UU\0UU\0ww\0\211\211" - "\0ww\0}}\0\217\217\0\254\254\0\276\276\0\333\333\0aa\0\240\240\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0aa\0\305" - "\305\0\305\305\0\236\236\0XX\0\222\222\0\366\366\0\341\341\0tt\0\231\231" - "\0\375\375\0\364\364\0\203\203\0\231\231\0\331\331\0\326\326\0\203\203\0" - "\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203" - "\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324" - "\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0" - "\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331" - "\331\0\324\324\0\203\203\0\231\231\0\331\331\0\326\326\0\231\231\0\231\231" - "\0\331\331\0\324\324\0\373\373\0\375\375\0\300\300\0\263\263\0\361\361\0" - "\366\366\0\222\222\0pp\0\276\276\0\305\305\0\305\305\0aa\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0<<\0\305\305\0" - "\305\305\0``\0\217\217\0\324\324\0\324\324\0rr\0\300\300\0\347\347\0\347" - "\347\0\206\206\0\324\324\0\353\353\0\353\353\0\215\215\0\316\316\0\353\353" - "\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0" - "\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316" - "\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213" - "\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0" - "\213\213\0\316\316\0\353\353\0\353\353\0\215\215\0\324\324\0\337\337\0\337" - "\337\0\332\332\0\312\312\0\347\347\0\347\347\0\330\330\0\224\224\0\274\274" - "\0\274\274\0\222\222\0nn\0\305\305\0\305\305\0<<\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\305\305\0ww" - "\0\225\225\0\304\304\0\314\314\0\225\225\0\300\300\0\344\344\0\342\342\0" - "\226\226\0\333\333\0\352\352\0\351\351\0\227\227\0\350\350\0\362\362\0\333" - "\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361" - "\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0" - "\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351" - "\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230" - "\0\351\351\0\361\361\0\333\333\0\230\230\0\362\362\0\351\351\0\323\323\0" - "\370\370\0\337\337\0\352\352\0\306\306\0\355\355\0\345\345\0\306\306\0\231" - "\231\0\343\343\0\254\254\0\266\266\0ww\0\305\305\0\240\240\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0aa" - "\0\333\333\0\236\236\0\304\304\0ww\0\340\340\0\300\300\0\343\343\0\210\210" - "\0\354\354\0\333\333\0\352\352\0\215\215\0\361\361\0\350\350\0\362\362\0" - "\223\223\0\351\351\0\351\351\0\361\361\0\223\223\0\351\351\0\351\351\0\361" - "\361\0\223\223\0\351\351\0\351\351\0\361\361\0\223\223\0\351\351\0\351\351" - "\0\361\361\0\223\223\0\351\351\0\351\351\0\361\361\0\223\223\0\351\351\0" - "\351\351\0\361\361\0\223\223\0\351\351\0\351\351\0\361\361\0\223\223\0\351" - "\351\0\351\351\0\361\361\0\223\223\0\351\351\0\362\362\0\351\351\0\351\351" - "\0\323\323\0\336\336\0\351\351\0\351\351\0\304\304\0\343\343\0\305\305\0" - "\317\317\0\217\217\0\254\254\0\276\276\0\333\333\0aa\0\240\240\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0aa\0\305" - "\305\0\305\305\0\236\236\0\222\222\0\361\361\0\361\361\0\316\316\0\230\230" - "\0\373\373\0\373\373\0\344\344\0\231\231\0\375\375\0\375\375\0\357\357\0" - "\231\231\0\375\375\0\375\375\0\347\347\0\231\231\0\375\375\0\375\375\0\347" - "\347\0\231\231\0\375\375\0\375\375\0\347\347\0\231\231\0\375\375\0\375\375" - "\0\347\347\0\231\231\0\375\375\0\375\375\0\347\347\0\231\231\0\375\375\0" - "\375\375\0\347\347\0\231\231\0\375\375\0\375\375\0\347\347\0\231\231\0\375" - "\375\0\375\375\0\347\347\0\231\231\0\375\375\0\375\375\0\360\360\0\373\373" - "\0\375\375\0\375\375\0\347\347\0\367\367\0\373\373\0\373\373\0\326\326\0" - "\351\351\0\361\361\0\361\361\0\271\271\0\276\276\0\305\305\0\305\305\0aa" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0<<\0\305\305\0\305\305\0\236\236\0HH\0\271\271\0\271\271\0\224\224\0VV" - "\0\277\277\0\277\277\0\251\251\0DD\0\252\252\0\252\252\0\235\235\0FF\0\253" - "\253\0\253\253\0\224\224\0EE\0\253\253\0\253\253\0\224\224\0EE\0\253\253" - "\0\253\253\0\224\224\0EE\0\253\253\0\253\253\0\224\224\0EE\0\253\253\0\253" - "\253\0\224\224\0EE\0\253\253\0\253\253\0\224\224\0EE\0\253\253\0\253\253" - "\0\224\224\0EE\0\253\253\0\253\253\0\224\224\0EE\0\253\253\0\253\253\0\235" - "\235\0rr\0uu\0uu\0^^\0\272\272\0\277\277\0\277\277\0\230\230\0\205\205\0" - "\222\222\0\222\222\0MM\0\266\266\0\305\305\0\305\305\0<<\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\305" - "\305\0\305\305\0RR\0\236\236\0\254\254\0\361\361\0VV\0\267\267\0\263\263" - "\0\356\356\0ee\0\247\247\0\244\244\0\356\356\0^^\0\251\251\0\247\247\0\365" - "\365\0bb\0\242\242\0\247\247\0\365\365\0bb\0\242\242\0\247\247\0\365\365" - "\0bb\0\242\242\0\247\247\0\365\365\0bb\0\242\242\0\247\247\0\365\365\0bb" - "\0\242\242\0\247\247\0\365\365\0bb\0\242\242\0\247\247\0\365\365\0bb\0\242" - "\242\0\247\247\0\365\365\0bb\0\242\242\0\247\247\0\365\365\0\252\252\0ee" - "\0jj\0\345\345\0tt\0\246\246\0\251\251\0\321\321\0\272\272\0ff\0\222\222" - "\0\322\322\0ww\0\210\210\0\305\305\0\305\305\0\240\240\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\240\240" - "\0\305\305\0``\0\236\236\0\236\236\0\254\254\0VV\0\264\264\0\254\254\0\261" - "\261\0dd\0\246\246\0\240\240\0\243\243\0^^\0\251\251\0\246\246\0\246\246" - "\0bb\0\242\242\0\246\246\0\246\246\0bb\0\242\242\0\246\246\0\246\246\0bb" - "\0\242\242\0\246\246\0\246\246\0bb\0\242\242\0\246\246\0\246\246\0bb\0\242" - "\242\0\246\246\0\246\246\0bb\0\242\242\0\246\246\0\246\246\0bb\0\242\242" - "\0\246\246\0\246\246\0bb\0\242\242\0\246\246\0\246\246\0\251\251\0dd\0hh" - "\0hh\0pp\0\243\243\0\240\240\0\236\236\0\264\264\0cc\0\177\177\0ww\0ww\0" - "\225\225\0\305\305\0\240\240\0\240\240\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\240\240\0\240\240\0``" - "\0\351\351\0\333\333\0\333\333\0||\0\366\366\0\361\361\0\361\361\0\211\211" - "\0\373\373\0\371\371\0\371\371\0\221\221\0\375\375\0\374\374\0\374\374\0" - "\224\224\0\365\365\0\374\374\0\374\374\0\224\224\0\365\365\0\374\374\0\374" - "\374\0\224\224\0\365\365\0\374\374\0\374\374\0\224\224\0\365\365\0\374\374" - "\0\374\374\0\224\224\0\365\365\0\374\374\0\374\374\0\224\224\0\365\365\0" - "\374\374\0\374\374\0\224\224\0\365\365\0\374\374\0\374\374\0\224\224\0\365" - "\365\0\374\374\0\374\374\0\375\375\0\356\356\0\371\371\0\371\371\0\372\372" - "\0\340\340\0\361\361\0\361\361\0\364\364\0\307\307\0\333\333\0\333\333\0" - "\351\351\0\225\225\0\240\240\0\240\240\0\240\240\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\240\240\0\240\240" - "\0aa\0\304\304\0\351\351\0\351\351\0\205\205\0\340\340\0\366\366\0\366\366" - "\0\222\222\0\355\355\0\373\373\0\373\373\0\227\227\0\364\364\0\375\375\0" - "\375\375\0\230\230\0\360\360\0\375\375\0\375\375\0\230\230\0\360\360\0\375" - "\375\0\375\375\0\230\230\0\360\360\0\375\375\0\375\375\0\230\230\0\360\360" - "\0\375\375\0\375\375\0\230\230\0\360\360\0\375\375\0\375\375\0\230\230\0" - "\360\360\0\375\375\0\375\375\0\230\230\0\360\360\0\375\375\0\375\375\0\230" - "\230\0\360\360\0\375\375\0\375\375\0\373\373\0\356\356\0\373\373\0\373\373" - "\0\367\367\0\340\340\0\364\364\0\364\364\0\354\354\0\304\304\0\351\351\0" - "\351\351\0\322\322\0\210\210\0\240\240\0\240\240\0dd\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\240\240\0\240" - "\240\0<<\0\240\240\0\305\305\0\351\351\0ww\0\320\320\0\301\301\0\324\324" - "\0\211\211\0\345\345\0\316\316\0\324\324\0\217\217\0\356\356\0\323\323\0" - "\326\326\0\223\223\0\354\354\0\323\323\0\326\326\0\223\223\0\354\354\0\323" - "\323\0\326\326\0\223\223\0\354\354\0\323\323\0\326\326\0\223\223\0\354\354" - "\0\323\323\0\326\326\0\223\223\0\354\354\0\323\323\0\326\326\0\223\223\0" - "\354\354\0\323\323\0\326\326\0\223\223\0\354\354\0\323\323\0\326\326\0\223" - "\223\0\354\354\0\323\323\0\326\326\0\362\362\0\344\344\0\261\261\0\272\272" - "\0\364\364\0\340\340\0\225\225\0\205\205\0\340\340\0\276\276\0\351\351\0" - "\266\266\0\240\240\0dd\0\240\240\0\240\240\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\240\240\0aa\0\240" - "\240\0\240\240\0\305\305\0ww\0\305\305\0\240\240\0\266\266\0\205\205\0\333" - "\333\0\266\266\0\304\304\0\215\215\0\352\352\0\305\305\0\314\314\0\222\222" - "\0\352\352\0\305\305\0\314\314\0\222\222\0\352\352\0\305\305\0\314\314\0" - "\222\222\0\352\352\0\305\305\0\314\314\0\222\222\0\352\352\0\305\305\0\314" - "\314\0\222\222\0\352\352\0\305\305\0\314\314\0\222\222\0\352\352\0\305\305" - "\0\314\314\0\222\222\0\352\352\0\305\305\0\314\314\0\222\222\0\352\352\0" - "\305\305\0\314\314\0\361\361\0\335\335\0\242\242\0\236\236\0\333\333\0\312" - "\312\0ii\0aa\0\305\305\0\255\255\0\266\266\0\240\240\0\240\240\0\210\210" - "\0\240\240\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0aa\0\305\305\0\240\240\0\240\240\0ww\0\333" - "\333\0\305\305\0\305\305\0\205\205\0\351\351\0\333\333\0\333\333\0\217\217" - "\0\363\363\0\351\351\0\351\351\0\223\223\0\357\357\0\351\351\0\351\351\0" - "\223\223\0\357\357\0\351\351\0\351\351\0\223\223\0\357\357\0\351\351\0\351" - "\351\0\223\223\0\357\357\0\351\351\0\351\351\0\223\223\0\357\357\0\351\351" - "\0\351\351\0\223\223\0\357\357\0\351\351\0\351\351\0\223\223\0\357\357\0" - "\351\351\0\351\351\0\223\223\0\357\357\0\351\351\0\351\351\0\363\363\0\345" - "\345\0\333\333\0\333\333\0\340\340\0\312\312\0\305\305\0\305\305\0\322\322" - "\0\255\255\0\240\240\0\240\240\0\305\305\0\210\210\0dd\0dd\0dd\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd" - "\0dd\0dd\0aa\0\305\305\0\305\305\0\240\240\0ww\0\333\333\0\333\333\0\305" - "\305\0\205\205\0\355\355\0\355\355\0\336\336\0\215\215\0\364\364\0\364\364" - "\0\335\335\0\215\215\0\364\364\0\364\364\0\335\335\0\215\215\0\364\364\0" - "\364\364\0\335\335\0\215\215\0\364\364\0\364\364\0\335\335\0\215\215\0\364" - "\364\0\364\364\0\335\335\0\215\215\0\364\364\0\364\364\0\335\335\0\215\215" - "\0\364\364\0\364\364\0\335\335\0\215\215\0\364\364\0\364\364\0\335\335\0" - "\215\215\0\364\364\0\364\364\0\335\335\0\351\351\0\355\355\0\355\355\0\312" - "\312\0\305\305\0\322\322\0\322\322\0\255\255\0\240\240\0\305\305\0\305\305" - "\0\210\210\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0\305\305\0aa" - "\0""11\0\225\225\0\351\351\0\205\205\0HH\0\254\254\0\333\333\0ww\0BB\0\264" - "\264\0\340\340\0nn\0BB\0\264\264\0\340\340\0nn\0BB\0\264\264\0\340\340\0" - "nn\0BB\0\264\264\0\340\340\0nn\0BB\0\264\264\0\340\340\0nn\0BB\0\264\264" - "\0\340\340\0nn\0BB\0\264\264\0\340\340\0nn\0BB\0\264\264\0\340\340\0nn\0" - "BB\0\264\264\0\340\340\0nn\0nn\0\205\205\0\314\314\0\266\266\0\304\304\0" - "\351\351\0\236\236\0yy\0\210\210\0\305\305\0<<\0\0\0\0\0\0\0dd\0dd\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0" - "\0dd\0dd\0\25\25\0\14\14\0dd\0dd\0\25\25\0\14\14\0dd\0dd\0\25\25\0\14\14" - "\0dd\0dd\0\25\25\0\14\14\0dd\0dd\0\25\25\0\14\14\0dd\0dd\0\25\25\0\14\14" - "\0dd\0dd\0\25\25\0\14\14\0dd\0dd\0\25\25\0\14\14\0dd\0dd\0\25\25\0\14\14" - "\0dd\0dd\0\25\25\0\25\25\0\0\0\0\0\0\0$$\0$$\0\0\0\0\0\0\0<<\0<<\0\0\0\0" - "\0\0\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0" - "\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0yy\0yy\0\0\0\0\0\0\0yy\0yy\0\0\0\0\0\0\0" - "yy\0yy\0\0\0\0\0\0\0yy\0yy\0\0\0\0\0\0\0yy\0yy\0\0\0\0\0\0\0yy\0yy\0\0\0" - "\0\0\0\0yy\0yy\0\0\0\0\0\0\0yy\0yy\0\0\0\0\0\0\0yy\0yy\0\0\0\0\0\0\0yy\0" - "yy\0\0\0\0\0\0\0$$\0$$\0\0\0\0\0\0\0<<\0<<\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0\0\0\0dd\0dd\0dd\0\0\0\0dd" - "\0\210\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210\210" - "\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210" - "\0\25\25\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0\25\25" - "\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210" - "\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0$$\0\0\0\0<<\0<<\0<<\0\0" - "\0\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0dd\0dd\0<<\0<<\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0" - "aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240" - "\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240" - "\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0" - "aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0\240\240\0\240\240" - "\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", + 80, + 60, + 3, + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0<<\0<<\0\240\240\0\240\240\0aa\0aa\0\240" + "\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0" + "aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240" + "\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0" + "aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240" + "\240\0\240\240\0\240\240\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0<<\0\240\240\0\240\240\0\240\240" + "\0aa\0\305\305\0\305\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww" + "\0\305\305\0\305\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww\0\305" + "\305\0\305\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww\0\305\305" + "\0\305\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww\0\305\305\0\305" + "\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww\0\305\305\0\305\305" + "\0\305\305\0\305\305\0\240\240\0\240\240\0\240\240\0\240\240\0dd\0dd\0dd" + "\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0<<\0\240\240" + "\0\240\240\0\240\240\0aa\0\305\305\0\305\305\0\305\305\0ww\0\333\333\0\333" + "\333\0\305\305\0ww\0\333\333\0\333\333\0\305\305\0ww\0\333\333\0\333\333" + "\0\305\305\0ww\0\333\333\0\333\333\0\305\305\0ww\0\333\333\0\333\333\0\305" + "\305\0ww\0\333\333\0\333\333\0\305\305\0ww\0\333\333\0\333\333\0\305\305" + "\0ww\0\333\333\0\333\333\0\305\305\0ww\0\333\333\0\333\333\0\305\305\0ww" + "\0\333\333\0\333\333\0\305\305\0\305\305\0\305\305\0\305\305\0\240\240\0" + "\240\240\0\240\240\0\240\240\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0dd\0dd\0dd\0<<\0aa\0aa\0aa\0::\0HH\0HH\0HH\0++\0PP\0PP\0PP\0" + "00\0PP" + "\0PP\0PP\0" + "00\0PP\0PP\0PP\0" + "00\0PP\0PP\0PP\0" + "00\0PP\0PP\0PP\0" + "00\0PP" + "\0PP\0PP\0" + "00\0PP\0PP\0PP\0" + "00\0PP\0PP\0PP\0" + "00\0PP\0PP\0PP\0" + "00\0PP" + "\0PP\0PP\0PP\0HH\0HH\0HH\0HH\0aa\0aa\0aa\0aa\0dd\0dd\0dd\0dd\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0dd\0dd\0dd\0$$\0aa\0\305\305\0\305\305\0``\0\205\205\0\351\351\0" + "\351\351\0||\0\222\222\0\321\321\0\321\321\0\177\177\0\225\225\0\324\324" + "\0\321\321\0\177\177\0\225\225\0\324\324\0\321\321\0\177\177\0\225\225\0" + "\324\324\0\321\321\0\177\177\0\225\225\0\324\324\0\321\321\0\177\177\0\225" + "\225\0\324\324\0\321\321\0\177\177\0\225\225\0\324\324\0\321\321\0\177\177" + "\0\225\225\0\324\324\0\321\321\0\177\177\0\225\225\0\324\324\0\321\321\0" + "\177\177\0\225\225\0\324\324\0\321\321\0\222\222\0\222\222\0\321\321\0\314" + "\314\0\351\351\0\351\351\0\254\254\0\236\236\0\305\305\0\305\305\0aa\0<<" + "\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0<<\0dd\0\240\240\0\240\240\0aa\0\255\255" + "\0\322\322\0\322\322\0\177\177\0\315\315\0\343\343\0\343\343\0\211\211\0" + "\313\313\0\346\346\0\346\346\0\211\211\0\313\313\0\346\346\0\346\346\0\211" + "\211\0\313\313\0\346\346\0\346\346\0\211\211\0\313\313\0\346\346\0\346\346" + "\0\211\211\0\313\313\0\346\346\0\346\346\0\211\211\0\313\313\0\346\346\0" + "\346\346\0\211\211\0\313\313\0\346\346\0\346\346\0\211\211\0\313\313\0\346" + "\346\0\346\346\0\211\211\0\313\313\0\346\346\0\346\346\0\211\211\0\320\320" + "\0\327\327\0\327\327\0\322\322\0\276\276\0\322\322\0\322\322\0\305\305\0" + "yy\0\210\210\0\210\210\0dd\0<<\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0<<\0\210\210\0\240" + "\240\0\240\240\0aa\0\266\266\0\322\322\0\322\322\0\205\205\0\327\327\0\343" + "\343\0\343\343\0\215\215\0\346\346\0\357\357\0\331\331\0\222\222\0\347\347" + "\0\357\357\0\331\331\0\222\222\0\347\347\0\357\357\0\331\331\0\222\222\0" + "\347\347\0\357\357\0\331\331\0\222\222\0\347\347\0\357\357\0\331\331\0\222" + "\222\0\347\347\0\357\357\0\331\331\0\222\222\0\347\347\0\357\357\0\331\331" + "\0\222\222\0\347\347\0\357\357\0\331\331\0\222\222\0\347\347\0\357\357\0" + "\331\331\0\222\222\0\357\357\0\346\346\0\320\320\0\351\351\0\327\327\0\343" + "\343\0\276\276\0\333\333\0\322\322\0\266\266\0yy\0\240\240\0\210\210\0\240" + "\240\0<<\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0dd\0<<\0\240\240\0\210\210\0\240\240\0aa\0ww\0nn\0\177" + "\177\0MM\0SS\0OO\0SS\0" + "22\0WW\0TT\0XX\0" + "55\0UU\0UU\0XX\0" + "55\0UU\0UU\0" + "XX\0" + "55\0UU\0UU\0XX\0" + "55\0UU\0UU\0XX\0" + "55\0UU\0UU\0XX\0" + "55\0UU\0UU\0" + "XX\0" + "55\0UU\0UU\0XX\0" + "55\0UU\0UU\0XX\0" + "55\0UU\0XX\0TT\0TT\0LL\0OO\0SS" + "\0SS\0ss\0\177\177\0nn\0nn\0yy\0\210\210\0\240\240\0\240\240\0<<\0dd\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0<<" + "\0\240\240\0\240\240\0\210\210\0HH\0\205\205\0\351\351\0\333\333\0pp\0\225" + "\225\0\371\371\0\363\363\0\202\202\0\231\231\0\330\330\0\325\325\0\203\203" + "\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0" + "\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324" + "\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331" + "\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0" + "\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\325\325\0\231\231\0\231" + "\231\0\330\330\0\323\323\0\371\371\0\371\371\0\274\274\0\257\257\0\351\351" + "\0\351\351\0\205\205\0``\0\240\240\0\240\240\0\240\240\0<<\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0<<\0\240\240" + "\0\240\240\0RR\0\207\207\0\304\304\0\304\304\0nn\0\275\275\0\343\343\0\343" + "\343\0\205\205\0\324\324\0\352\352\0\352\352\0\214\214\0\316\316\0\352\352" + "\0\352\352\0\213\213\0\316\316\0\352\352\0\352\352\0\213\213\0\316\316\0" + "\352\352\0\352\352\0\213\213\0\316\316\0\352\352\0\352\352\0\213\213\0\316" + "\316\0\352\352\0\352\352\0\213\213\0\316\316\0\352\352\0\352\352\0\213\213" + "\0\316\316\0\352\352\0\352\352\0\213\213\0\316\316\0\352\352\0\352\352\0" + "\213\213\0\316\316\0\352\352\0\352\352\0\214\214\0\324\324\0\336\336\0\336" + "\336\0\331\331\0\310\310\0\343\343\0\343\343\0\325\325\0\217\217\0\254\254" + "\0\254\254\0\207\207\0aa\0\240\240\0\240\240\0<<\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\240\240\0aa" + "\0\225\225\0\304\304\0\304\304\0\205\205\0\276\276\0\343\343\0\340\340\0" + "\222\222\0\333\333\0\352\352\0\351\351\0\226\226\0\347\347\0\362\362\0\333" + "\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361" + "\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0" + "\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351" + "\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230" + "\0\351\351\0\361\361\0\333\333\0\230\230\0\362\362\0\351\351\0\323\323\0" + "\366\366\0\336\336\0\351\351\0\304\304\0\351\351\0\343\343\0\304\304\0\217" + "\217\0\333\333\0\254\254\0\266\266\0aa\0\240\240\0\240\240\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0aa" + "\0\305\305\0\225\225\0\304\304\0ww\0\205\205\0ss\0\211\211\0RR\0VV\0PP\0" + "VV\0" + "33\0XX\0UU\0YY\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0" + "XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0" + "XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0YY\0UU\0UU\0MM\0QQ\0UU\0UU\0ww\0\211\211" + "\0ww\0||\0\217\217\0\254\254\0\266\266\0\305\305\0aa\0\240\240\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0aa\0\305" + "\305\0\305\305\0\225\225\0UU\0\222\222\0\366\366\0\340\340\0tt\0\231\231" + "\0\375\375\0\364\364\0\203\203\0\231\231\0\331\331\0\326\326\0\203\203\0" + "\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203" + "\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324" + "\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0" + "\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331" + "\331\0\324\324\0\203\203\0\231\231\0\331\331\0\326\326\0\231\231\0\231\231" + "\0\331\331\0\324\324\0\373\373\0\375\375\0\300\300\0\263\263\0\361\361\0" + "\366\366\0\222\222\0mm\0\266\266\0\305\305\0\305\305\0aa\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0<<\0\305\305\0" + "\305\305\0``\0\214\214\0\321\321\0\321\321\0rr\0\277\277\0\346\346\0\346" + "\346\0\206\206\0\324\324\0\353\353\0\353\353\0\215\215\0\316\316\0\353\353" + "\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0" + "\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316" + "\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213" + "\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0" + "\213\213\0\316\316\0\353\353\0\353\353\0\215\215\0\324\324\0\337\337\0\337" + "\337\0\331\331\0\312\312\0\346\346\0\346\346\0\330\330\0\224\224\0\271\271" + "\0\271\271\0\217\217\0nn\0\305\305\0\305\305\0<<\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\305\305\0ww" + "\0\225\225\0\304\304\0\314\314\0\222\222\0\277\277\0\343\343\0\342\342\0" + "\226\226\0\333\333\0\352\352\0\351\351\0\227\227\0\350\350\0\362\362\0\333" + "\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361" + "\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0" + "\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351" + "\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230" + "\0\351\351\0\361\361\0\333\333\0\230\230\0\362\362\0\351\351\0\323\323\0" + "\370\370\0\336\336\0\352\352\0\306\306\0\354\354\0\344\344\0\305\305\0\227" + "\227\0\343\343\0\254\254\0\266\266\0ww\0\305\305\0\240\240\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0aa" + "\0\333\333\0\236\236\0\304\304\0ww\0\210\210\0tt\0\211\211\0RR\0VV\0PP\0" + "VV\0" + "33\0XX\0UU\0YY\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0" + "XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0" + "XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0YY\0UU\0UU\0MM\0QQ\0UU\0UU\0ww\0\211\211" + "\0ww\0}}\0\217\217\0\254\254\0\276\276\0\333\333\0aa\0\240\240\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0aa\0\305" + "\305\0\305\305\0\236\236\0XX\0\222\222\0\366\366\0\341\341\0tt\0\231\231" + "\0\375\375\0\364\364\0\203\203\0\231\231\0\331\331\0\326\326\0\203\203\0" + "\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203" + "\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324" + "\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0" + "\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331" + "\331\0\324\324\0\203\203\0\231\231\0\331\331\0\326\326\0\231\231\0\231\231" + "\0\331\331\0\324\324\0\373\373\0\375\375\0\300\300\0\263\263\0\361\361\0" + "\366\366\0\222\222\0pp\0\276\276\0\305\305\0\305\305\0aa\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0<<\0\305\305\0" + "\305\305\0``\0\217\217\0\324\324\0\324\324\0rr\0\300\300\0\347\347\0\347" + "\347\0\206\206\0\324\324\0\353\353\0\353\353\0\215\215\0\316\316\0\353\353" + "\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0" + "\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316" + "\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213" + "\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0" + "\213\213\0\316\316\0\353\353\0\353\353\0\215\215\0\324\324\0\337\337\0\337" + "\337\0\332\332\0\312\312\0\347\347\0\347\347\0\330\330\0\224\224\0\274\274" + "\0\274\274\0\222\222\0nn\0\305\305\0\305\305\0<<\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\305\305\0ww" + "\0\225\225\0\304\304\0\314\314\0\225\225\0\300\300\0\344\344\0\342\342\0" + "\226\226\0\333\333\0\352\352\0\351\351\0\227\227\0\350\350\0\362\362\0\333" + "\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361" + "\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0" + "\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351" + "\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230" + "\0\351\351\0\361\361\0\333\333\0\230\230\0\362\362\0\351\351\0\323\323\0" + "\370\370\0\337\337\0\352\352\0\306\306\0\355\355\0\345\345\0\306\306\0\231" + "\231\0\343\343\0\254\254\0\266\266\0ww\0\305\305\0\240\240\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0aa" + "\0\333\333\0\236\236\0\304\304\0ww\0\210\210\0tt\0\211\211\0RR\0VV\0PP\0" + "VV\0" + "33\0XX\0UU\0YY\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0" + "XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0" + "XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0YY\0UU\0UU\0MM\0QQ\0UU\0UU\0ww\0\211\211" + "\0ww\0}}\0\217\217\0\254\254\0\276\276\0\333\333\0aa\0\240\240\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0aa\0\305" + "\305\0\305\305\0\236\236\0XX\0\222\222\0\366\366\0\341\341\0tt\0\231\231" + "\0\375\375\0\364\364\0\203\203\0\231\231\0\331\331\0\326\326\0\203\203\0" + "\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203" + "\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324" + "\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0" + "\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331" + "\331\0\324\324\0\203\203\0\231\231\0\331\331\0\326\326\0\231\231\0\231\231" + "\0\331\331\0\324\324\0\373\373\0\375\375\0\300\300\0\263\263\0\361\361\0" + "\366\366\0\222\222\0pp\0\276\276\0\305\305\0\305\305\0aa\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0<<\0\305\305\0" + "\305\305\0``\0\217\217\0\324\324\0\324\324\0rr\0\300\300\0\347\347\0\347" + "\347\0\206\206\0\324\324\0\353\353\0\353\353\0\215\215\0\316\316\0\353\353" + "\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0" + "\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316" + "\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213" + "\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0" + "\213\213\0\316\316\0\353\353\0\353\353\0\215\215\0\324\324\0\337\337\0\337" + "\337\0\332\332\0\312\312\0\347\347\0\347\347\0\330\330\0\224\224\0\274\274" + "\0\274\274\0\222\222\0nn\0\305\305\0\305\305\0<<\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\305\305\0ww" + "\0\225\225\0\304\304\0\314\314\0\225\225\0\300\300\0\344\344\0\342\342\0" + "\226\226\0\333\333\0\352\352\0\351\351\0\227\227\0\350\350\0\362\362\0\333" + "\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361" + "\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0" + "\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351" + "\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230" + "\0\351\351\0\361\361\0\333\333\0\230\230\0\362\362\0\351\351\0\323\323\0" + "\370\370\0\337\337\0\352\352\0\306\306\0\355\355\0\345\345\0\306\306\0\231" + "\231\0\343\343\0\254\254\0\266\266\0ww\0\305\305\0\240\240\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0aa" + "\0\333\333\0\236\236\0\304\304\0ww\0\210\210\0tt\0\211\211\0RR\0VV\0PP\0" + "VV\0" + "33\0XX\0UU\0YY\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0" + "XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0" + "XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0YY\0UU\0UU\0MM\0QQ\0UU\0UU\0ww\0\211\211" + "\0ww\0}}\0\217\217\0\254\254\0\276\276\0\333\333\0aa\0\240\240\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0aa\0\305" + "\305\0\305\305\0\236\236\0XX\0\222\222\0\366\366\0\341\341\0tt\0\231\231" + "\0\375\375\0\364\364\0\203\203\0\231\231\0\331\331\0\326\326\0\203\203\0" + "\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203" + "\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324" + "\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0" + "\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331" + "\331\0\324\324\0\203\203\0\231\231\0\331\331\0\326\326\0\231\231\0\231\231" + "\0\331\331\0\324\324\0\373\373\0\375\375\0\300\300\0\263\263\0\361\361\0" + "\366\366\0\222\222\0pp\0\276\276\0\305\305\0\305\305\0aa\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0<<\0\305\305\0" + "\305\305\0``\0\217\217\0\324\324\0\324\324\0rr\0\300\300\0\347\347\0\347" + "\347\0\206\206\0\324\324\0\353\353\0\353\353\0\215\215\0\316\316\0\353\353" + "\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0" + "\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316" + "\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213" + "\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0" + "\213\213\0\316\316\0\353\353\0\353\353\0\215\215\0\324\324\0\337\337\0\337" + "\337\0\332\332\0\312\312\0\347\347\0\347\347\0\330\330\0\224\224\0\274\274" + "\0\274\274\0\222\222\0nn\0\305\305\0\305\305\0<<\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\305\305\0ww" + "\0\225\225\0\304\304\0\314\314\0\225\225\0\300\300\0\344\344\0\342\342\0" + "\226\226\0\333\333\0\352\352\0\351\351\0\227\227\0\350\350\0\362\362\0\333" + "\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361" + "\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0" + "\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351" + "\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230" + "\0\351\351\0\361\361\0\333\333\0\230\230\0\362\362\0\351\351\0\323\323\0" + "\370\370\0\337\337\0\352\352\0\306\306\0\355\355\0\345\345\0\306\306\0\231" + "\231\0\343\343\0\254\254\0\266\266\0ww\0\305\305\0\240\240\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0aa" + "\0\333\333\0\236\236\0\304\304\0ww\0\210\210\0tt\0\211\211\0RR\0VV\0PP\0" + "VV\0" + "33\0XX\0UU\0YY\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0" + "XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0UU\0" + "XX\0" + "66\0UU\0UU\0XX\0" + "66\0UU\0YY\0UU\0UU\0MM\0QQ\0UU\0UU\0ww\0\211\211" + "\0ww\0}}\0\217\217\0\254\254\0\276\276\0\333\333\0aa\0\240\240\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0aa\0\305" + "\305\0\305\305\0\236\236\0XX\0\222\222\0\366\366\0\341\341\0tt\0\231\231" + "\0\375\375\0\364\364\0\203\203\0\231\231\0\331\331\0\326\326\0\203\203\0" + "\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203" + "\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0\324\324" + "\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331\331\0" + "\324\324\0\203\203\0\231\231\0\331\331\0\324\324\0\203\203\0\231\231\0\331" + "\331\0\324\324\0\203\203\0\231\231\0\331\331\0\326\326\0\231\231\0\231\231" + "\0\331\331\0\324\324\0\373\373\0\375\375\0\300\300\0\263\263\0\361\361\0" + "\366\366\0\222\222\0pp\0\276\276\0\305\305\0\305\305\0aa\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0<<\0\305\305\0" + "\305\305\0``\0\217\217\0\324\324\0\324\324\0rr\0\300\300\0\347\347\0\347" + "\347\0\206\206\0\324\324\0\353\353\0\353\353\0\215\215\0\316\316\0\353\353" + "\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0" + "\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213\0\316" + "\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0\213\213" + "\0\316\316\0\353\353\0\353\353\0\213\213\0\316\316\0\353\353\0\353\353\0" + "\213\213\0\316\316\0\353\353\0\353\353\0\215\215\0\324\324\0\337\337\0\337" + "\337\0\332\332\0\312\312\0\347\347\0\347\347\0\330\330\0\224\224\0\274\274" + "\0\274\274\0\222\222\0nn\0\305\305\0\305\305\0<<\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\305\305\0ww" + "\0\225\225\0\304\304\0\314\314\0\225\225\0\300\300\0\344\344\0\342\342\0" + "\226\226\0\333\333\0\352\352\0\351\351\0\227\227\0\350\350\0\362\362\0\333" + "\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361" + "\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351\351\0" + "\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230\0\351" + "\351\0\361\361\0\333\333\0\230\230\0\351\351\0\361\361\0\333\333\0\230\230" + "\0\351\351\0\361\361\0\333\333\0\230\230\0\362\362\0\351\351\0\323\323\0" + "\370\370\0\337\337\0\352\352\0\306\306\0\355\355\0\345\345\0\306\306\0\231" + "\231\0\343\343\0\254\254\0\266\266\0ww\0\305\305\0\240\240\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0aa" + "\0\333\333\0\236\236\0\304\304\0ww\0\340\340\0\300\300\0\343\343\0\210\210" + "\0\354\354\0\333\333\0\352\352\0\215\215\0\361\361\0\350\350\0\362\362\0" + "\223\223\0\351\351\0\351\351\0\361\361\0\223\223\0\351\351\0\351\351\0\361" + "\361\0\223\223\0\351\351\0\351\351\0\361\361\0\223\223\0\351\351\0\351\351" + "\0\361\361\0\223\223\0\351\351\0\351\351\0\361\361\0\223\223\0\351\351\0" + "\351\351\0\361\361\0\223\223\0\351\351\0\351\351\0\361\361\0\223\223\0\351" + "\351\0\351\351\0\361\361\0\223\223\0\351\351\0\362\362\0\351\351\0\351\351" + "\0\323\323\0\336\336\0\351\351\0\351\351\0\304\304\0\343\343\0\305\305\0" + "\317\317\0\217\217\0\254\254\0\276\276\0\333\333\0aa\0\240\240\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0aa\0\305" + "\305\0\305\305\0\236\236\0\222\222\0\361\361\0\361\361\0\316\316\0\230\230" + "\0\373\373\0\373\373\0\344\344\0\231\231\0\375\375\0\375\375\0\357\357\0" + "\231\231\0\375\375\0\375\375\0\347\347\0\231\231\0\375\375\0\375\375\0\347" + "\347\0\231\231\0\375\375\0\375\375\0\347\347\0\231\231\0\375\375\0\375\375" + "\0\347\347\0\231\231\0\375\375\0\375\375\0\347\347\0\231\231\0\375\375\0" + "\375\375\0\347\347\0\231\231\0\375\375\0\375\375\0\347\347\0\231\231\0\375" + "\375\0\375\375\0\347\347\0\231\231\0\375\375\0\375\375\0\360\360\0\373\373" + "\0\375\375\0\375\375\0\347\347\0\367\367\0\373\373\0\373\373\0\326\326\0" + "\351\351\0\361\361\0\361\361\0\271\271\0\276\276\0\305\305\0\305\305\0aa" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0<<\0\305\305\0\305\305\0\236\236\0HH\0\271\271\0\271\271\0\224\224\0VV" + "\0\277\277\0\277\277\0\251\251\0DD\0\252\252\0\252\252\0\235\235\0FF\0\253" + "\253\0\253\253\0\224\224\0EE\0\253\253\0\253\253\0\224\224\0EE\0\253\253" + "\0\253\253\0\224\224\0EE\0\253\253\0\253\253\0\224\224\0EE\0\253\253\0\253" + "\253\0\224\224\0EE\0\253\253\0\253\253\0\224\224\0EE\0\253\253\0\253\253" + "\0\224\224\0EE\0\253\253\0\253\253\0\224\224\0EE\0\253\253\0\253\253\0\235" + "\235\0rr\0uu\0uu\0^^\0\272\272\0\277\277\0\277\277\0\230\230\0\205\205\0" + "\222\222\0\222\222\0MM\0\266\266\0\305\305\0\305\305\0<<\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\305" + "\305\0\305\305\0RR\0\236\236\0\254\254\0\361\361\0VV\0\267\267\0\263\263" + "\0\356\356\0ee\0\247\247\0\244\244\0\356\356\0^^\0\251\251\0\247\247\0\365" + "\365\0bb\0\242\242\0\247\247\0\365\365\0bb\0\242\242\0\247\247\0\365\365" + "\0bb\0\242\242\0\247\247\0\365\365\0bb\0\242\242\0\247\247\0\365\365\0bb" + "\0\242\242\0\247\247\0\365\365\0bb\0\242\242\0\247\247\0\365\365\0bb\0\242" + "\242\0\247\247\0\365\365\0bb\0\242\242\0\247\247\0\365\365\0\252\252\0ee" + "\0jj\0\345\345\0tt\0\246\246\0\251\251\0\321\321\0\272\272\0ff\0\222\222" + "\0\322\322\0ww\0\210\210\0\305\305\0\305\305\0\240\240\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\240\240" + "\0\305\305\0``\0\236\236\0\236\236\0\254\254\0VV\0\264\264\0\254\254\0\261" + "\261\0dd\0\246\246\0\240\240\0\243\243\0^^\0\251\251\0\246\246\0\246\246" + "\0bb\0\242\242\0\246\246\0\246\246\0bb\0\242\242\0\246\246\0\246\246\0bb" + "\0\242\242\0\246\246\0\246\246\0bb\0\242\242\0\246\246\0\246\246\0bb\0\242" + "\242\0\246\246\0\246\246\0bb\0\242\242\0\246\246\0\246\246\0bb\0\242\242" + "\0\246\246\0\246\246\0bb\0\242\242\0\246\246\0\246\246\0\251\251\0dd\0hh" + "\0hh\0pp\0\243\243\0\240\240\0\236\236\0\264\264\0cc\0\177\177\0ww\0ww\0" + "\225\225\0\305\305\0\240\240\0\240\240\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\240\240\0\240\240\0``" + "\0\351\351\0\333\333\0\333\333\0||\0\366\366\0\361\361\0\361\361\0\211\211" + "\0\373\373\0\371\371\0\371\371\0\221\221\0\375\375\0\374\374\0\374\374\0" + "\224\224\0\365\365\0\374\374\0\374\374\0\224\224\0\365\365\0\374\374\0\374" + "\374\0\224\224\0\365\365\0\374\374\0\374\374\0\224\224\0\365\365\0\374\374" + "\0\374\374\0\224\224\0\365\365\0\374\374\0\374\374\0\224\224\0\365\365\0" + "\374\374\0\374\374\0\224\224\0\365\365\0\374\374\0\374\374\0\224\224\0\365" + "\365\0\374\374\0\374\374\0\375\375\0\356\356\0\371\371\0\371\371\0\372\372" + "\0\340\340\0\361\361\0\361\361\0\364\364\0\307\307\0\333\333\0\333\333\0" + "\351\351\0\225\225\0\240\240\0\240\240\0\240\240\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\240\240\0\240\240" + "\0aa\0\304\304\0\351\351\0\351\351\0\205\205\0\340\340\0\366\366\0\366\366" + "\0\222\222\0\355\355\0\373\373\0\373\373\0\227\227\0\364\364\0\375\375\0" + "\375\375\0\230\230\0\360\360\0\375\375\0\375\375\0\230\230\0\360\360\0\375" + "\375\0\375\375\0\230\230\0\360\360\0\375\375\0\375\375\0\230\230\0\360\360" + "\0\375\375\0\375\375\0\230\230\0\360\360\0\375\375\0\375\375\0\230\230\0" + "\360\360\0\375\375\0\375\375\0\230\230\0\360\360\0\375\375\0\375\375\0\230" + "\230\0\360\360\0\375\375\0\375\375\0\373\373\0\356\356\0\373\373\0\373\373" + "\0\367\367\0\340\340\0\364\364\0\364\364\0\354\354\0\304\304\0\351\351\0" + "\351\351\0\322\322\0\210\210\0\240\240\0\240\240\0dd\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\240\240\0\240" + "\240\0<<\0\240\240\0\305\305\0\351\351\0ww\0\320\320\0\301\301\0\324\324" + "\0\211\211\0\345\345\0\316\316\0\324\324\0\217\217\0\356\356\0\323\323\0" + "\326\326\0\223\223\0\354\354\0\323\323\0\326\326\0\223\223\0\354\354\0\323" + "\323\0\326\326\0\223\223\0\354\354\0\323\323\0\326\326\0\223\223\0\354\354" + "\0\323\323\0\326\326\0\223\223\0\354\354\0\323\323\0\326\326\0\223\223\0" + "\354\354\0\323\323\0\326\326\0\223\223\0\354\354\0\323\323\0\326\326\0\223" + "\223\0\354\354\0\323\323\0\326\326\0\362\362\0\344\344\0\261\261\0\272\272" + "\0\364\364\0\340\340\0\225\225\0\205\205\0\340\340\0\276\276\0\351\351\0" + "\266\266\0\240\240\0dd\0\240\240\0\240\240\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\240\240\0aa\0\240" + "\240\0\240\240\0\305\305\0ww\0\305\305\0\240\240\0\266\266\0\205\205\0\333" + "\333\0\266\266\0\304\304\0\215\215\0\352\352\0\305\305\0\314\314\0\222\222" + "\0\352\352\0\305\305\0\314\314\0\222\222\0\352\352\0\305\305\0\314\314\0" + "\222\222\0\352\352\0\305\305\0\314\314\0\222\222\0\352\352\0\305\305\0\314" + "\314\0\222\222\0\352\352\0\305\305\0\314\314\0\222\222\0\352\352\0\305\305" + "\0\314\314\0\222\222\0\352\352\0\305\305\0\314\314\0\222\222\0\352\352\0" + "\305\305\0\314\314\0\361\361\0\335\335\0\242\242\0\236\236\0\333\333\0\312" + "\312\0ii\0aa\0\305\305\0\255\255\0\266\266\0\240\240\0\240\240\0\210\210" + "\0\240\240\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0aa\0\305\305\0\240\240\0\240\240\0ww\0\333" + "\333\0\305\305\0\305\305\0\205\205\0\351\351\0\333\333\0\333\333\0\217\217" + "\0\363\363\0\351\351\0\351\351\0\223\223\0\357\357\0\351\351\0\351\351\0" + "\223\223\0\357\357\0\351\351\0\351\351\0\223\223\0\357\357\0\351\351\0\351" + "\351\0\223\223\0\357\357\0\351\351\0\351\351\0\223\223\0\357\357\0\351\351" + "\0\351\351\0\223\223\0\357\357\0\351\351\0\351\351\0\223\223\0\357\357\0" + "\351\351\0\351\351\0\223\223\0\357\357\0\351\351\0\351\351\0\363\363\0\345" + "\345\0\333\333\0\333\333\0\340\340\0\312\312\0\305\305\0\305\305\0\322\322" + "\0\255\255\0\240\240\0\240\240\0\305\305\0\210\210\0dd\0dd\0dd\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd" + "\0dd\0dd\0aa\0\305\305\0\305\305\0\240\240\0ww\0\333\333\0\333\333\0\305" + "\305\0\205\205\0\355\355\0\355\355\0\336\336\0\215\215\0\364\364\0\364\364" + "\0\335\335\0\215\215\0\364\364\0\364\364\0\335\335\0\215\215\0\364\364\0" + "\364\364\0\335\335\0\215\215\0\364\364\0\364\364\0\335\335\0\215\215\0\364" + "\364\0\364\364\0\335\335\0\215\215\0\364\364\0\364\364\0\335\335\0\215\215" + "\0\364\364\0\364\364\0\335\335\0\215\215\0\364\364\0\364\364\0\335\335\0" + "\215\215\0\364\364\0\364\364\0\335\335\0\351\351\0\355\355\0\355\355\0\312" + "\312\0\305\305\0\322\322\0\322\322\0\255\255\0\240\240\0\305\305\0\305\305" + "\0\210\210\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0\305\305\0aa" + "\0" + "11\0\225\225\0\351\351\0\205\205\0HH\0\254\254\0\333\333\0ww\0BB\0\264" + "\264\0\340\340\0nn\0BB\0\264\264\0\340\340\0nn\0BB\0\264\264\0\340\340\0" + "nn\0BB\0\264\264\0\340\340\0nn\0BB\0\264\264\0\340\340\0nn\0BB\0\264\264" + "\0\340\340\0nn\0BB\0\264\264\0\340\340\0nn\0BB\0\264\264\0\340\340\0nn\0" + "BB\0\264\264\0\340\340\0nn\0nn\0\205\205\0\314\314\0\266\266\0\304\304\0" + "\351\351\0\236\236\0yy\0\210\210\0\305\305\0<<\0\0\0\0\0\0\0dd\0dd\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0" + "\0dd\0dd\0\25\25\0\14\14\0dd\0dd\0\25\25\0\14\14\0dd\0dd\0\25\25\0\14\14" + "\0dd\0dd\0\25\25\0\14\14\0dd\0dd\0\25\25\0\14\14\0dd\0dd\0\25\25\0\14\14" + "\0dd\0dd\0\25\25\0\14\14\0dd\0dd\0\25\25\0\14\14\0dd\0dd\0\25\25\0\14\14" + "\0dd\0dd\0\25\25\0\25\25\0\0\0\0\0\0\0$$\0$$\0\0\0\0\0\0\0<<\0<<\0\0\0\0" + "\0\0\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0" + "\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0yy\0yy\0\0\0\0\0\0\0yy\0yy\0\0\0\0\0\0\0" + "yy\0yy\0\0\0\0\0\0\0yy\0yy\0\0\0\0\0\0\0yy\0yy\0\0\0\0\0\0\0yy\0yy\0\0\0" + "\0\0\0\0yy\0yy\0\0\0\0\0\0\0yy\0yy\0\0\0\0\0\0\0yy\0yy\0\0\0\0\0\0\0yy\0" + "yy\0\0\0\0\0\0\0$$\0$$\0\0\0\0\0\0\0<<\0<<\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0\0\0\0dd\0dd\0dd\0\0\0\0dd" + "\0\210\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210\210" + "\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210" + "\0\25\25\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0\25\25" + "\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210" + "\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0$$\0\0\0\0<<\0<<\0<<\0\0" + "\0\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0dd\0dd\0<<\0<<\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0" + "aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240" + "\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240" + "\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0" + "aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0\240\240\0\240\240" + "\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", }; /** @@ -1110,429 +1184,431 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlend = { */ SDL_Surface *SDLTest_ImageBlitBlend() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( - (void*)SDLTest_imageBlitBlend.pixel_data, + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + (void *)SDLTest_imageBlitBlend.pixel_data, SDLTest_imageBlitBlend.width, SDLTest_imageBlitBlend.height, SDLTest_imageBlitBlend.bytes_per_pixel * 8, SDLTest_imageBlitBlend.width * SDLTest_imageBlitBlend.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ + 0xff000000, /* Red bit mask. */ + 0x00ff0000, /* Green bit mask. */ + 0x0000ff00, /* Blue bit mask. */ + 0x000000ff /* Alpha bit mask. */ #else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ + 0x000000ff, /* Red bit mask. */ + 0x0000ff00, /* Green bit mask. */ + 0x00ff0000, /* Blue bit mask. */ + 0xff000000 /* Alpha bit mask. */ #endif - ); - return surface; + ); + return surface; } static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendMod = { - 80, 60, 3, - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", + 80, + 60, + 3, + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", }; /** @@ -1540,812 +1616,814 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendMod = { */ SDL_Surface *SDLTest_ImageBlitBlendMod() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( - (void*)SDLTest_imageBlitBlendMod.pixel_data, + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + (void *)SDLTest_imageBlitBlendMod.pixel_data, SDLTest_imageBlitBlendMod.width, SDLTest_imageBlitBlendMod.height, SDLTest_imageBlitBlendMod.bytes_per_pixel * 8, SDLTest_imageBlitBlendMod.width * SDLTest_imageBlitBlendMod.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ + 0xff000000, /* Red bit mask. */ + 0x00ff0000, /* Green bit mask. */ + 0x0000ff00, /* Blue bit mask. */ + 0x000000ff /* Alpha bit mask. */ #else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ + 0x000000ff, /* Red bit mask. */ + 0x0000ff00, /* Green bit mask. */ + 0x00ff0000, /* Blue bit mask. */ + 0xff000000 /* Alpha bit mask. */ #endif - ); - return surface; + ); + return surface; } static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendNone = { - 80, 60, 3, - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\0\0\0\0\0\0\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\0\0\0\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377" - "\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0" - "\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\377\0\0\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\377\0\0\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\0\0\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" - "\377\377\0\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" - "\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377\377\0\377\377" - "\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377\377\0\377" - "\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0" - "\377\377\0\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377" - "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377", + 80, + 60, + 3, + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\0\0\0\0\0\0\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\0\0\0\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377" + "\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0" + "\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\377\0\0\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\377\0\0\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\0\0\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0" + "\377\377\0\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377" + "\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377\377\0\377\377" + "\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377\377\0\377" + "\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0" + "\377\377\0\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377" + "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377", }; /** @@ -2353,467 +2431,546 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendNone = { */ SDL_Surface *SDLTest_ImageBlitBlendNone() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( - (void*)SDLTest_imageBlitBlendNone.pixel_data, + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + (void *)SDLTest_imageBlitBlendNone.pixel_data, SDLTest_imageBlitBlendNone.width, SDLTest_imageBlitBlendNone.height, SDLTest_imageBlitBlendNone.bytes_per_pixel * 8, SDLTest_imageBlitBlendNone.width * SDLTest_imageBlitBlendNone.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ + 0xff000000, /* Red bit mask. */ + 0x00ff0000, /* Green bit mask. */ + 0x0000ff00, /* Blue bit mask. */ + 0x000000ff /* Alpha bit mask. */ #else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ + 0x000000ff, /* Red bit mask. */ + 0x0000ff00, /* Green bit mask. */ + 0x00ff0000, /* Blue bit mask. */ + 0xff000000 /* Alpha bit mask. */ #endif - ); - return surface; + ); + return surface; } static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAll = { - 80, 60, 3, - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\0\0\4\0\0\0\0\0\0\0" - "\0\11\0\0\11\0\0\0\0\0\0\0\0\16\0\0\16\0\0\0\0\0\0\0\0\11\0\0\11\0\0\0\0" - "\0\0\0\0\14\0\0\14\0\0\0\0\0\0\0\0\17\0\0\17\0\0\0\0\0\0\0\0\21\0\0\21\0" - "\0\0\0\0\0\0\0K\0\0K\0\0\0\0\0\0\0\0T\0\0T\0\0\0\0\0\0\0\0^\0\0^\0\0\0\0" - "\0\0\0\0g\0\0g\0\0\0\0\0\0\0\0\317\0\0\317\0\0\317\0\0\317\0\0\317\0\0\317" - "\0\0\317\0\0\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\0\0\4\0\0\4\0\0\0\0\0\11\0\0\11\0\0\11" - "\0\0\0\0\0\16\0\0\16\0\0\16\0\0\0\0\0\22\0\0\22\0\0\11\0\0\0\0\0\14\0\0\14" - "\0\0\14\0\0\0\0\0\17\0\0\17\0\0\17\0\0\0\0\0\21\0\0\21\0\0\21\0\0\0\0\0\24" - "\0\0\24\0\0K\0\0\0\0\0T\0\0T\0\0T\0\0\0\0\0^\0\0^\0\0^\0\0\0\0\0g\0\0g\0" - "\0g\0\0\0\0\0q\0\0q\0\0\317\0\0\317\0\0\317\0\0\317\0\0\317\0\0\317\0\0\317" - "\0\0\317\0\0\317\0\0\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\4\0\0\4\0\0\4\0\0\0\0\0\11\0\0\11\0\0\11\0\0\0\0\0" - "\16\0\0\16\0\0\16\0\0\0\0\0\22\0\0\22\0\0\22\0\0\0\0\0\14\0\0\14\0\0\14\0" - "\0\0\0\0\17\0\0\17\0\0\17\0\0\0\0\0\21\0\0\21\0\0\21\0\0\0\0\0\24\0\0\24" - "\0\0\24\0\0\0\0\0T\0\0T\0\0T\0\0\0\0\0^\0\0^\0\0^\0\0\0\0\0g\0\0g\0\0g\0" - "\0\0\0\0q\0\0q\0\0q\0\0\317\0\0\317\0\0\317\0\0\317\0\0\317\0\0\317\0\0\317" - "\0\0\317\0\0\317\0\0\317\0\0\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\4\0\0\4\0\0\4\0\0\0\0\0\10\0\0\10\0\0\10\0\0\0\0\0\15" - "\0\0\15\0\0\15\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\16\0\0\16\0\0\16\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0J\0\0J\0\0J\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\317" - "\0\0\317\0\0\317\0\0\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\1\0\0\0\0\0\0\0\0\1\0\0\1\0\0\1\0\0\1" - "\0\0\4\0\0\4\0\0\0\0\0\0\0\0\7\0\0\7\0\0\0\0\0\0\0\0&\0\0&\0\0\32\0\0\32" - "\0\0&\0\0&\0\0&\0\0&\0\0C\0\0C\0\0\0\0\0\0\0\0^\0\0^\0\0\0\0\0\0\0\17\251" - "\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0\0\0\0\0" - "\0\0\0\317\0\0\317\0\0\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\6\2\0\6\2\0\0\1\0\0\0\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0" - "\17\0\0\0\0\0\4\0\0\11\0\0\11\0\0\0\0\6+\0\6+\0\0&\0\0\32\0\0&\0\0&\0\0&" - "\0\0&\0\0""5\0\0""5\0\2\210\0\0\0\0\0C\0\0|\0\0|\0\0\0\0\17\251\0\17\251" - "\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251" - "\0$\360\0$\360\0\0\0\0\0\317\0\0\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1" - "\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\1\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\6\2\0\6\2\0\6\2\0\0\0\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1" - "\0\0\1\0\0\0\0\0\17\0\0\17\0\0\4\0\0\0\0\6+\0\6+\0\6+\0\0\32\0\0&\0\0&\0" - "\0&\0\0&\0\0""5\0\0""5\0\0""5\0\0\0\0\2\210\0\2\210\0\0C\0\0\0\0\17\251\0" - "\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0" - "\17\251\0\17\251\0$\360\0$\360\0$\360\0\0\0\0\0\317\0\0\317\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\1\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "$\360\0$\360\0$\360\0$\360\0\0\0\0\0\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0" - "\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\14\1\0\14\1\0\14\1" - "\0\14\1\0\15\1\0\15\1\0\0\0\0\0\0\0\14\2\0\14\2\0\14\2\0\14\2\0\16\2\0\16" - "\2\0\0\0\0\0\0\0\14!\0\14!\0\14!\0\14!\0\17(\0\17(\0\0\0\0\0\0\0\14+\0\14" - "+\0\14+\0\14+\0\20""9\0\20""9\0\0\0\0\0\0\0\36\215\0\36\215\0\36\215\0\36" - "\215\0(\264\0(\264\0\0\0\0\0\0\0\36\251\0\36\251\0\36\251\0\36\251\0\36\251" - "\0\36\251\0\36\251\0\36\251\0\0\0\0\0\0\0$\360\0$\360\0$\360\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\1\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\36\3" - "\0\36\3\0\14\1\0\14\1\0\15\1\0\15\1\0\15\1\0\0\0\0\14\2\0\14\2\0\14\2\0\14" - "\2\0\16\2\0\16\2\0\16\2\0\0\0\0\14\3\0\14\3\0\14!\0\14!\0\17(\0\17(\0\17" - "(\0\0\0\0\14+\0\14+\0\14+\0\14+\0\20""9\0\20""9\0\20""9\0\0\0\0\14""7\0\14" - """7\0\36\215\0\36\215\0(\264\0(\264\0(\264\0\0\0\0\36\251\0\36\251\0\36\251" - "\0\36\251\0\36\251\0\36\251\0\36\251\0\36\251\0\36\251\0\36\251\0H\360\0" - "H\360\0\0\0\0$\360\0$\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\1\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\36\3\0\36\3\0\36\3\0\14\1\0\15\1\0\15\1\0\15\1" - "\0\0\0\0\14\2\0\14\2\0\14\2\0\14\2\0\16\2\0\16\2\0\16\2\0\0\0\0\14\3\0\14" - "\3\0\14\3\0\14!\0\17(\0\17(\0\17(\0\0\0\0\14+\0\14+\0\14+\0\14+\0\20""9\0" - "\20""9\0\20""9\0\0\0\0\14""7\0\14""7\0\14""7\0\36\215\0(\264\0(\264\0(\264" - "\0\0\0\0\36\251\0\36\251\0\36\251\0\36\251\0\36\251\0\36\251\0\36\251\0\36" - "\251\0\36\251\0\36\251\0\36\251\0H\360\0H\360\0H\360\0\0\0\0$\360\0$\360" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\13\1\0\13\1\0\13\1\0\13\1\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\11!\0" - "\11!\0\11!\0\11!\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\23n\0\23n\0\23n\0\23n\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0H\360\0H\360\0H\360\0H\360\0\0\0\0$\360\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\1\0\1\1\0\0\0\0\0\0\0\0\0\0\0\0\0\25\0\0\25\0\0\25\0\0\27\0" - "\0\13\0\0\13\0\0\1\0\0\11\0\0\4\0\0\4\0\0\0\0\0\0\0\0\25\3\0\25\3\0\0\0\0" - "\0\0\0\25\3\0\25\3\0\25\3\0\25\3\0\3\1\0\3\1\0\2\1\0\7\5\0\7\3\0\7\3\0\0" - "\0\0\0\0\0\25""4\0\25""4\0\0\0\0\0\0\0\25""4\0\25""4\0\25""4\0\25""4\0\20" - "\35\0\20\35\0\11\22\0\23F\0\34""6\0\34""6\0\0\0\0\0\0\0L\317\0L\317\0L\317" - "\0L\317\0L\317\0L\317\0L\317\0L\317\0\0\0\0\0\0\0""2\317\0""2\317\0""2\317" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1\0\0\0\0\0\0\0\0\0\0\25\0\0\25" - "\0\0\25\0\0\4\0\0\5\0\0\2\0\0\1\0\0\4\0\0\14\0\0\14\0\0\0\0\0\37\7\0\37\7" - "\0\25\3\0\0\0\0\25\3\0\25\3\0\25\3\0\25\3\0\37\6\0\37\6\0\15\4\0\11\3\0\7" - "\3\0\14\10\0\14\10\0\0\0\0\25\16\0\25\16\0\25""4\0\0\0\0\25""4\0\25""4\0" - "\25""4\0\25""4\0&Q\0&Q\0&Q\0\31""5\0\34""6\0&j\0&j\0\0\0\0""5q\0""5q\0L\317" - "\0L\317\0L\317\0L\317\0L\317\0L\317\0L\317\0L\317\0L\317\0L\317\0\0\0\0""2" - "\317\0""2\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\1\1\0\0\0\0\0\0\0\25\0" - "\0\25\0\0\25\0\0\31\1\0\5\0\0\5\0\0\2\0\0\4\0\0\14\0\0\14\0\0\0\0\0\37\7" - "\0\37\7\0\37\7\0\0\0\0\25\3\0\25\3\0\25\3\0\25\3\0\37\6\0\37\6\0\37\6\0\11" - "\3\0\16\6\0\16\6\0\7\3\0\0\0\0\25\16\0\25\16\0\25\16\0\0\0\0\25""4\0\25""4" - "\0\25""4\0\25""4\0&Q\0&Q\0&Q\0\31""5\0+X\0+X\0\34""6\0\0\0\0""5q\0""5q\0" - """5q\0L\317\0L\317\0L\317\0L\317\0L\317\0L\317\0L\317\0L\317\0L\317\0L\317" - "\0L\317\0\0\0\0""2\317\0""2\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0" - "\0\0\0\0\25\0\0\25\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0L\317\0L\317\0L\317\0L\317" - "\0\0\0\0""2\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0e\4\0e\4\0\0\0\0\0\0\0e\11\0e\11\0\0\0\0\0\0\0e\16\0e\16\0\0\0\0\0\0" - "\0G\11\0G\11\0\0\0\0\0\0\0G\14\0G\14\0\0\0\0\0\0\0G\17\0G\17\0\0\0\0\0\0" - "\0G\21\0G\21\0\0\0\0\0\0\0GK\0GK\0\0\0\0\0\0\0GT\0GT\0\0\0\0\0\0\0G^\0G^" - "\0\0\0\0\0\0\0Gg\0Gg\0\0\0\0\0\0\0e\317\0e\317\0e\317\0e\317\0e\317\0e\317" - "\0e\317\0e\317\0\0\0\0\0\0\0L\317\0L\317\0L\317\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0e\4\0e\4\0e\4\0\0\0\0e\11\0e\11\0e\11\0\0\0" - "\0e\16\0e\16\0e\16\0\0\0\0e\22\0e\22\0G\11\0\0\0\0G\14\0G\14\0G\14\0\0\0" - "\0G\17\0G\17\0G\17\0\0\0\0G\21\0G\21\0G\21\0\0\0\0G\24\0G\24\0GK\0\0\0\0" - "GT\0GT\0GT\0\0\0\0G^\0G^\0G^\0\0\0\0Gg\0Gg\0Gg\0\0\0\0Gq\0Gq\0e\317\0e\317" - "\0e\317\0e\317\0e\317\0e\317\0e\317\0e\317\0e\317\0e\317\0\0\0\0L\317\0L" - "\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0e\4\0e\4\0e\4\0\0\0" - "\0e\11\0e\11\0e\11\0\0\0\0e\16\0e\16\0e\16\0\0\0\0e\22\0e\22\0e\22\0\0\0" - "\0G\14\0G\14\0G\14\0\0\0\0G\17\0G\17\0G\17\0\0\0\0G\21\0G\21\0G\21\0\0\0" - "\0G\24\0G\24\0G\24\0\0\0\0GT\0GT\0GT\0\0\0\0G^\0G^\0G^\0\0\0\0Gg\0Gg\0Gg" - "\0\0\0\0Gq\0Gq\0Gq\0e\317\0e\317\0e\317\0e\317\0e\317\0e\317\0e\317\0e\317" - "\0e\317\0e\317\0e\317\0\0\0\0L\317\0L\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0e\4\0e\4\0e\4\0\0\0\0b\10\0b\10\0b\10\0\0\0\0b\15\0b\15\0b\15\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0<\16\0<\16\0<\16\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0""2J\0""2J\0""2J\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0e\317\0e\317\0e\317\0e" - "\317\0\0\0\0L\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\216\1\0c\0\0c\0\0\0\0\0" - "`\0\0c\0\0c\0\0\2\0\0c\1\0i\0\0i\0\0\0\0\0\0\0\0e\0\0e\0\0\0\0\0\0\0\0{\1" - "\0{\1\0f\0\0f\0\0z\1\0z\1\0z\1\0z\1\0)\4\0)\4\0\0\0\0\0\0\0Q\7\0Q\7\0\0\0" - "\0\0\0\0{&\0{&\0W\32\0W\32\0z&\0z&\0z&\0z&\0IC\0IC\0\0\0\0\0\0\0X^\0X^\0" - "\0\0\0\0\0\0\261\251\0\261\251\0\261\251\0\261\251\0\261\251\0\261\251\0" - "\261\251\0\261\251\0\0\0\0\0\0\0e\317\0e\317\0e\317\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\216\1\0c\0\0`\0\0\2\0\0c\0\0c\0\0c\0\0\12\0\0k\1\0i\0\0" - "\0\0\0\11\0\0i\0\0i\0\0\0\0\0\256\2\0\256\2\0{\1\0f\0\0z\1\0z\1\0z\1\0z\1" - "\0\221\1\0\221\1\0\221\17\0\0\0\0)\4\0c\11\0c\11\0\0\0\0\256+\0\256+\0{&" - "\0W\32\0z&\0z&\0z&\0z&\0\2415\0\2415\0\243\210\0\0\0\0IC\0{|\0{|\0\0\0\0" - "\261\251\0\261\251\0\261\251\0\261\251\0\261\251\0\261\251\0\261\251\0\261" - "\251\0\261\251\0\261\251\0\264\360\0\264\360\0\0\0\0e\317\0e\317\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\216\1\0\216\1\0`\0\0\2\0\0c\0\0c\0\0c\0\0\12\0\0" - "k\1\0k\1\0\0\0\0\11\0\0i\0\0i\0\0\0\0\0\256\2\0\256\2\0\256\2\0f\0\0z\1\0" - "z\1\0z\1\0z\1\0\221\1\0\221\1\0\221\1\0\0\0\0\221\17\0\221\17\0)\4\0\0\0" - "\0\256+\0\256+\0\256+\0W\32\0z&\0z&\0z&\0z&\0\2415\0\2415\0\2415\0\0\0\0" - "\243\210\0\243\210\0IC\0\0\0\0\261\251\0\261\251\0\261\251\0\261\251\0\261" - "\251\0\261\251\0\261\251\0\261\251\0\261\251\0\261\251\0\261\251\0\264\360" - "\0\264\360\0\264\360\0\0\0\0e\317\0e\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\216\1" - "\0\211\1\0c\0\0\2\0\0c\0\0c\0\0k\0\0\12\0\0k\1\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\264\360\0\264\360" - "\0\264\360\0\264\360\0\0\0\0e\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\211\1\0\216\1" - "\0c\0\0\2\0\0c\0\0k\0\0q\0\0\20\0\0\0\0\0\0\0\0\322\1\0\322\1\0\322\1\0\322" - "\1\0\346\1\0\346\1\0\0\0\0\0\0\0\322\2\0\322\2\0\322\2\0\322\2\0\363\2\0" - "\363\2\0\0\0\0\0\0\0\322!\0\322!\0\322!\0\322!\0\371(\0\371(\0\0\0\0\0\0" - "\0\322+\0\322+\0\322+\0\322+\0\3719\0\3719\0\0\0\0\0\0\0\325\215\0\325\215" - "\0\325\215\0\325\215\0\374\264\0\374\264\0\0\0\0\0\0\0\325\251\0\325\251" - "\0\325\251\0\325\251\0\325\251\0\325\251\0\325\251\0\325\251\0\0\0\0\0\0" - "\0\264\360\0\264\360\0\264\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\211\1\0\216" - "\1\0c\0\0\2\0\0f\0\0m\0\0m\0\0\0\0\0\325\3\0\325\3\0\322\1\0\322\1\0\346" - "\1\0\346\1\0\346\1\0\0\0\0\322\2\0\322\2\0\322\2\0\322\2\0\363\2\0\363\2" - "\0\363\2\0\0\0\0\322\3\0\322\3\0\322!\0\322!\0\371(\0\371(\0\371(\0\0\0\0" - "\322+\0\322+\0\322+\0\322+\0\3719\0\3719\0\3719\0\0\0\0\3227\0\3227\0\325" - "\215\0\325\215\0\374\264\0\374\264\0\374\264\0\0\0\0\325\251\0\325\251\0" - "\325\251\0\325\251\0\325\251\0\325\251\0\325\251\0\325\251\0\325\251\0\325" - "\251\0\330\360\0\330\360\0\0\0\0\264\360\0\264\360\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\216\1\0\216\1\0c\0\0\10\0\0m\0\0m\0\0\0\0\0\325\3\0\325\3\0\325" - "\3\0\322\1\0\346\1\0\346\1\0\346\1\0\0\0\0\322\2\0\322\2\0\322\2\0\322\2" - "\0\363\2\0\363\2\0\363\2\0\0\0\0\322\3\0\322\3\0\322\3\0\322!\0\371(\0\371" - "(\0\371(\0\0\0\0\322+\0\322+\0\322+\0\322+\0\3719\0\3719\0\3719\0\0\0\0\322" - "7\0\3227\0\3227\0\325\215\0\374\264\0\374\264\0\374\264\0\0\0\0\325\251\0" - "\325\251\0\325\251\0\325\251\0\325\251\0\325\251\0\325\251\0\325\251\0\325" - "\251\0\325\251\0\325\251\0\330\360\0\330\360\0\330\360\0\0\0\0\264\360\0" - "\264\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\216\1\0\216\1\0i\0\0\10\0\0m\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\275\1\0\275\1\0\275\1\0" - "\275\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\244!\0\244!\0\244!\0\244!\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\213n\0\213n\0\213n\0\213n\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\330\360\0\330\360\0\330\360\0\330" - "\360\0\0\0\0\264\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\216\1\0\224\1\0i\0\0\10\0" - "\0\0\0\0\0\0\0\325\3\0\325\3\0\325\3\0\351\3\0\365\1\0\365\1\0\14\0\0\313" - "\2\0#\2\0#\2\0\0\0\0\0\0\0\371\37\0\371\37\0\0\0\0\0\0\0\371\37\0\371\37" - "\0\371\37\0\371\37\0.\17\0.\17\0#\14\0\304-\0Y!\0Y!\0\0\0\0\0\0\0\371p\0" - "\371p\0\0\0\0\0\0\0\371p\0\371p\0\371p\0\371p\0O>\0O>\0""3(\0\247\227\0\211" - "s\0\211s\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" - "\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\330\360\0\330\360\0\330\360\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\0\0\224\1\0i\0\0\0\0\0\0\0\0\325\3\0\325" - "\3\0\325\3\0\17\2\0\"\2\0!\0\0\35\0\0#\2\0\342\4\0\342\4\0\0\0\0\371\37\0" - "\371\37\0\371\37\0\0\0\0\371\37\0\371\37\0\371\37\0\371\37\0\3775\0\3775" - "\0\374%\0\304\34\0Y!\0\373C\0\373C\0\0\0\0\371p\0\371p\0\371p\0\0\0\0\371" - "p\0\371p\0\371p\0\371p\0\377\256\0\377\256\0\377\256\0\247q\0\211s\0\375" - "\342\0\375\342\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" - "\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\0" - "\0\0\330\360\0\330\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\12\0\0\224\1\0\0\0" - "\0\0\0\0\325\3\0\325\3\0\325\3\0\344\5\0\"\2\0\"\2\0\200\0\0#\2\0\342\4\0" - "\342\4\0\0\0\0\371\37\0\371\37\0\371\37\0\0\0\0\371\37\0\371\37\0\371\37" - "\0\371\37\0\3775\0\3775\0\3775\0\304\34\0\3732\0\3732\0Y!\0\0\0\0\371p\0" - "\371p\0\371p\0\0\0\0\371p\0\371p\0\371p\0\371p\0\377\256\0\377\256\0\377" - "\256\0\247q\0\375\274\0\375\274\0\211s\0\0\0\0\374\360\0\374\360\0\374\360" - "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" - "\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\330\360\0\330\360\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\12\0\0\0\0\0i\0\0\0\0\0\325\3\0\325\3\0\344\5\0\344\5" - "\0\"\2\0\36\1\0""4\2\0#\2\0\342\4\0\0\0\0\371\37\0\371\37\0\371\37\0\0\0" - "\0\371\37\0\371\37\0\371\37\0\371\37\0\3775\0\3775\0\3775\0\307)\0\3732\0" - "\3732\0\3732\0\0\0\0\371p\0\371p\0\371p\0\0\0\0\371p\0\371p\0\371p\0\371" - "p\0\377\256\0\377\256\0\377\256\0\247q\0\375\274\0\375\274\0\375\274\0\0" - "\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" - "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" - "\374\360\0\374\360\0\0\0\0\330\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\12\0\0" - "\10\0\0\0\0\0\325\3\0\344\5\0\344\5\0\344\5\0\340\4\0\367\11\0\364\3\0#\2" - "\0\0\0\0\371\37\0\371\37\0\371\37\0\0\0\0\371\37\0\371\37\0\371\37\0\371" - "\37\0\3775\0\3775\0\3775\0\307)\0\376G\0\3732\0\3732\0\0\0\0\371p\0\371p" - "\0\371p\0\0\0\0\371p\0\371p\0\371p\0\371p\0\377\256\0\377\256\0\377\256\0" - "\247q\0\375\274\0\375\274\0\375\274\0\0\0\0\374\360\0\374\360\0\374\360\0" - "\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374" - "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\12\0\0\10\0\0\0\0\0\0\0\0\17\2\0\17" - "\2\0\17\2\0\323\2\0\352\7\0\347\2\0\26\1\0\0\0\0\371\37\0\371\37\0\371\37" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0/\26\0/\26\0/\26\0\0\0\0""7\36\0""6\25\0" - """6\25\0\0\0\0\371p\0\371p\0\371p\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0O>\0O>\0" - "O>\0\0\0\0VK\0VK\0VK\0\0\0\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5\0\0\12\0" - "\0\10\0\0\0\0\0\17\2\0\17\2\0\344\5\0\15\1\0\352\7\0\352\7\0\347\2\0\0\0" - "\0\371\37\0\371\37\0\371\37\0\0\0\0\0\0\0\0\0\0\362\4\0\0\0\0/\26\0/\26\0" - "\3775\0$\21\0""7\36\0""7\36\0\3672\0\0\0\0\371p\0\371p\0\371p\0\0\0\0\0\0" - "\0\0\0\0\370A\0\0\0\0O>\0O>\0\377\256\0""3(\0VK\0VK\0\372\264\0\0\0\0\374" - "\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\341\271\0\0\0\0\374\360" - "\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\343\350\0\0\0\0\374\360\0\374" - "\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5\0\0\5\0\0\10\0\0\0\0" - "\0\17\2\0\17\2\0\17\2\0\15\1\0\352\7\0\352\7\0\347\2\0\0\0\0\371\37\0\371" - "\37\0\371\37\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0/\26\0/\26\0/\26\0$\21\0""7\36" - "\0""7\36\0""6\25\0\0\0\0\371p\0\371p\0\371p\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0O>\0O>\0O>\0""3(\0VK\0VK\0VK\0\0\0\0\374\360\0\374\360\0\374\360\0\374" - "\360\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\5\0\0\5\0\0\5\0\0\0\0\0\344\5\0\344\5\0\344\5\0\316\4\0\367" - "\11\0\367\11\0\364\3\0\0\0\0\371\37\0\371\37\0\371\37\0\0\0\0\371\37\0\371" - "\37\0\371\37\0\371\37\0\3775\0\3775\0\3775\0\307)\0\376G\0\376G\0\3732\0" - "\0\0\0\371p\0\371p\0\371p\0\0\0\0\371p\0\371p\0\371p\0\371p\0\377\256\0\377" - "\256\0\377\256\0\247q\0\375\274\0\375\274\0\375\274\0\0\0\0\374\360\0\374" - "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" - "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" - "\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5" - "\0\0\5\0\0\5\0\0\17\2\0\344\5\0\344\5\0\316\4\0\345\11\0\367\11\0\364\3\0" - "\0\0\0\371\37\0\371\37\0\371\37\0\0\0\0\371\37\0\371\37\0\371\37\0\371\37" - "\0\3775\0\3775\0\3775\0\307)\0\376G\0\376G\0\3732\0\0\0\0\371p\0\371p\0\371" - "p\0\0\0\0\371p\0\371p\0\371p\0\371p\0\377\256\0\377\256\0\377\256\0\247q" - "\0\375\274\0\375\274\0\375\274\0\0\0\0\374\360\0\374\360\0\374\360\0\374" - "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" - "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" - "\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5\0\0\5\0\0\0\0\0\17\2" - "\0\344\5\0\344\5\0\15\1\0$\6\0$\6\0#\2\0\0\0\0\371\37\0\371\37\0\371\37\0" - "\0\0\0\371\37\0\371\37\0\371\37\0\371\37\0\3775\0/\26\0/\26\0\307)\0\376" - "G\0[/\0Y!\0\0\0\0\371p\0\371p\0\371p\0\0\0\0\371p\0\371p\0\371p\0\371p\0" - "\377\256\0O>\0O>\0\247q\0\375\274\0\211s\0\211s\0\0\0\0\374\360\0\374\360" - "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" - "\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" - "\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5\0\0" - "\5\0\0\17\2\0\17\2\0\344\5\0\316\4\0$\6\0$\6\0#\2\0\0\0\0\371\37\0\371\37" - "\0\371\37\0\0\0\0\371\37\0\371\37\0\371\37\0\371\37\0\3775\0/\26\0/\26\0" - "\307)\0\376G\0[/\0Y!\0\0\0\0\371p\0\371p\0\371p\0\0\0\0\371p\0\371p\0\371" - "p\0\371p\0\377\256\0O>\0O>\0\247q\0\375\274\0\211s\0\211s\0\0\0\0\374\360" - "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" - "\374\360\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" - "\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\5\0\0\24\2\0\17\2\0\17\2\0\316\4\0\345\11\0$\6\0#\2\0\0\0\0\371" - "\37\0\371\37\0\371\37\0\0\0\0\371\37\0\371\37\0\371\37\0\371\37\0\3775\0" - "\3775\0\3775\0\307)\0\376G\0\376G\0\3732\0\0\0\0\371p\0\371p\0\371p\0\0\0" - "\0\371p\0\371p\0\371p\0\371p\0\377\256\0\377\256\0\377\256\0\247q\0\375\274" - "\0\375\274\0\375\274\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374" - "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" - "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" - "\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5\0\0\24\2\0\24" - "\2\0\17\2\0\316\4\0\345\11\0\342\3\0#\2\0\0\0\0\371\37\0\371\37\0\371\37" - "\0\0\0\0\371\37\0\371\37\0\371\37\0\371\37\0\3775\0\3775\0\3775\0\307)\0" - "\376G\0\3732\0\3732\0\0\0\0\371p\0\371p\0\371p\0\0\0\0\371p\0\371p\0\371" - "p\0\371p\0\377\256\0\377\256\0\377\256\0\247q\0\375\274\0\375\274\0\375\274" - "\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374" - "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" - "\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\17\2\0\24\2\0\5\0\0\0\0\0\27\5\0\342\3\0\313" - "\1\0\0\0\0\371\37\0\371\37\0\0\0\0\0\0\0\0\0\0\371\37\0\0\0\0\0\0\0/\26\0" - "\3775\0\371\37\0\302\30\0\3716\0Y!\0#\14\0\0\0\0\371p\0\371p\0\0\0\0\0\0" - "\0\0\0\0\371p\0\0\0\0\0\0\0O>\0\377\256\0\371p\0\243I\0\371\224\0\211s\0" - """3(\0\0\0\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360\0\374" - "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0" - "\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\17\2\0\17\2\0\0\0\0\0\0\0\26\1\0\26\1\0\0\0\0\0\0\0\371" - "\37\0\371\37\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0/\26\0/\26\0\0\0\0\0\0" - "\0""6\25\0""6\25\0\0\0\0\0\0\0\371p\0\371p\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0O>\0O>\0\0\0\0\0\0\0VK\0VK\0\0\0\0\0\0\0\374\360\0\374\360\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374" - "\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\17\2\0\17\2\0\0\0\0\0\0\0\26\1\0\26\1\0\0\0\0\0\0" - "\0\371\37\0\371\37\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0/\26\0/\26\0\0\0" - "\0\0\0\0""6\25\0""6\25\0\0\0\0\0\0\0\371p\0\371p\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0O>\0O>\0\0\0\0\0\0\0VK\0VK\0\0\0\0\0\0\0\374\360\0\374\360" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0" - "\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\17\2\0\17\2\0\16\0\0\0\0\0\26\1\0\26\1\0\26" - "\1\0\0\0\0\371\37\0\371\37\0\371\37\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0/\26\0" - "/\26\0.\17\0\0\0\0""6\25\0""6\25\0""6\25\0\0\0\0\371p\0\371p\0\371p\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0O>\0O>\0O>\0\0\0\0VK\0VK\0VK\0\0\0\0\374\360\0" - "\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360" - "\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\16\0\0\16\0\0\14\0\0\14" - "\0\0#\2\0#\2\0\0\0\0\0\0\0\371\37\0\371\37\0\0\0\0\0\0\0\371\37\0\371\37" - "\0\371\37\0\371\37\0.\17\0.\17\0#\14\0#\14\0Y!\0Y!\0\0\0\0\0\0\0\371p\0\371" - "p\0\0\0\0\0\0\0\371p\0\371p\0\371p\0\371p\0O>\0O>\0""3(\0""3(\0\211s\0\211" - "s\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" - "\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", + 80, + 60, + 3, + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\0\0\4\0\0\0\0\0\0\0" + "\0\11\0\0\11\0\0\0\0\0\0\0\0\16\0\0\16\0\0\0\0\0\0\0\0\11\0\0\11\0\0\0\0" + "\0\0\0\0\14\0\0\14\0\0\0\0\0\0\0\0\17\0\0\17\0\0\0\0\0\0\0\0\21\0\0\21\0" + "\0\0\0\0\0\0\0K\0\0K\0\0\0\0\0\0\0\0T\0\0T\0\0\0\0\0\0\0\0^\0\0^\0\0\0\0" + "\0\0\0\0g\0\0g\0\0\0\0\0\0\0\0\317\0\0\317\0\0\317\0\0\317\0\0\317\0\0\317" + "\0\0\317\0\0\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\0\0\4\0\0\4\0\0\0\0\0\11\0\0\11\0\0\11" + "\0\0\0\0\0\16\0\0\16\0\0\16\0\0\0\0\0\22\0\0\22\0\0\11\0\0\0\0\0\14\0\0\14" + "\0\0\14\0\0\0\0\0\17\0\0\17\0\0\17\0\0\0\0\0\21\0\0\21\0\0\21\0\0\0\0\0\24" + "\0\0\24\0\0K\0\0\0\0\0T\0\0T\0\0T\0\0\0\0\0^\0\0^\0\0^\0\0\0\0\0g\0\0g\0" + "\0g\0\0\0\0\0q\0\0q\0\0\317\0\0\317\0\0\317\0\0\317\0\0\317\0\0\317\0\0\317" + "\0\0\317\0\0\317\0\0\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\4\0\0\4\0\0\4\0\0\0\0\0\11\0\0\11\0\0\11\0\0\0\0\0" + "\16\0\0\16\0\0\16\0\0\0\0\0\22\0\0\22\0\0\22\0\0\0\0\0\14\0\0\14\0\0\14\0" + "\0\0\0\0\17\0\0\17\0\0\17\0\0\0\0\0\21\0\0\21\0\0\21\0\0\0\0\0\24\0\0\24" + "\0\0\24\0\0\0\0\0T\0\0T\0\0T\0\0\0\0\0^\0\0^\0\0^\0\0\0\0\0g\0\0g\0\0g\0" + "\0\0\0\0q\0\0q\0\0q\0\0\317\0\0\317\0\0\317\0\0\317\0\0\317\0\0\317\0\0\317" + "\0\0\317\0\0\317\0\0\317\0\0\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\4\0\0\4\0\0\4\0\0\0\0\0\10\0\0\10\0\0\10\0\0\0\0\0\15" + "\0\0\15\0\0\15\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\16\0\0\16\0\0\16\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0J\0\0J\0\0J\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\317" + "\0\0\317\0\0\317\0\0\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\1\0\0\0\0\0\0\0\0\1\0\0\1\0\0\1\0\0\1" + "\0\0\4\0\0\4\0\0\0\0\0\0\0\0\7\0\0\7\0\0\0\0\0\0\0\0&\0\0&\0\0\32\0\0\32" + "\0\0&\0\0&\0\0&\0\0&\0\0C\0\0C\0\0\0\0\0\0\0\0^\0\0^\0\0\0\0\0\0\0\17\251" + "\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0\0\0\0\0" + "\0\0\0\317\0\0\317\0\0\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\6\2\0\6\2\0\0\1\0\0\0\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0" + "\17\0\0\0\0\0\4\0\0\11\0\0\11\0\0\0\0\6+\0\6+\0\0&\0\0\32\0\0&\0\0&\0\0&" + "\0\0&\0\0" + "5\0\0" + "5\0\2\210\0\0\0\0\0C\0\0|\0\0|\0\0\0\0\17\251\0\17\251" + "\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251" + "\0$\360\0$\360\0\0\0\0\0\317\0\0\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1" + "\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\1\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\6\2\0\6\2\0\6\2\0\0\0\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1" + "\0\0\1\0\0\0\0\0\17\0\0\17\0\0\4\0\0\0\0\6+\0\6+\0\6+\0\0\32\0\0&\0\0&\0" + "\0&\0\0&\0\0" + "5\0\0" + "5\0\0" + "5\0\0\0\0\2\210\0\2\210\0\0C\0\0\0\0\17\251\0" + "\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0\17\251\0" + "\17\251\0\17\251\0$\360\0$\360\0$\360\0\0\0\0\0\317\0\0\317\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\1\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "$\360\0$\360\0$\360\0$\360\0\0\0\0\0\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0" + "\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\14\1\0\14\1\0\14\1" + "\0\14\1\0\15\1\0\15\1\0\0\0\0\0\0\0\14\2\0\14\2\0\14\2\0\14\2\0\16\2\0\16" + "\2\0\0\0\0\0\0\0\14!\0\14!\0\14!\0\14!\0\17(\0\17(\0\0\0\0\0\0\0\14+\0\14" + "+\0\14+\0\14+\0\20" + "9\0\20" + "9\0\0\0\0\0\0\0\36\215\0\36\215\0\36\215\0\36" + "\215\0(\264\0(\264\0\0\0\0\0\0\0\36\251\0\36\251\0\36\251\0\36\251\0\36\251" + "\0\36\251\0\36\251\0\36\251\0\0\0\0\0\0\0$\360\0$\360\0$\360\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\1\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\36\3" + "\0\36\3\0\14\1\0\14\1\0\15\1\0\15\1\0\15\1\0\0\0\0\14\2\0\14\2\0\14\2\0\14" + "\2\0\16\2\0\16\2\0\16\2\0\0\0\0\14\3\0\14\3\0\14!\0\14!\0\17(\0\17(\0\17" + "(\0\0\0\0\14+\0\14+\0\14+\0\14+\0\20" + "9\0\20" + "9\0\20" + "9\0\0\0\0\14" + "7\0\14" + "" + "7\0\36\215\0\36\215\0(\264\0(\264\0(\264\0\0\0\0\36\251\0\36\251\0\36\251" + "\0\36\251\0\36\251\0\36\251\0\36\251\0\36\251\0\36\251\0\36\251\0H\360\0" + "H\360\0\0\0\0$\360\0$\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\1\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\36\3\0\36\3\0\36\3\0\14\1\0\15\1\0\15\1\0\15\1" + "\0\0\0\0\14\2\0\14\2\0\14\2\0\14\2\0\16\2\0\16\2\0\16\2\0\0\0\0\14\3\0\14" + "\3\0\14\3\0\14!\0\17(\0\17(\0\17(\0\0\0\0\14+\0\14+\0\14+\0\14+\0\20" + "9\0" + "\20" + "9\0\20" + "9\0\0\0\0\14" + "7\0\14" + "7\0\14" + "7\0\36\215\0(\264\0(\264\0(\264" + "\0\0\0\0\36\251\0\36\251\0\36\251\0\36\251\0\36\251\0\36\251\0\36\251\0\36" + "\251\0\36\251\0\36\251\0\36\251\0H\360\0H\360\0H\360\0\0\0\0$\360\0$\360" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\13\1\0\13\1\0\13\1\0\13\1\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\11!\0" + "\11!\0\11!\0\11!\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\23n\0\23n\0\23n\0\23n\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0H\360\0H\360\0H\360\0H\360\0\0\0\0$\360\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\1\0\1\1\0\0\0\0\0\0\0\0\0\0\0\0\0\25\0\0\25\0\0\25\0\0\27\0" + "\0\13\0\0\13\0\0\1\0\0\11\0\0\4\0\0\4\0\0\0\0\0\0\0\0\25\3\0\25\3\0\0\0\0" + "\0\0\0\25\3\0\25\3\0\25\3\0\25\3\0\3\1\0\3\1\0\2\1\0\7\5\0\7\3\0\7\3\0\0" + "\0\0\0\0\0\25" + "4\0\25" + "4\0\0\0\0\0\0\0\25" + "4\0\25" + "4\0\25" + "4\0\25" + "4\0\20" + "\35\0\20\35\0\11\22\0\23F\0\34" + "6\0\34" + "6\0\0\0\0\0\0\0L\317\0L\317\0L\317" + "\0L\317\0L\317\0L\317\0L\317\0L\317\0\0\0\0\0\0\0" + "2\317\0" + "2\317\0" + "2\317" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1\0\0\0\0\0\0\0\0\0\0\25\0\0\25" + "\0\0\25\0\0\4\0\0\5\0\0\2\0\0\1\0\0\4\0\0\14\0\0\14\0\0\0\0\0\37\7\0\37\7" + "\0\25\3\0\0\0\0\25\3\0\25\3\0\25\3\0\25\3\0\37\6\0\37\6\0\15\4\0\11\3\0\7" + "\3\0\14\10\0\14\10\0\0\0\0\25\16\0\25\16\0\25" + "4\0\0\0\0\25" + "4\0\25" + "4\0" + "\25" + "4\0\25" + "4\0&Q\0&Q\0&Q\0\31" + "5\0\34" + "6\0&j\0&j\0\0\0\0" + "5q\0" + "5q\0L\317" + "\0L\317\0L\317\0L\317\0L\317\0L\317\0L\317\0L\317\0L\317\0L\317\0\0\0\0" + "2" + "\317\0" + "2\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\1\1\0\0\0\0\0\0\0\25\0" + "\0\25\0\0\25\0\0\31\1\0\5\0\0\5\0\0\2\0\0\4\0\0\14\0\0\14\0\0\0\0\0\37\7" + "\0\37\7\0\37\7\0\0\0\0\25\3\0\25\3\0\25\3\0\25\3\0\37\6\0\37\6\0\37\6\0\11" + "\3\0\16\6\0\16\6\0\7\3\0\0\0\0\25\16\0\25\16\0\25\16\0\0\0\0\25" + "4\0\25" + "4" + "\0\25" + "4\0\25" + "4\0&Q\0&Q\0&Q\0\31" + "5\0+X\0+X\0\34" + "6\0\0\0\0" + "5q\0" + "5q\0" + "" + "5q\0L\317\0L\317\0L\317\0L\317\0L\317\0L\317\0L\317\0L\317\0L\317\0L\317" + "\0L\317\0\0\0\0" + "2\317\0" + "2\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0" + "\0\0\0\0\25\0\0\25\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0L\317\0L\317\0L\317\0L\317" + "\0\0\0\0" + "2\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0e\4\0e\4\0\0\0\0\0\0\0e\11\0e\11\0\0\0\0\0\0\0e\16\0e\16\0\0\0\0\0\0" + "\0G\11\0G\11\0\0\0\0\0\0\0G\14\0G\14\0\0\0\0\0\0\0G\17\0G\17\0\0\0\0\0\0" + "\0G\21\0G\21\0\0\0\0\0\0\0GK\0GK\0\0\0\0\0\0\0GT\0GT\0\0\0\0\0\0\0G^\0G^" + "\0\0\0\0\0\0\0Gg\0Gg\0\0\0\0\0\0\0e\317\0e\317\0e\317\0e\317\0e\317\0e\317" + "\0e\317\0e\317\0\0\0\0\0\0\0L\317\0L\317\0L\317\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0e\4\0e\4\0e\4\0\0\0\0e\11\0e\11\0e\11\0\0\0" + "\0e\16\0e\16\0e\16\0\0\0\0e\22\0e\22\0G\11\0\0\0\0G\14\0G\14\0G\14\0\0\0" + "\0G\17\0G\17\0G\17\0\0\0\0G\21\0G\21\0G\21\0\0\0\0G\24\0G\24\0GK\0\0\0\0" + "GT\0GT\0GT\0\0\0\0G^\0G^\0G^\0\0\0\0Gg\0Gg\0Gg\0\0\0\0Gq\0Gq\0e\317\0e\317" + "\0e\317\0e\317\0e\317\0e\317\0e\317\0e\317\0e\317\0e\317\0\0\0\0L\317\0L" + "\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0e\4\0e\4\0e\4\0\0\0" + "\0e\11\0e\11\0e\11\0\0\0\0e\16\0e\16\0e\16\0\0\0\0e\22\0e\22\0e\22\0\0\0" + "\0G\14\0G\14\0G\14\0\0\0\0G\17\0G\17\0G\17\0\0\0\0G\21\0G\21\0G\21\0\0\0" + "\0G\24\0G\24\0G\24\0\0\0\0GT\0GT\0GT\0\0\0\0G^\0G^\0G^\0\0\0\0Gg\0Gg\0Gg" + "\0\0\0\0Gq\0Gq\0Gq\0e\317\0e\317\0e\317\0e\317\0e\317\0e\317\0e\317\0e\317" + "\0e\317\0e\317\0e\317\0\0\0\0L\317\0L\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0e\4\0e\4\0e\4\0\0\0\0b\10\0b\10\0b\10\0\0\0\0b\15\0b\15\0b\15\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0<\16\0<\16\0<\16\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0" + "2J\0" + "2J\0" + "2J\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0e\317\0e\317\0e\317\0e" + "\317\0\0\0\0L\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\216\1\0c\0\0c\0\0\0\0\0" + "`\0\0c\0\0c\0\0\2\0\0c\1\0i\0\0i\0\0\0\0\0\0\0\0e\0\0e\0\0\0\0\0\0\0\0{\1" + "\0{\1\0f\0\0f\0\0z\1\0z\1\0z\1\0z\1\0)\4\0)\4\0\0\0\0\0\0\0Q\7\0Q\7\0\0\0" + "\0\0\0\0{&\0{&\0W\32\0W\32\0z&\0z&\0z&\0z&\0IC\0IC\0\0\0\0\0\0\0X^\0X^\0" + "\0\0\0\0\0\0\261\251\0\261\251\0\261\251\0\261\251\0\261\251\0\261\251\0" + "\261\251\0\261\251\0\0\0\0\0\0\0e\317\0e\317\0e\317\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\216\1\0c\0\0`\0\0\2\0\0c\0\0c\0\0c\0\0\12\0\0k\1\0i\0\0" + "\0\0\0\11\0\0i\0\0i\0\0\0\0\0\256\2\0\256\2\0{\1\0f\0\0z\1\0z\1\0z\1\0z\1" + "\0\221\1\0\221\1\0\221\17\0\0\0\0)\4\0c\11\0c\11\0\0\0\0\256+\0\256+\0{&" + "\0W\32\0z&\0z&\0z&\0z&\0\2415\0\2415\0\243\210\0\0\0\0IC\0{|\0{|\0\0\0\0" + "\261\251\0\261\251\0\261\251\0\261\251\0\261\251\0\261\251\0\261\251\0\261" + "\251\0\261\251\0\261\251\0\264\360\0\264\360\0\0\0\0e\317\0e\317\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\216\1\0\216\1\0`\0\0\2\0\0c\0\0c\0\0c\0\0\12\0\0" + "k\1\0k\1\0\0\0\0\11\0\0i\0\0i\0\0\0\0\0\256\2\0\256\2\0\256\2\0f\0\0z\1\0" + "z\1\0z\1\0z\1\0\221\1\0\221\1\0\221\1\0\0\0\0\221\17\0\221\17\0)\4\0\0\0" + "\0\256+\0\256+\0\256+\0W\32\0z&\0z&\0z&\0z&\0\2415\0\2415\0\2415\0\0\0\0" + "\243\210\0\243\210\0IC\0\0\0\0\261\251\0\261\251\0\261\251\0\261\251\0\261" + "\251\0\261\251\0\261\251\0\261\251\0\261\251\0\261\251\0\261\251\0\264\360" + "\0\264\360\0\264\360\0\0\0\0e\317\0e\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\216\1" + "\0\211\1\0c\0\0\2\0\0c\0\0c\0\0k\0\0\12\0\0k\1\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\264\360\0\264\360" + "\0\264\360\0\264\360\0\0\0\0e\317\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\211\1\0\216\1" + "\0c\0\0\2\0\0c\0\0k\0\0q\0\0\20\0\0\0\0\0\0\0\0\322\1\0\322\1\0\322\1\0\322" + "\1\0\346\1\0\346\1\0\0\0\0\0\0\0\322\2\0\322\2\0\322\2\0\322\2\0\363\2\0" + "\363\2\0\0\0\0\0\0\0\322!\0\322!\0\322!\0\322!\0\371(\0\371(\0\0\0\0\0\0" + "\0\322+\0\322+\0\322+\0\322+\0\3719\0\3719\0\0\0\0\0\0\0\325\215\0\325\215" + "\0\325\215\0\325\215\0\374\264\0\374\264\0\0\0\0\0\0\0\325\251\0\325\251" + "\0\325\251\0\325\251\0\325\251\0\325\251\0\325\251\0\325\251\0\0\0\0\0\0" + "\0\264\360\0\264\360\0\264\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\211\1\0\216" + "\1\0c\0\0\2\0\0f\0\0m\0\0m\0\0\0\0\0\325\3\0\325\3\0\322\1\0\322\1\0\346" + "\1\0\346\1\0\346\1\0\0\0\0\322\2\0\322\2\0\322\2\0\322\2\0\363\2\0\363\2" + "\0\363\2\0\0\0\0\322\3\0\322\3\0\322!\0\322!\0\371(\0\371(\0\371(\0\0\0\0" + "\322+\0\322+\0\322+\0\322+\0\3719\0\3719\0\3719\0\0\0\0\3227\0\3227\0\325" + "\215\0\325\215\0\374\264\0\374\264\0\374\264\0\0\0\0\325\251\0\325\251\0" + "\325\251\0\325\251\0\325\251\0\325\251\0\325\251\0\325\251\0\325\251\0\325" + "\251\0\330\360\0\330\360\0\0\0\0\264\360\0\264\360\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\216\1\0\216\1\0c\0\0\10\0\0m\0\0m\0\0\0\0\0\325\3\0\325\3\0\325" + "\3\0\322\1\0\346\1\0\346\1\0\346\1\0\0\0\0\322\2\0\322\2\0\322\2\0\322\2" + "\0\363\2\0\363\2\0\363\2\0\0\0\0\322\3\0\322\3\0\322\3\0\322!\0\371(\0\371" + "(\0\371(\0\0\0\0\322+\0\322+\0\322+\0\322+\0\3719\0\3719\0\3719\0\0\0\0\322" + "7\0\3227\0\3227\0\325\215\0\374\264\0\374\264\0\374\264\0\0\0\0\325\251\0" + "\325\251\0\325\251\0\325\251\0\325\251\0\325\251\0\325\251\0\325\251\0\325" + "\251\0\325\251\0\325\251\0\330\360\0\330\360\0\330\360\0\0\0\0\264\360\0" + "\264\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\216\1\0\216\1\0i\0\0\10\0\0m\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\275\1\0\275\1\0\275\1\0" + "\275\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\244!\0\244!\0\244!\0\244!\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\213n\0\213n\0\213n\0\213n\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\330\360\0\330\360\0\330\360\0\330" + "\360\0\0\0\0\264\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\216\1\0\224\1\0i\0\0\10\0" + "\0\0\0\0\0\0\0\325\3\0\325\3\0\325\3\0\351\3\0\365\1\0\365\1\0\14\0\0\313" + "\2\0#\2\0#\2\0\0\0\0\0\0\0\371\37\0\371\37\0\0\0\0\0\0\0\371\37\0\371\37" + "\0\371\37\0\371\37\0.\17\0.\17\0#\14\0\304-\0Y!\0Y!\0\0\0\0\0\0\0\371p\0" + "\371p\0\0\0\0\0\0\0\371p\0\371p\0\371p\0\371p\0O>\0O>\0" + "3(\0\247\227\0\211" + "s\0\211s\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" + "\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\330\360\0\330\360\0\330\360\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\0\0\224\1\0i\0\0\0\0\0\0\0\0\325\3\0\325" + "\3\0\325\3\0\17\2\0\"\2\0!\0\0\35\0\0#\2\0\342\4\0\342\4\0\0\0\0\371\37\0" + "\371\37\0\371\37\0\0\0\0\371\37\0\371\37\0\371\37\0\371\37\0\3775\0\3775" + "\0\374%\0\304\34\0Y!\0\373C\0\373C\0\0\0\0\371p\0\371p\0\371p\0\0\0\0\371" + "p\0\371p\0\371p\0\371p\0\377\256\0\377\256\0\377\256\0\247q\0\211s\0\375" + "\342\0\375\342\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" + "\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\0" + "\0\0\330\360\0\330\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\12\0\0\224\1\0\0\0" + "\0\0\0\0\325\3\0\325\3\0\325\3\0\344\5\0\"\2\0\"\2\0\200\0\0#\2\0\342\4\0" + "\342\4\0\0\0\0\371\37\0\371\37\0\371\37\0\0\0\0\371\37\0\371\37\0\371\37" + "\0\371\37\0\3775\0\3775\0\3775\0\304\34\0\3732\0\3732\0Y!\0\0\0\0\371p\0" + "\371p\0\371p\0\0\0\0\371p\0\371p\0\371p\0\371p\0\377\256\0\377\256\0\377" + "\256\0\247q\0\375\274\0\375\274\0\211s\0\0\0\0\374\360\0\374\360\0\374\360" + "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" + "\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\330\360\0\330\360\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\12\0\0\0\0\0i\0\0\0\0\0\325\3\0\325\3\0\344\5\0\344\5" + "\0\"\2\0\36\1\0" + "4\2\0#\2\0\342\4\0\0\0\0\371\37\0\371\37\0\371\37\0\0\0" + "\0\371\37\0\371\37\0\371\37\0\371\37\0\3775\0\3775\0\3775\0\307)\0\3732\0" + "\3732\0\3732\0\0\0\0\371p\0\371p\0\371p\0\0\0\0\371p\0\371p\0\371p\0\371" + "p\0\377\256\0\377\256\0\377\256\0\247q\0\375\274\0\375\274\0\375\274\0\0" + "\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" + "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" + "\374\360\0\374\360\0\0\0\0\330\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\12\0\0" + "\10\0\0\0\0\0\325\3\0\344\5\0\344\5\0\344\5\0\340\4\0\367\11\0\364\3\0#\2" + "\0\0\0\0\371\37\0\371\37\0\371\37\0\0\0\0\371\37\0\371\37\0\371\37\0\371" + "\37\0\3775\0\3775\0\3775\0\307)\0\376G\0\3732\0\3732\0\0\0\0\371p\0\371p" + "\0\371p\0\0\0\0\371p\0\371p\0\371p\0\371p\0\377\256\0\377\256\0\377\256\0" + "\247q\0\375\274\0\375\274\0\375\274\0\0\0\0\374\360\0\374\360\0\374\360\0" + "\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374" + "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\12\0\0\10\0\0\0\0\0\0\0\0\17\2\0\17" + "\2\0\17\2\0\323\2\0\352\7\0\347\2\0\26\1\0\0\0\0\371\37\0\371\37\0\371\37" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0/\26\0/\26\0/\26\0\0\0\0" + "7\36\0" + "6\25\0" + "" + "6\25\0\0\0\0\371p\0\371p\0\371p\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0O>\0O>\0" + "O>\0\0\0\0VK\0VK\0VK\0\0\0\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5\0\0\12\0" + "\0\10\0\0\0\0\0\17\2\0\17\2\0\344\5\0\15\1\0\352\7\0\352\7\0\347\2\0\0\0" + "\0\371\37\0\371\37\0\371\37\0\0\0\0\0\0\0\0\0\0\362\4\0\0\0\0/\26\0/\26\0" + "\3775\0$\21\0" + "7\36\0" + "7\36\0\3672\0\0\0\0\371p\0\371p\0\371p\0\0\0\0\0\0" + "\0\0\0\0\370A\0\0\0\0O>\0O>\0\377\256\0" + "3(\0VK\0VK\0\372\264\0\0\0\0\374" + "\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\341\271\0\0\0\0\374\360" + "\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\343\350\0\0\0\0\374\360\0\374" + "\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5\0\0\5\0\0\10\0\0\0\0" + "\0\17\2\0\17\2\0\17\2\0\15\1\0\352\7\0\352\7\0\347\2\0\0\0\0\371\37\0\371" + "\37\0\371\37\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0/\26\0/\26\0/\26\0$\21\0" + "7\36" + "\0" + "7\36\0" + "6\25\0\0\0\0\371p\0\371p\0\371p\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0O>\0O>\0O>\0" + "3(\0VK\0VK\0VK\0\0\0\0\374\360\0\374\360\0\374\360\0\374" + "\360\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\5\0\0\5\0\0\5\0\0\0\0\0\344\5\0\344\5\0\344\5\0\316\4\0\367" + "\11\0\367\11\0\364\3\0\0\0\0\371\37\0\371\37\0\371\37\0\0\0\0\371\37\0\371" + "\37\0\371\37\0\371\37\0\3775\0\3775\0\3775\0\307)\0\376G\0\376G\0\3732\0" + "\0\0\0\371p\0\371p\0\371p\0\0\0\0\371p\0\371p\0\371p\0\371p\0\377\256\0\377" + "\256\0\377\256\0\247q\0\375\274\0\375\274\0\375\274\0\0\0\0\374\360\0\374" + "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" + "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" + "\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5" + "\0\0\5\0\0\5\0\0\17\2\0\344\5\0\344\5\0\316\4\0\345\11\0\367\11\0\364\3\0" + "\0\0\0\371\37\0\371\37\0\371\37\0\0\0\0\371\37\0\371\37\0\371\37\0\371\37" + "\0\3775\0\3775\0\3775\0\307)\0\376G\0\376G\0\3732\0\0\0\0\371p\0\371p\0\371" + "p\0\0\0\0\371p\0\371p\0\371p\0\371p\0\377\256\0\377\256\0\377\256\0\247q" + "\0\375\274\0\375\274\0\375\274\0\0\0\0\374\360\0\374\360\0\374\360\0\374" + "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" + "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" + "\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5\0\0\5\0\0\0\0\0\17\2" + "\0\344\5\0\344\5\0\15\1\0$\6\0$\6\0#\2\0\0\0\0\371\37\0\371\37\0\371\37\0" + "\0\0\0\371\37\0\371\37\0\371\37\0\371\37\0\3775\0/\26\0/\26\0\307)\0\376" + "G\0[/\0Y!\0\0\0\0\371p\0\371p\0\371p\0\0\0\0\371p\0\371p\0\371p\0\371p\0" + "\377\256\0O>\0O>\0\247q\0\375\274\0\211s\0\211s\0\0\0\0\374\360\0\374\360" + "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" + "\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" + "\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5\0\0" + "\5\0\0\17\2\0\17\2\0\344\5\0\316\4\0$\6\0$\6\0#\2\0\0\0\0\371\37\0\371\37" + "\0\371\37\0\0\0\0\371\37\0\371\37\0\371\37\0\371\37\0\3775\0/\26\0/\26\0" + "\307)\0\376G\0[/\0Y!\0\0\0\0\371p\0\371p\0\371p\0\0\0\0\371p\0\371p\0\371" + "p\0\371p\0\377\256\0O>\0O>\0\247q\0\375\274\0\211s\0\211s\0\0\0\0\374\360" + "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" + "\374\360\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" + "\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\5\0\0\24\2\0\17\2\0\17\2\0\316\4\0\345\11\0$\6\0#\2\0\0\0\0\371" + "\37\0\371\37\0\371\37\0\0\0\0\371\37\0\371\37\0\371\37\0\371\37\0\3775\0" + "\3775\0\3775\0\307)\0\376G\0\376G\0\3732\0\0\0\0\371p\0\371p\0\371p\0\0\0" + "\0\371p\0\371p\0\371p\0\371p\0\377\256\0\377\256\0\377\256\0\247q\0\375\274" + "\0\375\274\0\375\274\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374" + "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" + "\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0" + "\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5\0\0\24\2\0\24" + "\2\0\17\2\0\316\4\0\345\11\0\342\3\0#\2\0\0\0\0\371\37\0\371\37\0\371\37" + "\0\0\0\0\371\37\0\371\37\0\371\37\0\371\37\0\3775\0\3775\0\3775\0\307)\0" + "\376G\0\3732\0\3732\0\0\0\0\371p\0\371p\0\371p\0\0\0\0\371p\0\371p\0\371" + "p\0\371p\0\377\256\0\377\256\0\377\256\0\247q\0\375\274\0\375\274\0\375\274" + "\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374" + "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" + "\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\17\2\0\24\2\0\5\0\0\0\0\0\27\5\0\342\3\0\313" + "\1\0\0\0\0\371\37\0\371\37\0\0\0\0\0\0\0\0\0\0\371\37\0\0\0\0\0\0\0/\26\0" + "\3775\0\371\37\0\302\30\0\3716\0Y!\0#\14\0\0\0\0\371p\0\371p\0\0\0\0\0\0" + "\0\0\0\0\371p\0\0\0\0\0\0\0O>\0\377\256\0\371p\0\243I\0\371\224\0\211s\0" + "" + "3(\0\0\0\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360\0\374" + "\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0" + "\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\17\2\0\17\2\0\0\0\0\0\0\0\26\1\0\26\1\0\0\0\0\0\0\0\371" + "\37\0\371\37\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0/\26\0/\26\0\0\0\0\0\0" + "\0" + "6\25\0" + "6\25\0\0\0\0\0\0\0\371p\0\371p\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0O>\0O>\0\0\0\0\0\0\0VK\0VK\0\0\0\0\0\0\0\374\360\0\374\360\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374" + "\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\17\2\0\17\2\0\0\0\0\0\0\0\26\1\0\26\1\0\0\0\0\0\0" + "\0\371\37\0\371\37\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0/\26\0/\26\0\0\0" + "\0\0\0\0" + "6\25\0" + "6\25\0\0\0\0\0\0\0\371p\0\371p\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0O>\0O>\0\0\0\0\0\0\0VK\0VK\0\0\0\0\0\0\0\374\360\0\374\360" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0" + "\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\17\2\0\17\2\0\16\0\0\0\0\0\26\1\0\26\1\0\26" + "\1\0\0\0\0\371\37\0\371\37\0\371\37\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0/\26\0" + "/\26\0.\17\0\0\0\0" + "6\25\0" + "6\25\0" + "6\25\0\0\0\0\371p\0\371p\0\371p\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0O>\0O>\0O>\0\0\0\0VK\0VK\0VK\0\0\0\0\374\360\0" + "\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\374\360\0\374\360" + "\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\16\0\0\16\0\0\14\0\0\14" + "\0\0#\2\0#\2\0\0\0\0\0\0\0\371\37\0\371\37\0\0\0\0\0\0\0\371\37\0\371\37" + "\0\371\37\0\371\37\0.\17\0.\17\0#\14\0#\14\0Y!\0Y!\0\0\0\0\0\0\0\371p\0\371" + "p\0\0\0\0\0\0\0\371p\0\371p\0\371p\0\371p\0O>\0O>\0" + "3(\0" + "3(\0\211s\0\211" + "s\0\0\0\0\0\0\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360\0\374\360" + "\0\374\360\0\374\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", }; /** @@ -2821,25 +2978,25 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAll = { */ SDL_Surface *SDLTest_ImageBlitBlendAll() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( - (void*)SDLTest_imageBlitBlendAll.pixel_data, + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + (void *)SDLTest_imageBlitBlendAll.pixel_data, SDLTest_imageBlitBlendAll.width, SDLTest_imageBlitBlendAll.height, SDLTest_imageBlitBlendAll.bytes_per_pixel * 8, SDLTest_imageBlitBlendAll.width * SDLTest_imageBlitBlendAll.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ + 0xff000000, /* Red bit mask. */ + 0x00ff0000, /* Green bit mask. */ + 0x0000ff00, /* Blue bit mask. */ + 0x000000ff /* Alpha bit mask. */ #else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ + 0x000000ff, /* Red bit mask. */ + 0x0000ff00, /* Green bit mask. */ + 0x00ff0000, /* Blue bit mask. */ + 0xff000000 /* Alpha bit mask. */ #endif - ); - return surface; + ); + return surface; } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/test/SDL_test_imageFace.c b/src/test/SDL_test_imageFace.c index 27f8c8463..cf9985c2a 100644 --- a/src/test/SDL_test_imageFace.c +++ b/src/test/SDL_test_imageFace.c @@ -25,197 +25,199 @@ /* GIMP RGBA C-Source image dump (face.c) */ static const SDLTest_SurfaceImage_t SDLTest_imageFace = { - 32, 32, 4, - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\0" - "\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0" - "\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\0\0\0\377\0\0\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\0\0\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\0\0\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\0\0\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\0\0\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\0\0\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\0\0\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\0\0\0\377" - "\377\377\377\0\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\0\0\0\377\0\0\0\377\377\377\377\0\0\0\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\0\0\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\0\0\0" - "\377\0\0\0\377\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\0\0\0\377\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0" - "\377\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0" - "\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0" - "\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\0\0\0\377\377\377\0\377\377\377\0\377\0\0\0\377\0\0\0\377" - "\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\0\0\0\377\0\0" - "\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\0\0\0\377\377\377\0\377\377\377\0\377\0\0\0\377\0\0\0\377\0\0\0\377" - "\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0" - "\0\0\377\0\0\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\0\0\0\377\377\377\0\377\377" - "\377\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0" - "\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\377\377\0\377\377\377\0\377\0\0\0" - "\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\0\0\0\377\0\0\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\0\0\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\0\0\0\377\0\0\0\377\0\0\0\377\0\0" - "\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0", + 32, + 32, + 4, + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\0" + "\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0" + "\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\0\0\0\377\0\0\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\0\0\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\0\0\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\0\0\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\0\0\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\0\0\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\0\0\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\0\0\0\377" + "\377\377\377\0\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\0\0\0\377\0\0\0\377\377\377\377\0\0\0\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\0\0\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\0\0\0" + "\377\0\0\0\377\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\0\0\0\377\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0" + "\377\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0" + "\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0" + "\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\0\0\0\377\377\377\0\377\377\377\0\377\0\0\0\377\0\0\0\377" + "\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\0\0\0\377\0\0" + "\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\0\0\0\377\377\377\0\377\377\377\0\377\0\0\0\377\0\0\0\377\0\0\0\377" + "\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0" + "\0\0\377\0\0\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\0\0\0\377\377\377\0\377\377" + "\377\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0" + "\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\377\377\0\377\377\377\0\377\0\0\0" + "\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\0\0\0\377\0\0\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\0\0\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\0\0\0\377\0\0\0\377\0\0\0\377\0\0" + "\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" + "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" + "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" + "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" + "\377\377\0\377\377\377\0", }; /** @@ -223,25 +225,25 @@ static const SDLTest_SurfaceImage_t SDLTest_imageFace = { */ SDL_Surface *SDLTest_ImageFace() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( - (void*)SDLTest_imageFace.pixel_data, + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + (void *)SDLTest_imageFace.pixel_data, SDLTest_imageFace.width, SDLTest_imageFace.height, SDLTest_imageFace.bytes_per_pixel * 8, SDLTest_imageFace.width * SDLTest_imageFace.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ + 0xff000000, /* Red bit mask. */ + 0x00ff0000, /* Green bit mask. */ + 0x0000ff00, /* Blue bit mask. */ + 0x000000ff /* Alpha bit mask. */ #else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ + 0x000000ff, /* Red bit mask. */ + 0x0000ff00, /* Green bit mask. */ + 0x00ff0000, /* Blue bit mask. */ + 0xff000000 /* Alpha bit mask. */ #endif - ); - return surface; + ); + return surface; } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/test/SDL_test_imagePrimitives.c b/src/test/SDL_test_imagePrimitives.c index 20e95d662..fe58c2e8a 100644 --- a/src/test/SDL_test_imagePrimitives.c +++ b/src/test/SDL_test_imagePrimitives.c @@ -25,464 +25,480 @@ /* GIMP RGB C-Source image dump (primitives.c) */ static const SDLTest_SurfaceImage_t SDLTest_imagePrimitives = { - 80, 60, 3, - "\5ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15" - "I\310\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310" - "\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310\0" - "\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310\0\0" - "\0\5ii\0\0\0\5ii\0\0\0\3\1\1\0\0\0\5\2\1\0\0\0\7\3\2\0\0\0\11\4\3\0\0\0\13" - "\5\3\0\0\0\15\6\4\0\0\0\17\7\5\0\0\0\21\10\5\0\0\0\23\11\6\0\0\0\25\12\7" - "\0\0\0\27\13\7\0\0\0\31\14\10\0\0\0\33\15\11\0\0\0\35\16\11\0\0\0\37\17\12" - "\0\0\0!\20\13\0\0\0#\21\13\0\0\0%\22\14\0\0\0'\23\15\15I\310)\24\15\15I\310" - "+\25\16\15I\310-\26\17\15I\310/\27\17\15I\3101\30\20\15I\3103\31\21\15I\310" - "5\32\21\15I\3107\33\22\15I\3109\34\23\15I\310;\35\23\15I\310=\36\24\15I\310" - "?\37\25\15I\310A\40\25\15I\310C!\26\15I\310E\"\27\15I\310G#\27\15I\310I$" - "\30\15I\310K%\31\15I\310M&\31\5iiO'\32\0\0\0\0\0\0\5ii\0\0\0\10\4\2\0\0\0" - "\14\6\4\0\0\0\20\10\5\0\0\0\24\12\6\0\0\0\30\14\10\0\0\0\34\16\11\0\0\0\40" - "\20\12\0\0\0$\22\14\0\0\0(\24\15\0\0\0,\26\16\0\0\0""0\30\20\0\0\0""4\32" - "\21\0\0\0""8\34\22\0\0\0<\36\24\0\0\0@\40\25\0\0\0D\"\26\0\0\0H$\30\0\0\0" - "L&\31\0\0\0P(\32\15I\310T*\34\15I\310X,\35\15I\310\\.\36\15I\310`0\40\15" - "I\310d2!\15I\310h4\"\15I\310l6$\15I\310p8%\15I\310t:&\15I\310x<(\15I\310" - "|>)\15I\310\200@*\15I\310\204B,\15I\310\210D-\15I\310\214F.\15I\310\220H" - "0\15I\310\224J1\15I\310\230L2\5ii\234N4\15I\310\0\0\0\0\0\0\0\0\0\5ii\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\5ii" - "\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\5ii\15I\310\15I\310\15I\310\15I\310" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\5ii\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\5ii\15I\310\15I\310\15I\310" - "\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5ii\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\5ii\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\5ii\15I\310\15I\310" - "\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\5ii\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" - "\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d" - "\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\5ii\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\5ii\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d" - "\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310" - "\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\5ii\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310" - "\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" - "\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310" - "\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d" - "\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" - "\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d" - "\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" - "\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" - "\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310" - "\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5" - "ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d" - "\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" - "\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d" - "\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310" - "\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" - "\15I\310\15I\310\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0" - "\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0" - "\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0" - "\0\377\0\0\377\0\0\377\0\0\377\0\5ii\0\377\0\0\377\0\0\377\0\0\377\0\0\377" - "\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0""77\5\0\377\0\0\377\0\0\377\0" - "\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\5ii\0\377\0\0\377\0\0\377" - "\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377" - "\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377" - "\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5" - "ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d" - "\310\0d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" - "\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" - "\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310" - "\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" - "\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" - "\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5i" - "i\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310" - "\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" - "\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310" - "\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310" - "\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\5ii\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310" - "\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" - "\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\15I\310\15I\310\15I\310" - "\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\5ii\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\5ii\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" - "I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d7" - "7\5\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" - "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" - "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\15I\310\15I\310" - "\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0""77\5\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\5ii\15I\310\15I\310\15I\310\15I\310" - "\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0""77\5\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\5ii\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" - "\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5ii\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0""77\5\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\5ii\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0""77\5\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\5ii\15I\310" - "\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5" - "ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0""77\5\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\5ii\15I\310\15I\310\15I\310" - "\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0""77\5\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\5ii\15I\310\15I\310\15I\310\15I\310\0\0\0\0" - "\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0""77\5\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\5ii\15I\310\15I\310\15I\310\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0""77\5\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\5ii" - "\15I\310\15I\310\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0""77\5\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\5ii\15I\310\5ii\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0""77\5\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" - "\310\15I\310\15I\310\15I\310\15I\310\5ii", + 80, + 60, + 3, + "\5ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15" + "I\310\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310" + "\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310\0" + "\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310\0\0\0\15I\310\0\0" + "\0\5ii\0\0\0\5ii\0\0\0\3\1\1\0\0\0\5\2\1\0\0\0\7\3\2\0\0\0\11\4\3\0\0\0\13" + "\5\3\0\0\0\15\6\4\0\0\0\17\7\5\0\0\0\21\10\5\0\0\0\23\11\6\0\0\0\25\12\7" + "\0\0\0\27\13\7\0\0\0\31\14\10\0\0\0\33\15\11\0\0\0\35\16\11\0\0\0\37\17\12" + "\0\0\0!\20\13\0\0\0#\21\13\0\0\0%\22\14\0\0\0'\23\15\15I\310)\24\15\15I\310" + "+\25\16\15I\310-\26\17\15I\310/\27\17\15I\3101\30\20\15I\3103\31\21\15I\310" + "5\32\21\15I\3107\33\22\15I\3109\34\23\15I\310;\35\23\15I\310=\36\24\15I\310" + "?\37\25\15I\310A\40\25\15I\310C!\26\15I\310E\"\27\15I\310G#\27\15I\310I$" + "\30\15I\310K%\31\15I\310M&\31\5iiO'\32\0\0\0\0\0\0\5ii\0\0\0\10\4\2\0\0\0" + "\14\6\4\0\0\0\20\10\5\0\0\0\24\12\6\0\0\0\30\14\10\0\0\0\34\16\11\0\0\0\40" + "\20\12\0\0\0$\22\14\0\0\0(\24\15\0\0\0,\26\16\0\0\0" + "0\30\20\0\0\0" + "4\32" + "\21\0\0\0" + "8\34\22\0\0\0<\36\24\0\0\0@\40\25\0\0\0D\"\26\0\0\0H$\30\0\0\0" + "L&\31\0\0\0P(\32\15I\310T*\34\15I\310X,\35\15I\310\\.\36\15I\310`0\40\15" + "I\310d2!\15I\310h4\"\15I\310l6$\15I\310p8%\15I\310t:&\15I\310x<(\15I\310" + "|>)\15I\310\200@*\15I\310\204B,\15I\310\210D-\15I\310\214F.\15I\310\220H" + "0\15I\310\224J1\15I\310\230L2\5ii\234N4\15I\310\0\0\0\0\0\0\0\0\0\5ii\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\5ii" + "\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\5ii\15I\310\15I\310\15I\310\15I\310" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\5ii\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\5ii\15I\310\15I\310\15I\310" + "\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5ii\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\5ii\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\5ii\15I\310\15I\310" + "\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\5ii\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" + "\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d" + "\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\5ii\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\5ii\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d" + "\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310" + "\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\5ii\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310" + "\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" + "\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310" + "\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d" + "\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" + "\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d" + "\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" + "\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" + "\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310" + "\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5" + "ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d" + "\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" + "\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d" + "\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310" + "\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" + "\15I\310\15I\310\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0" + "\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0" + "\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0" + "\0\377\0\0\377\0\0\377\0\0\377\0\5ii\0\377\0\0\377\0\0\377\0\0\377\0\0\377" + "\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0" + "77\5\0\377\0\0\377\0\0\377\0" + "\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\5ii\0\377\0\0\377\0\0\377" + "\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377" + "\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377" + "\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\377\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5" + "ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d" + "\310\0d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" + "\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" + "\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310" + "\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" + "\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" + "\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5i" + "i\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310" + "\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" + "\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310" + "\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\15I\310\15I\310\15I\310\15I\310" + "\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\310\0d\310\0d\5ii\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310" + "\0d\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" + "\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\310\0d\310\0d\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d77\5\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\5ii\310\0d\310\0d\15I\310\15I\310\15I\310" + "\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\0d\5ii\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d77\5\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\5ii\310\0d\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15" + "I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\5ii\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d7" + "7\5\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0" + "d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310" + "\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\310\0d\5ii\15I\310\15I\310" + "\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0" + "77\5\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\5ii\15I\310\15I\310\15I\310\15I\310" + "\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "77\5\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\5ii\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310" + "\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5ii\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "77\5\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\5ii\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0" + "77\5\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\5ii\15I\310" + "\15I\310\15I\310\15I\310\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5" + "ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "77\5\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\5ii\15I\310\15I\310\15I\310" + "\15I\310\15I\310\0\0\0\0\0\0\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "77\5\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\5ii\15I\310\15I\310\15I\310\15I\310\0\0\0\0" + "\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0" + "77\5\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\5ii\15I\310\15I\310\15I\310\0\0\0\0\0\0\5ii\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "77\5\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\5ii" + "\15I\310\15I\310\0\0\0\5ii\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "77\5\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\5ii\15I\310\5ii\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0" + "77\5\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I\310\15I" + "\310\15I\310\15I\310\15I\310\15I\310\5ii", }; /** @@ -490,25 +506,25 @@ static const SDLTest_SurfaceImage_t SDLTest_imagePrimitives = { */ SDL_Surface *SDLTest_ImagePrimitives() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( - (void*)SDLTest_imagePrimitives.pixel_data, + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + (void *)SDLTest_imagePrimitives.pixel_data, SDLTest_imagePrimitives.width, SDLTest_imagePrimitives.height, SDLTest_imagePrimitives.bytes_per_pixel * 8, SDLTest_imagePrimitives.width * SDLTest_imagePrimitives.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ + 0xff000000, /* Red bit mask. */ + 0x00ff0000, /* Green bit mask. */ + 0x0000ff00, /* Blue bit mask. */ + 0x000000ff /* Alpha bit mask. */ #else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ + 0x000000ff, /* Red bit mask. */ + 0x0000ff00, /* Green bit mask. */ + 0x00ff0000, /* Blue bit mask. */ + 0xff000000 /* Alpha bit mask. */ #endif - ); - return surface; + ); + return surface; } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/test/SDL_test_imagePrimitivesBlend.c b/src/test/SDL_test_imagePrimitivesBlend.c index 5997f9c35..e214f8abc 100644 --- a/src/test/SDL_test_imagePrimitivesBlend.c +++ b/src/test/SDL_test_imagePrimitivesBlend.c @@ -25,646 +25,653 @@ /* GIMP RGB C-Source image dump (alpha.c) */ static const SDLTest_SurfaceImage_t SDLTest_imagePrimitivesBlend = { - 80, 60, 3, - "\260e\15\222\356/\37\313\15\36\330\17K\3745D\3471\0\20\0D\3502D\3502<\321" - ",\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0-\0\377\377" - "\377\377\377\377\311\324\311\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\0H\0\377\377\377\377\377\377\256\307\256\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\0c\0\377\377\377\377\377\377" - "\223\300\223\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\0~\0\377\377\377\377\377\377x\277x\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\0\231\0\377\377\377\377\377\377]\303]\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\0\264\0\377\377\377\377\377" - "\377B\316B\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0" - "\317\0\377\377\377\377\377\377'\335'\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\0\352\0\377\377\377#\262\6\260d\15\260e\15\224\357" - "/&\262\6\34\300\5.\314\22\40\315\12[\3747M\332/\27\331\12\27\331\12K\374" - "5K\3745K\3745D\3471D\3471D\3471D\3471D\3471D\3502D\3502D\3502D\3502D\350" - "2D\3502D\3502D\3502D\3502D\3502\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377,\372\27\273\3465\327" - "Q.\260d\15\213\213\40\241\3601\200\366*=\265\13?\301\25s\375\265\14\177\252+\201\210\16\245\204" - "*\377\314U\312\\,\224'\11\260i\17\244\210\40\232\2211\331\353J\215\2351\377" - "\377\276\200\2521\200\2542\375\377\310u\2661t\2702t\2702\367\377\324\325" - "\355\305h\3021h\3042h\3042\377\377\377\377\377\377\364\377\336\335\364\323" - "\335\364\323\335\364\323\\\3202\\\3202\\\3202\\\3202\\\3202\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\346\371\342\346\371\342\346" - "\371\342\346\371\342\346\371\342\346\371\342\346\371\342\377\377\377\377" - "\377\377P\3342P\3342P\3342P\3342P\3342P\3342P\3342P\3342\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\27\331\12Y\316-h\3021\243\370Cg\230\15\230\224\"\245" - "\204*\377\314U\310J\21\327Q.\260b\21\245\2041\370\343N\230\2242\331\353J" - "\214\2402\377\377\276\200\2521\200\2542\375\377\310\317\344\266u\2661t\270" - "2\377\377\377\367\377\324\325\355\305h\3021h\3042h\3042h\3042\377\377\377" - "\377\377\377\364\377\336\335\364\323\335\364\323\335\364\323\335\364\323" - "\\\3202\\\3202\\\3202\\\3202\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\346\371\342\346\371" - "\342\346\371\342\346\371\342\346\371\342\346\371\342\377\377\377\377\377" - "\377\377\377\377\377\377\377P\3342P\3342P\3342P\3342P\3342P\3342P\3342P\334" - "2\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377K\3745!\315\13d\304,p\270)\177\252+\23\13\6\232\2211\245\204" - "1\347\270O\377\277Y\324<\22\265V\24\377\330Q\244\210\40#(\13\230\224\"\331" - "\353Ju\211.\377\377\276\200\2521\210\273:\200\2542\375\377\310\20""3\6u\266" - "1t\2702\271\307\271\367\377\324\325\355\305\341\377\321h\3021h\3042\16L\7" - "h\3042\377\377\377\242\300\242\377\377\377\335\364\323\355\377\343\335\364" - "\323\335\364\323\14f\7\\\3202\\\3202>\250*\\\3202\377\377\377\377\377\377" - "\377\377\377\377\377\377$\231$\377\377\377\377\377\377s\303s\377\377\377" - "\346\371\342\376\377\372\346\371\342\346\371\342\40\257\37\346\371\342\346" - "\371\342\\\316\\\377\377\377\377\377\377\377\377\377\377\377\377P\3342\13" - "\262\7P\3342P\3342*\327%P\3342P\3342o\377Q\377\377\377\377\377\377$\352$" - "\377\377\377\377\377\377K\3745]\3749s\375<\212\373@\243\370C\274\363G\331" - "\353J\370\343N\377\330Q\377\314U\377\277Y\377\260\\\224(\11\260|\36\245\204" - "1\377\377\250\232\2211\230\224\"\215\2351\214\2402\377\377\276\312\332\250" - "\200\2521\200\2542\377\377\377\317\344\266u\2661t\2702t\2702\377\377\377" - "\377\377\377\325\355\305\325\355\305\325\355\305h\3042h\3042h\3042\377\377" - "\377\377\377\377\377\377\377\377\377\377\335\364\323\335\364\323\335\364" - "\323\335\364\323\335\364\323\\\3202\\\3202\\\3202\\\3202\\\3202\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\346\371\342\346\371\342" - "\346\371\342\346\371\342\346\371\342\346\371\342\346\371\342\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377P\3342P\3342" - "P\3342P\3342\377\377\377K\3745O\3321\\\3161h\3021t\2702~\254'\214\240%\377" - "\377\262\370\343N\377\330Q\262x1\277l1\312`1\327R.\260X\23\377\330Q\244\210" - "2\377\377\250\230\2242\377\377\262\215\2351\214\2402\377\377\377\312\332" - "\250\200\2521\200\2542\377\377\377\375\377\310\317\344\266u\2661t\2702t\270" - "2\377\377\377\377\377\377\325\355\305\325\355\305\325\355\305h\3042h\304" - "2h\3042h\3042\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\335\364\323\335\364\323\335\364\323\335\364\323\377\377\377\\\3202\\\320" - "2\\\3202\\\3202\\\3202\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\346\371\342\346\371\342\346\371\342\346" - "\371\342\346\371\342\346\371\342\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377D\3471O\3321\21\7\11c\304+\367\377\324o\2520\200\252" - "1\214\2402\235\226'\377\377\250\377\330Q!\20\11\277l1\310d2\266?\33\224(" - "\11\260|\36\257\217;\377\377\250\232\2211\34$\11\377\377\262\215\2351q\206" - "0\377\377\377\312\332\250\217\303@\200\2542\200\25420Z0\317\344\266\317\344" - "\266X\2260t\2702t\2702\377\377\377\377\377\377\325\355\305(l%\325\355\305" - "\325\355\305K\2410h\3042h\3042\377\377\377\377\377\377\377\377\3770\2200" - "\377\377\377\377\377\377t\274p\335\364\323\335\364\323\373\377\361\377\377" - "\377\377\377\377\21\213\11\\\3202\\\3202<\274/\\\3202\377\377\377\377\377" - "\377\377\377\377\377\377\3770\3060\377\377\377\377\377\377V\330V\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\3770\3410\346\371\342\346" - "\371\342>\352>\346\371\342\377\377\377D\3471P\3342\364\377\352s\375\3369\\\3202\377\377\377\377\377\377\377\377\377\377\377\377D\3502\371\377" - "\364O\3321\\\3202\364\377\336h\3042\367\377\324u\2661\200\2542\377\377\276" - "\215\2351\230\2242\307\300\213\244\2102\377\377\234\262x1\274p2\377\337\207" - "\312`1\324E\30\327T1\260|2\377\377\234\245\2041\244\2102\377\377\250\232" - "\2211\230\2242\377\377\377\310\316\231\215\2351\214\2402\377\377\377\377" - "\377\377\312\332\250\312\332\250\200\2542\200\2542\377\377\377\377\377\377" - "\317\344\266\317\344\266\317\344\266t\2702t\2702t\2702\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\325\355\305\325\355\305\325\355" - "\305\377\377\377h\3042h\3042h\3042h\3042\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\335\364\323\335\364\323\335\364\323\335\364\323\377\377\377\377\377" - "\377\377\377\377\377\377\377\\\3202\\\3202\\\3202\377\377\377D\3502\371\377" - "\364O\3321\377\377\377\\\3161h\3042\367\377\324t\2702\375\377\310\200\252" - "1\377\377\377\215\2351\230\2242\377\377\250\244\2102\377\377\234\262x1\274" - "p2\316\214_\310d2\377\310|\327T1\227/\14\377\377\377\307\260|\244\2102\377" - "\377\377\307\300\213\230\2242\230\2242\377\377\377\310\316\231\214\2402\214" - "\2402\377\377\377\377\377\377\312\332\250\312\332\250\200\2542\200\2542\377" - "\377\377\377\377\377\377\377\377\317\344\266\317\344\266\317\344\266t\270" - "2t\2702t\2702\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\325\355\305\325\355\305\325\355\305\377\377\377\377\377\377h\3042h\3042" - "h\3042\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\335\364\323\335\364" - "\323\335\364\323\335\364\323\377\377\377\377\377\377\377\377\377\377\377" - "\377D\3502\371\377\364R\3344\364\377\352\\\3161H\22Hh\3021\377\377\377o\244" - "2\200\2542\312\332\250\226\245<\377\377\262\230\2242H-/\245\2041\377\377" - "\377\233i5\274p2\277l1\331sC\377\310|\324X2*\15\3\260|2\377\377\234\206s" - "7\244\2102\377\377\250\340\337\244\230\2242\377\377\377Hc2\310\316\231\214" - "\2402n\211:\377\377\377\377\377\377\353\377\311\312\332\250\200\2542$T\16" - "\377\377\377\377\377\377\236\277\236\377\377\377\317\344\266\367\377\336" - "\377\377\377t\2702\40n\16t\2702\377\377\377\212\303\212\377\377\377\377\377" - "\377\377\377\377\325\355\305\325\355\305<\2477\377\377\377\377\377\377O\276" - "Ah\3042h\3042\237\377i\377\377\377\377\377\377H\317H\377\377\377\377\377" - "\377c\335c\377\377\377\377\377\377\377\377\377\377\377\377\335\364\323>\337" - ";\335\364\323\377\377\377D\3502\362\375\360P\3342\346\371\342\\\3202\364" - "\377\336h\3042\367\377\324t\2702\375\377\310\200\2542\377\377\276\214\240" - "2\377\377\262\232\2211\377\377\377\245\2041\377\377\377\262x1\377\377\377" - "\277l1\310d2\312`1\324X2\327T1\260|2\377\377\377\307\260|\244\2102\377\377" - "\377\307\300\213\232\2211\230\2242\377\377\377\377\377\262\310\316\231\214" - "\2402\214\2402\377\377\377\377\377\377\312\332\250\312\332\250\200\2542\200" - "\2542\200\2542\377\377\377\377\377\377\377\377\377\317\344\266\317\344\266" - "\317\344\266\377\377\377t\2702t\2702t\2702\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\325\355\305\325\355\305\325\355\305\325\355" - "\305\377\377\377\377\377\377h\3042h\3042h\3042h\3042\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377D\3502\362\375\360P\3342\346\371\342\\\3202\335" - "\364\323h\3042\325\355\305t\2702\317\344\266\377\377\377\200\2521\377\377" - "\377\215\2351\377\377\377\232\2211\377\377\377\245\2041\377\377\377\262x" - "1\377\377\377\277l1\377\377\377\312`1\377\310|\327T1\227/\14\377\377\377" - "\307\260|\244\2102\244\2102\377\377\377\307\300\213\230\2242\230\2242\377" - "\377\377\310\316\231\310\316\231\214\2402\214\2402\377\377\377\377\377\377" - "\312\332\250\312\332\250\377\377\377\200\2542\200\2542\377\377\377\377\377" - "\377\377\377\377\377\377\377\317\344\266\317\344\266\377\377\377\377\377" - "\377t\2702t\2702\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\325\355\305\325\355\305\325\355\305\377\377" - "\377\377\377\377\377\377\377h\3042h\3042h\3042\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377D\3502\362\375\360" - "T\11TO\3321\377\377\377Z\3002\377\377\377h\3042\377\377\334t\2702\375\377" - "\310*\30\20\312\332\250\214\2402\262\260\214\230\2242\307\300\213\377\377" - "\377\245\2041\377\377\377:\35\20\377\377\377\277l1\316\264w\310d2\377\310" - "|\356qL\227/\14\260|2TZ3\307\260|\244\2102\274\302\274\307\300\213\307\300" - "\213\273\301U\377\377\377\377\377\377A^2\310\316\231\214\2402o\216B\377\377" - "\377\377\377\377\366\377\324\312\332\250\312\332\250*a\20\200\2542\377\377" - "\377\230\301\230\377\377\377\377\377\377\377\377\353\317\344\266\317\344" - "\266T\253Tt\2702t\2702]\265I\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377T\306T\377\377\377\325\355\305l\324i\325\355\305\377\377" - "\377\377\377\377\377\377\377h\3042\"\254\20h\3042h\3042b\353b\377\377\377" - "\377\377\377D\3502\362\375\360\377\377\377O\3321\377\377\377\\\3202\364\377" - "\336h\3042\325\355\305t\2702\317\344\266\377\377\377\200\2521\377\377\377" - "\214\2402\377\377\262\230\2242\307\300\213\244\2102\307\260|\377\377\377" - "\262x1\377\377\377\274p2\377\337\207\310d2\377\310|\324X2\333bB\260|2\377" - "\377\377\307\260|\244\2102\244\2102\377\377\377\307\300\213\232\2211\230" - "\2242\377\377\377\377\377\377\310\316\231\310\316\231\214\2402\214\2402\377" - "\377\377\377\377\377\377\377\377\312\332\250\312\332\250\200\2542\200\254" - "2\200\2542\377\377\377\377\377\377\377\377\377\377\377\377\317\344\266\317" - "\344\266\317\344\266\377\377\377t\2702t\2702t\2702\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\325\355\305" - "\325\355\305\325\355\305\325\355\305\377\377\377\377\377\377\377\377\377" - "h\3042h\3042\377\377\377\377\377\377D\3471\377\377\377P\3342\364\377\352" - "\\\3202\335\364\323\377\377\377h\3021\377\377\377t\2702\375\377\310\200\254" - "2\312\332\250\377\377\377\215\2351\377\377\377\230\2242\377\377\250\244\210" - "2\307\260|\377\377\377\262x1\377\377\377\274p2\377\337\207\310d2\323xQ\324" - "X2\327T1\227/\14\260|2\377\377\234\307\260|\244\2102\377\377\377\377\377" - "\377\307\300\213\230\2242\230\2242\377\377\377\377\377\377\310\316\231\310" - "\316\231\214\2402\214\2402\377\377\377\377\377\377\377\377\377\312\332\250" - "\312\332\250\377\377\377\200\2542\200\2542\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\317\344\266\317\344\266\377\377\377\377\377" - "\377t\2702t\2702t\2702\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\325\355\305\325\355\305\325" - "\355\305\377\377\377\377\377\377`\0`\377\377\377D\3471\371\366\371P\3342" - "\346\371\342\377\377\377\\\3161\377\377\377'\24\22\325\355\305t\2702\276" - "\310\251\377\377\377\200\2542\377\377\316\214\2402\310\316\231`6`\230\224" - "2\377\377\250\222u<\307\260|\377\377\377\315\214L\377\377\377\274p2M,#\310" - "d2\312`1\306\304\306\324X2\333bB\325\242W\377\377\377\307\260|=9\22\244\210" - "2\377\377\377\227\234w\307\300\213\230\2242\307\322a\377\377\377\377\377" - "\377Km9\310\316\231\214\2402r\226K\377\377\377\377\377\377\377\377\377\312" - "\332\250\312\332\250`\242`\200\2542\200\2542\224\306\224\377\377\377\377" - "\377\377\377\377\377\377\377\377\317\344\266M\250D\317\344\266\377\377\377" - "\203\322\203t\2702t\2702\301\377\177\377\377\377\377\377\377`\330`\377\377" - "\377\377\377\377r\344r\377\377\377\377\377\377\377\377\377\325\355\305\377" - "\377\377\377\377\377D\3502\371\377\364P\3342\346\371\342\377\377\377\\\320" - "2\364\377\336h\3042\325\355\305\377\377\377t\2702\317\344\266\200\2542\312" - "\332\250\377\377\377\214\2402\310\316\231\230\2242\307\300\213\377\377\377" - "\244\2102\307\260|\377\377\377\200U0\220^\377\7\4/\227U[\246]\377\255Q1\377" - "\242y\10\3/\306M@\6\4/{^\377mVvmVv\6\5/h\\\377h\\\377\\U\204\12\12\360\5" - "\5/VX\377VX\377\12\12\360LR\221\12\12\360\5\6/\214\2402\377\377\377\377\377" - "\377\377\377\377\312\332\250\312\332\250\377\377\377\200\2542\200\2542\200" - "\2542\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\317\344" - "\266\317\344\266\317\344\266\377\377\377\377\377\377t\2702t\2702\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377D\3502\362\375\360P\3342\346\371" - "\342\377\377\377\\\3202\335\364\323\377\377\377h\3042\367\377\324t\2702\317" - "\344\266\377\377\377\200\2542\312\332\250\377\377\377\214\2402\377\377\262" - "\230\2242\307\300\213\377\377\377\244\2102\307\260|{^\377\200U0\220^\377" - "\7\4/\227U[\246]\377\7\3/\377\242y\236\37""2\306M0\210%\14T-2{^\377mVv\6" - "\5/\6\5/h\\\377\\U\204\\U\204\5\5/\5\5/VX\377VX\377LR\221LR\221\377\377\377" - "\214\2402\214\2402\377\377\377\377\377\377\377\377\377\312\332\250\312\332" - "\250\312\332\250\377\377\377\200\2542\200\2542\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\317\344\266\317\344\266\377" - "\377\377\377\377\377t\2702t\2702t\2702\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377D\3502\365\375\363\377\377" - "\377O\3321l\22l\\\3202\335\364\323\357\346\357h\3042\325\355\305\377\377" - "\377t\2702\317\344\266l-l\200\2521\377\377\377\204\211=\310\316\231\377\377" - "\377\262\243L\307\300\213\377\377\377E&\25mVv{^\377ySB\220^\377\7\4/\275" - "t\201\246]\377\7\3/I\37!\277Z\377\10\3/\237YQ\6\4/{^\377\236\213\247mVv\6" - "\5/,-lh\\\377\\U\204dow\5\5/\5\5/\222\251\377VX\377\310\316\231T{@\377\377" - "\377\214\2402w\240V\377\377\377\377\377\377\377\377\377\377\377\377\312\332" - "\250U\231G\377\377\377\200\2542q\270\\\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377l\317l\317\344\266\317\344\266z\330v\377\377\377" - "\377\377\377\323\377\221t\2702t\2702l\352l\377\377\377\377\377\377\377\377" - "\377D\3502\362\375\360\377\377\377P\3342\346\371\342\377\377\377\\\3202\364" - "\377\336h\3042\325\355\305\377\377\377t\2702\317\344\266\377\377\377\200" - "\2542\312\332\250\377\377\377\214\2402\310\316\231\377\377\377\230\2242\307" - "\300\213\377\377\377\6\5/mVv{^\377\200U0\220^\377\7\4/\227U[\246]\377\7\3" - "/\255RN\277Z\377\10\3/\306M@\6\4/{^\377{^\377mVv\6\5/\6\5/h\\\377h\\\377" - "\\U\204\12\12\360\5\5/\12\12\360\377\377\377\377\377\377\310\316\231\310" - "\316\231\377\377\377\214\2402\214\2402\377\377\377\377\377\377\377\377\377" - "\377\377\377\312\332\250\312\332\250\377\377\377\200\2542\200\2542\200\254" - "2\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\317\344\266\317\344\266\317\344\266\377\377\377\377\377\377t\2702t\2702" - "\377\377\377\377\377\377D\3502\362\375\360\377\377\377P\3342\346\371\342" - "\377\377\377\\\3202\335\364\323\377\377\377h\3042\325\355\305\377\377\377" - "t\2702\317\344\266\377\377\377\200\2542\312\332\250\377\377\377\214\2402" - "\310\316\231\377\377\377\230\2242\307\300\213h\\\377\6\5/mVv{^\377\200U0" - "\220^\377\7\4/\227U[\246]\377\7\3/\255RN\277Z\377\10\3/\306M@\6\4/\6\4/{" - "^\377mVvmVv\6\5/\12\12\360h\\\377\\U\204\\U\204\5\5/\230\2242\377\377\377" - "\377\377\377\377\377\377\310\316\231\310\316\231\377\377\377\214\2402\214" - "\2402\377\377\377\377\377\377\377\377\377\377\377\377\312\332\250\312\332" - "\250\377\377\377\377\377\377\200\2542\200\2542\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\317\344\266\317" - "\344\266\377\377\377\377\377\377\377\377\377\377\377\377D\3502q\10p\377\377" - "\377P\3342\335\350\332\377\377\377\\\3202\351\366\337\377\377\377h\3042d" - "!\\\377\377\377t\2702\277\302\252\377\377\377\200\2542\343\345\301\377\377" - "\377\214\2402^2H\377\377\377\230\2242\257\235\204h\\\377\6\5/\223o\234{^" - "\377\6\4/<\36""1\377\252\215j)2\211XK\377\250\203\202$2\337~c\377\242y\236" - "\37""2]#\26\306M@\6\4/ym\274{^\377mVvELn\6\5/h\\\37703x\\U\204\307\300\213" - "\204\226\\\230\2242\377\377\377\377\377\377\377\377\377\310\316\231^\212" - "H\377\377\377\214\2402}\256b\377\377\377\377\377\377\377\377\377\377\377" - "\377\312\332\250_\251O\377\377\377\377\377\377y\310j\200\2542\377\377\377" - "\377\377\377\377\377\377\377\377\377x\341x\377\377\377\377\377\377\177\350" - "|\317\344\266\377\377\377\377\377\377D\3502\362\375\360\377\377\377P\334" - "2\346\371\342\377\377\377\\\3202\335\364\323\377\377\377\377\377\377h\304" - "2\325\355\305\377\377\377t\2702\317\344\266\377\377\377\200\2542\312\332" - "\250\377\377\377\214\2402\310\316\231\377\377\377\230\2242\\U\204h\\\377" - "\6\5/mVv{^\377\6\4/\12\12\360\201Vi\220^\377\7\4/\227U[\246]\377\7\3/\255" - "RN\277Z\377\10\3/\306M@\6\4/\12\12\360{^\377mVvmVv\6\5/\12\12\360h\\\377" - "\377\377\377\307\300\213\377\377\377\230\2242\230\2242\377\377\377\377\377" - "\377\377\377\377\310\316\231\310\316\231\377\377\377\214\2402\214\2402\377" - "\377\377\377\377\377\377\377\377\377\377\377\312\332\250\312\332\250\312" - "\332\250\377\377\377\200\2542\200\2542\200\2542\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377D\350" - "2\362\375\360\377\377\377P\3342\377\377\377\346\371\342\377\377\377\\\320" - "2\335\364\323\377\377\377h\3042\325\355\305\377\377\377t\2702\317\344\266" - "\377\377\377\200\2542\377\377\377\312\332\250\377\377\377\214\2402\310\316" - "\231\377\377\377\5\5/\\U\204h\\\377\6\5/mVv{^\377\6\4/\12\12\360\201Vi\220" - "^\377\7\4/\227U[\246]\377\7\3/\255RN\277Z\377\10\3/\306M@\6\4/\6\4/{^\377" - "\12\12\360mVv\6\5/\6\5/\377\377\377\377\377\377\307\300\213\307\300\213\377" - "\377\377\230\2242\377\377\377\377\377\377\377\377\377\377\377\377\310\316" - "\231\310\316\231\377\377\377\214\2402\214\2402\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\312\332\250\312\332\250\377\377\377\377" - "\377\377\200\2542\200\2542\377\377\377\377\377\377\377\377\377\377\377\377" - "\204\0\204\377\377\377D\3502\355\364\353\377\377\377\377\377\377Y\335;\346" - "\371\342\377\377\377/\26\31\335\364\323\377\377\377k\255<\325\355\305\377" - "\377\377\377\377\377t\2702\317\344\266\2046\204\200\2542\312\332\250\340" - "\317\340\214\2402\310\316\231\377\377\377VX\377\5\5//\33Dh\\\377\6\5/tVz" - "{^\377\6\4/=0\377\201Vi\220^\377\3\1\30\227U[\246]\377?6U\255RN\277Z\377" - "\337]s\306M0\306M@\3\2\30{^\377{^\377yv}mVv\244\2102\377\377\377\377\377" - "\377\377\377\377gyG\307\300\213\230\2242\212\242h\377\377\377\377\377\377" - "\377\377\377\377\377\377\310\316\231g\230O\377\377\377\214\2402\205\274q" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377h\270V\312\332" - "\250\377\377\377\222\344\222\200\2542\200\2542\377\377\377\377\377\377\377" - "\377\377\377\377\377D\3502\362\375\360\377\377\377\377\377\377P\3342\346" - "\371\342\377\377\377\\\3202\335\364\323\377\377\377\377\377\377h\3042\325" - "\355\305\377\377\377t\2702\317\344\266\377\377\377\377\377\377\200\2542\312" - "\332\250\377\377\377\214\2402\310\316\231VX\377\12\12\360\5\5/\\U\204h\\" - "\377\6\5/mVv{^\377\6\4/\12\12\360\201Vi\220^\377\7\4/\227U[\246]\377\7\3" - "/\255RN\255RN\277Z\377\10\3/\306M@\6\4/\12\12\360{^\377\12\12\360\307\260" - "|\244\2102\244\2102\377\377\377\377\377\377\377\377\377\307\300\213\377\377" - "\377\230\2242\230\2242\377\377\377\377\377\377\377\377\377\377\377\377\310" - "\316\231\377\377\377\377\377\377\214\2402\214\2402\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\312\332\250\312\332\250\377\377\377" - "\377\377\377\200\2542\200\2542\377\377\377\377\377\377D\3502\377\377\377" - "\362\375\360\377\377\377P\3342\346\371\342\377\377\377\\\3202\377\377\377" - "\335\364\323\377\377\377h\3042\325\355\305\377\377\377\377\377\377t\2702" - "\317\344\266\377\377\377\200\2542\312\332\250\377\377\377\377\377\377\214" - "\2402LR\221VX\377\5\5/\\U\204\12\12\360h\\\377\6\5/mVv{^\377\6\4/\12\12\360" - "\201Vi\220^\377\7\4/\227U[\246]\377\7\3/\7\3/\255RN\277Z\377\10\3/\306M@" - "\6\4/\6\4/{^\377\377\377\377\307\260|\377\377\377\244\2102\377\377\377\377" - "\377\377\377\377\377\307\300\213\307\300\213\377\377\377\230\2242\377\377" - "\377\377\377\377\377\377\377\377\377\377\310\316\231\310\316\231\377\377" - "\377\377\377\377\214\2402\214\2402\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\312\332\250\312\332\250\377\377\377\377\377\377\377" - "\377\377\377\377\377D\3502\377\377\377\362\375\360\377\377\377-\17\34\346" - "\371\342\377\377\377\363\346\363\\\3202\335\364\323\377\377\377h\3042\377" - "\377\377x)o\377\377\377t\2702\301\276\255\377\377\377\377\377\377\243\273" - "U\312\332\250\377\377\377O-\34\12\12\360LR\221gU\333\5\5/\\U\204<)\377h\\" - "\377\6\5/=!B{^\377\6\4/A2\306\201Vi\220^\377I9q\227U[\246]\377]-\220\7\3" - "/\255RN\245q\304\10\3/\306M0\377\236\221\6\4/\377\377\377\220\231\220\307" - "\260|\307\260|\226\227m\244\2102\377\377\377\377\377\377\377\377\377\307" - "\300\213p\207N\230\2242\230\2242\254\316\254\377\377\377\377\377\377\377" - "\377\377\310\316\231\310\316\231\220\317\220\377\377\377\214\2402\216\316" - "\200\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377r\310^\312" - "\332\250\377\377\377\377\377\377\377\377\377D\3502\362\375\360\377\377\377" - "P\3342\377\377\377\346\371\342\377\377\377\\\3202\335\364\323\377\377\377" - "\377\377\377h\3042\325\355\305\377\377\377\377\377\377t\2702\317\344\266" - "\377\377\377\200\2542\377\377\377\312\332\250\377\377\377\5\6/LR\221\12\12" - "\360VX\377\5\5/\\U\204h\\\377\12\12\360\6\5/mVv{^\377\6\4/\12\12\360\201" - "Vi\220^\377\7\4/\227U[\12\12\360\246]\377\7\3/\255RN\277Z\377\277Z\377\10" - "\3/\306M@\260|2\260|2\377\377\377\377\377\377\307\260|\377\377\377\244\210" - "2\377\377\377\377\377\377\377\377\377\377\377\377\307\300\213\377\377\377" - "\230\2242\230\2242\377\377\377\377\377\377\377\377\377\377\377\377\310\316" - "\231\310\316\231\377\377\377\377\377\377\214\2402\214\2402\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377D\3502\362\375\360\377\377\377P\3342\377\377\377\346\371\342\377" - "\377\377\\\3202\377\377\377\335\364\323\377\377\377h\3042\325\355\305\377" - "\377\377\377\377\377t\2702\317\344\266\377\377\377\377\377\377\200\2542\312" - "\332\250\377\377\377\12\12\360\5\6/LR\221VX\377\12\12\360\5\5/\\U\204h\\" - "\377\6\5/\12\12\360mVv{^\377\6\4/\12\12\360\201Vi\220^\377\7\4/\227U[\227" - "U[\246]\377\7\3/\255RN\12\12\360\277Z\377\10\3/\333bB\377\377\377\260|2\377" - "\377\377\377\377\377\307\260|\307\260|\244\2102\244\2102\377\377\377\377" - "\377\377\377\377\377\307\300\213\307\300\213\377\377\377\230\2242\230\224" - "2\377\377\377\377\377\377\377\377\377\377\377\377\310\316\231\310\316\231" - "\377\377\377\377\377\377\214\2402\214\2402\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377)\10\36\362\375\360\377\377\377\370" - "\356\370P\3342\346\371\342\377\377\377\377\377\377\\\3202\207\"\201\377\377" - "\377\377\377\377p\250D\325\355\305\377\377\377\377\377\377t\2702\317\344" - "\266\234?\234\200\2542\377\377\377\274\260\244FS\377\5\6/;#\377LR\221VX\377" - "\3\1\34\12\12\360\\U\204{^\330\6\5/\12\12\360\257\203\270{^\377\6\4/\6\4" - "\222\201Vi\220^\377P@d\12\12\360\227U[\370\244\377\7\3/\255RNi./\277Z\377" - "\324X2\264\202w\333bB\260|2\377\377\377\377\377\377\377\377\377yvK\377\377" - "\377\244\2102\236\247|\377\377\377\377\377\377\377\377\377\307\300\213\307" - "\300\213\234\306\234\230\2242\377\377\377\256\330\256\377\377\377\377\377" - "\377\377\377\377\310\316\231\310\316\231\234\341\234\377\377\377\214\240" - "2\232\343\223\377\377\377\377\377\377\377\377\377\377\377\377D\3502\362\375" - "\360\377\377\377\377\377\377P\3342\346\371\342\377\377\377\377\377\377\\" - "\3202\335\364\323\377\377\377\377\377\377h\3042\325\355\305\377\377\377\377" - "\377\377t\2702\317\344\266\377\377\377\377\377\377\200\2542\312\332\250\12" - "\12\360FS\377\5\6/LR\221\12\12\360RW\255\3\5\35\6\11\224ZT\\d[\261\3\4\35" - "\6\11\224lVTw]\264\4\4\35\6\11\224\200VN\214]\270\4\3\35\6\11\224\226UG\242" - "\\\274\4\3\35\4\3\35\254R@\377\377\311\203U\36\203U\36\323a:my\36my\36\377" - "\377\276\377\377\276\243\255X\243\255X\236\371\236e\204\36\236\371\236\374" - "\377\273\236\371\236\236\371\236\234\275`\236\371\236^\220\36^\220\36\236" - "\371\236\352\377\267\352\377\267\236\371\236\236\371\236\310\316\231\310" - "\316\231\377\377\377\377\377\377\214\2402\377\377\377\377\377\377\377\377" - "\377D\3502\362\375\360\377\377\377\377\377\377P\3342\346\371\342\377\377" - "\377\377\377\377\\\3202\377\377\377\335\364\323\377\377\377h\3042\377\377" - "\377\325\355\305\377\377\377t\2702\377\377\377\317\344\266\377\377\377\377" - "\377\377\200\2542\346\3\4\35lVT\4\4hw]\264\4\4\35aK\244\200VN\214]\270kZ\371\4\3\35" - "\270\212Io\225o\377\377\306{a\36\253\300\253\304wB\377\377\311\377\377\377" - "\203U\36\323a:\224D(my\36\236\371\236\307\316\266\377\377\276\236\371\236" - "\377\377\343\236\371\236e\204\36Gk\25\236\371\236\374\377\273\260\334\260" - "\236\371\236\234\275`\377\377\377\377\377\377\230\2242k\207#\377\377\377" - "\377\377\377\377\377\377\377\377\377D\3502\377\377\377\362\375\360\377\377" - "\377\377\377\377P\3342\346\371\342\377\377\377\377\377\377\\\3202\377\377" - "\377\335\364\323\377\377\377\377\377\377h\3042\377\377\377\325\355\305\377" - "\377\377\377\377\377t\2702\317\344\266\377\377\3778L\377\12\12\360\5\6/<" - "L\237\12\12\360BR\252\3\5\35\6\11\224JQbRW\255\6\11\224\3\5\35ZT\\\6\11\224" - "d[\261\6\11\224\3\4\35lVT\6\11\224w]\264\4\4\35\6\11\224\200VN\214]\270\6" - "\11\224tm\36\270\212I\270\212I\377\377\306{a\36{a\36\304wB\236\371\236\377" - "\377\311\203U\36\236\371\236\323a:my\36my\36\236\371\236\377\377\276\236" - "\371\236\243\255X\243\255X\236\371\236e\204\36\236\371\236\374\377\273\374" - "\377\273\236\371\236\307\300\213\307\300\213\377\377\377\377\377\377\230" - "\2242\377\377\377\377\377\377\377\377\377D\3502\377\377\377\362\375\360\377" - "\377\377\377\377\377P\3342\377\377\377\346\371\342\377\377\377\377\377\377" - "\\\3202\335\364\323\377\377\377\377\377\377\377\377\377h\3042\325\355\305" - "\377\377\377\377\377\377t\2702\377\377\377\317\344\2668L\377\12\12\360\5" - "\6/\12\12\360\265\14\177\252+\201\210\16\245\204" + "*\377\314U\312\\,\224'\11\260i\17\244\210\40\232\2211\331\353J\215\2351\377" + "\377\276\200\2521\200\2542\375\377\310u\2661t\2702t\2702\367\377\324\325" + "\355\305h\3021h\3042h\3042\377\377\377\377\377\377\364\377\336\335\364\323" + "\335\364\323\335\364\323\\\3202\\\3202\\\3202\\\3202\\\3202\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\346\371\342\346\371\342\346" + "\371\342\346\371\342\346\371\342\346\371\342\346\371\342\377\377\377\377" + "\377\377P\3342P\3342P\3342P\3342P\3342P\3342P\3342P\3342\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\27\331\12Y\316-h\3021\243\370Cg\230\15\230\224\"\245" + "\204*\377\314U\310J\21\327Q.\260b\21\245\2041\370\343N\230\2242\331\353J" + "\214\2402\377\377\276\200\2521\200\2542\375\377\310\317\344\266u\2661t\270" + "2\377\377\377\367\377\324\325\355\305h\3021h\3042h\3042h\3042\377\377\377" + "\377\377\377\364\377\336\335\364\323\335\364\323\335\364\323\335\364\323" + "\\\3202\\\3202\\\3202\\\3202\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\346\371\342\346\371" + "\342\346\371\342\346\371\342\346\371\342\346\371\342\377\377\377\377\377" + "\377\377\377\377\377\377\377P\3342P\3342P\3342P\3342P\3342P\3342P\3342P\334" + "2\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377K\3745!\315\13d\304,p\270)\177\252+\23\13\6\232\2211\245\204" + "1\347\270O\377\277Y\324<\22\265V\24\377\330Q\244\210\40#(\13\230\224\"\331" + "\353Ju\211.\377\377\276\200\2521\210\273:\200\2542\375\377\310\20" + "3\6u\266" + "1t\2702\271\307\271\367\377\324\325\355\305\341\377\321h\3021h\3042\16L\7" + "h\3042\377\377\377\242\300\242\377\377\377\335\364\323\355\377\343\335\364" + "\323\335\364\323\14f\7\\\3202\\\3202>\250*\\\3202\377\377\377\377\377\377" + "\377\377\377\377\377\377$\231$\377\377\377\377\377\377s\303s\377\377\377" + "\346\371\342\376\377\372\346\371\342\346\371\342\40\257\37\346\371\342\346" + "\371\342\\\316\\\377\377\377\377\377\377\377\377\377\377\377\377P\3342\13" + "\262\7P\3342P\3342*\327%P\3342P\3342o\377Q\377\377\377\377\377\377$\352$" + "\377\377\377\377\377\377K\3745]\3749s\375<\212\373@\243\370C\274\363G\331" + "\353J\370\343N\377\330Q\377\314U\377\277Y\377\260\\\224(\11\260|\36\245\204" + "1\377\377\250\232\2211\230\224\"\215\2351\214\2402\377\377\276\312\332\250" + "\200\2521\200\2542\377\377\377\317\344\266u\2661t\2702t\2702\377\377\377" + "\377\377\377\325\355\305\325\355\305\325\355\305h\3042h\3042h\3042\377\377" + "\377\377\377\377\377\377\377\377\377\377\335\364\323\335\364\323\335\364" + "\323\335\364\323\335\364\323\\\3202\\\3202\\\3202\\\3202\\\3202\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\346\371\342\346\371\342" + "\346\371\342\346\371\342\346\371\342\346\371\342\346\371\342\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377P\3342P\3342" + "P\3342P\3342\377\377\377K\3745O\3321\\\3161h\3021t\2702~\254'\214\240%\377" + "\377\262\370\343N\377\330Q\262x1\277l1\312`1\327R.\260X\23\377\330Q\244\210" + "2\377\377\250\230\2242\377\377\262\215\2351\214\2402\377\377\377\312\332" + "\250\200\2521\200\2542\377\377\377\375\377\310\317\344\266u\2661t\2702t\270" + "2\377\377\377\377\377\377\325\355\305\325\355\305\325\355\305h\3042h\304" + "2h\3042h\3042\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\335\364\323\335\364\323\335\364\323\335\364\323\377\377\377\\\3202\\\320" + "2\\\3202\\\3202\\\3202\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\346\371\342\346\371\342\346\371\342\346" + "\371\342\346\371\342\346\371\342\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377D\3471O\3321\21\7\11c\304+\367\377\324o\2520\200\252" + "1\214\2402\235\226'\377\377\250\377\330Q!\20\11\277l1\310d2\266?\33\224(" + "\11\260|\36\257\217;\377\377\250\232\2211\34$\11\377\377\262\215\2351q\206" + "0\377\377\377\312\332\250\217\303@\200\2542\200\25420Z0\317\344\266\317\344" + "\266X\2260t\2702t\2702\377\377\377\377\377\377\325\355\305(l%\325\355\305" + "\325\355\305K\2410h\3042h\3042\377\377\377\377\377\377\377\377\3770\2200" + "\377\377\377\377\377\377t\274p\335\364\323\335\364\323\373\377\361\377\377" + "\377\377\377\377\21\213\11\\\3202\\\3202<\274/\\\3202\377\377\377\377\377" + "\377\377\377\377\377\377\3770\3060\377\377\377\377\377\377V\330V\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\3770\3410\346\371\342\346" + "\371\342>\352>\346\371\342\377\377\377D\3471P\3342\364\377\352s\375\3369\\\3202\377\377\377\377\377\377\377\377\377\377\377\377D\3502\371\377" + "\364O\3321\\\3202\364\377\336h\3042\367\377\324u\2661\200\2542\377\377\276" + "\215\2351\230\2242\307\300\213\244\2102\377\377\234\262x1\274p2\377\337\207" + "\312`1\324E\30\327T1\260|2\377\377\234\245\2041\244\2102\377\377\250\232" + "\2211\230\2242\377\377\377\310\316\231\215\2351\214\2402\377\377\377\377" + "\377\377\312\332\250\312\332\250\200\2542\200\2542\377\377\377\377\377\377" + "\317\344\266\317\344\266\317\344\266t\2702t\2702t\2702\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\325\355\305\325\355\305\325\355" + "\305\377\377\377h\3042h\3042h\3042h\3042\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\335\364\323\335\364\323\335\364\323\335\364\323\377\377\377\377\377" + "\377\377\377\377\377\377\377\\\3202\\\3202\\\3202\377\377\377D\3502\371\377" + "\364O\3321\377\377\377\\\3161h\3042\367\377\324t\2702\375\377\310\200\252" + "1\377\377\377\215\2351\230\2242\377\377\250\244\2102\377\377\234\262x1\274" + "p2\316\214_\310d2\377\310|\327T1\227/\14\377\377\377\307\260|\244\2102\377" + "\377\377\307\300\213\230\2242\230\2242\377\377\377\310\316\231\214\2402\214" + "\2402\377\377\377\377\377\377\312\332\250\312\332\250\200\2542\200\2542\377" + "\377\377\377\377\377\377\377\377\317\344\266\317\344\266\317\344\266t\270" + "2t\2702t\2702\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\325\355\305\325\355\305\325\355\305\377\377\377\377\377\377h\3042h\3042" + "h\3042\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\335\364\323\335\364" + "\323\335\364\323\335\364\323\377\377\377\377\377\377\377\377\377\377\377" + "\377D\3502\371\377\364R\3344\364\377\352\\\3161H\22Hh\3021\377\377\377o\244" + "2\200\2542\312\332\250\226\245<\377\377\262\230\2242H-/\245\2041\377\377" + "\377\233i5\274p2\277l1\331sC\377\310|\324X2*\15\3\260|2\377\377\234\206s" + "7\244\2102\377\377\250\340\337\244\230\2242\377\377\377Hc2\310\316\231\214" + "\2402n\211:\377\377\377\377\377\377\353\377\311\312\332\250\200\2542$T\16" + "\377\377\377\377\377\377\236\277\236\377\377\377\317\344\266\367\377\336" + "\377\377\377t\2702\40n\16t\2702\377\377\377\212\303\212\377\377\377\377\377" + "\377\377\377\377\325\355\305\325\355\305<\2477\377\377\377\377\377\377O\276" + "Ah\3042h\3042\237\377i\377\377\377\377\377\377H\317H\377\377\377\377\377" + "\377c\335c\377\377\377\377\377\377\377\377\377\377\377\377\335\364\323>\337" + ";\335\364\323\377\377\377D\3502\362\375\360P\3342\346\371\342\\\3202\364" + "\377\336h\3042\367\377\324t\2702\375\377\310\200\2542\377\377\276\214\240" + "2\377\377\262\232\2211\377\377\377\245\2041\377\377\377\262x1\377\377\377" + "\277l1\310d2\312`1\324X2\327T1\260|2\377\377\377\307\260|\244\2102\377\377" + "\377\307\300\213\232\2211\230\2242\377\377\377\377\377\262\310\316\231\214" + "\2402\214\2402\377\377\377\377\377\377\312\332\250\312\332\250\200\2542\200" + "\2542\200\2542\377\377\377\377\377\377\377\377\377\317\344\266\317\344\266" + "\317\344\266\377\377\377t\2702t\2702t\2702\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\325\355\305\325\355\305\325\355\305\325\355" + "\305\377\377\377\377\377\377h\3042h\3042h\3042h\3042\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377D\3502\362\375\360P\3342\346\371\342\\\3202\335" + "\364\323h\3042\325\355\305t\2702\317\344\266\377\377\377\200\2521\377\377" + "\377\215\2351\377\377\377\232\2211\377\377\377\245\2041\377\377\377\262x" + "1\377\377\377\277l1\377\377\377\312`1\377\310|\327T1\227/\14\377\377\377" + "\307\260|\244\2102\244\2102\377\377\377\307\300\213\230\2242\230\2242\377" + "\377\377\310\316\231\310\316\231\214\2402\214\2402\377\377\377\377\377\377" + "\312\332\250\312\332\250\377\377\377\200\2542\200\2542\377\377\377\377\377" + "\377\377\377\377\377\377\377\317\344\266\317\344\266\377\377\377\377\377" + "\377t\2702t\2702\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\325\355\305\325\355\305\325\355\305\377\377" + "\377\377\377\377\377\377\377h\3042h\3042h\3042\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377D\3502\362\375\360" + "T\11TO\3321\377\377\377Z\3002\377\377\377h\3042\377\377\334t\2702\375\377" + "\310*\30\20\312\332\250\214\2402\262\260\214\230\2242\307\300\213\377\377" + "\377\245\2041\377\377\377:\35\20\377\377\377\277l1\316\264w\310d2\377\310" + "|\356qL\227/\14\260|2TZ3\307\260|\244\2102\274\302\274\307\300\213\307\300" + "\213\273\301U\377\377\377\377\377\377A^2\310\316\231\214\2402o\216B\377\377" + "\377\377\377\377\366\377\324\312\332\250\312\332\250*a\20\200\2542\377\377" + "\377\230\301\230\377\377\377\377\377\377\377\377\353\317\344\266\317\344" + "\266T\253Tt\2702t\2702]\265I\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377T\306T\377\377\377\325\355\305l\324i\325\355\305\377\377" + "\377\377\377\377\377\377\377h\3042\"\254\20h\3042h\3042b\353b\377\377\377" + "\377\377\377D\3502\362\375\360\377\377\377O\3321\377\377\377\\\3202\364\377" + "\336h\3042\325\355\305t\2702\317\344\266\377\377\377\200\2521\377\377\377" + "\214\2402\377\377\262\230\2242\307\300\213\244\2102\307\260|\377\377\377" + "\262x1\377\377\377\274p2\377\337\207\310d2\377\310|\324X2\333bB\260|2\377" + "\377\377\307\260|\244\2102\244\2102\377\377\377\307\300\213\232\2211\230" + "\2242\377\377\377\377\377\377\310\316\231\310\316\231\214\2402\214\2402\377" + "\377\377\377\377\377\377\377\377\312\332\250\312\332\250\200\2542\200\254" + "2\200\2542\377\377\377\377\377\377\377\377\377\377\377\377\317\344\266\317" + "\344\266\317\344\266\377\377\377t\2702t\2702t\2702\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\325\355\305" + "\325\355\305\325\355\305\325\355\305\377\377\377\377\377\377\377\377\377" + "h\3042h\3042\377\377\377\377\377\377D\3471\377\377\377P\3342\364\377\352" + "\\\3202\335\364\323\377\377\377h\3021\377\377\377t\2702\375\377\310\200\254" + "2\312\332\250\377\377\377\215\2351\377\377\377\230\2242\377\377\250\244\210" + "2\307\260|\377\377\377\262x1\377\377\377\274p2\377\337\207\310d2\323xQ\324" + "X2\327T1\227/\14\260|2\377\377\234\307\260|\244\2102\377\377\377\377\377" + "\377\307\300\213\230\2242\230\2242\377\377\377\377\377\377\310\316\231\310" + "\316\231\214\2402\214\2402\377\377\377\377\377\377\377\377\377\312\332\250" + "\312\332\250\377\377\377\200\2542\200\2542\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\317\344\266\317\344\266\377\377\377\377\377" + "\377t\2702t\2702t\2702\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\325\355\305\325\355\305\325" + "\355\305\377\377\377\377\377\377`\0`\377\377\377D\3471\371\366\371P\3342" + "\346\371\342\377\377\377\\\3161\377\377\377'\24\22\325\355\305t\2702\276" + "\310\251\377\377\377\200\2542\377\377\316\214\2402\310\316\231`6`\230\224" + "2\377\377\250\222u<\307\260|\377\377\377\315\214L\377\377\377\274p2M,#\310" + "d2\312`1\306\304\306\324X2\333bB\325\242W\377\377\377\307\260|=9\22\244\210" + "2\377\377\377\227\234w\307\300\213\230\2242\307\322a\377\377\377\377\377" + "\377Km9\310\316\231\214\2402r\226K\377\377\377\377\377\377\377\377\377\312" + "\332\250\312\332\250`\242`\200\2542\200\2542\224\306\224\377\377\377\377" + "\377\377\377\377\377\377\377\377\317\344\266M\250D\317\344\266\377\377\377" + "\203\322\203t\2702t\2702\301\377\177\377\377\377\377\377\377`\330`\377\377" + "\377\377\377\377r\344r\377\377\377\377\377\377\377\377\377\325\355\305\377" + "\377\377\377\377\377D\3502\371\377\364P\3342\346\371\342\377\377\377\\\320" + "2\364\377\336h\3042\325\355\305\377\377\377t\2702\317\344\266\200\2542\312" + "\332\250\377\377\377\214\2402\310\316\231\230\2242\307\300\213\377\377\377" + "\244\2102\307\260|\377\377\377\200U0\220^\377\7\4/\227U[\246]\377\255Q1\377" + "\242y\10\3/\306M@\6\4/{^\377mVvmVv\6\5/h\\\377h\\\377\\U\204\12\12\360\5" + "\5/VX\377VX\377\12\12\360LR\221\12\12\360\5\6/\214\2402\377\377\377\377\377" + "\377\377\377\377\312\332\250\312\332\250\377\377\377\200\2542\200\2542\200" + "\2542\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\317\344" + "\266\317\344\266\317\344\266\377\377\377\377\377\377t\2702t\2702\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377D\3502\362\375\360P\3342\346\371" + "\342\377\377\377\\\3202\335\364\323\377\377\377h\3042\367\377\324t\2702\317" + "\344\266\377\377\377\200\2542\312\332\250\377\377\377\214\2402\377\377\262" + "\230\2242\307\300\213\377\377\377\244\2102\307\260|{^\377\200U0\220^\377" + "\7\4/\227U[\246]\377\7\3/\377\242y\236\37" + "2\306M0\210%\14T-2{^\377mVv\6" + "\5/\6\5/h\\\377\\U\204\\U\204\5\5/\5\5/VX\377VX\377LR\221LR\221\377\377\377" + "\214\2402\214\2402\377\377\377\377\377\377\377\377\377\312\332\250\312\332" + "\250\312\332\250\377\377\377\200\2542\200\2542\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\317\344\266\317\344\266\377" + "\377\377\377\377\377t\2702t\2702t\2702\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377D\3502\365\375\363\377\377" + "\377O\3321l\22l\\\3202\335\364\323\357\346\357h\3042\325\355\305\377\377" + "\377t\2702\317\344\266l-l\200\2521\377\377\377\204\211=\310\316\231\377\377" + "\377\262\243L\307\300\213\377\377\377E&\25mVv{^\377ySB\220^\377\7\4/\275" + "t\201\246]\377\7\3/I\37!\277Z\377\10\3/\237YQ\6\4/{^\377\236\213\247mVv\6" + "\5/,-lh\\\377\\U\204dow\5\5/\5\5/\222\251\377VX\377\310\316\231T{@\377\377" + "\377\214\2402w\240V\377\377\377\377\377\377\377\377\377\377\377\377\312\332" + "\250U\231G\377\377\377\200\2542q\270\\\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377l\317l\317\344\266\317\344\266z\330v\377\377\377" + "\377\377\377\323\377\221t\2702t\2702l\352l\377\377\377\377\377\377\377\377" + "\377D\3502\362\375\360\377\377\377P\3342\346\371\342\377\377\377\\\3202\364" + "\377\336h\3042\325\355\305\377\377\377t\2702\317\344\266\377\377\377\200" + "\2542\312\332\250\377\377\377\214\2402\310\316\231\377\377\377\230\2242\307" + "\300\213\377\377\377\6\5/mVv{^\377\200U0\220^\377\7\4/\227U[\246]\377\7\3" + "/\255RN\277Z\377\10\3/\306M@\6\4/{^\377{^\377mVv\6\5/\6\5/h\\\377h\\\377" + "\\U\204\12\12\360\5\5/\12\12\360\377\377\377\377\377\377\310\316\231\310" + "\316\231\377\377\377\214\2402\214\2402\377\377\377\377\377\377\377\377\377" + "\377\377\377\312\332\250\312\332\250\377\377\377\200\2542\200\2542\200\254" + "2\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\317\344\266\317\344\266\317\344\266\377\377\377\377\377\377t\2702t\2702" + "\377\377\377\377\377\377D\3502\362\375\360\377\377\377P\3342\346\371\342" + "\377\377\377\\\3202\335\364\323\377\377\377h\3042\325\355\305\377\377\377" + "t\2702\317\344\266\377\377\377\200\2542\312\332\250\377\377\377\214\2402" + "\310\316\231\377\377\377\230\2242\307\300\213h\\\377\6\5/mVv{^\377\200U0" + "\220^\377\7\4/\227U[\246]\377\7\3/\255RN\277Z\377\10\3/\306M@\6\4/\6\4/{" + "^\377mVvmVv\6\5/\12\12\360h\\\377\\U\204\\U\204\5\5/\230\2242\377\377\377" + "\377\377\377\377\377\377\310\316\231\310\316\231\377\377\377\214\2402\214" + "\2402\377\377\377\377\377\377\377\377\377\377\377\377\312\332\250\312\332" + "\250\377\377\377\377\377\377\200\2542\200\2542\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\317\344\266\317" + "\344\266\377\377\377\377\377\377\377\377\377\377\377\377D\3502q\10p\377\377" + "\377P\3342\335\350\332\377\377\377\\\3202\351\366\337\377\377\377h\3042d" + "!\\\377\377\377t\2702\277\302\252\377\377\377\200\2542\343\345\301\377\377" + "\377\214\2402^2H\377\377\377\230\2242\257\235\204h\\\377\6\5/\223o\234{^" + "\377\6\4/<\36" + "1\377\252\215j)2\211XK\377\250\203\202$2\337~c\377\242y\236" + "\37" + "2]#\26\306M@\6\4/ym\274{^\377mVvELn\6\5/h\\\37703x\\U\204\307\300\213" + "\204\226\\\230\2242\377\377\377\377\377\377\377\377\377\310\316\231^\212" + "H\377\377\377\214\2402}\256b\377\377\377\377\377\377\377\377\377\377\377" + "\377\312\332\250_\251O\377\377\377\377\377\377y\310j\200\2542\377\377\377" + "\377\377\377\377\377\377\377\377\377x\341x\377\377\377\377\377\377\177\350" + "|\317\344\266\377\377\377\377\377\377D\3502\362\375\360\377\377\377P\334" + "2\346\371\342\377\377\377\\\3202\335\364\323\377\377\377\377\377\377h\304" + "2\325\355\305\377\377\377t\2702\317\344\266\377\377\377\200\2542\312\332" + "\250\377\377\377\214\2402\310\316\231\377\377\377\230\2242\\U\204h\\\377" + "\6\5/mVv{^\377\6\4/\12\12\360\201Vi\220^\377\7\4/\227U[\246]\377\7\3/\255" + "RN\277Z\377\10\3/\306M@\6\4/\12\12\360{^\377mVvmVv\6\5/\12\12\360h\\\377" + "\377\377\377\307\300\213\377\377\377\230\2242\230\2242\377\377\377\377\377" + "\377\377\377\377\310\316\231\310\316\231\377\377\377\214\2402\214\2402\377" + "\377\377\377\377\377\377\377\377\377\377\377\312\332\250\312\332\250\312" + "\332\250\377\377\377\200\2542\200\2542\200\2542\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377D\350" + "2\362\375\360\377\377\377P\3342\377\377\377\346\371\342\377\377\377\\\320" + "2\335\364\323\377\377\377h\3042\325\355\305\377\377\377t\2702\317\344\266" + "\377\377\377\200\2542\377\377\377\312\332\250\377\377\377\214\2402\310\316" + "\231\377\377\377\5\5/\\U\204h\\\377\6\5/mVv{^\377\6\4/\12\12\360\201Vi\220" + "^\377\7\4/\227U[\246]\377\7\3/\255RN\277Z\377\10\3/\306M@\6\4/\6\4/{^\377" + "\12\12\360mVv\6\5/\6\5/\377\377\377\377\377\377\307\300\213\307\300\213\377" + "\377\377\230\2242\377\377\377\377\377\377\377\377\377\377\377\377\310\316" + "\231\310\316\231\377\377\377\214\2402\214\2402\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\312\332\250\312\332\250\377\377\377\377" + "\377\377\200\2542\200\2542\377\377\377\377\377\377\377\377\377\377\377\377" + "\204\0\204\377\377\377D\3502\355\364\353\377\377\377\377\377\377Y\335;\346" + "\371\342\377\377\377/\26\31\335\364\323\377\377\377k\255<\325\355\305\377" + "\377\377\377\377\377t\2702\317\344\266\2046\204\200\2542\312\332\250\340" + "\317\340\214\2402\310\316\231\377\377\377VX\377\5\5//\33Dh\\\377\6\5/tVz" + "{^\377\6\4/=0\377\201Vi\220^\377\3\1\30\227U[\246]\377?6U\255RN\277Z\377" + "\337]s\306M0\306M@\3\2\30{^\377{^\377yv}mVv\244\2102\377\377\377\377\377" + "\377\377\377\377gyG\307\300\213\230\2242\212\242h\377\377\377\377\377\377" + "\377\377\377\377\377\377\310\316\231g\230O\377\377\377\214\2402\205\274q" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377h\270V\312\332" + "\250\377\377\377\222\344\222\200\2542\200\2542\377\377\377\377\377\377\377" + "\377\377\377\377\377D\3502\362\375\360\377\377\377\377\377\377P\3342\346" + "\371\342\377\377\377\\\3202\335\364\323\377\377\377\377\377\377h\3042\325" + "\355\305\377\377\377t\2702\317\344\266\377\377\377\377\377\377\200\2542\312" + "\332\250\377\377\377\214\2402\310\316\231VX\377\12\12\360\5\5/\\U\204h\\" + "\377\6\5/mVv{^\377\6\4/\12\12\360\201Vi\220^\377\7\4/\227U[\246]\377\7\3" + "/\255RN\255RN\277Z\377\10\3/\306M@\6\4/\12\12\360{^\377\12\12\360\307\260" + "|\244\2102\244\2102\377\377\377\377\377\377\377\377\377\307\300\213\377\377" + "\377\230\2242\230\2242\377\377\377\377\377\377\377\377\377\377\377\377\310" + "\316\231\377\377\377\377\377\377\214\2402\214\2402\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\312\332\250\312\332\250\377\377\377" + "\377\377\377\200\2542\200\2542\377\377\377\377\377\377D\3502\377\377\377" + "\362\375\360\377\377\377P\3342\346\371\342\377\377\377\\\3202\377\377\377" + "\335\364\323\377\377\377h\3042\325\355\305\377\377\377\377\377\377t\2702" + "\317\344\266\377\377\377\200\2542\312\332\250\377\377\377\377\377\377\214" + "\2402LR\221VX\377\5\5/\\U\204\12\12\360h\\\377\6\5/mVv{^\377\6\4/\12\12\360" + "\201Vi\220^\377\7\4/\227U[\246]\377\7\3/\7\3/\255RN\277Z\377\10\3/\306M@" + "\6\4/\6\4/{^\377\377\377\377\307\260|\377\377\377\244\2102\377\377\377\377" + "\377\377\377\377\377\307\300\213\307\300\213\377\377\377\230\2242\377\377" + "\377\377\377\377\377\377\377\377\377\377\310\316\231\310\316\231\377\377" + "\377\377\377\377\214\2402\214\2402\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\312\332\250\312\332\250\377\377\377\377\377\377\377" + "\377\377\377\377\377D\3502\377\377\377\362\375\360\377\377\377-\17\34\346" + "\371\342\377\377\377\363\346\363\\\3202\335\364\323\377\377\377h\3042\377" + "\377\377x)o\377\377\377t\2702\301\276\255\377\377\377\377\377\377\243\273" + "U\312\332\250\377\377\377O-\34\12\12\360LR\221gU\333\5\5/\\U\204<)\377h\\" + "\377\6\5/=!B{^\377\6\4/A2\306\201Vi\220^\377I9q\227U[\246]\377]-\220\7\3" + "/\255RN\245q\304\10\3/\306M0\377\236\221\6\4/\377\377\377\220\231\220\307" + "\260|\307\260|\226\227m\244\2102\377\377\377\377\377\377\377\377\377\307" + "\300\213p\207N\230\2242\230\2242\254\316\254\377\377\377\377\377\377\377" + "\377\377\310\316\231\310\316\231\220\317\220\377\377\377\214\2402\216\316" + "\200\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377r\310^\312" + "\332\250\377\377\377\377\377\377\377\377\377D\3502\362\375\360\377\377\377" + "P\3342\377\377\377\346\371\342\377\377\377\\\3202\335\364\323\377\377\377" + "\377\377\377h\3042\325\355\305\377\377\377\377\377\377t\2702\317\344\266" + "\377\377\377\200\2542\377\377\377\312\332\250\377\377\377\5\6/LR\221\12\12" + "\360VX\377\5\5/\\U\204h\\\377\12\12\360\6\5/mVv{^\377\6\4/\12\12\360\201" + "Vi\220^\377\7\4/\227U[\12\12\360\246]\377\7\3/\255RN\277Z\377\277Z\377\10" + "\3/\306M@\260|2\260|2\377\377\377\377\377\377\307\260|\377\377\377\244\210" + "2\377\377\377\377\377\377\377\377\377\377\377\377\307\300\213\377\377\377" + "\230\2242\230\2242\377\377\377\377\377\377\377\377\377\377\377\377\310\316" + "\231\310\316\231\377\377\377\377\377\377\214\2402\214\2402\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377D\3502\362\375\360\377\377\377P\3342\377\377\377\346\371\342\377" + "\377\377\\\3202\377\377\377\335\364\323\377\377\377h\3042\325\355\305\377" + "\377\377\377\377\377t\2702\317\344\266\377\377\377\377\377\377\200\2542\312" + "\332\250\377\377\377\12\12\360\5\6/LR\221VX\377\12\12\360\5\5/\\U\204h\\" + "\377\6\5/\12\12\360mVv{^\377\6\4/\12\12\360\201Vi\220^\377\7\4/\227U[\227" + "U[\246]\377\7\3/\255RN\12\12\360\277Z\377\10\3/\333bB\377\377\377\260|2\377" + "\377\377\377\377\377\307\260|\307\260|\244\2102\244\2102\377\377\377\377" + "\377\377\377\377\377\307\300\213\307\300\213\377\377\377\230\2242\230\224" + "2\377\377\377\377\377\377\377\377\377\377\377\377\310\316\231\310\316\231" + "\377\377\377\377\377\377\214\2402\214\2402\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377)\10\36\362\375\360\377\377\377\370" + "\356\370P\3342\346\371\342\377\377\377\377\377\377\\\3202\207\"\201\377\377" + "\377\377\377\377p\250D\325\355\305\377\377\377\377\377\377t\2702\317\344" + "\266\234?\234\200\2542\377\377\377\274\260\244FS\377\5\6/;#\377LR\221VX\377" + "\3\1\34\12\12\360\\U\204{^\330\6\5/\12\12\360\257\203\270{^\377\6\4/\6\4" + "\222\201Vi\220^\377P@d\12\12\360\227U[\370\244\377\7\3/\255RNi./\277Z\377" + "\324X2\264\202w\333bB\260|2\377\377\377\377\377\377\377\377\377yvK\377\377" + "\377\244\2102\236\247|\377\377\377\377\377\377\377\377\377\307\300\213\307" + "\300\213\234\306\234\230\2242\377\377\377\256\330\256\377\377\377\377\377" + "\377\377\377\377\310\316\231\310\316\231\234\341\234\377\377\377\214\240" + "2\232\343\223\377\377\377\377\377\377\377\377\377\377\377\377D\3502\362\375" + "\360\377\377\377\377\377\377P\3342\346\371\342\377\377\377\377\377\377\\" + "\3202\335\364\323\377\377\377\377\377\377h\3042\325\355\305\377\377\377\377" + "\377\377t\2702\317\344\266\377\377\377\377\377\377\200\2542\312\332\250\12" + "\12\360FS\377\5\6/LR\221\12\12\360RW\255\3\5\35\6\11\224ZT\\d[\261\3\4\35" + "\6\11\224lVTw]\264\4\4\35\6\11\224\200VN\214]\270\4\3\35\6\11\224\226UG\242" + "\\\274\4\3\35\4\3\35\254R@\377\377\311\203U\36\203U\36\323a:my\36my\36\377" + "\377\276\377\377\276\243\255X\243\255X\236\371\236e\204\36\236\371\236\374" + "\377\273\236\371\236\236\371\236\234\275`\236\371\236^\220\36^\220\36\236" + "\371\236\352\377\267\352\377\267\236\371\236\236\371\236\310\316\231\310" + "\316\231\377\377\377\377\377\377\214\2402\377\377\377\377\377\377\377\377" + "\377D\3502\362\375\360\377\377\377\377\377\377P\3342\346\371\342\377\377" + "\377\377\377\377\\\3202\377\377\377\335\364\323\377\377\377h\3042\377\377" + "\377\325\355\305\377\377\377t\2702\377\377\377\317\344\266\377\377\377\377" + "\377\377\200\2542\346\3\4\35lVT\4\4hw]\264\4\4\35aK\244\200VN\214]\270kZ\371\4\3\35" + "\270\212Io\225o\377\377\306{a\36\253\300\253\304wB\377\377\311\377\377\377" + "\203U\36\323a:\224D(my\36\236\371\236\307\316\266\377\377\276\236\371\236" + "\377\377\343\236\371\236e\204\36Gk\25\236\371\236\374\377\273\260\334\260" + "\236\371\236\234\275`\377\377\377\377\377\377\230\2242k\207#\377\377\377" + "\377\377\377\377\377\377\377\377\377D\3502\377\377\377\362\375\360\377\377" + "\377\377\377\377P\3342\346\371\342\377\377\377\377\377\377\\\3202\377\377" + "\377\335\364\323\377\377\377\377\377\377h\3042\377\377\377\325\355\305\377" + "\377\377\377\377\377t\2702\317\344\266\377\377\3778L\377\12\12\360\5\6/<" + "L\237\12\12\360BR\252\3\5\35\6\11\224JQbRW\255\6\11\224\3\5\35ZT\\\6\11\224" + "d[\261\6\11\224\3\4\35lVT\6\11\224w]\264\4\4\35\6\11\224\200VN\214]\270\6" + "\11\224tm\36\270\212I\270\212I\377\377\306{a\36{a\36\304wB\236\371\236\377" + "\377\311\203U\36\236\371\236\323a:my\36my\36\236\371\236\377\377\276\236" + "\371\236\243\255X\243\255X\236\371\236e\204\36\236\371\236\374\377\273\374" + "\377\273\236\371\236\307\300\213\307\300\213\377\377\377\377\377\377\230" + "\2242\377\377\377\377\377\377\377\377\377D\3502\377\377\377\362\375\360\377" + "\377\377\377\377\377P\3342\377\377\377\346\371\342\377\377\377\377\377\377" + "\\\3202\335\364\323\377\377\377\377\377\377\377\377\377h\3042\325\355\305" + "\377\377\377\377\377\377t\2702\377\377\377\317\344\2668L\377\12\12\360\5" + "\6/\12\12\360> (32-(n)))) +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) /* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */ /* Rotation is separate from addition to prevent recomputation */ -#define FF(a, b, c, d, x, s, ac) \ - {(a) += F ((b), (c), (d)) + (x) + (MD5UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define GG(a, b, c, d, x, s, ac) \ - {(a) += G ((b), (c), (d)) + (x) + (MD5UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define HH(a, b, c, d, x, s, ac) \ - {(a) += H ((b), (c), (d)) + (x) + (MD5UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define II(a, b, c, d, x, s, ac) \ - {(a) += I ((b), (c), (d)) + (x) + (MD5UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } +#define FF(a, b, c, d, x, s, ac) \ + { \ + (a) += F((b), (c), (d)) + (x) + (MD5UINT4)(ac); \ + (a) = ROTATE_LEFT((a), (s)); \ + (a) += (b); \ + } +#define GG(a, b, c, d, x, s, ac) \ + { \ + (a) += G((b), (c), (d)) + (x) + (MD5UINT4)(ac); \ + (a) = ROTATE_LEFT((a), (s)); \ + (a) += (b); \ + } +#define HH(a, b, c, d, x, s, ac) \ + { \ + (a) += H((b), (c), (d)) + (x) + (MD5UINT4)(ac); \ + (a) = ROTATE_LEFT((a), (s)); \ + (a) += (b); \ + } +#define II(a, b, c, d, x, s, ac) \ + { \ + (a) += I((b), (c), (d)) + (x) + (MD5UINT4)(ac); \ + (a) = ROTATE_LEFT((a), (s)); \ + (a) += (b); \ + } /* The routine MD5Init initializes the message-digest context mdContext. All fields are set to zero. */ -void SDLTest_Md5Init(SDLTest_Md5Context * mdContext) +void SDLTest_Md5Init(SDLTest_Md5Context *mdContext) { - if (mdContext == NULL) { - return; - } + if (mdContext == NULL) { + return; + } - mdContext->i[0] = mdContext->i[1] = (MD5UINT4) 0; + mdContext->i[0] = mdContext->i[1] = (MD5UINT4)0; - /* - * Load magic initialization constants. - */ - mdContext->buf[0] = (MD5UINT4) 0x67452301; - mdContext->buf[1] = (MD5UINT4) 0xefcdab89; - mdContext->buf[2] = (MD5UINT4) 0x98badcfe; - mdContext->buf[3] = (MD5UINT4) 0x10325476; + /* + * Load magic initialization constants. + */ + mdContext->buf[0] = (MD5UINT4)0x67452301; + mdContext->buf[1] = (MD5UINT4)0xefcdab89; + mdContext->buf[2] = (MD5UINT4)0x98badcfe; + mdContext->buf[3] = (MD5UINT4)0x10325476; } /* @@ -130,51 +134,51 @@ void SDLTest_Md5Init(SDLTest_Md5Context * mdContext) in the message whose digest is being computed. */ -void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf, - unsigned int inLen) +void SDLTest_Md5Update(SDLTest_Md5Context *mdContext, unsigned char *inBuf, + unsigned int inLen) { - MD5UINT4 in[16]; - int mdi; - unsigned int i, ii; + MD5UINT4 in[16]; + int mdi; + unsigned int i, ii; - if (mdContext == NULL) { - return; - } - if (inBuf == NULL || inLen < 1) { - return; - } - - /* - * compute number of bytes mod 64 - */ - mdi = (int) ((mdContext->i[0] >> 3) & 0x3F); - - /* - * update number of bits - */ - if ((mdContext->i[0] + ((MD5UINT4)inLen << 3)) < mdContext->i[0]) { - mdContext->i[1]++; - } - mdContext->i[0] += ((MD5UINT4) inLen << 3); - mdContext->i[1] += ((MD5UINT4) inLen >> 29); - - while (inLen--) { - /* - * add new character to buffer, increment mdi - */ - mdContext->in[mdi++] = *inBuf++; - - /* - * transform if necessary - */ - if (mdi == 0x40) { - for (i = 0, ii = 0; i < 16; i++, ii += 4) { - in[i] = (((MD5UINT4)mdContext->in[ii + 3]) << 24) | (((MD5UINT4)mdContext->in[ii + 2]) << 16) | (((MD5UINT4)mdContext->in[ii + 1]) << 8) | ((MD5UINT4)mdContext->in[ii]); - } - SDLTest_Md5Transform(mdContext->buf, in); - mdi = 0; + if (mdContext == NULL) { + return; + } + if (inBuf == NULL || inLen < 1) { + return; + } + + /* + * compute number of bytes mod 64 + */ + mdi = (int)((mdContext->i[0] >> 3) & 0x3F); + + /* + * update number of bits + */ + if ((mdContext->i[0] + ((MD5UINT4)inLen << 3)) < mdContext->i[0]) { + mdContext->i[1]++; + } + mdContext->i[0] += ((MD5UINT4)inLen << 3); + mdContext->i[1] += ((MD5UINT4)inLen >> 29); + + while (inLen--) { + /* + * add new character to buffer, increment mdi + */ + mdContext->in[mdi++] = *inBuf++; + + /* + * transform if necessary + */ + if (mdi == 0x40) { + for (i = 0, ii = 0; i < 16; i++, ii += 4) { + in[i] = (((MD5UINT4)mdContext->in[ii + 3]) << 24) | (((MD5UINT4)mdContext->in[ii + 2]) << 16) | (((MD5UINT4)mdContext->in[ii + 1]) << 8) | ((MD5UINT4)mdContext->in[ii]); + } + SDLTest_Md5Transform(mdContext->buf, in); + mdi = 0; + } } - } } /* @@ -182,162 +186,162 @@ void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf, ends with the desired message digest in mdContext->digest[0...15]. */ -void SDLTest_Md5Final(SDLTest_Md5Context * mdContext) +void SDLTest_Md5Final(SDLTest_Md5Context *mdContext) { - MD5UINT4 in[16]; - int mdi; - unsigned int i, ii; - unsigned int padLen; + MD5UINT4 in[16]; + int mdi; + unsigned int i, ii; + unsigned int padLen; - if (mdContext == NULL) { - return; - } + if (mdContext == NULL) { + return; + } - /* - * save number of bits - */ - in[14] = mdContext->i[0]; - in[15] = mdContext->i[1]; + /* + * save number of bits + */ + in[14] = mdContext->i[0]; + in[15] = mdContext->i[1]; - /* - * compute number of bytes mod 64 - */ - mdi = (int) ((mdContext->i[0] >> 3) & 0x3F); + /* + * compute number of bytes mod 64 + */ + mdi = (int)((mdContext->i[0] >> 3) & 0x3F); - /* - * pad out to 56 mod 64 - */ - padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi); - SDLTest_Md5Update(mdContext, MD5PADDING, padLen); + /* + * pad out to 56 mod 64 + */ + padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi); + SDLTest_Md5Update(mdContext, MD5PADDING, padLen); - /* - * append length in bits and transform - */ - for (i = 0, ii = 0; i < 14; i++, ii += 4) { - in[i] = (((MD5UINT4)mdContext->in[ii + 3]) << 24) | (((MD5UINT4)mdContext->in[ii + 2]) << 16) | (((MD5UINT4)mdContext->in[ii + 1]) << 8) | ((MD5UINT4)mdContext->in[ii]); - } - SDLTest_Md5Transform(mdContext->buf, in); + /* + * append length in bits and transform + */ + for (i = 0, ii = 0; i < 14; i++, ii += 4) { + in[i] = (((MD5UINT4)mdContext->in[ii + 3]) << 24) | (((MD5UINT4)mdContext->in[ii + 2]) << 16) | (((MD5UINT4)mdContext->in[ii + 1]) << 8) | ((MD5UINT4)mdContext->in[ii]); + } + SDLTest_Md5Transform(mdContext->buf, in); - /* - * store buffer in digest - */ - for (i = 0, ii = 0; i < 4; i++, ii += 4) { - mdContext->digest[ii] = (unsigned char) (mdContext->buf[i] & 0xFF); - mdContext->digest[ii + 1] = - (unsigned char) ((mdContext->buf[i] >> 8) & 0xFF); - mdContext->digest[ii + 2] = - (unsigned char) ((mdContext->buf[i] >> 16) & 0xFF); - mdContext->digest[ii + 3] = - (unsigned char) ((mdContext->buf[i] >> 24) & 0xFF); - } + /* + * store buffer in digest + */ + for (i = 0, ii = 0; i < 4; i++, ii += 4) { + mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF); + mdContext->digest[ii + 1] = + (unsigned char)((mdContext->buf[i] >> 8) & 0xFF); + mdContext->digest[ii + 2] = + (unsigned char)((mdContext->buf[i] >> 16) & 0xFF); + mdContext->digest[ii + 3] = + (unsigned char)((mdContext->buf[i] >> 24) & 0xFF); + } } /* Basic MD5 step. Transforms buf based on in. */ -static void SDLTest_Md5Transform(MD5UINT4 * buf, const MD5UINT4 * in) +static void SDLTest_Md5Transform(MD5UINT4 *buf, const MD5UINT4 *in) { - MD5UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3]; + MD5UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3]; - /* - * Round 1 - */ + /* + * Round 1 + */ #define S11 7 #define S12 12 #define S13 17 #define S14 22 - FF(a, b, c, d, in[0], S11, 3614090360u); /* 1 */ - FF(d, a, b, c, in[1], S12, 3905402710u); /* 2 */ - FF(c, d, a, b, in[2], S13, 606105819u); /* 3 */ - FF(b, c, d, a, in[3], S14, 3250441966u); /* 4 */ - FF(a, b, c, d, in[4], S11, 4118548399u); /* 5 */ - FF(d, a, b, c, in[5], S12, 1200080426u); /* 6 */ - FF(c, d, a, b, in[6], S13, 2821735955u); /* 7 */ - FF(b, c, d, a, in[7], S14, 4249261313u); /* 8 */ - FF(a, b, c, d, in[8], S11, 1770035416u); /* 9 */ - FF(d, a, b, c, in[9], S12, 2336552879u); /* 10 */ - FF(c, d, a, b, in[10], S13, 4294925233u); /* 11 */ - FF(b, c, d, a, in[11], S14, 2304563134u); /* 12 */ - FF(a, b, c, d, in[12], S11, 1804603682u); /* 13 */ - FF(d, a, b, c, in[13], S12, 4254626195u); /* 14 */ - FF(c, d, a, b, in[14], S13, 2792965006u); /* 15 */ - FF(b, c, d, a, in[15], S14, 1236535329u); /* 16 */ + FF(a, b, c, d, in[0], S11, 3614090360u); /* 1 */ + FF(d, a, b, c, in[1], S12, 3905402710u); /* 2 */ + FF(c, d, a, b, in[2], S13, 606105819u); /* 3 */ + FF(b, c, d, a, in[3], S14, 3250441966u); /* 4 */ + FF(a, b, c, d, in[4], S11, 4118548399u); /* 5 */ + FF(d, a, b, c, in[5], S12, 1200080426u); /* 6 */ + FF(c, d, a, b, in[6], S13, 2821735955u); /* 7 */ + FF(b, c, d, a, in[7], S14, 4249261313u); /* 8 */ + FF(a, b, c, d, in[8], S11, 1770035416u); /* 9 */ + FF(d, a, b, c, in[9], S12, 2336552879u); /* 10 */ + FF(c, d, a, b, in[10], S13, 4294925233u); /* 11 */ + FF(b, c, d, a, in[11], S14, 2304563134u); /* 12 */ + FF(a, b, c, d, in[12], S11, 1804603682u); /* 13 */ + FF(d, a, b, c, in[13], S12, 4254626195u); /* 14 */ + FF(c, d, a, b, in[14], S13, 2792965006u); /* 15 */ + FF(b, c, d, a, in[15], S14, 1236535329u); /* 16 */ - /* - * Round 2 - */ + /* + * Round 2 + */ #define S21 5 #define S22 9 #define S23 14 #define S24 20 - GG(a, b, c, d, in[1], S21, 4129170786u); /* 17 */ - GG(d, a, b, c, in[6], S22, 3225465664u); /* 18 */ - GG(c, d, a, b, in[11], S23, 643717713u); /* 19 */ - GG(b, c, d, a, in[0], S24, 3921069994u); /* 20 */ - GG(a, b, c, d, in[5], S21, 3593408605u); /* 21 */ - GG(d, a, b, c, in[10], S22, 38016083u); /* 22 */ - GG(c, d, a, b, in[15], S23, 3634488961u); /* 23 */ - GG(b, c, d, a, in[4], S24, 3889429448u); /* 24 */ - GG(a, b, c, d, in[9], S21, 568446438u); /* 25 */ - GG(d, a, b, c, in[14], S22, 3275163606u); /* 26 */ - GG(c, d, a, b, in[3], S23, 4107603335u); /* 27 */ - GG(b, c, d, a, in[8], S24, 1163531501u); /* 28 */ - GG(a, b, c, d, in[13], S21, 2850285829u); /* 29 */ - GG(d, a, b, c, in[2], S22, 4243563512u); /* 30 */ - GG(c, d, a, b, in[7], S23, 1735328473u); /* 31 */ - GG(b, c, d, a, in[12], S24, 2368359562u); /* 32 */ + GG(a, b, c, d, in[1], S21, 4129170786u); /* 17 */ + GG(d, a, b, c, in[6], S22, 3225465664u); /* 18 */ + GG(c, d, a, b, in[11], S23, 643717713u); /* 19 */ + GG(b, c, d, a, in[0], S24, 3921069994u); /* 20 */ + GG(a, b, c, d, in[5], S21, 3593408605u); /* 21 */ + GG(d, a, b, c, in[10], S22, 38016083u); /* 22 */ + GG(c, d, a, b, in[15], S23, 3634488961u); /* 23 */ + GG(b, c, d, a, in[4], S24, 3889429448u); /* 24 */ + GG(a, b, c, d, in[9], S21, 568446438u); /* 25 */ + GG(d, a, b, c, in[14], S22, 3275163606u); /* 26 */ + GG(c, d, a, b, in[3], S23, 4107603335u); /* 27 */ + GG(b, c, d, a, in[8], S24, 1163531501u); /* 28 */ + GG(a, b, c, d, in[13], S21, 2850285829u); /* 29 */ + GG(d, a, b, c, in[2], S22, 4243563512u); /* 30 */ + GG(c, d, a, b, in[7], S23, 1735328473u); /* 31 */ + GG(b, c, d, a, in[12], S24, 2368359562u); /* 32 */ - /* - * Round 3 - */ + /* + * Round 3 + */ #define S31 4 #define S32 11 #define S33 16 #define S34 23 - HH(a, b, c, d, in[5], S31, 4294588738u); /* 33 */ - HH(d, a, b, c, in[8], S32, 2272392833u); /* 34 */ - HH(c, d, a, b, in[11], S33, 1839030562u); /* 35 */ - HH(b, c, d, a, in[14], S34, 4259657740u); /* 36 */ - HH(a, b, c, d, in[1], S31, 2763975236u); /* 37 */ - HH(d, a, b, c, in[4], S32, 1272893353u); /* 38 */ - HH(c, d, a, b, in[7], S33, 4139469664u); /* 39 */ - HH(b, c, d, a, in[10], S34, 3200236656u); /* 40 */ - HH(a, b, c, d, in[13], S31, 681279174u); /* 41 */ - HH(d, a, b, c, in[0], S32, 3936430074u); /* 42 */ - HH(c, d, a, b, in[3], S33, 3572445317u); /* 43 */ - HH(b, c, d, a, in[6], S34, 76029189u); /* 44 */ - HH(a, b, c, d, in[9], S31, 3654602809u); /* 45 */ - HH(d, a, b, c, in[12], S32, 3873151461u); /* 46 */ - HH(c, d, a, b, in[15], S33, 530742520u); /* 47 */ - HH(b, c, d, a, in[2], S34, 3299628645u); /* 48 */ + HH(a, b, c, d, in[5], S31, 4294588738u); /* 33 */ + HH(d, a, b, c, in[8], S32, 2272392833u); /* 34 */ + HH(c, d, a, b, in[11], S33, 1839030562u); /* 35 */ + HH(b, c, d, a, in[14], S34, 4259657740u); /* 36 */ + HH(a, b, c, d, in[1], S31, 2763975236u); /* 37 */ + HH(d, a, b, c, in[4], S32, 1272893353u); /* 38 */ + HH(c, d, a, b, in[7], S33, 4139469664u); /* 39 */ + HH(b, c, d, a, in[10], S34, 3200236656u); /* 40 */ + HH(a, b, c, d, in[13], S31, 681279174u); /* 41 */ + HH(d, a, b, c, in[0], S32, 3936430074u); /* 42 */ + HH(c, d, a, b, in[3], S33, 3572445317u); /* 43 */ + HH(b, c, d, a, in[6], S34, 76029189u); /* 44 */ + HH(a, b, c, d, in[9], S31, 3654602809u); /* 45 */ + HH(d, a, b, c, in[12], S32, 3873151461u); /* 46 */ + HH(c, d, a, b, in[15], S33, 530742520u); /* 47 */ + HH(b, c, d, a, in[2], S34, 3299628645u); /* 48 */ - /* - * Round 4 - */ + /* + * Round 4 + */ #define S41 6 #define S42 10 #define S43 15 #define S44 21 - II(a, b, c, d, in[0], S41, 4096336452u); /* 49 */ - II(d, a, b, c, in[7], S42, 1126891415u); /* 50 */ - II(c, d, a, b, in[14], S43, 2878612391u); /* 51 */ - II(b, c, d, a, in[5], S44, 4237533241u); /* 52 */ - II(a, b, c, d, in[12], S41, 1700485571u); /* 53 */ - II(d, a, b, c, in[3], S42, 2399980690u); /* 54 */ - II(c, d, a, b, in[10], S43, 4293915773u); /* 55 */ - II(b, c, d, a, in[1], S44, 2240044497u); /* 56 */ - II(a, b, c, d, in[8], S41, 1873313359u); /* 57 */ - II(d, a, b, c, in[15], S42, 4264355552u); /* 58 */ - II(c, d, a, b, in[6], S43, 2734768916u); /* 59 */ - II(b, c, d, a, in[13], S44, 1309151649u); /* 60 */ - II(a, b, c, d, in[4], S41, 4149444226u); /* 61 */ - II(d, a, b, c, in[11], S42, 3174756917u); /* 62 */ - II(c, d, a, b, in[2], S43, 718787259u); /* 63 */ - II(b, c, d, a, in[9], S44, 3951481745u); /* 64 */ + II(a, b, c, d, in[0], S41, 4096336452u); /* 49 */ + II(d, a, b, c, in[7], S42, 1126891415u); /* 50 */ + II(c, d, a, b, in[14], S43, 2878612391u); /* 51 */ + II(b, c, d, a, in[5], S44, 4237533241u); /* 52 */ + II(a, b, c, d, in[12], S41, 1700485571u); /* 53 */ + II(d, a, b, c, in[3], S42, 2399980690u); /* 54 */ + II(c, d, a, b, in[10], S43, 4293915773u); /* 55 */ + II(b, c, d, a, in[1], S44, 2240044497u); /* 56 */ + II(a, b, c, d, in[8], S41, 1873313359u); /* 57 */ + II(d, a, b, c, in[15], S42, 4264355552u); /* 58 */ + II(c, d, a, b, in[6], S43, 2734768916u); /* 59 */ + II(b, c, d, a, in[13], S44, 1309151649u); /* 60 */ + II(a, b, c, d, in[4], S41, 4149444226u); /* 61 */ + II(d, a, b, c, in[11], S42, 3174756917u); /* 62 */ + II(c, d, a, b, in[2], S43, 718787259u); /* 63 */ + II(b, c, d, a, in[9], S44, 3951481745u); /* 64 */ - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; + buf[0] += a; + buf[1] += b; + buf[2] += c; + buf[3] += d; } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/test/SDL_test_memory.c b/src/test/SDL_test_memory.c index f01b509a4..d5dd5da91 100644 --- a/src/test/SDL_test_memory.c +++ b/src/test/SDL_test_memory.c @@ -62,7 +62,7 @@ static unsigned int get_allocation_bucket(void *mem) index = (crc_value & (SDL_arraysize(s_tracked_allocations) - 1)); return index; } - + static SDL_bool SDL_IsAllocationTracked(void *mem) { SDL_tracked_allocation *entry; @@ -145,7 +145,7 @@ static void SDL_UntrackAllocation(void *mem) } } -static void * SDLCALL SDLTest_TrackedMalloc(size_t size) +static void *SDLCALL SDLTest_TrackedMalloc(size_t size) { void *mem; @@ -156,7 +156,7 @@ static void * SDLCALL SDLTest_TrackedMalloc(size_t size) return mem; } -static void * SDLCALL SDLTest_TrackedCalloc(size_t nmemb, size_t size) +static void *SDLCALL SDLTest_TrackedCalloc(size_t nmemb, size_t size) { void *mem; @@ -167,7 +167,7 @@ static void * SDLCALL SDLTest_TrackedCalloc(size_t nmemb, size_t size) return mem; } -static void * SDLCALL SDLTest_TrackedRealloc(void *ptr, size_t size) +static void *SDLCALL SDLTest_TrackedRealloc(void *ptr, size_t size) { void *mem; @@ -233,13 +233,13 @@ void SDLTest_LogAllocations() return; } -#define ADD_LINE() \ - message_size += (SDL_strlen(line) + 1); \ +#define ADD_LINE() \ + message_size += (SDL_strlen(line) + 1); \ tmp = (char *)SDL_realloc_orig(message, message_size); \ - if (!tmp) { \ - return; \ - } \ - message = tmp; \ + if (!tmp) { \ + return; \ + } \ + message = tmp; \ SDL_strlcat(message, line, message_size) SDL_strlcpy(line, "Memory allocations:\n", sizeof(line)); @@ -258,7 +258,7 @@ void SDLTest_LogAllocations() if (!entry->stack[stack_index]) { break; } - SDL_snprintf(line, sizeof(line), "\t0x%"SDL_PRIx64": %s\n", entry->stack[stack_index], entry->stack_names[stack_index]); + SDL_snprintf(line, sizeof(line), "\t0x%" SDL_PRIx64 ": %s\n", entry->stack[stack_index], entry->stack_names[stack_index]); ADD_LINE(); } total_allocated += entry->size; diff --git a/src/test/SDL_test_random.c b/src/test/SDL_test_random.c index d00f2dfec..df1bfbf6a 100644 --- a/src/test/SDL_test_random.c +++ b/src/test/SDL_test_random.c @@ -38,67 +38,67 @@ /* Initialize random number generator with two integer variables */ -void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi, unsigned int ci) +void SDLTest_RandomInit(SDLTest_RandomContext *rndContext, unsigned int xi, unsigned int ci) { - if (rndContext == NULL) { - return; - } + if (rndContext == NULL) { + return; + } - /* - * Choose a value for 'a' from this list - * 1791398085 1929682203 1683268614 1965537969 1675393560 - * 1967773755 1517746329 1447497129 1655692410 1606218150 - * 2051013963 1075433238 1557985959 1781943330 1893513180 - * 1631296680 2131995753 2083801278 1873196400 1554115554 - */ - rndContext->a = 1655692410; - rndContext->x = 30903; - rndContext->c = 0; - if (xi != 0) { - rndContext->x = xi; - } - rndContext->c = ci; - rndContext->ah = rndContext->a >> 16; - rndContext->al = rndContext->a & 65535; + /* + * Choose a value for 'a' from this list + * 1791398085 1929682203 1683268614 1965537969 1675393560 + * 1967773755 1517746329 1447497129 1655692410 1606218150 + * 2051013963 1075433238 1557985959 1781943330 1893513180 + * 1631296680 2131995753 2083801278 1873196400 1554115554 + */ + rndContext->a = 1655692410; + rndContext->x = 30903; + rndContext->c = 0; + if (xi != 0) { + rndContext->x = xi; + } + rndContext->c = ci; + rndContext->ah = rndContext->a >> 16; + rndContext->al = rndContext->a & 65535; } /* Initialize random number generator from system time */ -void SDLTest_RandomInitTime(SDLTest_RandomContext * rndContext) +void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext) { - int a, b; + int a, b; - if (rndContext == NULL) { - return; - } + if (rndContext == NULL) { + return; + } - srand((unsigned int)time(NULL)); - a=rand(); - srand((unsigned int)SDL_GetPerformanceCounter()); - b=rand(); - SDLTest_RandomInit(rndContext, a, b); + srand((unsigned int)time(NULL)); + a = rand(); + srand((unsigned int)SDL_GetPerformanceCounter()); + b = rand(); + SDLTest_RandomInit(rndContext, a, b); } /* Returns random numbers */ -unsigned int SDLTest_Random(SDLTest_RandomContext * rndContext) +unsigned int SDLTest_Random(SDLTest_RandomContext *rndContext) { - unsigned int xh, xl; + unsigned int xh, xl; - if (rndContext == NULL) { - return -1; - } + if (rndContext == NULL) { + return -1; + } - xh = rndContext->x >> 16; - xl = rndContext->x & 65535; - rndContext->x = rndContext->x * rndContext->a + rndContext->c; - rndContext->c = - xh * rndContext->ah + ((xh * rndContext->al) >> 16) + - ((xl * rndContext->ah) >> 16); - if (xl * rndContext->al >= (~rndContext->c + 1)) { - rndContext->c++; - } - return rndContext->x; + xh = rndContext->x >> 16; + xl = rndContext->x & 65535; + rndContext->x = rndContext->x * rndContext->a + rndContext->c; + rndContext->c = + xh * rndContext->ah + ((xh * rndContext->al) >> 16) + + ((xl * rndContext->ah) >> 16); + if (xl * rndContext->al >= (~rndContext->c + 1)) { + rndContext->c++; + } + return rndContext->x; } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/SDL_systhread.h b/src/thread/SDL_systhread.h index ab6872c02..90ca03762 100644 --- a/src/thread/SDL_systhread.h +++ b/src/thread/SDL_systhread.h @@ -38,11 +38,11 @@ extern "C" { on success. */ #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD -extern int SDL_SYS_CreateThread(SDL_Thread * thread, +extern int SDL_SYS_CreateThread(SDL_Thread *thread, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread); #else -extern int SDL_SYS_CreateThread(SDL_Thread * thread); +extern int SDL_SYS_CreateThread(SDL_Thread *thread); #endif /* This function does any necessary setup in the child thread */ @@ -54,10 +54,10 @@ extern int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority); /* This function waits for the thread to finish and frees any data allocated by SDL_SYS_CreateThread() */ -extern void SDL_SYS_WaitThread(SDL_Thread * thread); +extern void SDL_SYS_WaitThread(SDL_Thread *thread); /* Mark thread as cleaned up as soon as it exits, without joining. */ -extern void SDL_SYS_DetachThread(SDL_Thread * thread); +extern void SDL_SYS_DetachThread(SDL_Thread *thread); /* Get the thread local storage for this thread */ extern SDL_TLSData *SDL_SYS_GetTLSData(void); @@ -67,7 +67,7 @@ extern int SDL_SYS_SetTLSData(SDL_TLSData *data); /* This is for internal SDL use, so we don't need #ifdefs everywhere. */ extern SDL_Thread * -SDL_CreateThreadInternal(int (SDLCALL * fn) (void *), const char *name, +SDL_CreateThreadInternal(int(SDLCALL *fn)(void *), const char *name, const size_t stacksize, void *data); /* Ends C function definitions when using C++ */ diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c index 47abb59d1..408699063 100644 --- a/src/thread/SDL_thread.c +++ b/src/thread/SDL_thread.c @@ -28,12 +28,11 @@ #include "SDL_hints.h" #include "../SDL_error_c.h" - SDL_TLSID SDL_TLSCreate() { static SDL_atomic_t SDL_tls_id; - return SDL_AtomicIncRef(&SDL_tls_id)+1; + return SDL_AtomicIncRef(&SDL_tls_id) + 1; } void * @@ -45,11 +44,10 @@ SDL_TLSGet(SDL_TLSID id) if (storage == NULL || id == 0 || id > storage->limit) { return NULL; } - return storage->array[id-1].data; + return storage->array[id - 1].data; } -int -SDL_TLSSet(SDL_TLSID id, const void *value, void (SDLCALL *destructor)(void *)) +int SDL_TLSSet(SDL_TLSID id, const void *value, void(SDLCALL *destructor)(void *)) { SDL_TLSData *storage; @@ -63,7 +61,7 @@ SDL_TLSSet(SDL_TLSID id, const void *value, void (SDLCALL *destructor)(void *)) oldlimit = storage ? storage->limit : 0; newlimit = (id + TLS_ALLOC_CHUNKSIZE); - storage = (SDL_TLSData *)SDL_realloc(storage, sizeof(*storage)+(newlimit-1)*sizeof(storage->array[0])); + storage = (SDL_TLSData *)SDL_realloc(storage, sizeof(*storage) + (newlimit - 1) * sizeof(storage->array[0])); if (storage == NULL) { return SDL_OutOfMemory(); } @@ -77,13 +75,12 @@ SDL_TLSSet(SDL_TLSID id, const void *value, void (SDLCALL *destructor)(void *)) } } - storage->array[id-1].data = SDL_const_cast(void*, value); - storage->array[id-1].destructor = destructor; + storage->array[id - 1].data = SDL_const_cast(void *, value); + storage->array[id - 1].destructor = destructor; return 0; } -void -SDL_TLSCleanup() +void SDL_TLSCleanup() { SDL_TLSData *storage; @@ -100,7 +97,6 @@ SDL_TLSCleanup() } } - /* This is a generic implementation of thread-local storage which doesn't require additional OS support. @@ -109,7 +105,8 @@ SDL_TLSCleanup() storage this implementation should be improved to be production quality. */ -typedef struct SDL_TLSEntry { +typedef struct SDL_TLSEntry +{ SDL_threadID thread; SDL_TLSData *storage; struct SDL_TLSEntry *next; @@ -118,7 +115,6 @@ typedef struct SDL_TLSEntry { static SDL_mutex *SDL_generic_TLS_mutex; static SDL_TLSEntry *SDL_generic_TLS; - SDL_TLSData * SDL_Generic_GetTLSData(void) { @@ -158,8 +154,7 @@ SDL_Generic_GetTLSData(void) return storage; } -int -SDL_Generic_SetTLSData(SDL_TLSData *storage) +int SDL_Generic_SetTLSData(SDL_TLSData *storage) { SDL_threadID thread = SDL_ThreadID(); SDL_TLSEntry *prev, *entry; @@ -201,8 +196,7 @@ SDL_Generic_SetTLSData(SDL_TLSData *storage) } /* Non-thread-safe global error variable */ -static SDL_error * -SDL_GetStaticErrBuf() +static SDL_error *SDL_GetStaticErrBuf() { static SDL_error SDL_global_error; static char SDL_global_error_str[128]; @@ -212,8 +206,7 @@ SDL_GetStaticErrBuf() } #if !SDL_THREADS_DISABLED -static void SDLCALL -SDL_FreeErrBuf(void *data) +static void SDLCALL SDL_FreeErrBuf(void *data) { SDL_error *errbuf = (SDL_error *)data; @@ -286,12 +279,10 @@ SDL_GetErrBuf(void) #endif /* SDL_THREADS_DISABLED */ } - -void -SDL_RunThread(SDL_Thread *thread) +void SDL_RunThread(SDL_Thread *thread) { void *userdata = thread->userdata; - int (SDLCALL * userfunc) (void *) = thread->userfunc; + int(SDLCALL * userfunc)(void *) = thread->userfunc; int *statusloc = &thread->status; @@ -324,27 +315,27 @@ SDL_RunThread(SDL_Thread *thread) #undef SDL_CreateThreadWithStackSize #endif #if SDL_DYNAMIC_API -#define SDL_CreateThread SDL_CreateThread_REAL +#define SDL_CreateThread SDL_CreateThread_REAL #define SDL_CreateThreadWithStackSize SDL_CreateThreadWithStackSize_REAL #endif #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD SDL_Thread * -SDL_CreateThreadWithStackSize(int (SDLCALL * fn) (void *), - const char *name, const size_t stacksize, void *data, - pfnSDL_CurrentBeginThread pfnBeginThread, - pfnSDL_CurrentEndThread pfnEndThread) +SDL_CreateThreadWithStackSize(int(SDLCALL *fn)(void *), + const char *name, const size_t stacksize, void *data, + pfnSDL_CurrentBeginThread pfnBeginThread, + pfnSDL_CurrentEndThread pfnEndThread) #else SDL_Thread * -SDL_CreateThreadWithStackSize(int (SDLCALL * fn) (void *), - const char *name, const size_t stacksize, void *data) +SDL_CreateThreadWithStackSize(int(SDLCALL *fn)(void *), + const char *name, const size_t stacksize, void *data) #endif { SDL_Thread *thread; int ret; /* Allocate memory for the thread info structure */ - thread = (SDL_Thread *) SDL_calloc(1, sizeof(*thread)); + thread = (SDL_Thread *)SDL_calloc(1, sizeof(*thread)); if (thread == NULL) { SDL_OutOfMemory(); return NULL; @@ -385,13 +376,13 @@ SDL_CreateThreadWithStackSize(int (SDLCALL * fn) (void *), #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD DECLSPEC SDL_Thread *SDLCALL -SDL_CreateThread(int (SDLCALL * fn) (void *), +SDL_CreateThread(int(SDLCALL *fn)(void *), const char *name, void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread) #else DECLSPEC SDL_Thread *SDLCALL -SDL_CreateThread(int (SDLCALL * fn) (void *), +SDL_CreateThread(int(SDLCALL *fn)(void *), const char *name, void *data) #endif { @@ -403,9 +394,9 @@ SDL_CreateThread(int (SDLCALL * fn) (void *), if (stackhint != NULL) { char *endp = NULL; const Sint64 hintval = SDL_strtoll(stackhint, &endp, 10); - if ((*stackhint != '\0') && (*endp == '\0')) { /* a valid number? */ - if (hintval > 0) { /* reject bogus values. */ - stacksize = (size_t) hintval; + if ((*stackhint != '\0') && (*endp == '\0')) { /* a valid number? */ + if (hintval > 0) { /* reject bogus values. */ + stacksize = (size_t)hintval; } } } @@ -418,8 +409,9 @@ SDL_CreateThread(int (SDLCALL * fn) (void *), } SDL_Thread * -SDL_CreateThreadInternal(int (SDLCALL * fn) (void *), const char *name, - const size_t stacksize, void *data) { +SDL_CreateThreadInternal(int(SDLCALL *fn)(void *), const char *name, + const size_t stacksize, void *data) +{ #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD return SDL_CreateThreadWithStackSize(fn, name, stacksize, data, NULL, NULL); #else @@ -428,7 +420,7 @@ SDL_CreateThreadInternal(int (SDLCALL * fn) (void *), const char *name, } SDL_threadID -SDL_GetThreadID(SDL_Thread * thread) +SDL_GetThreadID(SDL_Thread *thread) { SDL_threadID id; @@ -441,7 +433,7 @@ SDL_GetThreadID(SDL_Thread * thread) } const char * -SDL_GetThreadName(SDL_Thread * thread) +SDL_GetThreadName(SDL_Thread *thread) { if (thread) { return thread->name; @@ -450,14 +442,12 @@ SDL_GetThreadName(SDL_Thread * thread) } } -int -SDL_SetThreadPriority(SDL_ThreadPriority priority) +int SDL_SetThreadPriority(SDL_ThreadPriority priority) { return SDL_SYS_SetThreadPriority(priority); } -void -SDL_WaitThread(SDL_Thread * thread, int *status) +void SDL_WaitThread(SDL_Thread *thread, int *status) { if (thread) { SDL_SYS_WaitThread(thread); @@ -471,8 +461,7 @@ SDL_WaitThread(SDL_Thread * thread, int *status) } } -void -SDL_DetachThread(SDL_Thread * thread) +void SDL_DetachThread(SDL_Thread *thread) { if (thread == NULL) { return; @@ -485,9 +474,9 @@ SDL_DetachThread(SDL_Thread * thread) /* all other states are pretty final, see where we landed. */ const int thread_state = SDL_AtomicGet(&thread->state); if ((thread_state == SDL_THREAD_STATE_DETACHED) || (thread_state == SDL_THREAD_STATE_CLEANED)) { - return; /* already detached (you shouldn't call this twice!) */ + return; /* already detached (you shouldn't call this twice!) */ } else if (thread_state == SDL_THREAD_STATE_ZOMBIE) { - SDL_WaitThread(thread, NULL); /* already done, clean it up. */ + SDL_WaitThread(thread, NULL); /* already done, clean it up. */ } else { SDL_assert(0 && "Unexpected thread state"); } diff --git a/src/thread/SDL_thread_c.h b/src/thread/SDL_thread_c.h index f3348eaa9..3e426830f 100644 --- a/src/thread/SDL_thread_c.h +++ b/src/thread/SDL_thread_c.h @@ -66,25 +66,27 @@ struct SDL_Thread SDL_threadID threadid; SYS_ThreadHandle handle; int status; - SDL_atomic_t state; /* SDL_THREAD_STATE_* */ + SDL_atomic_t state; /* SDL_THREAD_STATE_* */ SDL_error errbuf; char *name; - size_t stacksize; /* 0 for default, >0 for user-specified stack size. */ - int (SDLCALL * userfunc) (void *); + size_t stacksize; /* 0 for default, >0 for user-specified stack size. */ + int(SDLCALL *userfunc)(void *); void *userdata; void *data; - void *endfunc; /* only used on some platforms. */ + void *endfunc; /* only used on some platforms. */ }; /* This is the function called to run a thread */ extern void SDL_RunThread(SDL_Thread *thread); /* This is the system-independent thread local storage structure */ -typedef struct { +typedef struct +{ unsigned int limit; - struct { + struct + { void *data; - void (SDLCALL *destructor)(void*); + void(SDLCALL *destructor)(void *); } array[1]; } SDL_TLSData; diff --git a/src/thread/generic/SDL_syscond.c b/src/thread/generic/SDL_syscond.c index f3255f812..5d303d956 100644 --- a/src/thread/generic/SDL_syscond.c +++ b/src/thread/generic/SDL_syscond.c @@ -58,7 +58,7 @@ SDL_CreateCond_generic(void) { SDL_cond_generic *cond; - cond = (SDL_cond_generic *) SDL_malloc(sizeof(SDL_cond_generic)); + cond = (SDL_cond_generic *)SDL_malloc(sizeof(SDL_cond_generic)); if (cond) { cond->lock = SDL_CreateMutex(); cond->wait_sem = SDL_CreateSemaphore(0); @@ -75,8 +75,7 @@ SDL_CreateCond_generic(void) } /* Destroy a condition variable */ -void -SDL_DestroyCond_generic(SDL_cond * _cond) +void SDL_DestroyCond_generic(SDL_cond *_cond) { SDL_cond_generic *cond = (SDL_cond_generic *)_cond; if (cond) { @@ -94,8 +93,7 @@ SDL_DestroyCond_generic(SDL_cond * _cond) } /* Restart one of the threads that are waiting on the condition variable */ -int -SDL_CondSignal_generic(SDL_cond * _cond) +int SDL_CondSignal_generic(SDL_cond *_cond) { SDL_cond_generic *cond = (SDL_cond_generic *)_cond; if (cond == NULL) { @@ -119,8 +117,7 @@ SDL_CondSignal_generic(SDL_cond * _cond) } /* Restart all threads that are waiting on the condition variable */ -int -SDL_CondBroadcast_generic(SDL_cond * _cond) +int SDL_CondBroadcast_generic(SDL_cond *_cond) { SDL_cond_generic *cond = (SDL_cond_generic *)_cond; if (cond == NULL) { @@ -174,8 +171,7 @@ Thread B: SDL_CondSignal(cond); SDL_UnlockMutex(lock); */ -int -SDL_CondWaitTimeout_generic(SDL_cond * _cond, SDL_mutex * mutex, Uint32 ms) +int SDL_CondWaitTimeout_generic(SDL_cond *_cond, SDL_mutex *mutex, Uint32 ms) { SDL_cond_generic *cond = (SDL_cond_generic *)_cond; int retval; @@ -230,8 +226,7 @@ SDL_CondWaitTimeout_generic(SDL_cond * _cond, SDL_mutex * mutex, Uint32 ms) } /* Wait on the condition variable forever */ -int -SDL_CondWait_generic(SDL_cond * cond, SDL_mutex * mutex) +int SDL_CondWait_generic(SDL_cond *cond, SDL_mutex *mutex) { return SDL_CondWaitTimeout_generic(cond, mutex, SDL_MUTEX_MAXWAIT); } diff --git a/src/thread/generic/SDL_syscond_c.h b/src/thread/generic/SDL_syscond_c.h index b7dadc781..00c7c2255 100644 --- a/src/thread/generic/SDL_syscond_c.h +++ b/src/thread/generic/SDL_syscond_c.h @@ -27,13 +27,13 @@ #if SDL_THREAD_GENERIC_COND_SUFFIX -SDL_cond * SDL_CreateCond_generic(void); -void SDL_DestroyCond_generic(SDL_cond * cond); -int SDL_CondSignal_generic(SDL_cond * cond); -int SDL_CondBroadcast_generic(SDL_cond * cond); -int SDL_CondWait_generic(SDL_cond * cond, SDL_mutex * mutex); -int SDL_CondWaitTimeout_generic(SDL_cond * cond, - SDL_mutex * mutex, Uint32 ms); +SDL_cond *SDL_CreateCond_generic(void); +void SDL_DestroyCond_generic(SDL_cond *cond); +int SDL_CondSignal_generic(SDL_cond *cond); +int SDL_CondBroadcast_generic(SDL_cond *cond); +int SDL_CondWait_generic(SDL_cond *cond, SDL_mutex *mutex); +int SDL_CondWaitTimeout_generic(SDL_cond *cond, + SDL_mutex *mutex, Uint32 ms); #endif /* SDL_THREAD_GENERIC_COND_SUFFIX */ diff --git a/src/thread/generic/SDL_sysmutex.c b/src/thread/generic/SDL_sysmutex.c index 12cc58041..dce32191f 100644 --- a/src/thread/generic/SDL_sysmutex.c +++ b/src/thread/generic/SDL_sysmutex.c @@ -25,7 +25,6 @@ #include "SDL_thread.h" #include "SDL_systhread_c.h" - struct SDL_mutex { int recursive; @@ -40,7 +39,7 @@ SDL_CreateMutex(void) SDL_mutex *mutex; /* Allocate mutex memory */ - mutex = (SDL_mutex *) SDL_calloc(1, sizeof(*mutex)); + mutex = (SDL_mutex *)SDL_calloc(1, sizeof(*mutex)); #if !SDL_THREADS_DISABLED if (mutex) { @@ -61,8 +60,7 @@ SDL_CreateMutex(void) } /* Free the mutex */ -void -SDL_DestroyMutex(SDL_mutex * mutex) +void SDL_DestroyMutex(SDL_mutex *mutex) { if (mutex) { if (mutex->sem) { @@ -73,8 +71,7 @@ SDL_DestroyMutex(SDL_mutex * mutex) } /* Lock the mutex */ -int -SDL_LockMutex(SDL_mutex * mutex) +int SDL_LockMutex(SDL_mutex *mutex) { #if SDL_THREADS_DISABLED return 0; @@ -103,8 +100,7 @@ SDL_LockMutex(SDL_mutex * mutex) } /* try Lock the mutex */ -int -SDL_TryLockMutex(SDL_mutex * mutex) +int SDL_TryLockMutex(SDL_mutex *mutex) { #if SDL_THREADS_DISABLED return 0; @@ -136,8 +132,7 @@ SDL_TryLockMutex(SDL_mutex * mutex) } /* Unlock the mutex */ -int -SDL_mutexV(SDL_mutex * mutex) +int SDL_mutexV(SDL_mutex *mutex) { #if SDL_THREADS_DISABLED return 0; diff --git a/src/thread/generic/SDL_syssem.c b/src/thread/generic/SDL_syssem.c index 797ede463..878c92b46 100644 --- a/src/thread/generic/SDL_syssem.c +++ b/src/thread/generic/SDL_syssem.c @@ -26,47 +26,41 @@ #include "SDL_thread.h" #include "SDL_systhread_c.h" - #if SDL_THREADS_DISABLED SDL_sem * SDL_CreateSemaphore(Uint32 initial_value) { SDL_SetError("SDL not built with thread support"); - return (SDL_sem *) 0; + return (SDL_sem *)0; } -void -SDL_DestroySemaphore(SDL_sem * sem) +void SDL_DestroySemaphore(SDL_sem *sem) { } -int -SDL_SemTryWait(SDL_sem * sem) +int SDL_SemTryWait(SDL_sem *sem) { return SDL_SetError("SDL not built with thread support"); } -int -SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) +int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) { return SDL_SetError("SDL not built with thread support"); } -int -SDL_SemWait(SDL_sem * sem) +int SDL_SemWait(SDL_sem *sem) { return SDL_SetError("SDL not built with thread support"); } Uint32 -SDL_SemValue(SDL_sem * sem) +SDL_SemValue(SDL_sem *sem) { return 0; } -int -SDL_SemPost(SDL_sem * sem) +int SDL_SemPost(SDL_sem *sem) { return SDL_SetError("SDL not built with thread support"); } @@ -86,7 +80,7 @@ SDL_CreateSemaphore(Uint32 initial_value) { SDL_sem *sem; - sem = (SDL_sem *) SDL_malloc(sizeof(*sem)); + sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); if (sem == NULL) { SDL_OutOfMemory(); return NULL; @@ -107,8 +101,7 @@ SDL_CreateSemaphore(Uint32 initial_value) /* WARNING: You cannot call this function when another thread is using the semaphore. */ -void -SDL_DestroySemaphore(SDL_sem * sem) +void SDL_DestroySemaphore(SDL_sem *sem) { if (sem) { sem->count = 0xFFFFFFFF; @@ -126,8 +119,7 @@ SDL_DestroySemaphore(SDL_sem * sem) } } -int -SDL_SemTryWait(SDL_sem * sem) +int SDL_SemTryWait(SDL_sem *sem) { int retval; @@ -146,8 +138,7 @@ SDL_SemTryWait(SDL_sem * sem) return retval; } -int -SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) +int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) { int retval; @@ -176,14 +167,13 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) return retval; } -int -SDL_SemWait(SDL_sem * sem) +int SDL_SemWait(SDL_sem *sem) { return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); } Uint32 -SDL_SemValue(SDL_sem * sem) +SDL_SemValue(SDL_sem *sem) { Uint32 value; @@ -196,8 +186,7 @@ SDL_SemValue(SDL_sem * sem) return value; } -int -SDL_SemPost(SDL_sem * sem) +int SDL_SemPost(SDL_sem *sem) { if (sem == NULL) { return SDL_InvalidParamError("sem"); diff --git a/src/thread/generic/SDL_systhread.c b/src/thread/generic/SDL_systhread.c index 1f8f04223..18707ff88 100644 --- a/src/thread/generic/SDL_systhread.c +++ b/src/thread/generic/SDL_systhread.c @@ -26,20 +26,17 @@ #include "../SDL_systhread.h" #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD -int -SDL_SYS_CreateThread(SDL_Thread * thread, - pfnSDL_CurrentBeginThread pfnBeginThread, - pfnSDL_CurrentEndThread pfnEndThread) +int SDL_SYS_CreateThread(SDL_Thread *thread, + pfnSDL_CurrentBeginThread pfnBeginThread, + pfnSDL_CurrentEndThread pfnEndThread) #else -int -SDL_SYS_CreateThread(SDL_Thread * thread) +int SDL_SYS_CreateThread(SDL_Thread *thread) #endif /* SDL_PASSED_BEGINTHREAD_ENDTHREAD */ { return SDL_SetError("Threads are not supported on this platform"); } -void -SDL_SYS_SetupThread(const char *name) +void SDL_SYS_SetupThread(const char *name) { return; } @@ -50,20 +47,17 @@ SDL_ThreadID(void) return 0; } -int -SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) +int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) { return 0; } -void -SDL_SYS_WaitThread(SDL_Thread * thread) +void SDL_SYS_WaitThread(SDL_Thread *thread) { return; } -void -SDL_SYS_DetachThread(SDL_Thread * thread) +void SDL_SYS_DetachThread(SDL_Thread *thread) { return; } diff --git a/src/thread/generic/SDL_systls.c b/src/thread/generic/SDL_systls.c index d4c371c39..546c2fb1b 100644 --- a/src/thread/generic/SDL_systls.c +++ b/src/thread/generic/SDL_systls.c @@ -22,15 +22,13 @@ #include "../../SDL_internal.h" #include "../SDL_thread_c.h" - SDL_TLSData * SDL_SYS_GetTLSData(void) { return SDL_Generic_GetTLSData(); } -int -SDL_SYS_SetTLSData(SDL_TLSData *data) +int SDL_SYS_SetTLSData(SDL_TLSData *data) { return SDL_Generic_SetTLSData(data); } diff --git a/src/thread/n3ds/SDL_syscond.c b/src/thread/n3ds/SDL_syscond.c index e825d6af0..7510b403c 100644 --- a/src/thread/n3ds/SDL_syscond.c +++ b/src/thread/n3ds/SDL_syscond.c @@ -35,7 +35,7 @@ struct SDL_cond SDL_cond * SDL_CreateCond(void) { - SDL_cond *cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); + SDL_cond *cond = (SDL_cond *)SDL_malloc(sizeof(SDL_cond)); if (cond) { CondVar_Init(&cond->cond_variable); } else { @@ -45,8 +45,7 @@ SDL_CreateCond(void) } /* Destroy a condition variable */ -void -SDL_DestroyCond(SDL_cond *cond) +void SDL_DestroyCond(SDL_cond *cond) { if (cond) { SDL_free(cond); @@ -54,8 +53,7 @@ SDL_DestroyCond(SDL_cond *cond) } /* Restart one of the threads that are waiting on the condition variable */ -int -SDL_CondSignal(SDL_cond *cond) +int SDL_CondSignal(SDL_cond *cond) { if (cond == NULL) { return SDL_InvalidParamError("cond"); @@ -66,8 +64,7 @@ SDL_CondSignal(SDL_cond *cond) } /* Restart all threads that are waiting on the condition variable */ -int -SDL_CondBroadcast(SDL_cond *cond) +int SDL_CondBroadcast(SDL_cond *cond) { if (cond == NULL) { return SDL_InvalidParamError("cond"); @@ -98,8 +95,7 @@ Thread B: SDL_CondSignal(cond); SDL_UnlockMutex(lock); */ -int -SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) +int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) { Result res; @@ -115,15 +111,14 @@ SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) CondVar_Wait(&cond->cond_variable, &mutex->lock.lock); } else { res = CondVar_WaitTimeout(&cond->cond_variable, &mutex->lock.lock, - (s64) ms * 1000000LL); + (s64)ms * 1000000LL); } return R_SUCCEEDED(res) ? 0 : SDL_MUTEX_TIMEDOUT; } /* Wait on the condition variable forever */ -int -SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex) +int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex) { return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT); } diff --git a/src/thread/n3ds/SDL_sysmutex.c b/src/thread/n3ds/SDL_sysmutex.c index 59fa8a801..1a4063d97 100644 --- a/src/thread/n3ds/SDL_sysmutex.c +++ b/src/thread/n3ds/SDL_sysmutex.c @@ -33,7 +33,7 @@ SDL_CreateMutex(void) SDL_mutex *mutex; /* Allocate mutex memory */ - mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); + mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex)); if (mutex) { RecursiveLock_Init(&mutex->lock); } else { @@ -43,8 +43,7 @@ SDL_CreateMutex(void) } /* Free the mutex */ -void -SDL_DestroyMutex(SDL_mutex *mutex) +void SDL_DestroyMutex(SDL_mutex *mutex) { if (mutex) { SDL_free(mutex); @@ -52,8 +51,7 @@ SDL_DestroyMutex(SDL_mutex *mutex) } /* Lock the mutex */ -int -SDL_LockMutex(SDL_mutex *mutex) +int SDL_LockMutex(SDL_mutex *mutex) { if (mutex == NULL) { return SDL_SetError("Passed a NULL mutex"); @@ -65,8 +63,7 @@ SDL_LockMutex(SDL_mutex *mutex) } /* try Lock the mutex */ -int -SDL_TryLockMutex(SDL_mutex *mutex) +int SDL_TryLockMutex(SDL_mutex *mutex) { if (mutex == NULL) { return SDL_SetError("Passed a NULL mutex"); @@ -76,8 +73,7 @@ SDL_TryLockMutex(SDL_mutex *mutex) } /* Unlock the mutex */ -int -SDL_mutexV(SDL_mutex *mutex) +int SDL_mutexV(SDL_mutex *mutex) { if (mutex == NULL) { return SDL_SetError("Passed a NULL mutex"); diff --git a/src/thread/n3ds/SDL_syssem.c b/src/thread/n3ds/SDL_syssem.c index 0621e8a2c..1a4109be5 100644 --- a/src/thread/n3ds/SDL_syssem.c +++ b/src/thread/n3ds/SDL_syssem.c @@ -43,7 +43,7 @@ SDL_CreateSemaphore(Uint32 initial_value) return NULL; } - sem = (SDL_sem *) SDL_malloc(sizeof(*sem)); + sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); if (sem == NULL) { SDL_OutOfMemory(); return NULL; @@ -57,16 +57,14 @@ SDL_CreateSemaphore(Uint32 initial_value) /* WARNING: You cannot call this function when another thread is using the semaphore. */ -void -SDL_DestroySemaphore(SDL_sem *sem) +void SDL_DestroySemaphore(SDL_sem *sem) { if (sem) { SDL_free(sem); } } -int -SDL_SemTryWait(SDL_sem *sem) +int SDL_SemTryWait(SDL_sem *sem) { if (sem == NULL) { return SDL_InvalidParamError("sem"); @@ -75,8 +73,7 @@ SDL_SemTryWait(SDL_sem *sem) return SDL_SemWaitTimeout(sem, 0); } -int -SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) +int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) { int retval; @@ -104,8 +101,7 @@ SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) return retval; } -int -SDL_SemWait(SDL_sem *sem) +int SDL_SemWait(SDL_sem *sem) { return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); } @@ -120,8 +116,7 @@ SDL_SemValue(SDL_sem *sem) return sem->semaphore.current_count; } -int -SDL_SemPost(SDL_sem *sem) +int SDL_SemPost(SDL_sem *sem) { if (sem == NULL) { return SDL_InvalidParamError("sem"); diff --git a/src/thread/n3ds/SDL_systhread.c b/src/thread/n3ds/SDL_systhread.c index a588400ad..caf2df7bb 100644 --- a/src/thread/n3ds/SDL_systhread.c +++ b/src/thread/n3ds/SDL_systhread.c @@ -37,10 +37,9 @@ static size_t GetStackSize(size_t requested_size); -static void -ThreadEntry(void *arg) +static void ThreadEntry(void *arg) { - SDL_RunThread((SDL_Thread *) arg); + SDL_RunThread((SDL_Thread *)arg); threadExit(0); } @@ -48,8 +47,7 @@ ThreadEntry(void *arg) #error "SDL_PASSED_BEGINTHREAD_ENDTHREAD is not supported on N3DS" #endif -int -SDL_SYS_CreateThread(SDL_Thread *thread) +int SDL_SYS_CreateThread(SDL_Thread *thread) { s32 priority = N3DS_THREAD_PRIORITY_MEDIUM; size_t stack_size = GetStackSize(thread->stacksize); @@ -86,8 +84,7 @@ GetStackSize(size_t requested_size) return requested_size; } -void -SDL_SYS_SetupThread(const char *name) +void SDL_SYS_SetupThread(const char *name) { return; } @@ -97,11 +94,10 @@ SDL_ThreadID(void) { u32 thread_ID = 0; svcGetThreadId(&thread_ID, CUR_THREAD_HANDLE); - return (SDL_threadID) thread_ID; + return (SDL_threadID)thread_ID; } -int -SDL_SYS_SetThreadPriority(SDL_ThreadPriority sdl_priority) +int SDL_SYS_SetThreadPriority(SDL_ThreadPriority sdl_priority) { s32 svc_priority; switch (sdl_priority) { @@ -120,11 +116,10 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority sdl_priority) default: svc_priority = N3DS_THREAD_PRIORITY_MEDIUM; } - return (int) svcSetThreadPriority(CUR_THREAD_HANDLE, svc_priority); + return (int)svcSetThreadPriority(CUR_THREAD_HANDLE, svc_priority); } -void -SDL_SYS_WaitThread(SDL_Thread *thread) +void SDL_SYS_WaitThread(SDL_Thread *thread) { Result res = threadJoin(thread->handle, U64_MAX); @@ -137,8 +132,7 @@ SDL_SYS_WaitThread(SDL_Thread *thread) } } -void -SDL_SYS_DetachThread(SDL_Thread *thread) +void SDL_SYS_DetachThread(SDL_Thread *thread) { threadDetach(thread->handle); } diff --git a/src/thread/ngage/SDL_sysmutex.cpp b/src/thread/ngage/SDL_sysmutex.cpp index 387887153..0983f71af 100644 --- a/src/thread/ngage/SDL_sysmutex.cpp +++ b/src/thread/ngage/SDL_sysmutex.cpp @@ -32,9 +32,9 @@ struct SDL_mutex TInt handle; }; -extern TInt CreateUnique(TInt (*aFunc)(const TDesC& aName, TAny*, TAny*), TAny*, TAny*); +extern TInt CreateUnique(TInt (*aFunc)(const TDesC &aName, TAny *, TAny *), TAny *, TAny *); -static TInt NewMutex(const TDesC& aName, TAny* aPtr1, TAny*) +static TInt NewMutex(const TDesC &aName, TAny *aPtr1, TAny *) { return ((RMutex *)aPtr1)->CreateGlobal(aName); } @@ -50,21 +50,20 @@ SDL_CreateMutex(void) SDL_SetError("Couldn't create mutex."); return NULL; } - SDL_mutex* mutex = new /*(ELeave)*/ SDL_mutex; + SDL_mutex *mutex = new /*(ELeave)*/ SDL_mutex; mutex->handle = rmutex.Handle(); return mutex; } /* Free the mutex */ -void -SDL_DestroyMutex(SDL_mutex * mutex) +void SDL_DestroyMutex(SDL_mutex *mutex) { if (mutex) { RMutex rmutex; rmutex.SetHandle(mutex->handle); rmutex.Signal(); rmutex.Close(); - delete(mutex); + delete (mutex); mutex = NULL; } } @@ -86,8 +85,7 @@ SDL_TryLockMutex(SDL_mutex * mutex) #endif /* Lock the mutex */ -int -SDL_LockMutex(SDL_mutex * mutex) +int SDL_LockMutex(SDL_mutex *mutex) { if (mutex == NULL) { return SDL_InvalidParamError("mutex"); @@ -101,8 +99,7 @@ SDL_LockMutex(SDL_mutex * mutex) } /* Unlock the mutex */ -int -SDL_UnlockMutex(SDL_mutex * mutex) +int SDL_UnlockMutex(SDL_mutex *mutex) { if (mutex == NULL) { return SDL_InvalidParamError("mutex"); diff --git a/src/thread/ngage/SDL_syssem.cpp b/src/thread/ngage/SDL_syssem.cpp index 64cbb97c0..961b0f9bf 100644 --- a/src/thread/ngage/SDL_syssem.cpp +++ b/src/thread/ngage/SDL_syssem.cpp @@ -37,18 +37,17 @@ struct SDL_semaphore struct TInfo { - TInfo(TInt aTime, TInt aHandle) : - iTime(aTime), iHandle(aHandle), iVal(0) {} + TInfo(TInt aTime, TInt aHandle) : iTime(aTime), iHandle(aHandle), iVal(0) {} TInt iTime; TInt iHandle; TInt iVal; }; -extern TInt CreateUnique(TInt (*aFunc)(const TDesC& aName, TAny*, TAny*), TAny*, TAny*); +extern TInt CreateUnique(TInt (*aFunc)(const TDesC &aName, TAny *, TAny *), TAny *, TAny *); -static TBool RunThread(TAny* aInfo) +static TBool RunThread(TAny *aInfo) { - TInfo* info = STATIC_CAST(TInfo*, aInfo); + TInfo *info = STATIC_CAST(TInfo *, aInfo); User::After(info->iTime); RSemaphore sema; sema.SetHandle(info->iHandle); @@ -57,15 +56,14 @@ static TBool RunThread(TAny* aInfo) return 0; } -static TInt -NewThread(const TDesC& aName, TAny* aPtr1, TAny* aPtr2) +static TInt NewThread(const TDesC &aName, TAny *aPtr1, TAny *aPtr2) { return ((RThread *)(aPtr1))->Create(aName, RunThread, KDefaultStackSize, NULL, aPtr2); } -static TInt NewSema(const TDesC& aName, TAny* aPtr1, TAny* aPtr2) +static TInt NewSema(const TDesC &aName, TAny *aPtr1, TAny *aPtr2) { - TInt value = *((TInt*) aPtr2); + TInt value = *((TInt *)aPtr2); return ((RSemaphore *)aPtr1)->CreateGlobal(aName, value); } @@ -87,14 +85,13 @@ SDL_CreateSemaphore(Uint32 initial_value) if (status != KErrNone) { SDL_SetError("Couldn't create semaphore"); } - SDL_semaphore* sem = new /*(ELeave)*/ SDL_semaphore; + SDL_semaphore *sem = new /*(ELeave)*/ SDL_semaphore; sem->handle = s.Handle(); sem->count = initial_value; return sem; } -void -SDL_DestroySemaphore(SDL_sem * sem) +void SDL_DestroySemaphore(SDL_sem *sem) { if (sem != NULL) { RSemaphore sema; @@ -106,8 +103,7 @@ SDL_DestroySemaphore(SDL_sem * sem) } } -int -SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) +int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) { if (sem == NULL) { return SDL_InvalidParamError("sem"); @@ -119,8 +115,8 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) } RThread thread; - TInfo* info = new (ELeave)TInfo(timeout, sem->handle); - TInt status = CreateUnique(NewThread, &thread, info); + TInfo *info = new (ELeave) TInfo(timeout, sem->handle); + TInt status = CreateUnique(NewThread, &thread, info); if (status != KErrNone) { return status; @@ -137,8 +133,7 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) return info->iVal; } -int -SDL_SemTryWait(SDL_sem *sem) +int SDL_SemTryWait(SDL_sem *sem) { if (sem == NULL) { return SDL_InvalidParamError("sem"); @@ -150,14 +145,13 @@ SDL_SemTryWait(SDL_sem *sem) return SDL_MUTEX_TIMEOUT; } -int -SDL_SemWait(SDL_sem * sem) +int SDL_SemWait(SDL_sem *sem) { return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); } Uint32 -SDL_SemValue(SDL_sem * sem) +SDL_SemValue(SDL_sem *sem) { if (sem == NULL) { SDL_InvalidParamError("sem"); @@ -166,8 +160,7 @@ SDL_SemValue(SDL_sem * sem) return sem->count; } -int -SDL_SemPost(SDL_sem * sem) +int SDL_SemPost(SDL_sem *sem) { if (sem == NULL) { return SDL_InvalidParamError("sem"); diff --git a/src/thread/ngage/SDL_systhread.cpp b/src/thread/ngage/SDL_systhread.cpp index 6965e4316..691940b73 100644 --- a/src/thread/ngage/SDL_systhread.cpp +++ b/src/thread/ngage/SDL_systhread.cpp @@ -36,24 +36,21 @@ extern "C" { static int object_count; -static int -RunThread(TAny* data) +static int RunThread(TAny *data) { - SDL_RunThread((SDL_Thread*)data); + SDL_RunThread((SDL_Thread *)data); return 0; } -static TInt -NewThread(const TDesC& aName, TAny* aPtr1, TAny* aPtr2) +static TInt NewThread(const TDesC &aName, TAny *aPtr1, TAny *aPtr2) { return ((RThread *)(aPtr1))->Create(aName, RunThread, KDefaultStackSize, NULL, aPtr2); } -int -CreateUnique(TInt (*aFunc)(const TDesC& aName, TAny*, TAny*), TAny* aPtr1, TAny* aPtr2) +int CreateUnique(TInt (*aFunc)(const TDesC &aName, TAny *, TAny *), TAny *aPtr1, TAny *aPtr2) { TBuf<16> name; - TInt status = KErrNone; + TInt status = KErrNone; do { object_count++; name.Format(_L("SDL_%x"), object_count); @@ -62,14 +59,13 @@ CreateUnique(TInt (*aFunc)(const TDesC& aName, TAny*, TAny*), TAny* aPtr1, TAny* return status; } -int -SDL_SYS_CreateThread(SDL_Thread *thread) +int SDL_SYS_CreateThread(SDL_Thread *thread) { RThread rthread; TInt status = CreateUnique(NewThread, &rthread, thread); if (status != KErrNone) { - delete(((RThread*)(thread->handle))); + delete (((RThread *)(thread->handle))); thread->handle = NULL; return SDL_SetError("Not enough resources to create thread"); } @@ -79,8 +75,7 @@ SDL_SYS_CreateThread(SDL_Thread *thread) return 0; } -void -SDL_SYS_SetupThread(const char *name) +void SDL_SYS_SetupThread(const char *name) { return; } @@ -88,19 +83,17 @@ SDL_SYS_SetupThread(const char *name) SDL_threadID SDL_ThreadID(void) { - RThread current; + RThread current; TThreadId id = current.Id(); return id; } -int -SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) +int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) { return 0; } -void -SDL_SYS_WaitThread(SDL_Thread * thread) +void SDL_SYS_WaitThread(SDL_Thread *thread) { RThread t; t.Open(thread->threadid); @@ -112,8 +105,7 @@ SDL_SYS_WaitThread(SDL_Thread * thread) t.Close(); } -void -SDL_SYS_DetachThread(SDL_Thread * thread) +void SDL_SYS_DetachThread(SDL_Thread *thread) { return; } diff --git a/src/thread/ps2/SDL_syssem.c b/src/thread/ps2/SDL_syssem.c index 1c33e63c5..c74b2a9fd 100644 --- a/src/thread/ps2/SDL_syssem.c +++ b/src/thread/ps2/SDL_syssem.c @@ -33,11 +33,13 @@ #include -struct SDL_semaphore { - s32 semid; +struct SDL_semaphore +{ + s32 semid; }; -static void usercb(struct timer_alarm_t *alarm, void *arg) { +static void usercb(struct timer_alarm_t *alarm, void *arg) +{ iReleaseWaitThread((int)arg); } @@ -47,12 +49,12 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) SDL_sem *sem; ee_sema_t sema; - sem = (SDL_sem *) SDL_malloc(sizeof(*sem)); + sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); if (sem != NULL) { /* TODO: Figure out the limit on the maximum value. */ sema.init_count = initial_value; - sema.max_count = 255; - sema.option = 0; + sema.max_count = 255; + sema.option = 0; sem->semid = CreateSema(&sema); if (sem->semid < 0) { diff --git a/src/thread/ps2/SDL_systhread.c b/src/thread/ps2/SDL_systhread.c index 4df65abf1..9f1430f9b 100644 --- a/src/thread/ps2/SDL_systhread.c +++ b/src/thread/ps2/SDL_systhread.c @@ -33,7 +33,8 @@ #include "../SDL_thread_c.h" #include -static void FinishThread(SDL_Thread *thread) { +static void FinishThread(SDL_Thread *thread) +{ ee_thread_status_t info; int res; @@ -69,18 +70,17 @@ int SDL_SYS_CreateThread(SDL_Thread *thread) priority = status.current_priority; } - stack_size = thread->stacksize ? ((int) thread->stacksize) : 0x1800; - + stack_size = thread->stacksize ? ((int)thread->stacksize) : 0x1800; /* Create EE Thread */ - eethread.attr = 0; - eethread.option = 0; - eethread.func = &childThread; - eethread.stack = SDL_malloc(stack_size); - eethread.stack_size = stack_size; - eethread.gp_reg = &_gp; - eethread.initial_priority = priority; - thread->handle = CreateThread(&eethread); + eethread.attr = 0; + eethread.option = 0; + eethread.func = &childThread; + eethread.stack = SDL_malloc(stack_size); + eethread.stack_size = stack_size; + eethread.gp_reg = &_gp; + eethread.initial_priority = priority; + thread->handle = CreateThread(&eethread); if (thread->handle < 0) { return SDL_SetError("CreateThread() failed"); @@ -88,8 +88,8 @@ int SDL_SYS_CreateThread(SDL_Thread *thread) // Prepare el semaphore for the ending function sema.init_count = 0; - sema.max_count = 1; - sema.option = 0; + sema.max_count = 1; + sema.option = 0; thread->endfunc = (void *)CreateSema(&sema); return StartThread(thread->handle, thread); @@ -102,7 +102,7 @@ void SDL_SYS_SetupThread(const char *name) SDL_threadID SDL_ThreadID(void) { - return (SDL_threadID) GetThreadId(); + return (SDL_threadID)GetThreadId(); } void SDL_SYS_WaitThread(SDL_Thread *thread) @@ -131,7 +131,7 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) value = 50; } - return ChangeThreadPriority(GetThreadId(),value); + return ChangeThreadPriority(GetThreadId(), value); } #endif /* SDL_THREAD_PS2 */ diff --git a/src/thread/psp/SDL_syscond.c b/src/thread/psp/SDL_syscond.c index 32dcbd176..7daa10033 100644 --- a/src/thread/psp/SDL_syscond.c +++ b/src/thread/psp/SDL_syscond.c @@ -45,7 +45,7 @@ SDL_CreateCond(void) { SDL_cond *cond; - cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); + cond = (SDL_cond *)SDL_malloc(sizeof(SDL_cond)); if (cond) { cond->lock = SDL_CreateMutex(); cond->wait_sem = SDL_CreateSemaphore(0); @@ -62,8 +62,7 @@ SDL_CreateCond(void) } /* Destroy a condition variable */ -void -SDL_DestroyCond(SDL_cond * cond) +void SDL_DestroyCond(SDL_cond *cond) { if (cond) { if (cond->wait_sem) { @@ -80,8 +79,7 @@ SDL_DestroyCond(SDL_cond * cond) } /* Restart one of the threads that are waiting on the condition variable */ -int -SDL_CondSignal(SDL_cond * cond) +int SDL_CondSignal(SDL_cond *cond) { if (cond == NULL) { return SDL_InvalidParamError("cond"); @@ -104,8 +102,7 @@ SDL_CondSignal(SDL_cond * cond) } /* Restart all threads that are waiting on the condition variable */ -int -SDL_CondBroadcast(SDL_cond * cond) +int SDL_CondBroadcast(SDL_cond *cond) { if (cond == NULL) { return SDL_InvalidParamError("cond"); @@ -158,8 +155,7 @@ Thread B: SDL_CondSignal(cond); SDL_UnlockMutex(lock); */ -int -SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) +int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) { int retval; @@ -213,8 +209,7 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) } /* Wait on the condition variable forever */ -int -SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) +int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex) { return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT); } diff --git a/src/thread/psp/SDL_sysmutex.c b/src/thread/psp/SDL_sysmutex.c index d672ec516..5f3a7f27d 100644 --- a/src/thread/psp/SDL_sysmutex.c +++ b/src/thread/psp/SDL_sysmutex.c @@ -45,7 +45,7 @@ SDL_CreateMutex(void) SceInt32 res = 0; /* Allocate mutex memory */ - mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); + mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex)); if (mutex) { res = sceKernelCreateLwMutex( @@ -53,8 +53,7 @@ SDL_CreateMutex(void) "SDL mutex", SCE_KERNEL_MUTEX_ATTR_RECURSIVE, 0, - NULL - ); + NULL); if (res < 0) { SDL_SetError("Error trying to create mutex: %lx", res); @@ -66,8 +65,7 @@ SDL_CreateMutex(void) } /* Free the mutex */ -void -SDL_DestroyMutex(SDL_mutex * mutex) +void SDL_DestroyMutex(SDL_mutex *mutex) { if (mutex) { sceKernelDeleteLwMutex(&mutex->lock); @@ -76,8 +74,7 @@ SDL_DestroyMutex(SDL_mutex * mutex) } /* Try to lock the mutex */ -int -SDL_TryLockMutex(SDL_mutex * mutex) +int SDL_TryLockMutex(SDL_mutex *mutex) { #if SDL_THREADS_DISABLED return 0; @@ -89,25 +86,23 @@ SDL_TryLockMutex(SDL_mutex * mutex) res = sceKernelTryLockLwMutex(&mutex->lock, 1); switch (res) { - case SCE_KERNEL_ERROR_OK: - return 0; - break; - case SCE_KERNEL_ERROR_WAIT_TIMEOUT: - return SDL_MUTEX_TIMEDOUT; - break; - default: - return SDL_SetError("Error trying to lock mutex: %lx", res); - break; + case SCE_KERNEL_ERROR_OK: + return 0; + break; + case SCE_KERNEL_ERROR_WAIT_TIMEOUT: + return SDL_MUTEX_TIMEDOUT; + break; + default: + return SDL_SetError("Error trying to lock mutex: %lx", res); + break; } return -1; #endif /* SDL_THREADS_DISABLED */ } - /* Lock the mutex */ -int -SDL_mutexP(SDL_mutex * mutex) +int SDL_mutexP(SDL_mutex *mutex) { #if SDL_THREADS_DISABLED return 0; @@ -127,8 +122,7 @@ SDL_mutexP(SDL_mutex * mutex) } /* Unlock the mutex */ -int -SDL_mutexV(SDL_mutex * mutex) +int SDL_mutexV(SDL_mutex *mutex) { #if SDL_THREADS_DISABLED return 0; diff --git a/src/thread/psp/SDL_syssem.c b/src/thread/psp/SDL_syssem.c index b3d145701..2b6b89801 100644 --- a/src/thread/psp/SDL_syssem.c +++ b/src/thread/psp/SDL_syssem.c @@ -33,17 +33,17 @@ #include #include -struct SDL_semaphore { - SceUID semid; +struct SDL_semaphore +{ + SceUID semid; }; - /* Create a semaphore */ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) { SDL_sem *sem; - sem = (SDL_sem *) SDL_malloc(sizeof(*sem)); + sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); if (sem != NULL) { /* TODO: Figure out the limit on the maximum value. */ sem->semid = sceKernelCreateSema("SDL sema", 0, initial_value, 255, NULL); @@ -96,18 +96,18 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) if (timeout == SDL_MUTEX_MAXWAIT) { pTimeout = NULL; } else { - timeout *= 1000; /* Convert to microseconds. */ + timeout *= 1000; /* Convert to microseconds. */ pTimeout = &timeout; } - res = sceKernelWaitSema(sem->semid, 1, (SceUInt *) pTimeout); - switch (res) { - case SCE_KERNEL_ERROR_OK: - return 0; - case SCE_KERNEL_ERROR_WAIT_TIMEOUT: - return SDL_MUTEX_TIMEDOUT; - default: - return SDL_SetError("sceKernelWaitSema() failed"); + res = sceKernelWaitSema(sem->semid, 1, (SceUInt *)pTimeout); + switch (res) { + case SCE_KERNEL_ERROR_OK: + return 0; + case SCE_KERNEL_ERROR_WAIT_TIMEOUT: + return SDL_MUTEX_TIMEDOUT; + default: + return SDL_SetError("sceKernelWaitSema() failed"); } } diff --git a/src/thread/psp/SDL_systhread.c b/src/thread/psp/SDL_systhread.c index 50417cb24..fc8def493 100644 --- a/src/thread/psp/SDL_systhread.c +++ b/src/thread/psp/SDL_systhread.c @@ -34,10 +34,9 @@ #include #include - static int ThreadEntry(SceSize args, void *argp) { - SDL_RunThread(*(SDL_Thread **) argp); + SDL_RunThread(*(SDL_Thread **)argp); return 0; } @@ -53,8 +52,8 @@ int SDL_SYS_CreateThread(SDL_Thread *thread) } thread->handle = sceKernelCreateThread(thread->name, ThreadEntry, - priority, thread->stacksize ? ((int) thread->stacksize) : 0x8000, - PSP_THREAD_ATTR_VFPU, NULL); + priority, thread->stacksize ? ((int)thread->stacksize) : 0x8000, + PSP_THREAD_ATTR_VFPU, NULL); if (thread->handle < 0) { return SDL_SetError("sceKernelCreateThread() failed"); } @@ -70,7 +69,7 @@ void SDL_SYS_SetupThread(const char *name) SDL_threadID SDL_ThreadID(void) { - return (SDL_threadID) sceKernelGetThreadId(); + return (SDL_threadID)sceKernelGetThreadId(); } void SDL_SYS_WaitThread(SDL_Thread *thread) @@ -104,8 +103,7 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) value = 50; } - return sceKernelChangeThreadPriority(sceKernelGetThreadId(),value); - + return sceKernelChangeThreadPriority(sceKernelGetThreadId(), value); } #endif /* SDL_THREAD_PSP */ diff --git a/src/thread/pthread/SDL_syscond.c b/src/thread/pthread/SDL_syscond.c index b7d764341..bb614bef4 100644 --- a/src/thread/pthread/SDL_syscond.c +++ b/src/thread/pthread/SDL_syscond.c @@ -40,7 +40,7 @@ SDL_CreateCond(void) { SDL_cond *cond; - cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); + cond = (SDL_cond *)SDL_malloc(sizeof(SDL_cond)); if (cond) { if (pthread_cond_init(&cond->cond, NULL) != 0) { SDL_SetError("pthread_cond_init() failed"); @@ -52,8 +52,7 @@ SDL_CreateCond(void) } /* Destroy a condition variable */ -void -SDL_DestroyCond(SDL_cond * cond) +void SDL_DestroyCond(SDL_cond *cond) { if (cond) { pthread_cond_destroy(&cond->cond); @@ -62,8 +61,7 @@ SDL_DestroyCond(SDL_cond * cond) } /* Restart one of the threads that are waiting on the condition variable */ -int -SDL_CondSignal(SDL_cond * cond) +int SDL_CondSignal(SDL_cond *cond) { int retval; @@ -79,8 +77,7 @@ SDL_CondSignal(SDL_cond * cond) } /* Restart all threads that are waiting on the condition variable */ -int -SDL_CondBroadcast(SDL_cond * cond) +int SDL_CondBroadcast(SDL_cond *cond) { int retval; @@ -95,8 +92,7 @@ SDL_CondBroadcast(SDL_cond * cond) return retval; } -int -SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) +int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) { int retval; #ifndef HAVE_CLOCK_GETTIME @@ -124,7 +120,7 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) abstime.tv_nsec -= 1000000000; } - tryagain: +tryagain: retval = pthread_cond_timedwait(&cond->cond, &mutex->id, &abstime); switch (retval) { case EINTR: @@ -144,8 +140,7 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) /* Wait on the condition variable, unlocking the provided mutex. The mutex must be locked before entering this function! */ -int -SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) +int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex) { if (cond == NULL) { return SDL_InvalidParamError("cond"); diff --git a/src/thread/pthread/SDL_sysmutex.c b/src/thread/pthread/SDL_sysmutex.c index 09a00ced8..c89c095ca 100644 --- a/src/thread/pthread/SDL_sysmutex.c +++ b/src/thread/pthread/SDL_sysmutex.c @@ -46,7 +46,7 @@ SDL_CreateMutex(void) pthread_mutexattr_t attr; /* Allocate the structure */ - mutex = (SDL_mutex *) SDL_calloc(1, sizeof(*mutex)); + mutex = (SDL_mutex *)SDL_calloc(1, sizeof(*mutex)); if (mutex) { pthread_mutexattr_init(&attr); #if SDL_THREAD_PTHREAD_RECURSIVE_MUTEX @@ -67,8 +67,7 @@ SDL_CreateMutex(void) return mutex; } -void -SDL_DestroyMutex(SDL_mutex * mutex) +void SDL_DestroyMutex(SDL_mutex *mutex) { if (mutex) { pthread_mutex_destroy(&mutex->id); @@ -77,8 +76,7 @@ SDL_DestroyMutex(SDL_mutex * mutex) } /* Lock the mutex */ -int -SDL_LockMutex(SDL_mutex * mutex) +int SDL_LockMutex(SDL_mutex *mutex) { #if FAKE_RECURSIVE_MUTEX pthread_t this_thread; @@ -112,8 +110,7 @@ SDL_LockMutex(SDL_mutex * mutex) return 0; } -int -SDL_TryLockMutex(SDL_mutex * mutex) +int SDL_TryLockMutex(SDL_mutex *mutex) { int retval; int result; @@ -158,8 +155,7 @@ SDL_TryLockMutex(SDL_mutex * mutex) return retval; } -int -SDL_UnlockMutex(SDL_mutex * mutex) +int SDL_UnlockMutex(SDL_mutex *mutex) { if (mutex == NULL) { return SDL_InvalidParamError("mutex"); diff --git a/src/thread/pthread/SDL_syssem.c b/src/thread/pthread/SDL_syssem.c index 12a5b9611..c933acbd0 100644 --- a/src/thread/pthread/SDL_syssem.c +++ b/src/thread/pthread/SDL_syssem.c @@ -45,7 +45,7 @@ struct SDL_semaphore SDL_sem * SDL_CreateSemaphore(Uint32 initial_value) { - SDL_sem *sem = (SDL_sem *) SDL_malloc(sizeof(SDL_sem)); + SDL_sem *sem = (SDL_sem *)SDL_malloc(sizeof(SDL_sem)); if (sem != NULL) { if (sem_init(&sem->sem, 0, initial_value) < 0) { SDL_SetError("sem_init() failed"); @@ -58,8 +58,7 @@ SDL_CreateSemaphore(Uint32 initial_value) return sem; } -void -SDL_DestroySemaphore(SDL_sem * sem) +void SDL_DestroySemaphore(SDL_sem *sem) { if (sem != NULL) { sem_destroy(&sem->sem); @@ -67,8 +66,7 @@ SDL_DestroySemaphore(SDL_sem * sem) } } -int -SDL_SemTryWait(SDL_sem * sem) +int SDL_SemTryWait(SDL_sem *sem) { int retval; @@ -82,8 +80,7 @@ SDL_SemTryWait(SDL_sem * sem) return retval; } -int -SDL_SemWait(SDL_sem * sem) +int SDL_SemWait(SDL_sem *sem) { int retval; @@ -101,8 +98,7 @@ SDL_SemWait(SDL_sem * sem) return retval; } -int -SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) +int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) { int retval; #ifdef HAVE_SEM_TIMEDWAIT @@ -128,9 +124,9 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) #ifdef HAVE_SEM_TIMEDWAIT /* Setup the timeout. sem_timedwait doesn't wait for - * a lapse of time, but until we reach a certain time. - * This time is now plus the timeout. - */ + * a lapse of time, but until we reach a certain time. + * This time is now plus the timeout. + */ #ifdef HAVE_CLOCK_GETTIME clock_gettime(CLOCK_REALTIME, &ts_timeout); @@ -177,7 +173,7 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) } Uint32 -SDL_SemValue(SDL_sem * sem) +SDL_SemValue(SDL_sem *sem) { int ret = 0; @@ -190,11 +186,10 @@ SDL_SemValue(SDL_sem * sem) if (ret < 0) { ret = 0; } - return (Uint32) ret; + return (Uint32)ret; } -int -SDL_SemPost(SDL_sem * sem) +int SDL_SemPost(SDL_sem *sem) { int retval; diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c index b873f3de5..fdbd28de5 100644 --- a/src/thread/pthread/SDL_systhread.c +++ b/src/thread/pthread/SDL_systhread.c @@ -68,25 +68,23 @@ static const int sig_list[] = { }; #endif -static void * -RunThread(void *data) +static void *RunThread(void *data) { #ifdef __ANDROID__ Android_JNI_SetupThread(); #endif - SDL_RunThread((SDL_Thread *) data); + SDL_RunThread((SDL_Thread *)data); return NULL; } #if (defined(__MACOSX__) || defined(__IPHONEOS__)) && defined(HAVE_DLOPEN) static SDL_bool checked_setname = SDL_FALSE; -static int (*ppthread_setname_np)(const char*) = NULL; +static int (*ppthread_setname_np)(const char *) = NULL; #elif defined(__LINUX__) && defined(HAVE_DLOPEN) static SDL_bool checked_setname = SDL_FALSE; -static int (*ppthread_setname_np)(pthread_t, const char*) = NULL; +static int (*ppthread_setname_np)(pthread_t, const char *) = NULL; #endif -int -SDL_SYS_CreateThread(SDL_Thread * thread) +int SDL_SYS_CreateThread(SDL_Thread *thread) { pthread_attr_t type; @@ -101,14 +99,14 @@ SDL_SYS_CreateThread(SDL_Thread * thread) #endif checked_setname = SDL_TRUE; } - #endif +#endif /* Set the thread attributes */ if (pthread_attr_init(&type) != 0) { return SDL_SetError("Couldn't initialize pthread attributes"); } pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE); - + /* Set caller-requested stack size. Otherwise: use the system default. */ if (thread->stacksize) { pthread_attr_setstacksize(&type, thread->stacksize); @@ -122,8 +120,7 @@ SDL_SYS_CreateThread(SDL_Thread * thread) return 0; } -void -SDL_SYS_SetupThread(const char *name) +void SDL_SYS_SetupThread(const char *name) { #if !defined(__NACL__) int i; @@ -136,32 +133,32 @@ SDL_SYS_SetupThread(const char *name) if (ppthread_setname_np != NULL) { #if defined(__MACOSX__) || defined(__IPHONEOS__) ppthread_setname_np(name); - #elif defined(__LINUX__) +#elif defined(__LINUX__) if (ppthread_setname_np(pthread_self(), name) == ERANGE) { char namebuf[16]; /* Limited to 16 char */ - SDL_strlcpy(namebuf, name, sizeof (namebuf)); + SDL_strlcpy(namebuf, name, sizeof(namebuf)); ppthread_setname_np(pthread_self(), namebuf); } - #endif +#endif } - #elif HAVE_PTHREAD_SETNAME_NP - #if defined(__NETBSD__) - pthread_setname_np(pthread_self(), "%s", name); - #else - if (pthread_setname_np(pthread_self(), name) == ERANGE) { - char namebuf[16]; /* Limited to 16 char */ - SDL_strlcpy(namebuf, name, sizeof (namebuf)); - pthread_setname_np(pthread_self(), namebuf); - } - #endif - #elif HAVE_PTHREAD_SET_NAME_NP - pthread_set_name_np(pthread_self(), name); - #elif defined(__HAIKU__) - /* The docs say the thread name can't be longer than B_OS_NAME_LENGTH. */ - char namebuf[B_OS_NAME_LENGTH]; - SDL_strlcpy(namebuf, name, sizeof (namebuf)); - rename_thread(find_thread(NULL), namebuf); - #endif +#elif HAVE_PTHREAD_SETNAME_NP +#if defined(__NETBSD__) + pthread_setname_np(pthread_self(), "%s", name); +#else + if (pthread_setname_np(pthread_self(), name) == ERANGE) { + char namebuf[16]; /* Limited to 16 char */ + SDL_strlcpy(namebuf, name, sizeof(namebuf)); + pthread_setname_np(pthread_self(), namebuf); + } +#endif +#elif HAVE_PTHREAD_SET_NAME_NP + pthread_set_name_np(pthread_self(), name); +#elif defined(__HAIKU__) + /* The docs say the thread name can't be longer than B_OS_NAME_LENGTH. */ + char namebuf[B_OS_NAME_LENGTH]; + SDL_strlcpy(namebuf, name, sizeof(namebuf)); + rename_thread(find_thread(NULL), namebuf); +#endif } /* NativeClient does not yet support signals.*/ @@ -190,8 +187,7 @@ SDL_ThreadID(void) return (SDL_threadID)pthread_self(); } -int -SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) +int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) { #if __NACL__ || __RISCOS__ || __OS2__ /* FIXME: Setting thread priority does not seem to be supported in NACL */ @@ -290,14 +286,12 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) #endif /* #if __NACL__ || __RISCOS__ */ } -void -SDL_SYS_WaitThread(SDL_Thread * thread) +void SDL_SYS_WaitThread(SDL_Thread *thread) { pthread_join(thread->handle, 0); } -void -SDL_SYS_DetachThread(SDL_Thread * thread) +void SDL_SYS_DetachThread(SDL_Thread *thread) { pthread_detach(thread->handle); } diff --git a/src/thread/pthread/SDL_systls.c b/src/thread/pthread/SDL_systls.c index c55c69720..d9f8ba0f8 100644 --- a/src/thread/pthread/SDL_systls.c +++ b/src/thread/pthread/SDL_systls.c @@ -25,7 +25,6 @@ #include - #define INVALID_PTHREAD_KEY ((pthread_key_t)-1) static pthread_key_t thread_local_storage = INVALID_PTHREAD_KEY; @@ -55,8 +54,7 @@ SDL_SYS_GetTLSData(void) return (SDL_TLSData *)pthread_getspecific(thread_local_storage); } -int -SDL_SYS_SetTLSData(SDL_TLSData *data) +int SDL_SYS_SetTLSData(SDL_TLSData *data) { if (generic_local_storage) { return SDL_Generic_SetTLSData(data); diff --git a/src/thread/stdcpp/SDL_syscond.cpp b/src/thread/stdcpp/SDL_syscond.cpp index 3b9530adf..a823f0b62 100644 --- a/src/thread/stdcpp/SDL_syscond.cpp +++ b/src/thread/stdcpp/SDL_syscond.cpp @@ -37,15 +37,14 @@ struct SDL_cond }; /* Create a condition variable */ -extern "C" -SDL_cond * +extern "C" SDL_cond * SDL_CreateCond(void) { /* Allocate and initialize the condition variable */ try { - SDL_cond * cond = new SDL_cond; + SDL_cond *cond = new SDL_cond; return cond; - } catch (std::system_error & ex) { + } catch (std::system_error &ex) { SDL_SetError("unable to create a C++ condition variable: code=%d; %s", ex.code(), ex.what()); return NULL; } catch (std::bad_alloc &) { @@ -55,9 +54,8 @@ SDL_CreateCond(void) } /* Destroy a condition variable */ -extern "C" -void -SDL_DestroyCond(SDL_cond * cond) +extern "C" void +SDL_DestroyCond(SDL_cond *cond) { if (cond != NULL) { delete cond; @@ -65,9 +63,8 @@ SDL_DestroyCond(SDL_cond * cond) } /* Restart one of the threads that are waiting on the condition variable */ -extern "C" -int -SDL_CondSignal(SDL_cond * cond) +extern "C" int +SDL_CondSignal(SDL_cond *cond) { if (cond == NULL) { return SDL_InvalidParamError("cond"); @@ -78,9 +75,8 @@ SDL_CondSignal(SDL_cond * cond) } /* Restart all threads that are waiting on the condition variable */ -extern "C" -int -SDL_CondBroadcast(SDL_cond * cond) +extern "C" int +SDL_CondBroadcast(SDL_cond *cond) { if (cond == NULL) { return SDL_InvalidParamError("cond"); @@ -111,9 +107,8 @@ Thread B: SDL_CondSignal(cond); SDL_UnlockMutex(lock); */ -extern "C" -int -SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) +extern "C" int +SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) { if (cond == NULL) { return SDL_InvalidParamError("cond"); @@ -127,15 +122,13 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) std::unique_lock cpp_lock(mutex->cpp_mutex, std::adopt_lock_t()); if (ms == SDL_MUTEX_MAXWAIT) { cond->cpp_cond.wait( - cpp_lock - ); + cpp_lock); cpp_lock.release(); return 0; } else { auto wait_result = cond->cpp_cond.wait_for( cpp_lock, - std::chrono::duration(ms) - ); + std::chrono::duration(ms)); cpp_lock.release(); if (wait_result == std::cv_status::timeout) { return SDL_MUTEX_TIMEDOUT; @@ -143,15 +136,14 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) return 0; } } - } catch (std::system_error & ex) { + } catch (std::system_error &ex) { return SDL_SetError("unable to wait on a C++ condition variable: code=%d; %s", ex.code(), ex.what()); } } /* Wait on the condition variable forever */ -extern "C" -int -SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) +extern "C" int +SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex) { return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT); } diff --git a/src/thread/stdcpp/SDL_sysmutex.cpp b/src/thread/stdcpp/SDL_sysmutex.cpp index b949daa3d..0113e67aa 100644 --- a/src/thread/stdcpp/SDL_sysmutex.cpp +++ b/src/thread/stdcpp/SDL_sysmutex.cpp @@ -30,17 +30,15 @@ extern "C" { #include "SDL_sysmutex_c.h" #include - /* Create a mutex */ -extern "C" -SDL_mutex * +extern "C" SDL_mutex * SDL_CreateMutex(void) { /* Allocate and initialize the mutex */ try { - SDL_mutex * mutex = new SDL_mutex; + SDL_mutex *mutex = new SDL_mutex; return mutex; - } catch (std::system_error & ex) { + } catch (std::system_error &ex) { SDL_SetError("unable to create a C++ mutex: code=%d; %s", ex.code(), ex.what()); return NULL; } catch (std::bad_alloc &) { @@ -50,9 +48,8 @@ SDL_CreateMutex(void) } /* Free the mutex */ -extern "C" -void -SDL_DestroyMutex(SDL_mutex * mutex) +extern "C" void +SDL_DestroyMutex(SDL_mutex *mutex) { if (mutex != NULL) { delete mutex; @@ -60,9 +57,8 @@ SDL_DestroyMutex(SDL_mutex * mutex) } /* Lock the semaphore */ -extern "C" -int -SDL_mutexP(SDL_mutex * mutex) +extern "C" int +SDL_mutexP(SDL_mutex *mutex) { if (mutex == NULL) { return SDL_InvalidParamError("mutex"); @@ -71,14 +67,13 @@ SDL_mutexP(SDL_mutex * mutex) try { mutex->cpp_mutex.lock(); return 0; - } catch (std::system_error & ex) { + } catch (std::system_error &ex) { return SDL_SetError("unable to lock a C++ mutex: code=%d; %s", ex.code(), ex.what()); } } /* TryLock the mutex */ -int -SDL_TryLockMutex(SDL_mutex * mutex) +int SDL_TryLockMutex(SDL_mutex *mutex) { int retval = 0; if (mutex == NULL) { @@ -92,9 +87,8 @@ SDL_TryLockMutex(SDL_mutex * mutex) } /* Unlock the mutex */ -extern "C" -int -SDL_mutexV(SDL_mutex * mutex) +extern "C" int +SDL_mutexV(SDL_mutex *mutex) { if (mutex == NULL) { return SDL_InvalidParamError("mutex"); diff --git a/src/thread/stdcpp/SDL_systhread.cpp b/src/thread/stdcpp/SDL_systhread.cpp index 0d1756539..814c531bd 100644 --- a/src/thread/stdcpp/SDL_systhread.cpp +++ b/src/thread/stdcpp/SDL_systhread.cpp @@ -36,30 +36,27 @@ extern "C" { #include #endif -static void -RunThread(void *args) +static void RunThread(void *args) { - SDL_RunThread((SDL_Thread *) args); + SDL_RunThread((SDL_Thread *)args); } -extern "C" -int -SDL_SYS_CreateThread(SDL_Thread * thread) +extern "C" int +SDL_SYS_CreateThread(SDL_Thread *thread) { try { // !!! FIXME: no way to set a thread stack size here. std::thread cpp_thread(RunThread, thread); - thread->handle = (void *) new std::thread(std::move(cpp_thread)); + thread->handle = (void *)new std::thread(std::move(cpp_thread)); return 0; - } catch (std::system_error & ex) { + } catch (std::system_error &ex) { return SDL_SetError("unable to start a C++ thread: code=%d; %s", ex.code(), ex.what()); } catch (std::bad_alloc &) { return SDL_OutOfMemory(); } } -extern "C" -void +extern "C" void SDL_SYS_SetupThread(const char *name) { // Make sure a thread ID gets assigned ASAP, for debugging purposes: @@ -67,8 +64,7 @@ SDL_SYS_SetupThread(const char *name) return; } -extern "C" -SDL_threadID +extern "C" SDL_threadID SDL_ThreadID(void) { #ifdef __WINRT__ @@ -89,8 +85,7 @@ SDL_ThreadID(void) #endif } -extern "C" -int +extern "C" int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) { #ifdef __WINRT__ @@ -116,16 +111,15 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) #endif } -extern "C" -void -SDL_SYS_WaitThread(SDL_Thread * thread) +extern "C" void +SDL_SYS_WaitThread(SDL_Thread *thread) { - if ( ! thread) { + if (!thread) { return; } try { - std::thread * cpp_thread = (std::thread *) thread->handle; + std::thread *cpp_thread = (std::thread *)thread->handle; if (cpp_thread->joinable()) { cpp_thread->join(); } @@ -136,16 +130,15 @@ SDL_SYS_WaitThread(SDL_Thread * thread) } } -extern "C" -void -SDL_SYS_DetachThread(SDL_Thread * thread) +extern "C" void +SDL_SYS_DetachThread(SDL_Thread *thread) { - if ( ! thread) { + if (!thread) { return; } try { - std::thread * cpp_thread = (std::thread *) thread->handle; + std::thread *cpp_thread = (std::thread *)thread->handle; if (cpp_thread->joinable()) { cpp_thread->detach(); } @@ -156,15 +149,13 @@ SDL_SYS_DetachThread(SDL_Thread * thread) } } -extern "C" -SDL_TLSData * +extern "C" SDL_TLSData * SDL_SYS_GetTLSData(void) { return SDL_Generic_GetTLSData(); } -extern "C" -int +extern "C" int SDL_SYS_SetTLSData(SDL_TLSData *data) { return SDL_Generic_SetTLSData(data); diff --git a/src/thread/stdcpp/SDL_systhread_c.h b/src/thread/stdcpp/SDL_systhread_c.h index 57c660a85..8675db28b 100644 --- a/src/thread/stdcpp/SDL_systhread_c.h +++ b/src/thread/stdcpp/SDL_systhread_c.h @@ -21,6 +21,6 @@ #include "SDL_config.h" /* For a thread handle, use a void pointer to a std::thread */ -typedef void * SYS_ThreadHandle; +typedef void *SYS_ThreadHandle; /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/vita/SDL_syscond.c b/src/thread/vita/SDL_syscond.c index 4f2627660..1a202f80d 100644 --- a/src/thread/vita/SDL_syscond.c +++ b/src/thread/vita/SDL_syscond.c @@ -45,7 +45,7 @@ SDL_CreateCond(void) { SDL_cond *cond; - cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); + cond = (SDL_cond *)SDL_malloc(sizeof(SDL_cond)); if (cond != NULL) { cond->lock = SDL_CreateMutex(); cond->wait_sem = SDL_CreateSemaphore(0); @@ -62,8 +62,7 @@ SDL_CreateCond(void) } /* Destroy a condition variable */ -void -SDL_DestroyCond(SDL_cond * cond) +void SDL_DestroyCond(SDL_cond *cond) { if (cond != NULL) { if (cond->wait_sem) { @@ -80,8 +79,7 @@ SDL_DestroyCond(SDL_cond * cond) } /* Restart one of the threads that are waiting on the condition variable */ -int -SDL_CondSignal(SDL_cond * cond) +int SDL_CondSignal(SDL_cond *cond) { if (cond == NULL) { return SDL_InvalidParamError("cond"); @@ -104,8 +102,7 @@ SDL_CondSignal(SDL_cond * cond) } /* Restart all threads that are waiting on the condition variable */ -int -SDL_CondBroadcast(SDL_cond * cond) +int SDL_CondBroadcast(SDL_cond *cond) { if (cond == NULL) { return SDL_InvalidParamError("cond"); @@ -158,8 +155,7 @@ Thread B: SDL_CondSignal(cond); SDL_UnlockMutex(lock); */ -int -SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) +int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) { int retval; @@ -213,8 +209,7 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) } /* Wait on the condition variable forever */ -int -SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) +int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex) { return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT); } diff --git a/src/thread/vita/SDL_sysmutex.c b/src/thread/vita/SDL_sysmutex.c index 1ca7d3b9c..4fbd4b463 100644 --- a/src/thread/vita/SDL_sysmutex.c +++ b/src/thread/vita/SDL_sysmutex.c @@ -41,7 +41,7 @@ SDL_CreateMutex(void) SceInt32 res = 0; /* Allocate mutex memory */ - mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); + mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex)); if (mutex != NULL) { res = sceKernelCreateLwMutex( @@ -49,8 +49,7 @@ SDL_CreateMutex(void) "SDL mutex", SCE_KERNEL_MUTEX_ATTR_RECURSIVE, 0, - NULL - ); + NULL); if (res < 0) { SDL_SetError("Error trying to create mutex: %x", res); @@ -62,8 +61,7 @@ SDL_CreateMutex(void) } /* Free the mutex */ -void -SDL_DestroyMutex(SDL_mutex * mutex) +void SDL_DestroyMutex(SDL_mutex *mutex) { if (mutex != NULL) { sceKernelDeleteLwMutex(&mutex->lock); @@ -72,8 +70,7 @@ SDL_DestroyMutex(SDL_mutex * mutex) } /* Try to lock the mutex */ -int -SDL_TryLockMutex(SDL_mutex * mutex) +int SDL_TryLockMutex(SDL_mutex *mutex) { #if SDL_THREADS_DISABLED return 0; @@ -85,25 +82,23 @@ SDL_TryLockMutex(SDL_mutex * mutex) res = sceKernelTryLockLwMutex(&mutex->lock, 1); switch (res) { - case SCE_KERNEL_OK: - return 0; - break; - case SCE_KERNEL_ERROR_MUTEX_FAILED_TO_OWN: - return SDL_MUTEX_TIMEDOUT; - break; - default: - return SDL_SetError("Error trying to lock mutex: %x", res); - break; + case SCE_KERNEL_OK: + return 0; + break; + case SCE_KERNEL_ERROR_MUTEX_FAILED_TO_OWN: + return SDL_MUTEX_TIMEDOUT; + break; + default: + return SDL_SetError("Error trying to lock mutex: %x", res); + break; } return -1; #endif /* SDL_THREADS_DISABLED */ } - /* Lock the mutex */ -int -SDL_mutexP(SDL_mutex * mutex) +int SDL_mutexP(SDL_mutex *mutex) { #if SDL_THREADS_DISABLED return 0; @@ -123,8 +118,7 @@ SDL_mutexP(SDL_mutex * mutex) } /* Unlock the mutex */ -int -SDL_mutexV(SDL_mutex * mutex) +int SDL_mutexV(SDL_mutex *mutex) { #if SDL_THREADS_DISABLED return 0; diff --git a/src/thread/vita/SDL_syssem.c b/src/thread/vita/SDL_syssem.c index 8f5b4f82b..d96d95c76 100644 --- a/src/thread/vita/SDL_syssem.c +++ b/src/thread/vita/SDL_syssem.c @@ -34,17 +34,17 @@ #include #include -struct SDL_semaphore { - SceUID semid; +struct SDL_semaphore +{ + SceUID semid; }; - /* Create a semaphore */ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) { SDL_sem *sem; - sem = (SDL_sem *) SDL_malloc(sizeof(*sem)); + sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); if (sem != NULL) { /* TODO: Figure out the limit on the maximum value. */ sem->semid = sceKernelCreateSema("SDL sema", 0, initial_value, 255, NULL); @@ -97,7 +97,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) if (timeout == SDL_MUTEX_MAXWAIT) { pTimeout = NULL; } else { - timeout *= 1000; /* Convert to microseconds. */ + timeout *= 1000; /* Convert to microseconds. */ pTimeout = &timeout; } diff --git a/src/thread/vita/SDL_systhread.c b/src/thread/vita/SDL_systhread.c index 91ae06256..e43d8f9d4 100644 --- a/src/thread/vita/SDL_systhread.c +++ b/src/thread/vita/SDL_systhread.c @@ -34,19 +34,19 @@ #include #include -#define VITA_THREAD_STACK_SIZE_MIN 0x1000 // 4KiB -#define VITA_THREAD_STACK_SIZE_MAX 0x2000000 // 32MiB -#define VITA_THREAD_STACK_SIZE_DEFAULT 0x10000 // 64KiB -#define VITA_THREAD_NAME_MAX 32 +#define VITA_THREAD_STACK_SIZE_MIN 0x1000 // 4KiB +#define VITA_THREAD_STACK_SIZE_MAX 0x2000000 // 32MiB +#define VITA_THREAD_STACK_SIZE_DEFAULT 0x10000 // 64KiB +#define VITA_THREAD_NAME_MAX 32 -#define VITA_THREAD_PRIORITY_LOW 191 -#define VITA_THREAD_PRIORITY_NORMAL 160 -#define VITA_THREAD_PRIORITY_HIGH 112 +#define VITA_THREAD_PRIORITY_LOW 191 +#define VITA_THREAD_PRIORITY_NORMAL 160 +#define VITA_THREAD_PRIORITY_HIGH 112 #define VITA_THREAD_PRIORITY_TIME_CRITICAL 64 static int ThreadEntry(SceSize args, void *argp) { - SDL_RunThread(*(SDL_Thread **) argp); + SDL_RunThread(*(SDL_Thread **)argp); return 0; } @@ -74,11 +74,11 @@ int SDL_SYS_CreateThread(SDL_Thread *thread) thread->handle = sceKernelCreateThread( thread_name, // name ThreadEntry, // function to run - 0, // priority. 0 means priority of calling thread - stack_size, // stack size - 0, // attibutes. always 0 - 0, // cpu affinity mask. 0 = all CPUs - NULL // opt. always NULL + 0, // priority. 0 means priority of calling thread + stack_size, // stack size + 0, // attibutes. always 0 + 0, // cpu affinity mask. 0 = all CPUs + NULL // opt. always NULL ); if (thread->handle < 0) { @@ -96,7 +96,7 @@ void SDL_SYS_SetupThread(const char *name) SDL_threadID SDL_ThreadID(void) { - return (SDL_threadID) sceKernelGetThreadId(); + return (SDL_threadID)sceKernelGetThreadId(); } void SDL_SYS_WaitThread(SDL_Thread *thread) @@ -114,23 +114,22 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) { int value = VITA_THREAD_PRIORITY_NORMAL; - switch(priority) { - case SDL_THREAD_PRIORITY_LOW: - value = VITA_THREAD_PRIORITY_LOW; - break; - case SDL_THREAD_PRIORITY_NORMAL: - value = VITA_THREAD_PRIORITY_NORMAL; - break; - case SDL_THREAD_PRIORITY_HIGH: - value = VITA_THREAD_PRIORITY_HIGH; - break; - case SDL_THREAD_PRIORITY_TIME_CRITICAL: - value = VITA_THREAD_PRIORITY_TIME_CRITICAL; - break; + switch (priority) { + case SDL_THREAD_PRIORITY_LOW: + value = VITA_THREAD_PRIORITY_LOW; + break; + case SDL_THREAD_PRIORITY_NORMAL: + value = VITA_THREAD_PRIORITY_NORMAL; + break; + case SDL_THREAD_PRIORITY_HIGH: + value = VITA_THREAD_PRIORITY_HIGH; + break; + case SDL_THREAD_PRIORITY_TIME_CRITICAL: + value = VITA_THREAD_PRIORITY_TIME_CRITICAL; + break; } return sceKernelChangeThreadPriority(0, value); - } #endif /* SDL_THREAD_VITA */ diff --git a/src/thread/windows/SDL_syscond_cv.c b/src/thread/windows/SDL_syscond_cv.c index eee769de8..95c09b95b 100644 --- a/src/thread/windows/SDL_syscond_cv.c +++ b/src/thread/windows/SDL_syscond_cv.c @@ -26,7 +26,7 @@ #include "../generic/SDL_syscond_c.h" #include "SDL_sysmutex_c.h" -typedef SDL_cond * (*pfnSDL_CreateCond)(void); +typedef SDL_cond *(*pfnSDL_CreateCond)(void); typedef void (*pfnSDL_DestroyCond)(SDL_cond *); typedef int (*pfnSDL_CondSignal)(SDL_cond *); typedef int (*pfnSDL_CondBroadcast)(SDL_cond *); @@ -35,39 +35,42 @@ typedef int (*pfnSDL_CondWaitTimeout)(SDL_cond *, SDL_mutex *, Uint32); typedef struct SDL_cond_impl_t { - pfnSDL_CreateCond Create; - pfnSDL_DestroyCond Destroy; - pfnSDL_CondSignal Signal; - pfnSDL_CondBroadcast Broadcast; - pfnSDL_CondWait Wait; - pfnSDL_CondWaitTimeout WaitTimeout; + pfnSDL_CreateCond Create; + pfnSDL_DestroyCond Destroy; + pfnSDL_CondSignal Signal; + pfnSDL_CondBroadcast Broadcast; + pfnSDL_CondWait Wait; + pfnSDL_CondWaitTimeout WaitTimeout; } SDL_cond_impl_t; /* Implementation will be chosen at runtime based on available Kernel features */ -static SDL_cond_impl_t SDL_cond_impl_active = {0}; - +static SDL_cond_impl_t SDL_cond_impl_active = { 0 }; /** * Native Windows Condition Variable (SRW Locks) */ #ifndef CONDITION_VARIABLE_INIT -#define CONDITION_VARIABLE_INIT {0} -typedef struct CONDITION_VARIABLE { +#define CONDITION_VARIABLE_INIT \ + { \ + 0 \ + } +typedef struct CONDITION_VARIABLE +{ PVOID Ptr; } CONDITION_VARIABLE, *PCONDITION_VARIABLE; #endif #if __WINRT__ -#define pWakeConditionVariable WakeConditionVariable -#define pWakeAllConditionVariable WakeAllConditionVariable +#define pWakeConditionVariable WakeConditionVariable +#define pWakeAllConditionVariable WakeAllConditionVariable #define pSleepConditionVariableSRW SleepConditionVariableSRW -#define pSleepConditionVariableCS SleepConditionVariableCS +#define pSleepConditionVariableCS SleepConditionVariableCS #else typedef VOID(WINAPI *pfnWakeConditionVariable)(PCONDITION_VARIABLE); typedef VOID(WINAPI *pfnWakeAllConditionVariable)(PCONDITION_VARIABLE); typedef BOOL(WINAPI *pfnSleepConditionVariableSRW)(PCONDITION_VARIABLE, PSRWLOCK, DWORD, ULONG); -typedef BOOL(WINAPI* pfnSleepConditionVariableCS)(PCONDITION_VARIABLE, PCRITICAL_SECTION, DWORD); +typedef BOOL(WINAPI *pfnSleepConditionVariableCS)(PCONDITION_VARIABLE, PCRITICAL_SECTION, DWORD); static pfnWakeConditionVariable pWakeConditionVariable = NULL; static pfnWakeAllConditionVariable pWakeAllConditionVariable = NULL; @@ -80,14 +83,12 @@ typedef struct SDL_cond_cv CONDITION_VARIABLE cond; } SDL_cond_cv; - -static SDL_cond * -SDL_CreateCond_cv(void) +static SDL_cond *SDL_CreateCond_cv(void) { SDL_cond_cv *cond; /* Relies on CONDITION_VARIABLE_INIT == 0. */ - cond = (SDL_cond_cv *) SDL_calloc(1, sizeof(*cond)); + cond = (SDL_cond_cv *)SDL_calloc(1, sizeof(*cond)); if (cond == NULL) { SDL_OutOfMemory(); } @@ -95,8 +96,7 @@ SDL_CreateCond_cv(void) return (SDL_cond *)cond; } -static void -SDL_DestroyCond_cv(SDL_cond * cond) +static void SDL_DestroyCond_cv(SDL_cond *cond) { if (cond != NULL) { /* There are no kernel allocated resources */ @@ -104,8 +104,7 @@ SDL_DestroyCond_cv(SDL_cond * cond) } } -static int -SDL_CondSignal_cv(SDL_cond * _cond) +static int SDL_CondSignal_cv(SDL_cond *_cond) { SDL_cond_cv *cond = (SDL_cond_cv *)_cond; if (cond == NULL) { @@ -117,8 +116,7 @@ SDL_CondSignal_cv(SDL_cond * _cond) return 0; } -static int -SDL_CondBroadcast_cv(SDL_cond * _cond) +static int SDL_CondBroadcast_cv(SDL_cond *_cond) { SDL_cond_cv *cond = (SDL_cond_cv *)_cond; if (cond == NULL) { @@ -130,8 +128,7 @@ SDL_CondBroadcast_cv(SDL_cond * _cond) return 0; } -static int -SDL_CondWaitTimeout_cv(SDL_cond * _cond, SDL_mutex * _mutex, Uint32 ms) +static int SDL_CondWaitTimeout_cv(SDL_cond *_cond, SDL_mutex *_mutex, Uint32 ms) { SDL_cond_cv *cond = (SDL_cond_cv *)_cond; DWORD timeout; @@ -147,7 +144,7 @@ SDL_CondWaitTimeout_cv(SDL_cond * _cond, SDL_mutex * _mutex, Uint32 ms) if (ms == SDL_MUTEX_MAXWAIT) { timeout = INFINITE; } else { - timeout = (DWORD) ms; + timeout = (DWORD)ms; } if (SDL_mutex_impl_active.Type == SDL_MUTEX_SRW) { @@ -194,13 +191,12 @@ SDL_CondWaitTimeout_cv(SDL_cond * _cond, SDL_mutex * _mutex, Uint32 ms) return ret; } -static int -SDL_CondWait_cv(SDL_cond * cond, SDL_mutex * mutex) { +static int SDL_CondWait_cv(SDL_cond *cond, SDL_mutex *mutex) +{ return SDL_CondWaitTimeout_cv(cond, mutex, SDL_MUTEX_MAXWAIT); } -static const SDL_cond_impl_t SDL_cond_impl_cv = -{ +static const SDL_cond_impl_t SDL_cond_impl_cv = { &SDL_CreateCond_cv, &SDL_DestroyCond_cv, &SDL_CondSignal_cv, @@ -213,8 +209,7 @@ static const SDL_cond_impl_t SDL_cond_impl_cv = * Generic Condition Variable implementation using SDL_mutex and SDL_sem */ -static const SDL_cond_impl_t SDL_cond_impl_generic = -{ +static const SDL_cond_impl_t SDL_cond_impl_generic = { &SDL_CreateCond_generic, &SDL_DestroyCond_generic, &SDL_CondSignal_generic, @@ -223,13 +218,12 @@ static const SDL_cond_impl_t SDL_cond_impl_generic = &SDL_CondWaitTimeout_generic, }; - SDL_cond * SDL_CreateCond(void) { if (SDL_cond_impl_active.Create == NULL) { /* Default to generic implementation, works with all mutex implementations */ - const SDL_cond_impl_t * impl = &SDL_cond_impl_generic; + const SDL_cond_impl_t *impl = &SDL_cond_impl_generic; if (SDL_mutex_impl_active.Type == SDL_MUTEX_INVALID) { /* The mutex implementation isn't decided yet, trigger it */ @@ -249,10 +243,10 @@ SDL_CreateCond(void) { HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll")); if (kernel32) { - pWakeConditionVariable = (pfnWakeConditionVariable) GetProcAddress(kernel32, "WakeConditionVariable"); - pWakeAllConditionVariable = (pfnWakeAllConditionVariable) GetProcAddress(kernel32, "WakeAllConditionVariable"); - pSleepConditionVariableSRW = (pfnSleepConditionVariableSRW) GetProcAddress(kernel32, "SleepConditionVariableSRW"); - pSleepConditionVariableCS = (pfnSleepConditionVariableCS) GetProcAddress(kernel32, "SleepConditionVariableCS"); + pWakeConditionVariable = (pfnWakeConditionVariable)GetProcAddress(kernel32, "WakeConditionVariable"); + pWakeAllConditionVariable = (pfnWakeAllConditionVariable)GetProcAddress(kernel32, "WakeAllConditionVariable"); + pSleepConditionVariableSRW = (pfnSleepConditionVariableSRW)GetProcAddress(kernel32, "SleepConditionVariableSRW"); + pSleepConditionVariableCS = (pfnSleepConditionVariableCS)GetProcAddress(kernel32, "SleepConditionVariableCS"); if (pWakeConditionVariable && pWakeAllConditionVariable && pSleepConditionVariableSRW && pSleepConditionVariableCS) { /* Use the Windows provided API */ impl = &SDL_cond_impl_cv; @@ -266,32 +260,27 @@ SDL_CreateCond(void) return SDL_cond_impl_active.Create(); } -void -SDL_DestroyCond(SDL_cond * cond) +void SDL_DestroyCond(SDL_cond *cond) { SDL_cond_impl_active.Destroy(cond); } -int -SDL_CondSignal(SDL_cond * cond) +int SDL_CondSignal(SDL_cond *cond) { return SDL_cond_impl_active.Signal(cond); } -int -SDL_CondBroadcast(SDL_cond * cond) +int SDL_CondBroadcast(SDL_cond *cond) { return SDL_cond_impl_active.Broadcast(cond); } -int -SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) +int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) { return SDL_cond_impl_active.WaitTimeout(cond, mutex, ms); } -int -SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) +int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex) { return SDL_cond_impl_active.Wait(cond, mutex); } diff --git a/src/thread/windows/SDL_sysmutex.c b/src/thread/windows/SDL_sysmutex.c index 1355a2b0f..c995244de 100644 --- a/src/thread/windows/SDL_sysmutex.c +++ b/src/thread/windows/SDL_sysmutex.c @@ -35,10 +35,8 @@ #include "SDL_sysmutex_c.h" - /* Implementation will be chosen at runtime based on available Kernel features */ -SDL_mutex_impl_t SDL_mutex_impl_active = {0}; - +SDL_mutex_impl_t SDL_mutex_impl_active = { 0 }; /** * Implementation based on Slim Reader/Writer (SRW) Locks for Win 7 and newer. @@ -46,8 +44,8 @@ SDL_mutex_impl_t SDL_mutex_impl_active = {0}; #if __WINRT__ /* Functions are guaranteed to be available */ -#define pReleaseSRWLockExclusive ReleaseSRWLockExclusive -#define pAcquireSRWLockExclusive AcquireSRWLockExclusive +#define pReleaseSRWLockExclusive ReleaseSRWLockExclusive +#define pAcquireSRWLockExclusive AcquireSRWLockExclusive #define pTryAcquireSRWLockExclusive TryAcquireSRWLockExclusive #else typedef VOID(WINAPI *pfnReleaseSRWLockExclusive)(PSRWLOCK); @@ -58,13 +56,12 @@ static pfnAcquireSRWLockExclusive pAcquireSRWLockExclusive = NULL; static pfnTryAcquireSRWLockExclusive pTryAcquireSRWLockExclusive = NULL; #endif -static SDL_mutex * -SDL_CreateMutex_srw(void) +static SDL_mutex *SDL_CreateMutex_srw(void) { SDL_mutex_srw *mutex; /* Relies on SRWLOCK_INIT == 0. */ - mutex = (SDL_mutex_srw *) SDL_calloc(1, sizeof(*mutex)); + mutex = (SDL_mutex_srw *)SDL_calloc(1, sizeof(*mutex)); if (mutex == NULL) { SDL_OutOfMemory(); } @@ -72,8 +69,7 @@ SDL_CreateMutex_srw(void) return (SDL_mutex *)mutex; } -static void -SDL_DestroyMutex_srw(SDL_mutex * mutex) +static void SDL_DestroyMutex_srw(SDL_mutex *mutex) { if (mutex != NULL) { /* There are no kernel allocated resources */ @@ -81,8 +77,7 @@ SDL_DestroyMutex_srw(SDL_mutex * mutex) } } -static int -SDL_LockMutex_srw(SDL_mutex * _mutex) +static int SDL_LockMutex_srw(SDL_mutex *_mutex) { SDL_mutex_srw *mutex = (SDL_mutex_srw *)_mutex; DWORD this_thread; @@ -107,8 +102,7 @@ SDL_LockMutex_srw(SDL_mutex * _mutex) return 0; } -static int -SDL_TryLockMutex_srw(SDL_mutex * _mutex) +static int SDL_TryLockMutex_srw(SDL_mutex *_mutex) { SDL_mutex_srw *mutex = (SDL_mutex_srw *)_mutex; DWORD this_thread; @@ -133,8 +127,7 @@ SDL_TryLockMutex_srw(SDL_mutex * _mutex) return retval; } -static int -SDL_UnlockMutex_srw(SDL_mutex * _mutex) +static int SDL_UnlockMutex_srw(SDL_mutex *_mutex) { SDL_mutex_srw *mutex = (SDL_mutex_srw *)_mutex; @@ -154,8 +147,7 @@ SDL_UnlockMutex_srw(SDL_mutex * _mutex) return 0; } -static const SDL_mutex_impl_t SDL_mutex_impl_srw = -{ +static const SDL_mutex_impl_t SDL_mutex_impl_srw = { &SDL_CreateMutex_srw, &SDL_DestroyMutex_srw, &SDL_LockMutex_srw, @@ -164,19 +156,17 @@ static const SDL_mutex_impl_t SDL_mutex_impl_srw = SDL_MUTEX_SRW, }; - /** * Fallback Mutex implementation using Critical Sections (before Win 7) */ /* Create a mutex */ -static SDL_mutex * -SDL_CreateMutex_cs(void) +static SDL_mutex *SDL_CreateMutex_cs(void) { SDL_mutex_cs *mutex; /* Allocate mutex memory */ - mutex = (SDL_mutex_cs *) SDL_malloc(sizeof(*mutex)); + mutex = (SDL_mutex_cs *)SDL_malloc(sizeof(*mutex)); if (mutex != NULL) { /* Initialize */ /* On SMP systems, a non-zero spin count generally helps performance */ @@ -192,8 +182,7 @@ SDL_CreateMutex_cs(void) } /* Free the mutex */ -static void -SDL_DestroyMutex_cs(SDL_mutex * mutex_) +static void SDL_DestroyMutex_cs(SDL_mutex *mutex_) { SDL_mutex_cs *mutex = (SDL_mutex_cs *)mutex_; if (mutex != NULL) { @@ -203,8 +192,7 @@ SDL_DestroyMutex_cs(SDL_mutex * mutex_) } /* Lock the mutex */ -static int -SDL_LockMutex_cs(SDL_mutex * mutex_) +static int SDL_LockMutex_cs(SDL_mutex *mutex_) { SDL_mutex_cs *mutex = (SDL_mutex_cs *)mutex_; if (mutex == NULL) { @@ -216,8 +204,7 @@ SDL_LockMutex_cs(SDL_mutex * mutex_) } /* TryLock the mutex */ -static int -SDL_TryLockMutex_cs(SDL_mutex * mutex_) +static int SDL_TryLockMutex_cs(SDL_mutex *mutex_) { SDL_mutex_cs *mutex = (SDL_mutex_cs *)mutex_; int retval = 0; @@ -232,8 +219,7 @@ SDL_TryLockMutex_cs(SDL_mutex * mutex_) } /* Unlock the mutex */ -static int -SDL_UnlockMutex_cs(SDL_mutex * mutex_) +static int SDL_UnlockMutex_cs(SDL_mutex *mutex_) { SDL_mutex_cs *mutex = (SDL_mutex_cs *)mutex_; if (mutex == NULL) { @@ -244,8 +230,7 @@ SDL_UnlockMutex_cs(SDL_mutex * mutex_) return 0; } -static const SDL_mutex_impl_t SDL_mutex_impl_cs = -{ +static const SDL_mutex_impl_t SDL_mutex_impl_cs = { &SDL_CreateMutex_cs, &SDL_DestroyMutex_cs, &SDL_LockMutex_cs, @@ -254,7 +239,6 @@ static const SDL_mutex_impl_t SDL_mutex_impl_cs = SDL_MUTEX_CS, }; - /** * Runtime selection and redirection */ @@ -264,7 +248,7 @@ SDL_CreateMutex(void) { if (SDL_mutex_impl_active.Create == NULL) { /* Default to fallback implementation */ - const SDL_mutex_impl_t * impl = &SDL_mutex_impl_cs; + const SDL_mutex_impl_t *impl = &SDL_mutex_impl_cs; if (!SDL_GetHintBoolean(SDL_HINT_WINDOWS_FORCE_MUTEX_CRITICAL_SECTIONS, SDL_FALSE)) { #if __WINRT__ @@ -275,10 +259,10 @@ SDL_CreateMutex(void) HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll")); if (kernel32) { /* Requires Vista: */ - pReleaseSRWLockExclusive = (pfnReleaseSRWLockExclusive) GetProcAddress(kernel32, "ReleaseSRWLockExclusive"); - pAcquireSRWLockExclusive = (pfnAcquireSRWLockExclusive) GetProcAddress(kernel32, "AcquireSRWLockExclusive"); + pReleaseSRWLockExclusive = (pfnReleaseSRWLockExclusive)GetProcAddress(kernel32, "ReleaseSRWLockExclusive"); + pAcquireSRWLockExclusive = (pfnAcquireSRWLockExclusive)GetProcAddress(kernel32, "AcquireSRWLockExclusive"); /* Requires 7: */ - pTryAcquireSRWLockExclusive = (pfnTryAcquireSRWLockExclusive) GetProcAddress(kernel32, "TryAcquireSRWLockExclusive"); + pTryAcquireSRWLockExclusive = (pfnTryAcquireSRWLockExclusive)GetProcAddress(kernel32, "TryAcquireSRWLockExclusive"); if (pReleaseSRWLockExclusive && pAcquireSRWLockExclusive && pTryAcquireSRWLockExclusive) { impl = &SDL_mutex_impl_srw; } @@ -292,23 +276,23 @@ SDL_CreateMutex(void) return SDL_mutex_impl_active.Create(); } -void -SDL_DestroyMutex(SDL_mutex * mutex) { +void SDL_DestroyMutex(SDL_mutex *mutex) +{ SDL_mutex_impl_active.Destroy(mutex); } -int -SDL_LockMutex(SDL_mutex * mutex) { +int SDL_LockMutex(SDL_mutex *mutex) +{ return SDL_mutex_impl_active.Lock(mutex); } -int -SDL_TryLockMutex(SDL_mutex * mutex) { +int SDL_TryLockMutex(SDL_mutex *mutex) +{ return SDL_mutex_impl_active.TryLock(mutex); } -int -SDL_UnlockMutex(SDL_mutex * mutex) { +int SDL_UnlockMutex(SDL_mutex *mutex) +{ return SDL_mutex_impl_active.Unlock(mutex); } diff --git a/src/thread/windows/SDL_sysmutex_c.h b/src/thread/windows/SDL_sysmutex_c.h index a97c5293d..5d0eea8f7 100644 --- a/src/thread/windows/SDL_sysmutex_c.h +++ b/src/thread/windows/SDL_sysmutex_c.h @@ -39,21 +39,24 @@ typedef enum typedef struct SDL_mutex_impl_t { - pfnSDL_CreateMutex Create; + pfnSDL_CreateMutex Create; pfnSDL_DestroyMutex Destroy; - pfnSDL_LockMutex Lock; + pfnSDL_LockMutex Lock; pfnSDL_TryLockMutex TryLock; - pfnSDL_UnlockMutex Unlock; + pfnSDL_UnlockMutex Unlock; /* Needed by SDL_cond: */ - SDL_MutexType Type; + SDL_MutexType Type; } SDL_mutex_impl_t; extern SDL_mutex_impl_t SDL_mutex_impl_active; - #ifndef SRWLOCK_INIT -#define SRWLOCK_INIT {0} -typedef struct _SRWLOCK { +#define SRWLOCK_INIT \ + { \ + 0 \ + } +typedef struct _SRWLOCK +{ PVOID Ptr; } SRWLOCK, *PSRWLOCK; #endif diff --git a/src/thread/windows/SDL_syssem.c b/src/thread/windows/SDL_syssem.c index 657679966..55a67214a 100644 --- a/src/thread/windows/SDL_syssem.c +++ b/src/thread/windows/SDL_syssem.c @@ -31,7 +31,7 @@ * Faster due to significantly less context switches. * Requires Windows 8 or newer. * which are chosen at runtime. -*/ + */ #include "../../core/windows/SDL_windows.h" @@ -49,18 +49,17 @@ typedef int (*pfnSDL_SemPost)(SDL_sem *); typedef struct SDL_semaphore_impl_t { - pfnSDL_CreateSemaphore Create; + pfnSDL_CreateSemaphore Create; pfnSDL_DestroySemaphore Destroy; - pfnSDL_SemWaitTimeout WaitTimeout; - pfnSDL_SemTryWait TryWait; - pfnSDL_SemWait Wait; - pfnSDL_SemValue Value; - pfnSDL_SemPost Post; + pfnSDL_SemWaitTimeout WaitTimeout; + pfnSDL_SemTryWait TryWait; + pfnSDL_SemWait Wait; + pfnSDL_SemValue Value; + pfnSDL_SemPost Post; } SDL_sem_impl_t; /* Implementation will be chosen at runtime based on available Kernel features */ -static SDL_sem_impl_t SDL_sem_impl_active = {0}; - +static SDL_sem_impl_t SDL_sem_impl_active = { 0 }; /** * Atomic + WaitOnAddress implementation @@ -70,7 +69,7 @@ static SDL_sem_impl_t SDL_sem_impl_active = {0}; /* https://www.microsoft.com/en-us/download/details.aspx?id=47328 */ #if (HAVE_WINAPIFAMILY_H) && defined(WINAPI_FAMILY_PHONE_APP) -#define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP) +#define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) #else #define SDL_WINAPI_FAMILY_PHONE 0 #endif @@ -78,10 +77,10 @@ static SDL_sem_impl_t SDL_sem_impl_active = {0}; #if !SDL_WINAPI_FAMILY_PHONE #if __WINRT__ /* Functions are guaranteed to be available */ -#define pWaitOnAddress WaitOnAddress +#define pWaitOnAddress WaitOnAddress #define pWakeByAddressSingle WakeByAddressSingle #else -typedef BOOL(WINAPI *pfnWaitOnAddress)(volatile VOID*, PVOID, SIZE_T, DWORD); +typedef BOOL(WINAPI *pfnWaitOnAddress)(volatile VOID *, PVOID, SIZE_T, DWORD); typedef VOID(WINAPI *pfnWakeByAddressSingle)(PVOID); static pfnWaitOnAddress pWaitOnAddress = NULL; @@ -93,12 +92,11 @@ typedef struct SDL_semaphore_atom LONG count; } SDL_sem_atom; -static SDL_sem * -SDL_CreateSemaphore_atom(Uint32 initial_value) +static SDL_sem *SDL_CreateSemaphore_atom(Uint32 initial_value) { SDL_sem_atom *sem; - sem = (SDL_sem_atom *) SDL_malloc(sizeof(*sem)); + sem = (SDL_sem_atom *)SDL_malloc(sizeof(*sem)); if (sem != NULL) { sem->count = initial_value; } else { @@ -107,16 +105,14 @@ SDL_CreateSemaphore_atom(Uint32 initial_value) return (SDL_sem *)sem; } -static void -SDL_DestroySemaphore_atom(SDL_sem * sem) +static void SDL_DestroySemaphore_atom(SDL_sem *sem) { if (sem != NULL) { SDL_free(sem); } } -static int -SDL_SemTryWait_atom(SDL_sem * _sem) +static int SDL_SemTryWait_atom(SDL_sem *_sem) { SDL_sem_atom *sem = (SDL_sem_atom *)_sem; LONG count; @@ -137,8 +133,7 @@ SDL_SemTryWait_atom(SDL_sem * _sem) return SDL_MUTEX_TIMEDOUT; } -static int -SDL_SemWait_atom(SDL_sem * _sem) +static int SDL_SemWait_atom(SDL_sem *_sem) { SDL_sem_atom *sem = (SDL_sem_atom *)_sem; LONG count; @@ -162,8 +157,7 @@ SDL_SemWait_atom(SDL_sem * _sem) } } -static int -SDL_SemWaitTimeout_atom(SDL_sem * _sem, Uint32 timeout) +static int SDL_SemWaitTimeout_atom(SDL_sem *_sem, Uint32 timeout) { SDL_sem_atom *sem = (SDL_sem_atom *)_sem; LONG count; @@ -184,7 +178,7 @@ SDL_SemWaitTimeout_atom(SDL_sem * _sem, Uint32 timeout) * need to recalculate the effective timeout before every wait */ now = SDL_GetTicks(); - deadline = now + (DWORD) timeout; + deadline = now + (DWORD)timeout; for (;;) { count = sem->count; @@ -213,8 +207,7 @@ SDL_SemWaitTimeout_atom(SDL_sem * _sem, Uint32 timeout) } } -static Uint32 -SDL_SemValue_atom(SDL_sem * _sem) +static Uint32 SDL_SemValue_atom(SDL_sem *_sem) { SDL_sem_atom *sem = (SDL_sem_atom *)_sem; @@ -226,8 +219,7 @@ SDL_SemValue_atom(SDL_sem * _sem) return (Uint32)sem->count; } -static int -SDL_SemPost_atom(SDL_sem * _sem) +static int SDL_SemPost_atom(SDL_sem *_sem) { SDL_sem_atom *sem = (SDL_sem_atom *)_sem; @@ -241,8 +233,7 @@ SDL_SemPost_atom(SDL_sem * _sem) return 0; } -static const SDL_sem_impl_t SDL_sem_impl_atom = -{ +static const SDL_sem_impl_t SDL_sem_impl_atom = { &SDL_CreateSemaphore_atom, &SDL_DestroySemaphore_atom, &SDL_SemWaitTimeout_atom, @@ -253,7 +244,6 @@ static const SDL_sem_impl_t SDL_sem_impl_atom = }; #endif /* !SDL_WINAPI_FAMILY_PHONE */ - /** * Fallback Semaphore implementation using Kernel Semaphores */ @@ -265,13 +255,12 @@ typedef struct SDL_semaphore_kern } SDL_sem_kern; /* Create a semaphore */ -static SDL_sem * -SDL_CreateSemaphore_kern(Uint32 initial_value) +static SDL_sem *SDL_CreateSemaphore_kern(Uint32 initial_value) { SDL_sem_kern *sem; /* Allocate sem memory */ - sem = (SDL_sem_kern *) SDL_malloc(sizeof(*sem)); + sem = (SDL_sem_kern *)SDL_malloc(sizeof(*sem)); if (sem != NULL) { /* Create the semaphore, with max value 32K */ #if __WINRT__ @@ -292,8 +281,7 @@ SDL_CreateSemaphore_kern(Uint32 initial_value) } /* Free the semaphore */ -static void -SDL_DestroySemaphore_kern(SDL_sem * _sem) +static void SDL_DestroySemaphore_kern(SDL_sem *_sem) { SDL_sem_kern *sem = (SDL_sem_kern *)_sem; if (sem != NULL) { @@ -305,8 +293,7 @@ SDL_DestroySemaphore_kern(SDL_sem * _sem) } } -static int -SDL_SemWaitTimeout_kern(SDL_sem * _sem, Uint32 timeout) +static int SDL_SemWaitTimeout_kern(SDL_sem *_sem, Uint32 timeout) { SDL_sem_kern *sem = (SDL_sem_kern *)_sem; int retval; @@ -319,7 +306,7 @@ SDL_SemWaitTimeout_kern(SDL_sem * _sem, Uint32 timeout) if (timeout == SDL_MUTEX_MAXWAIT) { dwMilliseconds = INFINITE; } else { - dwMilliseconds = (DWORD) timeout; + dwMilliseconds = (DWORD)timeout; } switch (WaitForSingleObjectEx(sem->id, dwMilliseconds, FALSE)) { case WAIT_OBJECT_0: @@ -336,21 +323,18 @@ SDL_SemWaitTimeout_kern(SDL_sem * _sem, Uint32 timeout) return retval; } -static int -SDL_SemTryWait_kern(SDL_sem * sem) +static int SDL_SemTryWait_kern(SDL_sem *sem) { return SDL_SemWaitTimeout_kern(sem, 0); } -static int -SDL_SemWait_kern(SDL_sem * sem) +static int SDL_SemWait_kern(SDL_sem *sem) { return SDL_SemWaitTimeout_kern(sem, SDL_MUTEX_MAXWAIT); } /* Returns the current count of the semaphore */ -static Uint32 -SDL_SemValue_kern(SDL_sem * _sem) +static Uint32 SDL_SemValue_kern(SDL_sem *_sem) { SDL_sem_kern *sem = (SDL_sem_kern *)_sem; if (sem == NULL) { @@ -360,8 +344,7 @@ SDL_SemValue_kern(SDL_sem * _sem) return (Uint32)sem->count; } -static int -SDL_SemPost_kern(SDL_sem * _sem) +static int SDL_SemPost_kern(SDL_sem *_sem) { SDL_sem_kern *sem = (SDL_sem_kern *)_sem; if (sem == NULL) { @@ -374,14 +357,13 @@ SDL_SemPost_kern(SDL_sem * _sem) */ InterlockedIncrement(&sem->count); if (ReleaseSemaphore(sem->id, 1, NULL) == FALSE) { - InterlockedDecrement(&sem->count); /* restore */ + InterlockedDecrement(&sem->count); /* restore */ return SDL_SetError("ReleaseSemaphore() failed"); } return 0; } -static const SDL_sem_impl_t SDL_sem_impl_kern = -{ +static const SDL_sem_impl_t SDL_sem_impl_kern = { &SDL_CreateSemaphore_kern, &SDL_DestroySemaphore_kern, &SDL_SemWaitTimeout_kern, @@ -391,7 +373,6 @@ static const SDL_sem_impl_t SDL_sem_impl_kern = &SDL_SemPost_kern, }; - /** * Runtime selection and redirection */ @@ -401,7 +382,7 @@ SDL_CreateSemaphore(Uint32 initial_value) { if (SDL_sem_impl_active.Create == NULL) { /* Default to fallback implementation */ - const SDL_sem_impl_t * impl = &SDL_sem_impl_kern; + const SDL_sem_impl_t *impl = &SDL_sem_impl_kern; #if !SDL_WINAPI_FAMILY_PHONE if (!SDL_GetHintBoolean(SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL, SDL_FALSE)) { @@ -418,8 +399,8 @@ SDL_CreateSemaphore(Uint32 initial_value) HMODULE synch120 = GetModuleHandle(TEXT("api-ms-win-core-synch-l1-2-0.dll")); if (synch120) { /* Try to load required functions provided by Win 8 or newer */ - pWaitOnAddress = (pfnWaitOnAddress) GetProcAddress(synch120, "WaitOnAddress"); - pWakeByAddressSingle = (pfnWakeByAddressSingle) GetProcAddress(synch120, "WakeByAddressSingle"); + pWaitOnAddress = (pfnWaitOnAddress)GetProcAddress(synch120, "WaitOnAddress"); + pWakeByAddressSingle = (pfnWakeByAddressSingle)GetProcAddress(synch120, "WakeByAddressSingle"); if (pWaitOnAddress && pWakeByAddressSingle) { impl = &SDL_sem_impl_atom; @@ -435,38 +416,33 @@ SDL_CreateSemaphore(Uint32 initial_value) return SDL_sem_impl_active.Create(initial_value); } -void -SDL_DestroySemaphore(SDL_sem * sem) +void SDL_DestroySemaphore(SDL_sem *sem) { SDL_sem_impl_active.Destroy(sem); } -int -SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) +int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) { return SDL_sem_impl_active.WaitTimeout(sem, timeout); } -int -SDL_SemTryWait(SDL_sem * sem) +int SDL_SemTryWait(SDL_sem *sem) { return SDL_sem_impl_active.TryWait(sem); } -int -SDL_SemWait(SDL_sem * sem) +int SDL_SemWait(SDL_sem *sem) { return SDL_sem_impl_active.Wait(sem); } Uint32 -SDL_SemValue(SDL_sem * sem) +SDL_SemValue(SDL_sem *sem) { return SDL_sem_impl_active.Value(sem); } -int -SDL_SemPost(SDL_sem * sem) +int SDL_SemPost(SDL_sem *sem) { return SDL_sem_impl_active.Post(sem); } diff --git a/src/thread/windows/SDL_systhread.c b/src/thread/windows/SDL_systhread.c index dbd6654c9..391871b58 100644 --- a/src/thread/windows/SDL_systhread.c +++ b/src/thread/windows/SDL_systhread.c @@ -40,10 +40,10 @@ /* Cygwin gcc-3 ... MingW64 (even with a i386 host) does this like MSVC. */ #if (defined(__MINGW32__) && (__GNUC__ < 4)) -typedef unsigned long (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned, - unsigned (__stdcall *func)(void *), void *arg, - unsigned, unsigned *threadID); -typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code); +typedef unsigned long(__cdecl *pfnSDL_CurrentBeginThread)(void *, unsigned, + unsigned(__stdcall *func)(void *), void *arg, + unsigned, unsigned *threadID); +typedef void(__cdecl *pfnSDL_CurrentEndThread)(unsigned code); #elif defined(__WATCOMC__) /* This is for Watcom targets except OS2 */ @@ -63,22 +63,20 @@ typedef unsigned long (__watcall * pfnSDL_CurrentBeginThread) (void *, typedef void (__watcall * pfnSDL_CurrentEndThread) (unsigned code); #else -typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, - unsigned (__stdcall * - func) (void - *), - void *arg, unsigned, - unsigned *threadID); -typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code); +typedef uintptr_t(__cdecl *pfnSDL_CurrentBeginThread)(void *, unsigned, + unsigned(__stdcall * + func)(void + *), + void *arg, unsigned, + unsigned *threadID); +typedef void(__cdecl *pfnSDL_CurrentEndThread)(unsigned code); #endif #endif /* !SDL_PASSED_BEGINTHREAD_ENDTHREAD */ - -static DWORD -RunThread(void *data) +static DWORD RunThread(void *data) { - SDL_Thread *thread = (SDL_Thread *) data; - pfnSDL_CurrentEndThread pfnEndThread = (pfnSDL_CurrentEndThread) thread->endfunc; + SDL_Thread *thread = (SDL_Thread *)data; + pfnSDL_CurrentEndThread pfnEndThread = (pfnSDL_CurrentEndThread)thread->endfunc; SDL_RunThread(thread); if (pfnEndThread != NULL) { pfnEndThread(0); @@ -86,33 +84,28 @@ RunThread(void *data) return 0; } -static DWORD WINAPI -RunThreadViaCreateThread(LPVOID data) +static DWORD WINAPI RunThreadViaCreateThread(LPVOID data) { - return RunThread(data); + return RunThread(data); } -static unsigned __stdcall -RunThreadViaBeginThreadEx(void *data) +static unsigned __stdcall RunThreadViaBeginThreadEx(void *data) { - return (unsigned)RunThread(data); + return (unsigned)RunThread(data); } #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD -int -SDL_SYS_CreateThread(SDL_Thread * thread, - pfnSDL_CurrentBeginThread pfnBeginThread, - pfnSDL_CurrentEndThread pfnEndThread) +int SDL_SYS_CreateThread(SDL_Thread *thread, + pfnSDL_CurrentBeginThread pfnBeginThread, + pfnSDL_CurrentEndThread pfnEndThread) { #elif defined(__CYGWIN__) || defined(__WINRT__) -int -SDL_SYS_CreateThread(SDL_Thread * thread) +int SDL_SYS_CreateThread(SDL_Thread *thread) { pfnSDL_CurrentBeginThread pfnBeginThread = NULL; pfnSDL_CurrentEndThread pfnEndThread = NULL; #else -int -SDL_SYS_CreateThread(SDL_Thread * thread) +int SDL_SYS_CreateThread(SDL_Thread *thread) { pfnSDL_CurrentBeginThread pfnBeginThread = (pfnSDL_CurrentBeginThread)_beginthreadex; pfnSDL_CurrentEndThread pfnEndThread = (pfnSDL_CurrentEndThread)_endthreadex; @@ -125,10 +118,9 @@ SDL_SYS_CreateThread(SDL_Thread * thread) /* thread->stacksize == 0 means "system default", same as win32 expects */ if (pfnBeginThread) { unsigned threadid = 0; - thread->handle = (SYS_ThreadHandle) - ((size_t) pfnBeginThread(NULL, (unsigned int) thread->stacksize, - RunThreadViaBeginThreadEx, - thread, flags, &threadid)); + thread->handle = (SYS_ThreadHandle)((size_t)pfnBeginThread(NULL, (unsigned int)thread->stacksize, + RunThreadViaBeginThreadEx, + thread, flags, &threadid)); } else { DWORD threadid = 0; thread->handle = CreateThread(NULL, thread->stacksize, @@ -141,31 +133,29 @@ SDL_SYS_CreateThread(SDL_Thread * thread) return 0; } -#pragma pack(push,8) +#pragma pack(push, 8) typedef struct tagTHREADNAME_INFO { - DWORD dwType; /* must be 0x1000 */ - LPCSTR szName; /* pointer to name (in user addr space) */ + DWORD dwType; /* must be 0x1000 */ + LPCSTR szName; /* pointer to name (in user addr space) */ DWORD dwThreadID; /* thread ID (-1=caller thread) */ - DWORD dwFlags; /* reserved for future use, must be zero */ + DWORD dwFlags; /* reserved for future use, must be zero */ } THREADNAME_INFO; #pragma pack(pop) +typedef HRESULT(WINAPI *pfnSetThreadDescription)(HANDLE, PCWSTR); -typedef HRESULT (WINAPI *pfnSetThreadDescription)(HANDLE, PCWSTR); - -void -SDL_SYS_SetupThread(const char *name) +void SDL_SYS_SetupThread(const char *name) { if (name != NULL) { - #ifndef __WINRT__ /* !!! FIXME: There's no LoadLibrary() in WinRT; don't know if SetThreadDescription is available there at all at the moment. */ +#ifndef __WINRT__ /* !!! FIXME: There's no LoadLibrary() in WinRT; don't know if SetThreadDescription is available there at all at the moment. */ static pfnSetThreadDescription pSetThreadDescription = NULL; static HMODULE kernel32 = 0; if (!kernel32) { kernel32 = GetModuleHandle(TEXT("kernel32.dll")); if (kernel32) { - pSetThreadDescription = (pfnSetThreadDescription) GetProcAddress(kernel32, "SetThreadDescription"); + pSetThreadDescription = (pfnSetThreadDescription)GetProcAddress(kernel32, "SetThreadDescription"); } } @@ -176,7 +166,7 @@ SDL_SYS_SetupThread(const char *name) SDL_free(strw); } } - #endif +#endif /* Presumably some version of Visual Studio will understand SetThreadDescription(), but we still need to deal with older OSes and debuggers. Set it with the arcane @@ -194,11 +184,11 @@ SDL_SYS_SetupThread(const char *name) SDL_zero(inf); inf.dwType = 0x1000; inf.szName = name; - inf.dwThreadID = (DWORD) -1; + inf.dwThreadID = (DWORD)-1; inf.dwFlags = 0; /* The debugger catches this, renames the thread, continues on. */ - RaiseException(0x406D1388, 0, sizeof(inf) / sizeof(ULONG), (const ULONG_PTR*) &inf); + RaiseException(0x406D1388, 0, sizeof(inf) / sizeof(ULONG), (const ULONG_PTR *)&inf); } } } @@ -209,8 +199,7 @@ SDL_ThreadID(void) return (SDL_threadID)GetCurrentThreadId(); } -int -SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) +int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) { int value; @@ -229,15 +218,13 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) return 0; } -void -SDL_SYS_WaitThread(SDL_Thread * thread) +void SDL_SYS_WaitThread(SDL_Thread *thread) { WaitForSingleObjectEx(thread->handle, INFINITE, FALSE); CloseHandle(thread->handle); } -void -SDL_SYS_DetachThread(SDL_Thread * thread) +void SDL_SYS_DetachThread(SDL_Thread *thread) { CloseHandle(thread->handle); } diff --git a/src/thread/windows/SDL_systls.c b/src/thread/windows/SDL_systls.c index 22e507a7a..884bf0a18 100644 --- a/src/thread/windows/SDL_systls.c +++ b/src/thread/windows/SDL_systls.c @@ -32,7 +32,7 @@ #include #ifndef TLS_OUT_OF_INDEXES -#define TLS_OUT_OF_INDEXES FLS_OUT_OF_INDEXES +#define TLS_OUT_OF_INDEXES FLS_OUT_OF_INDEXES #endif #define TlsAlloc() FlsAlloc(NULL) @@ -67,8 +67,7 @@ SDL_SYS_GetTLSData(void) return (SDL_TLSData *)TlsGetValue(thread_local_storage); } -int -SDL_SYS_SetTLSData(SDL_TLSData *data) +int SDL_SYS_SetTLSData(SDL_TLSData *data) { if (generic_local_storage) { return SDL_Generic_SetTLSData(data); diff --git a/src/timer/SDL_timer.c b/src/timer/SDL_timer.c index 3a5828b42..fc8e62d9e 100644 --- a/src/timer/SDL_timer.c +++ b/src/timer/SDL_timer.c @@ -49,7 +49,8 @@ typedef struct _SDL_TimerMap } SDL_TimerMap; /* The timers are kept in a sorted list */ -typedef struct { +typedef struct +{ /* Data used by the main thread */ SDL_Thread *thread; SDL_atomic_t nextID; @@ -78,14 +79,13 @@ static SDL_TimerData SDL_timer_data; * Timers are removed by simply setting a canceled flag */ -static void -SDL_AddTimerInternal(SDL_TimerData *data, SDL_Timer *timer) +static void SDL_AddTimerInternal(SDL_TimerData *data, SDL_Timer *timer) { SDL_Timer *prev, *curr; prev = NULL; for (curr = data->timers; curr; prev = curr, curr = curr->next) { - if ((Sint32)(timer->scheduled-curr->scheduled) < 0) { + if ((Sint32)(timer->scheduled - curr->scheduled) < 0) { break; } } @@ -99,8 +99,7 @@ SDL_AddTimerInternal(SDL_TimerData *data, SDL_Timer *timer) timer->next = curr; } -static int SDLCALL -SDL_TimerThread(void *_data) +static int SDLCALL SDL_TimerThread(void *_data) { SDL_TimerData *data = (SDL_TimerData *)_data; SDL_Timer *pending; @@ -114,7 +113,7 @@ SDL_TimerThread(void *_data) * 2. Handle any timers that should dispatch this cycle * 3. Wait until next dispatch time or new timer arrives */ - for ( ; ; ) { + for (;;) { /* Pending and freelist maintenance */ SDL_AtomicLock(&data->lock); { @@ -153,7 +152,7 @@ SDL_TimerThread(void *_data) while (data->timers) { current = data->timers; - if ((Sint32)(tick-current->scheduled) < 0) { + if ((Sint32)(tick - current->scheduled) < 0) { /* Scheduled for the future, wait a bit */ delay = (current->scheduled - tick); break; @@ -205,8 +204,7 @@ SDL_TimerThread(void *_data) return 0; } -int -SDL_TimerInit(void) +int SDL_TimerInit(void) { SDL_TimerData *data = &SDL_timer_data; @@ -237,14 +235,13 @@ SDL_TimerInit(void) return 0; } -void -SDL_TimerQuit(void) +void SDL_TimerQuit(void) { SDL_TimerData *data = &SDL_timer_data; SDL_Timer *timer; SDL_TimerMap *entry; - if (SDL_AtomicCAS(&data->active, 1, 0)) { /* active? Move to inactive. */ + if (SDL_AtomicCAS(&data->active, 1, 0)) { /* active? Move to inactive. */ /* Shutdown the timer thread */ if (data->thread) { SDL_SemPost(data->sem); @@ -387,17 +384,17 @@ typedef struct _SDL_TimerMap struct _SDL_TimerMap *next; } SDL_TimerMap; -typedef struct { +typedef struct +{ int nextID; SDL_TimerMap *timermap; } SDL_TimerData; static SDL_TimerData SDL_timer_data; -static void -SDL_Emscripten_TimerHelper(void *userdata) +static void SDL_Emscripten_TimerHelper(void *userdata) { - SDL_TimerMap *entry = (SDL_TimerMap*)userdata; + SDL_TimerMap *entry = (SDL_TimerMap *)userdata; entry->interval = entry->callback(entry->interval, entry->param); if (entry->interval > 0) { entry->timeoutID = emscripten_set_timeout(&SDL_Emscripten_TimerHelper, @@ -406,14 +403,12 @@ SDL_Emscripten_TimerHelper(void *userdata) } } -int -SDL_TimerInit(void) +int SDL_TimerInit(void) { return 0; } -void -SDL_TimerQuit(void) +void SDL_TimerQuit(void) { SDL_TimerData *data = &SDL_timer_data; SDL_TimerMap *entry; @@ -488,7 +483,7 @@ SDL_RemoveTimer(SDL_TimerID id) Uint32 SDL_GetTicks(void) { - return (Uint32) (SDL_GetTicks64() & 0xFFFFFFFF); + return (Uint32)(SDL_GetTicks64() & 0xFFFFFFFF); } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/timer/SDL_timer_c.h b/src/timer/SDL_timer_c.h index 555913e4d..05a548ca3 100644 --- a/src/timer/SDL_timer_c.h +++ b/src/timer/SDL_timer_c.h @@ -28,7 +28,7 @@ #include "SDL_timer.h" #define ROUND_RESOLUTION(X) \ - (((X+TIMER_RESOLUTION-1)/TIMER_RESOLUTION)*TIMER_RESOLUTION) + (((X + TIMER_RESOLUTION - 1) / TIMER_RESOLUTION) * TIMER_RESOLUTION) extern void SDL_TicksInit(void); extern void SDL_TicksQuit(void); diff --git a/src/timer/dummy/SDL_systimer.c b/src/timer/dummy/SDL_systimer.c index 8e34959f0..dc34647d5 100644 --- a/src/timer/dummy/SDL_systimer.c +++ b/src/timer/dummy/SDL_systimer.c @@ -26,8 +26,7 @@ static SDL_bool ticks_started = SDL_FALSE; -void -SDL_TicksInit(void) +void SDL_TicksInit(void) { if (ticks_started) { return; @@ -35,8 +34,7 @@ SDL_TicksInit(void) ticks_started = SDL_TRUE; } -void -SDL_TicksQuit(void) +void SDL_TicksQuit(void) { ticks_started = SDL_FALSE; } @@ -64,8 +62,7 @@ SDL_GetPerformanceFrequency(void) return 1000; } -void -SDL_Delay(Uint32 ms) +void SDL_Delay(Uint32 ms) { SDL_Unsupported(); } diff --git a/src/timer/haiku/SDL_systimer.c b/src/timer/haiku/SDL_systimer.c index fb358b9d2..65a87306b 100644 --- a/src/timer/haiku/SDL_systimer.c +++ b/src/timer/haiku/SDL_systimer.c @@ -29,8 +29,7 @@ static bigtime_t start; static SDL_bool ticks_started = SDL_FALSE; -void -SDL_TicksInit(void) +void SDL_TicksInit(void) { if (ticks_started) { return; @@ -41,8 +40,7 @@ SDL_TicksInit(void) start = system_time(); } -void -SDL_TicksQuit(void) +void SDL_TicksQuit(void) { ticks_started = SDL_FALSE; } @@ -54,7 +52,7 @@ SDL_GetTicks64(void) SDL_TicksInit(); } - return (Uint64) ((system_time() - start) / 1000); + return (Uint64)((system_time() - start) / 1000); } Uint64 @@ -69,8 +67,7 @@ SDL_GetPerformanceFrequency(void) return 1000000; } -void -SDL_Delay(Uint32 ms) +void SDL_Delay(Uint32 ms) { snooze(ms * 1000); } diff --git a/src/timer/n3ds/SDL_systimer.c b/src/timer/n3ds/SDL_systimer.c index 6a4d29b04..adce9ea88 100644 --- a/src/timer/n3ds/SDL_systimer.c +++ b/src/timer/n3ds/SDL_systimer.c @@ -29,8 +29,7 @@ static u64 start_tick; #define NSEC_PER_MSEC 1000000ULL -void -SDL_TicksInit(void) +void SDL_TicksInit(void) { if (ticks_started) { return; @@ -40,8 +39,7 @@ SDL_TicksInit(void) start_tick = svcGetSystemTick(); } -void -SDL_TicksQuit(void) +void SDL_TicksQuit(void) { ticks_started = SDL_FALSE; } @@ -70,8 +68,7 @@ SDL_GetPerformanceFrequency(void) return SYSCLOCK_ARM11; } -void -SDL_Delay(Uint32 ms) +void SDL_Delay(Uint32 ms) { svcSleepThread(ms * NSEC_PER_MSEC); } diff --git a/src/timer/ngage/SDL_systimer.cpp b/src/timer/ngage/SDL_systimer.cpp index bb56d2388..94fe8b570 100644 --- a/src/timer/ngage/SDL_systimer.cpp +++ b/src/timer/ngage/SDL_systimer.cpp @@ -28,32 +28,30 @@ #include "SDL_timer.h" static SDL_bool ticks_started = SDL_FALSE; -static TUint start = 0; -static TInt tickPeriodMilliSeconds; +static TUint start = 0; +static TInt tickPeriodMilliSeconds; #ifdef __cplusplus extern "C" { #endif -void -SDL_TicksInit(void) +void SDL_TicksInit(void) { if (ticks_started) { return; } ticks_started = SDL_TRUE; - start = User::TickCount(); + start = User::TickCount(); TTimeIntervalMicroSeconds32 period; - TInt tmp = UserHal::TickPeriod(period); + TInt tmp = UserHal::TickPeriod(period); (void)tmp; /* Suppress redundant warning. */ tickPeriodMilliSeconds = period.Int() / 1000; } -void -SDL_TicksQuit(void) +void SDL_TicksQuit(void) { ticks_started = SDL_FALSE; } @@ -61,7 +59,7 @@ SDL_TicksQuit(void) Uint64 SDL_GetTicks64(void) { - if (! ticks_started) { + if (!ticks_started) { SDL_TicksInit(); } @@ -83,8 +81,7 @@ SDL_GetPerformanceFrequency(void) return 1000000; } -void -SDL_Delay(Uint32 ms) +void SDL_Delay(Uint32 ms) { User::After(TTimeIntervalMicroSeconds32(ms * 1000)); } diff --git a/src/timer/ps2/SDL_systimer.c b/src/timer/ps2/SDL_systimer.c index 42d296803..98a0454c5 100644 --- a/src/timer/ps2/SDL_systimer.c +++ b/src/timer/ps2/SDL_systimer.c @@ -34,8 +34,7 @@ static uint64_t start; static SDL_bool ticks_started = SDL_FALSE; -void -SDL_TicksInit(void) +void SDL_TicksInit(void) { if (ticks_started) { return; @@ -45,8 +44,7 @@ SDL_TicksInit(void) start = GetTimerSystemTime(); } -void -SDL_TicksQuit(void) +void SDL_TicksQuit(void) { ticks_started = SDL_FALSE; } @@ -78,9 +76,9 @@ SDL_GetPerformanceFrequency(void) void SDL_Delay(Uint32 ms) { - struct timespec tv = {0}; - tv.tv_sec = ms / 1000; - tv.tv_nsec = (ms % 1000) * 1000000; + struct timespec tv = { 0 }; + tv.tv_sec = ms / 1000; + tv.tv_nsec = (ms % 1000) * 1000000; nanosleep(&tv, NULL); } diff --git a/src/timer/psp/SDL_systimer.c b/src/timer/psp/SDL_systimer.c index 0609958dd..de115d01e 100644 --- a/src/timer/psp/SDL_systimer.c +++ b/src/timer/psp/SDL_systimer.c @@ -34,8 +34,7 @@ static struct timeval start; static SDL_bool ticks_started = SDL_FALSE; -void -SDL_TicksInit(void) +void SDL_TicksInit(void) { if (ticks_started) { return; @@ -45,8 +44,7 @@ SDL_TicksInit(void) gettimeofday(&start, NULL); } -void -SDL_TicksQuit(void) +void SDL_TicksQuit(void) { ticks_started = SDL_FALSE; } diff --git a/src/timer/unix/SDL_systimer.c b/src/timer/unix/SDL_systimer.c index c7696c398..cbda1f758 100644 --- a/src/timer/unix/SDL_systimer.c +++ b/src/timer/unix/SDL_systimer.c @@ -73,8 +73,7 @@ static SDL_bool has_monotonic_time = SDL_FALSE; static struct timeval start_tv; static SDL_bool ticks_started = SDL_FALSE; -void -SDL_TicksInit(void) +void SDL_TicksInit(void) { if (ticks_started) { return; @@ -97,8 +96,7 @@ SDL_TicksInit(void) } } -void -SDL_TicksQuit(void) +void SDL_TicksQuit(void) { ticks_started = SDL_FALSE; } @@ -178,13 +176,12 @@ SDL_GetPerformanceFrequency(void) freq /= mach_base_info.numer; return freq; #endif - } - + } + return 1000000; } -void -SDL_Delay(Uint32 ms) +void SDL_Delay(Uint32 ms) { int was_error; diff --git a/src/timer/vita/SDL_systimer.c b/src/timer/vita/SDL_systimer.c index 899d6bf6f..e61a9f132 100644 --- a/src/timer/vita/SDL_systimer.c +++ b/src/timer/vita/SDL_systimer.c @@ -34,8 +34,7 @@ static uint64_t start; static SDL_bool ticks_started = SDL_FALSE; -void -SDL_TicksInit(void) +void SDL_TicksInit(void) { if (ticks_started) { return; @@ -45,8 +44,7 @@ SDL_TicksInit(void) start = sceKernelGetProcessTimeWide(); } -void -SDL_TicksQuit(void) +void SDL_TicksQuit(void) { ticks_started = SDL_FALSE; } @@ -61,7 +59,7 @@ SDL_GetTicks64(void) } now = sceKernelGetProcessTimeWide(); - return (Uint64) ((now - start) / 1000); + return (Uint64)((now - start) / 1000); } Uint64 diff --git a/src/timer/windows/SDL_systimer.c b/src/timer/windows/SDL_systimer.c index 52dea837f..4f371ffcc 100644 --- a/src/timer/windows/SDL_systimer.c +++ b/src/timer/windows/SDL_systimer.c @@ -31,15 +31,14 @@ /* The first (low-resolution) ticks value of the application */ static DWORD start = 0; -static BOOL ticks_started = FALSE; +static BOOL ticks_started = FALSE; /* The first high-resolution ticks value of the application */ static LARGE_INTEGER start_ticks; /* The number of ticks per second of the high-resolution performance counter */ static LARGE_INTEGER ticks_per_second; -static void -SDL_SetSystemTimerResolution(const UINT uPeriod) +static void SDL_SetSystemTimerResolution(const UINT uPeriod) { #if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) static UINT timer_period = 0; @@ -58,8 +57,7 @@ SDL_SetSystemTimerResolution(const UINT uPeriod) #endif } -static void SDLCALL -SDL_TimerResolutionChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_TimerResolutionChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { UINT uPeriod; @@ -74,8 +72,7 @@ SDL_TimerResolutionChanged(void *userdata, const char *name, const char *oldValu } } -void -SDL_TicksInit(void) +void SDL_TicksInit(void) { BOOL rc; @@ -94,17 +91,16 @@ SDL_TicksInit(void) so we'll rely on it here. */ rc = QueryPerformanceFrequency(&ticks_per_second); - SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */ + SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */ QueryPerformanceCounter(&start_ticks); } -void -SDL_TicksQuit(void) +void SDL_TicksQuit(void) { SDL_DelHintCallback(SDL_HINT_TIMER_RESOLUTION, SDL_TimerResolutionChanged, NULL); - SDL_SetSystemTimerResolution(0); /* always release our timer resolution request. */ + SDL_SetSystemTimerResolution(0); /* always release our timer resolution request. */ start = 0; ticks_started = SDL_FALSE; @@ -121,8 +117,8 @@ SDL_GetTicks64(void) } rc = QueryPerformanceCounter(&now); - SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */ - return (Uint64) (((now.QuadPart - start_ticks.QuadPart) * 1000) / ticks_per_second.QuadPart); + SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */ + return (Uint64)(((now.QuadPart - start_ticks.QuadPart) * 1000) / ticks_per_second.QuadPart); } Uint64 @@ -130,8 +126,8 @@ SDL_GetPerformanceCounter(void) { LARGE_INTEGER counter; const BOOL rc = QueryPerformanceCounter(&counter); - SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */ - return (Uint64) counter.QuadPart; + SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */ + return (Uint64)counter.QuadPart; } Uint64 @@ -139,12 +135,11 @@ SDL_GetPerformanceFrequency(void) { LARGE_INTEGER frequency; const BOOL rc = QueryPerformanceFrequency(&frequency); - SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */ - return (Uint64) frequency.QuadPart; + SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */ + return (Uint64)frequency.QuadPart; } -void -SDL_Delay(Uint32 ms) +void SDL_Delay(Uint32 ms) { /* Sleep() is not publicly available to apps in early versions of WinRT. * diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c index d9eaa4905..a20e2b606 100644 --- a/src/video/SDL_RLEaccel.c +++ b/src/video/SDL_RLEaccel.c @@ -92,14 +92,14 @@ #include "SDL_blit.h" #include "SDL_RLEaccel_c.h" -#define PIXEL_COPY(to, from, len, bpp) \ +#define PIXEL_COPY(to, from, len, bpp) \ SDL_memcpy(to, from, (size_t)(len) * (bpp)) /* * Various colorkey blit methods, for opaque and per-surface alpha */ -#define OPAQUE_BLIT(to, from, length, bpp, alpha) \ +#define OPAQUE_BLIT(to, from, length, bpp, alpha) \ PIXEL_COPY(to, from, length, bpp) /* @@ -109,22 +109,22 @@ * of each component, so the bits from the multiplication don't collide. * This can be used for any RGB permutation of course. */ -#define ALPHA_BLIT32_888(to, from, length, bpp, alpha) \ - do { \ - int i; \ - Uint32 *src = (Uint32 *)(from); \ - Uint32 *dst = (Uint32 *)(to); \ - for (i = 0; i < (int)(length); i++) { \ - Uint32 s = *src++; \ - Uint32 d = *dst; \ - Uint32 s1 = s & 0xff00ff; \ - Uint32 d1 = d & 0xff00ff; \ +#define ALPHA_BLIT32_888(to, from, length, bpp, alpha) \ + do { \ + int i; \ + Uint32 *src = (Uint32 *)(from); \ + Uint32 *dst = (Uint32 *)(to); \ + for (i = 0; i < (int)(length); i++) { \ + Uint32 s = *src++; \ + Uint32 d = *dst; \ + Uint32 s1 = s & 0xff00ff; \ + Uint32 d1 = d & 0xff00ff; \ d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; \ - s &= 0xff00; \ - d &= 0xff00; \ - d = (d + ((s - d) * alpha >> 8)) & 0xff00; \ - *dst++ = d1 | d; \ - } \ + s &= 0xff00; \ + d &= 0xff00; \ + d = (d + ((s - d) * alpha >> 8)) & 0xff00; \ + *dst++ = d1 | d; \ + } \ } while (0) /* @@ -133,98 +133,98 @@ * components at the same time. Since the smallest gap is here just * 5 bits, we have to scale alpha down to 5 bits as well. */ -#define ALPHA_BLIT16_565(to, from, length, bpp, alpha) \ - do { \ - int i; \ - Uint16 *src = (Uint16 *)(from); \ - Uint16 *dst = (Uint16 *)(to); \ - Uint32 ALPHA = alpha >> 3; \ - for (i = 0; i < (int)(length); i++) { \ - Uint32 s = *src++; \ - Uint32 d = *dst; \ - s = (s | s << 16) & 0x07e0f81f; \ - d = (d | d << 16) & 0x07e0f81f; \ - d += (s - d) * ALPHA >> 5; \ - d &= 0x07e0f81f; \ - *dst++ = (Uint16)(d | d >> 16); \ - } \ +#define ALPHA_BLIT16_565(to, from, length, bpp, alpha) \ + do { \ + int i; \ + Uint16 *src = (Uint16 *)(from); \ + Uint16 *dst = (Uint16 *)(to); \ + Uint32 ALPHA = alpha >> 3; \ + for (i = 0; i < (int)(length); i++) { \ + Uint32 s = *src++; \ + Uint32 d = *dst; \ + s = (s | s << 16) & 0x07e0f81f; \ + d = (d | d << 16) & 0x07e0f81f; \ + d += (s - d) * ALPHA >> 5; \ + d &= 0x07e0f81f; \ + *dst++ = (Uint16)(d | d >> 16); \ + } \ } while (0) -#define ALPHA_BLIT16_555(to, from, length, bpp, alpha) \ - do { \ - int i; \ - Uint16 *src = (Uint16 *)(from); \ - Uint16 *dst = (Uint16 *)(to); \ - Uint32 ALPHA = alpha >> 3; \ - for (i = 0; i < (int)(length); i++) { \ - Uint32 s = *src++; \ - Uint32 d = *dst; \ - s = (s | s << 16) & 0x03e07c1f; \ - d = (d | d << 16) & 0x03e07c1f; \ - d += (s - d) * ALPHA >> 5; \ - d &= 0x03e07c1f; \ - *dst++ = (Uint16)(d | d >> 16); \ - } \ +#define ALPHA_BLIT16_555(to, from, length, bpp, alpha) \ + do { \ + int i; \ + Uint16 *src = (Uint16 *)(from); \ + Uint16 *dst = (Uint16 *)(to); \ + Uint32 ALPHA = alpha >> 3; \ + for (i = 0; i < (int)(length); i++) { \ + Uint32 s = *src++; \ + Uint32 d = *dst; \ + s = (s | s << 16) & 0x03e07c1f; \ + d = (d | d << 16) & 0x03e07c1f; \ + d += (s - d) * ALPHA >> 5; \ + d &= 0x03e07c1f; \ + *dst++ = (Uint16)(d | d >> 16); \ + } \ } while (0) /* * The general slow catch-all function, for remaining depths and formats */ -#define ALPHA_BLIT_ANY(to, from, length, bpp, alpha) \ - do { \ - int i; \ - Uint8 *src = from; \ - Uint8 *dst = to; \ - for (i = 0; i < (int)(length); i++) { \ - Uint32 s, d; \ - unsigned rs, gs, bs, rd, gd, bd; \ - switch (bpp) { \ - case 2: \ - s = *(Uint16 *)src; \ - d = *(Uint16 *)dst; \ - break; \ - case 3: \ - if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \ +#define ALPHA_BLIT_ANY(to, from, length, bpp, alpha) \ + do { \ + int i; \ + Uint8 *src = from; \ + Uint8 *dst = to; \ + for (i = 0; i < (int)(length); i++) { \ + Uint32 s, d; \ + unsigned rs, gs, bs, rd, gd, bd; \ + switch (bpp) { \ + case 2: \ + s = *(Uint16 *)src; \ + d = *(Uint16 *)dst; \ + break; \ + case 3: \ + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \ s = (src[0] << 16) | (src[1] << 8) | src[2]; \ d = (dst[0] << 16) | (dst[1] << 8) | dst[2]; \ - } else { \ + } else { \ s = (src[2] << 16) | (src[1] << 8) | src[0]; \ d = (dst[2] << 16) | (dst[1] << 8) | dst[0]; \ - } \ - break; \ - case 4: \ - s = *(Uint32 *)src; \ - d = *(Uint32 *)dst; \ - break; \ - } \ - RGB_FROM_PIXEL(s, fmt, rs, gs, bs); \ - RGB_FROM_PIXEL(d, fmt, rd, gd, bd); \ - rd += (rs - rd) * alpha >> 8; \ - gd += (gs - gd) * alpha >> 8; \ - bd += (bs - bd) * alpha >> 8; \ - PIXEL_FROM_RGB(d, fmt, rd, gd, bd); \ - switch (bpp) { \ - case 2: \ - *(Uint16 *)dst = (Uint16)d; \ - break; \ - case 3: \ - if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \ - dst[0] = (Uint8)(d >> 16); \ - dst[1] = (Uint8)(d >> 8); \ - dst[2] = (Uint8)(d); \ - } else { \ - dst[0] = (Uint8)d; \ - dst[1] = (Uint8)(d >> 8); \ - dst[2] = (Uint8)(d >> 16); \ - } \ - break; \ - case 4: \ - *(Uint32 *)dst = d; \ - break; \ - } \ - src += bpp; \ - dst += bpp; \ - } \ + } \ + break; \ + case 4: \ + s = *(Uint32 *)src; \ + d = *(Uint32 *)dst; \ + break; \ + } \ + RGB_FROM_PIXEL(s, fmt, rs, gs, bs); \ + RGB_FROM_PIXEL(d, fmt, rd, gd, bd); \ + rd += (rs - rd) * alpha >> 8; \ + gd += (gs - gd) * alpha >> 8; \ + bd += (bs - bd) * alpha >> 8; \ + PIXEL_FROM_RGB(d, fmt, rd, gd, bd); \ + switch (bpp) { \ + case 2: \ + *(Uint16 *)dst = (Uint16)d; \ + break; \ + case 3: \ + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \ + dst[0] = (Uint8)(d >> 16); \ + dst[1] = (Uint8)(d >> 8); \ + dst[2] = (Uint8)(d); \ + } else { \ + dst[0] = (Uint8)d; \ + dst[1] = (Uint8)(d >> 8); \ + dst[2] = (Uint8)(d >> 16); \ + } \ + break; \ + case 4: \ + *(Uint32 *)dst = d; \ + break; \ + } \ + src += bpp; \ + dst += bpp; \ + } \ } while (0) /* @@ -235,17 +235,16 @@ * First zero the lowest bit of each component, which gives us room to * add them. Then shift right and add the sum of the lowest bits. */ -#define ALPHA_BLIT32_888_50(to, from, length, bpp, alpha) \ - do { \ - int i; \ - Uint32 *src = (Uint32 *)(from); \ - Uint32 *dst = (Uint32 *)(to); \ - for (i = 0; i < (int)(length); i++) { \ - Uint32 s = *src++; \ - Uint32 d = *dst; \ - *dst++ = (((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1) \ - + (s & d & 0x00010101); \ - } \ +#define ALPHA_BLIT32_888_50(to, from, length, bpp, alpha) \ + do { \ + int i; \ + Uint32 *src = (Uint32 *)(from); \ + Uint32 *dst = (Uint32 *)(to); \ + for (i = 0; i < (int)(length); i++) { \ + Uint32 s = *src++; \ + Uint32 d = *dst; \ + *dst++ = (((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1) + (s & d & 0x00010101); \ + } \ } while (0) /* @@ -254,190 +253,187 @@ */ /* helper: blend a single 16 bit pixel at 50% */ -#define BLEND16_50(dst, src, mask) \ - do { \ - Uint32 s = *src++; \ - Uint32 d = *dst; \ - *dst++ = (Uint16)((((s & mask) + (d & mask)) >> 1) + \ - (s & d & (~mask & 0xffff))); \ +#define BLEND16_50(dst, src, mask) \ + do { \ + Uint32 s = *src++; \ + Uint32 d = *dst; \ + *dst++ = (Uint16)((((s & mask) + (d & mask)) >> 1) + \ + (s & d & (~mask & 0xffff))); \ } while (0) /* basic 16bpp blender. mask is the pixels to keep when adding. */ -#define ALPHA_BLIT16_50(to, from, length, bpp, alpha, mask) \ - do { \ - unsigned n = (length); \ - Uint16 *src = (Uint16 *)(from); \ - Uint16 *dst = (Uint16 *)(to); \ - if (((uintptr_t)src ^ (uintptr_t)dst) & 3) { \ - /* source and destination not in phase, blit one by one */ \ - while (n--) \ - BLEND16_50(dst, src, mask); \ - } else { \ - if ((uintptr_t)src & 3) { \ - /* first odd pixel */ \ - BLEND16_50(dst, src, mask); \ - n--; \ - } \ - for (; n > 1; n -= 2) { \ - Uint32 s = *(Uint32 *)src; \ - Uint32 d = *(Uint32 *)dst; \ - *(Uint32 *)dst = ((s & (mask | mask << 16)) >> 1) \ - + ((d & (mask | mask << 16)) >> 1) \ - + (s & d & (~(mask | mask << 16))); \ - src += 2; \ - dst += 2; \ - } \ - if (n) \ - BLEND16_50(dst, src, mask); /* last odd pixel */ \ - } \ +#define ALPHA_BLIT16_50(to, from, length, bpp, alpha, mask) \ + do { \ + unsigned n = (length); \ + Uint16 *src = (Uint16 *)(from); \ + Uint16 *dst = (Uint16 *)(to); \ + if (((uintptr_t)src ^ (uintptr_t)dst) & 3) { \ + /* source and destination not in phase, blit one by one */ \ + while (n--) \ + BLEND16_50(dst, src, mask); \ + } else { \ + if ((uintptr_t)src & 3) { \ + /* first odd pixel */ \ + BLEND16_50(dst, src, mask); \ + n--; \ + } \ + for (; n > 1; n -= 2) { \ + Uint32 s = *(Uint32 *)src; \ + Uint32 d = *(Uint32 *)dst; \ + *(Uint32 *)dst = ((s & (mask | mask << 16)) >> 1) + ((d & (mask | mask << 16)) >> 1) + (s & d & (~(mask | mask << 16))); \ + src += 2; \ + dst += 2; \ + } \ + if (n) \ + BLEND16_50(dst, src, mask); /* last odd pixel */ \ + } \ } while (0) -#define ALPHA_BLIT16_565_50(to, from, length, bpp, alpha) \ +#define ALPHA_BLIT16_565_50(to, from, length, bpp, alpha) \ ALPHA_BLIT16_50(to, from, length, bpp, alpha, 0xf7deU) -#define ALPHA_BLIT16_555_50(to, from, length, bpp, alpha) \ +#define ALPHA_BLIT16_555_50(to, from, length, bpp, alpha) \ ALPHA_BLIT16_50(to, from, length, bpp, alpha, 0xfbdeU) -#define CHOOSE_BLIT(blitter, alpha, fmt) \ - do { \ - if (alpha == 255) { \ - switch (fmt->BytesPerPixel) { \ - case 1: blitter(1, Uint8, OPAQUE_BLIT); break; \ - case 2: blitter(2, Uint8, OPAQUE_BLIT); break; \ - case 3: blitter(3, Uint8, OPAQUE_BLIT); break; \ - case 4: blitter(4, Uint16, OPAQUE_BLIT); break; \ - } \ - } else { \ - switch (fmt->BytesPerPixel) { \ - case 1: \ - /* No 8bpp alpha blitting */ \ - break; \ - \ - case 2: \ - switch (fmt->Rmask | fmt->Gmask | fmt->Bmask) { \ - case 0xffff: \ - if (fmt->Gmask == 0x07e0 \ - || fmt->Rmask == 0x07e0 \ - || fmt->Bmask == 0x07e0) { \ - if (alpha == 128) { \ - blitter(2, Uint8, ALPHA_BLIT16_565_50); \ - } else { \ - blitter(2, Uint8, ALPHA_BLIT16_565); \ - } \ - } else { \ - goto general16; \ - } \ - break; \ - \ - case 0x7fff: \ - if (fmt->Gmask == 0x03e0 \ - || fmt->Rmask == 0x03e0 \ - || fmt->Bmask == 0x03e0) { \ - if (alpha == 128) { \ - blitter(2, Uint8, ALPHA_BLIT16_555_50); \ - } else { \ - blitter(2, Uint8, ALPHA_BLIT16_555); \ - } \ - break; \ - } else { \ - goto general16; \ - } \ - break; \ - \ - default: \ - general16: \ - blitter(2, Uint8, ALPHA_BLIT_ANY); \ - } \ - break; \ - \ - case 3: \ - blitter(3, Uint8, ALPHA_BLIT_ANY); \ - break; \ - \ - case 4: \ - if ((fmt->Rmask | fmt->Gmask | fmt->Bmask) == 0x00ffffff \ - && (fmt->Gmask == 0xff00 || fmt->Rmask == 0xff00 \ - || fmt->Bmask == 0xff00)) { \ - if (alpha == 128) { \ - blitter(4, Uint16, ALPHA_BLIT32_888_50); \ - } else { \ - blitter(4, Uint16, ALPHA_BLIT32_888); \ - } \ - } else { \ - blitter(4, Uint16, ALPHA_BLIT_ANY); \ - } \ - break; \ - } \ - } \ +#define CHOOSE_BLIT(blitter, alpha, fmt) \ + do { \ + if (alpha == 255) { \ + switch (fmt->BytesPerPixel) { \ + case 1: \ + blitter(1, Uint8, OPAQUE_BLIT); \ + break; \ + case 2: \ + blitter(2, Uint8, OPAQUE_BLIT); \ + break; \ + case 3: \ + blitter(3, Uint8, OPAQUE_BLIT); \ + break; \ + case 4: \ + blitter(4, Uint16, OPAQUE_BLIT); \ + break; \ + } \ + } else { \ + switch (fmt->BytesPerPixel) { \ + case 1: \ + /* No 8bpp alpha blitting */ \ + break; \ + \ + case 2: \ + switch (fmt->Rmask | fmt->Gmask | fmt->Bmask) { \ + case 0xffff: \ + if (fmt->Gmask == 0x07e0 || fmt->Rmask == 0x07e0 || fmt->Bmask == 0x07e0) { \ + if (alpha == 128) { \ + blitter(2, Uint8, ALPHA_BLIT16_565_50); \ + } else { \ + blitter(2, Uint8, ALPHA_BLIT16_565); \ + } \ + } else { \ + goto general16; \ + } \ + break; \ + \ + case 0x7fff: \ + if (fmt->Gmask == 0x03e0 || fmt->Rmask == 0x03e0 || fmt->Bmask == 0x03e0) { \ + if (alpha == 128) { \ + blitter(2, Uint8, ALPHA_BLIT16_555_50); \ + } else { \ + blitter(2, Uint8, ALPHA_BLIT16_555); \ + } \ + break; \ + } else { \ + goto general16; \ + } \ + break; \ + \ + default: \ + general16: \ + blitter(2, Uint8, ALPHA_BLIT_ANY); \ + } \ + break; \ + \ + case 3: \ + blitter(3, Uint8, ALPHA_BLIT_ANY); \ + break; \ + \ + case 4: \ + if ((fmt->Rmask | fmt->Gmask | fmt->Bmask) == 0x00ffffff && (fmt->Gmask == 0xff00 || fmt->Rmask == 0xff00 || fmt->Bmask == 0xff00)) { \ + if (alpha == 128) { \ + blitter(4, Uint16, ALPHA_BLIT32_888_50); \ + } else { \ + blitter(4, Uint16, ALPHA_BLIT32_888); \ + } \ + } else { \ + blitter(4, Uint16, ALPHA_BLIT_ANY); \ + } \ + break; \ + } \ + } \ } while (0) /* * Set a pixel value using the given format, except that the alpha value is * placed in the top byte. This is the format used for RLE with alpha. */ -#define RLEPIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \ -{ \ - Pixel = ((r>>fmt->Rloss)<Rshift)| \ - ((g>>fmt->Gloss)<Gshift)| \ - ((b>>fmt->Bloss)<Bshift)| \ - (a<<24); \ -} +#define RLEPIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \ + { \ + Pixel = ((r >> fmt->Rloss) << fmt->Rshift) | \ + ((g >> fmt->Gloss) << fmt->Gshift) | \ + ((b >> fmt->Bloss) << fmt->Bshift) | \ + (a << 24); \ + } /* * This takes care of the case when the surface is clipped on the left and/or * right. Top clipping has already been taken care of. */ -#define RLECLIPBLIT(bpp, Type, do_blit) \ - do { \ - int linecount = srcrect->h; \ - int ofs = 0; \ - int left = srcrect->x; \ - int right = left + srcrect->w; \ - dstbuf -= left * bpp; \ - for (;;) { \ - int run; \ - ofs += *(Type *)srcbuf; \ - run = ((Type *)srcbuf)[1]; \ - srcbuf += 2 * sizeof(Type); \ - if (run) { \ - /* clip to left and right borders */ \ - if (ofs < right) { \ - int start = 0; \ - int len = run; \ - int startcol; \ - if (left - ofs > 0) { \ - start = left - ofs; \ - len -= start; \ - if (len <= 0) \ - goto nocopy ## bpp ## do_blit; \ - } \ - startcol = ofs + start; \ - if (len > right - startcol) \ - len = right - startcol; \ +#define RLECLIPBLIT(bpp, Type, do_blit) \ + do { \ + int linecount = srcrect->h; \ + int ofs = 0; \ + int left = srcrect->x; \ + int right = left + srcrect->w; \ + dstbuf -= left * bpp; \ + for (;;) { \ + int run; \ + ofs += *(Type *)srcbuf; \ + run = ((Type *)srcbuf)[1]; \ + srcbuf += 2 * sizeof(Type); \ + if (run) { \ + /* clip to left and right borders */ \ + if (ofs < right) { \ + int start = 0; \ + int len = run; \ + int startcol; \ + if (left - ofs > 0) { \ + start = left - ofs; \ + len -= start; \ + if (len <= 0) \ + goto nocopy##bpp##do_blit; \ + } \ + startcol = ofs + start; \ + if (len > right - startcol) \ + len = right - startcol; \ do_blit(dstbuf + startcol * bpp, srcbuf + start * bpp, \ - len, bpp, alpha); \ - } \ - nocopy ## bpp ## do_blit: \ - srcbuf += run * bpp; \ - ofs += run; \ - } else if (!ofs) { \ - break; \ - } \ - \ - if (ofs == w) { \ - ofs = 0; \ - dstbuf += surf_dst->pitch; \ - if (!--linecount) { \ - break; \ - } \ - } \ - } \ + len, bpp, alpha); \ + } \ + nocopy##bpp##do_blit : srcbuf += run * bpp; \ + ofs += run; \ + } else if (!ofs) { \ + break; \ + } \ + \ + if (ofs == w) { \ + ofs = 0; \ + dstbuf += surf_dst->pitch; \ + if (!--linecount) { \ + break; \ + } \ + } \ + } \ } while (0) - -static void -RLEClipBlit(int w, Uint8 * srcbuf, SDL_Surface * surf_dst, - Uint8 * dstbuf, SDL_Rect * srcrect, unsigned alpha) +static void RLEClipBlit(int w, Uint8 *srcbuf, SDL_Surface *surf_dst, + Uint8 *dstbuf, SDL_Rect *srcrect, unsigned alpha) { SDL_PixelFormat *fmt = surf_dst->format; @@ -447,9 +443,8 @@ RLEClipBlit(int w, Uint8 * srcbuf, SDL_Surface * surf_dst, #undef RLECLIPBLIT /* blit a colorkeyed RLE surface */ -static int SDLCALL -SDL_RLEBlit(SDL_Surface * surf_src, SDL_Rect * srcrect, - SDL_Surface * surf_dst, SDL_Rect * dstrect) +static int SDLCALL SDL_RLEBlit(SDL_Surface *surf_src, SDL_Rect *srcrect, + SDL_Surface *surf_dst, SDL_Rect *dstrect) { Uint8 *dstbuf; Uint8 *srcbuf; @@ -467,9 +462,8 @@ SDL_RLEBlit(SDL_Surface * surf_src, SDL_Rect * srcrect, /* Set up the source and destination pointers */ x = dstrect->x; y = dstrect->y; - dstbuf = (Uint8 *) surf_dst->pixels - + y * surf_dst->pitch + x * surf_src->format->BytesPerPixel; - srcbuf = (Uint8 *) surf_src->map->data; + dstbuf = (Uint8 *)surf_dst->pixels + y * surf_dst->pitch + x * surf_src->format->BytesPerPixel; + srcbuf = (Uint8 *)surf_src->map->data; { /* skip lines at the top if necessary */ @@ -478,22 +472,22 @@ SDL_RLEBlit(SDL_Surface * surf_src, SDL_Rect * srcrect, if (vskip) { #define RLESKIP(bpp, Type) \ - for (;;) { \ - int run; \ - ofs += *(Type *)srcbuf; \ - run = ((Type *)srcbuf)[1]; \ - srcbuf += sizeof(Type) * 2; \ - if (run) { \ + for (;;) { \ + int run; \ + ofs += *(Type *)srcbuf; \ + run = ((Type *)srcbuf)[1]; \ + srcbuf += sizeof(Type) * 2; \ + if (run) { \ srcbuf += run * bpp; \ - ofs += run; \ - } else if (!ofs) \ - goto done; \ - if (ofs == w) { \ - ofs = 0; \ - if (!--vskip) \ - break; \ - } \ - } + ofs += run; \ + } else if (!ofs) \ + goto done; \ + if (ofs == w) { \ + ofs = 0; \ + if (!--vskip) \ + break; \ + } \ + } switch (surf_src->format->BytesPerPixel) { case 1: @@ -511,7 +505,6 @@ SDL_RLEBlit(SDL_Surface * surf_src, SDL_Rect * srcrect, } #undef RLESKIP - } } @@ -522,36 +515,36 @@ SDL_RLEBlit(SDL_Surface * surf_src, SDL_Rect * srcrect, } else { SDL_PixelFormat *fmt = surf_src->format; -#define RLEBLIT(bpp, Type, do_blit) \ - do { \ - int linecount = srcrect->h; \ - int ofs = 0; \ - for (;;) { \ - unsigned run; \ - ofs += *(Type *)srcbuf; \ - run = ((Type *)srcbuf)[1]; \ - srcbuf += 2 * sizeof(Type); \ - if (run) { \ - do_blit(dstbuf + ofs * bpp, srcbuf, run, bpp, alpha); \ - srcbuf += run * bpp; \ - ofs += run; \ - } else if (!ofs) \ - break; \ - if (ofs == w) { \ - ofs = 0; \ - dstbuf += surf_dst->pitch; \ - if (!--linecount) \ - break; \ - } \ - } \ - } while (0) +#define RLEBLIT(bpp, Type, do_blit) \ + do { \ + int linecount = srcrect->h; \ + int ofs = 0; \ + for (;;) { \ + unsigned run; \ + ofs += *(Type *)srcbuf; \ + run = ((Type *)srcbuf)[1]; \ + srcbuf += 2 * sizeof(Type); \ + if (run) { \ + do_blit(dstbuf + ofs * bpp, srcbuf, run, bpp, alpha); \ + srcbuf += run * bpp; \ + ofs += run; \ + } else if (!ofs) \ + break; \ + if (ofs == w) { \ + ofs = 0; \ + dstbuf += surf_dst->pitch; \ + if (!--linecount) \ + break; \ + } \ + } \ + } while (0) CHOOSE_BLIT(RLEBLIT, alpha, fmt); #undef RLEBLIT } - done: +done: /* Unlock the destination if necessary */ if (SDL_MUSTLOCK(surf_dst)) { SDL_UnlockSurface(surf_dst); @@ -570,46 +563,46 @@ SDL_RLEBlit(SDL_Surface * surf_src, SDL_Rect * srcrect, * For 32bpp pixels, we have made sure the alpha is stored in the top * 8 bits, so proceed as usual */ -#define BLIT_TRANSL_888(src, dst) \ - do { \ - Uint32 s = src; \ - Uint32 d = dst; \ - unsigned alpha = s >> 24; \ - Uint32 s1 = s & 0xff00ff; \ - Uint32 d1 = d & 0xff00ff; \ - d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; \ - s &= 0xff00; \ - d &= 0xff00; \ - d = (d + ((s - d) * alpha >> 8)) & 0xff00; \ - dst = d1 | d | 0xff000000; \ +#define BLIT_TRANSL_888(src, dst) \ + do { \ + Uint32 s = src; \ + Uint32 d = dst; \ + unsigned alpha = s >> 24; \ + Uint32 s1 = s & 0xff00ff; \ + Uint32 d1 = d & 0xff00ff; \ + d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; \ + s &= 0xff00; \ + d &= 0xff00; \ + d = (d + ((s - d) * alpha >> 8)) & 0xff00; \ + dst = d1 | d | 0xff000000; \ } while (0) /* * For 16bpp pixels, we have stored the 5 most significant alpha bits in * bits 5-10. As before, we can process all 3 RGB components at the same time. */ -#define BLIT_TRANSL_565(src, dst) \ - do { \ - Uint32 s = src; \ - Uint32 d = dst; \ - unsigned alpha = (s & 0x3e0) >> 5; \ - s &= 0x07e0f81f; \ - d = (d | d << 16) & 0x07e0f81f; \ - d += (s - d) * alpha >> 5; \ - d &= 0x07e0f81f; \ - dst = (Uint16)(d | d >> 16); \ +#define BLIT_TRANSL_565(src, dst) \ + do { \ + Uint32 s = src; \ + Uint32 d = dst; \ + unsigned alpha = (s & 0x3e0) >> 5; \ + s &= 0x07e0f81f; \ + d = (d | d << 16) & 0x07e0f81f; \ + d += (s - d) * alpha >> 5; \ + d &= 0x07e0f81f; \ + dst = (Uint16)(d | d >> 16); \ } while (0) -#define BLIT_TRANSL_555(src, dst) \ - do { \ - Uint32 s = src; \ - Uint32 d = dst; \ - unsigned alpha = (s & 0x3e0) >> 5; \ - s &= 0x03e07c1f; \ - d = (d | d << 16) & 0x03e07c1f; \ - d += (s - d) * alpha >> 5; \ - d &= 0x03e07c1f; \ - dst = (Uint16)(d | d >> 16); \ +#define BLIT_TRANSL_555(src, dst) \ + do { \ + Uint32 s = src; \ + Uint32 d = dst; \ + unsigned alpha = (s & 0x3e0) >> 5; \ + s &= 0x03e07c1f; \ + d = (d | d << 16) & 0x03e07c1f; \ + d += (s - d) * alpha >> 5; \ + d &= 0x03e07c1f; \ + dst = (Uint16)(d | d >> 16); \ } while (0) /* used to save the destination format in the encoding. Designed to be @@ -633,9 +626,8 @@ typedef struct } RLEDestFormat; /* blit a pixel-alpha RLE surface clipped at the right and/or left edges */ -static void -RLEAlphaClipBlit(int w, Uint8 * srcbuf, SDL_Surface * surf_dst, - Uint8 * dstbuf, SDL_Rect * srcrect) +static void RLEAlphaClipBlit(int w, Uint8 *srcbuf, SDL_Surface *surf_dst, + Uint8 *dstbuf, SDL_Rect *srcrect) { SDL_PixelFormat *df = surf_dst->format; /* @@ -643,72 +635,72 @@ RLEAlphaClipBlit(int w, Uint8 * srcbuf, SDL_Surface * surf_dst, * Ctype the translucent count type, and do_blend the macro * to blend one pixel. */ -#define RLEALPHACLIPBLIT(Ptype, Ctype, do_blend) \ - do { \ - int linecount = srcrect->h; \ - int left = srcrect->x; \ - int right = left + srcrect->w; \ - dstbuf -= left * sizeof(Ptype); \ - do { \ - int ofs = 0; \ - /* blit opaque pixels on one line */ \ - do { \ - unsigned run; \ - ofs += ((Ctype *)srcbuf)[0]; \ - run = ((Ctype *)srcbuf)[1]; \ - srcbuf += 2 * sizeof(Ctype); \ - if (run) { \ - /* clip to left and right borders */ \ - int cofs = ofs; \ - int crun = run; \ - if (left - cofs > 0) { \ - crun -= left - cofs; \ - cofs = left; \ - } \ - if (crun > right - cofs) \ - crun = right - cofs; \ - if (crun > 0) \ - PIXEL_COPY(dstbuf + cofs * sizeof(Ptype), \ - srcbuf + (cofs - ofs) * sizeof(Ptype), \ - (unsigned)crun, sizeof(Ptype)); \ - srcbuf += run * sizeof(Ptype); \ - ofs += run; \ - } else if (!ofs) \ - return; \ - } while (ofs < w); \ - /* skip padding if necessary */ \ - if (sizeof(Ptype) == 2) \ - srcbuf += (uintptr_t)srcbuf & 2; \ - /* blit translucent pixels on the same line */ \ - ofs = 0; \ - do { \ - unsigned run; \ - ofs += ((Uint16 *)srcbuf)[0]; \ - run = ((Uint16 *)srcbuf)[1]; \ - srcbuf += 4; \ - if (run) { \ - /* clip to left and right borders */ \ - int cofs = ofs; \ - int crun = run; \ - if (left - cofs > 0) { \ - crun -= left - cofs; \ - cofs = left; \ - } \ - if (crun > right - cofs) \ - crun = right - cofs; \ - if (crun > 0) { \ - Ptype *dst = (Ptype *)dstbuf + cofs; \ - Uint32 *src = (Uint32 *)srcbuf + (cofs - ofs); \ - int i; \ - for (i = 0; i < crun; i++) \ - do_blend(src[i], dst[i]); \ - } \ - srcbuf += run * 4; \ - ofs += run; \ - } \ - } while (ofs < w); \ - dstbuf += surf_dst->pitch; \ - } while (--linecount); \ +#define RLEALPHACLIPBLIT(Ptype, Ctype, do_blend) \ + do { \ + int linecount = srcrect->h; \ + int left = srcrect->x; \ + int right = left + srcrect->w; \ + dstbuf -= left * sizeof(Ptype); \ + do { \ + int ofs = 0; \ + /* blit opaque pixels on one line */ \ + do { \ + unsigned run; \ + ofs += ((Ctype *)srcbuf)[0]; \ + run = ((Ctype *)srcbuf)[1]; \ + srcbuf += 2 * sizeof(Ctype); \ + if (run) { \ + /* clip to left and right borders */ \ + int cofs = ofs; \ + int crun = run; \ + if (left - cofs > 0) { \ + crun -= left - cofs; \ + cofs = left; \ + } \ + if (crun > right - cofs) \ + crun = right - cofs; \ + if (crun > 0) \ + PIXEL_COPY(dstbuf + cofs * sizeof(Ptype), \ + srcbuf + (cofs - ofs) * sizeof(Ptype), \ + (unsigned)crun, sizeof(Ptype)); \ + srcbuf += run * sizeof(Ptype); \ + ofs += run; \ + } else if (!ofs) \ + return; \ + } while (ofs < w); \ + /* skip padding if necessary */ \ + if (sizeof(Ptype) == 2) \ + srcbuf += (uintptr_t)srcbuf & 2; \ + /* blit translucent pixels on the same line */ \ + ofs = 0; \ + do { \ + unsigned run; \ + ofs += ((Uint16 *)srcbuf)[0]; \ + run = ((Uint16 *)srcbuf)[1]; \ + srcbuf += 4; \ + if (run) { \ + /* clip to left and right borders */ \ + int cofs = ofs; \ + int crun = run; \ + if (left - cofs > 0) { \ + crun -= left - cofs; \ + cofs = left; \ + } \ + if (crun > right - cofs) \ + crun = right - cofs; \ + if (crun > 0) { \ + Ptype *dst = (Ptype *)dstbuf + cofs; \ + Uint32 *src = (Uint32 *)srcbuf + (cofs - ofs); \ + int i; \ + for (i = 0; i < crun; i++) \ + do_blend(src[i], dst[i]); \ + } \ + srcbuf += run * 4; \ + ofs += run; \ + } \ + } while (ofs < w); \ + dstbuf += surf_dst->pitch; \ + } while (--linecount); \ } while (0) switch (df->BytesPerPixel) { @@ -725,9 +717,8 @@ RLEAlphaClipBlit(int w, Uint8 * srcbuf, SDL_Surface * surf_dst, } /* blit a pixel-alpha RLE surface */ -static int SDLCALL -SDL_RLEAlphaBlit(SDL_Surface * surf_src, SDL_Rect * srcrect, - SDL_Surface * surf_dst, SDL_Rect * dstrect) +static int SDLCALL SDL_RLEAlphaBlit(SDL_Surface *surf_src, SDL_Rect *srcrect, + SDL_Surface *surf_dst, SDL_Rect *dstrect) { int x, y; int w = surf_src->w; @@ -743,8 +734,8 @@ SDL_RLEAlphaBlit(SDL_Surface * surf_src, SDL_Rect * srcrect, x = dstrect->x; y = dstrect->y; - dstbuf = (Uint8 *) surf_dst->pixels + y * surf_dst->pitch + x * df->BytesPerPixel; - srcbuf = (Uint8 *) surf_src->map->data + sizeof(RLEDestFormat); + dstbuf = (Uint8 *)surf_dst->pixels + y * surf_dst->pitch + x * df->BytesPerPixel; + srcbuf = (Uint8 *)surf_src->map->data + sizeof(RLEDestFormat); { /* skip lines at the top if necessary */ @@ -769,27 +760,27 @@ SDL_RLEAlphaBlit(SDL_Surface * surf_src, SDL_Rect * srcrect, } while (ofs < w); /* skip padding */ - srcbuf += (uintptr_t) srcbuf & 2; + srcbuf += (uintptr_t)srcbuf & 2; /* skip translucent line */ ofs = 0; do { int run; - ofs += ((Uint16 *) srcbuf)[0]; - run = ((Uint16 *) srcbuf)[1]; + ofs += ((Uint16 *)srcbuf)[0]; + run = ((Uint16 *)srcbuf)[1]; srcbuf += 4 * (run + 1); ofs += run; } while (ofs < w); } while (--vskip); } else { /* the 32/32 interleaved format */ - vskip <<= 1; /* opaque and translucent have same format */ + vskip <<= 1; /* opaque and translucent have same format */ do { ofs = 0; do { int run; - ofs += ((Uint16 *) srcbuf)[0]; - run = ((Uint16 *) srcbuf)[1]; + ofs += ((Uint16 *)srcbuf)[0]; + run = ((Uint16 *)srcbuf)[1]; srcbuf += 4; if (run) { srcbuf += 4 * run; @@ -812,55 +803,54 @@ SDL_RLEAlphaBlit(SDL_Surface * surf_src, SDL_Rect * srcrect, * Ctype the translucent count type, and do_blend the * macro to blend one pixel. */ -#define RLEALPHABLIT(Ptype, Ctype, do_blend) \ - do { \ - int linecount = srcrect->h; \ - do { \ - int ofs = 0; \ - /* blit opaque pixels on one line */ \ - do { \ - unsigned run; \ - ofs += ((Ctype *)srcbuf)[0]; \ - run = ((Ctype *)srcbuf)[1]; \ - srcbuf += 2 * sizeof(Ctype); \ - if (run) { \ - PIXEL_COPY(dstbuf + ofs * sizeof(Ptype), srcbuf, \ - run, sizeof(Ptype)); \ - srcbuf += run * sizeof(Ptype); \ - ofs += run; \ - } else if (!ofs) \ - goto done; \ - } while (ofs < w); \ - /* skip padding if necessary */ \ - if (sizeof(Ptype) == 2) \ - srcbuf += (uintptr_t)srcbuf & 2; \ - /* blit translucent pixels on the same line */ \ - ofs = 0; \ - do { \ - unsigned run; \ - ofs += ((Uint16 *)srcbuf)[0]; \ - run = ((Uint16 *)srcbuf)[1]; \ - srcbuf += 4; \ - if (run) { \ - Ptype *dst = (Ptype *)dstbuf + ofs; \ - unsigned i; \ - for (i = 0; i < run; i++) { \ - Uint32 src = *(Uint32 *)srcbuf; \ - do_blend(src, *dst); \ - srcbuf += 4; \ - dst++; \ - } \ - ofs += run; \ - } \ - } while (ofs < w); \ - dstbuf += surf_dst->pitch; \ - } while (--linecount); \ +#define RLEALPHABLIT(Ptype, Ctype, do_blend) \ + do { \ + int linecount = srcrect->h; \ + do { \ + int ofs = 0; \ + /* blit opaque pixels on one line */ \ + do { \ + unsigned run; \ + ofs += ((Ctype *)srcbuf)[0]; \ + run = ((Ctype *)srcbuf)[1]; \ + srcbuf += 2 * sizeof(Ctype); \ + if (run) { \ + PIXEL_COPY(dstbuf + ofs * sizeof(Ptype), srcbuf, \ + run, sizeof(Ptype)); \ + srcbuf += run * sizeof(Ptype); \ + ofs += run; \ + } else if (!ofs) \ + goto done; \ + } while (ofs < w); \ + /* skip padding if necessary */ \ + if (sizeof(Ptype) == 2) \ + srcbuf += (uintptr_t)srcbuf & 2; \ + /* blit translucent pixels on the same line */ \ + ofs = 0; \ + do { \ + unsigned run; \ + ofs += ((Uint16 *)srcbuf)[0]; \ + run = ((Uint16 *)srcbuf)[1]; \ + srcbuf += 4; \ + if (run) { \ + Ptype *dst = (Ptype *)dstbuf + ofs; \ + unsigned i; \ + for (i = 0; i < run; i++) { \ + Uint32 src = *(Uint32 *)srcbuf; \ + do_blend(src, *dst); \ + srcbuf += 4; \ + dst++; \ + } \ + ofs += run; \ + } \ + } while (ofs < w); \ + dstbuf += surf_dst->pitch; \ + } while (--linecount); \ } while (0) switch (df->BytesPerPixel) { case 2: - if (df->Gmask == 0x07e0 || df->Rmask == 0x07e0 - || df->Bmask == 0x07e0) + if (df->Gmask == 0x07e0 || df->Rmask == 0x07e0 || df->Bmask == 0x07e0) RLEALPHABLIT(Uint16, Uint8, BLIT_TRANSL_565); else RLEALPHABLIT(Uint16, Uint8, BLIT_TRANSL_555); @@ -871,7 +861,7 @@ SDL_RLEAlphaBlit(SDL_Surface * surf_src, SDL_Rect * srcrect, } } - done: +done: /* Unlock the destination if necessary */ if (SDL_MUSTLOCK(surf_dst)) { SDL_UnlockSurface(surf_dst); @@ -890,9 +880,8 @@ SDL_RLEAlphaBlit(SDL_Surface * surf_src, SDL_Rect * srcrect, */ /* encode 32bpp rgb + a into 16bpp rgb, losing alpha */ -static int -copy_opaque_16(void *dst, Uint32 * src, int n, - SDL_PixelFormat * sfmt, SDL_PixelFormat * dfmt) +static int copy_opaque_16(void *dst, Uint32 *src, int n, + SDL_PixelFormat *sfmt, SDL_PixelFormat *dfmt) { int i; Uint16 *d = dst; @@ -907,9 +896,8 @@ copy_opaque_16(void *dst, Uint32 * src, int n, } /* decode opaque pixels from 16bpp to 32bpp rgb + a */ -static int -uncopy_opaque_16(Uint32 * dst, void *src, int n, - RLEDestFormat * sfmt, SDL_PixelFormat * dfmt) +static int uncopy_opaque_16(Uint32 *dst, void *src, int n, + RLEDestFormat *sfmt, SDL_PixelFormat *dfmt) { int i; Uint16 *s = src; @@ -924,12 +912,9 @@ uncopy_opaque_16(Uint32 * dst, void *src, int n, return n * 2; } - - /* encode 32bpp rgb + a into 32bpp G0RAB format for blitting into 565 */ -static int -copy_transl_565(void *dst, Uint32 * src, int n, - SDL_PixelFormat * sfmt, SDL_PixelFormat * dfmt) +static int copy_transl_565(void *dst, Uint32 *src, int n, + SDL_PixelFormat *sfmt, SDL_PixelFormat *dfmt) { int i; Uint32 *d = dst; @@ -946,9 +931,8 @@ copy_transl_565(void *dst, Uint32 * src, int n, } /* encode 32bpp rgb + a into 32bpp G0RAB format for blitting into 555 */ -static int -copy_transl_555(void *dst, Uint32 * src, int n, - SDL_PixelFormat * sfmt, SDL_PixelFormat * dfmt) +static int copy_transl_555(void *dst, Uint32 *src, int n, + SDL_PixelFormat *sfmt, SDL_PixelFormat *dfmt) { int i; Uint32 *d = dst; @@ -965,9 +949,8 @@ copy_transl_555(void *dst, Uint32 * src, int n, } /* decode translucent pixels from 32bpp GORAB to 32bpp rgb + a */ -static int -uncopy_transl_16(Uint32 * dst, void *src, int n, - RLEDestFormat * sfmt, SDL_PixelFormat * dfmt) +static int uncopy_transl_16(Uint32 *dst, void *src, int n, + RLEDestFormat *sfmt, SDL_PixelFormat *dfmt) { int i; Uint32 *s = src; @@ -984,9 +967,8 @@ uncopy_transl_16(Uint32 * dst, void *src, int n, } /* encode 32bpp rgba into 32bpp rgba, keeping alpha (dual purpose) */ -static int -copy_32(void *dst, Uint32 * src, int n, - SDL_PixelFormat * sfmt, SDL_PixelFormat * dfmt) +static int copy_32(void *dst, Uint32 *src, int n, + SDL_PixelFormat *sfmt, SDL_PixelFormat *dfmt) { int i; Uint32 *d = dst; @@ -1001,9 +983,8 @@ copy_32(void *dst, Uint32 * src, int n, } /* decode 32bpp rgba into 32bpp rgba, keeping alpha (dual purpose) */ -static int -uncopy_32(Uint32 * dst, void *src, int n, - RLEDestFormat * sfmt, SDL_PixelFormat * dfmt) +static int uncopy_32(Uint32 *dst, void *src, int n, + RLEDestFormat *sfmt, SDL_PixelFormat *dfmt) { int i; Uint32 *s = src; @@ -1018,14 +999,13 @@ uncopy_32(Uint32 * dst, void *src, int n, return n * 4; } -#define ISOPAQUE(pixel, fmt) ((((pixel) & fmt->Amask) >> fmt->Ashift) == 255) +#define ISOPAQUE(pixel, fmt) ((((pixel)&fmt->Amask) >> fmt->Ashift) == 255) -#define ISTRANSL(pixel, fmt) \ - ((unsigned)((((pixel) & fmt->Amask) >> fmt->Ashift) - 1U) < 254U) +#define ISTRANSL(pixel, fmt) \ + ((unsigned)((((pixel)&fmt->Amask) >> fmt->Ashift) - 1U) < 254U) /* convert surface to be quickly alpha-blittable onto dest, if possible */ -static int -RLEAlphaSurface(SDL_Surface * surface) +static int RLEAlphaSurface(SDL_Surface *surface) { SDL_Surface *dest; SDL_PixelFormat *df; @@ -1034,10 +1014,10 @@ RLEAlphaSurface(SDL_Surface * surface) int max_transl_run = 65535; unsigned masksum; Uint8 *rlebuf, *dst; - int (*copy_opaque) (void *, Uint32 *, int, - SDL_PixelFormat *, SDL_PixelFormat *); - int (*copy_transl) (void *, Uint32 *, int, - SDL_PixelFormat *, SDL_PixelFormat *); + int (*copy_opaque)(void *, Uint32 *, int, + SDL_PixelFormat *, SDL_PixelFormat *); + int (*copy_transl)(void *, Uint32 *, int, + SDL_PixelFormat *, SDL_PixelFormat *); dest = surface->map->dst; if (dest == NULL) { @@ -1056,16 +1036,14 @@ RLEAlphaSurface(SDL_Surface * surface) /* 16bpp: only support 565 and 555 formats */ switch (masksum) { case 0xffff: - if (df->Gmask == 0x07e0 - || df->Rmask == 0x07e0 || df->Bmask == 0x07e0) { + if (df->Gmask == 0x07e0 || df->Rmask == 0x07e0 || df->Bmask == 0x07e0) { copy_opaque = copy_opaque_16; copy_transl = copy_transl_565; } else return -1; break; case 0x7fff: - if (df->Gmask == 0x03e0 - || df->Rmask == 0x03e0 || df->Bmask == 0x03e0) { + if (df->Gmask == 0x03e0 || df->Rmask == 0x03e0 || df->Bmask == 0x03e0) { copy_opaque = copy_opaque_16; copy_transl = copy_transl_555; } else @@ -1074,7 +1052,7 @@ RLEAlphaSurface(SDL_Surface * surface) default: return -1; } - max_opaque_run = 255; /* runs stored as bytes */ + max_opaque_run = 255; /* runs stored as bytes */ /* worst case is alternating opaque and translucent pixels, with room for alignment padding between lines */ @@ -1082,26 +1060,26 @@ RLEAlphaSurface(SDL_Surface * surface) break; case 4: if (masksum != 0x00ffffff) - return -1; /* requires unused high byte */ + return -1; /* requires unused high byte */ copy_opaque = copy_32; copy_transl = copy_32; - max_opaque_run = 255; /* runs stored as short ints */ + max_opaque_run = 255; /* runs stored as short ints */ /* worst case is alternating opaque and translucent pixels */ maxsize = surface->h * 2 * 4 * (surface->w + 1) + 4; break; default: - return -1; /* anything else unsupported right now */ + return -1; /* anything else unsupported right now */ } maxsize += sizeof(RLEDestFormat); - rlebuf = (Uint8 *) SDL_malloc(maxsize); + rlebuf = (Uint8 *)SDL_malloc(maxsize); if (rlebuf == NULL) { return SDL_OutOfMemory(); } { /* save the destination format so we can undo the encoding later */ - RLEDestFormat *r = (RLEDestFormat *) rlebuf; + RLEDestFormat *r = (RLEDestFormat *)rlebuf; r->BytesPerPixel = df->BytesPerPixel; r->Rmask = df->Rmask; r->Gmask = df->Gmask; @@ -1123,23 +1101,23 @@ RLEAlphaSurface(SDL_Surface * surface) int x, y; int h = surface->h, w = surface->w; SDL_PixelFormat *sf = surface->format; - Uint32 *src = (Uint32 *) surface->pixels; - Uint8 *lastline = dst; /* end of last non-blank line */ + Uint32 *src = (Uint32 *)surface->pixels; + Uint8 *lastline = dst; /* end of last non-blank line */ /* opaque counts are 8 or 16 bits, depending on target depth */ -#define ADD_OPAQUE_COUNTS(n, m) \ - if (df->BytesPerPixel == 4) { \ - ((Uint16 *)dst)[0] = n; \ - ((Uint16 *)dst)[1] = m; \ - dst += 4; \ - } else { \ - dst[0] = n; \ - dst[1] = m; \ - dst += 2; \ +#define ADD_OPAQUE_COUNTS(n, m) \ + if (df->BytesPerPixel == 4) { \ + ((Uint16 *)dst)[0] = n; \ + ((Uint16 *)dst)[1] = m; \ + dst += 4; \ + } else { \ + dst[0] = n; \ + dst[1] = m; \ + dst += 2; \ } /* translucent counts are always 16 bit */ -#define ADD_TRANSL_COUNTS(n, m) \ +#define ADD_TRANSL_COUNTS(n, m) \ (((Uint16 *)dst)[0] = n, ((Uint16 *)dst)[1] = m, dst += 4) for (y = 0; y < h; y++) { @@ -1179,7 +1157,7 @@ RLEAlphaSurface(SDL_Surface * surface) } while (x < w); /* Make sure the next output address is 32-bit aligned */ - dst += (uintptr_t) dst & 2; + dst += (uintptr_t)dst & 2; /* Next, encode all translucent pixels of the same scan line */ x = 0; @@ -1217,7 +1195,7 @@ RLEAlphaSurface(SDL_Surface * surface) src += surface->pitch >> 2; } - dst = lastline; /* back up past trailing blank lines */ + dst = lastline; /* back up past trailing blank lines */ ADD_OPAQUE_COUNTS(0, 0); } @@ -1247,20 +1225,17 @@ RLEAlphaSurface(SDL_Surface * surface) return 0; } -static Uint32 -getpix_8(const Uint8 * srcbuf) +static Uint32 getpix_8(const Uint8 *srcbuf) { return *srcbuf; } -static Uint32 -getpix_16(const Uint8 * srcbuf) +static Uint32 getpix_16(const Uint8 *srcbuf) { return *(const Uint16 *)srcbuf; } -static Uint32 -getpix_24(const Uint8 * srcbuf) +static Uint32 getpix_24(const Uint8 *srcbuf) { #if SDL_BYTEORDER == SDL_LIL_ENDIAN return srcbuf[0] + (srcbuf[1] << 8) + (srcbuf[2] << 16); @@ -1269,20 +1244,18 @@ getpix_24(const Uint8 * srcbuf) #endif } -static Uint32 -getpix_32(const Uint8 * srcbuf) +static Uint32 getpix_32(const Uint8 *srcbuf) { return *(const Uint32 *)srcbuf; } -typedef Uint32(*getpix_func) (const Uint8 *); +typedef Uint32 (*getpix_func)(const Uint8 *); static const getpix_func getpixes[4] = { getpix_8, getpix_16, getpix_24, getpix_32 }; -static int -RLEColorkeySurface(SDL_Surface * surface) +static int RLEColorkeySurface(SDL_Surface *surface) { Uint8 *rlebuf, *dst; int maxn; @@ -1304,26 +1277,24 @@ RLEColorkeySurface(SDL_Surface * surface) case 2: case 3: /* worst case is solid runs, at most 255 pixels wide */ - maxsize = surface->h * (2 * (surface->w / 255 + 1) - + surface->w * bpp) + 2; + maxsize = surface->h * (2 * (surface->w / 255 + 1) + surface->w * bpp) + 2; break; case 4: /* worst case is solid runs, at most 65535 pixels wide */ - maxsize = surface->h * (4 * (surface->w / 65535 + 1) - + surface->w * 4) + 4; + maxsize = surface->h * (4 * (surface->w / 65535 + 1) + surface->w * 4) + 4; break; default: return -1; } - rlebuf = (Uint8 *) SDL_malloc(maxsize); + rlebuf = (Uint8 *)SDL_malloc(maxsize); if (rlebuf == NULL) { return SDL_OutOfMemory(); } /* Set up the conversion */ - srcbuf = (Uint8 *) surface->pixels; + srcbuf = (Uint8 *)surface->pixels; maxn = bpp == 4 ? 65535 : 255; dst = rlebuf; rgbmask = ~surface->format->Amask; @@ -1333,12 +1304,12 @@ RLEColorkeySurface(SDL_Surface * surface) w = surface->w; h = surface->h; -#define ADD_COUNTS(n, m) \ - if (bpp == 4) { \ - ((Uint16 *)dst)[0] = n; \ - ((Uint16 *)dst)[1] = m; \ +#define ADD_COUNTS(n, m) \ + if (bpp == 4) { \ + ((Uint16 *)dst)[0] = n; \ + ((Uint16 *)dst)[1] = m; \ dst += 4; \ - } else { \ + } else { \ dst[0] = n; \ dst[1] = m; \ dst += 2; \ @@ -1390,7 +1361,7 @@ RLEColorkeySurface(SDL_Surface * surface) srcbuf += surface->pitch; } - dst = lastline; /* back up bast trailing blank lines */ + dst = lastline; /* back up bast trailing blank lines */ ADD_COUNTS(0, 0); #undef ADD_COUNTS @@ -1419,8 +1390,7 @@ RLEColorkeySurface(SDL_Surface * surface) return 0; } -int -SDL_RLESurface(SDL_Surface * surface) +int SDL_RLESurface(SDL_Surface *surface) { int flags; @@ -1487,17 +1457,16 @@ SDL_RLESurface(SDL_Surface * surface) * completely transparent pixels will be lost, and color and alpha depth * may have been reduced (when encoding for 16bpp targets). */ -static SDL_bool -UnRLEAlpha(SDL_Surface * surface) +static SDL_bool UnRLEAlpha(SDL_Surface *surface) { Uint8 *srcbuf; Uint32 *dst; SDL_PixelFormat *sf = surface->format; RLEDestFormat *df = surface->map->data; - int (*uncopy_opaque) (Uint32 *, void *, int, - RLEDestFormat *, SDL_PixelFormat *); - int (*uncopy_transl) (Uint32 *, void *, int, - RLEDestFormat *, SDL_PixelFormat *); + int (*uncopy_opaque)(Uint32 *, void *, int, + RLEDestFormat *, SDL_PixelFormat *); + int (*uncopy_transl)(Uint32 *, void *, int, + RLEDestFormat *, SDL_PixelFormat *); int w = surface->w; int bpp = df->BytesPerPixel; @@ -1517,7 +1486,7 @@ UnRLEAlpha(SDL_Surface * surface) SDL_memset(surface->pixels, 0, surface->h * surface->pitch); dst = surface->pixels; - srcbuf = (Uint8 *) (df + 1); + srcbuf = (Uint8 *)(df + 1); for (;;) { /* copy opaque pixels */ int ofs = 0; @@ -1528,8 +1497,8 @@ UnRLEAlpha(SDL_Surface * surface) run = srcbuf[1]; srcbuf += 2; } else { - ofs += ((Uint16 *) srcbuf)[0]; - run = ((Uint16 *) srcbuf)[1]; + ofs += ((Uint16 *)srcbuf)[0]; + run = ((Uint16 *)srcbuf)[1]; srcbuf += 4; } if (run) { @@ -1549,8 +1518,8 @@ UnRLEAlpha(SDL_Surface * surface) ofs = 0; do { unsigned run; - ofs += ((Uint16 *) srcbuf)[0]; - run = ((Uint16 *) srcbuf)[1]; + ofs += ((Uint16 *)srcbuf)[0]; + run = ((Uint16 *)srcbuf)[1]; srcbuf += 4; if (run) { srcbuf += uncopy_transl(dst + ofs, srcbuf, run, df, sf); @@ -1564,8 +1533,7 @@ end_function: return SDL_TRUE; } -void -SDL_UnRLESurface(SDL_Surface * surface, int recode) +void SDL_UnRLESurface(SDL_Surface *surface, int recode) { if (surface->flags & SDL_RLEACCEL) { surface->flags &= ~SDL_RLEACCEL; diff --git a/src/video/SDL_RLEaccel_c.h b/src/video/SDL_RLEaccel_c.h index 6f0d95f91..7e7cf9931 100644 --- a/src/video/SDL_RLEaccel_c.h +++ b/src/video/SDL_RLEaccel_c.h @@ -26,8 +26,8 @@ /* Useful functions and variables from SDL_RLEaccel.c */ -extern int SDL_RLESurface(SDL_Surface * surface); -extern void SDL_UnRLESurface(SDL_Surface * surface, int recode); +extern int SDL_RLESurface(SDL_Surface *surface); +extern void SDL_UnRLESurface(SDL_Surface *surface, int recode); #endif /* SDL_RLEaccel_c_h_ */ diff --git a/src/video/SDL_blit.c b/src/video/SDL_blit.c index 70a66caef..fe0bd5ac2 100644 --- a/src/video/SDL_blit.c +++ b/src/video/SDL_blit.c @@ -30,9 +30,8 @@ #include "SDL_pixels_c.h" /* The general purpose software blit routine */ -static int SDLCALL -SDL_SoftBlit(SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +static int SDLCALL SDL_SoftBlit(SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect) { int okay; int src_locked; @@ -66,23 +65,23 @@ SDL_SoftBlit(SDL_Surface * src, SDL_Rect * srcrect, SDL_BlitInfo *info = &src->map->info; /* Set up the blit information */ - info->src = (Uint8 *) src->pixels + - (Uint16) srcrect->y * src->pitch + - (Uint16) srcrect->x * info->src_fmt->BytesPerPixel; + info->src = (Uint8 *)src->pixels + + (Uint16)srcrect->y * src->pitch + + (Uint16)srcrect->x * info->src_fmt->BytesPerPixel; info->src_w = srcrect->w; info->src_h = srcrect->h; info->src_pitch = src->pitch; info->src_skip = info->src_pitch - info->src_w * info->src_fmt->BytesPerPixel; info->dst = - (Uint8 *) dst->pixels + (Uint16) dstrect->y * dst->pitch + - (Uint16) dstrect->x * info->dst_fmt->BytesPerPixel; + (Uint8 *)dst->pixels + (Uint16)dstrect->y * dst->pitch + + (Uint16)dstrect->x * info->dst_fmt->BytesPerPixel; info->dst_w = dstrect->w; info->dst_h = dstrect->h; info->dst_pitch = dst->pitch; info->dst_skip = info->dst_pitch - info->dst_w * info->dst_fmt->BytesPerPixel; - RunBlit = (SDL_BlitFunc) src->map->data; + RunBlit = (SDL_BlitFunc)src->map->data; /* Run the actual software blit */ RunBlit(info); @@ -104,8 +103,7 @@ SDL_SoftBlit(SDL_Surface * src, SDL_Rect * srcrect, #ifdef __MACOSX__ #include -static SDL_bool -SDL_UseAltivecPrefetch() +static SDL_bool SDL_UseAltivecPrefetch() { const char key[] = "hw.l3cachesize"; u_int64_t result = 0; @@ -118,17 +116,15 @@ SDL_UseAltivecPrefetch() } } #else -static SDL_bool -SDL_UseAltivecPrefetch() +static SDL_bool SDL_UseAltivecPrefetch() { /* Just guess G4 */ return SDL_TRUE; } #endif /* __MACOSX__ */ -static SDL_BlitFunc -SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, - SDL_BlitFuncEntry * entries) +static SDL_BlitFunc SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, + SDL_BlitFuncEntry *entries) { int i, flagcheck = (flags & (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_COLORKEY | SDL_COPY_NEAREST)); static int features = 0x7fffffff; @@ -192,8 +188,7 @@ SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, #endif /* SDL_HAVE_BLIT_AUTO */ /* Figure out which of many blit routines to set up on a surface */ -int -SDL_CalculateBlit(SDL_Surface * surface) +int SDL_CalculateBlit(SDL_Surface *surface) { SDL_BlitFunc blit = NULL; SDL_BlitMap *map = surface->map; @@ -235,13 +230,13 @@ SDL_CalculateBlit(SDL_Surface * surface) } #if SDL_HAVE_BLIT_0 else if (surface->format->BitsPerPixel < 8 && - SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) { + SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) { blit = SDL_CalculateBlit0(surface); } #endif #if SDL_HAVE_BLIT_1 else if (surface->format->BytesPerPixel == 1 && - SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) { + SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) { blit = SDL_CalculateBlit1(surface); } #endif diff --git a/src/video/SDL_blit.h b/src/video/SDL_blit.h index 2f99fa8d9..c50dc6cf1 100644 --- a/src/video/SDL_blit.h +++ b/src/video/SDL_blit.h @@ -28,36 +28,36 @@ #include "SDL_surface.h" /* pixman ARM blitters are 32 bit only : */ -#if defined(__aarch64__)||defined(_M_ARM64) +#if defined(__aarch64__) || defined(_M_ARM64) #undef SDL_ARM_SIMD_BLITTERS #undef SDL_ARM_NEON_BLITTERS #endif /* Table to do pixel byte expansion */ -extern Uint8* SDL_expand_byte[9]; +extern Uint8 *SDL_expand_byte[9]; /* SDL blit copy flags */ -#define SDL_COPY_MODULATE_COLOR 0x00000001 -#define SDL_COPY_MODULATE_ALPHA 0x00000002 -#define SDL_COPY_BLEND 0x00000010 -#define SDL_COPY_ADD 0x00000020 -#define SDL_COPY_MOD 0x00000040 -#define SDL_COPY_MUL 0x00000080 -#define SDL_COPY_COLORKEY 0x00000100 -#define SDL_COPY_NEAREST 0x00000200 -#define SDL_COPY_RLE_DESIRED 0x00001000 -#define SDL_COPY_RLE_COLORKEY 0x00002000 -#define SDL_COPY_RLE_ALPHAKEY 0x00004000 -#define SDL_COPY_RLE_MASK (SDL_COPY_RLE_DESIRED|SDL_COPY_RLE_COLORKEY|SDL_COPY_RLE_ALPHAKEY) +#define SDL_COPY_MODULATE_COLOR 0x00000001 +#define SDL_COPY_MODULATE_ALPHA 0x00000002 +#define SDL_COPY_BLEND 0x00000010 +#define SDL_COPY_ADD 0x00000020 +#define SDL_COPY_MOD 0x00000040 +#define SDL_COPY_MUL 0x00000080 +#define SDL_COPY_COLORKEY 0x00000100 +#define SDL_COPY_NEAREST 0x00000200 +#define SDL_COPY_RLE_DESIRED 0x00001000 +#define SDL_COPY_RLE_COLORKEY 0x00002000 +#define SDL_COPY_RLE_ALPHAKEY 0x00004000 +#define SDL_COPY_RLE_MASK (SDL_COPY_RLE_DESIRED | SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY) /* SDL blit CPU flags */ -#define SDL_CPU_ANY 0x00000000 -#define SDL_CPU_MMX 0x00000001 -#define SDL_CPU_3DNOW 0x00000002 -#define SDL_CPU_SSE 0x00000004 -#define SDL_CPU_SSE2 0x00000008 -#define SDL_CPU_ALTIVEC_PREFETCH 0x00000010 -#define SDL_CPU_ALTIVEC_NOPREFETCH 0x00000020 +#define SDL_CPU_ANY 0x00000000 +#define SDL_CPU_MMX 0x00000001 +#define SDL_CPU_3DNOW 0x00000002 +#define SDL_CPU_SSE 0x00000004 +#define SDL_CPU_SSE2 0x00000008 +#define SDL_CPU_ALTIVEC_PREFETCH 0x00000010 +#define SDL_CPU_ALTIVEC_NOPREFETCH 0x00000020 typedef struct { @@ -77,8 +77,7 @@ typedef struct Uint8 r, g, b, a; } SDL_BlitInfo; -typedef void (*SDL_BlitFunc) (SDL_BlitInfo *info); - +typedef void (*SDL_BlitFunc)(SDL_BlitInfo *info); typedef struct { @@ -106,367 +105,365 @@ struct SDL_BlitMap }; /* Functions found in SDL_blit.c */ -extern int SDL_CalculateBlit(SDL_Surface * surface); +extern int SDL_CalculateBlit(SDL_Surface *surface); /* Functions found in SDL_blit_*.c */ -extern SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface * surface); -extern SDL_BlitFunc SDL_CalculateBlit1(SDL_Surface * surface); -extern SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface * surface); -extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface * surface); +extern SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface); +extern SDL_BlitFunc SDL_CalculateBlit1(SDL_Surface *surface); +extern SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface *surface); +extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface); /* * Useful macros for blitting routines */ #if defined(__GNUC__) -#define DECLARE_ALIGNED(t,v,a) t __attribute__((aligned(a))) v +#define DECLARE_ALIGNED(t, v, a) t __attribute__((aligned(a))) v #elif defined(_MSC_VER) -#define DECLARE_ALIGNED(t,v,a) __declspec(align(a)) t v +#define DECLARE_ALIGNED(t, v, a) __declspec(align(a)) t v #else -#define DECLARE_ALIGNED(t,v,a) t v +#define DECLARE_ALIGNED(t, v, a) t v #endif /* Load pixel of the specified format from a buffer and get its R-G-B values */ -#define RGB_FROM_PIXEL(Pixel, fmt, r, g, b) \ -{ \ - r = SDL_expand_byte[fmt->Rloss][((Pixel&fmt->Rmask)>>fmt->Rshift)]; \ - g = SDL_expand_byte[fmt->Gloss][((Pixel&fmt->Gmask)>>fmt->Gshift)]; \ - b = SDL_expand_byte[fmt->Bloss][((Pixel&fmt->Bmask)>>fmt->Bshift)]; \ -} -#define RGB_FROM_RGB565(Pixel, r, g, b) \ -{ \ - r = SDL_expand_byte[3][((Pixel&0xF800)>>11)]; \ - g = SDL_expand_byte[2][((Pixel&0x07E0)>>5)]; \ - b = SDL_expand_byte[3][(Pixel&0x001F)]; \ -} -#define RGB_FROM_RGB555(Pixel, r, g, b) \ -{ \ - r = SDL_expand_byte[3][((Pixel&0x7C00)>>10)]; \ - g = SDL_expand_byte[3][((Pixel&0x03E0)>>5)]; \ - b = SDL_expand_byte[3][(Pixel&0x001F)]; \ -} -#define RGB_FROM_RGB888(Pixel, r, g, b) \ -{ \ - r = ((Pixel&0xFF0000)>>16); \ - g = ((Pixel&0xFF00)>>8); \ - b = (Pixel&0xFF); \ -} -#define RETRIEVE_RGB_PIXEL(buf, bpp, Pixel) \ -do { \ - switch (bpp) { \ - case 1: \ - Pixel = *((Uint8 *)(buf)); \ - break; \ - \ - case 2: \ - Pixel = *((Uint16 *)(buf)); \ - break; \ - \ - case 3: { \ - Uint8 *B = (Uint8 *)(buf); \ - if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ - Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \ - } else { \ - Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \ - } \ - } \ - break; \ - \ - case 4: \ - Pixel = *((Uint32 *)(buf)); \ - break; \ - \ - default: \ - Pixel = 0; /* stop gcc complaints */ \ - break; \ - } \ -} while (0) +#define RGB_FROM_PIXEL(Pixel, fmt, r, g, b) \ + { \ + r = SDL_expand_byte[fmt->Rloss][((Pixel & fmt->Rmask) >> fmt->Rshift)]; \ + g = SDL_expand_byte[fmt->Gloss][((Pixel & fmt->Gmask) >> fmt->Gshift)]; \ + b = SDL_expand_byte[fmt->Bloss][((Pixel & fmt->Bmask) >> fmt->Bshift)]; \ + } +#define RGB_FROM_RGB565(Pixel, r, g, b) \ + { \ + r = SDL_expand_byte[3][((Pixel & 0xF800) >> 11)]; \ + g = SDL_expand_byte[2][((Pixel & 0x07E0) >> 5)]; \ + b = SDL_expand_byte[3][(Pixel & 0x001F)]; \ + } +#define RGB_FROM_RGB555(Pixel, r, g, b) \ + { \ + r = SDL_expand_byte[3][((Pixel & 0x7C00) >> 10)]; \ + g = SDL_expand_byte[3][((Pixel & 0x03E0) >> 5)]; \ + b = SDL_expand_byte[3][(Pixel & 0x001F)]; \ + } +#define RGB_FROM_RGB888(Pixel, r, g, b) \ + { \ + r = ((Pixel & 0xFF0000) >> 16); \ + g = ((Pixel & 0xFF00) >> 8); \ + b = (Pixel & 0xFF); \ + } +#define RETRIEVE_RGB_PIXEL(buf, bpp, Pixel) \ + do { \ + switch (bpp) { \ + case 1: \ + Pixel = *((Uint8 *)(buf)); \ + break; \ + \ + case 2: \ + Pixel = *((Uint16 *)(buf)); \ + break; \ + \ + case 3: \ + { \ + Uint8 *B = (Uint8 *)(buf); \ + if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ + Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \ + } else { \ + Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \ + } \ + } break; \ + \ + case 4: \ + Pixel = *((Uint32 *)(buf)); \ + break; \ + \ + default: \ + Pixel = 0; /* stop gcc complaints */ \ + break; \ + } \ + } while (0) -#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b) \ -do { \ - switch (bpp) { \ - case 1: \ - Pixel = *((Uint8 *)(buf)); \ - RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \ - break; \ - \ - case 2: \ - Pixel = *((Uint16 *)(buf)); \ - RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \ - break; \ - \ - case 3: { \ - Pixel = 0; \ - if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ - r = *((buf)+fmt->Rshift/8); \ - g = *((buf)+fmt->Gshift/8); \ - b = *((buf)+fmt->Bshift/8); \ - } else { \ - r = *((buf)+2-fmt->Rshift/8); \ - g = *((buf)+2-fmt->Gshift/8); \ - b = *((buf)+2-fmt->Bshift/8); \ - } \ - } \ - break; \ - \ - case 4: \ - Pixel = *((Uint32 *)(buf)); \ - RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \ - break; \ - \ - default: \ - /* stop gcc complaints */ \ - Pixel = 0; \ - r = g = b = 0; \ - break; \ - } \ -} while (0) +#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b) \ + do { \ + switch (bpp) { \ + case 1: \ + Pixel = *((Uint8 *)(buf)); \ + RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \ + break; \ + \ + case 2: \ + Pixel = *((Uint16 *)(buf)); \ + RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \ + break; \ + \ + case 3: \ + { \ + Pixel = 0; \ + if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ + r = *((buf) + fmt->Rshift / 8); \ + g = *((buf) + fmt->Gshift / 8); \ + b = *((buf) + fmt->Bshift / 8); \ + } else { \ + r = *((buf) + 2 - fmt->Rshift / 8); \ + g = *((buf) + 2 - fmt->Gshift / 8); \ + b = *((buf) + 2 - fmt->Bshift / 8); \ + } \ + } break; \ + \ + case 4: \ + Pixel = *((Uint32 *)(buf)); \ + RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \ + break; \ + \ + default: \ + /* stop gcc complaints */ \ + Pixel = 0; \ + r = g = b = 0; \ + break; \ + } \ + } while (0) /* Assemble R-G-B values into a specified pixel format and store them */ -#define PIXEL_FROM_RGB(Pixel, fmt, r, g, b) \ -{ \ - Pixel = ((r>>fmt->Rloss)<Rshift)| \ - ((g>>fmt->Gloss)<Gshift)| \ - ((b>>fmt->Bloss)<Bshift)| \ - fmt->Amask; \ -} -#define RGB565_FROM_RGB(Pixel, r, g, b) \ -{ \ - Pixel = ((r>>3)<<11)|((g>>2)<<5)|(b>>3); \ -} -#define RGB555_FROM_RGB(Pixel, r, g, b) \ -{ \ - Pixel = ((r>>3)<<10)|((g>>3)<<5)|(b>>3); \ -} -#define RGB888_FROM_RGB(Pixel, r, g, b) \ -{ \ - Pixel = (r<<16)|(g<<8)|b; \ -} -#define ARGB8888_FROM_RGBA(Pixel, r, g, b, a) \ -{ \ - Pixel = (a<<24)|(r<<16)|(g<<8)|b; \ -} -#define RGBA8888_FROM_RGBA(Pixel, r, g, b, a) \ -{ \ - Pixel = (r<<24)|(g<<16)|(b<<8)|a; \ -} -#define ABGR8888_FROM_RGBA(Pixel, r, g, b, a) \ -{ \ - Pixel = (a<<24)|(b<<16)|(g<<8)|r; \ -} -#define BGRA8888_FROM_RGBA(Pixel, r, g, b, a) \ -{ \ - Pixel = (b<<24)|(g<<16)|(r<<8)|a; \ -} -#define ARGB2101010_FROM_RGBA(Pixel, r, g, b, a) \ -{ \ - r = r ? ((r << 2) | 0x3) : 0; \ - g = g ? ((g << 2) | 0x3) : 0; \ - b = b ? ((b << 2) | 0x3) : 0; \ - a = (a * 3) / 255; \ - Pixel = (a<<30)|(r<<20)|(g<<10)|b; \ -} -#define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b) \ -{ \ - switch (bpp) { \ - case 1: { \ - Uint8 _pixel; \ - \ - PIXEL_FROM_RGB(_pixel, fmt, r, g, b); \ - *((Uint8 *)(buf)) = _pixel; \ - } \ - break; \ - \ - case 2: { \ - Uint16 _pixel; \ - \ - PIXEL_FROM_RGB(_pixel, fmt, r, g, b); \ - *((Uint16 *)(buf)) = _pixel; \ - } \ - break; \ - \ - case 3: { \ - if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ - *((buf)+fmt->Rshift/8) = r; \ - *((buf)+fmt->Gshift/8) = g; \ - *((buf)+fmt->Bshift/8) = b; \ - } else { \ - *((buf)+2-fmt->Rshift/8) = r; \ - *((buf)+2-fmt->Gshift/8) = g; \ - *((buf)+2-fmt->Bshift/8) = b; \ - } \ - } \ - break; \ - \ - case 4: { \ - Uint32 _pixel; \ - \ - PIXEL_FROM_RGB(_pixel, fmt, r, g, b); \ - *((Uint32 *)(buf)) = _pixel; \ - } \ - break; \ - } \ -} +#define PIXEL_FROM_RGB(Pixel, fmt, r, g, b) \ + { \ + Pixel = ((r >> fmt->Rloss) << fmt->Rshift) | \ + ((g >> fmt->Gloss) << fmt->Gshift) | \ + ((b >> fmt->Bloss) << fmt->Bshift) | \ + fmt->Amask; \ + } +#define RGB565_FROM_RGB(Pixel, r, g, b) \ + { \ + Pixel = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3); \ + } +#define RGB555_FROM_RGB(Pixel, r, g, b) \ + { \ + Pixel = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3); \ + } +#define RGB888_FROM_RGB(Pixel, r, g, b) \ + { \ + Pixel = (r << 16) | (g << 8) | b; \ + } +#define ARGB8888_FROM_RGBA(Pixel, r, g, b, a) \ + { \ + Pixel = (a << 24) | (r << 16) | (g << 8) | b; \ + } +#define RGBA8888_FROM_RGBA(Pixel, r, g, b, a) \ + { \ + Pixel = (r << 24) | (g << 16) | (b << 8) | a; \ + } +#define ABGR8888_FROM_RGBA(Pixel, r, g, b, a) \ + { \ + Pixel = (a << 24) | (b << 16) | (g << 8) | r; \ + } +#define BGRA8888_FROM_RGBA(Pixel, r, g, b, a) \ + { \ + Pixel = (b << 24) | (g << 16) | (r << 8) | a; \ + } +#define ARGB2101010_FROM_RGBA(Pixel, r, g, b, a) \ + { \ + r = r ? ((r << 2) | 0x3) : 0; \ + g = g ? ((g << 2) | 0x3) : 0; \ + b = b ? ((b << 2) | 0x3) : 0; \ + a = (a * 3) / 255; \ + Pixel = (a << 30) | (r << 20) | (g << 10) | b; \ + } +#define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b) \ + { \ + switch (bpp) { \ + case 1: \ + { \ + Uint8 _pixel; \ + \ + PIXEL_FROM_RGB(_pixel, fmt, r, g, b); \ + *((Uint8 *)(buf)) = _pixel; \ + } break; \ + \ + case 2: \ + { \ + Uint16 _pixel; \ + \ + PIXEL_FROM_RGB(_pixel, fmt, r, g, b); \ + *((Uint16 *)(buf)) = _pixel; \ + } break; \ + \ + case 3: \ + { \ + if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ + *((buf) + fmt->Rshift / 8) = r; \ + *((buf) + fmt->Gshift / 8) = g; \ + *((buf) + fmt->Bshift / 8) = b; \ + } else { \ + *((buf) + 2 - fmt->Rshift / 8) = r; \ + *((buf) + 2 - fmt->Gshift / 8) = g; \ + *((buf) + 2 - fmt->Bshift / 8) = b; \ + } \ + } break; \ + \ + case 4: \ + { \ + Uint32 _pixel; \ + \ + PIXEL_FROM_RGB(_pixel, fmt, r, g, b); \ + *((Uint32 *)(buf)) = _pixel; \ + } break; \ + } \ + } /* FIXME: Should we rescale alpha into 0..255 here? */ -#define RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a) \ -{ \ - r = SDL_expand_byte[fmt->Rloss][((Pixel&fmt->Rmask)>>fmt->Rshift)]; \ - g = SDL_expand_byte[fmt->Gloss][((Pixel&fmt->Gmask)>>fmt->Gshift)]; \ - b = SDL_expand_byte[fmt->Bloss][((Pixel&fmt->Bmask)>>fmt->Bshift)]; \ - a = SDL_expand_byte[fmt->Aloss][((Pixel&fmt->Amask)>>fmt->Ashift)]; \ -} -#define RGBA_FROM_8888(Pixel, fmt, r, g, b, a) \ -{ \ - r = (Pixel&fmt->Rmask)>>fmt->Rshift; \ - g = (Pixel&fmt->Gmask)>>fmt->Gshift; \ - b = (Pixel&fmt->Bmask)>>fmt->Bshift; \ - a = (Pixel&fmt->Amask)>>fmt->Ashift; \ -} -#define RGBA_FROM_RGBA8888(Pixel, r, g, b, a) \ -{ \ - r = (Pixel>>24); \ - g = ((Pixel>>16)&0xFF); \ - b = ((Pixel>>8)&0xFF); \ - a = (Pixel&0xFF); \ -} -#define RGBA_FROM_ARGB8888(Pixel, r, g, b, a) \ -{ \ - r = ((Pixel>>16)&0xFF); \ - g = ((Pixel>>8)&0xFF); \ - b = (Pixel&0xFF); \ - a = (Pixel>>24); \ -} -#define RGBA_FROM_ABGR8888(Pixel, r, g, b, a) \ -{ \ - r = (Pixel&0xFF); \ - g = ((Pixel>>8)&0xFF); \ - b = ((Pixel>>16)&0xFF); \ - a = (Pixel>>24); \ -} -#define RGBA_FROM_BGRA8888(Pixel, r, g, b, a) \ -{ \ - r = ((Pixel>>8)&0xFF); \ - g = ((Pixel>>16)&0xFF); \ - b = (Pixel>>24); \ - a = (Pixel&0xFF); \ -} -#define RGBA_FROM_ARGB2101010(Pixel, r, g, b, a) \ -{ \ - r = ((Pixel>>22)&0xFF); \ - g = ((Pixel>>12)&0xFF); \ - b = ((Pixel>>2)&0xFF); \ - a = SDL_expand_byte[6][(Pixel>>30)]; \ -} -#define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a) \ -do { \ - switch (bpp) { \ - case 1: \ - Pixel = *((Uint8 *)(buf)); \ - RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \ - break; \ - \ - case 2: \ - Pixel = *((Uint16 *)(buf)); \ - RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \ - break; \ - \ - case 3: { \ - Pixel = 0; \ - if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ - r = *((buf)+fmt->Rshift/8); \ - g = *((buf)+fmt->Gshift/8); \ - b = *((buf)+fmt->Bshift/8); \ - } else { \ - r = *((buf)+2-fmt->Rshift/8); \ - g = *((buf)+2-fmt->Gshift/8); \ - b = *((buf)+2-fmt->Bshift/8); \ - } \ - a = 0xFF; \ - } \ - break; \ - \ - case 4: \ - Pixel = *((Uint32 *)(buf)); \ - RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \ - break; \ - \ - default: \ - /* stop gcc complaints */ \ - Pixel = 0; \ - r = g = b = a = 0; \ - break; \ - } \ -} while (0) +#define RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a) \ + { \ + r = SDL_expand_byte[fmt->Rloss][((Pixel & fmt->Rmask) >> fmt->Rshift)]; \ + g = SDL_expand_byte[fmt->Gloss][((Pixel & fmt->Gmask) >> fmt->Gshift)]; \ + b = SDL_expand_byte[fmt->Bloss][((Pixel & fmt->Bmask) >> fmt->Bshift)]; \ + a = SDL_expand_byte[fmt->Aloss][((Pixel & fmt->Amask) >> fmt->Ashift)]; \ + } +#define RGBA_FROM_8888(Pixel, fmt, r, g, b, a) \ + { \ + r = (Pixel & fmt->Rmask) >> fmt->Rshift; \ + g = (Pixel & fmt->Gmask) >> fmt->Gshift; \ + b = (Pixel & fmt->Bmask) >> fmt->Bshift; \ + a = (Pixel & fmt->Amask) >> fmt->Ashift; \ + } +#define RGBA_FROM_RGBA8888(Pixel, r, g, b, a) \ + { \ + r = (Pixel >> 24); \ + g = ((Pixel >> 16) & 0xFF); \ + b = ((Pixel >> 8) & 0xFF); \ + a = (Pixel & 0xFF); \ + } +#define RGBA_FROM_ARGB8888(Pixel, r, g, b, a) \ + { \ + r = ((Pixel >> 16) & 0xFF); \ + g = ((Pixel >> 8) & 0xFF); \ + b = (Pixel & 0xFF); \ + a = (Pixel >> 24); \ + } +#define RGBA_FROM_ABGR8888(Pixel, r, g, b, a) \ + { \ + r = (Pixel & 0xFF); \ + g = ((Pixel >> 8) & 0xFF); \ + b = ((Pixel >> 16) & 0xFF); \ + a = (Pixel >> 24); \ + } +#define RGBA_FROM_BGRA8888(Pixel, r, g, b, a) \ + { \ + r = ((Pixel >> 8) & 0xFF); \ + g = ((Pixel >> 16) & 0xFF); \ + b = (Pixel >> 24); \ + a = (Pixel & 0xFF); \ + } +#define RGBA_FROM_ARGB2101010(Pixel, r, g, b, a) \ + { \ + r = ((Pixel >> 22) & 0xFF); \ + g = ((Pixel >> 12) & 0xFF); \ + b = ((Pixel >> 2) & 0xFF); \ + a = SDL_expand_byte[6][(Pixel >> 30)]; \ + } +#define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a) \ + do { \ + switch (bpp) { \ + case 1: \ + Pixel = *((Uint8 *)(buf)); \ + RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \ + break; \ + \ + case 2: \ + Pixel = *((Uint16 *)(buf)); \ + RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \ + break; \ + \ + case 3: \ + { \ + Pixel = 0; \ + if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ + r = *((buf) + fmt->Rshift / 8); \ + g = *((buf) + fmt->Gshift / 8); \ + b = *((buf) + fmt->Bshift / 8); \ + } else { \ + r = *((buf) + 2 - fmt->Rshift / 8); \ + g = *((buf) + 2 - fmt->Gshift / 8); \ + b = *((buf) + 2 - fmt->Bshift / 8); \ + } \ + a = 0xFF; \ + } break; \ + \ + case 4: \ + Pixel = *((Uint32 *)(buf)); \ + RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \ + break; \ + \ + default: \ + /* stop gcc complaints */ \ + Pixel = 0; \ + r = g = b = a = 0; \ + break; \ + } \ + } while (0) /* FIXME: this isn't correct, especially for Alpha (maximum != 255) */ -#define PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \ -{ \ - Pixel = ((r>>fmt->Rloss)<Rshift)| \ - ((g>>fmt->Gloss)<Gshift)| \ - ((b>>fmt->Bloss)<Bshift)| \ - ((a>>fmt->Aloss)<Ashift); \ -} -#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a) \ -{ \ - switch (bpp) { \ - case 1: { \ - Uint8 _pixel; \ - \ - PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \ - *((Uint8 *)(buf)) = _pixel; \ - } \ - break; \ - \ - case 2: { \ - Uint16 _pixel; \ - \ - PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \ - *((Uint16 *)(buf)) = _pixel; \ - } \ - break; \ - \ - case 3: { \ - if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ - *((buf)+fmt->Rshift/8) = r; \ - *((buf)+fmt->Gshift/8) = g; \ - *((buf)+fmt->Bshift/8) = b; \ - } else { \ - *((buf)+2-fmt->Rshift/8) = r; \ - *((buf)+2-fmt->Gshift/8) = g; \ - *((buf)+2-fmt->Bshift/8) = b; \ - } \ - } \ - break; \ - \ - case 4: { \ - Uint32 _pixel; \ - \ - PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \ - *((Uint32 *)(buf)) = _pixel; \ - } \ - break; \ - } \ -} +#define PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \ + { \ + Pixel = ((r >> fmt->Rloss) << fmt->Rshift) | \ + ((g >> fmt->Gloss) << fmt->Gshift) | \ + ((b >> fmt->Bloss) << fmt->Bshift) | \ + ((a >> fmt->Aloss) << fmt->Ashift); \ + } +#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a) \ + { \ + switch (bpp) { \ + case 1: \ + { \ + Uint8 _pixel; \ + \ + PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \ + *((Uint8 *)(buf)) = _pixel; \ + } break; \ + \ + case 2: \ + { \ + Uint16 _pixel; \ + \ + PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \ + *((Uint16 *)(buf)) = _pixel; \ + } break; \ + \ + case 3: \ + { \ + if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ + *((buf) + fmt->Rshift / 8) = r; \ + *((buf) + fmt->Gshift / 8) = g; \ + *((buf) + fmt->Bshift / 8) = b; \ + } else { \ + *((buf) + 2 - fmt->Rshift / 8) = r; \ + *((buf) + 2 - fmt->Gshift / 8) = g; \ + *((buf) + 2 - fmt->Bshift / 8) = b; \ + } \ + } break; \ + \ + case 4: \ + { \ + Uint32 _pixel; \ + \ + PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \ + *((Uint32 *)(buf)) = _pixel; \ + } break; \ + } \ + } /* Blend the RGB values of two pixels with an alpha value */ -#define ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB) \ -do { \ - dR = (Uint8)((((int)(sR-dR)*(int)A)/255)+dR); \ - dG = (Uint8)((((int)(sG-dG)*(int)A)/255)+dG); \ - dB = (Uint8)((((int)(sB-dB)*(int)A)/255)+dB); \ -} while(0) - +#define ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB) \ + do { \ + dR = (Uint8)((((int)(sR - dR) * (int)A) / 255) + dR); \ + dG = (Uint8)((((int)(sG - dG) * (int)A) / 255) + dG); \ + dB = (Uint8)((((int)(sB - dB) * (int)A) / 255) + dB); \ + } while (0) /* Blend the RGBA values of two pixels */ -#define ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA) \ -do { \ - dR = (Uint8)((((int)(sR-dR)*(int)sA)/255)+dR); \ - dG = (Uint8)((((int)(sG-dG)*(int)sA)/255)+dG); \ - dB = (Uint8)((((int)(sB-dB)*(int)sA)/255)+dB); \ - dA = (Uint8)((int)sA+dA-((int)sA*dA)/255); \ -} while(0) - +#define ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA) \ + do { \ + dR = (Uint8)((((int)(sR - dR) * (int)sA) / 255) + dR); \ + dG = (Uint8)((((int)(sG - dG) * (int)sA) / 255) + dG); \ + dB = (Uint8)((((int)(sB - dB) * (int)sA) / 255) + dB); \ + dA = (Uint8)((int)sA + dA - ((int)sA * dA) / 255); \ + } while (0) /* This is a very useful loop for optimizing blitters */ #if defined(_MSC_VER) && (_MSC_VER == 1300) @@ -477,83 +474,114 @@ do { \ #ifdef USE_DUFFS_LOOP /* 8-times unrolled loop */ -#define DUFFS_LOOP8(pixel_copy_increment, width) \ -{ int n = (width+7)/8; \ - switch (width & 7) { \ - case 0: do { pixel_copy_increment; SDL_FALLTHROUGH; \ - case 7: pixel_copy_increment; SDL_FALLTHROUGH; \ - case 6: pixel_copy_increment; SDL_FALLTHROUGH; \ - case 5: pixel_copy_increment; SDL_FALLTHROUGH; \ - case 4: pixel_copy_increment; SDL_FALLTHROUGH; \ - case 3: pixel_copy_increment; SDL_FALLTHROUGH; \ - case 2: pixel_copy_increment; SDL_FALLTHROUGH; \ - case 1: pixel_copy_increment; \ - } while ( --n > 0 ); \ - } \ -} +#define DUFFS_LOOP8(pixel_copy_increment, width) \ + { \ + int n = (width + 7) / 8; \ + switch (width & 7) { \ + case 0: \ + do { \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 7: \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 6: \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 5: \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 4: \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 3: \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 2: \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 1: \ + pixel_copy_increment; \ + } while (--n > 0); \ + } \ + } /* 4-times unrolled loop */ -#define DUFFS_LOOP4(pixel_copy_increment, width) \ -{ int n = (width+3)/4; \ - switch (width & 3) { \ - case 0: do { pixel_copy_increment; SDL_FALLTHROUGH; \ - case 3: pixel_copy_increment; SDL_FALLTHROUGH; \ - case 2: pixel_copy_increment; SDL_FALLTHROUGH; \ - case 1: pixel_copy_increment; \ - } while (--n > 0); \ - } \ -} +#define DUFFS_LOOP4(pixel_copy_increment, width) \ + { \ + int n = (width + 3) / 4; \ + switch (width & 3) { \ + case 0: \ + do { \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 3: \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 2: \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 1: \ + pixel_copy_increment; \ + } while (--n > 0); \ + } \ + } /* Use the 8-times version of the loop by default */ -#define DUFFS_LOOP(pixel_copy_increment, width) \ +#define DUFFS_LOOP(pixel_copy_increment, width) \ DUFFS_LOOP8(pixel_copy_increment, width) /* Special version of Duff's device for even more optimization */ -#define DUFFS_LOOP_124(pixel_copy_increment1, \ - pixel_copy_increment2, \ - pixel_copy_increment4, width) \ -{ int n = width; \ - if (n & 1) { \ - pixel_copy_increment1; n -= 1; \ - } \ - if (n & 2) { \ - pixel_copy_increment2; n -= 2; \ - } \ - if (n & 4) { \ - pixel_copy_increment4; n -= 4; \ - } \ - if (n) { \ - n /= 8; \ - do { \ - pixel_copy_increment4; \ - pixel_copy_increment4; \ - } while (--n > 0); \ - } \ -} +#define DUFFS_LOOP_124(pixel_copy_increment1, \ + pixel_copy_increment2, \ + pixel_copy_increment4, width) \ + { \ + int n = width; \ + if (n & 1) { \ + pixel_copy_increment1; \ + n -= 1; \ + } \ + if (n & 2) { \ + pixel_copy_increment2; \ + n -= 2; \ + } \ + if (n & 4) { \ + pixel_copy_increment4; \ + n -= 4; \ + } \ + if (n) { \ + n /= 8; \ + do { \ + pixel_copy_increment4; \ + pixel_copy_increment4; \ + } while (--n > 0); \ + } \ + } #else /* Don't use Duff's device to unroll loops */ -#define DUFFS_LOOP(pixel_copy_increment, width) \ -{ int n; \ - for ( n=width; n > 0; --n ) { \ - pixel_copy_increment; \ - } \ -} -#define DUFFS_LOOP8(pixel_copy_increment, width) \ +#define DUFFS_LOOP(pixel_copy_increment, width) \ + { \ + int n; \ + for (n = width; n > 0; --n) { \ + pixel_copy_increment; \ + } \ + } +#define DUFFS_LOOP8(pixel_copy_increment, width) \ DUFFS_LOOP(pixel_copy_increment, width) -#define DUFFS_LOOP4(pixel_copy_increment, width) \ +#define DUFFS_LOOP4(pixel_copy_increment, width) \ DUFFS_LOOP(pixel_copy_increment, width) -#define DUFFS_LOOP_124(pixel_copy_increment1, \ - pixel_copy_increment2, \ - pixel_copy_increment4, width) \ +#define DUFFS_LOOP_124(pixel_copy_increment1, \ + pixel_copy_increment2, \ + pixel_copy_increment4, width) \ DUFFS_LOOP(pixel_copy_increment1, width) #endif /* USE_DUFFS_LOOP */ /* Prevent Visual C++ 6.0 from printing out stupid warnings */ #if defined(_MSC_VER) && (_MSC_VER >= 600) -#pragma warning(disable: 4550) +#pragma warning(disable : 4550) #endif #endif /* SDL_blit_h_ */ diff --git a/src/video/SDL_blit_0.c b/src/video/SDL_blit_0.c index 54882f8b1..71247c504 100644 --- a/src/video/SDL_blit_0.c +++ b/src/video/SDL_blit_0.c @@ -27,8 +27,7 @@ /* Functions to blit from bitmaps to other surfaces */ -static void -BlitBto1(SDL_BlitInfo * info) +static void BlitBto1(SDL_BlitInfo *info) { int c; int width, height; @@ -82,8 +81,7 @@ BlitBto1(SDL_BlitInfo * info) } } -static void -BlitBto2(SDL_BlitInfo * info) +static void BlitBto2(SDL_BlitInfo *info) { int c; int width, height; @@ -96,9 +94,9 @@ BlitBto2(SDL_BlitInfo * info) height = info->dst_h; src = info->src; srcskip = info->src_skip; - dst = (Uint16 *) info->dst; + dst = (Uint16 *)info->dst; dstskip = info->dst_skip / 2; - map = (Uint16 *) info->table; + map = (Uint16 *)info->table; srcskip += width - (width + 7) / 8; while (height--) { @@ -119,8 +117,7 @@ BlitBto2(SDL_BlitInfo * info) } } -static void -BlitBto3(SDL_BlitInfo * info) +static void BlitBto3(SDL_BlitInfo *info) { int c, o; int width, height; @@ -158,8 +155,7 @@ BlitBto3(SDL_BlitInfo * info) } } -static void -BlitBto4(SDL_BlitInfo * info) +static void BlitBto4(SDL_BlitInfo *info) { int width, height; Uint8 *src; @@ -172,9 +168,9 @@ BlitBto4(SDL_BlitInfo * info) height = info->dst_h; src = info->src; srcskip = info->src_skip; - dst = (Uint32 *) info->dst; + dst = (Uint32 *)info->dst; dstskip = info->dst_skip / 4; - map = (Uint32 *) info->table; + map = (Uint32 *)info->table; srcskip += width - (width + 7) / 8; while (height--) { @@ -195,8 +191,7 @@ BlitBto4(SDL_BlitInfo * info) } } -static void -BlitBto1Key(SDL_BlitInfo * info) +static void BlitBto1Key(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -248,13 +243,12 @@ BlitBto1Key(SDL_BlitInfo * info) } } -static void -BlitBto2Key(SDL_BlitInfo * info) +static void BlitBto2Key(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; Uint8 *src = info->src; - Uint16 *dstp = (Uint16 *) info->dst; + Uint16 *dstp = (Uint16 *)info->dst; int srcskip = info->src_skip; int dstskip = info->dst_skip; Uint32 ckey = info->colorkey; @@ -273,7 +267,7 @@ BlitBto2Key(SDL_BlitInfo * info) } bit = (byte & 0x80) >> 7; if (bit != ckey) { - *dstp = ((Uint16 *) palmap)[bit]; + *dstp = ((Uint16 *)palmap)[bit]; } byte <<= 1; dstp++; @@ -283,8 +277,7 @@ BlitBto2Key(SDL_BlitInfo * info) } } -static void -BlitBto3Key(SDL_BlitInfo * info) +static void BlitBto3Key(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -317,13 +310,12 @@ BlitBto3Key(SDL_BlitInfo * info) } } -static void -BlitBto4Key(SDL_BlitInfo * info) +static void BlitBto4Key(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; Uint8 *src = info->src; - Uint32 *dstp = (Uint32 *) info->dst; + Uint32 *dstp = (Uint32 *)info->dst; int srcskip = info->src_skip; int dstskip = info->dst_skip; Uint32 ckey = info->colorkey; @@ -342,7 +334,7 @@ BlitBto4Key(SDL_BlitInfo * info) } bit = (byte & 0x80) >> 7; if (bit != ckey) { - *dstp = ((Uint32 *) palmap)[bit]; + *dstp = ((Uint32 *)palmap)[bit]; } byte <<= 1; dstp++; @@ -352,8 +344,7 @@ BlitBto4Key(SDL_BlitInfo * info) } } -static void -BlitBtoNAlpha(SDL_BlitInfo * info) +static void BlitBtoNAlpha(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -397,8 +388,7 @@ BlitBtoNAlpha(SDL_BlitInfo * info) } } -static void -BlitBtoNAlphaKey(SDL_BlitInfo * info) +static void BlitBtoNAlphaKey(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -445,24 +435,22 @@ BlitBtoNAlphaKey(SDL_BlitInfo * info) } static const SDL_BlitFunc bitmap_blit[] = { - (SDL_BlitFunc) NULL, BlitBto1, BlitBto2, BlitBto3, BlitBto4 + (SDL_BlitFunc)NULL, BlitBto1, BlitBto2, BlitBto3, BlitBto4 }; static const SDL_BlitFunc colorkey_blit[] = { - (SDL_BlitFunc) NULL, BlitBto1Key, BlitBto2Key, BlitBto3Key, BlitBto4Key + (SDL_BlitFunc)NULL, BlitBto1Key, BlitBto2Key, BlitBto3Key, BlitBto4Key }; - -static void -Blit4bto4(SDL_BlitInfo * info) +static void Blit4bto4(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; Uint8 *src = info->src; - Uint32 *dst = (Uint32 *) info->dst; + Uint32 *dst = (Uint32 *)info->dst; int srcskip = info->src_skip; int dstskip = info->dst_skip; - Uint32 *map = (Uint32 *) info->table; + Uint32 *map = (Uint32 *)info->table; int c; /* Set up some basic variables */ @@ -482,21 +470,20 @@ Blit4bto4(SDL_BlitInfo * info) dst++; } src += srcskip; - dst = (Uint32 *) ((Uint8 *) dst + dstskip); + dst = (Uint32 *)((Uint8 *)dst + dstskip); } } -static void -Blit4bto4Key(SDL_BlitInfo * info) +static void Blit4bto4Key(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; Uint8 *src = info->src; - Uint32 *dst = (Uint32 *) info->dst; + Uint32 *dst = (Uint32 *)info->dst; int srcskip = info->src_skip; int dstskip = info->dst_skip; Uint32 ckey = info->colorkey; - Uint32 *map = (Uint32 *) info->table; + Uint32 *map = (Uint32 *)info->table; int c; /* Set up some basic variables */ @@ -516,12 +503,12 @@ Blit4bto4Key(SDL_BlitInfo * info) dst++; } src += srcskip; - dst = (Uint32 *) ((Uint8 *) dst + dstskip); + dst = (Uint32 *)((Uint8 *)dst + dstskip); } } SDL_BlitFunc -SDL_CalculateBlit0(SDL_Surface * surface) +SDL_CalculateBlit0(SDL_Surface *surface) { int which; @@ -529,11 +516,11 @@ SDL_CalculateBlit0(SDL_Surface * surface) if (surface->format->BitsPerPixel == 4) { if (surface->map->dst->format->BytesPerPixel == 4) { switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) { - case 0: - return Blit4bto4; + case 0: + return Blit4bto4; - case SDL_COPY_COLORKEY: - return Blit4bto4Key; + case SDL_COPY_COLORKEY: + return Blit4bto4Key; } } /* We don't fully support 4-bit packed pixel modes */ diff --git a/src/video/SDL_blit_1.c b/src/video/SDL_blit_1.c index 2c353fd27..3756c9e28 100644 --- a/src/video/SDL_blit_1.c +++ b/src/video/SDL_blit_1.c @@ -29,8 +29,7 @@ /* Functions to blit from 8-bit surfaces to other surfaces */ -static void -Blit1to1(SDL_BlitInfo * info) +static void Blit1to1(SDL_BlitInfo *info) { #ifndef USE_DUFFS_LOOP int c; @@ -73,16 +72,15 @@ Blit1to1(SDL_BlitInfo * info) /* This is now endian dependent */ #ifndef USE_DUFFS_LOOP -# if ( SDL_BYTEORDER == SDL_LIL_ENDIAN ) -# define HI 1 -# define LO 0 -# else /* ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) */ -# define HI 0 -# define LO 1 -# endif +#if (SDL_BYTEORDER == SDL_LIL_ENDIAN) +#define HI 1 +#define LO 0 +#else /* ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) */ +#define HI 0 +#define LO 1 #endif -static void -Blit1to2(SDL_BlitInfo * info) +#endif +static void Blit1to2(SDL_BlitInfo *info) { #ifndef USE_DUFFS_LOOP int c; @@ -99,7 +97,7 @@ Blit1to2(SDL_BlitInfo * info) srcskip = info->src_skip; dst = info->dst; dstskip = info->dst_skip; - map = (Uint16 *) info->table; + map = (Uint16 *)info->table; #ifdef USE_DUFFS_LOOP while (height--) { @@ -116,7 +114,7 @@ Blit1to2(SDL_BlitInfo * info) } #else /* Memory align at 4-byte boundary, if necessary */ - if ((long) dst & 0x03) { + if ((long)dst & 0x03) { /* Don't do anything if width is 0 */ if (width == 0) { return; @@ -125,30 +123,30 @@ Blit1to2(SDL_BlitInfo * info) while (height--) { /* Perform copy alignment */ - *(Uint16 *) dst = map[*src++]; + *(Uint16 *)dst = map[*src++]; dst += 2; /* Copy in 4 pixel chunks */ for (c = width / 4; c; --c) { - *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]); + *(Uint32 *)dst = (map[src[HI]] << 16) | (map[src[LO]]); src += 2; dst += 4; - *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]); + *(Uint32 *)dst = (map[src[HI]] << 16) | (map[src[LO]]); src += 2; dst += 4; } /* Get any leftovers */ switch (width & 3) { case 3: - *(Uint16 *) dst = map[*src++]; + *(Uint16 *)dst = map[*src++]; dst += 2; case 2: - *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]); + *(Uint32 *)dst = (map[src[HI]] << 16) | (map[src[LO]]); src += 2; dst += 4; break; case 1: - *(Uint16 *) dst = map[*src++]; + *(Uint16 *)dst = map[*src++]; dst += 2; break; } @@ -159,25 +157,25 @@ Blit1to2(SDL_BlitInfo * info) while (height--) { /* Copy in 4 pixel chunks */ for (c = width / 4; c; --c) { - *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]); + *(Uint32 *)dst = (map[src[HI]] << 16) | (map[src[LO]]); src += 2; dst += 4; - *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]); + *(Uint32 *)dst = (map[src[HI]] << 16) | (map[src[LO]]); src += 2; dst += 4; } /* Get any leftovers */ switch (width & 3) { case 3: - *(Uint16 *) dst = map[*src++]; + *(Uint16 *)dst = map[*src++]; dst += 2; case 2: - *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]); + *(Uint32 *)dst = (map[src[HI]] << 16) | (map[src[LO]]); src += 2; dst += 4; break; case 1: - *(Uint16 *) dst = map[*src++]; + *(Uint16 *)dst = map[*src++]; dst += 2; break; } @@ -188,8 +186,7 @@ Blit1to2(SDL_BlitInfo * info) #endif /* USE_DUFFS_LOOP */ } -static void -Blit1to3(SDL_BlitInfo * info) +static void Blit1to3(SDL_BlitInfo *info) { #ifndef USE_DUFFS_LOOP int c; @@ -237,8 +234,7 @@ Blit1to3(SDL_BlitInfo * info) } } -static void -Blit1to4(SDL_BlitInfo * info) +static void Blit1to4(SDL_BlitInfo *info) { #ifndef USE_DUFFS_LOOP int c; @@ -253,9 +249,9 @@ Blit1to4(SDL_BlitInfo * info) height = info->dst_h; src = info->src; srcskip = info->src_skip; - dst = (Uint32 *) info->dst; + dst = (Uint32 *)info->dst; dstskip = info->dst_skip / 4; - map = (Uint32 *) info->table; + map = (Uint32 *)info->table; while (height--) { #ifdef USE_DUFFS_LOOP @@ -285,8 +281,7 @@ Blit1to4(SDL_BlitInfo * info) } } -static void -Blit1to1Key(SDL_BlitInfo * info) +static void Blit1to1Key(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -332,16 +327,15 @@ Blit1to1Key(SDL_BlitInfo * info) } } -static void -Blit1to2Key(SDL_BlitInfo * info) +static void Blit1to2Key(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; Uint8 *src = info->src; int srcskip = info->src_skip; - Uint16 *dstp = (Uint16 *) info->dst; + Uint16 *dstp = (Uint16 *)info->dst; int dstskip = info->dst_skip; - Uint16 *palmap = (Uint16 *) info->table; + Uint16 *palmap = (Uint16 *)info->table; Uint32 ckey = info->colorkey; /* Set up some basic variables */ @@ -364,8 +358,7 @@ Blit1to2Key(SDL_BlitInfo * info) } } -static void -Blit1to3Key(SDL_BlitInfo * info) +static void Blit1to3Key(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -397,16 +390,15 @@ Blit1to3Key(SDL_BlitInfo * info) } } -static void -Blit1to4Key(SDL_BlitInfo * info) +static void Blit1to4Key(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; Uint8 *src = info->src; int srcskip = info->src_skip; - Uint32 *dstp = (Uint32 *) info->dst; + Uint32 *dstp = (Uint32 *)info->dst; int dstskip = info->dst_skip; - Uint32 *palmap = (Uint32 *) info->table; + Uint32 *palmap = (Uint32 *)info->table; Uint32 ckey = info->colorkey; /* Set up some basic variables */ @@ -429,8 +421,7 @@ Blit1to4Key(SDL_BlitInfo * info) } } -static void -Blit1toNAlpha(SDL_BlitInfo * info) +static void Blit1toNAlpha(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -469,8 +460,7 @@ Blit1toNAlpha(SDL_BlitInfo * info) } } -static void -Blit1toNAlphaKey(SDL_BlitInfo * info) +static void Blit1toNAlphaKey(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -513,15 +503,15 @@ Blit1toNAlphaKey(SDL_BlitInfo * info) } static const SDL_BlitFunc one_blit[] = { - (SDL_BlitFunc) NULL, Blit1to1, Blit1to2, Blit1to3, Blit1to4 + (SDL_BlitFunc)NULL, Blit1to1, Blit1to2, Blit1to3, Blit1to4 }; static const SDL_BlitFunc one_blitkey[] = { - (SDL_BlitFunc) NULL, Blit1to1Key, Blit1to2Key, Blit1to3Key, Blit1to4Key + (SDL_BlitFunc)NULL, Blit1to1Key, Blit1to2Key, Blit1to3Key, Blit1to4Key }; SDL_BlitFunc -SDL_CalculateBlit1(SDL_Surface * surface) +SDL_CalculateBlit1(SDL_Surface *surface) { int which; SDL_PixelFormat *dstfmt; @@ -543,12 +533,12 @@ SDL_CalculateBlit1(SDL_Surface * surface) /* Supporting 8bpp->8bpp alpha is doable but requires lots of tables which consume space and takes time to precompute, so is better left to the user */ - return which >= 2 ? Blit1toNAlpha : (SDL_BlitFunc) NULL; + return which >= 2 ? Blit1toNAlpha : (SDL_BlitFunc)NULL; case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: - return which >= 2 ? Blit1toNAlphaKey : (SDL_BlitFunc) NULL; + return which >= 2 ? Blit1toNAlphaKey : (SDL_BlitFunc)NULL; } - return (SDL_BlitFunc) NULL; + return (SDL_BlitFunc)NULL; } #endif /* SDL_HAVE_BLIT_1 */ diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c index 1a181ab17..87d3ec7ce 100644 --- a/src/video/SDL_blit_A.c +++ b/src/video/SDL_blit_A.c @@ -28,8 +28,7 @@ /* Functions to perform alpha blended blitting */ /* N->1 blending with per-surface alpha */ -static void -BlitNto1SurfaceAlpha(SDL_BlitInfo * info) +static void BlitNto1SurfaceAlpha(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -75,8 +74,7 @@ BlitNto1SurfaceAlpha(SDL_BlitInfo * info) } /* N->1 blending with pixel alpha */ -static void -BlitNto1PixelAlpha(SDL_BlitInfo * info) +static void BlitNto1PixelAlpha(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -121,8 +119,7 @@ BlitNto1PixelAlpha(SDL_BlitInfo * info) } /* colorkeyed N->1 blending with per-surface alpha */ -static void -BlitNto1SurfaceAlphaKey(SDL_BlitInfo * info) +static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -173,51 +170,49 @@ BlitNto1SurfaceAlphaKey(SDL_BlitInfo * info) #ifdef __MMX__ /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ -static void -BlitRGBtoRGBSurfaceAlpha128MMX(SDL_BlitInfo * info) +static void BlitRGBtoRGBSurfaceAlpha128MMX(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; - Uint32 *srcp = (Uint32 *) info->src; + Uint32 *srcp = (Uint32 *)info->src; int srcskip = info->src_skip >> 2; - Uint32 *dstp = (Uint32 *) info->dst; + Uint32 *dstp = (Uint32 *)info->dst; int dstskip = info->dst_skip >> 2; Uint32 dalpha = info->dst_fmt->Amask; __m64 src1, src2, dst1, dst2, lmask, hmask, dsta; - hmask = _mm_set_pi32(0x00fefefe, 0x00fefefe); /* alpha128 mask -> hmask */ - lmask = _mm_set_pi32(0x00010101, 0x00010101); /* !alpha128 mask -> lmask */ - dsta = _mm_set_pi32(dalpha, dalpha); /* dst alpha mask -> dsta */ + hmask = _mm_set_pi32(0x00fefefe, 0x00fefefe); /* alpha128 mask -> hmask */ + lmask = _mm_set_pi32(0x00010101, 0x00010101); /* !alpha128 mask -> lmask */ + dsta = _mm_set_pi32(dalpha, dalpha); /* dst alpha mask -> dsta */ while (height--) { int n = width; if (n & 1) { Uint32 s = *srcp++; Uint32 d = *dstp; - *dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1) - + (s & d & 0x00010101)) | dalpha; + *dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1) + (s & d & 0x00010101)) | dalpha; n--; } for (n >>= 1; n > 0; --n) { - dst1 = *(__m64 *) dstp; /* 2 x dst -> dst1(ARGBARGB) */ - dst2 = dst1; /* 2 x dst -> dst2(ARGBARGB) */ + dst1 = *(__m64 *)dstp; /* 2 x dst -> dst1(ARGBARGB) */ + dst2 = dst1; /* 2 x dst -> dst2(ARGBARGB) */ - src1 = *(__m64 *) srcp; /* 2 x src -> src1(ARGBARGB) */ - src2 = src1; /* 2 x src -> src2(ARGBARGB) */ + src1 = *(__m64 *)srcp; /* 2 x src -> src1(ARGBARGB) */ + src2 = src1; /* 2 x src -> src2(ARGBARGB) */ - dst2 = _mm_and_si64(dst2, hmask); /* dst & mask -> dst2 */ - src2 = _mm_and_si64(src2, hmask); /* src & mask -> src2 */ - src2 = _mm_add_pi32(src2, dst2); /* dst2 + src2 -> src2 */ - src2 = _mm_srli_pi32(src2, 1); /* src2 >> 1 -> src2 */ + dst2 = _mm_and_si64(dst2, hmask); /* dst & mask -> dst2 */ + src2 = _mm_and_si64(src2, hmask); /* src & mask -> src2 */ + src2 = _mm_add_pi32(src2, dst2); /* dst2 + src2 -> src2 */ + src2 = _mm_srli_pi32(src2, 1); /* src2 >> 1 -> src2 */ - dst1 = _mm_and_si64(dst1, src1); /* src & dst -> dst1 */ - dst1 = _mm_and_si64(dst1, lmask); /* dst1 & !mask -> dst1 */ - dst1 = _mm_add_pi32(dst1, src2); /* src2 + dst1 -> dst1 */ - dst1 = _mm_or_si64(dst1, dsta); /* dsta(full alpha) | dst1 -> dst1 */ + dst1 = _mm_and_si64(dst1, src1); /* src & dst -> dst1 */ + dst1 = _mm_and_si64(dst1, lmask); /* dst1 & !mask -> dst1 */ + dst1 = _mm_add_pi32(dst1, src2); /* src2 + dst1 -> dst1 */ + dst1 = _mm_or_si64(dst1, dsta); /* dsta(full alpha) | dst1 -> dst1 */ - *(__m64 *) dstp = dst1; /* dst1 -> 2 x dst pixels */ + *(__m64 *)dstp = dst1; /* dst1 -> 2 x dst pixels */ dstp += 2; srcp += 2; } @@ -229,8 +224,7 @@ BlitRGBtoRGBSurfaceAlpha128MMX(SDL_BlitInfo * info) } /* fast RGB888->(A)RGB888 blending with surface alpha */ -static void -BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo * info) +static void BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo *info) { SDL_PixelFormat *df = info->dst_fmt; Uint32 chanmask; @@ -242,45 +236,44 @@ BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo * info) } else { int width = info->dst_w; int height = info->dst_h; - Uint32 *srcp = (Uint32 *) info->src; + Uint32 *srcp = (Uint32 *)info->src; int srcskip = info->src_skip >> 2; - Uint32 *dstp = (Uint32 *) info->dst; + Uint32 *dstp = (Uint32 *)info->dst; int dstskip = info->dst_skip >> 2; Uint32 dalpha = df->Amask; Uint32 amult; __m64 src1, src2, dst1, dst2, mm_alpha, mm_zero, dsta; - mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ + mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ /* form the alpha mult */ amult = alpha | (alpha << 8); amult = amult | (amult << 16); chanmask = - (0xff << df->Rshift) | (0xff << df-> - Gshift) | (0xff << df->Bshift); + (0xff << df->Rshift) | (0xff << df->Gshift) | (0xff << df->Bshift); mm_alpha = _mm_set_pi32(0, amult & chanmask); /* 0000AAAA -> mm_alpha, minus 1 chan */ mm_alpha = _mm_unpacklo_pi8(mm_alpha, mm_zero); /* 0A0A0A0A -> mm_alpha, minus 1 chan */ /* at this point mm_alpha can be 000A0A0A or 0A0A0A00 or another combo */ - dsta = _mm_set_pi32(dalpha, dalpha); /* dst alpha mask -> dsta */ + dsta = _mm_set_pi32(dalpha, dalpha); /* dst alpha mask -> dsta */ while (height--) { int n = width; if (n & 1) { /* One Pixel Blend */ - src2 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src2 (0000ARGB) */ + src2 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src2 (0000ARGB) */ src2 = _mm_unpacklo_pi8(src2, mm_zero); /* 0A0R0G0B -> src2 */ - dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB) */ + dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB) */ dst1 = _mm_unpacklo_pi8(dst1, mm_zero); /* 0A0R0G0B -> dst1 */ - src2 = _mm_sub_pi16(src2, dst1); /* src2 - dst2 -> src2 */ - src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ - src2 = _mm_srli_pi16(src2, 8); /* src2 >> 8 -> src2 */ - dst1 = _mm_add_pi8(src2, dst1); /* src2 + dst1 -> dst1 */ + src2 = _mm_sub_pi16(src2, dst1); /* src2 - dst2 -> src2 */ + src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ + src2 = _mm_srli_pi16(src2, 8); /* src2 >> 8 -> src2 */ + dst1 = _mm_add_pi8(src2, dst1); /* src2 + dst1 -> dst1 */ - dst1 = _mm_packs_pu16(dst1, mm_zero); /* 0000ARGB -> dst1 */ - dst1 = _mm_or_si64(dst1, dsta); /* dsta | dst1 -> dst1 */ - *dstp = _mm_cvtsi64_si32(dst1); /* dst1 -> pixel */ + dst1 = _mm_packs_pu16(dst1, mm_zero); /* 0000ARGB -> dst1 */ + dst1 = _mm_or_si64(dst1, dsta); /* dsta | dst1 -> dst1 */ + *dstp = _mm_cvtsi64_si32(dst1); /* dst1 -> pixel */ ++srcp; ++dstp; @@ -290,30 +283,30 @@ BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo * info) for (n >>= 1; n > 0; --n) { /* Two Pixels Blend */ - src1 = *(__m64 *) srcp; /* 2 x src -> src1(ARGBARGB) */ - src2 = src1; /* 2 x src -> src2(ARGBARGB) */ + src1 = *(__m64 *)srcp; /* 2 x src -> src1(ARGBARGB) */ + src2 = src1; /* 2 x src -> src2(ARGBARGB) */ src1 = _mm_unpacklo_pi8(src1, mm_zero); /* low - 0A0R0G0B -> src1 */ src2 = _mm_unpackhi_pi8(src2, mm_zero); /* high - 0A0R0G0B -> src2 */ - dst1 = *(__m64 *) dstp; /* 2 x dst -> dst1(ARGBARGB) */ - dst2 = dst1; /* 2 x dst -> dst2(ARGBARGB) */ + dst1 = *(__m64 *)dstp; /* 2 x dst -> dst1(ARGBARGB) */ + dst2 = dst1; /* 2 x dst -> dst2(ARGBARGB) */ dst1 = _mm_unpacklo_pi8(dst1, mm_zero); /* low - 0A0R0G0B -> dst1 */ dst2 = _mm_unpackhi_pi8(dst2, mm_zero); /* high - 0A0R0G0B -> dst2 */ - src1 = _mm_sub_pi16(src1, dst1); /* src1 - dst1 -> src1 */ - src1 = _mm_mullo_pi16(src1, mm_alpha); /* src1 * alpha -> src1 */ - src1 = _mm_srli_pi16(src1, 8); /* src1 >> 8 -> src1 */ - dst1 = _mm_add_pi8(src1, dst1); /* src1 + dst1(dst1) -> dst1 */ + src1 = _mm_sub_pi16(src1, dst1); /* src1 - dst1 -> src1 */ + src1 = _mm_mullo_pi16(src1, mm_alpha); /* src1 * alpha -> src1 */ + src1 = _mm_srli_pi16(src1, 8); /* src1 >> 8 -> src1 */ + dst1 = _mm_add_pi8(src1, dst1); /* src1 + dst1(dst1) -> dst1 */ - src2 = _mm_sub_pi16(src2, dst2); /* src2 - dst2 -> src2 */ - src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ - src2 = _mm_srli_pi16(src2, 8); /* src2 >> 8 -> src2 */ - dst2 = _mm_add_pi8(src2, dst2); /* src2 + dst2(dst2) -> dst2 */ + src2 = _mm_sub_pi16(src2, dst2); /* src2 - dst2 -> src2 */ + src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ + src2 = _mm_srli_pi16(src2, 8); /* src2 >> 8 -> src2 */ + dst2 = _mm_add_pi8(src2, dst2); /* src2 + dst2(dst2) -> dst2 */ - dst1 = _mm_packs_pu16(dst1, dst2); /* 0A0R0G0B(res1), 0A0R0G0B(res2) -> dst1(ARGBARGB) */ - dst1 = _mm_or_si64(dst1, dsta); /* dsta | dst1 -> dst1 */ + dst1 = _mm_packs_pu16(dst1, dst2); /* 0A0R0G0B(res1), 0A0R0G0B(res2) -> dst1(ARGBARGB) */ + dst1 = _mm_or_si64(dst1, dsta); /* dsta | dst1 -> dst1 */ - *(__m64 *) dstp = dst1; /* dst1 -> 2 x pixel */ + *(__m64 *)dstp = dst1; /* dst1 -> 2 x pixel */ srcp += 2; dstp += 2; @@ -326,14 +319,13 @@ BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo * info) } /* fast ARGB888->(A)RGB888 blending with pixel alpha */ -static void -BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info) +static void BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; - Uint32 *srcp = (Uint32 *) info->src; + Uint32 *srcp = (Uint32 *)info->src; int srcskip = info->src_skip >> 2; - Uint32 *dstp = (Uint32 *) info->dst; + Uint32 *dstp = (Uint32 *)info->dst; int dstskip = info->dst_skip >> 2; SDL_PixelFormat *sf = info->src_fmt; Uint32 amask = sf->Amask; @@ -342,7 +334,7 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info) __m64 src1, dst1, mm_alpha, mm_zero, mm_alpha2; - mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ + mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ multmask = 0x00FF; multmask <<= (ashift * 2); multmask2 = 0x00FF00FF00FF00FFULL; @@ -394,8 +386,7 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info) #if SDL_ARM_SIMD_BLITTERS void BlitARGBto565PixelAlphaARMSIMDAsm(int32_t w, int32_t h, uint16_t *dst, int32_t dst_stride, uint32_t *src, int32_t src_stride); -static void -BlitARGBto565PixelAlphaARMSIMD(SDL_BlitInfo * info) +static void BlitARGBto565PixelAlphaARMSIMD(SDL_BlitInfo *info) { int32_t width = info->dst_w; int32_t height = info->dst_h; @@ -409,8 +400,7 @@ BlitARGBto565PixelAlphaARMSIMD(SDL_BlitInfo * info) void BlitRGBtoRGBPixelAlphaARMSIMDAsm(int32_t w, int32_t h, uint32_t *dst, int32_t dst_stride, uint32_t *src, int32_t src_stride); -static void -BlitRGBtoRGBPixelAlphaARMSIMD(SDL_BlitInfo * info) +static void BlitRGBtoRGBPixelAlphaARMSIMD(SDL_BlitInfo *info) { int32_t width = info->dst_w; int32_t height = info->dst_h; @@ -426,8 +416,7 @@ BlitRGBtoRGBPixelAlphaARMSIMD(SDL_BlitInfo * info) #if SDL_ARM_NEON_BLITTERS void BlitARGBto565PixelAlphaARMNEONAsm(int32_t w, int32_t h, uint16_t *dst, int32_t dst_stride, uint32_t *src, int32_t src_stride); -static void -BlitARGBto565PixelAlphaARMNEON(SDL_BlitInfo * info) +static void BlitARGBto565PixelAlphaARMNEON(SDL_BlitInfo *info) { int32_t width = info->dst_w; int32_t height = info->dst_h; @@ -441,8 +430,7 @@ BlitARGBto565PixelAlphaARMNEON(SDL_BlitInfo * info) void BlitRGBtoRGBPixelAlphaARMNEONAsm(int32_t w, int32_t h, uint32_t *dst, int32_t dst_stride, uint32_t *src, int32_t src_stride); -static void -BlitRGBtoRGBPixelAlphaARMNEON(SDL_BlitInfo * info) +static void BlitRGBtoRGBPixelAlphaARMNEON(SDL_BlitInfo *info) { int32_t width = info->dst_w; int32_t height = info->dst_h; @@ -456,14 +444,13 @@ BlitRGBtoRGBPixelAlphaARMNEON(SDL_BlitInfo * info) #endif /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ -static void -BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo * info) +static void BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; - Uint32 *srcp = (Uint32 *) info->src; + Uint32 *srcp = (Uint32 *)info->src; int srcskip = info->src_skip >> 2; - Uint32 *dstp = (Uint32 *) info->dst; + Uint32 *dstp = (Uint32 *)info->dst; int dstskip = info->dst_skip >> 2; while (height--) { @@ -481,8 +468,7 @@ BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo * info) } /* fast RGB888->(A)RGB888 blending with surface alpha */ -static void -BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo * info) +static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo *info) { unsigned alpha = info->a; if (alpha == 128) { @@ -490,9 +476,9 @@ BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo * info) } else { int width = info->dst_w; int height = info->dst_h; - Uint32 *srcp = (Uint32 *) info->src; + Uint32 *srcp = (Uint32 *)info->src; int srcskip = info->src_skip >> 2; - Uint32 *dstp = (Uint32 *) info->dst; + Uint32 *dstp = (Uint32 *)info->dst; int dstskip = info->dst_skip >> 2; Uint32 s; Uint32 d; @@ -523,14 +509,13 @@ BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo * info) } /* fast ARGB888->(A)RGB888 blending with pixel alpha */ -static void -BlitRGBtoRGBPixelAlpha(SDL_BlitInfo * info) +static void BlitRGBtoRGBPixelAlpha(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; - Uint32 *srcp = (Uint32 *) info->src; + Uint32 *srcp = (Uint32 *)info->src; int srcskip = info->src_skip >> 2; - Uint32 *dstp = (Uint32 *) info->dst; + Uint32 *dstp = (Uint32 *)info->dst; int dstskip = info->dst_skip >> 2; while (height--) { @@ -576,14 +561,13 @@ BlitRGBtoRGBPixelAlpha(SDL_BlitInfo * info) } /* fast ARGB888->(A)BGR888 blending with pixel alpha */ -static void -BlitRGBtoBGRPixelAlpha(SDL_BlitInfo * info) +static void BlitRGBtoBGRPixelAlpha(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; - Uint32 *srcp = (Uint32 *) info->src; + Uint32 *srcp = (Uint32 *)info->src; int srcskip = info->src_skip >> 2; - Uint32 *dstp = (Uint32 *) info->dst; + Uint32 *dstp = (Uint32 *)info->dst; int dstskip = info->dst_skip >> 2; while (height--) { @@ -632,14 +616,13 @@ BlitRGBtoBGRPixelAlpha(SDL_BlitInfo * info) #ifdef __3dNOW__ /* fast (as in MMX with prefetch) ARGB888->(A)RGB888 blending with pixel alpha */ -static void -BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info) +static void BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; - Uint32 *srcp = (Uint32 *) info->src; + Uint32 *srcp = (Uint32 *)info->src; int srcskip = info->src_skip >> 2; - Uint32 *dstp = (Uint32 *) info->dst; + Uint32 *dstp = (Uint32 *)info->dst; int dstskip = info->dst_skip >> 2; SDL_PixelFormat *sf = info->src_fmt; Uint32 amask = sf->Amask; @@ -648,7 +631,7 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info) __m64 src1, dst1, mm_alpha, mm_zero, mm_alpha2; - mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ + mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ multmask = 0x00FF; multmask <<= (ashift * 2); multmask2 = 0x00FF00FF00FF00FFULL; @@ -706,26 +689,24 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info) /* 16bpp special case for per-surface alpha=50%: blend 2 pixels in parallel */ /* blend a single 16 bit pixel at 50% */ -#define BLEND16_50(d, s, mask) \ +#define BLEND16_50(d, s, mask) \ ((((s & mask) + (d & mask)) >> 1) + (s & d & (~mask & 0xffff))) /* blend two 16 bit pixels at 50% */ -#define BLEND2x16_50(d, s, mask) \ - (((s & (mask | mask << 16)) >> 1) + ((d & (mask | mask << 16)) >> 1) \ - + (s & d & (~(mask | mask << 16)))) +#define BLEND2x16_50(d, s, mask) \ + (((s & (mask | mask << 16)) >> 1) + ((d & (mask | mask << 16)) >> 1) + (s & d & (~(mask | mask << 16)))) -static void -Blit16to16SurfaceAlpha128(SDL_BlitInfo * info, Uint16 mask) +static void Blit16to16SurfaceAlpha128(SDL_BlitInfo *info, Uint16 mask) { int width = info->dst_w; int height = info->dst_h; - Uint16 *srcp = (Uint16 *) info->src; + Uint16 *srcp = (Uint16 *)info->src; int srcskip = info->src_skip >> 1; - Uint16 *dstp = (Uint16 *) info->dst; + Uint16 *dstp = (Uint16 *)info->dst; int dstskip = info->dst_skip >> 1; while (height--) { - if (((uintptr_t) srcp ^ (uintptr_t) dstp) & 2) { + if (((uintptr_t)srcp ^ (uintptr_t)dstp) & 2) { /* * Source and destination not aligned, pipeline it. * This is mostly a win for big blits but no loss for @@ -735,29 +716,29 @@ Blit16to16SurfaceAlpha128(SDL_BlitInfo * info, Uint16 mask) int w = width; /* handle odd destination */ - if ((uintptr_t) dstp & 2) { + if ((uintptr_t)dstp & 2) { Uint16 d = *dstp, s = *srcp; *dstp = BLEND16_50(d, s, mask); dstp++; srcp++; w--; } - srcp++; /* srcp is now 32-bit aligned */ + srcp++; /* srcp is now 32-bit aligned */ /* bootstrap pipeline with first halfword */ - prev_sw = ((Uint32 *) srcp)[-1]; + prev_sw = ((Uint32 *)srcp)[-1]; while (w > 1) { Uint32 sw, dw, s; - sw = *(Uint32 *) srcp; - dw = *(Uint32 *) dstp; + sw = *(Uint32 *)srcp; + dw = *(Uint32 *)dstp; #if SDL_BYTEORDER == SDL_BIG_ENDIAN s = (prev_sw << 16) + (sw >> 16); #else s = (prev_sw >> 16) + (sw << 16); #endif prev_sw = sw; - *(Uint32 *) dstp = BLEND2x16_50(dw, s, mask); + *(Uint32 *)dstp = BLEND2x16_50(dw, s, mask); dstp += 2; srcp += 2; w -= 2; @@ -767,9 +748,9 @@ Blit16to16SurfaceAlpha128(SDL_BlitInfo * info, Uint16 mask) if (w) { Uint16 d = *dstp, s; #if SDL_BYTEORDER == SDL_BIG_ENDIAN - s = (Uint16) prev_sw; + s = (Uint16)prev_sw; #else - s = (Uint16) (prev_sw >> 16); + s = (Uint16)(prev_sw >> 16); #endif *dstp = BLEND16_50(d, s, mask); srcp++; @@ -782,7 +763,7 @@ Blit16to16SurfaceAlpha128(SDL_BlitInfo * info, Uint16 mask) int w = width; /* first odd pixel? */ - if ((uintptr_t) srcp & 2) { + if ((uintptr_t)srcp & 2) { Uint16 d = *dstp, s = *srcp; *dstp = BLEND16_50(d, s, mask); srcp++; @@ -792,9 +773,9 @@ Blit16to16SurfaceAlpha128(SDL_BlitInfo * info, Uint16 mask) /* srcp and dstp are now 32-bit aligned */ while (w > 1) { - Uint32 sw = *(Uint32 *) srcp; - Uint32 dw = *(Uint32 *) dstp; - *(Uint32 *) dstp = BLEND2x16_50(dw, sw, mask); + Uint32 sw = *(Uint32 *)srcp; + Uint32 dw = *(Uint32 *)dstp; + *(Uint32 *)dstp = BLEND2x16_50(dw, sw, mask); srcp += 2; dstp += 2; w -= 2; @@ -816,8 +797,7 @@ Blit16to16SurfaceAlpha128(SDL_BlitInfo * info, Uint16 mask) #ifdef __MMX__ /* fast RGB565->RGB565 blending with surface alpha */ -static void -Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info) +static void Blit565to565SurfaceAlphaMMX(SDL_BlitInfo *info) { unsigned alpha = info->a; if (alpha == 128) { @@ -825,27 +805,27 @@ Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info) } else { int width = info->dst_w; int height = info->dst_h; - Uint16 *srcp = (Uint16 *) info->src; + Uint16 *srcp = (Uint16 *)info->src; int srcskip = info->src_skip >> 1; - Uint16 *dstp = (Uint16 *) info->dst; + Uint16 *dstp = (Uint16 *)info->dst; int dstskip = info->dst_skip >> 1; Uint32 s, d; __m64 src1, dst1, src2, dst2, gmask, bmask, mm_res, mm_alpha; - alpha &= ~(1 + 2 + 4); /* cut alpha to get the exact same behaviour */ - mm_alpha = _mm_set_pi32(0, alpha); /* 0000000A -> mm_alpha */ - alpha >>= 3; /* downscale alpha to 5 bits */ + alpha &= ~(1 + 2 + 4); /* cut alpha to get the exact same behaviour */ + mm_alpha = _mm_set_pi32(0, alpha); /* 0000000A -> mm_alpha */ + alpha >>= 3; /* downscale alpha to 5 bits */ - mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ - mm_alpha = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha */ + mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ + mm_alpha = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha */ /* position alpha to allow for mullo and mulhi on diff channels to reduce the number of operations */ mm_alpha = _mm_slli_si64(mm_alpha, 3); /* Setup the 565 color channel masks */ - gmask = _mm_set_pi32(0x07E007E0, 0x07E007E0); /* MASKGREEN -> gmask */ - bmask = _mm_set_pi32(0x001F001F, 0x001F001F); /* MASKBLUE -> bmask */ + gmask = _mm_set_pi32(0x07E007E0, 0x07E007E0); /* MASKGREEN -> gmask */ + bmask = _mm_set_pi32(0x001F001F, 0x001F001F); /* MASKBLUE -> bmask */ while (height--) { /* *INDENT-OFF* */ /* clang-format off */ @@ -953,8 +933,7 @@ Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info) } /* fast RGB555->RGB555 blending with surface alpha */ -static void -Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info) +static void Blit555to555SurfaceAlphaMMX(SDL_BlitInfo *info) { unsigned alpha = info->a; if (alpha == 128) { @@ -962,28 +941,28 @@ Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info) } else { int width = info->dst_w; int height = info->dst_h; - Uint16 *srcp = (Uint16 *) info->src; + Uint16 *srcp = (Uint16 *)info->src; int srcskip = info->src_skip >> 1; - Uint16 *dstp = (Uint16 *) info->dst; + Uint16 *dstp = (Uint16 *)info->dst; int dstskip = info->dst_skip >> 1; Uint32 s, d; __m64 src1, dst1, src2, dst2, rmask, gmask, bmask, mm_res, mm_alpha; - alpha &= ~(1 + 2 + 4); /* cut alpha to get the exact same behaviour */ - mm_alpha = _mm_set_pi32(0, alpha); /* 0000000A -> mm_alpha */ - alpha >>= 3; /* downscale alpha to 5 bits */ + alpha &= ~(1 + 2 + 4); /* cut alpha to get the exact same behaviour */ + mm_alpha = _mm_set_pi32(0, alpha); /* 0000000A -> mm_alpha */ + alpha >>= 3; /* downscale alpha to 5 bits */ - mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ - mm_alpha = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha */ + mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ + mm_alpha = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha */ /* position alpha to allow for mullo and mulhi on diff channels to reduce the number of operations */ mm_alpha = _mm_slli_si64(mm_alpha, 3); /* Setup the 555 color channel masks */ - rmask = _mm_set_pi32(0x7C007C00, 0x7C007C00); /* MASKRED -> rmask */ - gmask = _mm_set_pi32(0x03E003E0, 0x03E003E0); /* MASKGREEN -> gmask */ - bmask = _mm_set_pi32(0x001F001F, 0x001F001F); /* MASKBLUE -> bmask */ + rmask = _mm_set_pi32(0x7C007C00, 0x7C007C00); /* MASKRED -> rmask */ + gmask = _mm_set_pi32(0x03E003E0, 0x03E003E0); /* MASKGREEN -> gmask */ + bmask = _mm_set_pi32(0x001F001F, 0x001F001F); /* MASKBLUE -> bmask */ while (height--) { /* *INDENT-OFF* */ /* clang-format off */ @@ -1093,8 +1072,7 @@ Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info) #endif /* __MMX__ */ /* fast RGB565->RGB565 blending with surface alpha */ -static void -Blit565to565SurfaceAlpha(SDL_BlitInfo * info) +static void Blit565to565SurfaceAlpha(SDL_BlitInfo *info) { unsigned alpha = info->a; if (alpha == 128) { @@ -1102,11 +1080,11 @@ Blit565to565SurfaceAlpha(SDL_BlitInfo * info) } else { int width = info->dst_w; int height = info->dst_h; - Uint16 *srcp = (Uint16 *) info->src; + Uint16 *srcp = (Uint16 *)info->src; int srcskip = info->src_skip >> 1; - Uint16 *dstp = (Uint16 *) info->dst; + Uint16 *dstp = (Uint16 *)info->dst; int dstskip = info->dst_skip >> 1; - alpha >>= 3; /* downscale alpha to 5 bits */ + alpha >>= 3; /* downscale alpha to 5 bits */ while (height--) { /* *INDENT-OFF* */ /* clang-format off */ @@ -1132,20 +1110,19 @@ Blit565to565SurfaceAlpha(SDL_BlitInfo * info) } /* fast RGB555->RGB555 blending with surface alpha */ -static void -Blit555to555SurfaceAlpha(SDL_BlitInfo * info) +static void Blit555to555SurfaceAlpha(SDL_BlitInfo *info) { - unsigned alpha = info->a; /* downscale alpha to 5 bits */ + unsigned alpha = info->a; /* downscale alpha to 5 bits */ if (alpha == 128) { Blit16to16SurfaceAlpha128(info, 0xfbde); } else { int width = info->dst_w; int height = info->dst_h; - Uint16 *srcp = (Uint16 *) info->src; + Uint16 *srcp = (Uint16 *)info->src; int srcskip = info->src_skip >> 1; - Uint16 *dstp = (Uint16 *) info->dst; + Uint16 *dstp = (Uint16 *)info->dst; int dstskip = info->dst_skip >> 1; - alpha >>= 3; /* downscale alpha to 5 bits */ + alpha >>= 3; /* downscale alpha to 5 bits */ while (height--) { /* *INDENT-OFF* */ /* clang-format off */ @@ -1171,14 +1148,13 @@ Blit555to555SurfaceAlpha(SDL_BlitInfo * info) } /* fast ARGB8888->RGB565 blending with pixel alpha */ -static void -BlitARGBto565PixelAlpha(SDL_BlitInfo * info) +static void BlitARGBto565PixelAlpha(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; - Uint32 *srcp = (Uint32 *) info->src; + Uint32 *srcp = (Uint32 *)info->src; int srcskip = info->src_skip >> 2; - Uint16 *dstp = (Uint16 *) info->dst; + Uint16 *dstp = (Uint16 *)info->dst; int dstskip = info->dst_skip >> 1; while (height--) { @@ -1217,14 +1193,13 @@ BlitARGBto565PixelAlpha(SDL_BlitInfo * info) } /* fast ARGB8888->RGB555 blending with pixel alpha */ -static void -BlitARGBto555PixelAlpha(SDL_BlitInfo * info) +static void BlitARGBto555PixelAlpha(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; - Uint32 *srcp = (Uint32 *) info->src; + Uint32 *srcp = (Uint32 *)info->src; int srcskip = info->src_skip >> 2; - Uint16 *dstp = (Uint16 *) info->dst; + Uint16 *dstp = (Uint16 *)info->dst; int dstskip = info->dst_skip >> 1; while (height--) { @@ -1264,8 +1239,7 @@ BlitARGBto555PixelAlpha(SDL_BlitInfo * info) } /* General (slow) N->N blending with per-surface alpha */ -static void -BlitNtoNSurfaceAlpha(SDL_BlitInfo * info) +static void BlitNtoNSurfaceAlpha(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -1284,7 +1258,7 @@ BlitNtoNSurfaceAlpha(SDL_BlitInfo * info) if (sA) { while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ /* clang-format off */ DUFFS_LOOP4( { DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB); @@ -1303,8 +1277,7 @@ BlitNtoNSurfaceAlpha(SDL_BlitInfo * info) } /* General (slow) colorkeyed N->N blending with per-surface alpha */ -static void -BlitNtoNSurfaceAlphaKey(SDL_BlitInfo * info) +static void BlitNtoNSurfaceAlphaKey(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -1344,8 +1317,7 @@ BlitNtoNSurfaceAlphaKey(SDL_BlitInfo * info) } /* General (slow) N->N blending with pixel alpha */ -static void -BlitNtoNPixelAlpha(SDL_BlitInfo * info) +static void BlitNtoNPixelAlpha(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -1385,9 +1357,8 @@ BlitNtoNPixelAlpha(SDL_BlitInfo * info) } } - SDL_BlitFunc -SDL_CalculateBlitA(SDL_Surface * surface) +SDL_CalculateBlitA(SDL_Surface *surface) { SDL_PixelFormat *sf = surface->format; SDL_PixelFormat *df = surface->map->dst->format; @@ -1406,27 +1377,20 @@ SDL_CalculateBlitA(SDL_Surface * surface) case 2: #if SDL_ARM_NEON_BLITTERS || SDL_ARM_SIMD_BLITTERS - if (sf->BytesPerPixel == 4 && sf->Amask == 0xff000000 - && sf->Gmask == 0xff00 && df->Gmask == 0x7e0 - && ((sf->Rmask == 0xff && df->Rmask == 0x1f) - || (sf->Bmask == 0xff && df->Bmask == 0x1f))) - { + if (sf->BytesPerPixel == 4 && sf->Amask == 0xff000000 && sf->Gmask == 0xff00 && df->Gmask == 0x7e0 && ((sf->Rmask == 0xff && df->Rmask == 0x1f) || (sf->Bmask == 0xff && df->Bmask == 0x1f))) { #if SDL_ARM_NEON_BLITTERS - if (SDL_HasNEON()) { - return BlitARGBto565PixelAlphaARMNEON; - } -#endif -#if SDL_ARM_SIMD_BLITTERS - if (SDL_HasARMSIMD()) { - return BlitARGBto565PixelAlphaARMSIMD; - } -#endif + if (SDL_HasNEON()) { + return BlitARGBto565PixelAlphaARMNEON; } #endif - if (sf->BytesPerPixel == 4 && sf->Amask == 0xff000000 - && sf->Gmask == 0xff00 - && ((sf->Rmask == 0xff && df->Rmask == 0x1f) - || (sf->Bmask == 0xff && df->Bmask == 0x1f))) { +#if SDL_ARM_SIMD_BLITTERS + if (SDL_HasARMSIMD()) { + return BlitARGBto565PixelAlphaARMSIMD; + } +#endif + } +#endif + if (sf->BytesPerPixel == 4 && sf->Amask == 0xff000000 && sf->Gmask == 0xff00 && ((sf->Rmask == 0xff && df->Rmask == 0x1f) || (sf->Bmask == 0xff && df->Bmask == 0x1f))) { if (df->Gmask == 0x7e0) { return BlitARGBto565PixelAlpha; } else if (df->Gmask == 0x3e0) { @@ -1436,14 +1400,9 @@ SDL_CalculateBlitA(SDL_Surface * surface) return BlitNtoNPixelAlpha; case 4: - if (sf->Rmask == df->Rmask - && sf->Gmask == df->Gmask - && sf->Bmask == df->Bmask && sf->BytesPerPixel == 4) { + if (sf->Rmask == df->Rmask && sf->Gmask == df->Gmask && sf->Bmask == df->Bmask && sf->BytesPerPixel == 4) { #if defined(__MMX__) || defined(__3dNOW__) - if (sf->Rshift % 8 == 0 - && sf->Gshift % 8 == 0 - && sf->Bshift % 8 == 0 - && sf->Ashift % 8 == 0 && sf->Aloss == 0) { + if (sf->Rshift % 8 == 0 && sf->Gshift % 8 == 0 && sf->Bshift % 8 == 0 && sf->Ashift % 8 == 0 && sf->Aloss == 0) { #ifdef __3dNOW__ if (SDL_Has3DNow()) { return BlitRGBtoRGBPixelAlphaMMX3DNOW; @@ -1469,9 +1428,7 @@ SDL_CalculateBlitA(SDL_Surface * surface) #endif return BlitRGBtoRGBPixelAlpha; } - } else if (sf->Rmask == df->Bmask - && sf->Gmask == df->Gmask - && sf->Bmask == df->Rmask && sf->BytesPerPixel == 4) { + } else if (sf->Rmask == df->Bmask && sf->Gmask == df->Gmask && sf->Bmask == df->Rmask && sf->BytesPerPixel == 4) { if (sf->Amask == 0xff000000) { return BlitRGBtoBGRPixelAlpha; } @@ -1517,9 +1474,7 @@ SDL_CalculateBlitA(SDL_Surface * surface) return BlitNtoNSurfaceAlpha; case 4: - if (sf->Rmask == df->Rmask - && sf->Gmask == df->Gmask - && sf->Bmask == df->Bmask && sf->BytesPerPixel == 4) { + if (sf->Rmask == df->Rmask && sf->Gmask == df->Gmask && sf->Bmask == df->Bmask && sf->BytesPerPixel == 4) { #ifdef __MMX__ if (sf->Rshift % 8 == 0 && sf->Gshift % 8 == 0 && sf->Bshift % 8 == 0 && SDL_HasMMX()) { return BlitRGBtoRGBSurfaceAlphaMMX; diff --git a/src/video/SDL_blit_N.c b/src/video/SDL_blit_N.c index 458b2840b..cac0bb403 100644 --- a/src/video/SDL_blit_N.c +++ b/src/video/SDL_blit_N.c @@ -28,19 +28,19 @@ #include "SDL_blit.h" #include "SDL_blit_copy.h" - /* General optimized routines that write char by char */ #define HAVE_FAST_WRITE_INT8 1 /* On some CPU, it's slower than combining and write a word */ -#if defined(__MIPS__) -# undef HAVE_FAST_WRITE_INT8 -# define HAVE_FAST_WRITE_INT8 0 +#if defined(__MIPS__) +#undef HAVE_FAST_WRITE_INT8 +#define HAVE_FAST_WRITE_INT8 0 #endif /* Functions to blit from N-bit surfaces to other surfaces */ -enum blit_features { +enum blit_features +{ BLIT_FEATURE_NONE = 0, BLIT_FEATURE_HAS_MMX = 1, BLIT_FEATURE_HAS_ALTIVEC = 2, @@ -61,7 +61,6 @@ GetL3CacheSize(void) u_int64_t result = 0; size_t typeSize = sizeof(result); - int err = sysctlbyname(key, &result, &typeSize, NULL, 0); if (0 != err) { return 0; @@ -84,24 +83,23 @@ GetL3CacheSize(void) #define VECUINT16_LITERAL(a,b,c,d,e,f,g,h) \ (vector unsigned short) ( a,b,c,d,e,f,g,h ) #else -#define VECUINT8_LITERAL(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \ - (vector unsigned char) { a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p } -#define VECUINT16_LITERAL(a,b,c,d,e,f,g,h) \ - (vector unsigned short) { a,b,c,d,e,f,g,h } +#define VECUINT8_LITERAL(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \ + (vector unsigned char) { a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p } +#define VECUINT16_LITERAL(a, b, c, d, e, f, g, h) \ + (vector unsigned short) { a, b, c, d, e, f, g, h } #endif -#define UNALIGNED_PTR(x) (((size_t) x) & 0x0000000F) -#define VSWIZZLE32(a,b,c,d) (vector unsigned char) \ - ( 0x00+a, 0x00+b, 0x00+c, 0x00+d, \ - 0x04+a, 0x04+b, 0x04+c, 0x04+d, \ - 0x08+a, 0x08+b, 0x08+c, 0x08+d, \ - 0x0C+a, 0x0C+b, 0x0C+c, 0x0C+d ) +#define UNALIGNED_PTR(x) (((size_t)x) & 0x0000000F) +#define VSWIZZLE32(a, b, c, d) (vector unsigned char)(0x00 + a, 0x00 + b, 0x00 + c, 0x00 + d, \ + 0x04 + a, 0x04 + b, 0x04 + c, 0x04 + d, \ + 0x08 + a, 0x08 + b, 0x08 + c, 0x08 + d, \ + 0x0C + a, 0x0C + b, 0x0C + c, 0x0C + d) -#define MAKE8888(dstfmt, r, g, b, a) \ - ( ((r<Rshift)&dstfmt->Rmask) | \ - ((g<Gshift)&dstfmt->Gmask) | \ - ((b<Bshift)&dstfmt->Bmask) | \ - ((a<Ashift)&dstfmt->Amask) ) +#define MAKE8888(dstfmt, r, g, b, a) \ + (((r << dstfmt->Rshift) & dstfmt->Rmask) | \ + ((g << dstfmt->Gshift) & dstfmt->Gmask) | \ + ((b << dstfmt->Bshift) & dstfmt->Bmask) | \ + ((a << dstfmt->Ashift) & dstfmt->Amask)) /* * Data Stream Touch...Altivec cache prefetching. @@ -109,20 +107,19 @@ GetL3CacheSize(void) * Don't use this on a G5...however, the speed boost is very significant * on a G4. */ -#define DST_CHAN_SRC 1 +#define DST_CHAN_SRC 1 #define DST_CHAN_DEST 2 /* macro to set DST control word value... */ #define DST_CTRL(size, count, stride) \ (((size) << 24) | ((count) << 16) | (stride)) -#define VEC_ALIGNER(src) ((UNALIGNED_PTR(src)) \ - ? vec_lvsl(0, src) \ - : vec_add(vec_lvsl(8, src), vec_splat_u8(8))) +#define VEC_ALIGNER(src) ((UNALIGNED_PTR(src)) \ + ? vec_lvsl(0, src) \ + : vec_add(vec_lvsl(8, src), vec_splat_u8(8))) /* Calculate the permute vector used for 32->32 swizzling */ -static vector unsigned char -calc_swizzle32(const SDL_PixelFormat * srcfmt, const SDL_PixelFormat * dstfmt) +static vector unsigned char calc_swizzle32(const SDL_PixelFormat *srcfmt, const SDL_PixelFormat *dstfmt) { /* * We have to assume that the bits that aren't used by other @@ -131,12 +128,7 @@ calc_swizzle32(const SDL_PixelFormat * srcfmt, const SDL_PixelFormat * dstfmt) */ /* ARGB */ static const struct SDL_PixelFormat default_pixel_format = { - 0, NULL, 0, 0, - {0, 0}, - 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000, - 0, 0, 0, 0, - 16, 8, 0, 24, - 0, NULL + 0, NULL, 0, 0, { 0, 0 }, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000, 0, 0, 0, 0, 16, 8, 0, 24, 0, NULL }; const vector unsigned char plus = VECUINT8_LITERAL(0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, @@ -162,8 +154,7 @@ calc_swizzle32(const SDL_PixelFormat * srcfmt, const SDL_PixelFormat * dstfmt) /* Use zero for alpha if either surface doesn't have alpha */ if (dstfmt->Amask) { amask = - ((srcfmt->Amask) ? RESHIFT(srcfmt-> - Ashift) : 0x10) << (dstfmt->Ashift); + ((srcfmt->Amask) ? RESHIFT(srcfmt->Ashift) : 0x10) << (dstfmt->Ashift); } else { amask = 0x10101010 & ((dstfmt->Rmask | dstfmt->Gmask | dstfmt->Bmask) ^ @@ -171,8 +162,8 @@ calc_swizzle32(const SDL_PixelFormat * srcfmt, const SDL_PixelFormat * dstfmt) } #undef RESHIFT - ((unsigned int *) (char *) &srcvec)[0] = (rmask | gmask | bmask | amask); - vswiz = vec_add(plus, (vector unsigned char) vec_splat(srcvec, 0)); + ((unsigned int *)(char *)&srcvec)[0] = (rmask | gmask | bmask | amask); + vswiz = vec_add(plus, (vector unsigned char)vec_splat(srcvec, 0)); return (vswiz); } @@ -183,7 +174,7 @@ static vector unsigned char reorder_ppc64le_vec(vector unsigned char vpermute) /* The result vector of calc_swizzle32 reorder bytes using vec_perm. The LE transformation for vec_perm has an implicit assumption that the permutation is being used to reorder vector elements, - not to reorder bytes within those elements. + not to reorder bytes within those elements. Unfortunatly the result order is not the expected one for powerpc little endian when the two first vector parameters of vec_perm are not of type 'vector char'. This is because the numbering from the @@ -193,25 +184,24 @@ static vector unsigned char reorder_ppc64le_vec(vector unsigned char vpermute) */ const vector unsigned char ppc64le_reorder = VECUINT8_LITERAL( - 0x01, 0x00, 0x03, 0x02, - 0x05, 0x04, 0x07, 0x06, - 0x09, 0x08, 0x0B, 0x0A, - 0x0D, 0x0C, 0x0F, 0x0E ); + 0x01, 0x00, 0x03, 0x02, + 0x05, 0x04, 0x07, 0x06, + 0x09, 0x08, 0x0B, 0x0A, + 0x0D, 0x0C, 0x0F, 0x0E); vector unsigned char vswiz_ppc64le; vswiz_ppc64le = vec_perm(vpermute, vpermute, ppc64le_reorder); - return(vswiz_ppc64le); + return (vswiz_ppc64le); } #endif -static void Blit_RGB888_RGB565(SDL_BlitInfo * info); -static void -Blit_RGB888_RGB565Altivec(SDL_BlitInfo * info) +static void Blit_RGB888_RGB565(SDL_BlitInfo *info); +static void Blit_RGB888_RGB565Altivec(SDL_BlitInfo *info) { int height = info->dst_h; - Uint8 *src = (Uint8 *) info->src; + Uint8 *src = (Uint8 *)info->src; int srcskip = info->src_skip; - Uint8 *dst = (Uint8 *) info->dst; + Uint8 *dst = (Uint8 *)info->dst; int dstskip = info->dst_skip; SDL_PixelFormat *srcfmt = info->src_fmt; vector unsigned char valpha = vec_splat_u8(0); @@ -228,7 +218,7 @@ Blit_RGB888_RGB565Altivec(SDL_BlitInfo * info) vector unsigned short vfc = VECUINT16_LITERAL(0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc); - vector unsigned short vf800 = (vector unsigned short) vec_splat_u8(-7); + vector unsigned short vf800 = (vector unsigned short)vec_splat_u8(-7); vf800 = vec_sl(vf800, vec_splat_u16(8)); while (height--) { @@ -240,24 +230,24 @@ Blit_RGB888_RGB565Altivec(SDL_BlitInfo * info) int extrawidth; /* do scalar until we can align... */ -#define ONE_PIXEL_BLEND(condition, widthvar) \ - while (condition) { \ - Uint32 Pixel; \ - unsigned sR, sG, sB, sA; \ - DISEMBLE_RGBA((Uint8 *)src, 4, srcfmt, Pixel, \ - sR, sG, sB, sA); \ - *(Uint16 *)(dst) = (((sR << 8) & 0x0000F800) | \ - ((sG << 3) & 0x000007E0) | \ - ((sB >> 3) & 0x0000001F)); \ - dst += 2; \ - src += 4; \ - widthvar--; \ - } +#define ONE_PIXEL_BLEND(condition, widthvar) \ + while (condition) { \ + Uint32 Pixel; \ + unsigned sR, sG, sB, sA; \ + DISEMBLE_RGBA((Uint8 *)src, 4, srcfmt, Pixel, \ + sR, sG, sB, sA); \ + *(Uint16 *)(dst) = (((sR << 8) & 0x0000F800) | \ + ((sG << 3) & 0x000007E0) | \ + ((sB >> 3) & 0x0000001F)); \ + dst += 2; \ + src += 4; \ + widthvar--; \ + } ONE_PIXEL_BLEND(((UNALIGNED_PTR(dst)) && (width)), width); /* After all that work, here's the vector part! */ - extrawidth = (width % 8); /* trailing unaligned stores */ + extrawidth = (width % 8); /* trailing unaligned stores */ width -= extrawidth; vsrc = vec_ld(0, src); valigner = VEC_ALIGNER(src); @@ -269,25 +259,25 @@ Blit_RGB888_RGB565Altivec(SDL_BlitInfo * info) voverflow = vec_ld(15, src); vsrc = vec_perm(vsrc, voverflow, valigner); - vsrc1 = (vector unsigned int) vec_perm(vsrc, valpha, vpermute); + vsrc1 = (vector unsigned int)vec_perm(vsrc, valpha, vpermute); src += 16; vsrc = voverflow; voverflow = vec_ld(15, src); vsrc = vec_perm(vsrc, voverflow, valigner); - vsrc2 = (vector unsigned int) vec_perm(vsrc, valpha, vpermute); + vsrc2 = (vector unsigned int)vec_perm(vsrc, valpha, vpermute); /* 1555 */ - vpixel = (vector unsigned short) vec_packpx(vsrc1, vsrc2); - vgpixel = (vector unsigned short) vec_perm(vsrc1, vsrc2, vgmerge); + vpixel = (vector unsigned short)vec_packpx(vsrc1, vsrc2); + vgpixel = (vector unsigned short)vec_perm(vsrc1, vsrc2, vgmerge); vgpixel = vec_and(vgpixel, vfc); vgpixel = vec_sl(vgpixel, v3); vrpixel = vec_sl(vpixel, v1); vrpixel = vec_and(vrpixel, vf800); vbpixel = vec_and(vpixel, v3f); vdst = - vec_or((vector unsigned char) vrpixel, - (vector unsigned char) vgpixel); + vec_or((vector unsigned char)vrpixel, + (vector unsigned char)vgpixel); /* 565 */ - vdst = vec_or(vdst, (vector unsigned char) vbpixel); + vdst = vec_or(vdst, (vector unsigned char)vbpixel); vec_st(vdst, 0, dst); width -= 8; @@ -302,20 +292,17 @@ Blit_RGB888_RGB565Altivec(SDL_BlitInfo * info) ONE_PIXEL_BLEND((extrawidth), extrawidth); #undef ONE_PIXEL_BLEND - src += srcskip; /* move to next row, accounting for pitch. */ + src += srcskip; /* move to next row, accounting for pitch. */ dst += dstskip; } - - } -static void -Blit_RGB565_32Altivec(SDL_BlitInfo * info) +static void Blit_RGB565_32Altivec(SDL_BlitInfo *info) { int height = info->dst_h; - Uint8 *src = (Uint8 *) info->src; + Uint8 *src = (Uint8 *)info->src; int srcskip = info->src_skip; - Uint8 *dst = (Uint8 *) info->dst; + Uint8 *dst = (Uint8 *)info->dst; int dstskip = info->dst_skip; SDL_PixelFormat *srcfmt = info->src_fmt; SDL_PixelFormat *dstfmt = info->dst_fmt; @@ -338,9 +325,7 @@ Blit_RGB565_32Altivec(SDL_BlitInfo * info) 0x10, 0x06, 0x01, 0x01); vector unsigned char vredalpha2 = - (vector unsigned - char) (vec_add((vector unsigned int) vredalpha1, vec_sl(v8, v16)) - ); + (vector unsigned char)(vec_add((vector unsigned int)vredalpha1, vec_sl(v8, v16))); /* 0x00 - 0x0f is ARxx ARxx ARxx ARxx 0x11 - 0x0f odds are blue @@ -350,8 +335,7 @@ Blit_RGB565_32Altivec(SDL_BlitInfo * info) 0x08, 0x09, 0x0a, 0x15, 0x0c, 0x0d, 0x0e, 0x17); vector unsigned char vblue2 = - (vector unsigned char) (vec_add((vector unsigned int) vblue1, v8) - ); + (vector unsigned char)(vec_add((vector unsigned int)vblue1, v8)); /* 0x00 - 0x0f is ARxB ARxB ARxB ARxB 0x10 - 0x0e evens are green @@ -361,18 +345,16 @@ Blit_RGB565_32Altivec(SDL_BlitInfo * info) 0x08, 0x09, 0x14, 0x0b, 0x0c, 0x0d, 0x16, 0x0f); vector unsigned char vgreen2 = - (vector unsigned - char) (vec_add((vector unsigned int) vgreen1, vec_sl(v8, v8)) - ); + (vector unsigned char)(vec_add((vector unsigned int)vgreen1, vec_sl(v8, v8))); SDL_assert(srcfmt->BytesPerPixel == 2); SDL_assert(dstfmt->BytesPerPixel == 4); - vf800 = (vector unsigned short) vec_splat_u8(-7); + vf800 = (vector unsigned short)vec_splat_u8(-7); vf800 = vec_sl(vf800, vec_splat_u16(8)); if (dstfmt->Amask && info->a) { - ((unsigned char *) &valpha)[0] = alpha = info->a; + ((unsigned char *)&valpha)[0] = alpha = info->a; valpha = vec_splat(valpha, 0); } else { alpha = 0; @@ -389,22 +371,22 @@ Blit_RGB565_32Altivec(SDL_BlitInfo * info) int extrawidth; /* do scalar until we can align... */ -#define ONE_PIXEL_BLEND(condition, widthvar) \ - while (condition) { \ - unsigned sR, sG, sB; \ - unsigned short Pixel = *((unsigned short *)src); \ - sR = (Pixel >> 8) & 0xf8; \ - sG = (Pixel >> 3) & 0xfc; \ - sB = (Pixel << 3) & 0xf8; \ - ASSEMBLE_RGBA(dst, 4, dstfmt, sR, sG, sB, alpha); \ - src += 2; \ - dst += 4; \ - widthvar--; \ - } +#define ONE_PIXEL_BLEND(condition, widthvar) \ + while (condition) { \ + unsigned sR, sG, sB; \ + unsigned short Pixel = *((unsigned short *)src); \ + sR = (Pixel >> 8) & 0xf8; \ + sG = (Pixel >> 3) & 0xfc; \ + sB = (Pixel << 3) & 0xf8; \ + ASSEMBLE_RGBA(dst, 4, dstfmt, sR, sG, sB, alpha); \ + src += 2; \ + dst += 4; \ + widthvar--; \ + } ONE_PIXEL_BLEND(((UNALIGNED_PTR(dst)) && (width)), width); /* After all that work, here's the vector part! */ - extrawidth = (width % 8); /* trailing unaligned stores */ + extrawidth = (width % 8); /* trailing unaligned stores */ width -= extrawidth; vsrc = vec_ld(0, src); valigner = VEC_ALIGNER(src); @@ -416,23 +398,23 @@ Blit_RGB565_32Altivec(SDL_BlitInfo * info) voverflow = vec_ld(15, src); vsrc = vec_perm(vsrc, voverflow, valigner); - vR = vec_and((vector unsigned short) vsrc, vf800); - vB = vec_sl((vector unsigned short) vsrc, v3); + vR = vec_and((vector unsigned short)vsrc, vf800); + vB = vec_sl((vector unsigned short)vsrc, v3); vG = vec_sl(vB, v2); vdst1 = - (vector unsigned char) vec_perm((vector unsigned char) vR, - valpha, vredalpha1); - vdst1 = vec_perm(vdst1, (vector unsigned char) vB, vblue1); - vdst1 = vec_perm(vdst1, (vector unsigned char) vG, vgreen1); + (vector unsigned char)vec_perm((vector unsigned char)vR, + valpha, vredalpha1); + vdst1 = vec_perm(vdst1, (vector unsigned char)vB, vblue1); + vdst1 = vec_perm(vdst1, (vector unsigned char)vG, vgreen1); vdst1 = vec_perm(vdst1, valpha, vpermute); vec_st(vdst1, 0, dst); vdst2 = - (vector unsigned char) vec_perm((vector unsigned char) vR, - valpha, vredalpha2); - vdst2 = vec_perm(vdst2, (vector unsigned char) vB, vblue2); - vdst2 = vec_perm(vdst2, (vector unsigned char) vG, vgreen2); + (vector unsigned char)vec_perm((vector unsigned char)vR, + valpha, vredalpha2); + vdst2 = vec_perm(vdst2, (vector unsigned char)vB, vblue2); + vdst2 = vec_perm(vdst2, (vector unsigned char)vG, vgreen2); vdst2 = vec_perm(vdst2, valpha, vpermute); vec_st(vdst2, 16, dst); @@ -444,25 +426,21 @@ Blit_RGB565_32Altivec(SDL_BlitInfo * info) SDL_assert(width == 0); - /* do scalar until we can align... */ ONE_PIXEL_BLEND((extrawidth), extrawidth); #undef ONE_PIXEL_BLEND - src += srcskip; /* move to next row, accounting for pitch. */ + src += srcskip; /* move to next row, accounting for pitch. */ dst += dstskip; } - } - -static void -Blit_RGB555_32Altivec(SDL_BlitInfo * info) +static void Blit_RGB555_32Altivec(SDL_BlitInfo *info) { int height = info->dst_h; - Uint8 *src = (Uint8 *) info->src; + Uint8 *src = (Uint8 *)info->src; int srcskip = info->src_skip; - Uint8 *dst = (Uint8 *) info->dst; + Uint8 *dst = (Uint8 *)info->dst; int dstskip = info->dst_skip; SDL_PixelFormat *srcfmt = info->src_fmt; SDL_PixelFormat *dstfmt = info->dst_fmt; @@ -485,9 +463,7 @@ Blit_RGB555_32Altivec(SDL_BlitInfo * info) 0x10, 0x06, 0x01, 0x01); vector unsigned char vredalpha2 = - (vector unsigned - char) (vec_add((vector unsigned int) vredalpha1, vec_sl(v8, v16)) - ); + (vector unsigned char)(vec_add((vector unsigned int)vredalpha1, vec_sl(v8, v16))); /* 0x00 - 0x0f is ARxx ARxx ARxx ARxx 0x11 - 0x0f odds are blue @@ -497,8 +473,7 @@ Blit_RGB555_32Altivec(SDL_BlitInfo * info) 0x08, 0x09, 0x0a, 0x15, 0x0c, 0x0d, 0x0e, 0x17); vector unsigned char vblue2 = - (vector unsigned char) (vec_add((vector unsigned int) vblue1, v8) - ); + (vector unsigned char)(vec_add((vector unsigned int)vblue1, v8)); /* 0x00 - 0x0f is ARxB ARxB ARxB ARxB 0x10 - 0x0e evens are green @@ -508,18 +483,16 @@ Blit_RGB555_32Altivec(SDL_BlitInfo * info) 0x08, 0x09, 0x14, 0x0b, 0x0c, 0x0d, 0x16, 0x0f); vector unsigned char vgreen2 = - (vector unsigned - char) (vec_add((vector unsigned int) vgreen1, vec_sl(v8, v8)) - ); + (vector unsigned char)(vec_add((vector unsigned int)vgreen1, vec_sl(v8, v8))); SDL_assert(srcfmt->BytesPerPixel == 2); SDL_assert(dstfmt->BytesPerPixel == 4); - vf800 = (vector unsigned short) vec_splat_u8(-7); + vf800 = (vector unsigned short)vec_splat_u8(-7); vf800 = vec_sl(vf800, vec_splat_u16(8)); if (dstfmt->Amask && info->a) { - ((unsigned char *) &valpha)[0] = alpha = info->a; + ((unsigned char *)&valpha)[0] = alpha = info->a; valpha = vec_splat(valpha, 0); } else { alpha = 0; @@ -536,22 +509,22 @@ Blit_RGB555_32Altivec(SDL_BlitInfo * info) int extrawidth; /* do scalar until we can align... */ -#define ONE_PIXEL_BLEND(condition, widthvar) \ - while (condition) { \ - unsigned sR, sG, sB; \ - unsigned short Pixel = *((unsigned short *)src); \ - sR = (Pixel >> 7) & 0xf8; \ - sG = (Pixel >> 2) & 0xf8; \ - sB = (Pixel << 3) & 0xf8; \ - ASSEMBLE_RGBA(dst, 4, dstfmt, sR, sG, sB, alpha); \ - src += 2; \ - dst += 4; \ - widthvar--; \ - } +#define ONE_PIXEL_BLEND(condition, widthvar) \ + while (condition) { \ + unsigned sR, sG, sB; \ + unsigned short Pixel = *((unsigned short *)src); \ + sR = (Pixel >> 7) & 0xf8; \ + sG = (Pixel >> 2) & 0xf8; \ + sB = (Pixel << 3) & 0xf8; \ + ASSEMBLE_RGBA(dst, 4, dstfmt, sR, sG, sB, alpha); \ + src += 2; \ + dst += 4; \ + widthvar--; \ + } ONE_PIXEL_BLEND(((UNALIGNED_PTR(dst)) && (width)), width); /* After all that work, here's the vector part! */ - extrawidth = (width % 8); /* trailing unaligned stores */ + extrawidth = (width % 8); /* trailing unaligned stores */ width -= extrawidth; vsrc = vec_ld(0, src); valigner = VEC_ALIGNER(src); @@ -563,23 +536,23 @@ Blit_RGB555_32Altivec(SDL_BlitInfo * info) voverflow = vec_ld(15, src); vsrc = vec_perm(vsrc, voverflow, valigner); - vR = vec_and(vec_sl((vector unsigned short) vsrc, v1), vf800); - vB = vec_sl((vector unsigned short) vsrc, v3); + vR = vec_and(vec_sl((vector unsigned short)vsrc, v1), vf800); + vB = vec_sl((vector unsigned short)vsrc, v3); vG = vec_sl(vB, v3); vdst1 = - (vector unsigned char) vec_perm((vector unsigned char) vR, - valpha, vredalpha1); - vdst1 = vec_perm(vdst1, (vector unsigned char) vB, vblue1); - vdst1 = vec_perm(vdst1, (vector unsigned char) vG, vgreen1); + (vector unsigned char)vec_perm((vector unsigned char)vR, + valpha, vredalpha1); + vdst1 = vec_perm(vdst1, (vector unsigned char)vB, vblue1); + vdst1 = vec_perm(vdst1, (vector unsigned char)vG, vgreen1); vdst1 = vec_perm(vdst1, valpha, vpermute); vec_st(vdst1, 0, dst); vdst2 = - (vector unsigned char) vec_perm((vector unsigned char) vR, - valpha, vredalpha2); - vdst2 = vec_perm(vdst2, (vector unsigned char) vB, vblue2); - vdst2 = vec_perm(vdst2, (vector unsigned char) vG, vgreen2); + (vector unsigned char)vec_perm((vector unsigned char)vR, + valpha, vredalpha2); + vdst2 = vec_perm(vdst2, (vector unsigned char)vB, vblue2); + vdst2 = vec_perm(vdst2, (vector unsigned char)vG, vgreen2); vdst2 = vec_perm(vdst2, valpha, vpermute); vec_st(vdst2, 16, dst); @@ -591,26 +564,23 @@ Blit_RGB555_32Altivec(SDL_BlitInfo * info) SDL_assert(width == 0); - /* do scalar until we can align... */ ONE_PIXEL_BLEND((extrawidth), extrawidth); #undef ONE_PIXEL_BLEND - src += srcskip; /* move to next row, accounting for pitch. */ + src += srcskip; /* move to next row, accounting for pitch. */ dst += dstskip; } - } -static void BlitNtoNKey(SDL_BlitInfo * info); -static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info); -static void -Blit32to32KeyAltivec(SDL_BlitInfo * info) +static void BlitNtoNKey(SDL_BlitInfo *info); +static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info); +static void Blit32to32KeyAltivec(SDL_BlitInfo *info) { int height = info->dst_h; - Uint32 *srcp = (Uint32 *) info->src; + Uint32 *srcp = (Uint32 *)info->src; int srcskip = info->src_skip / 4; - Uint32 *dstp = (Uint32 *) info->dst; + Uint32 *dstp = (Uint32 *)info->dst; int dstskip = info->dst_skip / 4; SDL_PixelFormat *srcfmt = info->src_fmt; int srcbpp = srcfmt->BytesPerPixel; @@ -636,49 +606,49 @@ Blit32to32KeyAltivec(SDL_BlitInfo * info) } vzero = vec_splat_u8(0); if (alpha) { - ((unsigned char *) &valpha)[0] = (unsigned char) alpha; + ((unsigned char *)&valpha)[0] = (unsigned char)alpha; valpha = - (vector unsigned int) vec_splat((vector unsigned char) valpha, 0); + (vector unsigned int)vec_splat((vector unsigned char)valpha, 0); } else { - valpha = (vector unsigned int) vzero; + valpha = (vector unsigned int)vzero; } ckey &= rgbmask; - ((unsigned int *) (char *) &vckey)[0] = ckey; + ((unsigned int *)(char *)&vckey)[0] = ckey; vckey = vec_splat(vckey, 0); - ((unsigned int *) (char *) &vrgbmask)[0] = rgbmask; + ((unsigned int *)(char *)&vrgbmask)[0] = rgbmask; vrgbmask = vec_splat(vrgbmask, 0); while (height--) { -#define ONE_PIXEL_BLEND(condition, widthvar) \ - if (copy_alpha) { \ - while (condition) { \ - Uint32 Pixel; \ - unsigned sR, sG, sB, sA; \ - DISEMBLE_RGBA((Uint8 *)srcp, srcbpp, srcfmt, Pixel, \ - sR, sG, sB, sA); \ - if ( (Pixel & rgbmask) != ckey ) { \ - ASSEMBLE_RGBA((Uint8 *)dstp, dstbpp, dstfmt, \ - sR, sG, sB, sA); \ - } \ - dstp = (Uint32 *) (((Uint8 *) dstp) + dstbpp); \ - srcp = (Uint32 *) (((Uint8 *) srcp) + srcbpp); \ - widthvar--; \ - } \ - } else { \ - while (condition) { \ - Uint32 Pixel; \ - unsigned sR, sG, sB; \ - RETRIEVE_RGB_PIXEL((Uint8 *)srcp, srcbpp, Pixel); \ - if ( Pixel != ckey ) { \ - RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB); \ - ASSEMBLE_RGBA((Uint8 *)dstp, dstbpp, dstfmt, \ - sR, sG, sB, alpha); \ - } \ - dstp = (Uint32 *) (((Uint8 *)dstp) + dstbpp); \ - srcp = (Uint32 *) (((Uint8 *)srcp) + srcbpp); \ - widthvar--; \ - } \ - } +#define ONE_PIXEL_BLEND(condition, widthvar) \ + if (copy_alpha) { \ + while (condition) { \ + Uint32 Pixel; \ + unsigned sR, sG, sB, sA; \ + DISEMBLE_RGBA((Uint8 *)srcp, srcbpp, srcfmt, Pixel, \ + sR, sG, sB, sA); \ + if ((Pixel & rgbmask) != ckey) { \ + ASSEMBLE_RGBA((Uint8 *)dstp, dstbpp, dstfmt, \ + sR, sG, sB, sA); \ + } \ + dstp = (Uint32 *)(((Uint8 *)dstp) + dstbpp); \ + srcp = (Uint32 *)(((Uint8 *)srcp) + srcbpp); \ + widthvar--; \ + } \ + } else { \ + while (condition) { \ + Uint32 Pixel; \ + unsigned sR, sG, sB; \ + RETRIEVE_RGB_PIXEL((Uint8 *)srcp, srcbpp, Pixel); \ + if (Pixel != ckey) { \ + RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB); \ + ASSEMBLE_RGBA((Uint8 *)dstp, dstbpp, dstfmt, \ + sR, sG, sB, alpha); \ + } \ + dstp = (Uint32 *)(((Uint8 *)dstp) + dstbpp); \ + srcp = (Uint32 *)(((Uint8 *)srcp) + srcbpp); \ + widthvar--; \ + } \ + } int width = info->dst_w; ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width); SDL_assert(width > 0); @@ -695,8 +665,8 @@ Blit32to32KeyAltivec(SDL_BlitInfo * info) /* load the source vec */ vs = vec_perm(vs, voverflow, valigner); /* vsel is set for items that match the key */ - vsel = (vector unsigned char) vec_and(vs, vrgbmask); - vsel = (vector unsigned char) vec_cmpeq(vs, vckey); + vsel = (vector unsigned char)vec_and(vs, vrgbmask); + vsel = (vector unsigned char)vec_cmpeq(vs, vckey); #if defined(__powerpc__) && (SDL_BYTEORDER == SDL_LIL_ENDIAN) /* reorder bytes for PowerPC little endian */ vpermute = reorder_ppc64le_vec(vpermute); @@ -706,9 +676,9 @@ Blit32to32KeyAltivec(SDL_BlitInfo * info) /* load the destination vec */ vd = vec_ld(0, dstp); /* select the source and dest into vs */ - vd = (vector unsigned int) vec_sel((vector unsigned char) vs, - (vector unsigned char) vd, - vsel); + vd = (vector unsigned int)vec_sel((vector unsigned char)vs, + (vector unsigned char)vd, + vsel); vec_st(vd, 0, dstp); srcp += 4; @@ -726,13 +696,12 @@ Blit32to32KeyAltivec(SDL_BlitInfo * info) /* Altivec code to swizzle one 32-bit surface to a different 32-bit format. */ /* Use this on a G5 */ -static void -ConvertAltivec32to32_noprefetch(SDL_BlitInfo * info) +static void ConvertAltivec32to32_noprefetch(SDL_BlitInfo *info) { int height = info->dst_h; - Uint32 *src = (Uint32 *) info->src; + Uint32 *src = (Uint32 *)info->src; int srcskip = info->src_skip / 4; - Uint32 *dst = (Uint32 *) info->dst; + Uint32 *dst = (Uint32 *)info->dst; int dstskip = info->dst_skip / 4; SDL_PixelFormat *srcfmt = info->src_fmt; SDL_PixelFormat *dstfmt = info->dst_fmt; @@ -741,8 +710,8 @@ ConvertAltivec32to32_noprefetch(SDL_BlitInfo * info) if (dstfmt->Amask && !srcfmt->Amask) { if (info->a) { vector unsigned char valpha; - ((unsigned char *) &valpha)[0] = info->a; - vzero = (vector unsigned int) vec_splat(valpha, 0); + ((unsigned char *)&valpha)[0] = info->a; + vzero = (vector unsigned int)vec_splat(valpha, 0); } } @@ -764,7 +733,7 @@ ConvertAltivec32to32_noprefetch(SDL_BlitInfo * info) bits = *(src++); RGBA_FROM_8888(bits, srcfmt, r, g, b, a); if (!srcfmt->Amask) - a = info->a; + a = info->a; *(dst++) = MAKE8888(dstfmt, r, g, b, a); width--; } @@ -779,13 +748,13 @@ ConvertAltivec32to32_noprefetch(SDL_BlitInfo * info) voverflow = vec_ld(15, src); src += 4; width -= 4; - vbits = vec_perm(vbits, voverflow, valigner); /* src is ready. */ + vbits = vec_perm(vbits, voverflow, valigner); /* src is ready. */ #if defined(__powerpc__) && (SDL_BYTEORDER == SDL_LIL_ENDIAN) /* reorder bytes for PowerPC little endian */ vpermute = reorder_ppc64le_vec(vpermute); #endif - vbits = vec_perm(vbits, vzero, vpermute); /* swizzle it. */ - vec_st(vbits, 0, dst); /* store it back out. */ + vbits = vec_perm(vbits, vzero, vpermute); /* swizzle it. */ + vec_st(vbits, 0, dst); /* store it back out. */ dst += 4; vbits = voverflow; } @@ -794,10 +763,10 @@ ConvertAltivec32to32_noprefetch(SDL_BlitInfo * info) /* cover pixels at the end of the row that didn't fit in 16 bytes. */ while (extrawidth) { - bits = *(src++); /* max 7 pixels, don't bother with prefetch. */ + bits = *(src++); /* max 7 pixels, don't bother with prefetch. */ RGBA_FROM_8888(bits, srcfmt, r, g, b, a); if (!srcfmt->Amask) - a = info->a; + a = info->a; *(dst++) = MAKE8888(dstfmt, r, g, b, a); extrawidth--; } @@ -805,21 +774,19 @@ ConvertAltivec32to32_noprefetch(SDL_BlitInfo * info) src += srcskip; dst += dstskip; } - } /* Altivec code to swizzle one 32-bit surface to a different 32-bit format. */ /* Use this on a G4 */ -static void -ConvertAltivec32to32_prefetch(SDL_BlitInfo * info) +static void ConvertAltivec32to32_prefetch(SDL_BlitInfo *info) { const int scalar_dst_lead = sizeof(Uint32) * 4; const int vector_dst_lead = sizeof(Uint32) * 16; int height = info->dst_h; - Uint32 *src = (Uint32 *) info->src; + Uint32 *src = (Uint32 *)info->src; int srcskip = info->src_skip / 4; - Uint32 *dst = (Uint32 *) info->dst; + Uint32 *dst = (Uint32 *)info->dst; int dstskip = info->dst_skip / 4; SDL_PixelFormat *srcfmt = info->src_fmt; SDL_PixelFormat *dstfmt = info->dst_fmt; @@ -828,8 +795,8 @@ ConvertAltivec32to32_prefetch(SDL_BlitInfo * info) if (dstfmt->Amask && !srcfmt->Amask) { if (info->a) { vector unsigned char valpha; - ((unsigned char *) &valpha)[0] = info->a; - vzero = (vector unsigned int) vec_splat(valpha, 0); + ((unsigned char *)&valpha)[0] = info->a; + vzero = (vector unsigned int)vec_splat(valpha, 0); } } @@ -855,7 +822,7 @@ ConvertAltivec32to32_prefetch(SDL_BlitInfo * info) bits = *(src++); RGBA_FROM_8888(bits, srcfmt, r, g, b, a); if (!srcfmt->Amask) - a = info->a; + a = info->a; *(dst++) = MAKE8888(dstfmt, r, g, b, a); width--; } @@ -874,13 +841,13 @@ ConvertAltivec32to32_prefetch(SDL_BlitInfo * info) voverflow = vec_ld(15, src); src += 4; width -= 4; - vbits = vec_perm(vbits, voverflow, valigner); /* src is ready. */ + vbits = vec_perm(vbits, voverflow, valigner); /* src is ready. */ #if defined(__powerpc__) && (SDL_BYTEORDER == SDL_LIL_ENDIAN) /* reorder bytes for PowerPC little endian */ vpermute = reorder_ppc64le_vec(vpermute); #endif - vbits = vec_perm(vbits, vzero, vpermute); /* swizzle it. */ - vec_st(vbits, 0, dst); /* store it back out. */ + vbits = vec_perm(vbits, vzero, vpermute); /* swizzle it. */ + vec_st(vbits, 0, dst); /* store it back out. */ dst += 4; vbits = voverflow; } @@ -889,10 +856,10 @@ ConvertAltivec32to32_prefetch(SDL_BlitInfo * info) /* cover pixels at the end of the row that didn't fit in 16 bytes. */ while (extrawidth) { - bits = *(src++); /* max 7 pixels, don't bother with prefetch. */ + bits = *(src++); /* max 7 pixels, don't bother with prefetch. */ RGBA_FROM_8888(bits, srcfmt, r, g, b, a); if (!srcfmt->Amask) - a = info->a; + a = info->a; *(dst++) = MAKE8888(dstfmt, r, g, b, a); extrawidth--; } @@ -905,27 +872,25 @@ ConvertAltivec32to32_prefetch(SDL_BlitInfo * info) vec_dss(DST_CHAN_DEST); } -static enum blit_features -GetBlitFeatures(void) +static enum blit_features GetBlitFeatures(void) { static enum blit_features features = -1; - if (features == (enum blit_features) -1) { + if (features == (enum blit_features) - 1) { /* Provide an override for testing .. */ char *override = SDL_getenv("SDL_ALTIVEC_BLIT_FEATURES"); if (override) { unsigned int features_as_uint = 0; SDL_sscanf(override, "%u", &features_as_uint); - features = (enum blit_features) features_as_uint; + features = (enum blit_features)features_as_uint; } else { features = (0 /* Feature 1 is has-MMX */ - | ((SDL_HasMMX())? BLIT_FEATURE_HAS_MMX : 0) + | ((SDL_HasMMX()) ? BLIT_FEATURE_HAS_MMX : 0) /* Feature 2 is has-AltiVec */ - | ((SDL_HasAltiVec())? BLIT_FEATURE_HAS_ALTIVEC : 0) + | ((SDL_HasAltiVec()) ? BLIT_FEATURE_HAS_ALTIVEC : 0) /* Feature 4 is dont-use-prefetch */ /* !!!! FIXME: Check for G5 or later, not the cache size! Always prefetch on a G4. */ - | ((GetL3CacheSize() == 0) ? BLIT_FEATURE_ALTIVEC_DONT_USE_PREFETCH : 0) - ); + | ((GetL3CacheSize() == 0) ? BLIT_FEATURE_ALTIVEC_DONT_USE_PREFETCH : 0)); } } return features; @@ -942,8 +907,7 @@ GetBlitFeatures(void) #if SDL_ARM_SIMD_BLITTERS void Blit_BGR888_RGB888ARMSIMDAsm(int32_t w, int32_t h, uint32_t *dst, int32_t dst_stride, uint32_t *src, int32_t src_stride); -static void -Blit_BGR888_RGB888ARMSIMD(SDL_BlitInfo * info) +static void Blit_BGR888_RGB888ARMSIMD(SDL_BlitInfo *info) { int32_t width = info->dst_w; int32_t height = info->dst_h; @@ -957,8 +921,7 @@ Blit_BGR888_RGB888ARMSIMD(SDL_BlitInfo * info) void Blit_RGB444_RGB888ARMSIMDAsm(int32_t w, int32_t h, uint32_t *dst, int32_t dst_stride, uint16_t *src, int32_t src_stride); -static void -Blit_RGB444_RGB888ARMSIMD(SDL_BlitInfo * info) +static void Blit_RGB444_RGB888ARMSIMD(SDL_BlitInfo *info) { int32_t width = info->dst_w; int32_t height = info->dst_h; @@ -973,21 +936,21 @@ Blit_RGB444_RGB888ARMSIMD(SDL_BlitInfo * info) /* This is now endian dependent */ #if SDL_BYTEORDER == SDL_LIL_ENDIAN -#define HI 1 -#define LO 0 +#define HI 1 +#define LO 0 #else /* SDL_BYTEORDER == SDL_BIG_ENDIAN */ -#define HI 0 -#define LO 1 +#define HI 0 +#define LO 1 #endif /* Special optimized blit for RGB 8-8-8 --> RGB 3-3-2 */ -#define RGB888_RGB332(dst, src) { \ - dst = (Uint8)((((src)&0x00E00000)>>16)| \ - (((src)&0x0000E000)>>11)| \ - (((src)&0x000000C0)>>6)); \ -} -static void -Blit_RGB888_index8(SDL_BlitInfo * info) +#define RGB888_RGB332(dst, src) \ + { \ + dst = (Uint8)((((src)&0x00E00000) >> 16) | \ + (((src)&0x0000E000) >> 11) | \ + (((src)&0x000000C0) >> 6)); \ + } +static void Blit_RGB888_index8(SDL_BlitInfo *info) { #ifndef USE_DUFFS_LOOP int c; @@ -1001,7 +964,7 @@ Blit_RGB888_index8(SDL_BlitInfo * info) /* Set up some basic variables */ width = info->dst_w; height = info->dst_h; - src = (Uint32 *) info->src; + src = (Uint32 *)info->src; srcskip = info->src_skip / 4; dst = info->dst; dstskip = info->dst_skip; @@ -1091,13 +1054,13 @@ Blit_RGB888_index8(SDL_BlitInfo * info) } /* Special optimized blit for RGB 10-10-10 --> RGB 3-3-2 */ -#define RGB101010_RGB332(dst, src) { \ - dst = (Uint8)((((src)&0x38000000)>>22)| \ - (((src)&0x000E0000)>>15)| \ - (((src)&0x00000300)>>8)); \ -} -static void -Blit_RGB101010_index8(SDL_BlitInfo * info) +#define RGB101010_RGB332(dst, src) \ + { \ + dst = (Uint8)((((src)&0x38000000) >> 22) | \ + (((src)&0x000E0000) >> 15) | \ + (((src)&0x00000300) >> 8)); \ + } +static void Blit_RGB101010_index8(SDL_BlitInfo *info) { #ifndef USE_DUFFS_LOOP int c; @@ -1111,7 +1074,7 @@ Blit_RGB101010_index8(SDL_BlitInfo * info) /* Set up some basic variables */ width = info->dst_w; height = info->dst_h; - src = (Uint32 *) info->src; + src = (Uint32 *)info->src; srcskip = info->src_skip / 4; dst = info->dst; dstskip = info->dst_skip; @@ -1201,23 +1164,25 @@ Blit_RGB101010_index8(SDL_BlitInfo * info) } /* Special optimized blit for RGB 8-8-8 --> RGB 5-5-5 */ -#define RGB888_RGB555(dst, src) { \ - *(Uint16 *)(dst) = (Uint16)((((*src)&0x00F80000)>>9)| \ - (((*src)&0x0000F800)>>6)| \ - (((*src)&0x000000F8)>>3)); \ -} +#define RGB888_RGB555(dst, src) \ + { \ + *(Uint16 *)(dst) = (Uint16)((((*src) & 0x00F80000) >> 9) | \ + (((*src) & 0x0000F800) >> 6) | \ + (((*src) & 0x000000F8) >> 3)); \ + } #ifndef USE_DUFFS_LOOP -#define RGB888_RGB555_TWO(dst, src) { \ - *(Uint32 *)(dst) = (((((src[HI])&0x00F80000)>>9)| \ - (((src[HI])&0x0000F800)>>6)| \ - (((src[HI])&0x000000F8)>>3))<<16)| \ - (((src[LO])&0x00F80000)>>9)| \ - (((src[LO])&0x0000F800)>>6)| \ - (((src[LO])&0x000000F8)>>3); \ -} +#define RGB888_RGB555_TWO(dst, src) \ + { \ + *(Uint32 *)(dst) = (((((src[HI]) & 0x00F80000) >> 9) | \ + (((src[HI]) & 0x0000F800) >> 6) | \ + (((src[HI]) & 0x000000F8) >> 3)) \ + << 16) | \ + (((src[LO]) & 0x00F80000) >> 9) | \ + (((src[LO]) & 0x0000F800) >> 6) | \ + (((src[LO]) & 0x000000F8) >> 3); \ + } #endif -static void -Blit_RGB888_RGB555(SDL_BlitInfo * info) +static void Blit_RGB888_RGB555(SDL_BlitInfo *info) { #ifndef USE_DUFFS_LOOP int c; @@ -1230,9 +1195,9 @@ Blit_RGB888_RGB555(SDL_BlitInfo * info) /* Set up some basic variables */ width = info->dst_w; height = info->dst_h; - src = (Uint32 *) info->src; + src = (Uint32 *)info->src; srcskip = info->src_skip / 4; - dst = (Uint16 *) info->dst; + dst = (Uint16 *)info->dst; dstskip = info->dst_skip / 2; #ifdef USE_DUFFS_LOOP @@ -1249,7 +1214,7 @@ Blit_RGB888_RGB555(SDL_BlitInfo * info) } #else /* Memory align at 4-byte boundary, if necessary */ - if ((long) dst & 0x03) { + if ((long)dst & 0x03) { /* Don't do anything if width is 0 */ if (width == 0) { return; @@ -1327,23 +1292,25 @@ Blit_RGB888_RGB555(SDL_BlitInfo * info) } /* Special optimized blit for RGB 8-8-8 --> RGB 5-6-5 */ -#define RGB888_RGB565(dst, src) { \ - *(Uint16 *)(dst) = (Uint16)((((*src)&0x00F80000)>>8)| \ - (((*src)&0x0000FC00)>>5)| \ - (((*src)&0x000000F8)>>3)); \ -} +#define RGB888_RGB565(dst, src) \ + { \ + *(Uint16 *)(dst) = (Uint16)((((*src) & 0x00F80000) >> 8) | \ + (((*src) & 0x0000FC00) >> 5) | \ + (((*src) & 0x000000F8) >> 3)); \ + } #ifndef USE_DUFFS_LOOP -#define RGB888_RGB565_TWO(dst, src) { \ - *(Uint32 *)(dst) = (((((src[HI])&0x00F80000)>>8)| \ - (((src[HI])&0x0000FC00)>>5)| \ - (((src[HI])&0x000000F8)>>3))<<16)| \ - (((src[LO])&0x00F80000)>>8)| \ - (((src[LO])&0x0000FC00)>>5)| \ - (((src[LO])&0x000000F8)>>3); \ -} +#define RGB888_RGB565_TWO(dst, src) \ + { \ + *(Uint32 *)(dst) = (((((src[HI]) & 0x00F80000) >> 8) | \ + (((src[HI]) & 0x0000FC00) >> 5) | \ + (((src[HI]) & 0x000000F8) >> 3)) \ + << 16) | \ + (((src[LO]) & 0x00F80000) >> 8) | \ + (((src[LO]) & 0x0000FC00) >> 5) | \ + (((src[LO]) & 0x000000F8) >> 3); \ + } #endif -static void -Blit_RGB888_RGB565(SDL_BlitInfo * info) +static void Blit_RGB888_RGB565(SDL_BlitInfo *info) { #ifndef USE_DUFFS_LOOP int c; @@ -1356,9 +1323,9 @@ Blit_RGB888_RGB565(SDL_BlitInfo * info) /* Set up some basic variables */ width = info->dst_w; height = info->dst_h; - src = (Uint32 *) info->src; + src = (Uint32 *)info->src; srcskip = info->src_skip / 4; - dst = (Uint16 *) info->dst; + dst = (Uint16 *)info->dst; dstskip = info->dst_skip / 2; #ifdef USE_DUFFS_LOOP @@ -1375,7 +1342,7 @@ Blit_RGB888_RGB565(SDL_BlitInfo * info) } #else /* Memory align at 4-byte boundary, if necessary */ - if ((long) dst & 0x03) { + if ((long)dst & 0x03) { /* Don't do anything if width is 0 */ if (width == 0) { return; @@ -1452,13 +1419,11 @@ Blit_RGB888_RGB565(SDL_BlitInfo * info) #endif /* USE_DUFFS_LOOP */ } - #if SDL_HAVE_BLIT_N_RGB565 /* Special optimized blit for RGB 5-6-5 --> 32-bit RGB surfaces */ -#define RGB565_32(dst, src, map) (map[src[LO]*2] + map[src[HI]*2+1]) -static void -Blit_RGB565_32(SDL_BlitInfo * info, const Uint32 * map) +#define RGB565_32(dst, src, map) (map[src[LO] * 2] + map[src[HI] * 2 + 1]) +static void Blit_RGB565_32(SDL_BlitInfo *info, const Uint32 *map) { #ifndef USE_DUFFS_LOOP int c; @@ -1473,7 +1438,7 @@ Blit_RGB565_32(SDL_BlitInfo * info, const Uint32 * map) height = info->dst_h; src = info->src; srcskip = info->src_skip; - dst = (Uint32 *) info->dst; + dst = (Uint32 *)info->dst; dstskip = info->dst_skip / 4; #ifdef USE_DUFFS_LOOP @@ -1521,6 +1486,8 @@ Blit_RGB565_32(SDL_BlitInfo * info, const Uint32 * map) #endif /* USE_DUFFS_LOOP */ } +/* *INDENT-OFF* */ /* clang-format off */ + /* Special optimized blit for RGB 5-6-5 --> ARGB 8-8-8-8 */ static const Uint32 RGB565_ARGB8888_LUT[512] = { 0x00000000, 0xff000000, 0x00000008, 0xff002000, @@ -1653,8 +1620,7 @@ static const Uint32 RGB565_ARGB8888_LUT[512] = { 0x00001cf6, 0xffffc200, 0x00001cff, 0xffffe200 }; -static void -Blit_RGB565_ARGB8888(SDL_BlitInfo * info) +static void Blit_RGB565_ARGB8888(SDL_BlitInfo * info) { Blit_RGB565_32(info, RGB565_ARGB8888_LUT); } @@ -1791,8 +1757,7 @@ static const Uint32 RGB565_ABGR8888_LUT[512] = { 0xfff61c00, 0x0000c2ff, 0xffff1c00, 0x0000e2ff }; -static void -Blit_RGB565_ABGR8888(SDL_BlitInfo * info) +static void Blit_RGB565_ABGR8888(SDL_BlitInfo * info) { Blit_RGB565_32(info, RGB565_ABGR8888_LUT); } @@ -1929,8 +1894,7 @@ static const Uint32 RGB565_RGBA8888_LUT[512] = { 0x001cf6ff, 0xffc20000, 0x001cffff, 0xffe20000, }; -static void -Blit_RGB565_RGBA8888(SDL_BlitInfo * info) +static void Blit_RGB565_RGBA8888(SDL_BlitInfo * info) { Blit_RGB565_32(info, RGB565_RGBA8888_LUT); } @@ -2067,23 +2031,23 @@ static const Uint32 RGB565_BGRA8888_LUT[512] = { 0xf61c0000, 0x00c2ffff, 0xff1c0000, 0x00e2ffff }; -static void -Blit_RGB565_BGRA8888(SDL_BlitInfo * info) +static void Blit_RGB565_BGRA8888(SDL_BlitInfo * info) { Blit_RGB565_32(info, RGB565_BGRA8888_LUT); } +/* *INDENT-ON* */ /* clang-format on */ + #endif /* SDL_HAVE_BLIT_N_RGB565 */ /* RGB555->ARGB1555, and BGR555->ABGR1555, SET_ALPHA */ -static void -Blit_RGB555_ARGB1555(SDL_BlitInfo * info) +static void Blit_RGB555_ARGB1555(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; - Uint16 *src = (Uint16 *) info->src; + Uint16 *src = (Uint16 *)info->src; int srcskip = info->src_skip; - Uint16 *dst = (Uint16 *) info->dst; + Uint16 *dst = (Uint16 *)info->dst; int dstskip = info->dst_skip; SDL_PixelFormat *dstfmt = info->dst_fmt; @@ -2099,13 +2063,12 @@ Blit_RGB555_ARGB1555(SDL_BlitInfo * info) }, width); /* *INDENT-ON* */ /* clang-format on */ - src = (Uint16 *) ((Uint8 *) src + srcskip); - dst = (Uint16 *) ((Uint8 *) dst + dstskip); + src = (Uint16 *)((Uint8 *)src + srcskip); + dst = (Uint16 *)((Uint8 *)dst + dstskip); } } -static void -BlitNto1(SDL_BlitInfo * info) +static void BlitNto1(SDL_BlitInfo *info) { #ifndef USE_DUFFS_LOOP int c; @@ -2154,7 +2117,7 @@ BlitNto1(SDL_BlitInfo * info) if (1) { /* Pack RGB into 8bit pixel */ *dst = ((sR >> 5) << (3 + 2)) | - ((sG >> 5) << (2)) | ((sB >> 6) << (0)); + ((sG >> 5) << (2)) | ((sB >> 6) << (0)); } dst++; src += srcbpp; @@ -2199,14 +2162,13 @@ BlitNto1(SDL_BlitInfo * info) } /* blits 32 bit RGB<->RGBA with both surfaces having the same R,G,B fields */ -static void -Blit4to4MaskAlpha(SDL_BlitInfo * info) +static void Blit4to4MaskAlpha(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; - Uint32 *src = (Uint32 *) info->src; + Uint32 *src = (Uint32 *)info->src; int srcskip = info->src_skip; - Uint32 *dst = (Uint32 *) info->dst; + Uint32 *dst = (Uint32 *)info->dst; int dstskip = info->dst_skip; SDL_PixelFormat *srcfmt = info->src_fmt; SDL_PixelFormat *dstfmt = info->dst_fmt; @@ -2225,8 +2187,8 @@ Blit4to4MaskAlpha(SDL_BlitInfo * info) }, width); /* *INDENT-ON* */ /* clang-format on */ - src = (Uint32 *) ((Uint8 *) src + srcskip); - dst = (Uint32 *) ((Uint8 *) dst + dstskip); + src = (Uint32 *)((Uint8 *)src + srcskip); + dst = (Uint32 *)((Uint8 *)dst + dstskip); } } else { /* RGBA->RGB, NO_ALPHA */ @@ -2242,16 +2204,15 @@ Blit4to4MaskAlpha(SDL_BlitInfo * info) }, width); /* *INDENT-ON* */ /* clang-format on */ - src = (Uint32 *) ((Uint8 *) src + srcskip); - dst = (Uint32 *) ((Uint8 *) dst + dstskip); + src = (Uint32 *)((Uint8 *)src + srcskip); + dst = (Uint32 *)((Uint8 *)dst + dstskip); } } } /* permutation for mapping srcfmt to dstfmt, overloading or not the alpha channel */ -static void -get_permutation(SDL_PixelFormat *srcfmt, SDL_PixelFormat *dstfmt, - int *_p0 , int *_p1, int *_p2, int *_p3, int *_alpha_channel) +static void get_permutation(SDL_PixelFormat *srcfmt, SDL_PixelFormat *dstfmt, + int *_p0, int *_p1, int *_p2, int *_p3, int *_alpha_channel) { int alpha_channel = 0, p0, p1, p2, p3; #if SDL_BYTEORDER == SDL_LIL_ENDIAN @@ -2336,9 +2297,7 @@ get_permutation(SDL_PixelFormat *srcfmt, SDL_PixelFormat *dstfmt, } } - -static void -BlitNtoN(SDL_BlitInfo * info) +static void BlitNtoN(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -2456,8 +2415,7 @@ BlitNtoN(SDL_BlitInfo * info) } } -static void -BlitNtoNCopyAlpha(SDL_BlitInfo * info) +static void BlitNtoNCopyAlpha(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -2514,8 +2472,7 @@ BlitNtoNCopyAlpha(SDL_BlitInfo * info) } } -static void -BlitNto1Key(SDL_BlitInfo * info) +static void BlitNto1Key(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -2580,14 +2537,13 @@ BlitNto1Key(SDL_BlitInfo * info) } } -static void -Blit2to2Key(SDL_BlitInfo * info) +static void Blit2to2Key(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; - Uint16 *srcp = (Uint16 *) info->src; + Uint16 *srcp = (Uint16 *)info->src; int srcskip = info->src_skip; - Uint16 *dstp = (Uint16 *) info->dst; + Uint16 *dstp = (Uint16 *)info->dst; int dstskip = info->dst_skip; Uint32 ckey = info->colorkey; Uint32 rgbmask = ~info->src_fmt->Amask; @@ -2614,8 +2570,7 @@ Blit2to2Key(SDL_BlitInfo * info) } } -static void -BlitNtoNKey(SDL_BlitInfo * info) +static void BlitNtoNKey(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -2638,8 +2593,8 @@ BlitNtoNKey(SDL_BlitInfo * info) /* BPP 4, same rgb */ if (srcbpp == 4 && dstbpp == 4 && srcfmt->Rmask == dstfmt->Rmask && srcfmt->Gmask == dstfmt->Gmask && srcfmt->Bmask == dstfmt->Bmask) { - Uint32 *src32 = (Uint32*)src; - Uint32 *dst32 = (Uint32*)dst; + Uint32 *src32 = (Uint32 *)src; + Uint32 *dst32 = (Uint32 *)dst; if (dstfmt->Amask) { /* RGB->RGBA, SET_ALPHA */ @@ -2655,8 +2610,8 @@ BlitNtoNKey(SDL_BlitInfo * info) ++src32; }, width); /* *INDENT-ON* */ /* clang-format on */ - src32 = (Uint32 *) ((Uint8 *) src32 + srcskip); - dst32 = (Uint32 *) ((Uint8 *) dst32 + dstskip); + src32 = (Uint32 *)((Uint8 *)src32 + srcskip); + dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip); } return; } else { @@ -2673,8 +2628,8 @@ BlitNtoNKey(SDL_BlitInfo * info) ++src32; }, width); /* *INDENT-ON* */ /* clang-format on */ - src32 = (Uint32 *) ((Uint8 *) src32 + srcskip); - dst32 = (Uint32 *) ((Uint8 *) dst32 + dstskip); + src32 = (Uint32 *)((Uint8 *)src32 + srcskip); + dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip); } return; } @@ -2720,7 +2675,7 @@ BlitNtoNKey(SDL_BlitInfo * info) #if SDL_BYTEORDER == SDL_LIL_ENDIAN Uint8 k0 = ckey & 0xFF; - Uint8 k1 = (ckey >> 8) & 0xFF; + Uint8 k1 = (ckey >> 8) & 0xFF; Uint8 k2 = (ckey >> 16) & 0xFF; #else Uint8 k0 = (ckey >> 16) & 0xFF; @@ -2758,7 +2713,7 @@ BlitNtoNKey(SDL_BlitInfo * info) #if SDL_BYTEORDER == SDL_LIL_ENDIAN Uint8 k0 = ckey & 0xFF; - Uint8 k1 = (ckey >> 8) & 0xFF; + Uint8 k1 = (ckey >> 8) & 0xFF; Uint8 k2 = (ckey >> 16) & 0xFF; #else Uint8 k0 = (ckey >> 16) & 0xFF; @@ -2825,12 +2780,12 @@ BlitNtoNKey(SDL_BlitInfo * info) #if SDL_BYTEORDER == SDL_LIL_ENDIAN Uint8 k0 = ckey & 0xFF; - Uint8 k1 = (ckey >> 8) & 0xFF; + Uint8 k1 = (ckey >> 8) & 0xFF; Uint8 k2 = (ckey >> 16) & 0xFF; #else Uint8 k0 = (ckey >> 16) & 0xFF; Uint8 k1 = (ckey >> 8) & 0xFF; - Uint8 k2 = ckey & 0xFF; + Uint8 k2 = ckey & 0xFF; #endif /* Find the appropriate permutation */ @@ -2886,8 +2841,7 @@ BlitNtoNKey(SDL_BlitInfo * info) } } -static void -BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info) +static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -2918,8 +2872,8 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info) srcfmt->format == SDL_PIXELFORMAT_BGRA8888 || srcfmt->format == SDL_PIXELFORMAT_RGBA8888) { - Uint32 *src32 = (Uint32*)src; - Uint32 *dst32 = (Uint32*)dst; + Uint32 *src32 = (Uint32 *)src; + Uint32 *dst32 = (Uint32 *)dst; while (height--) { /* *INDENT-OFF* */ /* clang-format off */ DUFFS_LOOP( @@ -2990,8 +2944,7 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info) } /* Special optimized blit for ARGB 2-10-10-10 --> RGBA */ -static void -Blit2101010toN(SDL_BlitInfo * info) +static void Blit2101010toN(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -3022,8 +2975,7 @@ Blit2101010toN(SDL_BlitInfo * info) } /* Special optimized blit for RGBA --> ARGB 2-10-10-10 */ -static void -BlitNto2101010(SDL_BlitInfo * info) +static void BlitNto2101010(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -3054,8 +3006,7 @@ BlitNto2101010(SDL_BlitInfo * info) } /* Blit_3or4_to_3or4__same_rgb: 3 or 4 bpp, same RGB triplet */ -static void -Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo * info) +static void Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -3128,8 +3079,7 @@ Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo * info) } /* Blit_3or4_to_3or4__inversed_rgb: 3 or 4 bpp, inversed RGB triplet */ -static void -Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo * info) +static void Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo *info) { int width = info->dst_w; int height = info->dst_h; @@ -3242,126 +3192,126 @@ struct blit_table Uint32 dstR, dstG, dstB; enum blit_features blit_features; SDL_BlitFunc blitfunc; - Uint32 alpha; /* bitwise NO_ALPHA, SET_ALPHA, COPY_ALPHA */ + Uint32 alpha; /* bitwise NO_ALPHA, SET_ALPHA, COPY_ALPHA */ }; static const struct blit_table normal_blit_1[] = { /* Default for 8-bit RGB source, never optimized */ - {0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0} + { 0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0 } }; static const struct blit_table normal_blit_2[] = { #if SDL_ALTIVEC_BLITTERS /* has-altivec */ - {0x0000F800, 0x000007E0, 0x0000001F, 4, 0x00000000, 0x00000000, 0x00000000, - BLIT_FEATURE_HAS_ALTIVEC, Blit_RGB565_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA}, - {0x00007C00, 0x000003E0, 0x0000001F, 4, 0x00000000, 0x00000000, 0x00000000, - BLIT_FEATURE_HAS_ALTIVEC, Blit_RGB555_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA}, + { 0x0000F800, 0x000007E0, 0x0000001F, 4, 0x00000000, 0x00000000, 0x00000000, + BLIT_FEATURE_HAS_ALTIVEC, Blit_RGB565_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, + { 0x00007C00, 0x000003E0, 0x0000001F, 4, 0x00000000, 0x00000000, 0x00000000, + BLIT_FEATURE_HAS_ALTIVEC, Blit_RGB555_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, #endif #if SDL_ARM_SIMD_BLITTERS - {0x00000F00, 0x000000F0, 0x0000000F, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, - BLIT_FEATURE_HAS_ARM_SIMD, Blit_RGB444_RGB888ARMSIMD, NO_ALPHA | COPY_ALPHA}, + { 0x00000F00, 0x000000F0, 0x0000000F, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, + BLIT_FEATURE_HAS_ARM_SIMD, Blit_RGB444_RGB888ARMSIMD, NO_ALPHA | COPY_ALPHA }, #endif #if SDL_HAVE_BLIT_N_RGB565 - {0x0000F800, 0x000007E0, 0x0000001F, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, - 0, Blit_RGB565_ARGB8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA}, - {0x0000F800, 0x000007E0, 0x0000001F, 4, 0x000000FF, 0x0000FF00, 0x00FF0000, - 0, Blit_RGB565_ABGR8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA}, - {0x0000F800, 0x000007E0, 0x0000001F, 4, 0xFF000000, 0x00FF0000, 0x0000FF00, - 0, Blit_RGB565_RGBA8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA}, - {0x0000F800, 0x000007E0, 0x0000001F, 4, 0x0000FF00, 0x00FF0000, 0xFF000000, - 0, Blit_RGB565_BGRA8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA}, + { 0x0000F800, 0x000007E0, 0x0000001F, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, + 0, Blit_RGB565_ARGB8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, + { 0x0000F800, 0x000007E0, 0x0000001F, 4, 0x000000FF, 0x0000FF00, 0x00FF0000, + 0, Blit_RGB565_ABGR8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, + { 0x0000F800, 0x000007E0, 0x0000001F, 4, 0xFF000000, 0x00FF0000, 0x0000FF00, + 0, Blit_RGB565_RGBA8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, + { 0x0000F800, 0x000007E0, 0x0000001F, 4, 0x0000FF00, 0x00FF0000, 0xFF000000, + 0, Blit_RGB565_BGRA8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, #endif - {0x00007C00, 0x000003E0, 0x0000001F, 2, 0x00007C00, 0x000003E0, 0x0000001F, - 0, Blit_RGB555_ARGB1555, SET_ALPHA}, - {0x0000001F, 0x000003E0, 0x00007C00, 2, 0x0000001F, 0x000003E0, 0x00007C00, - 0, Blit_RGB555_ARGB1555, SET_ALPHA}, + { 0x00007C00, 0x000003E0, 0x0000001F, 2, 0x00007C00, 0x000003E0, 0x0000001F, + 0, Blit_RGB555_ARGB1555, SET_ALPHA }, + { 0x0000001F, 0x000003E0, 0x00007C00, 2, 0x0000001F, 0x000003E0, 0x00007C00, + 0, Blit_RGB555_ARGB1555, SET_ALPHA }, /* Default for 16-bit RGB source, used if no other blitter matches */ - {0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0} + { 0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0 } }; static const struct blit_table normal_blit_3[] = { /* 3->4 with same rgb triplet */ - {0x000000FF, 0x0000FF00, 0x00FF0000, 4, 0x000000FF, 0x0000FF00, 0x00FF0000, - 0, Blit_3or4_to_3or4__same_rgb, + { 0x000000FF, 0x0000FF00, 0x00FF0000, 4, 0x000000FF, 0x0000FF00, 0x00FF0000, + 0, Blit_3or4_to_3or4__same_rgb, #if HAVE_FAST_WRITE_INT8 - NO_ALPHA | + NO_ALPHA | #endif - SET_ALPHA}, - {0x00FF0000, 0x0000FF00, 0x000000FF, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, - 0, Blit_3or4_to_3or4__same_rgb, + SET_ALPHA }, + { 0x00FF0000, 0x0000FF00, 0x000000FF, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, + 0, Blit_3or4_to_3or4__same_rgb, #if HAVE_FAST_WRITE_INT8 - NO_ALPHA | + NO_ALPHA | #endif - SET_ALPHA}, + SET_ALPHA }, /* 3->4 with inversed rgb triplet */ - {0x000000FF, 0x0000FF00, 0x00FF0000, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, - 0, Blit_3or4_to_3or4__inversed_rgb, + { 0x000000FF, 0x0000FF00, 0x00FF0000, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, + 0, Blit_3or4_to_3or4__inversed_rgb, #if HAVE_FAST_WRITE_INT8 - NO_ALPHA | + NO_ALPHA | #endif - SET_ALPHA}, - {0x00FF0000, 0x0000FF00, 0x000000FF, 4, 0x000000FF, 0x0000FF00, 0x00FF0000, - 0, Blit_3or4_to_3or4__inversed_rgb, + SET_ALPHA }, + { 0x00FF0000, 0x0000FF00, 0x000000FF, 4, 0x000000FF, 0x0000FF00, 0x00FF0000, + 0, Blit_3or4_to_3or4__inversed_rgb, #if HAVE_FAST_WRITE_INT8 - NO_ALPHA | + NO_ALPHA | #endif - SET_ALPHA}, + SET_ALPHA }, /* 3->3 to switch RGB 24 <-> BGR 24 */ - {0x000000FF, 0x0000FF00, 0x00FF0000, 3, 0x00FF0000, 0x0000FF00, 0x000000FF, - 0, Blit_3or4_to_3or4__inversed_rgb, NO_ALPHA }, - {0x00FF0000, 0x0000FF00, 0x000000FF, 3, 0x000000FF, 0x0000FF00, 0x00FF0000, - 0, Blit_3or4_to_3or4__inversed_rgb, NO_ALPHA }, + { 0x000000FF, 0x0000FF00, 0x00FF0000, 3, 0x00FF0000, 0x0000FF00, 0x000000FF, + 0, Blit_3or4_to_3or4__inversed_rgb, NO_ALPHA }, + { 0x00FF0000, 0x0000FF00, 0x000000FF, 3, 0x000000FF, 0x0000FF00, 0x00FF0000, + 0, Blit_3or4_to_3or4__inversed_rgb, NO_ALPHA }, /* Default for 24-bit RGB source, never optimized */ - {0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0} + { 0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0 } }; static const struct blit_table normal_blit_4[] = { #if SDL_ALTIVEC_BLITTERS /* has-altivec | dont-use-prefetch */ - {0x00000000, 0x00000000, 0x00000000, 4, 0x00000000, 0x00000000, 0x00000000, - BLIT_FEATURE_HAS_ALTIVEC | BLIT_FEATURE_ALTIVEC_DONT_USE_PREFETCH, ConvertAltivec32to32_noprefetch, NO_ALPHA | COPY_ALPHA | SET_ALPHA}, + { 0x00000000, 0x00000000, 0x00000000, 4, 0x00000000, 0x00000000, 0x00000000, + BLIT_FEATURE_HAS_ALTIVEC | BLIT_FEATURE_ALTIVEC_DONT_USE_PREFETCH, ConvertAltivec32to32_noprefetch, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, /* has-altivec */ - {0x00000000, 0x00000000, 0x00000000, 4, 0x00000000, 0x00000000, 0x00000000, - BLIT_FEATURE_HAS_ALTIVEC, ConvertAltivec32to32_prefetch, NO_ALPHA | COPY_ALPHA | SET_ALPHA}, + { 0x00000000, 0x00000000, 0x00000000, 4, 0x00000000, 0x00000000, 0x00000000, + BLIT_FEATURE_HAS_ALTIVEC, ConvertAltivec32to32_prefetch, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, /* has-altivec */ - {0x00000000, 0x00000000, 0x00000000, 2, 0x0000F800, 0x000007E0, 0x0000001F, - BLIT_FEATURE_HAS_ALTIVEC, Blit_RGB888_RGB565Altivec, NO_ALPHA}, + { 0x00000000, 0x00000000, 0x00000000, 2, 0x0000F800, 0x000007E0, 0x0000001F, + BLIT_FEATURE_HAS_ALTIVEC, Blit_RGB888_RGB565Altivec, NO_ALPHA }, #endif #if SDL_ARM_SIMD_BLITTERS - {0x000000FF, 0x0000FF00, 0x00FF0000, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, - BLIT_FEATURE_HAS_ARM_SIMD, Blit_BGR888_RGB888ARMSIMD, NO_ALPHA | COPY_ALPHA }, + { 0x000000FF, 0x0000FF00, 0x00FF0000, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, + BLIT_FEATURE_HAS_ARM_SIMD, Blit_BGR888_RGB888ARMSIMD, NO_ALPHA | COPY_ALPHA }, #endif /* 4->3 with same rgb triplet */ - {0x000000FF, 0x0000FF00, 0x00FF0000, 3, 0x000000FF, 0x0000FF00, 0x00FF0000, - 0, Blit_3or4_to_3or4__same_rgb, NO_ALPHA | SET_ALPHA}, - {0x00FF0000, 0x0000FF00, 0x000000FF, 3, 0x00FF0000, 0x0000FF00, 0x000000FF, - 0, Blit_3or4_to_3or4__same_rgb, NO_ALPHA | SET_ALPHA}, + { 0x000000FF, 0x0000FF00, 0x00FF0000, 3, 0x000000FF, 0x0000FF00, 0x00FF0000, + 0, Blit_3or4_to_3or4__same_rgb, NO_ALPHA | SET_ALPHA }, + { 0x00FF0000, 0x0000FF00, 0x000000FF, 3, 0x00FF0000, 0x0000FF00, 0x000000FF, + 0, Blit_3or4_to_3or4__same_rgb, NO_ALPHA | SET_ALPHA }, /* 4->3 with inversed rgb triplet */ - {0x000000FF, 0x0000FF00, 0x00FF0000, 3, 0x00FF0000, 0x0000FF00, 0x000000FF, - 0, Blit_3or4_to_3or4__inversed_rgb, NO_ALPHA | SET_ALPHA}, - {0x00FF0000, 0x0000FF00, 0x000000FF, 3, 0x000000FF, 0x0000FF00, 0x00FF0000, - 0, Blit_3or4_to_3or4__inversed_rgb, NO_ALPHA | SET_ALPHA}, + { 0x000000FF, 0x0000FF00, 0x00FF0000, 3, 0x00FF0000, 0x0000FF00, 0x000000FF, + 0, Blit_3or4_to_3or4__inversed_rgb, NO_ALPHA | SET_ALPHA }, + { 0x00FF0000, 0x0000FF00, 0x000000FF, 3, 0x000000FF, 0x0000FF00, 0x00FF0000, + 0, Blit_3or4_to_3or4__inversed_rgb, NO_ALPHA | SET_ALPHA }, /* 4->4 with inversed rgb triplet, and COPY_ALPHA to switch ABGR8888 <-> ARGB8888 */ - {0x000000FF, 0x0000FF00, 0x00FF0000, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, - 0, Blit_3or4_to_3or4__inversed_rgb, + { 0x000000FF, 0x0000FF00, 0x00FF0000, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, + 0, Blit_3or4_to_3or4__inversed_rgb, #if HAVE_FAST_WRITE_INT8 - NO_ALPHA | + NO_ALPHA | #endif - SET_ALPHA | COPY_ALPHA}, - {0x00FF0000, 0x0000FF00, 0x000000FF, 4, 0x000000FF, 0x0000FF00, 0x00FF0000, - 0, Blit_3or4_to_3or4__inversed_rgb, + SET_ALPHA | COPY_ALPHA }, + { 0x00FF0000, 0x0000FF00, 0x000000FF, 4, 0x000000FF, 0x0000FF00, 0x00FF0000, + 0, Blit_3or4_to_3or4__inversed_rgb, #if HAVE_FAST_WRITE_INT8 - NO_ALPHA | + NO_ALPHA | #endif - SET_ALPHA | COPY_ALPHA}, + SET_ALPHA | COPY_ALPHA }, /* RGB 888 and RGB 565 */ - {0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x0000F800, 0x000007E0, 0x0000001F, - 0, Blit_RGB888_RGB565, NO_ALPHA}, - {0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x00007C00, 0x000003E0, 0x0000001F, - 0, Blit_RGB888_RGB555, NO_ALPHA}, + { 0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x0000F800, 0x000007E0, 0x0000001F, + 0, Blit_RGB888_RGB565, NO_ALPHA }, + { 0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x00007C00, 0x000003E0, 0x0000001F, + 0, Blit_RGB888_RGB555, NO_ALPHA }, /* Default for 32-bit RGB source, used if no other blitter matches */ - {0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0} + { 0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0 } }; static const struct blit_table *const normal_blit[] = { @@ -3372,7 +3322,7 @@ static const struct blit_table *const normal_blit[] = { #define MASKOK(x, y) (((x) == (y)) || ((y) == 0x00000000)) SDL_BlitFunc -SDL_CalculateBlitN(SDL_Surface * surface) +SDL_CalculateBlitN(SDL_Surface *surface) { SDL_PixelFormat *srcfmt; SDL_PixelFormat *dstfmt; @@ -3399,9 +3349,9 @@ SDL_CalculateBlitN(SDL_Surface * surface) (srcfmt->Bmask == 0x000000FF)) { blitfun = Blit_RGB888_index8; } else if ((srcfmt->BytesPerPixel == 4) && - (srcfmt->Rmask == 0x3FF00000) && - (srcfmt->Gmask == 0x000FFC00) && - (srcfmt->Bmask == 0x000003FF)) { + (srcfmt->Rmask == 0x3FF00000) && + (srcfmt->Gmask == 0x000FFC00) && + (srcfmt->Bmask == 0x000003FF)) { blitfun = Blit_RGB101010_index8; } else { blitfun = BlitNto1; @@ -3429,16 +3379,16 @@ SDL_CalculateBlitN(SDL_Surface * surface) } blitfun = table[which].blitfunc; - if (blitfun == BlitNtoN) { /* default C fallback catch-all. Slow! */ + if (blitfun == BlitNtoN) { /* default C fallback catch-all. Slow! */ if (srcfmt->format == SDL_PIXELFORMAT_ARGB2101010) { blitfun = Blit2101010toN; } else if (dstfmt->format == SDL_PIXELFORMAT_ARGB2101010) { blitfun = BlitNto2101010; } else if (srcfmt->BytesPerPixel == 4 && - dstfmt->BytesPerPixel == 4 && - srcfmt->Rmask == dstfmt->Rmask && - srcfmt->Gmask == dstfmt->Gmask && - srcfmt->Bmask == dstfmt->Bmask) { + dstfmt->BytesPerPixel == 4 && + srcfmt->Rmask == dstfmt->Rmask && + srcfmt->Gmask == dstfmt->Gmask && + srcfmt->Bmask == dstfmt->Bmask) { if (a_need == COPY_ALPHA) { if (srcfmt->Amask == dstfmt->Amask) { /* Fastpath C fallback: 32bit RGBA<->RGBA blit with matching RGBA */ @@ -3468,12 +3418,11 @@ SDL_CalculateBlitN(SDL_Surface * surface) return BlitNto1Key; else { #if SDL_ALTIVEC_BLITTERS - if ((srcfmt->BytesPerPixel == 4) && (dstfmt->BytesPerPixel == 4) - && SDL_HasAltiVec()) { + if ((srcfmt->BytesPerPixel == 4) && (dstfmt->BytesPerPixel == 4) && SDL_HasAltiVec()) { return Blit32to32KeyAltivec; } else #endif - if (srcfmt->Amask && dstfmt->Amask) { + if (srcfmt->Amask && dstfmt->Amask) { return BlitNtoNKeyCopyAlpha; } else { return BlitNtoNKey; diff --git a/src/video/SDL_blit_copy.c b/src/video/SDL_blit_copy.c index 91e2de982..5812c5f8e 100644 --- a/src/video/SDL_blit_copy.c +++ b/src/video/SDL_blit_copy.c @@ -24,25 +24,23 @@ #include "SDL_blit.h" #include "SDL_blit_copy.h" - #ifdef __SSE__ /* This assumes 16-byte aligned src and dst */ -static SDL_INLINE void -SDL_memcpySSE(Uint8 * dst, const Uint8 * src, int len) +static SDL_INLINE void SDL_memcpySSE(Uint8 *dst, const Uint8 *src, int len) { int i; __m128 values[4]; for (i = len / 64; i--;) { _mm_prefetch((const char *)src, _MM_HINT_NTA); - values[0] = *(__m128 *) (src + 0); - values[1] = *(__m128 *) (src + 16); - values[2] = *(__m128 *) (src + 32); - values[3] = *(__m128 *) (src + 48); - _mm_stream_ps((float *) (dst + 0), values[0]); - _mm_stream_ps((float *) (dst + 16), values[1]); - _mm_stream_ps((float *) (dst + 32), values[2]); - _mm_stream_ps((float *) (dst + 48), values[3]); + values[0] = *(__m128 *)(src + 0); + values[1] = *(__m128 *)(src + 16); + values[2] = *(__m128 *)(src + 32); + values[3] = *(__m128 *)(src + 48); + _mm_stream_ps((float *)(dst + 0), values[0]); + _mm_stream_ps((float *)(dst + 16), values[1]); + _mm_stream_ps((float *)(dst + 32), values[2]); + _mm_stream_ps((float *)(dst + 48), values[3]); src += 64; dst += 64; } @@ -55,18 +53,17 @@ SDL_memcpySSE(Uint8 * dst, const Uint8 * src, int len) #ifdef __MMX__ #ifdef _MSC_VER -#pragma warning(disable:4799) +#pragma warning(disable : 4799) #endif -static SDL_INLINE void -SDL_memcpyMMX(Uint8 * dst, const Uint8 * src, int len) +static SDL_INLINE void SDL_memcpyMMX(Uint8 *dst, const Uint8 *src, int len) { const int remain = (len & 63); int i; - __m64* d64 = (__m64*)dst; - __m64* s64 = (__m64*)src; + __m64 *d64 = (__m64 *)dst; + __m64 *s64 = (__m64 *)src; - for (i= len / 64; i--;) { + for (i = len / 64; i--;) { d64[0] = s64[0]; d64[1] = s64[1]; d64[2] = s64[2]; @@ -87,8 +84,7 @@ SDL_memcpyMMX(Uint8 * dst, const Uint8 * src, int len) } #endif /* __MMX__ */ -void -SDL_BlitCopy(SDL_BlitInfo * info) +void SDL_BlitCopy(SDL_BlitInfo *info) { SDL_bool overlap; Uint8 *src, *dst; @@ -104,33 +100,33 @@ SDL_BlitCopy(SDL_BlitInfo * info) /* Properly handle overlapping blits */ if (src < dst) { - overlap = (dst < (src + h*srcskip)); + overlap = (dst < (src + h * srcskip)); } else { - overlap = (src < (dst + h*dstskip)); + overlap = (src < (dst + h * dstskip)); } if (overlap) { - if ( dst < src ) { - while ( h-- ) { - SDL_memmove(dst, src, w); - src += srcskip; - dst += dstskip; - } + if (dst < src) { + while (h--) { + SDL_memmove(dst, src, w); + src += srcskip; + dst += dstskip; + } } else { - src += ((h-1) * srcskip); - dst += ((h-1) * dstskip); - while ( h-- ) { - SDL_memmove(dst, src, w); - src -= srcskip; - dst -= dstskip; - } + src += ((h - 1) * srcskip); + dst += ((h - 1) * dstskip); + while (h--) { + SDL_memmove(dst, src, w); + src -= srcskip; + dst -= dstskip; + } } return; } #ifdef __SSE__ if (SDL_HasSSE() && - !((uintptr_t) src & 15) && !(srcskip & 15) && - !((uintptr_t) dst & 15) && !(dstskip & 15)) { + !((uintptr_t)src & 15) && !(srcskip & 15) && + !((uintptr_t)dst & 15) && !(dstskip & 15)) { while (h--) { SDL_memcpySSE(dst, src, w); src += srcskip; diff --git a/src/video/SDL_blit_copy.h b/src/video/SDL_blit_copy.h index 24ced5241..446f2ac82 100644 --- a/src/video/SDL_blit_copy.h +++ b/src/video/SDL_blit_copy.h @@ -22,7 +22,7 @@ #ifndef SDL_blit_copy_h_ #define SDL_blit_copy_h_ -void SDL_BlitCopy(SDL_BlitInfo * info); +void SDL_BlitCopy(SDL_BlitInfo *info); #endif /* SDL_blit_copy_h_ */ diff --git a/src/video/SDL_blit_slow.c b/src/video/SDL_blit_slow.c index ebcb825e5..a64b2805f 100644 --- a/src/video/SDL_blit_slow.c +++ b/src/video/SDL_blit_slow.c @@ -24,12 +24,13 @@ #include "SDL_blit.h" #include "SDL_blit_slow.h" -#define FORMAT_ALPHA 0 -#define FORMAT_NO_ALPHA -1 -#define FORMAT_2101010 1 -#define FORMAT_HAS_ALPHA(format) format == 0 -#define FORMAT_HAS_NO_ALPHA(format) format < 0 -static int SDL_INLINE detect_format(SDL_PixelFormat *pf) { +#define FORMAT_ALPHA 0 +#define FORMAT_NO_ALPHA -1 +#define FORMAT_2101010 1 +#define FORMAT_HAS_ALPHA(format) format == 0 +#define FORMAT_HAS_NO_ALPHA(format) format < 0 +static int SDL_INLINE detect_format(SDL_PixelFormat *pf) +{ if (pf->format == SDL_PIXELFORMAT_ARGB2101010) { return FORMAT_2101010; } else if (pf->Amask) { @@ -42,8 +43,7 @@ static int SDL_INLINE detect_format(SDL_PixelFormat *pf) { /* The ONE TRUE BLITTER * This puppy has to handle all the unoptimized cases - yes, it's slow. */ -void -SDL_Blit_Slow(SDL_BlitInfo * info) +void SDL_Blit_Slow(SDL_BlitInfo *info) { const int flags = info->flags; const Uint32 modulateR = info->r; @@ -98,7 +98,7 @@ SDL_Blit_Slow(SDL_BlitInfo * info) /* srcpixel isn't set for 24 bpp */ if (srcbpp == 3) { srcpixel = (srcR << src_fmt->Rshift) | - (srcG << src_fmt->Gshift) | (srcB << src_fmt->Bshift); + (srcG << src_fmt->Gshift) | (srcB << src_fmt->Bshift); } if ((srcpixel & rgbmask) == ckey) { posx += incx; diff --git a/src/video/SDL_blit_slow.h b/src/video/SDL_blit_slow.h index cb5388a3e..84e46251b 100644 --- a/src/video/SDL_blit_slow.h +++ b/src/video/SDL_blit_slow.h @@ -24,7 +24,7 @@ #include "../SDL_internal.h" -extern void SDL_Blit_Slow(SDL_BlitInfo * info); +extern void SDL_Blit_Slow(SDL_BlitInfo *info); #endif /* SDL_blit_slow_h_ */ diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c index 884580d87..bfd87cbfb 100644 --- a/src/video/SDL_bmp.c +++ b/src/video/SDL_bmp.c @@ -41,19 +41,19 @@ /* Compression encodings for BMP files */ #ifndef BI_RGB -#define BI_RGB 0 -#define BI_RLE8 1 -#define BI_RLE4 2 -#define BI_BITFIELDS 3 +#define BI_RGB 0 +#define BI_RLE8 1 +#define BI_RLE4 2 +#define BI_BITFIELDS 3 #endif /* Logical color space values for BMP files */ #ifndef LCS_WINDOWS_COLOR_SPACE /* 0x57696E20 == "Win " */ -#define LCS_WINDOWS_COLOR_SPACE 0x57696E20 +#define LCS_WINDOWS_COLOR_SPACE 0x57696E20 #endif -static SDL_bool readRlePixels(SDL_Surface * surface, SDL_RWops * src, int isRle8) +static SDL_bool readRlePixels(SDL_Surface *surface, SDL_RWops *src, int isRle8) { /* | Sets the surface pixels from src. A bmp image is upside down. @@ -61,13 +61,16 @@ static SDL_bool readRlePixels(SDL_Surface * surface, SDL_RWops * src, int isRle8 int pitch = surface->pitch; int height = surface->h; Uint8 *start = (Uint8 *)surface->pixels; - Uint8 *end = start + (height*pitch); - Uint8 *bits = end-pitch, *spot; + Uint8 *end = start + (height * pitch); + Uint8 *bits = end - pitch, *spot; int ofs = 0; Uint8 ch; Uint8 needsPad; -#define COPY_PIXEL(x) spot = &bits[ofs++]; if (spot >= start && spot < end) *spot = (x) +#define COPY_PIXEL(x) \ + spot = &bits[ofs++]; \ + if (spot >= start && spot < end) \ + *spot = (x) for (;;) { if (!SDL_RWread(src, &ch, 1, 1)) { @@ -82,21 +85,21 @@ static SDL_bool readRlePixels(SDL_Surface * surface, SDL_RWops * src, int isRle8 if (!SDL_RWread(src, &pixel, 1, 1)) { return SDL_TRUE; } - if (isRle8) { /* 256-color bitmap, compressed */ + if (isRle8) { /* 256-color bitmap, compressed */ do { COPY_PIXEL(pixel); } while (--ch); - } else { /* 16-color bitmap, compressed */ + } else { /* 16-color bitmap, compressed */ Uint8 pixel0 = pixel >> 4; Uint8 pixel1 = pixel & 0x0F; for (;;) { COPY_PIXEL(pixel0); /* even count, high nibble */ if (!--ch) { - break; + break; } COPY_PIXEL(pixel1); /* odd count, low nibble */ if (!--ch) { - break; + break; } } } @@ -110,13 +113,13 @@ static SDL_bool readRlePixels(SDL_Surface * surface, SDL_RWops * src, int isRle8 return SDL_TRUE; } switch (ch) { - case 0: /* end of line */ + case 0: /* end of line */ ofs = 0; - bits -= pitch; /* go to previous */ + bits -= pitch; /* go to previous */ break; - case 1: /* end of bitmap */ - return SDL_FALSE; /* success! */ - case 2: /* delta */ + case 1: /* end of bitmap */ + return SDL_FALSE; /* success! */ + case 2: /* delta */ if (!SDL_RWread(src, &ch, 1, 1)) { return SDL_TRUE; } @@ -126,7 +129,7 @@ static SDL_bool readRlePixels(SDL_Surface * surface, SDL_RWops * src, int isRle8 } bits -= (ch * pitch); break; - default: /* no compression */ + default: /* no compression */ if (isRle8) { needsPad = (ch & 1); do { @@ -137,7 +140,7 @@ static SDL_bool readRlePixels(SDL_Surface * surface, SDL_RWops * src, int isRle8 COPY_PIXEL(pixel); } while (--ch); } else { - needsPad = (((ch+1)>>1) & 1); /* (ch+1)>>1: bytes size */ + needsPad = (((ch + 1) >> 1) & 1); /* (ch+1)>>1: bytes size */ for (;;) { Uint8 pixel; if (!SDL_RWread(src, &pixel, 1, 1)) { @@ -172,7 +175,7 @@ static void CorrectAlphaChannel(SDL_Surface *surface) #else int alphaChannelOffset = 3; #endif - Uint8 *alpha = ((Uint8*)surface->pixels) + alphaChannelOffset; + Uint8 *alpha = ((Uint8 *)surface->pixels) + alphaChannelOffset; Uint8 *end = alpha + surface->h * surface->pitch; while (alpha < end) { @@ -184,7 +187,7 @@ static void CorrectAlphaChannel(SDL_Surface *surface) } if (!hasAlpha) { - alpha = ((Uint8*)surface->pixels) + alphaChannelOffset; + alpha = ((Uint8 *)surface->pixels) + alphaChannelOffset; while (alpha < end) { *alpha = SDL_ALPHA_OPAQUE; alpha += 4; @@ -193,7 +196,7 @@ static void CorrectAlphaChannel(SDL_Surface *surface) } SDL_Surface * -SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) +SDL_LoadBMP_RW(SDL_RWops *src, int freesrc) { SDL_bool was_error; Sint64 fp_offset = 0; @@ -262,13 +265,13 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) /* bfSize = */ SDL_ReadLE32(src); /* bfReserved1 = */ SDL_ReadLE16(src); /* bfReserved2 = */ SDL_ReadLE16(src); - bfOffBits = SDL_ReadLE32(src); + bfOffBits = SDL_ReadLE32(src); /* Read the Win32 BITMAPINFOHEADER */ biSize = SDL_ReadLE32(src); - if (biSize == 12) { /* really old BITMAPCOREHEADER */ - biWidth = (Uint32) SDL_ReadLE16(src); - biHeight = (Uint32) SDL_ReadLE16(src); + if (biSize == 12) { /* really old BITMAPCOREHEADER */ + biWidth = (Uint32)SDL_ReadLE16(src); + biHeight = (Uint32)SDL_ReadLE16(src); /* biPlanes = */ SDL_ReadLE16(src); biBitCount = SDL_ReadLE16(src); biCompression = BI_RGB; @@ -277,7 +280,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) /* biYPelsPerMeter = 0; */ biClrUsed = 0; /* biClrImportant = 0; */ - } else if (biSize >= 40) { /* some version of BITMAPINFOHEADER */ + } else if (biSize >= 40) { /* some version of BITMAPINFOHEADER */ Uint32 headerSize; biWidth = SDL_ReadLE32(src); biHeight = SDL_ReadLE32(src); @@ -306,18 +309,18 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) Bmask = SDL_ReadLE32(src); /* ...v3 adds an alpha mask. */ - if (biSize >= 56) { /* BITMAPV3INFOHEADER; adds alpha mask */ + if (biSize >= 56) { /* BITMAPV3INFOHEADER; adds alpha mask */ haveAlphaMask = SDL_TRUE; Amask = SDL_ReadLE32(src); } } else { /* the mask fields are ignored for v2+ headers if not BI_BITFIELD. */ - if (biSize >= 52) { /* BITMAPV2INFOHEADER; adds RGB masks */ + if (biSize >= 52) { /* BITMAPV2INFOHEADER; adds RGB masks */ /*Rmask = */ SDL_ReadLE32(src); /*Gmask = */ SDL_ReadLE32(src); /*Bmask = */ SDL_ReadLE32(src); } - if (biSize >= 56) { /* BITMAPV3INFOHEADER; adds alpha mask */ + if (biSize >= 56) { /* BITMAPV3INFOHEADER; adds alpha mask */ /*Amask = */ SDL_ReadLE32(src); } } @@ -329,7 +332,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) } /* skip any header bytes we didn't handle... */ - headerSize = (Uint32) (SDL_RWtell(src) - (fp_offset + 14)); + headerSize = (Uint32)(SDL_RWtell(src) - (fp_offset + 14)); if (biSize > headerSize) { SDL_RWseek(src, (biSize - headerSize), RW_SEEK_CUR); } @@ -412,7 +415,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) break; case BI_BITFIELDS: - break; /* we handled this in the info header. */ + break; /* we handled this in the info header. */ default: break; @@ -430,13 +433,13 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) /* Load the palette, if any */ palette = (surface->format)->palette; if (palette) { - if (SDL_RWseek(src, fp_offset+14+biSize, RW_SEEK_SET) < 0) { + if (SDL_RWseek(src, fp_offset + 14 + biSize, RW_SEEK_SET) < 0) { SDL_Error(SDL_EFSEEK); was_error = SDL_TRUE; goto done; } - if (biBitCount >= 32) { /* we shift biClrUsed by this value later. */ + if (biBitCount >= 32) { /* we shift biClrUsed by this value later. */ SDL_SetError("Unsupported or incorrect biBitCount field"); was_error = SDL_TRUE; goto done; @@ -447,7 +450,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) } if (biClrUsed > (Uint32)palette->ncolors) { - biClrUsed = 1 << biBitCount; /* try forcing it? */ + biClrUsed = 1 << biBitCount; /* try forcing it? */ if (biClrUsed > (Uint32)palette->ncolors) { SDL_SetError("Unsupported or incorrect biClrUsed field"); was_error = SDL_TRUE; @@ -455,15 +458,15 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) } } - if (biSize == 12) { - for (i = 0; i < (int) biClrUsed; ++i) { + if (biSize == 12) { + for (i = 0; i < (int)biClrUsed; ++i) { SDL_RWread(src, &palette->colors[i].b, 1, 1); SDL_RWread(src, &palette->colors[i].g, 1, 1); SDL_RWread(src, &palette->colors[i].r, 1, 1); palette->colors[i].a = SDL_ALPHA_OPAQUE; } } else { - for (i = 0; i < (int) biClrUsed; ++i) { + for (i = 0; i < (int)biClrUsed; ++i) { SDL_RWread(src, &palette->colors[i].b, 1, 1); SDL_RWread(src, &palette->colors[i].g, 1, 1); SDL_RWread(src, &palette->colors[i].r, 1, 1); @@ -493,7 +496,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) goto done; } top = (Uint8 *)surface->pixels; - end = (Uint8 *)surface->pixels+(surface->h*surface->pitch); + end = (Uint8 *)surface->pixels + (surface->h * surface->pitch); switch (ExpandBMP) { case 1: bmpPitch = (biWidth + 7) >> 3; @@ -520,27 +523,27 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) switch (ExpandBMP) { case 1: case 2: - case 4:{ - Uint8 pixel = 0; - int shift = (8 - ExpandBMP); - for (i = 0; i < surface->w; ++i) { - if (i % (8 / ExpandBMP) == 0) { - if (!SDL_RWread(src, &pixel, 1, 1)) { - SDL_Error(SDL_EFREAD); - was_error = SDL_TRUE; - goto done; - } - } - bits[i] = (pixel >> shift); - if (bits[i] >= biClrUsed) { - SDL_SetError("A BMP image contains a pixel with a color out of the palette"); + case 4: + { + Uint8 pixel = 0; + int shift = (8 - ExpandBMP); + for (i = 0; i < surface->w; ++i) { + if (i % (8 / ExpandBMP) == 0) { + if (!SDL_RWread(src, &pixel, 1, 1)) { + SDL_Error(SDL_EFREAD); was_error = SDL_TRUE; goto done; } - pixel <<= ExpandBMP; } + bits[i] = (pixel >> shift); + if (bits[i] >= biClrUsed) { + SDL_SetError("A BMP image contains a pixel with a color out of the palette"); + was_error = SDL_TRUE; + goto done; + } + pixel <<= ExpandBMP; } - break; + } break; default: if (SDL_RWread(src, bits, 1, surface->pitch) != surface->pitch) { @@ -562,21 +565,23 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) case has already been taken care of above. */ switch (biBitCount) { case 15: - case 16:{ - Uint16 *pix = (Uint16 *) bits; - for (i = 0; i < surface->w; i++) { - pix[i] = SDL_Swap16(pix[i]); - } - break; + case 16: + { + Uint16 *pix = (Uint16 *)bits; + for (i = 0; i < surface->w; i++) { + pix[i] = SDL_Swap16(pix[i]); } + break; + } - case 32:{ - Uint32 *pix = (Uint32 *) bits; - for (i = 0; i < surface->w; i++) { - pix[i] = SDL_Swap32(pix[i]); - } - break; + case 32: + { + Uint32 *pix = (Uint32 *)bits; + for (i = 0; i < surface->w; i++) { + pix[i] = SDL_Swap32(pix[i]); } + break; + } } #endif break; @@ -597,7 +602,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) if (correctAlpha) { CorrectAlphaChannel(surface); } - done: +done: if (was_error) { if (src) { SDL_RWseek(src, fp_offset, RW_SEEK_SET); @@ -611,8 +616,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) return surface; } -int -SDL_SaveBMP_RW(SDL_Surface * saveme, SDL_RWops * dst, int freedst) +int SDL_SaveBMP_RW(SDL_Surface *saveme, SDL_RWops *dst, int freedst) { Sint64 fp_offset; int i, pad; @@ -647,7 +651,7 @@ SDL_SaveBMP_RW(SDL_Surface * saveme, SDL_RWops * dst, int freedst) Uint32 bV4BlueMask = 0; Uint32 bV4AlphaMask = 0; Uint32 bV4CSType = 0; - Sint32 bV4Endpoints[3 * 3] = {0}; + Sint32 bV4Endpoints[3 * 3] = { 0 }; Uint32 bV4GammaRed = 0; Uint32 bV4GammaGreen = 0; Uint32 bV4GammaBlue = 0; @@ -658,7 +662,7 @@ SDL_SaveBMP_RW(SDL_Surface * saveme, SDL_RWops * dst, int freedst) #ifdef SAVE_32BIT_BMP /* We can save alpha information in a 32-bit BMP */ if (saveme->format->BitsPerPixel >= 8 && (saveme->format->Amask || - saveme->map->info.flags & SDL_COPY_COLORKEY)) { + saveme->map->info.flags & SDL_COPY_COLORKEY)) { save32bit = SDL_TRUE; } #endif /* SAVE_32BIT_BMP */ @@ -680,7 +684,7 @@ SDL_SaveBMP_RW(SDL_Surface * saveme, SDL_RWops * dst, int freedst) (saveme->format->Gmask == 0x0000FF00) && (saveme->format->Bmask == 0x00FF0000) #endif - ) { + ) { surface = saveme; } else { SDL_PixelFormat format; @@ -712,10 +716,10 @@ SDL_SaveBMP_RW(SDL_Surface * saveme, SDL_RWops * dst, int freedst) const int bw = surface->w * surface->format->BytesPerPixel; /* Set the BMP file header values */ - bfSize = 0; /* We'll write this when we're done */ + bfSize = 0; /* We'll write this when we're done */ bfReserved1 = 0; bfReserved2 = 0; - bfOffBits = 0; /* We'll write this when we're done */ + bfOffBits = 0; /* We'll write this when we're done */ /* Write the BMP file header values */ fp_offset = SDL_RWtell(dst); @@ -748,9 +752,9 @@ SDL_SaveBMP_RW(SDL_Surface * saveme, SDL_RWops * dst, int freedst) biSize = 108; biCompression = BI_BITFIELDS; /* The BMP format is always little endian, these masks stay the same */ - bV4RedMask = 0x00ff0000; + bV4RedMask = 0x00ff0000; bV4GreenMask = 0x0000ff00; - bV4BlueMask = 0x000000ff; + bV4BlueMask = 0x000000ff; bV4AlphaMask = 0xff000000; bV4CSType = LCS_WINDOWS_COLOR_SPACE; bV4GammaRed = 0; @@ -812,9 +816,9 @@ SDL_SaveBMP_RW(SDL_Surface * saveme, SDL_RWops * dst, int freedst) } /* Write the bitmap image upside down */ - bits = (Uint8 *) surface->pixels + (surface->h * surface->pitch); + bits = (Uint8 *)surface->pixels + (surface->h * surface->pitch); pad = ((bw % 4) ? (4 - (bw % 4)) : 0); - while (bits > (Uint8 *) surface->pixels) { + while (bits > (Uint8 *)surface->pixels) { bits -= surface->pitch; if (SDL_RWwrite(dst, bits, 1, bw) != bw) { SDL_Error(SDL_EFWRITE); diff --git a/src/video/SDL_clipboard.c b/src/video/SDL_clipboard.c index f1ce89293..5aac7230e 100644 --- a/src/video/SDL_clipboard.c +++ b/src/video/SDL_clipboard.c @@ -23,9 +23,7 @@ #include "SDL_clipboard.h" #include "SDL_sysvideo.h" - -int -SDL_SetClipboardText(const char *text) +int SDL_SetClipboardText(const char *text) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); @@ -45,8 +43,7 @@ SDL_SetClipboardText(const char *text) } } -int -SDL_SetPrimarySelectionText(const char *text) +int SDL_SetPrimarySelectionText(const char *text) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index d6385e0ce..034e0c453 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -1,15 +1,15 @@ /* * Simple DirectMedia Layer * Copyright (C) 1997-2022 Sam Lantinga - * + * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. - * + * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: - * + * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be @@ -47,62 +47,62 @@ #ifndef EGL_EXT_pixel_format_float #define EGL_EXT_pixel_format_float -#define EGL_COLOR_COMPONENT_TYPE_EXT 0x3339 +#define EGL_COLOR_COMPONENT_TYPE_EXT 0x3339 #define EGL_COLOR_COMPONENT_TYPE_FIXED_EXT 0x333A #define EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT 0x333B #endif #ifndef EGL_EXT_present_opaque #define EGL_EXT_present_opaque 1 -#define EGL_PRESENT_OPAQUE_EXT 0x31DF +#define EGL_PRESENT_OPAQUE_EXT 0x31DF #endif /* EGL_EXT_present_opaque */ #if SDL_VIDEO_DRIVER_RPI /* Raspbian places the OpenGL ES/EGL binaries in a non standard path */ -#define DEFAULT_EGL ( vc4 ? "libEGL.so.1" : "libbrcmEGL.so" ) -#define DEFAULT_OGL_ES2 ( vc4 ? "libGLESv2.so.2" : "libbrcmGLESv2.so" ) -#define ALT_EGL "libEGL.so" -#define ALT_OGL_ES2 "libGLESv2.so" -#define DEFAULT_OGL_ES_PVR ( vc4 ? "libGLES_CM.so.1" : "libbrcmGLESv2.so" ) -#define DEFAULT_OGL_ES ( vc4 ? "libGLESv1_CM.so.1" : "libbrcmGLESv2.so" ) +#define DEFAULT_EGL (vc4 ? "libEGL.so.1" : "libbrcmEGL.so") +#define DEFAULT_OGL_ES2 (vc4 ? "libGLESv2.so.2" : "libbrcmGLESv2.so") +#define ALT_EGL "libEGL.so" +#define ALT_OGL_ES2 "libGLESv2.so" +#define DEFAULT_OGL_ES_PVR (vc4 ? "libGLES_CM.so.1" : "libbrcmGLESv2.so") +#define DEFAULT_OGL_ES (vc4 ? "libGLESv1_CM.so.1" : "libbrcmGLESv2.so") #elif SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_VIVANTE /* Android */ -#define DEFAULT_EGL "libEGL.so" -#define DEFAULT_OGL_ES2 "libGLESv2.so" +#define DEFAULT_EGL "libEGL.so" +#define DEFAULT_OGL_ES2 "libGLESv2.so" #define DEFAULT_OGL_ES_PVR "libGLES_CM.so" -#define DEFAULT_OGL_ES "libGLESv1_CM.so" +#define DEFAULT_OGL_ES "libGLESv1_CM.so" #elif SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT /* EGL AND OpenGL ES support via ANGLE */ #define DEFAULT_EGL "libEGL.dll" #define DEFAULT_OGL_ES2 "libGLESv2.dll" #define DEFAULT_OGL_ES_PVR "libGLES_CM.dll" -#define DEFAULT_OGL_ES "libGLESv1_CM.dll" +#define DEFAULT_OGL_ES "libGLESv1_CM.dll" #elif SDL_VIDEO_DRIVER_COCOA /* EGL AND OpenGL ES support via ANGLE */ -#define DEFAULT_EGL "libEGL.dylib" -#define DEFAULT_OGL_ES2 "libGLESv2.dylib" +#define DEFAULT_EGL "libEGL.dylib" +#define DEFAULT_OGL_ES2 "libGLESv2.dylib" #define DEFAULT_OGL_ES_PVR "libGLES_CM.dylib" //??? -#define DEFAULT_OGL_ES "libGLESv1_CM.dylib" //??? +#define DEFAULT_OGL_ES "libGLESv1_CM.dylib" //??? #elif defined(__OpenBSD__) /* OpenBSD */ -#define DEFAULT_OGL "libGL.so" -#define DEFAULT_EGL "libEGL.so" -#define DEFAULT_OGL_ES2 "libGLESv2.so" +#define DEFAULT_OGL "libGL.so" +#define DEFAULT_EGL "libEGL.so" +#define DEFAULT_OGL_ES2 "libGLESv2.so" #define DEFAULT_OGL_ES_PVR "libGLES_CM.so" -#define DEFAULT_OGL_ES "libGLESv1_CM.so" +#define DEFAULT_OGL_ES "libGLESv1_CM.so" #else /* Desktop Linux/Unix-like */ -#define DEFAULT_OGL "libGL.so.1" -#define DEFAULT_EGL "libEGL.so.1" -#define ALT_OGL "libOpenGL.so.0" -#define DEFAULT_OGL_ES2 "libGLESv2.so.2" +#define DEFAULT_OGL "libGL.so.1" +#define DEFAULT_EGL "libEGL.so.1" +#define ALT_OGL "libOpenGL.so.0" +#define DEFAULT_OGL_ES2 "libGLESv2.so.2" #define DEFAULT_OGL_ES_PVR "libGLES_CM.so.1" -#define DEFAULT_OGL_ES "libGLESv1_CM.so.1" +#define DEFAULT_OGL_ES "libGLESv1_CM.so.1" #endif /* SDL_VIDEO_DRIVER_RPI */ #if SDL_VIDEO_OPENGL && !SDL_VIDEO_VITA_PVR_OGL @@ -118,23 +118,24 @@ #if defined(SDL_VIDEO_STATIC_ANGLE) || defined(SDL_VIDEO_DRIVER_VITA) #define LOAD_FUNC(NAME) \ -_this->egl_data->NAME = (void *)NAME; + _this->egl_data->NAME = (void *)NAME; #else -#define LOAD_FUNC(NAME) \ -_this->egl_data->NAME = SDL_LoadFunction(_this->egl_data->egl_dll_handle, #NAME); \ -if (!_this->egl_data->NAME) \ -{ \ - return SDL_SetError("Could not retrieve EGL function " #NAME); \ -} +#define LOAD_FUNC(NAME) \ + _this->egl_data->NAME = SDL_LoadFunction(_this->egl_data->egl_dll_handle, #NAME); \ + if (!_this->egl_data->NAME) { \ + return SDL_SetError("Could not retrieve EGL function " #NAME); \ + } #endif /* it is allowed to not have some of the EGL extensions on start - attempts to use them will fail later. */ #define LOAD_FUNC_EGLEXT(NAME) \ _this->egl_data->NAME = _this->egl_data->eglGetProcAddress(#NAME); -static const char * SDL_EGL_GetErrorName(EGLint eglErrorCode) +static const char *SDL_EGL_GetErrorName(EGLint eglErrorCode) { -#define SDL_EGL_ERROR_TRANSLATE(e) case e: return #e; +#define SDL_EGL_ERROR_TRANSLATE(e) \ + case e: \ + return #e; switch (eglErrorCode) { SDL_EGL_ERROR_TRANSLATE(EGL_SUCCESS); SDL_EGL_ERROR_TRANSLATE(EGL_NOT_INITIALIZED); @@ -155,9 +156,9 @@ static const char * SDL_EGL_GetErrorName(EGLint eglErrorCode) return ""; } -int SDL_EGL_SetErrorEx(const char * message, const char * eglFunctionName, EGLint eglErrorCode) +int SDL_EGL_SetErrorEx(const char *message, const char *eglFunctionName, EGLint eglErrorCode) { - const char * errorText = SDL_EGL_GetErrorName(eglErrorCode); + const char *errorText = SDL_EGL_GetErrorName(eglErrorCode); char altErrorText[32]; if (errorText[0] == '\0') { /* An unknown-to-SDL error code was reported. Report its hexadecimal value, instead of its name. */ @@ -246,20 +247,20 @@ SDL_EGL_GetProcAddress(_THIS, const char *proc) { void *retval = NULL; if (_this->egl_data != NULL) { - const Uint32 eglver = (((Uint32) _this->egl_data->egl_version_major) << 16) | ((Uint32) _this->egl_data->egl_version_minor); - const SDL_bool is_egl_15_or_later = eglver >= ((((Uint32) 1) << 16) | 5); + const Uint32 eglver = (((Uint32)_this->egl_data->egl_version_major) << 16) | ((Uint32)_this->egl_data->egl_version_minor); + const SDL_bool is_egl_15_or_later = eglver >= ((((Uint32)1) << 16) | 5); /* EGL 1.5 can use eglGetProcAddress() for any symbol. 1.4 and earlier can't use it for core entry points. */ if (retval == NULL && is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { retval = _this->egl_data->eglGetProcAddress(proc); } - #if !defined(__EMSCRIPTEN__) && !defined(SDL_VIDEO_DRIVER_VITA) /* LoadFunction isn't needed on Emscripten and will call dlsym(), causing other problems. */ +#if !defined(__EMSCRIPTEN__) && !defined(SDL_VIDEO_DRIVER_VITA) /* LoadFunction isn't needed on Emscripten and will call dlsym(), causing other problems. */ /* Try SDL_LoadFunction() first for EGL <= 1.4, or as a fallback for >= 1.5. */ if (retval == NULL) { retval = SDL_LoadFunction(_this->egl_data->opengl_dll_handle, proc); } - #endif +#endif /* Try eglGetProcAddress if we're on <= 1.4 and still searching... */ if (retval == NULL && !is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { @@ -269,8 +270,7 @@ SDL_EGL_GetProcAddress(_THIS, const char *proc) return retval; } -void -SDL_EGL_UnloadLibrary(_THIS) +void SDL_EGL_UnloadLibrary(_THIS) { if (_this->egl_data) { if (_this->egl_data->egl_display) { @@ -286,14 +286,13 @@ SDL_EGL_UnloadLibrary(_THIS) SDL_UnloadObject(_this->egl_data->opengl_dll_handle); _this->egl_data->opengl_dll_handle = NULL; } - + SDL_free(_this->egl_data); _this->egl_data = NULL; } } -static int -SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path) +static int SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path) { void *egl_dll_handle = NULL, *opengl_dll_handle = NULL; const char *path = NULL; @@ -316,7 +315,8 @@ SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path) if (WIN_IsWindowsVistaOrGreater()) { /* Try the newer d3d compilers first */ const char *d3dcompiler_list[] = { - "d3dcompiler_47.dll", "d3dcompiler_46.dll", + "d3dcompiler_47.dll", + "d3dcompiler_46.dll", }; int i; @@ -368,7 +368,7 @@ SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path) #endif } } -#ifdef DEFAULT_OGL +#ifdef DEFAULT_OGL else { path = DEFAULT_OGL; opengl_dll_handle = SDL_LoadObject(path); @@ -379,7 +379,7 @@ SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path) } #endif } -#endif +#endif } _this->egl_data->opengl_dll_handle = opengl_dll_handle; @@ -390,7 +390,7 @@ SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path) /* Loading libGL* in the previous step took care of loading libEGL.so, but we future proof by double checking */ if (egl_path != NULL) { egl_dll_handle = SDL_LoadObject(egl_path); - } + } /* Try loading a EGL symbol, if it does not work try the default library paths */ if (egl_dll_handle == NULL || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) { if (egl_dll_handle != NULL) { @@ -464,14 +464,13 @@ SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path) return 0; } -int -SDL_EGL_LoadLibraryOnly(_THIS, const char *egl_path) +int SDL_EGL_LoadLibraryOnly(_THIS, const char *egl_path) { if (_this->egl_data) { return SDL_SetError("EGL context already created"); } - _this->egl_data = (struct SDL_EGL_VideoData *) SDL_calloc(1, sizeof(SDL_EGL_VideoData)); + _this->egl_data = (struct SDL_EGL_VideoData *)SDL_calloc(1, sizeof(SDL_EGL_VideoData)); if (!_this->egl_data) { return SDL_OutOfMemory(); } @@ -484,8 +483,8 @@ SDL_EGL_LoadLibraryOnly(_THIS, const char *egl_path) return 0; } -static void -SDL_EGL_GetVersion(_THIS) { +static void SDL_EGL_GetVersion(_THIS) +{ if (_this->egl_data->eglQueryString) { const char *egl_version = _this->egl_data->eglQueryString(_this->egl_data->egl_display, EGL_VERSION); if (egl_version) { @@ -500,8 +499,7 @@ SDL_EGL_GetVersion(_THIS) { } } -int -SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_display, EGLenum platform) +int SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_display, EGLenum platform) { int library_load_retcode = SDL_EGL_LoadLibraryOnly(_this, egl_path); if (library_load_retcode != 0) { @@ -570,8 +568,7 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa valid available GPU for EGL to use. */ -int -SDL_EGL_InitializeOffscreen(_THIS, int device) +int SDL_EGL_InitializeOffscreen(_THIS, int device) { void *egl_devices[SDL_EGL_MAX_DEVICES]; EGLint num_egl_devices = 0; @@ -649,63 +646,64 @@ SDL_EGL_InitializeOffscreen(_THIS, int device) return 0; } -void -SDL_EGL_SetRequiredVisualId(_THIS, int visual_id) +void SDL_EGL_SetRequiredVisualId(_THIS, int visual_id) { - _this->egl_data->egl_required_visual_id=visual_id; + _this->egl_data->egl_required_visual_id = visual_id; } #ifdef DUMP_EGL_CONFIG -#define ATTRIBUTE(_attr) { _attr, #_attr } +#define ATTRIBUTE(_attr) \ + { \ + _attr, #_attr \ + } -typedef struct { +typedef struct +{ EGLint attribute; - char const* name; + char const *name; } Attribute; -static -Attribute all_attributes[] = { - ATTRIBUTE( EGL_BUFFER_SIZE ), - ATTRIBUTE( EGL_ALPHA_SIZE ), - ATTRIBUTE( EGL_BLUE_SIZE ), - ATTRIBUTE( EGL_GREEN_SIZE ), - ATTRIBUTE( EGL_RED_SIZE ), - ATTRIBUTE( EGL_DEPTH_SIZE ), - ATTRIBUTE( EGL_STENCIL_SIZE ), - ATTRIBUTE( EGL_CONFIG_CAVEAT ), - ATTRIBUTE( EGL_CONFIG_ID ), - ATTRIBUTE( EGL_LEVEL ), - ATTRIBUTE( EGL_MAX_PBUFFER_HEIGHT ), - ATTRIBUTE( EGL_MAX_PBUFFER_WIDTH ), - ATTRIBUTE( EGL_MAX_PBUFFER_PIXELS ), - ATTRIBUTE( EGL_NATIVE_RENDERABLE ), - ATTRIBUTE( EGL_NATIVE_VISUAL_ID ), - ATTRIBUTE( EGL_NATIVE_VISUAL_TYPE ), - ATTRIBUTE( EGL_SAMPLES ), - ATTRIBUTE( EGL_SAMPLE_BUFFERS ), - ATTRIBUTE( EGL_SURFACE_TYPE ), - ATTRIBUTE( EGL_TRANSPARENT_TYPE ), - ATTRIBUTE( EGL_TRANSPARENT_BLUE_VALUE ), - ATTRIBUTE( EGL_TRANSPARENT_GREEN_VALUE ), - ATTRIBUTE( EGL_TRANSPARENT_RED_VALUE ), - ATTRIBUTE( EGL_BIND_TO_TEXTURE_RGB ), - ATTRIBUTE( EGL_BIND_TO_TEXTURE_RGBA ), - ATTRIBUTE( EGL_MIN_SWAP_INTERVAL ), - ATTRIBUTE( EGL_MAX_SWAP_INTERVAL ), - ATTRIBUTE( EGL_LUMINANCE_SIZE ), - ATTRIBUTE( EGL_ALPHA_MASK_SIZE ), - ATTRIBUTE( EGL_COLOR_BUFFER_TYPE ), - ATTRIBUTE( EGL_RENDERABLE_TYPE ), - ATTRIBUTE( EGL_MATCH_NATIVE_PIXMAP ), - ATTRIBUTE( EGL_CONFORMANT ), +static Attribute all_attributes[] = { + ATTRIBUTE(EGL_BUFFER_SIZE), + ATTRIBUTE(EGL_ALPHA_SIZE), + ATTRIBUTE(EGL_BLUE_SIZE), + ATTRIBUTE(EGL_GREEN_SIZE), + ATTRIBUTE(EGL_RED_SIZE), + ATTRIBUTE(EGL_DEPTH_SIZE), + ATTRIBUTE(EGL_STENCIL_SIZE), + ATTRIBUTE(EGL_CONFIG_CAVEAT), + ATTRIBUTE(EGL_CONFIG_ID), + ATTRIBUTE(EGL_LEVEL), + ATTRIBUTE(EGL_MAX_PBUFFER_HEIGHT), + ATTRIBUTE(EGL_MAX_PBUFFER_WIDTH), + ATTRIBUTE(EGL_MAX_PBUFFER_PIXELS), + ATTRIBUTE(EGL_NATIVE_RENDERABLE), + ATTRIBUTE(EGL_NATIVE_VISUAL_ID), + ATTRIBUTE(EGL_NATIVE_VISUAL_TYPE), + ATTRIBUTE(EGL_SAMPLES), + ATTRIBUTE(EGL_SAMPLE_BUFFERS), + ATTRIBUTE(EGL_SURFACE_TYPE), + ATTRIBUTE(EGL_TRANSPARENT_TYPE), + ATTRIBUTE(EGL_TRANSPARENT_BLUE_VALUE), + ATTRIBUTE(EGL_TRANSPARENT_GREEN_VALUE), + ATTRIBUTE(EGL_TRANSPARENT_RED_VALUE), + ATTRIBUTE(EGL_BIND_TO_TEXTURE_RGB), + ATTRIBUTE(EGL_BIND_TO_TEXTURE_RGBA), + ATTRIBUTE(EGL_MIN_SWAP_INTERVAL), + ATTRIBUTE(EGL_MAX_SWAP_INTERVAL), + ATTRIBUTE(EGL_LUMINANCE_SIZE), + ATTRIBUTE(EGL_ALPHA_MASK_SIZE), + ATTRIBUTE(EGL_COLOR_BUFFER_TYPE), + ATTRIBUTE(EGL_RENDERABLE_TYPE), + ATTRIBUTE(EGL_MATCH_NATIVE_PIXMAP), + ATTRIBUTE(EGL_CONFORMANT), }; - static void dumpconfig(_THIS, EGLConfig config) { int attr; - for (attr = 0 ; attregl_data->eglGetConfigAttrib(_this->egl_data->egl_display, config, all_attributes[attr].attribute, &value); SDL_Log("\t%-32s: %10d (0x%08x)\n", all_attributes[attr].name, value, value); @@ -714,8 +712,7 @@ static void dumpconfig(_THIS, EGLConfig config) #endif /* DUMP_EGL_CONFIG */ -static int -SDL_EGL_PrivateChooseConfig(_THIS, SDL_bool set_config_caveat_none) +static int SDL_EGL_PrivateChooseConfig(_THIS, SDL_bool set_config_caveat_none) { /* 64 seems nice. */ EGLint attribs[64]; @@ -788,7 +785,7 @@ SDL_EGL_PrivateChooseConfig(_THIS, SDL_bool set_config_caveat_none) attribs[i++] = EGL_OPENGL_ES3_BIT_KHR; } else #endif - if (_this->gl_config.major_version >= 2) { + if (_this->gl_config.major_version >= 2) { attribs[i++] = EGL_OPENGL_ES2_BIT; } else { attribs[i++] = EGL_OPENGL_ES_BIT; @@ -809,20 +806,20 @@ SDL_EGL_PrivateChooseConfig(_THIS, SDL_bool set_config_caveat_none) SDL_assert(i < SDL_arraysize(attribs)); if (_this->egl_data->eglChooseConfig(_this->egl_data->egl_display, - attribs, - configs, SDL_arraysize(configs), - &found_configs) == EGL_FALSE || + attribs, + configs, SDL_arraysize(configs), + &found_configs) == EGL_FALSE || found_configs == 0) { return -1; } /* first ensure that a found config has a matching format, or the function will fall through. */ if (_this->egl_data->egl_required_visual_id) { - for (i = 0; i < found_configs; i++ ) { + for (i = 0; i < found_configs; i++) { EGLint format; _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, - configs[i], - EGL_NATIVE_VISUAL_ID, &format); + configs[i], + EGL_NATIVE_VISUAL_ID, &format); if (_this->egl_data->egl_required_visual_id == format) { has_matching_format = SDL_TRUE; break; @@ -833,15 +830,15 @@ SDL_EGL_PrivateChooseConfig(_THIS, SDL_bool set_config_caveat_none) /* eglChooseConfig returns a number of configurations that match or exceed the requested attribs. */ /* From those, we select the one that matches our requirements more closely via a makeshift algorithm */ - for (i = 0; i < found_configs; i++ ) { + for (i = 0; i < found_configs; i++) { SDL_bool is_truecolor = SDL_FALSE; int bitdiff = 0; if (has_matching_format && _this->egl_data->egl_required_visual_id) { EGLint format; _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, - configs[i], - EGL_NATIVE_VISUAL_ID, &format); + configs[i], + EGL_NATIVE_VISUAL_ID, &format); if (_this->egl_data->egl_required_visual_id != format) { continue; } @@ -860,16 +857,15 @@ SDL_EGL_PrivateChooseConfig(_THIS, SDL_bool set_config_caveat_none) for (j = 0; j < SDL_arraysize(attribs) - 1; j += 2) { if (attribs[j] == EGL_NONE) { - break; + break; } - if ( attribs[j+1] != EGL_DONT_CARE && ( - attribs[j] == EGL_RED_SIZE || - attribs[j] == EGL_GREEN_SIZE || - attribs[j] == EGL_BLUE_SIZE || - attribs[j] == EGL_ALPHA_SIZE || - attribs[j] == EGL_DEPTH_SIZE || - attribs[j] == EGL_STENCIL_SIZE)) { + if (attribs[j + 1] != EGL_DONT_CARE && (attribs[j] == EGL_RED_SIZE || + attribs[j] == EGL_GREEN_SIZE || + attribs[j] == EGL_BLUE_SIZE || + attribs[j] == EGL_ALPHA_SIZE || + attribs[j] == EGL_DEPTH_SIZE || + attribs[j] == EGL_STENCIL_SIZE)) { _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, configs[i], attribs[j], &value); bitdiff += value - attribs[j + 1]; /* value is always >= attrib */ } @@ -886,8 +882,8 @@ SDL_EGL_PrivateChooseConfig(_THIS, SDL_bool set_config_caveat_none) } } - #define FAVOR_TRUECOLOR 1 - #if FAVOR_TRUECOLOR +#define FAVOR_TRUECOLOR 1 +#if FAVOR_TRUECOLOR /* Some apps request a low color depth, either because they _assume_ they'll get a larger one but don't want to fail if only smaller ones are available, or they just never called SDL_GL_SetAttribute at all and @@ -900,12 +896,12 @@ SDL_EGL_PrivateChooseConfig(_THIS, SDL_bool set_config_caveat_none) on small hardware that all expected to actually get 16-bit color. In this case, turn off FAVOR_TRUECOLOR (and maybe send a patch to make this more flexible). */ - if ( ((_this->gl_config.red_size + _this->gl_config.blue_size + _this->gl_config.green_size) <= 16) ) { + if (((_this->gl_config.red_size + _this->gl_config.blue_size + _this->gl_config.green_size) <= 16)) { if (truecolor_config_idx != -1) { _this->egl_data->egl_config = configs[truecolor_config_idx]; } } - #endif +#endif #ifdef DUMP_EGL_CONFIG dumpconfig(_this, _this->egl_data->egl_config); @@ -914,8 +910,7 @@ SDL_EGL_PrivateChooseConfig(_THIS, SDL_bool set_config_caveat_none) return 0; } -int -SDL_EGL_ChooseConfig(_THIS) +int SDL_EGL_ChooseConfig(_THIS) { int ret; @@ -1043,8 +1038,8 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface) _this->egl_data->eglBindAPI(_this->egl_data->apitype); egl_context = _this->egl_data->eglCreateContext(_this->egl_data->egl_display, - _this->egl_data->egl_config, - share_context, attribs); + _this->egl_data->egl_config, + share_context, attribs); if (egl_context == EGL_NO_CONTEXT) { SDL_EGL_SetError("Could not create EGL context", "eglCreateContext"); @@ -1064,8 +1059,7 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface) * or later, or if the EGL_KHR_surfaceless_context extension is present. */ if ((_this->egl_data->egl_version_major > 1) || ((_this->egl_data->egl_version_major == 1) && (_this->egl_data->egl_version_minor >= 5)) || - SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_surfaceless_context")) - { + SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_surfaceless_context")) { /* Secondary condition: The client API must support it. */ if (profile_es) { /* On OpenGL ES, the GL_OES_surfaceless_context extension must be @@ -1076,7 +1070,7 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface) #if SDL_VIDEO_OPENGL && !defined(SDL_VIDEO_DRIVER_VITA) } else { /* Desktop OpenGL supports it by default from version 3.0 on. */ - void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params); + void(APIENTRY * glGetIntegervFunc)(GLenum pname, GLint * params); glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv"); if (glGetIntegervFunc) { GLint v = 0; @@ -1089,13 +1083,12 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface) } } - return (SDL_GLContext) egl_context; + return (SDL_GLContext)egl_context; } -int -SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context) +int SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context) { - EGLContext egl_context = (EGLContext) context; + EGLContext egl_context = (EGLContext)context; if (!_this->egl_data) { return SDL_SetError("EGL not initialized"); @@ -1106,7 +1099,7 @@ SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context) /* Can't do the nothing there is to do? Probably trying to cleanup a failed startup, just return. */ return 0; } else { - return SDL_SetError("EGL not initialized"); /* something clearly went wrong somewhere. */ + return SDL_SetError("EGL not initialized"); /* something clearly went wrong somewhere. */ } } @@ -1115,14 +1108,14 @@ SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context) _this->egl_data->eglBindAPI(_this->egl_data->apitype); } - /* The android emulator crashes badly if you try to eglMakeCurrent + /* The android emulator crashes badly if you try to eglMakeCurrent * with a valid context and invalid surface, so we have to check for both here. */ if (!egl_context || (!egl_surface && !_this->gl_allow_no_surface)) { - _this->egl_data->eglMakeCurrent(_this->egl_data->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + _this->egl_data->eglMakeCurrent(_this->egl_data->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); } else { if (!_this->egl_data->eglMakeCurrent(_this->egl_data->egl_display, - egl_surface, egl_surface, egl_context)) { + egl_surface, egl_surface, egl_context)) { return SDL_EGL_SetError("Unable to make EGL context current", "eglMakeCurrent"); } } @@ -1130,11 +1123,10 @@ SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context) return 0; } -int -SDL_EGL_SetSwapInterval(_THIS, int interval) +int SDL_EGL_SetSwapInterval(_THIS, int interval) { EGLBoolean status; - + if (!_this->egl_data) { return SDL_SetError("EGL not initialized"); } @@ -1145,29 +1137,27 @@ SDL_EGL_SetSwapInterval(_THIS, int interval) if (interval < 0) { return SDL_SetError("Late swap tearing currently unsupported"); } - + status = _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, interval); if (status == EGL_TRUE) { _this->egl_data->egl_swapinterval = interval; return 0; } - + return SDL_EGL_SetError("Unable to set the EGL swap interval", "eglSwapInterval"); } -int -SDL_EGL_GetSwapInterval(_THIS) +int SDL_EGL_GetSwapInterval(_THIS) { if (!_this->egl_data) { SDL_SetError("EGL not initialized"); return 0; } - + return _this->egl_data->egl_swapinterval; } -int -SDL_EGL_SwapBuffers(_THIS, EGLSurface egl_surface) +int SDL_EGL_SwapBuffers(_THIS, EGLSurface egl_surface) { if (!_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, egl_surface)) { return SDL_EGL_SetError("unable to show color buffer in an OS-native window", "eglSwapBuffers"); @@ -1175,24 +1165,22 @@ SDL_EGL_SwapBuffers(_THIS, EGLSurface egl_surface) return 0; } -void -SDL_EGL_DeleteContext(_THIS, SDL_GLContext context) +void SDL_EGL_DeleteContext(_THIS, SDL_GLContext context) { - EGLContext egl_context = (EGLContext) context; + EGLContext egl_context = (EGLContext)context; /* Clean up GLES and EGL */ if (!_this->egl_data) { return; } - + if (egl_context != NULL && egl_context != EGL_NO_CONTEXT) { _this->egl_data->eglDestroyContext(_this->egl_data->egl_display, egl_context); } - } EGLSurface * -SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) +SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) { #if SDL_VIDEO_DRIVER_ANDROID EGLint format_wanted; @@ -1202,7 +1190,7 @@ SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) EGLint attribs[5]; int attr = 0; - EGLSurface * surface; + EGLSurface *surface; if (SDL_EGL_ChooseConfig(_this) != 0) { return EGL_NO_SURFACE; @@ -1212,8 +1200,8 @@ SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) /* On Android, EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is * guaranteed to be accepted by ANativeWindow_setBuffersGeometry(). */ _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, - _this->egl_data->egl_config, - EGL_NATIVE_VISUAL_ID, &format_wanted); + _this->egl_data->egl_config, + EGL_NATIVE_VISUAL_ID, &format_wanted); /* Format based on selected egl config. */ ANativeWindow_setBuffersGeometry(nw, 0, 0, format_wanted); @@ -1241,11 +1229,11 @@ SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) #endif attribs[attr++] = EGL_NONE; - + surface = _this->egl_data->eglCreateWindowSurface( - _this->egl_data->egl_display, - _this->egl_data->egl_config, - nw, &attribs[0]); + _this->egl_data->egl_display, + _this->egl_data->egl_config, + nw, &attribs[0]); if (surface == EGL_NO_SURFACE) { SDL_EGL_SetError("unable to create an EGL window surface", "eglCreateWindowSurface"); } @@ -1279,13 +1267,12 @@ SDL_EGL_CreateOffscreenSurface(_THIS, int width, int height) attributes); } -void -SDL_EGL_DestroySurface(_THIS, EGLSurface egl_surface) +void SDL_EGL_DestroySurface(_THIS, EGLSurface egl_surface) { if (!_this->egl_data) { return; } - + if (egl_surface != EGL_NO_SURFACE) { _this->egl_data->eglDestroySurface(_this->egl_data->egl_display, egl_surface); } @@ -1294,4 +1281,3 @@ SDL_EGL_DestroySurface(_THIS, EGLSurface egl_surface) #endif /* SDL_VIDEO_OPENGL_EGL */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/video/SDL_egl_c.h b/src/video/SDL_egl_c.h index 76d26f93b..c8765ede3 100644 --- a/src/video/SDL_egl_c.h +++ b/src/video/SDL_egl_c.h @@ -29,7 +29,7 @@ #include "SDL_sysvideo.h" -#define SDL_EGL_MAX_DEVICES 8 +#define SDL_EGL_MAX_DEVICES 8 typedef struct SDL_EGL_VideoData { @@ -71,45 +71,73 @@ typedef struct SDL_EGL_VideoData EGLSurface(EGLAPIENTRY *eglCreatePbufferSurface)(EGLDisplay dpy, EGLConfig config, EGLint const* attrib_list); - EGLSurface(EGLAPIENTRY *eglCreateWindowSurface) (EGLDisplay dpy, - EGLConfig config, - NativeWindowType window, - const EGLint * attrib_list); - EGLBoolean(EGLAPIENTRY *eglDestroySurface) (EGLDisplay dpy, EGLSurface surface); - - EGLBoolean(EGLAPIENTRY *eglMakeCurrent) (EGLDisplay dpy, EGLSurface draw, - EGLSurface read, EGLContext ctx); - - EGLBoolean(EGLAPIENTRY *eglSwapBuffers) (EGLDisplay dpy, EGLSurface draw); - - EGLBoolean(EGLAPIENTRY *eglSwapInterval) (EGLDisplay dpy, EGLint interval); - - const char *(EGLAPIENTRY *eglQueryString) (EGLDisplay dpy, EGLint name); + EGLDisplay(EGLAPIENTRY *eglGetDisplay)(NativeDisplayType display); + EGLDisplay(EGLAPIENTRY *eglGetPlatformDisplay)(EGLenum platform, + void *native_display, + const EGLAttrib *attrib_list); + EGLDisplay(EGLAPIENTRY *eglGetPlatformDisplayEXT)(EGLenum platform, + void *native_display, + const EGLint *attrib_list); + EGLBoolean(EGLAPIENTRY *eglInitialize)(EGLDisplay dpy, EGLint *major, + EGLint *minor); + EGLBoolean(EGLAPIENTRY *eglTerminate)(EGLDisplay dpy); + + void *(EGLAPIENTRY *eglGetProcAddress)(const char *procName); + + EGLBoolean(EGLAPIENTRY *eglChooseConfig)(EGLDisplay dpy, + const EGLint *attrib_list, + EGLConfig *configs, + EGLint config_size, EGLint *num_config); + + EGLContext(EGLAPIENTRY *eglCreateContext)(EGLDisplay dpy, + EGLConfig config, + EGLContext share_list, + const EGLint *attrib_list); + + EGLBoolean(EGLAPIENTRY *eglDestroyContext)(EGLDisplay dpy, EGLContext ctx); + + EGLSurface(EGLAPIENTRY *eglCreatePbufferSurface)(EGLDisplay dpy, EGLConfig config, + EGLint const *attrib_list); + + EGLSurface(EGLAPIENTRY *eglCreateWindowSurface)(EGLDisplay dpy, + EGLConfig config, + NativeWindowType window, + const EGLint *attrib_list); + EGLBoolean(EGLAPIENTRY *eglDestroySurface)(EGLDisplay dpy, EGLSurface surface); + + EGLBoolean(EGLAPIENTRY *eglMakeCurrent)(EGLDisplay dpy, EGLSurface draw, + EGLSurface read, EGLContext ctx); + + EGLBoolean(EGLAPIENTRY *eglSwapBuffers)(EGLDisplay dpy, EGLSurface draw); + + EGLBoolean(EGLAPIENTRY *eglSwapInterval)(EGLDisplay dpy, EGLint interval); + + const char *(EGLAPIENTRY *eglQueryString)(EGLDisplay dpy, EGLint name); EGLenum(EGLAPIENTRY *eglQueryAPI)(void); - - EGLBoolean(EGLAPIENTRY *eglGetConfigAttrib) (EGLDisplay dpy, EGLConfig config, - EGLint attribute, EGLint * value); - - EGLBoolean(EGLAPIENTRY *eglWaitNative) (EGLint engine); + + EGLBoolean(EGLAPIENTRY *eglGetConfigAttrib)(EGLDisplay dpy, EGLConfig config, + EGLint attribute, EGLint *value); + + EGLBoolean(EGLAPIENTRY *eglWaitNative)(EGLint engine); EGLBoolean(EGLAPIENTRY *eglWaitGL)(void); - + EGLBoolean(EGLAPIENTRY *eglBindAPI)(EGLenum); EGLint(EGLAPIENTRY *eglGetError)(void); EGLBoolean(EGLAPIENTRY *eglQueryDevicesEXT)(EGLint max_devices, - void **devices, - EGLint *num_devices); + void **devices, + EGLint *num_devices); - /* Atomic functions */ + /* Atomic functions */ EGLSyncKHR(EGLAPIENTRY *eglCreateSyncKHR)(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); EGLBoolean(EGLAPIENTRY *eglDestroySyncKHR)(EGLDisplay dpy, EGLSyncKHR sync); - EGLint(EGLAPIENTRY *eglDupNativeFenceFDANDROID)(EGLDisplay dpy, EGLSyncKHR sync); + EGLint(EGLAPIENTRY *eglDupNativeFenceFDANDROID)(EGLDisplay dpy, EGLSyncKHR sync); EGLint(EGLAPIENTRY *eglWaitSyncKHR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); @@ -119,7 +147,8 @@ typedef struct SDL_EGL_VideoData } SDL_EGL_VideoData; /* OpenGLES functions */ -typedef enum SDL_EGL_ExtensionType { +typedef enum SDL_EGL_ExtensionType +{ SDL_EGL_DISPLAY_EXTENSION, SDL_EGL_CLIENT_EXTENSION } SDL_EGL_ExtensionType; @@ -152,28 +181,31 @@ extern int SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext cont extern int SDL_EGL_SwapBuffers(_THIS, EGLSurface egl_surface); /* SDL Error-reporting */ -extern int SDL_EGL_SetErrorEx(const char * message, const char * eglFunctionName, EGLint eglErrorCode); +extern int SDL_EGL_SetErrorEx(const char *message, const char *eglFunctionName, EGLint eglErrorCode); #define SDL_EGL_SetError(message, eglFunctionName) SDL_EGL_SetErrorEx(message, eglFunctionName, _this->egl_data->eglGetError()) /* A few of useful macros */ -#define SDL_EGL_SwapWindow_impl(BACKEND) int \ -BACKEND ## _GLES_SwapWindow(_THIS, SDL_Window * window) \ -{\ - return SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);\ -} +#define SDL_EGL_SwapWindow_impl(BACKEND) \ + int \ + BACKEND##_GLES_SwapWindow(_THIS, SDL_Window *window) \ + { \ + return SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *)window->driverdata)->egl_surface); \ + } -#define SDL_EGL_MakeCurrent_impl(BACKEND) int \ -BACKEND ## _GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) \ -{\ - return SDL_EGL_MakeCurrent(_this, window ? ((SDL_WindowData *) window->driverdata)->egl_surface : EGL_NO_SURFACE, context);\ -} +#define SDL_EGL_MakeCurrent_impl(BACKEND) \ + int \ + BACKEND##_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context) \ + { \ + return SDL_EGL_MakeCurrent(_this, window ? ((SDL_WindowData *)window->driverdata)->egl_surface : EGL_NO_SURFACE, context); \ + } -#define SDL_EGL_CreateContext_impl(BACKEND) SDL_GLContext \ -BACKEND ## _GLES_CreateContext(_THIS, SDL_Window * window) \ -{\ - return SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);\ -} +#define SDL_EGL_CreateContext_impl(BACKEND) \ + SDL_GLContext \ + BACKEND##_GLES_CreateContext(_THIS, SDL_Window *window) \ + { \ + return SDL_EGL_CreateContext(_this, ((SDL_WindowData *)window->driverdata)->egl_surface); \ + } #endif /* SDL_VIDEO_OPENGL_EGL */ diff --git a/src/video/SDL_fillrect.c b/src/video/SDL_fillrect.c index 748b61a19..9a6620192 100644 --- a/src/video/SDL_fillrect.c +++ b/src/video/SDL_fillrect.c @@ -24,7 +24,6 @@ #include "SDL_blit.h" #include "SDL_cpuinfo.h" - #ifdef __SSE__ /* *INDENT-OFF* */ /* clang-format off */ @@ -58,8 +57,7 @@ #define SSE_END #define DEFINE_SSE_FILLRECT(bpp, type) \ -static void \ -SDL_FillRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \ +static void SDL_FillRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \ { \ int i, n; \ Uint8 *p = NULL; \ @@ -96,8 +94,7 @@ SDL_FillRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \ SSE_END; \ } -static void -SDL_FillRect1SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) +static void SDL_FillRect1SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) { int i, n; @@ -129,28 +126,29 @@ DEFINE_SSE_FILLRECT(2, Uint16) DEFINE_SSE_FILLRECT(4, Uint32) /* *INDENT-ON* */ /* clang-format on */ -#endif /* __SSE__ */ +#endif /* __SSE__ */ -static void -SDL_FillRect1(Uint8 * pixels, int pitch, Uint32 color, int w, int h) +static void SDL_FillRect1(Uint8 *pixels, int pitch, Uint32 color, int w, int h) { int n; Uint8 *p = NULL; - + while (h--) { n = w; p = pixels; if (n > 3) { - switch ((uintptr_t) p & 3) { + switch ((uintptr_t)p & 3) { case 1: - *p++ = (Uint8) color; - --n; SDL_FALLTHROUGH; + *p++ = (Uint8)color; + --n; + SDL_FALLTHROUGH; case 2: - *p++ = (Uint8) color; - --n; SDL_FALLTHROUGH; + *p++ = (Uint8)color; + --n; + SDL_FALLTHROUGH; case 3: - *p++ = (Uint8) color; + *p++ = (Uint8)color; --n; } SDL_memset4(p, color, (n >> 2)); @@ -159,52 +157,52 @@ SDL_FillRect1(Uint8 * pixels, int pitch, Uint32 color, int w, int h) p += (n & ~3); switch (n & 3) { case 3: - *p++ = (Uint8) color; SDL_FALLTHROUGH; + *p++ = (Uint8)color; + SDL_FALLTHROUGH; case 2: - *p++ = (Uint8) color; SDL_FALLTHROUGH; + *p++ = (Uint8)color; + SDL_FALLTHROUGH; case 1: - *p++ = (Uint8) color; + *p++ = (Uint8)color; } } pixels += pitch; } } -static void -SDL_FillRect2(Uint8 * pixels, int pitch, Uint32 color, int w, int h) +static void SDL_FillRect2(Uint8 *pixels, int pitch, Uint32 color, int w, int h) { int n; Uint16 *p = NULL; - + while (h--) { n = w; - p = (Uint16 *) pixels; + p = (Uint16 *)pixels; if (n > 1) { - if ((uintptr_t) p & 2) { - *p++ = (Uint16) color; + if ((uintptr_t)p & 2) { + *p++ = (Uint16)color; --n; } SDL_memset4(p, color, (n >> 1)); } if (n & 1) { - p[n - 1] = (Uint16) color; + p[n - 1] = (Uint16)color; } pixels += pitch; } } -static void -SDL_FillRect3(Uint8 * pixels, int pitch, Uint32 color, int w, int h) +static void SDL_FillRect3(Uint8 *pixels, int pitch, Uint32 color, int w, int h) { #if SDL_BYTEORDER == SDL_LIL_ENDIAN - Uint8 b1 = (Uint8) (color & 0xFF); - Uint8 b2 = (Uint8) ((color >> 8) & 0xFF); - Uint8 b3 = (Uint8) ((color >> 16) & 0xFF); + Uint8 b1 = (Uint8)(color & 0xFF); + Uint8 b2 = (Uint8)((color >> 8) & 0xFF); + Uint8 b3 = (Uint8)((color >> 16) & 0xFF); #elif SDL_BYTEORDER == SDL_BIG_ENDIAN - Uint8 b1 = (Uint8) ((color >> 16) & 0xFF); - Uint8 b2 = (Uint8) ((color >> 8) & 0xFF); - Uint8 b3 = (Uint8) (color & 0xFF); + Uint8 b1 = (Uint8)((color >> 16) & 0xFF); + Uint8 b2 = (Uint8)((color >> 8) & 0xFF); + Uint8 b3 = (Uint8)(color & 0xFF); #endif int n; Uint8 *p = NULL; @@ -222,8 +220,7 @@ SDL_FillRect3(Uint8 * pixels, int pitch, Uint32 color, int w, int h) } } -static void -SDL_FillRect4(Uint8 * pixels, int pitch, Uint32 color, int w, int h) +static void SDL_FillRect4(Uint8 *pixels, int pitch, Uint32 color, int w, int h) { while (h--) { SDL_memset4(pixels, color, w); @@ -231,11 +228,10 @@ SDL_FillRect4(Uint8 * pixels, int pitch, Uint32 color, int w, int h) } } -/* +/* * This function performs a fast fill of the given rectangle with 'color' */ -int -SDL_FillRect(SDL_Surface * dst, const SDL_Rect * rect, Uint32 color) +int SDL_FillRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color) { if (dst == NULL) { return SDL_InvalidParamError("SDL_FillRect(): dst"); @@ -258,18 +254,21 @@ void FillRect8ARMNEONAsm(int32_t w, int32_t h, uint8_t *dst, int32_t dst_stride, void FillRect16ARMNEONAsm(int32_t w, int32_t h, uint16_t *dst, int32_t dst_stride, uint16_t src); void FillRect32ARMNEONAsm(int32_t w, int32_t h, uint32_t *dst, int32_t dst_stride, uint32_t src); -static void fill_8_neon(Uint8 * pixels, int pitch, Uint32 color, int w, int h) { - FillRect8ARMNEONAsm(w, h, (uint8_t *) pixels, pitch >> 0, color); +static void fill_8_neon(Uint8 *pixels, int pitch, Uint32 color, int w, int h) +{ + FillRect8ARMNEONAsm(w, h, (uint8_t *)pixels, pitch >> 0, color); return; } -static void fill_16_neon(Uint8 * pixels, int pitch, Uint32 color, int w, int h) { - FillRect16ARMNEONAsm(w, h, (uint16_t *) pixels, pitch >> 1, color); +static void fill_16_neon(Uint8 *pixels, int pitch, Uint32 color, int w, int h) +{ + FillRect16ARMNEONAsm(w, h, (uint16_t *)pixels, pitch >> 1, color); return; } -static void fill_32_neon(Uint8 * pixels, int pitch, Uint32 color, int w, int h) { - FillRect32ARMNEONAsm(w, h, (uint32_t *) pixels, pitch >> 2, color); +static void fill_32_neon(Uint8 *pixels, int pitch, Uint32 color, int w, int h) +{ + FillRect32ARMNEONAsm(w, h, (uint32_t *)pixels, pitch >> 2, color); return; } #endif @@ -279,29 +278,31 @@ void FillRect8ARMSIMDAsm(int32_t w, int32_t h, uint8_t *dst, int32_t dst_stride, void FillRect16ARMSIMDAsm(int32_t w, int32_t h, uint16_t *dst, int32_t dst_stride, uint16_t src); void FillRect32ARMSIMDAsm(int32_t w, int32_t h, uint32_t *dst, int32_t dst_stride, uint32_t src); -static void fill_8_simd(Uint8 * pixels, int pitch, Uint32 color, int w, int h) { - FillRect8ARMSIMDAsm(w, h, (uint8_t *) pixels, pitch >> 0, color); +static void fill_8_simd(Uint8 *pixels, int pitch, Uint32 color, int w, int h) +{ + FillRect8ARMSIMDAsm(w, h, (uint8_t *)pixels, pitch >> 0, color); return; } -static void fill_16_simd(Uint8 * pixels, int pitch, Uint32 color, int w, int h) { - FillRect16ARMSIMDAsm(w, h, (uint16_t *) pixels, pitch >> 1, color); +static void fill_16_simd(Uint8 *pixels, int pitch, Uint32 color, int w, int h) +{ + FillRect16ARMSIMDAsm(w, h, (uint16_t *)pixels, pitch >> 1, color); return; } -static void fill_32_simd(Uint8 * pixels, int pitch, Uint32 color, int w, int h) { - FillRect32ARMSIMDAsm(w, h, (uint32_t *) pixels, pitch >> 2, color); +static void fill_32_simd(Uint8 *pixels, int pitch, Uint32 color, int w, int h) +{ + FillRect32ARMSIMDAsm(w, h, (uint32_t *)pixels, pitch >> 2, color); return; } #endif -int -SDL_FillRects(SDL_Surface * dst, const SDL_Rect * rects, int count, - Uint32 color) +int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, + Uint32 color) { SDL_Rect clipped; Uint8 *pixels; - const SDL_Rect* rect; + const SDL_Rect *rect; void (*fill_function)(Uint8 * pixels, int pitch, Uint32 color, int w, int h) = NULL; int i; @@ -331,7 +332,7 @@ SDL_FillRects(SDL_Surface * dst, const SDL_Rect * rects, int count, const SDL_Rect *r = &rects[0]; if (r->x == 0 && r->y == 0 && r->w == dst->w && r->h == dst->h) { if (dst->format->BitsPerPixel == 4) { - Uint8 b = (((Uint8) color << 4) | (Uint8) color); + Uint8 b = (((Uint8)color << 4) | (Uint8)color); SDL_memset(dst->pixels, b, dst->h * dst->pitch); return 1; } @@ -374,31 +375,31 @@ SDL_FillRects(SDL_Surface * dst, const SDL_Rect * rects, int count, if (fill_function == NULL) { switch (dst->format->BytesPerPixel) { case 1: - { - color |= (color << 8); - color |= (color << 16); + { + color |= (color << 8); + color |= (color << 16); #ifdef __SSE__ - if (SDL_HasSSE()) { - fill_function = SDL_FillRect1SSE; - break; - } -#endif - fill_function = SDL_FillRect1; + if (SDL_HasSSE()) { + fill_function = SDL_FillRect1SSE; break; } +#endif + fill_function = SDL_FillRect1; + break; + } case 2: - { - color |= (color << 16); + { + color |= (color << 16); #ifdef __SSE__ - if (SDL_HasSSE()) { - fill_function = SDL_FillRect2SSE; - break; - } -#endif - fill_function = SDL_FillRect2; + if (SDL_HasSSE()) { + fill_function = SDL_FillRect2SSE; break; } +#endif + fill_function = SDL_FillRect2; + break; + } case 3: /* 24-bit RGB is a slow path, at least for now. */ @@ -408,16 +409,16 @@ SDL_FillRects(SDL_Surface * dst, const SDL_Rect * rects, int count, } case 4: - { + { #ifdef __SSE__ - if (SDL_HasSSE()) { - fill_function = SDL_FillRect4SSE; - break; - } -#endif - fill_function = SDL_FillRect4; + if (SDL_HasSSE()) { + fill_function = SDL_FillRect4SSE; break; } +#endif + fill_function = SDL_FillRect4; + break; + } default: return SDL_SetError("Unsupported pixel format"); @@ -432,8 +433,8 @@ SDL_FillRects(SDL_Surface * dst, const SDL_Rect * rects, int count, } rect = &clipped; - pixels = (Uint8 *) dst->pixels + rect->y * dst->pitch + - rect->x * dst->format->BytesPerPixel; + pixels = (Uint8 *)dst->pixels + rect->y * dst->pitch + + rect->x * dst->format->BytesPerPixel; fill_function(pixels, dst->pitch, color, rect->w, rect->h); } diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c index 561512b92..7cffbc140 100644 --- a/src/video/SDL_pixels.c +++ b/src/video/SDL_pixels.c @@ -30,46 +30,45 @@ #include "SDL_RLEaccel_c.h" #include "../SDL_list.h" - /* Lookup tables to expand partial bytes to the full 0..255 range */ static Uint8 lookup_0[] = { -0, 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 + 0, 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 }; static Uint8 lookup_1[] = { -0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 255 + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 255 }; static Uint8 lookup_2[] = { -0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 85, 89, 93, 97, 101, 105, 109, 113, 117, 121, 125, 129, 133, 137, 141, 145, 149, 153, 157, 161, 165, 170, 174, 178, 182, 186, 190, 194, 198, 202, 206, 210, 214, 218, 222, 226, 230, 234, 238, 242, 246, 250, 255 + 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 85, 89, 93, 97, 101, 105, 109, 113, 117, 121, 125, 129, 133, 137, 141, 145, 149, 153, 157, 161, 165, 170, 174, 178, 182, 186, 190, 194, 198, 202, 206, 210, 214, 218, 222, 226, 230, 234, 238, 242, 246, 250, 255 }; static Uint8 lookup_3[] = { -0, 8, 16, 24, 32, 41, 49, 57, 65, 74, 82, 90, 98, 106, 115, 123, 131, 139, 148, 156, 164, 172, 180, 189, 197, 205, 213, 222, 230, 238, 246, 255 + 0, 8, 16, 24, 32, 41, 49, 57, 65, 74, 82, 90, 98, 106, 115, 123, 131, 139, 148, 156, 164, 172, 180, 189, 197, 205, 213, 222, 230, 238, 246, 255 }; static Uint8 lookup_4[] = { -0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255 + 0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255 }; static Uint8 lookup_5[] = { -0, 36, 72, 109, 145, 182, 218, 255 + 0, 36, 72, 109, 145, 182, 218, 255 }; static Uint8 lookup_6[] = { -0, 85, 170, 255 + 0, 85, 170, 255 }; static Uint8 lookup_7[] = { -0, 255 + 0, 255 }; static Uint8 lookup_8[] = { -255 + 255 }; -Uint8* SDL_expand_byte[9] = { +Uint8 *SDL_expand_byte[9] = { lookup_0, lookup_1, lookup_2, @@ -83,51 +82,53 @@ Uint8* SDL_expand_byte[9] = { /* Helper functions */ -#define CASE(X) case X: return #X; -const char* +#define CASE(X) \ + case X: \ + return #X; +const char * SDL_GetPixelFormatName(Uint32 format) { switch (format) { - CASE(SDL_PIXELFORMAT_INDEX1LSB) - CASE(SDL_PIXELFORMAT_INDEX1MSB) - CASE(SDL_PIXELFORMAT_INDEX4LSB) - CASE(SDL_PIXELFORMAT_INDEX4MSB) - CASE(SDL_PIXELFORMAT_INDEX8) - CASE(SDL_PIXELFORMAT_RGB332) - CASE(SDL_PIXELFORMAT_RGB444) - CASE(SDL_PIXELFORMAT_BGR444) - CASE(SDL_PIXELFORMAT_RGB555) - CASE(SDL_PIXELFORMAT_BGR555) - CASE(SDL_PIXELFORMAT_ARGB4444) - CASE(SDL_PIXELFORMAT_RGBA4444) - CASE(SDL_PIXELFORMAT_ABGR4444) - CASE(SDL_PIXELFORMAT_BGRA4444) - CASE(SDL_PIXELFORMAT_ARGB1555) - CASE(SDL_PIXELFORMAT_RGBA5551) - CASE(SDL_PIXELFORMAT_ABGR1555) - CASE(SDL_PIXELFORMAT_BGRA5551) - CASE(SDL_PIXELFORMAT_RGB565) - CASE(SDL_PIXELFORMAT_BGR565) - CASE(SDL_PIXELFORMAT_RGB24) - CASE(SDL_PIXELFORMAT_BGR24) - CASE(SDL_PIXELFORMAT_RGB888) - CASE(SDL_PIXELFORMAT_RGBX8888) - CASE(SDL_PIXELFORMAT_BGR888) - CASE(SDL_PIXELFORMAT_BGRX8888) - CASE(SDL_PIXELFORMAT_ARGB8888) - CASE(SDL_PIXELFORMAT_RGBA8888) - CASE(SDL_PIXELFORMAT_ABGR8888) - CASE(SDL_PIXELFORMAT_BGRA8888) - CASE(SDL_PIXELFORMAT_ARGB2101010) - CASE(SDL_PIXELFORMAT_YV12) - CASE(SDL_PIXELFORMAT_IYUV) - CASE(SDL_PIXELFORMAT_YUY2) - CASE(SDL_PIXELFORMAT_UYVY) - CASE(SDL_PIXELFORMAT_YVYU) - CASE(SDL_PIXELFORMAT_NV12) - CASE(SDL_PIXELFORMAT_NV21) - CASE(SDL_PIXELFORMAT_EXTERNAL_OES) + CASE(SDL_PIXELFORMAT_INDEX1LSB) + CASE(SDL_PIXELFORMAT_INDEX1MSB) + CASE(SDL_PIXELFORMAT_INDEX4LSB) + CASE(SDL_PIXELFORMAT_INDEX4MSB) + CASE(SDL_PIXELFORMAT_INDEX8) + CASE(SDL_PIXELFORMAT_RGB332) + CASE(SDL_PIXELFORMAT_RGB444) + CASE(SDL_PIXELFORMAT_BGR444) + CASE(SDL_PIXELFORMAT_RGB555) + CASE(SDL_PIXELFORMAT_BGR555) + CASE(SDL_PIXELFORMAT_ARGB4444) + CASE(SDL_PIXELFORMAT_RGBA4444) + CASE(SDL_PIXELFORMAT_ABGR4444) + CASE(SDL_PIXELFORMAT_BGRA4444) + CASE(SDL_PIXELFORMAT_ARGB1555) + CASE(SDL_PIXELFORMAT_RGBA5551) + CASE(SDL_PIXELFORMAT_ABGR1555) + CASE(SDL_PIXELFORMAT_BGRA5551) + CASE(SDL_PIXELFORMAT_RGB565) + CASE(SDL_PIXELFORMAT_BGR565) + CASE(SDL_PIXELFORMAT_RGB24) + CASE(SDL_PIXELFORMAT_BGR24) + CASE(SDL_PIXELFORMAT_RGB888) + CASE(SDL_PIXELFORMAT_RGBX8888) + CASE(SDL_PIXELFORMAT_BGR888) + CASE(SDL_PIXELFORMAT_BGRX8888) + CASE(SDL_PIXELFORMAT_ARGB8888) + CASE(SDL_PIXELFORMAT_RGBA8888) + CASE(SDL_PIXELFORMAT_ABGR8888) + CASE(SDL_PIXELFORMAT_BGRA8888) + CASE(SDL_PIXELFORMAT_ARGB2101010) + CASE(SDL_PIXELFORMAT_YV12) + CASE(SDL_PIXELFORMAT_IYUV) + CASE(SDL_PIXELFORMAT_YUY2) + CASE(SDL_PIXELFORMAT_UYVY) + CASE(SDL_PIXELFORMAT_YVYU) + CASE(SDL_PIXELFORMAT_NV12) + CASE(SDL_PIXELFORMAT_NV21) + CASE(SDL_PIXELFORMAT_EXTERNAL_OES) default: return "SDL_PIXELFORMAT_UNKNOWN"; @@ -136,8 +137,8 @@ SDL_GetPixelFormatName(Uint32 format) #undef CASE SDL_bool -SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp, Uint32 * Rmask, - Uint32 * Gmask, Uint32 * Bmask, Uint32 * Amask) +SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp, Uint32 *Rmask, + Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask) { Uint32 masks[4]; @@ -544,8 +545,7 @@ SDL_AllocFormat(Uint32 pixel_format) return format; } -int -SDL_InitFormat(SDL_PixelFormat * format, Uint32 pixel_format) +int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format) { int bpp; Uint32 Rmask, Gmask, Bmask, Amask; @@ -613,8 +613,7 @@ SDL_InitFormat(SDL_PixelFormat * format, Uint32 pixel_format) return 0; } -void -SDL_FreeFormat(SDL_PixelFormat *format) +void SDL_FreeFormat(SDL_PixelFormat *format) { SDL_PixelFormat *prev; @@ -657,17 +656,17 @@ SDL_AllocPalette(int ncolors) /* Input validation */ if (ncolors < 1) { - SDL_InvalidParamError("ncolors"); - return NULL; + SDL_InvalidParamError("ncolors"); + return NULL; } - palette = (SDL_Palette *) SDL_malloc(sizeof(*palette)); + palette = (SDL_Palette *)SDL_malloc(sizeof(*palette)); if (palette == NULL) { SDL_OutOfMemory(); return NULL; } palette->colors = - (SDL_Color *) SDL_malloc(ncolors * sizeof(*palette->colors)); + (SDL_Color *)SDL_malloc(ncolors * sizeof(*palette->colors)); if (!palette->colors) { SDL_free(palette); SDL_OutOfMemory(); @@ -682,8 +681,7 @@ SDL_AllocPalette(int ncolors) return palette; } -int -SDL_SetPixelFormatPalette(SDL_PixelFormat * format, SDL_Palette *palette) +int SDL_SetPixelFormatPalette(SDL_PixelFormat *format, SDL_Palette *palette) { if (format == NULL) { return SDL_InvalidParamError("SDL_SetPixelFormatPalette(): format"); @@ -710,9 +708,8 @@ SDL_SetPixelFormatPalette(SDL_PixelFormat * format, SDL_Palette *palette) return 0; } -int -SDL_SetPaletteColors(SDL_Palette * palette, const SDL_Color * colors, - int firstcolor, int ncolors) +int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, + int firstcolor, int ncolors) { int status = 0; @@ -737,8 +734,7 @@ SDL_SetPaletteColors(SDL_Palette * palette, const SDL_Color * colors, return status; } -void -SDL_FreePalette(SDL_Palette * palette) +void SDL_FreePalette(SDL_Palette *palette) { if (palette == NULL) { SDL_InvalidParamError("palette"); @@ -754,8 +750,7 @@ SDL_FreePalette(SDL_Palette * palette) /* * Calculate an 8-bit (3 red, 3 green, 2 blue) dithered palette of colors */ -void -SDL_DitherColors(SDL_Color * colors, int bpp) +void SDL_DitherColors(SDL_Color *colors, int bpp) { int i; if (bpp != 8) { @@ -783,8 +778,7 @@ SDL_DitherColors(SDL_Color * colors, int bpp) /* * Match an RGB value to a particular palette index */ -Uint8 -SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +Uint8 SDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { /* Do colorspace distance matching */ unsigned int smallest; @@ -802,7 +796,7 @@ SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a) distance = (rd * rd) + (gd * gd) + (bd * bd) + (ad * ad); if (distance < smallest) { pixel = i; - if (distance == 0) { /* Perfect match! */ + if (distance == 0) { /* Perfect match! */ break; } smallest = distance; @@ -812,8 +806,7 @@ SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a) } /* Tell whether palette is opaque, and if it has an alpha_channel */ -void -SDL_DetectPalette(SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alpha_channel) +void SDL_DetectPalette(SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alpha_channel) { int i; @@ -858,10 +851,9 @@ SDL_DetectPalette(SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alpha_cha *has_alpha_channel = SDL_TRUE; } - /* Find the opaque pixel value corresponding to an RGB triple */ Uint32 -SDL_MapRGB(const SDL_PixelFormat * format, Uint8 r, Uint8 g, Uint8 b) +SDL_MapRGB(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b) { if (format->palette == NULL) { return (r >> format->Rloss) << format->Rshift | (g >> format->Gloss) << format->Gshift | (b >> format->Bloss) << format->Bshift | format->Amask; @@ -872,7 +864,7 @@ SDL_MapRGB(const SDL_PixelFormat * format, Uint8 r, Uint8 g, Uint8 b) /* Find the pixel value corresponding to an RGBA quadruple */ Uint32 -SDL_MapRGBA(const SDL_PixelFormat * format, Uint8 r, Uint8 g, Uint8 b, +SDL_MapRGBA(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { if (format->palette == NULL) { @@ -882,9 +874,8 @@ SDL_MapRGBA(const SDL_PixelFormat * format, Uint8 r, Uint8 g, Uint8 b, } } -void -SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat * format, Uint8 * r, Uint8 * g, - Uint8 * b) +void SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g, + Uint8 *b) { if (format->palette == NULL) { unsigned v; @@ -905,9 +896,8 @@ SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat * format, Uint8 * r, Uint8 * g, } } -void -SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat * format, - Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a) +void SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat *format, + Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) { if (format->palette == NULL) { unsigned v; @@ -932,8 +922,7 @@ SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat * format, } /* Map from Palette to Palette */ -static Uint8 * -Map1to1(SDL_Palette * src, SDL_Palette * dst, int *identical) +static Uint8 *Map1to1(SDL_Palette *src, SDL_Palette *dst, int *identical) { Uint8 *map; int i; @@ -941,18 +930,16 @@ Map1to1(SDL_Palette * src, SDL_Palette * dst, int *identical) if (identical) { if (src->ncolors <= dst->ncolors) { /* If an identical palette, no need to map */ - if (src == dst - || - (SDL_memcmp - (src->colors, dst->colors, - src->ncolors * sizeof(SDL_Color)) == 0)) { + if (src == dst || + (SDL_memcmp(src->colors, dst->colors, + src->ncolors * sizeof(SDL_Color)) == 0)) { *identical = 1; return NULL; } } *identical = 0; } - map = (Uint8 *) SDL_calloc(256, sizeof(Uint8)); + map = (Uint8 *)SDL_calloc(256, sizeof(Uint8)); if (map == NULL) { SDL_OutOfMemory(); return NULL; @@ -966,9 +953,8 @@ Map1to1(SDL_Palette * src, SDL_Palette * dst, int *identical) } /* Map from Palette to BitField */ -static Uint8 * -Map1toN(SDL_PixelFormat * src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod, - SDL_PixelFormat * dst) +static Uint8 *Map1toN(SDL_PixelFormat *src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod, + SDL_PixelFormat *dst) { Uint8 *map; int i; @@ -976,7 +962,7 @@ Map1toN(SDL_PixelFormat * src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod, SDL_Palette *pal = src->palette; bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel); - map = (Uint8 *) SDL_calloc(256, bpp); + map = (Uint8 *)SDL_calloc(256, bpp); if (map == NULL) { SDL_OutOfMemory(); return NULL; @@ -984,18 +970,17 @@ Map1toN(SDL_PixelFormat * src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod, /* We memory copy to the pixel map so the endianness is preserved */ for (i = 0; i < pal->ncolors; ++i) { - Uint8 R = (Uint8) ((pal->colors[i].r * Rmod) / 255); - Uint8 G = (Uint8) ((pal->colors[i].g * Gmod) / 255); - Uint8 B = (Uint8) ((pal->colors[i].b * Bmod) / 255); - Uint8 A = (Uint8) ((pal->colors[i].a * Amod) / 255); + Uint8 R = (Uint8)((pal->colors[i].r * Rmod) / 255); + Uint8 G = (Uint8)((pal->colors[i].g * Gmod) / 255); + Uint8 B = (Uint8)((pal->colors[i].b * Bmod) / 255); + Uint8 A = (Uint8)((pal->colors[i].a * Amod) / 255); ASSEMBLE_RGBA(&map[i * bpp], dst->BytesPerPixel, dst, (Uint32)R, (Uint32)G, (Uint32)B, (Uint32)A); } return map; } /* Map from BitField to Dithered-Palette to Palette */ -static Uint8 * -MapNto1(SDL_PixelFormat * src, SDL_PixelFormat * dst, int *identical) +static Uint8 *MapNto1(SDL_PixelFormat *src, SDL_PixelFormat *dst, int *identical) { /* Generate a 256 color dither palette */ SDL_Palette dithered; @@ -1014,7 +999,7 @@ SDL_AllocBlitMap(void) SDL_BlitMap *map; /* Allocate the empty map */ - map = (SDL_BlitMap *) SDL_calloc(1, sizeof(*map)); + map = (SDL_BlitMap *)SDL_calloc(1, sizeof(*map)); if (map == NULL) { SDL_OutOfMemory(); return NULL; @@ -1028,9 +1013,7 @@ SDL_AllocBlitMap(void) return map; } - -void -SDL_InvalidateAllBlitMap(SDL_Surface *surface) +void SDL_InvalidateAllBlitMap(SDL_Surface *surface) { SDL_ListNode *l = surface->list_blitmap; @@ -1044,8 +1027,7 @@ SDL_InvalidateAllBlitMap(SDL_Surface *surface) } } -void -SDL_InvalidateMap(SDL_BlitMap * map) +void SDL_InvalidateMap(SDL_BlitMap *map) { if (map == NULL) { return; @@ -1061,8 +1043,7 @@ SDL_InvalidateMap(SDL_BlitMap * map) map->info.table = NULL; } -int -SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst) +int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst) { SDL_PixelFormat *srcfmt; SDL_PixelFormat *dstfmt; @@ -1112,7 +1093,7 @@ SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst) return -1; } } - map->identity = 0; /* Don't optimize to copy */ + map->identity = 0; /* Don't optimize to copy */ } else { /* BitField --> BitField */ if (srcfmt == dstfmt) { @@ -1144,8 +1125,7 @@ SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst) return SDL_CalculateBlit(src); } -void -SDL_FreeBlitMap(SDL_BlitMap * map) +void SDL_FreeBlitMap(SDL_BlitMap *map) { if (map) { SDL_InvalidateMap(map); diff --git a/src/video/SDL_pixels_c.h b/src/video/SDL_pixels_c.h index 828fe3bd8..f31c7fff4 100644 --- a/src/video/SDL_pixels_c.h +++ b/src/video/SDL_pixels_c.h @@ -29,19 +29,19 @@ #include "SDL_blit.h" /* Pixel format functions */ -extern int SDL_InitFormat(SDL_PixelFormat * format, Uint32 pixel_format); +extern int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format); /* Blit mapping functions */ extern SDL_BlitMap *SDL_AllocBlitMap(void); -extern void SDL_InvalidateMap(SDL_BlitMap * map); -extern int SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst); -extern void SDL_FreeBlitMap(SDL_BlitMap * map); +extern void SDL_InvalidateMap(SDL_BlitMap *map); +extern int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst); +extern void SDL_FreeBlitMap(SDL_BlitMap *map); extern void SDL_InvalidateAllBlitMap(SDL_Surface *surface); /* Miscellaneous functions */ -extern void SDL_DitherColors(SDL_Color * colors, int bpp); -extern Uint8 SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a); +extern void SDL_DitherColors(SDL_Color *colors, int bpp); +extern Uint8 SDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a); extern void SDL_DetectPalette(SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alpha_channel); #endif /* SDL_pixels_c_h_ */ diff --git a/src/video/SDL_rect.c b/src/video/SDL_rect.c index 26eb3cef4..d065e9079 100644 --- a/src/video/SDL_rect.c +++ b/src/video/SDL_rect.c @@ -27,7 +27,7 @@ and internally we only need the int version. */ SDL_bool SDL_GetSpanEnclosingRect(int width, int height, - int numrects, const SDL_Rect * rects, SDL_Rect *span) + int numrects, const SDL_Rect *rects, SDL_Rect *span) { int i; int span_y1, span_y2; @@ -80,7 +80,6 @@ SDL_GetSpanEnclosingRect(int width, int height, return SDL_FALSE; } - /* For use with the Cohen-Sutherland algorithm for line clipping, in SDL_rect_impl.h */ #define CODE_BOTTOM 1 #define CODE_TOP 2 @@ -88,27 +87,27 @@ SDL_GetSpanEnclosingRect(int width, int height, #define CODE_RIGHT 8 /* Same code twice, for float and int versions... */ -#define RECTTYPE SDL_Rect -#define POINTTYPE SDL_Point -#define SCALARTYPE int -#define COMPUTEOUTCODE ComputeOutCode -#define SDL_HASINTERSECTION SDL_HasIntersection -#define SDL_INTERSECTRECT SDL_IntersectRect -#define SDL_RECTEMPTY SDL_RectEmpty -#define SDL_UNIONRECT SDL_UnionRect -#define SDL_ENCLOSEPOINTS SDL_EnclosePoints +#define RECTTYPE SDL_Rect +#define POINTTYPE SDL_Point +#define SCALARTYPE int +#define COMPUTEOUTCODE ComputeOutCode +#define SDL_HASINTERSECTION SDL_HasIntersection +#define SDL_INTERSECTRECT SDL_IntersectRect +#define SDL_RECTEMPTY SDL_RectEmpty +#define SDL_UNIONRECT SDL_UnionRect +#define SDL_ENCLOSEPOINTS SDL_EnclosePoints #define SDL_INTERSECTRECTANDLINE SDL_IntersectRectAndLine #include "SDL_rect_impl.h" -#define RECTTYPE SDL_FRect -#define POINTTYPE SDL_FPoint -#define SCALARTYPE float -#define COMPUTEOUTCODE ComputeOutCodeF -#define SDL_HASINTERSECTION SDL_HasIntersectionF -#define SDL_INTERSECTRECT SDL_IntersectFRect -#define SDL_RECTEMPTY SDL_FRectEmpty -#define SDL_UNIONRECT SDL_UnionFRect -#define SDL_ENCLOSEPOINTS SDL_EncloseFPoints +#define RECTTYPE SDL_FRect +#define POINTTYPE SDL_FPoint +#define SCALARTYPE float +#define COMPUTEOUTCODE ComputeOutCodeF +#define SDL_HASINTERSECTION SDL_HasIntersectionF +#define SDL_INTERSECTRECT SDL_IntersectFRect +#define SDL_RECTEMPTY SDL_FRectEmpty +#define SDL_UNIONRECT SDL_UnionFRect +#define SDL_ENCLOSEPOINTS SDL_EncloseFPoints #define SDL_INTERSECTRECTANDLINE SDL_IntersectFRectAndLine #include "SDL_rect_impl.h" diff --git a/src/video/SDL_rect_c.h b/src/video/SDL_rect_c.h index 6205abc70..f371847fe 100644 --- a/src/video/SDL_rect_c.h +++ b/src/video/SDL_rect_c.h @@ -24,7 +24,7 @@ #include "../SDL_internal.h" -extern SDL_bool SDL_GetSpanEnclosingRect(int width, int height, int numrects, const SDL_Rect * rects, SDL_Rect *span); +extern SDL_bool SDL_GetSpanEnclosingRect(int width, int height, int numrects, const SDL_Rect *rects, SDL_Rect *span); #endif /* SDL_rect_c_h_ */ diff --git a/src/video/SDL_rect_impl.h b/src/video/SDL_rect_impl.h index 0e2513c35..5727ec679 100644 --- a/src/video/SDL_rect_impl.h +++ b/src/video/SDL_rect_impl.h @@ -22,7 +22,7 @@ /* This file is #included twice to support int and float versions with the same code. */ SDL_bool -SDL_HASINTERSECTION(const RECTTYPE * A, const RECTTYPE * B) +SDL_HASINTERSECTION(const RECTTYPE *A, const RECTTYPE *B) { SCALARTYPE Amin, Amax, Bmin, Bmax; @@ -33,7 +33,7 @@ SDL_HASINTERSECTION(const RECTTYPE * A, const RECTTYPE * B) SDL_InvalidParamError("B"); return SDL_FALSE; } else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) { - return SDL_FALSE; /* Special cases for empty rects */ + return SDL_FALSE; /* Special cases for empty rects */ } /* Horizontal intersection */ @@ -68,7 +68,7 @@ SDL_HASINTERSECTION(const RECTTYPE * A, const RECTTYPE * B) } SDL_bool -SDL_INTERSECTRECT(const RECTTYPE * A, const RECTTYPE * B, RECTTYPE * result) +SDL_INTERSECTRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *result) { SCALARTYPE Amin, Amax, Bmin, Bmax; @@ -81,7 +81,7 @@ SDL_INTERSECTRECT(const RECTTYPE * A, const RECTTYPE * B, RECTTYPE * result) } else if (result == NULL) { SDL_InvalidParamError("result"); return SDL_FALSE; - } else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) { /* Special cases for empty rects */ + } else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) { /* Special cases for empty rects */ result->w = 0; result->h = 0; return SDL_FALSE; @@ -118,8 +118,7 @@ SDL_INTERSECTRECT(const RECTTYPE * A, const RECTTYPE * B, RECTTYPE * result) return !SDL_RECTEMPTY(result); } -void -SDL_UNIONRECT(const RECTTYPE * A, const RECTTYPE * B, RECTTYPE * result) +void SDL_UNIONRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *result) { SCALARTYPE Amin, Amax, Bmin, Bmax; @@ -132,16 +131,16 @@ SDL_UNIONRECT(const RECTTYPE * A, const RECTTYPE * B, RECTTYPE * result) } else if (result == NULL) { SDL_InvalidParamError("result"); return; - } else if (SDL_RECTEMPTY(A)) { /* Special cases for empty Rects */ - if (SDL_RECTEMPTY(B)) { /* A and B empty */ + } else if (SDL_RECTEMPTY(A)) { /* Special cases for empty Rects */ + if (SDL_RECTEMPTY(B)) { /* A and B empty */ SDL_zerop(result); - } else { /* A empty, B not empty */ + } else { /* A empty, B not empty */ *result = *B; } return; - } else if (SDL_RECTEMPTY(B)) { /* A not empty, B empty */ - *result = *A; - return; + } else if (SDL_RECTEMPTY(B)) { /* A not empty, B empty */ + *result = *A; + return; } /* Horizontal union */ @@ -173,8 +172,8 @@ SDL_UNIONRECT(const RECTTYPE * A, const RECTTYPE * B, RECTTYPE * result) result->h = Amax - Amin; } -SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE * points, int count, const RECTTYPE * clip, - RECTTYPE * result) +SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *clip, + RECTTYPE *result) { SCALARTYPE minx = 0; SCALARTYPE miny = 0; @@ -195,8 +194,8 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE * points, int count, const RECTTYPE * SDL_bool added = SDL_FALSE; const SCALARTYPE clip_minx = clip->x; const SCALARTYPE clip_miny = clip->y; - const SCALARTYPE clip_maxx = clip->x+clip->w-1; - const SCALARTYPE clip_maxy = clip->y+clip->h-1; + const SCALARTYPE clip_maxx = clip->x + clip->w - 1; + const SCALARTYPE clip_maxy = clip->y + clip->h - 1; /* Special case for empty rectangle */ if (SDL_RECTEMPTY(clip)) { @@ -267,15 +266,14 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE * points, int count, const RECTTYPE * if (result) { result->x = minx; result->y = miny; - result->w = (maxx-minx)+1; - result->h = (maxy-miny)+1; + result->w = (maxx - minx) + 1; + result->h = (maxy - miny) + 1; } return SDL_TRUE; } /* Use the Cohen-Sutherland algorithm for line clipping */ -static int -COMPUTEOUTCODE(const RECTTYPE * rect, SCALARTYPE x, SCALARTYPE y) +static int COMPUTEOUTCODE(const RECTTYPE *rect, SCALARTYPE x, SCALARTYPE y) { int code = 0; if (y < rect->y) { @@ -292,7 +290,7 @@ COMPUTEOUTCODE(const RECTTYPE * rect, SCALARTYPE x, SCALARTYPE y) } SDL_bool -SDL_INTERSECTRECTANDLINE(const RECTTYPE * rect, SCALARTYPE *X1, SCALARTYPE *Y1, SCALARTYPE *X2, +SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTYPE *Y1, SCALARTYPE *X2, SCALARTYPE *Y2) { SCALARTYPE x = 0; @@ -321,7 +319,7 @@ SDL_INTERSECTRECTANDLINE(const RECTTYPE * rect, SCALARTYPE *X1, SCALARTYPE *Y1, SDL_InvalidParamError("Y2"); return SDL_FALSE; } else if (SDL_RECTEMPTY(rect)) { - return SDL_FALSE; /* Special case for empty rect */ + return SDL_FALSE; /* Special case for empty rect */ } x1 = *X1; @@ -345,7 +343,7 @@ SDL_INTERSECTRECTANDLINE(const RECTTYPE * rect, SCALARTYPE *X1, SCALARTYPE *Y1, return SDL_FALSE; } - if (y1 == y2) { /* Horizontal line, easy to clip */ + if (y1 == y2) { /* Horizontal line, easy to clip */ if (x1 < rectx1) { *X1 = rectx1; } else if (x1 > rectx2) { @@ -359,7 +357,7 @@ SDL_INTERSECTRECTANDLINE(const RECTTYPE * rect, SCALARTYPE *X1, SCALARTYPE *Y1, return SDL_TRUE; } - if (x1 == x2) { /* Vertical line, easy to clip */ + if (x1 == x2) { /* Vertical line, easy to clip */ if (y1 < recty1) { *Y1 = recty1; } else if (y1 > recty2) { @@ -400,23 +398,23 @@ SDL_INTERSECTRECTANDLINE(const RECTTYPE * rect, SCALARTYPE *X1, SCALARTYPE *Y1, outcode1 = COMPUTEOUTCODE(rect, x, y); } else { if (outcode2 & CODE_TOP) { - SDL_assert(y2 != y1); /* if equal: division by zero. */ + SDL_assert(y2 != y1); /* if equal: division by zero. */ y = recty1; x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1); } else if (outcode2 & CODE_BOTTOM) { - SDL_assert(y2 != y1); /* if equal: division by zero. */ + SDL_assert(y2 != y1); /* if equal: division by zero. */ y = recty2; x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1); } else if (outcode2 & CODE_LEFT) { /* If this assertion ever fires, here's the static analysis that warned about it: http://buildbot.libsdl.org/sdl-static-analysis/sdl-macosx-static-analysis/sdl-macosx-static-analysis-1101/report-b0d01a.html#EndPath */ - SDL_assert(x2 != x1); /* if equal: division by zero. */ + SDL_assert(x2 != x1); /* if equal: division by zero. */ x = rectx1; y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1); } else if (outcode2 & CODE_RIGHT) { /* If this assertion ever fires, here's the static analysis that warned about it: http://buildbot.libsdl.org/sdl-static-analysis/sdl-macosx-static-analysis/sdl-macosx-static-analysis-1101/report-39b114.html#EndPath */ - SDL_assert(x2 != x1); /* if equal: division by zero. */ + SDL_assert(x2 != x1); /* if equal: division by zero. */ x = rectx2; y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1); } diff --git a/src/video/SDL_shape.c b/src/video/SDL_shape.c index f45dc25a1..2cba72df2 100644 --- a/src/video/SDL_shape.c +++ b/src/video/SDL_shape.c @@ -28,11 +28,11 @@ #include "SDL_shape.h" #include "SDL_shape_internals.h" -SDL_Window* -SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) +SDL_Window * +SDL_CreateShapedWindow(const char *title, unsigned int x, unsigned int y, unsigned int w, unsigned int h, Uint32 flags) { SDL_Window *result = NULL; - result = SDL_CreateWindow(title,-1000,-1000,w,h,(flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /* & (~SDL_WINDOW_SHOWN) */); + result = SDL_CreateWindow(title, -1000, -1000, w, h, (flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /* & (~SDL_WINDOW_SHOWN) */); if (result != NULL) { if (SDL_GetVideoDevice()->shape_driver.CreateShaper == NULL) { SDL_DestroyWindow(result); @@ -64,14 +64,13 @@ SDL_IsShapedWindow(const SDL_Window *window) } /* REQUIRES that bitmap point to a w-by-h bitmap with ppb pixels-per-byte. */ -void -SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode,SDL_Surface *shape,Uint8* bitmap,Uint8 ppb) +void SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode, SDL_Surface *shape, Uint8 *bitmap, Uint8 ppb) { int x = 0; int y = 0; - Uint8 r = 0,g = 0,b = 0,alpha = 0; - Uint8* pixel = NULL; - Uint32 pixel_value = 0,mask_value = 0; + Uint8 r = 0, g = 0, b = 0, alpha = 0; + Uint8 *pixel = NULL; + Uint32 pixel_value = 0, mask_value = 0; int bytes_per_scanline = (shape->w + (ppb - 1)) / ppb; Uint8 *bitmap_scanline; SDL_Color key; @@ -82,41 +81,41 @@ SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode,SDL_Surface *shape,Uint8* bitm SDL_memset(bitmap, 0, shape->h * bytes_per_scanline); - for (y = 0;yh;y++) { + for (y = 0; y < shape->h; y++) { bitmap_scanline = bitmap + y * bytes_per_scanline; - for (x=0;xw;x++) { + for (x = 0; x < shape->w; x++) { alpha = 0; pixel_value = 0; - pixel = (Uint8 *)(shape->pixels) + (y*shape->pitch) + (x*shape->format->BytesPerPixel); - switch(shape->format->BytesPerPixel) { - case(1): - pixel_value = *pixel; - break; - case(2): - pixel_value = *(Uint16*)pixel; - break; - case(3): - pixel_value = *(Uint32*)pixel & (~shape->format->Amask); - break; - case(4): - pixel_value = *(Uint32*)pixel; - break; + pixel = (Uint8 *)(shape->pixels) + (y * shape->pitch) + (x * shape->format->BytesPerPixel); + switch (shape->format->BytesPerPixel) { + case (1): + pixel_value = *pixel; + break; + case (2): + pixel_value = *(Uint16 *)pixel; + break; + case (3): + pixel_value = *(Uint32 *)pixel & (~shape->format->Amask); + break; + case (4): + pixel_value = *(Uint32 *)pixel; + break; } - SDL_GetRGBA(pixel_value,shape->format,&r,&g,&b,&alpha); - switch(mode.mode) { - case(ShapeModeDefault): - mask_value = (alpha >= 1 ? 1 : 0); - break; - case(ShapeModeBinarizeAlpha): - mask_value = (alpha >= mode.parameters.binarizationCutoff ? 1 : 0); - break; - case(ShapeModeReverseBinarizeAlpha): - mask_value = (alpha <= mode.parameters.binarizationCutoff ? 1 : 0); - break; - case(ShapeModeColorKey): - key = mode.parameters.colorKey; - mask_value = ((key.r != r || key.g != g || key.b != b) ? 1 : 0); - break; + SDL_GetRGBA(pixel_value, shape->format, &r, &g, &b, &alpha); + switch (mode.mode) { + case (ShapeModeDefault): + mask_value = (alpha >= 1 ? 1 : 0); + break; + case (ShapeModeBinarizeAlpha): + mask_value = (alpha >= mode.parameters.binarizationCutoff ? 1 : 0); + break; + case (ShapeModeReverseBinarizeAlpha): + mask_value = (alpha <= mode.parameters.binarizationCutoff ? 1 : 0); + break; + case (ShapeModeColorKey): + key = mode.parameters.colorKey; + mask_value = ((key.r != r || key.g != g || key.b != b) ? 1 : 0); + break; } bitmap_scanline[x / ppb] |= mask_value << (x % ppb); } @@ -127,51 +126,51 @@ SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode,SDL_Surface *shape,Uint8* bitm } } -static SDL_ShapeTree* -RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* mask,SDL_Rect dimensions) { - int x = 0,y = 0; - Uint8* pixel = NULL; +static SDL_ShapeTree *RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode, SDL_Surface *mask, SDL_Rect dimensions) +{ + int x = 0, y = 0; + Uint8 *pixel = NULL; Uint32 pixel_value = 0; - Uint8 r = 0,g = 0,b = 0,a = 0; + Uint8 r = 0, g = 0, b = 0, a = 0; SDL_bool pixel_opaque = SDL_FALSE; int last_opaque = -1; SDL_Color key; - SDL_ShapeTree* result = (SDL_ShapeTree*)SDL_malloc(sizeof(SDL_ShapeTree)); - SDL_Rect next = {0,0,0,0}; + SDL_ShapeTree *result = (SDL_ShapeTree *)SDL_malloc(sizeof(SDL_ShapeTree)); + SDL_Rect next = { 0, 0, 0, 0 }; - for (y=dimensions.y;ypixels) + (y*mask->pitch) + (x*mask->format->BytesPerPixel); - switch(mask->format->BytesPerPixel) { - case(1): - pixel_value = *pixel; - break; - case(2): - pixel_value = *(Uint16*)pixel; - break; - case(3): - pixel_value = *(Uint32*)pixel & (~mask->format->Amask); - break; - case(4): - pixel_value = *(Uint32*)pixel; - break; + pixel = (Uint8 *)(mask->pixels) + (y * mask->pitch) + (x * mask->format->BytesPerPixel); + switch (mask->format->BytesPerPixel) { + case (1): + pixel_value = *pixel; + break; + case (2): + pixel_value = *(Uint16 *)pixel; + break; + case (3): + pixel_value = *(Uint32 *)pixel & (~mask->format->Amask); + break; + case (4): + pixel_value = *(Uint32 *)pixel; + break; } - SDL_GetRGBA(pixel_value,mask->format,&r,&g,&b,&a); - switch(mode.mode) { - case(ShapeModeDefault): - pixel_opaque = (a >= 1 ? SDL_TRUE : SDL_FALSE); - break; - case(ShapeModeBinarizeAlpha): - pixel_opaque = (a >= mode.parameters.binarizationCutoff ? SDL_TRUE : SDL_FALSE); - break; - case(ShapeModeReverseBinarizeAlpha): - pixel_opaque = (a <= mode.parameters.binarizationCutoff ? SDL_TRUE : SDL_FALSE); - break; - case(ShapeModeColorKey): - key = mode.parameters.colorKey; - pixel_opaque = ((key.r != r || key.g != g || key.b != b) ? SDL_TRUE : SDL_FALSE); - break; + SDL_GetRGBA(pixel_value, mask->format, &r, &g, &b, &a); + switch (mode.mode) { + case (ShapeModeDefault): + pixel_opaque = (a >= 1 ? SDL_TRUE : SDL_FALSE); + break; + case (ShapeModeBinarizeAlpha): + pixel_opaque = (a >= mode.parameters.binarizationCutoff ? SDL_TRUE : SDL_FALSE); + break; + case (ShapeModeReverseBinarizeAlpha): + pixel_opaque = (a <= mode.parameters.binarizationCutoff ? SDL_TRUE : SDL_FALSE); + break; + case (ShapeModeColorKey): + key = mode.parameters.colorKey; + pixel_opaque = ((key.r != r || key.g != g || key.b != b) ? SDL_TRUE : SDL_FALSE); + break; } if (last_opaque == -1) { last_opaque = pixel_opaque; @@ -186,39 +185,38 @@ RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* mask,SDL_Rec next.y = dimensions.y; next.w = halfwidth; next.h = halfheight; - result->data.children.upleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next); + result->data.children.upleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode, mask, next); next.x = dimensions.x + halfwidth; next.w = dimensions.w - halfwidth; - result->data.children.upright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next); + result->data.children.upright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode, mask, next); next.x = dimensions.x; next.w = halfwidth; next.y = dimensions.y + halfheight; next.h = dimensions.h - halfheight; - result->data.children.downleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next); + result->data.children.downleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode, mask, next); next.x = dimensions.x + halfwidth; next.w = dimensions.w - halfwidth; - result->data.children.downright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next); + result->data.children.downright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode, mask, next); return result; } } } - /* If we never recursed, all the pixels in this quadrant have the same "value". */ result->kind = (last_opaque == SDL_TRUE ? OpaqueShape : TransparentShape); result->data.shape = dimensions; return result; } -SDL_ShapeTree* -SDL_CalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* shape) +SDL_ShapeTree * +SDL_CalculateShapeTree(SDL_WindowShapeMode mode, SDL_Surface *shape) { SDL_Rect dimensions; - SDL_ShapeTree* result = NULL; + SDL_ShapeTree *result = NULL; dimensions.x = 0; dimensions.y = 0; @@ -228,41 +226,38 @@ SDL_CalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* shape) if (SDL_MUSTLOCK(shape)) { SDL_LockSurface(shape); } - result = RecursivelyCalculateShapeTree(mode,shape,dimensions); + result = RecursivelyCalculateShapeTree(mode, shape, dimensions); if (SDL_MUSTLOCK(shape)) { SDL_UnlockSurface(shape); } return result; } -void -SDL_TraverseShapeTree(SDL_ShapeTree *tree,SDL_TraversalFunction function,void* closure) +void SDL_TraverseShapeTree(SDL_ShapeTree *tree, SDL_TraversalFunction function, void *closure) { SDL_assert(tree != NULL); if (tree->kind == QuadShape) { - SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upleft,function,closure); - SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upright,function,closure); - SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.downleft,function,closure); - SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.downright,function,closure); + SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upleft, function, closure); + SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upright, function, closure); + SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.downleft, function, closure); + SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.downright, function, closure); } else - function(tree,closure); + function(tree, closure); } -void -SDL_FreeShapeTree(SDL_ShapeTree** shape_tree) +void SDL_FreeShapeTree(SDL_ShapeTree **shape_tree) { if ((*shape_tree)->kind == QuadShape) { - SDL_FreeShapeTree((SDL_ShapeTree **)(char*)&(*shape_tree)->data.children.upleft); - SDL_FreeShapeTree((SDL_ShapeTree **)(char*)&(*shape_tree)->data.children.upright); - SDL_FreeShapeTree((SDL_ShapeTree **)(char*)&(*shape_tree)->data.children.downleft); - SDL_FreeShapeTree((SDL_ShapeTree **)(char*)&(*shape_tree)->data.children.downright); + SDL_FreeShapeTree((SDL_ShapeTree **)(char *)&(*shape_tree)->data.children.upleft); + SDL_FreeShapeTree((SDL_ShapeTree **)(char *)&(*shape_tree)->data.children.upright); + SDL_FreeShapeTree((SDL_ShapeTree **)(char *)&(*shape_tree)->data.children.downleft); + SDL_FreeShapeTree((SDL_ShapeTree **)(char *)&(*shape_tree)->data.children.downright); } SDL_free(*shape_tree); *shape_tree = NULL; } -int -SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) +int SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); int result; @@ -317,8 +312,7 @@ SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *sh return result; } -static SDL_bool -SDL_WindowHasAShape(SDL_Window *window) +static SDL_bool SDL_WindowHasAShape(SDL_Window *window) { if (window == NULL || !SDL_IsShapedWindow(window)) { return SDL_FALSE; @@ -326,8 +320,7 @@ SDL_WindowHasAShape(SDL_Window *window) return window->shaper->hasshape; } -int -SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode) +int SDL_GetShapedWindowMode(SDL_Window *window, SDL_WindowShapeMode *shape_mode) { if (window != NULL && SDL_IsShapedWindow(window)) { if (shape_mode == NULL) { diff --git a/src/video/SDL_shape_internals.h b/src/video/SDL_shape_internals.h index 16d659ef1..7a12c73a1 100644 --- a/src/video/SDL_shape_internals.h +++ b/src/video/SDL_shape_internals.h @@ -37,28 +37,36 @@ extern "C" { struct SDL_ShapeTree; -typedef struct { - struct SDL_ShapeTree *upleft,*upright,*downleft,*downright; +typedef struct +{ + struct SDL_ShapeTree *upleft, *upright, *downleft, *downright; } SDL_QuadTreeChildren; -typedef union { +typedef union +{ SDL_QuadTreeChildren children; SDL_Rect shape; } SDL_ShapeUnion; -typedef enum { QuadShape,TransparentShape,OpaqueShape } SDL_ShapeKind; +typedef enum +{ + QuadShape, + TransparentShape, + OpaqueShape +} SDL_ShapeKind; -typedef struct SDL_ShapeTree { +typedef struct SDL_ShapeTree +{ SDL_ShapeKind kind; SDL_ShapeUnion data; } SDL_ShapeTree; -typedef void(*SDL_TraversalFunction)(SDL_ShapeTree*,void*); +typedef void (*SDL_TraversalFunction)(SDL_ShapeTree *, void *); -extern void SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode,SDL_Surface *shape,Uint8* bitmap,Uint8 ppb); -extern SDL_ShapeTree* SDL_CalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* shape); -extern void SDL_TraverseShapeTree(SDL_ShapeTree *tree,SDL_TraversalFunction function,void* closure); -extern void SDL_FreeShapeTree(SDL_ShapeTree** shape_tree); +extern void SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode, SDL_Surface *shape, Uint8 *bitmap, Uint8 ppb); +extern SDL_ShapeTree *SDL_CalculateShapeTree(SDL_WindowShapeMode mode, SDL_Surface *shape); +extern void SDL_TraverseShapeTree(SDL_ShapeTree *tree, SDL_TraversalFunction function, void *closure); +extern void SDL_FreeShapeTree(SDL_ShapeTree **shape_tree); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/src/video/SDL_stretch.c b/src/video/SDL_stretch.c index bc7b4e551..bf20248c3 100644 --- a/src/video/SDL_stretch.c +++ b/src/video/SDL_stretch.c @@ -26,25 +26,22 @@ static int SDL_LowerSoftStretchNearest(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect); static int SDL_LowerSoftStretchLinear(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect); -static int SDL_UpperSoftStretch(SDL_Surface * src, const SDL_Rect * srcrect, SDL_Surface * dst, const SDL_Rect * dstrect, SDL_ScaleMode scaleMode); +static int SDL_UpperSoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode); -int -SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, - SDL_Surface *dst, const SDL_Rect *dstrect) +int SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, + SDL_Surface *dst, const SDL_Rect *dstrect) { return SDL_UpperSoftStretch(src, srcrect, dst, dstrect, SDL_ScaleModeNearest); } -int -SDL_SoftStretchLinear(SDL_Surface *src, const SDL_Rect *srcrect, - SDL_Surface *dst, const SDL_Rect *dstrect) +int SDL_SoftStretchLinear(SDL_Surface *src, const SDL_Rect *srcrect, + SDL_Surface *dst, const SDL_Rect *dstrect) { return SDL_UpperSoftStretch(src, srcrect, dst, dstrect, SDL_ScaleModeLinear); } -static int -SDL_UpperSoftStretch(SDL_Surface * src, const SDL_Rect * srcrect, - SDL_Surface * dst, const SDL_Rect * dstrect, SDL_ScaleMode scaleMode) +static int SDL_UpperSoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, + SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode) { int ret; int src_locked; @@ -140,55 +137,53 @@ SDL_UpperSoftStretch(SDL_Surface * src, const SDL_Rect * srcrect, Because with SSE: add-multiply: _mm_madd_epi16 works with signed int so pixels 0xb1...... are negatives and false the result same in NEON probably */ -#define PRECISION 7 +#define PRECISION 7 -#define FIXED_POINT(i) ((Uint32)(i) << 16) -#define SRC_INDEX(fp) ((Uint32)(fp) >> 16) -#define INTEGER(fp) ((Uint32)(fp) >> PRECISION) -#define FRAC(fp) ((Uint32)(fp >> (16 - PRECISION)) & ((1< dst_h - 1 - right_pad_h); \ - index_h = SRC_INDEX(fp_sum_h); \ - frac_h0 = FRAC(fp_sum_h); \ - \ - index_h = no_padding ? index_h : (i < left_pad_h ? 0 : src_h - 1); \ - frac_h0 = no_padding ? frac_h0 : 0; \ - incr_h1 = no_padding ? src_pitch : 0; \ - incr_h0 = index_h * src_pitch; \ - \ - src_h0 = (const Uint32 *)((const Uint8 *)src + incr_h0); \ - src_h1 = (const Uint32 *)((const Uint8 *)src_h0 + incr_h1); \ - \ - fp_sum_h += fp_step_h; \ - \ - frac_h1 = FRAC_ONE - frac_h0; \ - fp_sum_w = fp_sum_w_init; \ - right_pad_w = right_pad_w_init; \ - left_pad_w = left_pad_w_init; \ - middle = middle_init; \ +#define FIXED_POINT(i) ((Uint32)(i) << 16) +#define SRC_INDEX(fp) ((Uint32)(fp) >> 16) +#define INTEGER(fp) ((Uint32)(fp) >> PRECISION) +#define FRAC(fp) ((Uint32)(fp >> (16 - PRECISION)) & ((1 << PRECISION) - 1)) +#define FRAC_ZERO 0 +#define FRAC_ONE (1 << PRECISION) +#define FP_ONE FIXED_POINT(1) +#define BILINEAR___START \ + int i; \ + int fp_sum_h, fp_step_h, left_pad_h, right_pad_h; \ + int fp_sum_w, fp_step_w, left_pad_w, right_pad_w; \ + int fp_sum_w_init, left_pad_w_init, right_pad_w_init, dst_gap, middle_init; \ + get_scaler_datas(src_h, dst_h, &fp_sum_h, &fp_step_h, &left_pad_h, &right_pad_h); \ + get_scaler_datas(src_w, dst_w, &fp_sum_w, &fp_step_w, &left_pad_w, &right_pad_w); \ + fp_sum_w_init = fp_sum_w + left_pad_w * fp_step_w; \ + left_pad_w_init = left_pad_w; \ + right_pad_w_init = right_pad_w; \ + dst_gap = dst_pitch - 4 * dst_w; \ + middle_init = dst_w - left_pad_w - right_pad_w; +#define BILINEAR___HEIGHT \ + int index_h, frac_h0, frac_h1, middle; \ + const Uint32 *src_h0, *src_h1; \ + int no_padding, incr_h0, incr_h1; \ + \ + no_padding = !(i < left_pad_h || i > dst_h - 1 - right_pad_h); \ + index_h = SRC_INDEX(fp_sum_h); \ + frac_h0 = FRAC(fp_sum_h); \ + \ + index_h = no_padding ? index_h : (i < left_pad_h ? 0 : src_h - 1); \ + frac_h0 = no_padding ? frac_h0 : 0; \ + incr_h1 = no_padding ? src_pitch : 0; \ + incr_h0 = index_h * src_pitch; \ + \ + src_h0 = (const Uint32 *)((const Uint8 *)src + incr_h0); \ + src_h1 = (const Uint32 *)((const Uint8 *)src_h0 + incr_h1); \ + \ + fp_sum_h += fp_step_h; \ + \ + frac_h1 = FRAC_ONE - frac_h0; \ + fp_sum_w = fp_sum_w_init; \ + right_pad_w = right_pad_w_init; \ + left_pad_w = left_pad_w_init; \ + middle = middle_init; #if defined(__clang__) // Remove inlining of this function @@ -202,8 +197,8 @@ static void get_scaler_datas(int src_nb, int dst_nb, int *fp_start, int *fp_step, int *left_pad, int *right_pad) { - int step = FIXED_POINT(src_nb) / (dst_nb); /* source step in fixed point */ - int x0 = FP_ONE / 2; /* dst first pixel center at 0.5 in fixed point */ + int step = FIXED_POINT(src_nb) / (dst_nb); /* source step in fixed point */ + int x0 = FP_ONE / 2; /* dst first pixel center at 0.5 in fixed point */ int fp_sum; int i; #if 0 @@ -215,7 +210,7 @@ get_scaler_datas(int src_nb, int dst_nb, int *fp_start, int *fp_step, int *left_ Sint64 tmp[2]; tmp[0] = (Sint64)step * (x0 >> 16); tmp[1] = (Sint64)step * (x0 & 0xFFFF); - x0 = (int) (tmp[0] + ((tmp[1] + 0x8000) >> 16)); /* x0 == (step + 1) / 2 */ + x0 = (int)(tmp[0] + ((tmp[1] + 0x8000) >> 16)); /* x0 == (step + 1) / 2 */ #endif /* -= 0.5, get back the pixel origin, in source coordinates */ x0 -= FP_ONE / 2; @@ -237,19 +232,19 @@ get_scaler_datas(int src_nb, int dst_nb, int *fp_start, int *fp_step, int *left_ } fp_sum += step; } -// SDL_Log("%d -> %d x0=%d step=%d left_pad=%d right_pad=%d", src_nb, dst_nb, *fp_start, *fp_step, *left_pad, *right_pad); + // SDL_Log("%d -> %d x0=%d step=%d left_pad=%d right_pad=%d", src_nb, dst_nb, *fp_start, *fp_step, *left_pad, *right_pad); } -typedef struct color_t { - Uint8 a; - Uint8 b; - Uint8 c; - Uint8 d; +typedef struct color_t +{ + Uint8 a; + Uint8 b; + Uint8 c; + Uint8 d; } color_t; #if 0 -static void -printf_64(const char *str, void *var) +static void printf_64(const char *str, void *var) { uint8_t *val = (uint8_t*) var; printf(" * %s: %02x %02x %02x %02x _ %02x %02x %02x %02x\n", @@ -259,12 +254,11 @@ printf_64(const char *str, void *var) /* Interpolated == x0 + frac * (x1 - x0) == x0 * (1 - frac) + x1 * frac */ -static SDL_INLINE void -INTERPOL(const Uint32 *src_x0, const Uint32 *src_x1, int frac0, int frac1, Uint32 *dst) +static SDL_INLINE void INTERPOL(const Uint32 *src_x0, const Uint32 *src_x1, int frac0, int frac1, Uint32 *dst) { const color_t *c0 = (const color_t *)src_x0; const color_t *c1 = (const color_t *)src_x1; - color_t *cx = (color_t *)dst; + color_t *cx = (color_t *)dst; #if 0 cx->a = c0->a + INTEGER(frac0 * (c1->a - c0->a)); cx->b = c0->b + INTEGER(frac0 * (c1->b - c0->b)); @@ -278,23 +272,21 @@ INTERPOL(const Uint32 *src_x0, const Uint32 *src_x1, int frac0, int frac1, Uint3 #endif } -static SDL_INLINE void -INTERPOL_BILINEAR(const Uint32 *s0, const Uint32 *s1, int frac_w0, int frac_h0, int frac_h1, Uint32 *dst) +static SDL_INLINE void INTERPOL_BILINEAR(const Uint32 *s0, const Uint32 *s1, int frac_w0, int frac_h0, int frac_h1, Uint32 *dst) { Uint32 tmp[2]; unsigned int frac_w1 = FRAC_ONE - frac_w0; /* Vertical first, store to 'tmp' */ - INTERPOL(s0, s1, frac_h0, frac_h1, tmp); + INTERPOL(s0, s1, frac_h0, frac_h1, tmp); INTERPOL(s0 + 1, s1 + 1, frac_h0, frac_h1, tmp + 1); /* Horizontal, store to 'dst' */ - INTERPOL(tmp, tmp + 1, frac_w0, frac_w1, dst); + INTERPOL(tmp, tmp + 1, frac_w0, frac_w1, dst); } -static int -scale_mat(const Uint32 *src, int src_w, int src_h, int src_pitch, - Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +static int scale_mat(const Uint32 *src, int src_w, int src_h, int src_pitch, + Uint32 *dst, int dst_w, int dst_h, int dst_pitch) { BILINEAR___START @@ -314,14 +306,14 @@ scale_mat(const Uint32 *src, int src_w, int src_h, int src_pitch, int frac_w = FRAC(fp_sum_w); fp_sum_w += fp_step_w; -/* - x00 ... x0_ ..... x01 - . . . - . x . - . . . - . . . - x10 ... x1_ ..... x11 -*/ + /* + x00 ... x0_ ..... x01 + . . . + . x . + . . . + . . . + x10 ... x1_ ..... x11 + */ s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w); s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w); @@ -343,29 +335,28 @@ scale_mat(const Uint32 *src, int src_w, int src_h, int src_pitch, } #if defined(__SSE2__) -# define HAVE_SSE2_INTRINSICS 1 +#define HAVE_SSE2_INTRINSICS 1 #endif #if defined(__ARM_NEON) -# define HAVE_NEON_INTRINSICS 1 -# define CAST_uint8x8_t (uint8x8_t) -# define CAST_uint32x2_t (uint32x2_t) +#define HAVE_NEON_INTRINSICS 1 +#define CAST_uint8x8_t (uint8x8_t) +#define CAST_uint32x2_t (uint32x2_t) #endif #if defined(__WINRT__) || defined(_MSC_VER) -# if defined(HAVE_NEON_INTRINSICS) -# undef CAST_uint8x8_t -# undef CAST_uint32x2_t -# define CAST_uint8x8_t -# define CAST_uint32x2_t -# endif +#if defined(HAVE_NEON_INTRINSICS) +#undef CAST_uint8x8_t +#undef CAST_uint32x2_t +#define CAST_uint8x8_t +#define CAST_uint32x2_t +#endif #endif #if defined(HAVE_SSE2_INTRINSICS) #if 0 -static void -printf_128(const char *str, __m128i var) +static void printf_128(const char *str, __m128i var) { uint16_t *val = (uint16_t*) &var; printf(" * %s: %04x %04x %04x %04x _ %04x %04x %04x %04x\n", @@ -373,8 +364,7 @@ printf_128(const char *str, __m128i var) } #endif -static SDL_INLINE int -hasSSE2() +static SDL_INLINE int hasSSE2() { static int val = -1; if (val != -1) { @@ -384,8 +374,7 @@ hasSSE2() return val; } -static SDL_INLINE void -INTERPOL_BILINEAR_SSE(const Uint32 *s0, const Uint32 *s1, int frac_w, __m128i v_frac_h0, __m128i v_frac_h1, Uint32 *dst, __m128i zero) +static SDL_INLINE void INTERPOL_BILINEAR_SSE(const Uint32 *s0, const Uint32 *s1, int frac_w, __m128i v_frac_h0, __m128i v_frac_h1, Uint32 *dst, __m128i zero) { __m128i x_00_01, x_10_11; /* Pixels in 4*uint8 in row */ __m128i v_frac_w0, k0, l0, d0, e0; @@ -395,8 +384,7 @@ INTERPOL_BILINEAR_SSE(const Uint32 *s0, const Uint32 *s1, int frac_w, __m128i v_ f2 = FRAC_ONE - frac_w; v_frac_w0 = _mm_set_epi16(f, f2, f, f2, f, f2, f, f2); - - x_00_01 = _mm_loadl_epi64((const __m128i *)s0); /* Load x00 and x01 */ + x_00_01 = _mm_loadl_epi64((const __m128i *)s0); /* Load x00 and x01 */ x_10_11 = _mm_loadl_epi64((const __m128i *)s1); /* Interpolated == x0 + frac * (x1 - x0) == x0 * (1 - frac) + x1 * frac */ @@ -423,8 +411,7 @@ INTERPOL_BILINEAR_SSE(const Uint32 *s0, const Uint32 *s1, int frac_w, __m128i v_ *dst = _mm_cvtsi128_si32(e0); } -static int -scale_mat_SSE(const Uint32 *src, int src_w, int src_h, int src_pitch, Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +static int scale_mat_SSE(const Uint32 *src, int src_w, int src_h, int src_pitch, Uint32 *dst, int dst_w, int dst_h, int dst_pitch) { BILINEAR___START @@ -453,7 +440,7 @@ scale_mat_SSE(const Uint32 *src, int src_w, int src_h, int src_pitch, Uint32 *ds const Uint32 *s_00_01, *s_02_03, *s_10_11, *s_12_13; - __m128i x_00_01, x_10_11, x_02_03, x_12_13;/* Pixels in 4*uint8 in row */ + __m128i x_00_01, x_10_11, x_02_03, x_12_13; /* Pixels in 4*uint8 in row */ __m128i v_frac_w0, k0, l0, d0, e0; __m128i v_frac_w1, k1, l1, d1, e1; @@ -464,15 +451,15 @@ scale_mat_SSE(const Uint32 *src, int src_w, int src_h, int src_pitch, Uint32 *ds index_w_1 = 4 * SRC_INDEX(fp_sum_w); frac_w_1 = FRAC(fp_sum_w); fp_sum_w += fp_step_w; -/* - x00............ x01 x02...........x03 - . . . . . . - j0 f0 j1 j2 f1 j3 - . . . . . . - . . . . . . - . . . . . . - x10............ x11 x12...........x13 - */ + /* + x00............ x01 x02...........x03 + . . . . . . + j0 f0 j1 j2 f1 j3 + . . . . . . + . . . . . . + . . . . . . + x10............ x11 x12...........x13 + */ s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_0); s_02_03 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_1); s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_0); @@ -546,8 +533,7 @@ scale_mat_SSE(const Uint32 *src, int src_w, int src_h, int src_pitch, Uint32 *ds #if defined(HAVE_NEON_INTRINSICS) -static SDL_INLINE int -hasNEON() +static SDL_INLINE int hasNEON() { static int val = -1; if (val != -1) { @@ -557,8 +543,7 @@ hasNEON() return val; } -static SDL_INLINE void -INTERPOL_BILINEAR_NEON(const Uint32 *s0, const Uint32 *s1, int frac_w, uint8x8_t v_frac_h0, uint8x8_t v_frac_h1, Uint32 *dst) +static SDL_INLINE void INTERPOL_BILINEAR_NEON(const Uint32 *s0, const Uint32 *s1, int frac_w, uint8x8_t v_frac_h0, uint8x8_t v_frac_h1, Uint32 *dst) { uint8x8_t x_00_01, x_10_11; /* Pixels in 4*uint8 in row */ uint16x8_t k0; @@ -570,8 +555,8 @@ INTERPOL_BILINEAR_NEON(const Uint32 *s0, const Uint32 *s1, int frac_w, uint8x8_t x_10_11 = CAST_uint8x8_t vld1_u32(s1); /* Interpolated == x0 + frac * (x1 - x0) == x0 * (1 - frac) + x1 * frac */ - k0 = vmull_u8(x_00_01, v_frac_h1); /* k0 := x0 * (1 - frac) */ - k0 = vmlal_u8(k0, x_10_11, v_frac_h0); /* k0 += x1 * frac */ + k0 = vmull_u8(x_00_01, v_frac_h1); /* k0 := x0 * (1 - frac) */ + k0 = vmlal_u8(k0, x_10_11, v_frac_h0); /* k0 += x1 * frac */ /* k0 now contains 2 interpolated pixels { j0, j1 } */ l0 = vshll_n_u16(vget_low_u16(k0), PRECISION); @@ -580,9 +565,8 @@ INTERPOL_BILINEAR_NEON(const Uint32 *s0, const Uint32 *s1, int frac_w, uint8x8_t /* Shift and narrow */ d0 = vcombine_u16( - /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION), - /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION) - ); + /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION), + /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION)); /* Narrow again */ e0 = vmovn_u16(d0); @@ -591,7 +575,7 @@ INTERPOL_BILINEAR_NEON(const Uint32 *s0, const Uint32 *s1, int frac_w, uint8x8_t *dst = vget_lane_u32(CAST_uint32x2_t e0, 0); } - static int +static int scale_mat_NEON(const Uint32 *src, int src_w, int src_h, int src_pitch, Uint32 *dst, int dst_w, int dst_h, int dst_pitch) { BILINEAR___START @@ -621,7 +605,7 @@ scale_mat_NEON(const Uint32 *src, int src_w, int src_h, int src_pitch, Uint32 *d const Uint32 *s_00_01, *s_02_03, *s_04_05, *s_06_07; const Uint32 *s_10_11, *s_12_13, *s_14_15, *s_16_17; - uint8x8_t x_00_01, x_10_11, x_02_03, x_12_13;/* Pixels in 4*uint8 in row */ + uint8x8_t x_00_01, x_10_11, x_02_03, x_12_13; /* Pixels in 4*uint8 in row */ uint8x8_t x_04_05, x_14_15, x_06_07, x_16_17; uint16x8_t k0, k1, k2, k3; @@ -631,17 +615,17 @@ scale_mat_NEON(const Uint32 *src, int src_w, int src_h, int src_pitch, Uint32 *d uint32x4_t f0; index_w_0 = 4 * SRC_INDEX(fp_sum_w); - frac_w_0 = FRAC(fp_sum_w); - fp_sum_w += fp_step_w; + frac_w_0 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; index_w_1 = 4 * SRC_INDEX(fp_sum_w); - frac_w_1 = FRAC(fp_sum_w); - fp_sum_w += fp_step_w; + frac_w_1 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; index_w_2 = 4 * SRC_INDEX(fp_sum_w); - frac_w_2 = FRAC(fp_sum_w); - fp_sum_w += fp_step_w; + frac_w_2 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; index_w_3 = 4 * SRC_INDEX(fp_sum_w); - frac_w_3 = FRAC(fp_sum_w); - fp_sum_w += fp_step_w; + frac_w_3 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_0); s_02_03 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_1); @@ -663,8 +647,8 @@ scale_mat_NEON(const Uint32 *src, int src_w, int src_h, int src_pitch, Uint32 *d x_16_17 = CAST_uint8x8_t vld1_u32(s_16_17); /* Interpolated == x0 + frac * (x1 - x0) == x0 * (1 - frac) + x1 * frac */ - k0 = vmull_u8(x_00_01, v_frac_h1); /* k0 := x0 * (1 - frac) */ - k0 = vmlal_u8(k0, x_10_11, v_frac_h0); /* k0 += x1 * frac */ + k0 = vmull_u8(x_00_01, v_frac_h1); /* k0 := x0 * (1 - frac) */ + k0 = vmlal_u8(k0, x_10_11, v_frac_h0); /* k0 += x1 * frac */ k1 = vmull_u8(x_02_03, v_frac_h1); k1 = vmlal_u8(k1, x_12_13, v_frac_h0); @@ -698,17 +682,15 @@ scale_mat_NEON(const Uint32 *src, int src_w, int src_h, int src_pitch, Uint32 *d /* shift and narrow */ d0 = vcombine_u16( - /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION), - /* uint16x4_t */ vshrn_n_u32(l1, 2 * PRECISION) - ); + /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION), + /* uint16x4_t */ vshrn_n_u32(l1, 2 * PRECISION)); /* narrow again */ e0 = vmovn_u16(d0); /* Shift and narrow */ d1 = vcombine_u16( - /* uint16x4_t */ vshrn_n_u32(l2, 2 * PRECISION), - /* uint16x4_t */ vshrn_n_u32(l3, 2 * PRECISION) - ); + /* uint16x4_t */ vshrn_n_u32(l2, 2 * PRECISION), + /* uint16x4_t */ vshrn_n_u32(l3, 2 * PRECISION)); /* Narrow again */ e1 = vmovn_u16(d1); @@ -724,41 +706,41 @@ scale_mat_NEON(const Uint32 *src, int src_w, int src_h, int src_pitch, Uint32 *d int index_w_1, frac_w_1; const Uint32 *s_00_01, *s_02_03; const Uint32 *s_10_11, *s_12_13; - uint8x8_t x_00_01, x_10_11, x_02_03, x_12_13;/* Pixels in 4*uint8 in row */ + uint8x8_t x_00_01, x_10_11, x_02_03, x_12_13; /* Pixels in 4*uint8 in row */ uint16x8_t k0, k1; uint32x4_t l0, l1; uint16x8_t d0; uint8x8_t e0; index_w_0 = 4 * SRC_INDEX(fp_sum_w); - frac_w_0 = FRAC(fp_sum_w); - fp_sum_w += fp_step_w; + frac_w_0 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; index_w_1 = 4 * SRC_INDEX(fp_sum_w); - frac_w_1 = FRAC(fp_sum_w); - fp_sum_w += fp_step_w; -/* - x00............ x01 x02...........x03 - . . . . . . - j0 dest0 j1 j2 dest1 j3 - . . . . . . - . . . . . . - . . . . . . - x10............ x11 x12...........x13 -*/ + frac_w_1 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; + /* + x00............ x01 x02...........x03 + . . . . . . + j0 dest0 j1 j2 dest1 j3 + . . . . . . + . . . . . . + . . . . . . + x10............ x11 x12...........x13 + */ s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_0); s_02_03 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_1); s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_0); s_12_13 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_1); /* Interpolation vertical */ - x_00_01 = CAST_uint8x8_t vld1_u32(s_00_01);/* Load 2 pixels */ + x_00_01 = CAST_uint8x8_t vld1_u32(s_00_01); /* Load 2 pixels */ x_02_03 = CAST_uint8x8_t vld1_u32(s_02_03); x_10_11 = CAST_uint8x8_t vld1_u32(s_10_11); x_12_13 = CAST_uint8x8_t vld1_u32(s_12_13); /* Interpolated == x0 + frac * (x1 - x0) == x0 * (1 - frac) + x1 * frac */ - k0 = vmull_u8(x_00_01, v_frac_h1); /* k0 := x0 * (1 - frac) */ - k0 = vmlal_u8(k0, x_10_11, v_frac_h0); /* k0 += x1 * frac */ + k0 = vmull_u8(x_00_01, v_frac_h1); /* k0 := x0 * (1 - frac) */ + k0 = vmlal_u8(k0, x_10_11, v_frac_h0); /* k0 += x1 * frac */ k1 = vmull_u8(x_02_03, v_frac_h1); k1 = vmlal_u8(k1, x_12_13, v_frac_h0); @@ -777,9 +759,8 @@ scale_mat_NEON(const Uint32 *src, int src_w, int src_h, int src_pitch, Uint32 *d /* Shift and narrow */ d0 = vcombine_u16( - /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION), - /* uint16x4_t */ vshrn_n_u32(l1, 2 * PRECISION) - ); + /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION), + /* uint16x4_t */ vshrn_n_u32(l1, 2 * PRECISION)); /* Narrow again */ e0 = vmovn_u16(d0); @@ -813,9 +794,8 @@ scale_mat_NEON(const Uint32 *src, int src_w, int src_h, int src_pitch, Uint32 *d } #endif -int -SDL_LowerSoftStretchLinear(SDL_Surface *s, const SDL_Rect *srcrect, - SDL_Surface *d, const SDL_Rect *dstrect) +int SDL_LowerSoftStretchLinear(SDL_Surface *s, const SDL_Rect *srcrect, + SDL_Surface *d, const SDL_Rect *dstrect) { int ret = -1; int src_w = srcrect->w; @@ -824,8 +804,8 @@ SDL_LowerSoftStretchLinear(SDL_Surface *s, const SDL_Rect *srcrect, int dst_h = dstrect->h; int src_pitch = s->pitch; int dst_pitch = d->pitch; - Uint32 *src = (Uint32 *) ((Uint8 *)s->pixels + srcrect->x * 4 + srcrect->y * src_pitch); - Uint32 *dst = (Uint32 *) ((Uint8 *)d->pixels + dstrect->x * 4 + dstrect->y * dst_pitch); + Uint32 *src = (Uint32 *)((Uint8 *)s->pixels + srcrect->x * 4 + srcrect->y * src_pitch); + Uint32 *dst = (Uint32 *)((Uint8 *)d->pixels + dstrect->x * 4 + dstrect->y * dst_pitch); #if defined(HAVE_NEON_INTRINSICS) if (ret == -1 && hasNEON()) { @@ -846,30 +826,27 @@ SDL_LowerSoftStretchLinear(SDL_Surface *s, const SDL_Rect *srcrect, return ret; } +#define SDL_SCALE_NEAREST__START \ + int i; \ + Uint32 posy, incy; \ + Uint32 posx, incx; \ + int dst_gap; \ + int srcy, n; \ + const Uint32 *src_h0; \ + incy = (src_h << 16) / dst_h; \ + incx = (src_w << 16) / dst_w; \ + dst_gap = dst_pitch - bpp * dst_w; \ + posy = incy / 2; -#define SDL_SCALE_NEAREST__START \ - int i; \ - Uint32 posy, incy; \ - Uint32 posx, incx; \ - int dst_gap; \ - int srcy, n; \ - const Uint32 *src_h0; \ - incy = (src_h << 16) / dst_h; \ - incx = (src_w << 16) / dst_w; \ - dst_gap = dst_pitch - bpp * dst_w; \ - posy = incy / 2; \ - -#define SDL_SCALE_NEAREST__HEIGHT \ - srcy = (posy >> 16); \ - src_h0 = (const Uint32 *)((const Uint8 *)src_ptr + srcy * src_pitch); \ - posy += incy; \ - posx = incx / 2; \ +#define SDL_SCALE_NEAREST__HEIGHT \ + srcy = (posy >> 16); \ + src_h0 = (const Uint32 *)((const Uint8 *)src_ptr + srcy * src_pitch); \ + posy += incy; \ + posx = incx / 2; \ n = dst_w; - -static int -scale_mat_nearest_1(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, - Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +static int scale_mat_nearest_1(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, + Uint32 *dst, int dst_w, int dst_h, int dst_pitch) { Uint32 bpp = 1; SDL_SCALE_NEAREST__START @@ -880,17 +857,16 @@ scale_mat_nearest_1(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, int srcx = bpp * (posx >> 16); posx += incx; src = (const Uint8 *)src_h0 + srcx; - *(Uint8*)dst = *src; - dst = (Uint32 *)((Uint8*)dst + bpp); + *(Uint8 *)dst = *src; + dst = (Uint32 *)((Uint8 *)dst + bpp); } dst = (Uint32 *)((Uint8 *)dst + dst_gap); } return 0; } -static int -scale_mat_nearest_2(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, - Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +static int scale_mat_nearest_2(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, + Uint32 *dst, int dst_w, int dst_h, int dst_pitch) { Uint32 bpp = 2; SDL_SCALE_NEAREST__START @@ -901,17 +877,16 @@ scale_mat_nearest_2(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, int srcx = bpp * (posx >> 16); posx += incx; src = (const Uint16 *)((const Uint8 *)src_h0 + srcx); - *(Uint16*)dst = *src; - dst = (Uint32 *)((Uint8*)dst + bpp); + *(Uint16 *)dst = *src; + dst = (Uint32 *)((Uint8 *)dst + bpp); } dst = (Uint32 *)((Uint8 *)dst + dst_gap); } return 0; } -static int -scale_mat_nearest_3(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, - Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +static int scale_mat_nearest_3(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, + Uint32 *dst, int dst_w, int dst_h, int dst_pitch) { Uint32 bpp = 3; SDL_SCALE_NEAREST__START @@ -922,19 +897,18 @@ scale_mat_nearest_3(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, int srcx = bpp * (posx >> 16); posx += incx; src = (const Uint8 *)src_h0 + srcx; - ((Uint8*)dst)[0] = src[0]; - ((Uint8*)dst)[1] = src[1]; - ((Uint8*)dst)[2] = src[2]; - dst = (Uint32 *)((Uint8*)dst + bpp); + ((Uint8 *)dst)[0] = src[0]; + ((Uint8 *)dst)[1] = src[1]; + ((Uint8 *)dst)[2] = src[2]; + dst = (Uint32 *)((Uint8 *)dst + bpp); } dst = (Uint32 *)((Uint8 *)dst + dst_gap); } return 0; } -static int -scale_mat_nearest_4(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, - Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +static int scale_mat_nearest_4(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, + Uint32 *dst, int dst_w, int dst_h, int dst_pitch) { Uint32 bpp = 4; SDL_SCALE_NEAREST__START @@ -946,16 +920,15 @@ scale_mat_nearest_4(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, posx += incx; src = (const Uint32 *)((const Uint8 *)src_h0 + srcx); *dst = *src; - dst = (Uint32 *)((Uint8*)dst + bpp); + dst = (Uint32 *)((Uint8 *)dst + bpp); } dst = (Uint32 *)((Uint8 *)dst + dst_gap); } return 0; } -int -SDL_LowerSoftStretchNearest(SDL_Surface *s, const SDL_Rect *srcrect, - SDL_Surface *d, const SDL_Rect *dstrect) +int SDL_LowerSoftStretchNearest(SDL_Surface *s, const SDL_Rect *srcrect, + SDL_Surface *d, const SDL_Rect *dstrect) { int src_w = srcrect->w; int src_h = srcrect->h; @@ -963,11 +936,11 @@ SDL_LowerSoftStretchNearest(SDL_Surface *s, const SDL_Rect *srcrect, int dst_h = dstrect->h; int src_pitch = s->pitch; int dst_pitch = d->pitch; - + const int bpp = d->format->BytesPerPixel; - Uint32 *src = (Uint32 *) ((Uint8 *)s->pixels + srcrect->x * bpp + srcrect->y * src_pitch); - Uint32 *dst = (Uint32 *) ((Uint8 *)d->pixels + dstrect->x * bpp + dstrect->y * dst_pitch); + Uint32 *src = (Uint32 *)((Uint8 *)s->pixels + srcrect->x * bpp + srcrect->y * src_pitch); + Uint32 *dst = (Uint32 *)((Uint8 *)d->pixels + dstrect->x * bpp + dstrect->y * dst_pitch); if (bpp == 4) { return scale_mat_nearest_4(src, src_w, src_h, src_pitch, dst, dst_w, dst_h, dst_pitch); diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 129debeae..99bd37b67 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -28,10 +28,9 @@ #include "SDL_yuv_c.h" #include "../render/SDL_sysrender.h" - /* Check to make sure we can safely check multiplication of surface w and pitch and it won't overflow size_t */ SDL_COMPILE_TIME_ASSERT(surface_size_assumptions, - sizeof(int) == sizeof(Sint32) && sizeof(size_t) >= sizeof(Sint32)); + sizeof(int) == sizeof(Sint32) && sizeof(size_t) >= sizeof(Sint32)); SDL_COMPILE_TIME_ASSERT(can_indicate_overflow, SDL_SIZE_MAX > SDL_MAX_SINT32); @@ -102,7 +101,7 @@ SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, } /* Allocate the surface */ - surface = (SDL_Surface *) SDL_calloc(1, sizeof(*surface)); + surface = (SDL_Surface *)SDL_calloc(1, sizeof(*surface)); if (surface == NULL) { SDL_OutOfMemory(); return NULL; @@ -230,7 +229,7 @@ SDL_CreateRGBSurfaceFrom(void *pixels, minimalPitch = SDL_CalculatePitch(format, width, SDL_TRUE); - if (pitch < 0 || (pitch > 0 && ((size_t) pitch) < minimalPitch)) { + if (pitch < 0 || (pitch > 0 && ((size_t)pitch) < minimalPitch)) { SDL_InvalidParamError("pitch"); return NULL; } @@ -272,7 +271,7 @@ SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, minimalPitch = SDL_CalculatePitch(format, width, SDL_TRUE); - if (pitch < 0 || (pitch > 0 && ((size_t) pitch) < minimalPitch)) { + if (pitch < 0 || (pitch > 0 && ((size_t)pitch) < minimalPitch)) { SDL_InvalidParamError("pitch"); return NULL; } @@ -289,8 +288,7 @@ SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, return surface; } -int -SDL_SetSurfacePalette(SDL_Surface * surface, SDL_Palette * palette) +int SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette) { if (surface == NULL) { return SDL_InvalidParamError("SDL_SetSurfacePalette(): surface"); @@ -303,8 +301,7 @@ SDL_SetSurfacePalette(SDL_Surface * surface, SDL_Palette * palette) return 0; } -int -SDL_SetSurfaceRLE(SDL_Surface * surface, int flag) +int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag) { int flags; @@ -325,7 +322,7 @@ SDL_SetSurfaceRLE(SDL_Surface * surface, int flag) } SDL_bool -SDL_HasSurfaceRLE(SDL_Surface * surface) +SDL_HasSurfaceRLE(SDL_Surface *surface) { if (surface == NULL) { return SDL_FALSE; @@ -338,8 +335,7 @@ SDL_HasSurfaceRLE(SDL_Surface * surface) return SDL_TRUE; } -int -SDL_SetColorKey(SDL_Surface * surface, int flag, Uint32 key) +int SDL_SetColorKey(SDL_Surface *surface, int flag, Uint32 key) { int flags; @@ -347,7 +343,7 @@ SDL_SetColorKey(SDL_Surface * surface, int flag, Uint32 key) return SDL_InvalidParamError("surface"); } - if (surface->format->palette && key >= ((Uint32) surface->format->palette->ncolors)) { + if (surface->format->palette && key >= ((Uint32)surface->format->palette->ncolors)) { return SDL_InvalidParamError("key"); } @@ -370,7 +366,7 @@ SDL_SetColorKey(SDL_Surface * surface, int flag, Uint32 key) } SDL_bool -SDL_HasColorKey(SDL_Surface * surface) +SDL_HasColorKey(SDL_Surface *surface) { if (surface == NULL) { return SDL_FALSE; @@ -383,8 +379,7 @@ SDL_HasColorKey(SDL_Surface * surface) return SDL_TRUE; } -int -SDL_GetColorKey(SDL_Surface * surface, Uint32 * key) +int SDL_GetColorKey(SDL_Surface *surface, Uint32 *key) { if (surface == NULL) { return SDL_InvalidParamError("surface"); @@ -400,10 +395,9 @@ SDL_GetColorKey(SDL_Surface * surface, Uint32 * key) return 0; } -/* This is a fairly slow function to switch from colorkey to alpha +/* This is a fairly slow function to switch from colorkey to alpha NB: it doesn't handle bpp 1 or 3, because they have no alpha channel */ -static void -SDL_ConvertColorkeyToAlpha(SDL_Surface * surface, SDL_bool ignore_alpha) +static void SDL_ConvertColorkeyToAlpha(SDL_Surface *surface, SDL_bool ignore_alpha) { int x, y, bpp; @@ -422,13 +416,13 @@ SDL_ConvertColorkeyToAlpha(SDL_Surface * surface, SDL_bool ignore_alpha) if (bpp == 2) { Uint16 *row, *spot; - Uint16 ckey = (Uint16) surface->map->info.colorkey; - Uint16 mask = (Uint16) (~surface->format->Amask); + Uint16 ckey = (Uint16)surface->map->info.colorkey; + Uint16 mask = (Uint16)(~surface->format->Amask); /* Ignore, or not, alpha in colorkey comparison */ if (ignore_alpha) { ckey &= mask; - row = (Uint16 *) surface->pixels; + row = (Uint16 *)surface->pixels; for (y = surface->h; y--;) { spot = row; for (x = surface->w; x--;) { @@ -440,7 +434,7 @@ SDL_ConvertColorkeyToAlpha(SDL_Surface * surface, SDL_bool ignore_alpha) row += surface->pitch / 2; } } else { - row = (Uint16 *) surface->pixels; + row = (Uint16 *)surface->pixels; for (y = surface->h; y--;) { spot = row; for (x = surface->w; x--;) { @@ -460,7 +454,7 @@ SDL_ConvertColorkeyToAlpha(SDL_Surface * surface, SDL_bool ignore_alpha) /* Ignore, or not, alpha in colorkey comparison */ if (ignore_alpha) { ckey &= mask; - row = (Uint32 *) surface->pixels; + row = (Uint32 *)surface->pixels; for (y = surface->h; y--;) { spot = row; for (x = surface->w; x--;) { @@ -472,7 +466,7 @@ SDL_ConvertColorkeyToAlpha(SDL_Surface * surface, SDL_bool ignore_alpha) row += surface->pitch / 4; } } else { - row = (Uint32 *) surface->pixels; + row = (Uint32 *)surface->pixels; for (y = surface->h; y--;) { spot = row; for (x = surface->w; x--;) { @@ -492,8 +486,7 @@ SDL_ConvertColorkeyToAlpha(SDL_Surface * surface, SDL_bool ignore_alpha) SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND); } -int -SDL_SetSurfaceColorMod(SDL_Surface * surface, Uint8 r, Uint8 g, Uint8 b) +int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b) { int flags; @@ -517,9 +510,7 @@ SDL_SetSurfaceColorMod(SDL_Surface * surface, Uint8 r, Uint8 g, Uint8 b) return 0; } - -int -SDL_GetSurfaceColorMod(SDL_Surface * surface, Uint8 * r, Uint8 * g, Uint8 * b) +int SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b) { if (surface == NULL) { return -1; @@ -537,8 +528,7 @@ SDL_GetSurfaceColorMod(SDL_Surface * surface, Uint8 * r, Uint8 * g, Uint8 * b) return 0; } -int -SDL_SetSurfaceAlphaMod(SDL_Surface * surface, Uint8 alpha) +int SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha) { int flags; @@ -560,8 +550,7 @@ SDL_SetSurfaceAlphaMod(SDL_Surface * surface, Uint8 alpha) return 0; } -int -SDL_GetSurfaceAlphaMod(SDL_Surface * surface, Uint8 * alpha) +int SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha) { if (surface == NULL) { return -1; @@ -573,8 +562,7 @@ SDL_GetSurfaceAlphaMod(SDL_Surface * surface, Uint8 * alpha) return 0; } -int -SDL_SetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode blendMode) +int SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode) { int flags, status; @@ -613,8 +601,7 @@ SDL_SetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode blendMode) return status; } -int -SDL_GetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode *blendMode) +int SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode) { if (surface == NULL) { return -1; @@ -624,8 +611,7 @@ SDL_GetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode *blendMode) return 0; } - switch (surface->map-> - info.flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL)) { + switch (surface->map->info.flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL)) { case SDL_COPY_BLEND: *blendMode = SDL_BLENDMODE_BLEND; break; @@ -646,7 +632,7 @@ SDL_GetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode *blendMode) } SDL_bool -SDL_SetClipRect(SDL_Surface * surface, const SDL_Rect * rect) +SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect) { SDL_Rect full_rect; @@ -669,8 +655,7 @@ SDL_SetClipRect(SDL_Surface * surface, const SDL_Rect * rect) return SDL_IntersectRect(rect, &full_rect, &surface->clip_rect); } -void -SDL_GetClipRect(SDL_Surface * surface, SDL_Rect * rect) +void SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect) { if (surface && rect) { *rect = surface->clip_rect; @@ -688,9 +673,8 @@ SDL_GetClipRect(SDL_Surface * surface, SDL_Rect * rect) * you know exactly what you are doing, you can optimize your code * by calling the one(s) you need. */ -int -SDL_LowerBlit(SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +int SDL_LowerBlit(SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect) { /* Check to make sure the blit mapping is valid */ if ((src->map->dst != dst) || @@ -702,18 +686,16 @@ SDL_LowerBlit(SDL_Surface * src, SDL_Rect * srcrect, return -1; } /* just here for debugging */ -/* printf */ -/* ("src = 0x%08X src->flags = %08X src->map->info.flags = %08x\ndst = 0x%08X dst->flags = %08X dst->map->info.flags = %08X\nsrc->map->blit = 0x%08x\n", */ -/* src, dst->flags, src->map->info.flags, dst, dst->flags, */ -/* dst->map->info.flags, src->map->blit); */ + /* printf */ + /* ("src = 0x%08X src->flags = %08X src->map->info.flags = %08x\ndst = 0x%08X dst->flags = %08X dst->map->info.flags = %08X\nsrc->map->blit = 0x%08x\n", */ + /* src, dst->flags, src->map->info.flags, dst, dst->flags, */ + /* dst->map->info.flags, src->map->blit); */ } return src->map->blit(src, srcrect, dst, dstrect); } - -int -SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +int SDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect) { SDL_Rect fulldst; int srcx, srcy, w, h; @@ -814,17 +796,14 @@ SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect, return 0; } -int -SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +int SDL_UpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect) { return SDL_PrivateUpperBlitScaled(src, srcrect, dst, dstrect, SDL_ScaleModeNearest); } - -int -SDL_PrivateUpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode) +int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect, SDL_ScaleMode scaleMode) { double src_x0, src_y0, src_x1, src_y1; double dst_x0, dst_y0, dst_x1, dst_y1; @@ -985,22 +964,18 @@ SDL_PrivateUpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, * This is a semi-private blit function and it performs low-level surface * scaled blitting only. */ -int -SDL_LowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +int SDL_LowerBlitScaled(SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect) { return SDL_PrivateLowerBlitScaled(src, srcrect, dst, dstrect, SDL_ScaleModeNearest); } -int -SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode) +int SDL_PrivateLowerBlitScaled(SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect, SDL_ScaleMode scaleMode) { - static const Uint32 complex_copy_flags = ( - SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | - SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | - SDL_COPY_COLORKEY - ); + static const Uint32 complex_copy_flags = (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | + SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | + SDL_COPY_COLORKEY); if (srcrect->w > SDL_MAX_UINT16 || srcrect->h > SDL_MAX_UINT16 || dstrect->w > SDL_MAX_UINT16 || dstrect->h > SDL_MAX_UINT16) { @@ -1013,19 +988,19 @@ SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, } if (scaleMode == SDL_ScaleModeNearest) { - if ( !(src->map->info.flags & complex_copy_flags) && - src->format->format == dst->format->format && - !SDL_ISPIXELFORMAT_INDEXED(src->format->format) ) { + if (!(src->map->info.flags & complex_copy_flags) && + src->format->format == dst->format->format && + !SDL_ISPIXELFORMAT_INDEXED(src->format->format)) { return SDL_SoftStretch(src, srcrect, dst, dstrect); } else { return SDL_LowerBlit(src, srcrect, dst, dstrect); } } else { - if ( !(src->map->info.flags & complex_copy_flags) && - src->format->format == dst->format->format && - !SDL_ISPIXELFORMAT_INDEXED(src->format->format) && - src->format->BytesPerPixel == 4 && - src->format->format != SDL_PIXELFORMAT_ARGB2101010) { + if (!(src->map->info.flags & complex_copy_flags) && + src->format->format == dst->format->format && + !SDL_ISPIXELFORMAT_INDEXED(src->format->format) && + src->format->BytesPerPixel == 4 && + src->format->format != SDL_PIXELFORMAT_ARGB2101010) { /* fast path */ return SDL_SoftStretchLinear(src, srcrect, dst, dstrect); } else { @@ -1066,7 +1041,6 @@ SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, tmp1 = SDL_CreateRGBSurfaceWithFormat(flags, src->w, src->h, 0, fmt); SDL_LowerBlit(src, srcrect, tmp1, &tmprect); - srcrect2.x = 0; srcrect2.y = 0; SDL_SetSurfaceColorMod(tmp1, r, g, b); @@ -1105,15 +1079,14 @@ SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, /* * Lock a surface to directly access the pixels */ -int -SDL_LockSurface(SDL_Surface * surface) +int SDL_LockSurface(SDL_Surface *surface) { if (!surface->locked) { #if SDL_HAVE_RLE /* Perform the lock */ if (surface->flags & SDL_RLEACCEL) { SDL_UnRLESurface(surface, 1); - surface->flags |= SDL_RLEACCEL; /* save accel'd state */ + surface->flags |= SDL_RLEACCEL; /* save accel'd state */ } #endif } @@ -1128,8 +1101,7 @@ SDL_LockSurface(SDL_Surface * surface) /* * Unlock a previously locked surface */ -void -SDL_UnlockSurface(SDL_Surface * surface) +void SDL_UnlockSurface(SDL_Surface *surface) { /* Only perform an unlock if we are locked */ if (!surface->locked || (--surface->locked > 0)) { @@ -1139,7 +1111,7 @@ SDL_UnlockSurface(SDL_Surface * surface) #if SDL_HAVE_RLE /* Update RLE encoded surface with new data */ if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) { - surface->flags &= ~SDL_RLEACCEL; /* stop lying */ + surface->flags &= ~SDL_RLEACCEL; /* stop lying */ SDL_RLESurface(surface); } #endif @@ -1149,7 +1121,7 @@ SDL_UnlockSurface(SDL_Surface * surface) * Creates a new surface identical to the existing surface */ SDL_Surface * -SDL_DuplicateSurface(SDL_Surface * surface) +SDL_DuplicateSurface(SDL_Surface *surface) { return SDL_ConvertSurface(surface, surface->format, surface->flags); } @@ -1293,8 +1265,7 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format, convert->map->info.a = copy_color.a; convert->map->info.flags = (copy_flags & - ~(SDL_COPY_COLORKEY | SDL_COPY_BLEND - | SDL_COPY_RLE_DESIRED | SDL_COPY_RLE_COLORKEY | + ~(SDL_COPY_COLORKEY | SDL_COPY_BLEND | SDL_COPY_RLE_DESIRED | SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY)); surface->map->info.r = copy_color.r; surface->map->info.g = copy_color.g; @@ -1317,7 +1288,7 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format, if (format->palette && surface->format->palette->ncolors <= format->palette->ncolors && (SDL_memcmp(surface->format->palette->colors, format->palette->colors, - surface->format->palette->ncolors * sizeof(SDL_Color)) == 0)) { + surface->format->palette->ncolors * sizeof(SDL_Color)) == 0)) { /* The palette is identical, just set the same colorkey */ SDL_SetColorKey(convert, 1, surface->map->info.colorkey); } else if (!format->palette) { @@ -1408,10 +1379,9 @@ SDL_ConvertSurfaceFormat(SDL_Surface * surface, Uint32 pixel_format, /* * Create a surface on the stack for quick blit operations */ -static SDL_INLINE SDL_bool -SDL_CreateSurfaceOnStack(int width, int height, Uint32 pixel_format, - void * pixels, int pitch, SDL_Surface * surface, - SDL_PixelFormat * format, SDL_BlitMap * blitmap) +static SDL_INLINE SDL_bool SDL_CreateSurfaceOnStack(int width, int height, Uint32 pixel_format, + void *pixels, int pitch, SDL_Surface *surface, + SDL_PixelFormat *format, SDL_BlitMap *blitmap) { if (SDL_ISPIXELFORMAT_INDEXED(pixel_format)) { SDL_SetError("Indexed pixel formats not supported"); @@ -1448,14 +1418,14 @@ SDL_CreateSurfaceOnStack(int width, int height, Uint32 pixel_format, * Copy a block of pixels of one format to another format */ int SDL_ConvertPixels(int width, int height, - Uint32 src_format, const void * src, int src_pitch, - Uint32 dst_format, void * dst, int dst_pitch) + Uint32 src_format, const void *src, int src_pitch, + Uint32 dst_format, void *dst, int dst_pitch) { SDL_Surface src_surface, dst_surface; SDL_PixelFormat src_fmt, dst_fmt; SDL_BlitMap src_blitmap, dst_blitmap; SDL_Rect rect; - void *nonconst_src = (void *) src; + void *nonconst_src = (void *)src; int ret; if (src == NULL) { @@ -1492,8 +1462,8 @@ int SDL_ConvertPixels(int width, int height, width *= bpp; for (i = height; i--;) { SDL_memcpy(dst, src, width); - src = (const Uint8*)src + src_pitch; - dst = (Uint8*)dst + dst_pitch; + src = (const Uint8 *)src + src_pitch; + dst = (Uint8 *)dst + dst_pitch; } return 0; } @@ -1531,8 +1501,8 @@ int SDL_ConvertPixels(int width, int height, * https://developer.arm.com/documentation/101964/0201/Pre-multiplied-alpha-channel-data */ int SDL_PremultiplyAlpha(int width, int height, - Uint32 src_format, const void * src, int src_pitch, - Uint32 dst_format, void * dst, int dst_pitch) + Uint32 src_format, const void *src, int src_pitch, + Uint32 dst_format, void *dst, int dst_pitch) { int c; Uint32 srcpixel; @@ -1586,8 +1556,7 @@ int SDL_PremultiplyAlpha(int width, int height, /* * Free a surface created by the above function. */ -void -SDL_FreeSurface(SDL_Surface * surface) +void SDL_FreeSurface(SDL_Surface *surface) { if (surface == NULL) { return; diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 4bc1f111f..abc036084 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -44,7 +44,7 @@ struct SDL_WindowShaper SDL_Window *window; /* The user's specified coordinates for the window, for once we give it a shape. */ - Uint32 userx,usery; + Uint32 userx, usery; /* The parameters for shape calculation. */ SDL_WindowShapeMode mode; @@ -58,8 +58,8 @@ struct SDL_WindowShaper /* Define the SDL shape driver structure */ struct SDL_ShapeDriver { - SDL_WindowShaper *(*CreateShaper)(SDL_Window * window); - int (*SetWindowShape)(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode); + SDL_WindowShaper *(*CreateShaper)(SDL_Window *window); + int (*SetWindowShape)(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode); int (*ResizeWindowShape)(SDL_Window *window); }; @@ -101,7 +101,7 @@ struct SDL_Window SDL_bool is_hiding; SDL_bool is_destroying; - SDL_bool is_dropping; /* drag/drop in progress, expecting SDL_SendDropComplete(). */ + SDL_bool is_dropping; /* drag/drop in progress, expecting SDL_SendDropComplete(). */ SDL_Rect mouse_rect; @@ -117,9 +117,9 @@ struct SDL_Window SDL_Window *prev; SDL_Window *next; }; -#define FULLSCREEN_VISIBLE(W) \ +#define FULLSCREEN_VISIBLE(W) \ (((W)->flags & SDL_WINDOW_FULLSCREEN) && \ - ((W)->flags & SDL_WINDOW_SHOWN) && \ + ((W)->flags & SDL_WINDOW_SHOWN) && \ !((W)->flags & SDL_WINDOW_MINIMIZED)) /* @@ -147,11 +147,12 @@ struct SDL_VideoDisplay struct SDL_SysWMinfo; /* Define the SDL video driver structure */ -#define _THIS SDL_VideoDevice *_this +#define _THIS SDL_VideoDevice *_this /* Video device flags */ -typedef enum { - VIDEO_DEVICE_QUIRK_DISABLE_DISPLAY_MODE_SWITCHING = 0x01, +typedef enum +{ + VIDEO_DEVICE_QUIRK_DISABLE_DISPLAY_MODE_SWITCHING = 0x01, VIDEO_DEVICE_QUIRK_DISABLE_UNSET_FULLSCREEN_ON_MINIMIZE = 0x02, } DeviceQuirkFlags; @@ -168,18 +169,18 @@ struct SDL_VideoDevice * Initialize the native video subsystem, filling in the list of * displays for this driver, returning 0 or -1 if there's an error. */ - int (*VideoInit) (_THIS); + int (*VideoInit)(_THIS); /* * Reverse the effects VideoInit() -- called if VideoInit() fails or * if the application is shutting down the video subsystem. */ - void (*VideoQuit) (_THIS); + void (*VideoQuit)(_THIS); /* * Reinitialize the touch devices -- called if an unknown touch ID occurs. */ - void (*ResetTouch) (_THIS); + void (*ResetTouch)(_THIS); /* * * */ /* @@ -189,22 +190,22 @@ struct SDL_VideoDevice /* * Get the bounds of a display */ - int (*GetDisplayBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect); + int (*GetDisplayBounds)(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect); /* * Get the usable bounds of a display (bounds minus menubar or whatever) */ - int (*GetDisplayUsableBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect); + int (*GetDisplayUsableBounds)(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect); /* * Get the dots/pixels-per-inch of a display */ - int (*GetDisplayDPI) (_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi); + int (*GetDisplayDPI)(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi); /* * Get a list of the available display modes for a display. */ - void (*GetDisplayModes) (_THIS, SDL_VideoDisplay * display); + void (*GetDisplayModes)(_THIS, SDL_VideoDisplay *display); /* * Setting the display mode is independent of creating windows, so @@ -212,21 +213,21 @@ struct SDL_VideoDevice * their data updated accordingly, including the display surfaces * associated with them. */ - int (*SetDisplayMode) (_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); + int (*SetDisplayMode)(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode); /* * * */ /* * Window functions */ - int (*CreateSDLWindow) (_THIS, SDL_Window * window); - int (*CreateSDLWindowFrom) (_THIS, SDL_Window * window, const void *data); - void (*SetWindowTitle) (_THIS, SDL_Window * window); - void (*SetWindowIcon) (_THIS, SDL_Window * window, SDL_Surface * icon); - void (*SetWindowPosition) (_THIS, SDL_Window * window); - void (*SetWindowSize) (_THIS, SDL_Window * window); - void (*SetWindowMinimumSize) (_THIS, SDL_Window * window); - void (*SetWindowMaximumSize) (_THIS, SDL_Window * window); - int (*GetWindowBordersSize) (_THIS, SDL_Window * window, int *top, int *left, int *bottom, int *right); + int (*CreateSDLWindow)(_THIS, SDL_Window *window); + int (*CreateSDLWindowFrom)(_THIS, SDL_Window *window, const void *data); + void (*SetWindowTitle)(_THIS, SDL_Window *window); + void (*SetWindowIcon)(_THIS, SDL_Window *window, SDL_Surface *icon); + void (*SetWindowPosition)(_THIS, SDL_Window *window); + void (*SetWindowSize)(_THIS, SDL_Window *window); + void (*SetWindowMinimumSize)(_THIS, SDL_Window *window); + void (*SetWindowMaximumSize)(_THIS, SDL_Window *window); + int (*GetWindowBordersSize)(_THIS, SDL_Window *window, int *top, int *left, int *bottom, int *right); void (*GetWindowSizeInPixels)(_THIS, SDL_Window *window, int *w, int *h); int (*SetWindowOpacity) (_THIS, SDL_Window * window, float opacity); int (*SetWindowModalFor) (_THIS, SDL_Window * modal_window, SDL_Window * parent_window); @@ -285,61 +286,61 @@ struct SDL_VideoDevice /* * Vulkan support */ - int (*Vulkan_LoadLibrary) (_THIS, const char *path); - void (*Vulkan_UnloadLibrary) (_THIS); - SDL_bool (*Vulkan_GetInstanceExtensions) (_THIS, SDL_Window *window, unsigned *count, const char **names); - SDL_bool (*Vulkan_CreateSurface) (_THIS, SDL_Window *window, VkInstance instance, VkSurfaceKHR *surface); - void (*Vulkan_GetDrawableSize) (_THIS, SDL_Window * window, int *w, int *h); + int (*Vulkan_LoadLibrary)(_THIS, const char *path); + void (*Vulkan_UnloadLibrary)(_THIS); + SDL_bool (*Vulkan_GetInstanceExtensions)(_THIS, SDL_Window *window, unsigned *count, const char **names); + SDL_bool (*Vulkan_CreateSurface)(_THIS, SDL_Window *window, VkInstance instance, VkSurfaceKHR *surface); + void (*Vulkan_GetDrawableSize)(_THIS, SDL_Window *window, int *w, int *h); /* * * */ /* * Metal support */ - SDL_MetalView (*Metal_CreateView) (_THIS, SDL_Window * window); - void (*Metal_DestroyView) (_THIS, SDL_MetalView view); - void *(*Metal_GetLayer) (_THIS, SDL_MetalView view); - void (*Metal_GetDrawableSize) (_THIS, SDL_Window * window, int *w, int *h); + SDL_MetalView (*Metal_CreateView)(_THIS, SDL_Window *window); + void (*Metal_DestroyView)(_THIS, SDL_MetalView view); + void *(*Metal_GetLayer)(_THIS, SDL_MetalView view); + void (*Metal_GetDrawableSize)(_THIS, SDL_Window *window, int *w, int *h); /* * * */ /* * Event manager functions */ - int (*WaitEventTimeout) (_THIS, int timeout); - void (*SendWakeupEvent) (_THIS, SDL_Window *window); - void (*PumpEvents) (_THIS); + int (*WaitEventTimeout)(_THIS, int timeout); + void (*SendWakeupEvent)(_THIS, SDL_Window *window); + void (*PumpEvents)(_THIS); /* Suspend the screensaver */ - void (*SuspendScreenSaver) (_THIS); + void (*SuspendScreenSaver)(_THIS); /* Text input */ - void (*StartTextInput) (_THIS); - void (*StopTextInput) (_THIS); - void (*SetTextInputRect) (_THIS, const SDL_Rect *rect); - void (*ClearComposition) (_THIS); - SDL_bool (*IsTextInputShown) (_THIS); + void (*StartTextInput)(_THIS); + void (*StopTextInput)(_THIS); + void (*SetTextInputRect)(_THIS, const SDL_Rect *rect); + void (*ClearComposition)(_THIS); + SDL_bool (*IsTextInputShown)(_THIS); /* Screen keyboard */ - SDL_bool (*HasScreenKeyboardSupport) (_THIS); - void (*ShowScreenKeyboard) (_THIS, SDL_Window *window); - void (*HideScreenKeyboard) (_THIS, SDL_Window *window); - SDL_bool (*IsScreenKeyboardShown) (_THIS, SDL_Window *window); + SDL_bool (*HasScreenKeyboardSupport)(_THIS); + void (*ShowScreenKeyboard)(_THIS, SDL_Window *window); + void (*HideScreenKeyboard)(_THIS, SDL_Window *window); + SDL_bool (*IsScreenKeyboardShown)(_THIS, SDL_Window *window); /* Clipboard */ - int (*SetClipboardText) (_THIS, const char *text); - char * (*GetClipboardText) (_THIS); - SDL_bool (*HasClipboardText) (_THIS); - int (*SetPrimarySelectionText) (_THIS, const char *text); - char * (*GetPrimarySelectionText) (_THIS); - SDL_bool (*HasPrimarySelectionText) (_THIS); + int (*SetClipboardText)(_THIS, const char *text); + char *(*GetClipboardText)(_THIS); + SDL_bool (*HasClipboardText)(_THIS); + int (*SetPrimarySelectionText)(_THIS, const char *text); + char *(*GetPrimarySelectionText)(_THIS); + SDL_bool (*HasPrimarySelectionText)(_THIS); /* MessageBox */ - int (*ShowMessageBox) (_THIS, const SDL_MessageBoxData *messageboxdata, int *buttonid); + int (*ShowMessageBox)(_THIS, const SDL_MessageBoxData *messageboxdata, int *buttonid); /* Hit-testing */ - int (*SetWindowHitTest)(SDL_Window * window, SDL_bool enabled); + int (*SetWindowHitTest)(SDL_Window *window, SDL_bool enabled); /* Tell window that app enabled drag'n'drop events */ - void (*AcceptDragAndDrop)(SDL_Window * window, SDL_bool accept); + void (*AcceptDragAndDrop)(SDL_Window *window, SDL_bool accept); /* * * */ /* Data common to all drivers */ @@ -437,14 +438,14 @@ struct SDL_VideoDevice /* * * */ /* The function used to dispose of this structure */ - void (*free) (_THIS); + void (*free)(_THIS); }; typedef struct VideoBootStrap { const char *name; const char *desc; - SDL_VideoDevice *(*create) (void); + SDL_VideoDevice *(*create)(void); } VideoBootStrap; /* Not all of these are available in a given build. Use #ifdefs, etc. */ @@ -480,37 +481,37 @@ extern VideoBootStrap OS2VMAN_bootstrap; /* Use SDL_OnVideoThread() sparingly, to avoid regressions in use cases that currently happen to work */ extern SDL_bool SDL_OnVideoThread(void); extern SDL_VideoDevice *SDL_GetVideoDevice(void); -extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode); -extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display, SDL_bool send_event); +extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode *desktop_mode); +extern int SDL_AddVideoDisplay(const SDL_VideoDisplay *display, SDL_bool send_event); extern void SDL_DelVideoDisplay(int index); -extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode); -extern void SDL_SetCurrentDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode); -extern void SDL_SetDesktopDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode); +extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode); +extern void SDL_SetCurrentDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode); +extern void SDL_SetDesktopDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode); extern void SDL_ResetDisplayModes(int displayIndex); extern int SDL_GetIndexOfDisplay(SDL_VideoDisplay *display); extern SDL_VideoDisplay *SDL_GetDisplay(int displayIndex); extern SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window); -extern void *SDL_GetDisplayDriverData( int displayIndex ); +extern void *SDL_GetDisplayDriverData(int displayIndex); extern SDL_bool SDL_IsVideoContextExternal(void); extern int SDL_GetMessageBoxCount(void); -extern void SDL_GL_DeduceMaxSupportedESProfile(int* major, int* minor); +extern void SDL_GL_DeduceMaxSupportedESProfile(int *major, int *minor); -extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags); +extern int SDL_RecreateWindow(SDL_Window *window, Uint32 flags); extern SDL_bool SDL_HasWindows(void); -extern void SDL_OnWindowShown(SDL_Window * window); -extern void SDL_OnWindowHidden(SDL_Window * window); -extern void SDL_OnWindowMoved(SDL_Window * window); -extern void SDL_OnWindowResized(SDL_Window * window); -extern void SDL_OnWindowMinimized(SDL_Window * window); -extern void SDL_OnWindowRestored(SDL_Window * window); -extern void SDL_OnWindowEnter(SDL_Window * window); -extern void SDL_OnWindowLeave(SDL_Window * window); -extern void SDL_OnWindowFocusGained(SDL_Window * window); -extern void SDL_OnWindowFocusLost(SDL_Window * window); -extern void SDL_UpdateWindowGrab(SDL_Window * window); -extern SDL_Window * SDL_GetFocusWindow(void); +extern void SDL_OnWindowShown(SDL_Window *window); +extern void SDL_OnWindowHidden(SDL_Window *window); +extern void SDL_OnWindowMoved(SDL_Window *window); +extern void SDL_OnWindowResized(SDL_Window *window); +extern void SDL_OnWindowMinimized(SDL_Window *window); +extern void SDL_OnWindowRestored(SDL_Window *window); +extern void SDL_OnWindowEnter(SDL_Window *window); +extern void SDL_OnWindowLeave(SDL_Window *window); +extern void SDL_OnWindowFocusGained(SDL_Window *window); +extern void SDL_OnWindowFocusLost(SDL_Window *window); +extern void SDL_UpdateWindowGrab(SDL_Window *window); +extern SDL_Window *SDL_GetFocusWindow(void); extern SDL_bool SDL_ShouldAllowTopmost(void); @@ -518,9 +519,9 @@ extern float SDL_ComputeDiagonalDPI(int hpix, int vpix, float hinches, float vin extern void SDL_ToggleDragAndDropSupport(void); -extern int SDL_GetPointDisplayIndex(const SDL_Point * point); +extern int SDL_GetPointDisplayIndex(const SDL_Point *point); -extern int SDL_GL_SwapWindowWithResult(SDL_Window * window); +extern int SDL_GL_SwapWindowWithResult(SDL_Window *window); #endif /* SDL_sysvideo_h_ */ diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 636cff947..658058f33 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -62,7 +62,6 @@ #include #endif - /* Available video drivers */ static VideoBootStrap *bootstrap[] = { #if SDL_VIDEO_DRIVER_COCOA @@ -147,25 +146,25 @@ static VideoBootStrap *bootstrap[] = { NULL }; -#define CHECK_WINDOW_MAGIC(window, retval) \ - if (!_this) { \ - SDL_UninitializedVideo(); \ - return retval; \ - } \ +#define CHECK_WINDOW_MAGIC(window, retval) \ + if (!_this) { \ + SDL_UninitializedVideo(); \ + return retval; \ + } \ if (!window || window->magic != &_this->window_magic) { \ - SDL_SetError("Invalid window"); \ - return retval; \ + SDL_SetError("Invalid window"); \ + return retval; \ } -#define CHECK_DISPLAY_INDEX(displayIndex, retval) \ - if (!_this) { \ - SDL_UninitializedVideo(); \ - return retval; \ - } \ +#define CHECK_DISPLAY_INDEX(displayIndex, retval) \ + if (!_this) { \ + SDL_UninitializedVideo(); \ + return retval; \ + } \ if (displayIndex < 0 || displayIndex >= _this->num_displays) { \ - SDL_SetError("displayIndex must be in the range 0 - %d", \ - _this->num_displays - 1); \ - return retval; \ + SDL_SetError("displayIndex must be in the range 0 - %d", \ + _this->num_displays - 1); \ + return retval; \ } #define FULLSCREEN_MASK (SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN) @@ -177,23 +176,22 @@ extern SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool sta #endif /* Convenience functions for reading driver flags */ -static SDL_bool -DisableDisplayModeSwitching(_THIS) +static SDL_bool DisableDisplayModeSwitching(_THIS) { return !!(_this->quirk_flags & VIDEO_DEVICE_QUIRK_DISABLE_DISPLAY_MODE_SWITCHING); } -static SDL_bool -DisableUnsetFullscreenOnMinimize(_THIS) +static SDL_bool DisableUnsetFullscreenOnMinimize(_THIS) { return !!(_this->quirk_flags & VIDEO_DEVICE_QUIRK_DISABLE_UNSET_FULLSCREEN_ON_MINIMIZE); } /* Support for framebuffer emulation using an accelerated renderer */ -#define SDL_WINDOWTEXTUREDATA "_SDL_WindowTextureData" +#define SDL_WINDOWTEXTUREDATA "_SDL_WindowTextureData" -typedef struct { +typedef struct +{ SDL_Renderer *renderer; SDL_Texture *texture; void *pixels; @@ -201,9 +199,7 @@ typedef struct { int bytes_per_pixel; } SDL_WindowTextureData; - -static Uint32 -SDL_DefaultGraphicsBackends(SDL_VideoDevice *_this) +static Uint32 SDL_DefaultGraphicsBackends(SDL_VideoDevice *_this) { #if (SDL_VIDEO_OPENGL && __MACOSX__) || (__IPHONEOS__ && !TARGET_OS_MACCATALYST) || __ANDROID__ || __NACL__ if (_this->GL_CreateContext != NULL) { @@ -218,8 +214,7 @@ SDL_DefaultGraphicsBackends(SDL_VideoDevice *_this) return 0; } -static int -SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch) +static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch) { SDL_RendererInfo info; SDL_WindowTextureData *data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA); @@ -228,12 +223,10 @@ SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window * window, Uint32 * fo if (data == NULL) { SDL_Renderer *renderer = NULL; const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); - const SDL_bool specific_accelerated_renderer = ( - hint && *hint != '0' && *hint != '1' && - SDL_strcasecmp(hint, "true") != 0 && - SDL_strcasecmp(hint, "false") != 0 && - SDL_strcasecmp(hint, "software") != 0 - ); + const SDL_bool specific_accelerated_renderer = (hint && *hint != '0' && *hint != '1' && + SDL_strcasecmp(hint, "true") != 0 && + SDL_strcasecmp(hint, "false") != 0 && + SDL_strcasecmp(hint, "software") != 0); /* Check to see if there's a specific driver requested */ if (specific_accelerated_renderer) { @@ -245,7 +238,9 @@ SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window * window, Uint32 * fo } } if (renderer == NULL || (SDL_GetRendererInfo(renderer, &info) == -1)) { - if (renderer) { SDL_DestroyRenderer(renderer); } + if (renderer) { + SDL_DestroyRenderer(renderer); + } return SDL_SetError("Requested renderer for " SDL_HINT_FRAMEBUFFER_ACCELERATION " is not available"); } /* if it was specifically requested, even if SDL_RENDERER_ACCELERATED isn't set, we'll accept this renderer. */ @@ -255,9 +250,9 @@ SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window * window, Uint32 * fo if (SDL_strcmp(info.name, "software") != 0) { renderer = SDL_CreateRenderer(window, i, 0); if (renderer && (SDL_GetRendererInfo(renderer, &info) == 0) && (info.flags & SDL_RENDERER_ACCELERATED)) { - break; /* this will work. */ + break; /* this will work. */ } - if (renderer) { /* wasn't accelerated, etc, skip it. */ + if (renderer) { /* wasn't accelerated, etc, skip it. */ SDL_DestroyRenderer(renderer); renderer = NULL; } @@ -268,7 +263,7 @@ SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window * window, Uint32 * fo } } - SDL_assert(renderer != NULL); /* should have explicitly checked this above. */ + SDL_assert(renderer != NULL); /* should have explicitly checked this above. */ /* Create the data after we successfully create the renderer (bug #1116) */ data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data)); @@ -296,7 +291,7 @@ SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window * window, Uint32 * fo /* Find the first format without an alpha channel */ *format = info.texture_formats[0]; - for (i = 0; i < (int) info.num_texture_formats; ++i) { + for (i = 0; i < (int)info.num_texture_formats; ++i) { if (!SDL_ISPIXELFORMAT_FOURCC(info.texture_formats[i]) && !SDL_ISPIXELFORMAT_ALPHA(info.texture_formats[i])) { *format = info.texture_formats[i]; @@ -337,8 +332,7 @@ SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window * window, Uint32 * fo static SDL_VideoDevice *_this = NULL; static SDL_atomic_t SDL_messagebox_count; -static int -SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, const SDL_Rect * rects, int numrects) +static int SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window, const SDL_Rect *rects, int numrects) { SDL_WindowTextureData *data; SDL_Rect rect; @@ -352,8 +346,8 @@ SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, const SDL_ /* Update a single rect that contains subrects for best DMA performance */ if (SDL_GetSpanEnclosingRect(window->w, window->h, numrects, rects, &rect)) { src = (void *)((Uint8 *)data->pixels + - rect.y * data->pitch + - rect.x * data->bytes_per_pixel); + rect.y * data->pitch + + rect.x * data->bytes_per_pixel); if (SDL_UpdateTexture(data->texture, &rect, src, data->pitch) < 0) { return -1; } @@ -367,8 +361,7 @@ SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, const SDL_ return 0; } -static void -SDL_DestroyWindowTexture(SDL_VideoDevice *unused, SDL_Window * window) +static void SDL_DestroyWindowTexture(SDL_VideoDevice *unused, SDL_Window *window) { SDL_WindowTextureData *data; @@ -386,11 +379,10 @@ SDL_DestroyWindowTexture(SDL_VideoDevice *unused, SDL_Window * window) SDL_free(data); } -static int SDLCALL -cmpmodes(const void *A, const void *B) +static int SDLCALL cmpmodes(const void *A, const void *B) { - const SDL_DisplayMode *a = (const SDL_DisplayMode *) A; - const SDL_DisplayMode *b = (const SDL_DisplayMode *) B; + const SDL_DisplayMode *a = (const SDL_DisplayMode *)A; + const SDL_DisplayMode *b = (const SDL_DisplayMode *)B; if (a == b) { return 0; } else if (a->w != b->w) { @@ -407,14 +399,12 @@ cmpmodes(const void *A, const void *B) return 0; } -static int -SDL_UninitializedVideo() +static int SDL_UninitializedVideo() { return SDL_SetError("Video subsystem has not been initialized"); } -int -SDL_GetNumVideoDrivers(void) +int SDL_GetNumVideoDrivers(void) { return SDL_arraysize(bootstrap) - 1; } @@ -431,8 +421,7 @@ SDL_GetVideoDriver(int index) /* * Initialize the video and event subsystems -- determine native pixel format */ -int -SDL_VideoInit(const char *driver_name) +int SDL_VideoInit(const char *driver_name) { SDL_VideoDevice *video; SDL_bool init_events = SDL_FALSE; @@ -476,7 +465,7 @@ SDL_VideoInit(const char *driver_name) if (driver_name != NULL && *driver_name != 0) { const char *driver_attempt = driver_name; while (driver_attempt != NULL && *driver_attempt != 0 && video == NULL) { - const char* driver_attempt_end = SDL_strchr(driver_attempt, ','); + const char *driver_attempt_end = SDL_strchr(driver_attempt, ','); size_t driver_attempt_len = (driver_attempt_end != NULL) ? (driver_attempt_end - driver_attempt) : SDL_strlen(driver_attempt); @@ -506,7 +495,7 @@ SDL_VideoInit(const char *driver_name) SDL_SetError("No available video device"); goto pre_driver_error; } - + /* From this point on, use SDL_VideoQuit to cleanup on error, rather than pre_driver_error. */ _this = video; @@ -514,7 +503,6 @@ SDL_VideoInit(const char *driver_name) _this->next_object_id = 1; _this->thread = SDL_ThreadID(); - /* Set some very sane GL defaults */ _this->gl_config.driver_loaded = 0; _this->gl_config.dll_handle = NULL; @@ -598,8 +586,7 @@ SDL_OnVideoThread() return (_this && SDL_ThreadID() == _this->thread) ? SDL_TRUE : SDL_FALSE; } -int -SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode) +int SDL_AddBasicVideoDisplay(const SDL_DisplayMode *desktop_mode) { SDL_VideoDisplay display; @@ -612,8 +599,7 @@ SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode) return SDL_AddVideoDisplay(&display, SDL_FALSE); } -int -SDL_AddVideoDisplay(const SDL_VideoDisplay * display, SDL_bool send_event) +int SDL_AddVideoDisplay(const SDL_VideoDisplay *display, SDL_bool send_event) { SDL_VideoDisplay *displays; int index = -1; @@ -645,8 +631,7 @@ SDL_AddVideoDisplay(const SDL_VideoDisplay * display, SDL_bool send_event) return index; } -void -SDL_DelVideoDisplay(int index) +void SDL_DelVideoDisplay(int index) { if (index < 0 || index >= _this->num_displays) { return; @@ -655,13 +640,12 @@ SDL_DelVideoDisplay(int index) SDL_SendDisplayEvent(&_this->displays[index], SDL_DISPLAYEVENT_DISCONNECTED, 0); if (index < (_this->num_displays - 1)) { - SDL_memmove(&_this->displays[index], &_this->displays[index+1], (_this->num_displays - index - 1)*sizeof(_this->displays[index])); + SDL_memmove(&_this->displays[index], &_this->displays[index + 1], (_this->num_displays - index - 1) * sizeof(_this->displays[index])); } --_this->num_displays; } -int -SDL_GetNumVideoDisplays(void) +int SDL_GetNumVideoDisplays(void) { if (_this == NULL) { SDL_UninitializedVideo(); @@ -670,8 +654,7 @@ SDL_GetNumVideoDisplays(void) return _this->num_displays; } -int -SDL_GetIndexOfDisplay(SDL_VideoDisplay *display) +int SDL_GetIndexOfDisplay(SDL_VideoDisplay *display) { int displayIndex; @@ -707,8 +690,7 @@ SDL_GetDisplayName(int displayIndex) return _this->displays[displayIndex].name; } -int -SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect) +int SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect) { SDL_VideoDisplay *display; @@ -731,7 +713,7 @@ SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect) rect->x = 0; rect->y = 0; } else { - SDL_GetDisplayBounds(displayIndex-1, rect); + SDL_GetDisplayBounds(displayIndex - 1, rect); rect->x += rect->w; } rect->w = display->current_mode.w; @@ -739,15 +721,13 @@ SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect) return 0; } -static int -ParseDisplayUsableBoundsHint(SDL_Rect *rect) +static int ParseDisplayUsableBoundsHint(SDL_Rect *rect) { const char *hint = SDL_GetHint(SDL_HINT_DISPLAY_USABLE_BOUNDS); return hint && (SDL_sscanf(hint, "%d,%d,%d,%d", &rect->x, &rect->y, &rect->w, &rect->h) == 4); } -int -SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect * rect) +int SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect *rect) { SDL_VideoDisplay *display; @@ -773,8 +753,7 @@ SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect * rect) return SDL_GetDisplayBounds(displayIndex, rect); } -int -SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi) +int SDL_GetDisplayDPI(int displayIndex, float *ddpi, float *hdpi, float *vdpi) { SDL_VideoDisplay *display; @@ -805,7 +784,7 @@ SDL_GetDisplayOrientation(int displayIndex) } SDL_bool -SDL_AddDisplayMode(SDL_VideoDisplay * display, const SDL_DisplayMode * mode) +SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode) { SDL_DisplayMode *modes; int i, nmodes; @@ -840,20 +819,17 @@ SDL_AddDisplayMode(SDL_VideoDisplay * display, const SDL_DisplayMode * mode) return SDL_TRUE; } -void -SDL_SetCurrentDisplayMode(SDL_VideoDisplay * display, const SDL_DisplayMode * mode) +void SDL_SetCurrentDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode) { SDL_memcpy(&display->current_mode, mode, sizeof(*mode)); } -void -SDL_SetDesktopDisplayMode(SDL_VideoDisplay * display, const SDL_DisplayMode * mode) +void SDL_SetDesktopDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode) { SDL_memcpy(&display->desktop_mode, mode, sizeof(*mode)); } -static int -SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display) +static int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay *display) { if (!display->num_display_modes && _this->GetDisplayModes) { _this->GetDisplayModes(_this, display); @@ -863,21 +839,19 @@ SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display) return display->num_display_modes; } -int -SDL_GetNumDisplayModes(int displayIndex) +int SDL_GetNumDisplayModes(int displayIndex) { CHECK_DISPLAY_INDEX(displayIndex, -1); return SDL_GetNumDisplayModesForDisplay(&_this->displays[displayIndex]); } -void -SDL_ResetDisplayModes(int displayIndex) +void SDL_ResetDisplayModes(int displayIndex) { SDL_VideoDisplay *display; int i; - CHECK_DISPLAY_INDEX(displayIndex,); + CHECK_DISPLAY_INDEX(displayIndex, ); display = &_this->displays[displayIndex]; for (i = display->num_display_modes; i--;) { @@ -890,8 +864,7 @@ SDL_ResetDisplayModes(int displayIndex) display->max_display_modes = 0; } -int -SDL_GetDisplayMode(int displayIndex, int index, SDL_DisplayMode * mode) +int SDL_GetDisplayMode(int displayIndex, int index, SDL_DisplayMode *mode) { SDL_VideoDisplay *display; @@ -907,8 +880,7 @@ SDL_GetDisplayMode(int displayIndex, int index, SDL_DisplayMode * mode) return 0; } -int -SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * mode) +int SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode *mode) { SDL_VideoDisplay *display; @@ -921,8 +893,7 @@ SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * mode) return 0; } -int -SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode * mode) +int SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode *mode) { SDL_VideoDisplay *display; @@ -935,10 +906,9 @@ SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode * mode) return 0; } -static SDL_DisplayMode * -SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display, - const SDL_DisplayMode * mode, - SDL_DisplayMode * closest) +static SDL_DisplayMode *SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *display, + const SDL_DisplayMode *mode, + SDL_DisplayMode *closest) { Uint32 target_format; int target_refresh_rate; @@ -990,9 +960,9 @@ SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display, /* Sorted highest depth to lowest */ if (current->format == target_format || (SDL_BITSPERPIXEL(current->format) >= - SDL_BITSPERPIXEL(target_format) - && SDL_PIXELTYPE(current->format) == - SDL_PIXELTYPE(target_format))) { + SDL_BITSPERPIXEL(target_format) && + SDL_PIXELTYPE(current->format) == + SDL_PIXELTYPE(target_format))) { match = current; } continue; @@ -1044,8 +1014,8 @@ SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * SDL_GetClosestDisplayMode(int displayIndex, - const SDL_DisplayMode * mode, - SDL_DisplayMode * closest) + const SDL_DisplayMode *mode, + SDL_DisplayMode *closest) { SDL_VideoDisplay *display; @@ -1055,8 +1025,7 @@ SDL_GetClosestDisplayMode(int displayIndex, return SDL_GetClosestDisplayModeForDisplay(display, mode, closest); } -static int -SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode) +static int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay *display, const SDL_DisplayMode *mode) { SDL_DisplayMode display_mode; SDL_DisplayMode current_mode; @@ -1124,8 +1093,7 @@ SDL_GetDisplay(int displayIndex) * If x, y are outside of rect, snaps them to the closest point inside rect * (between rect->x, rect->y, inclusive, and rect->x + w, rect->y + h, exclusive) */ -static void -SDL_GetClosestPointOnRect(const SDL_Rect *rect, SDL_Point *point) +static void SDL_GetClosestPointOnRect(const SDL_Rect *rect, SDL_Point *point) { const int right = rect->x + rect->w - 1; const int bottom = rect->y + rect->h - 1; @@ -1143,8 +1111,7 @@ SDL_GetClosestPointOnRect(const SDL_Rect *rect, SDL_Point *point) } } -static int -GetRectDisplayIndex(int x, int y, int w, int h) +static int GetRectDisplayIndex(int x, int y, int w, int h) { int i, dist; int closest = -1; @@ -1170,7 +1137,7 @@ GetRectDisplayIndex(int x, int y, int w, int h) delta.x = center.x - closest_point_on_display.x; delta.y = center.y - closest_point_on_display.y; - dist = (delta.x*delta.x + delta.y*delta.y); + dist = (delta.x * delta.x + delta.y * delta.y); if (dist < closest_dist) { closest = i; closest_dist = dist; @@ -1184,20 +1151,17 @@ GetRectDisplayIndex(int x, int y, int w, int h) return closest; } -int -SDL_GetPointDisplayIndex(const SDL_Point *point) +int SDL_GetPointDisplayIndex(const SDL_Point *point) { return GetRectDisplayIndex(point->x, point->y, 1, 1); } -int -SDL_GetRectDisplayIndex(const SDL_Rect *rect) +int SDL_GetRectDisplayIndex(const SDL_Rect *rect) { return GetRectDisplayIndex(rect->x, rect->y, rect->w, rect->h); } -int -SDL_GetWindowDisplayIndex(SDL_Window * window) +int SDL_GetWindowDisplayIndex(SDL_Window *window) { int displayIndex = -1; @@ -1255,8 +1219,7 @@ SDL_GetDisplayForWindow(SDL_Window *window) } } -int -SDL_SetWindowDisplayMode(SDL_Window * window, const SDL_DisplayMode * mode) +int SDL_SetWindowDisplayMode(SDL_Window *window, const SDL_DisplayMode *mode) { CHECK_WINDOW_MAGIC(window, -1); @@ -1284,8 +1247,7 @@ SDL_SetWindowDisplayMode(SDL_Window * window, const SDL_DisplayMode * mode) return 0; } -int -SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode) +int SDL_GetWindowDisplayMode(SDL_Window *window, SDL_DisplayMode *mode) { SDL_DisplayMode fullscreen_mode; SDL_VideoDisplay *display; @@ -1310,8 +1272,8 @@ SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode) if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) { fullscreen_mode = display->desktop_mode; } else if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayForWindow(window), - &fullscreen_mode, - &fullscreen_mode)) { + &fullscreen_mode, + &fullscreen_mode)) { SDL_zerop(mode); return SDL_SetError("Couldn't find display mode match"); } @@ -1321,8 +1283,8 @@ SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode) return 0; } -void* -SDL_GetWindowICCProfile(SDL_Window * window, size_t* size) +void * +SDL_GetWindowICCProfile(SDL_Window *window, size_t *size) { if (!_this->GetWindowICCProfile) { SDL_Unsupported(); @@ -1332,7 +1294,7 @@ SDL_GetWindowICCProfile(SDL_Window * window, size_t* size) } Uint32 -SDL_GetWindowPixelFormat(SDL_Window * window) +SDL_GetWindowPixelFormat(SDL_Window *window) { SDL_VideoDisplay *display; @@ -1342,8 +1304,7 @@ SDL_GetWindowPixelFormat(SDL_Window * window) return display->current_mode.format; } -static void -SDL_RestoreMousePosition(SDL_Window *window) +static void SDL_RestoreMousePosition(SDL_Window *window) { int x, y; @@ -1354,16 +1315,15 @@ SDL_RestoreMousePosition(SDL_Window *window) } #if __WINRT__ -extern Uint32 WINRT_DetectWindowFlags(SDL_Window * window); +extern Uint32 WINRT_DetectWindowFlags(SDL_Window *window); #endif -static int -SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen) +static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen) { SDL_VideoDisplay *display; SDL_Window *other; - CHECK_WINDOW_MAGIC(window,-1); + CHECK_WINDOW_MAGIC(window, -1); /* if we are in the process of hiding don't go back to fullscreen */ if (window->is_hiding && fullscreen) { @@ -1374,11 +1334,11 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen) /* if the window is going away and no resolution change is necessary, do nothing, or else we may trigger an ugly double-transition */ - if (SDL_strcmp(_this->name, "cocoa") == 0) { /* don't do this for X11, etc */ + if (SDL_strcmp(_this->name, "cocoa") == 0) { /* don't do this for X11, etc */ if (window->is_destroying && (window->last_fullscreen_flags & FULLSCREEN_MASK) == SDL_WINDOW_FULLSCREEN_DESKTOP) { return 0; } - + /* If we're switching between a fullscreen Space and "normal" fullscreen, we need to get back to normal first. */ if (fullscreen && ((window->last_fullscreen_flags & FULLSCREEN_MASK) == SDL_WINDOW_FULLSCREEN_DESKTOP) && ((window->flags & FULLSCREEN_MASK) == SDL_WINDOW_FULLSCREEN)) { if (!Cocoa_SetWindowFullscreenSpace(window, SDL_FALSE)) { @@ -1531,8 +1491,7 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen) #define CREATE_FLAGS \ (SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_SKIP_TASKBAR | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP | SDL_WINDOW_VULKAN | SDL_WINDOW_MINIMIZED | SDL_WINDOW_METAL) -static SDL_INLINE SDL_bool -IsAcceptingDragAndDrop(void) +static SDL_INLINE SDL_bool IsAcceptingDragAndDrop(void) { if ((SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) || (SDL_GetEventState(SDL_DROPTEXT) == SDL_ENABLE)) { @@ -1542,8 +1501,7 @@ IsAcceptingDragAndDrop(void) } /* prepare a newly-created window */ -static SDL_INLINE void -PrepareDragAndDropSupport(SDL_Window *window) +static SDL_INLINE void PrepareDragAndDropSupport(SDL_Window *window) { if (_this->AcceptDragAndDrop) { _this->AcceptDragAndDrop(window, IsAcceptingDragAndDrop()); @@ -1551,8 +1509,7 @@ PrepareDragAndDropSupport(SDL_Window *window) } /* toggle d'n'd for all existing windows. */ -void -SDL_ToggleDragAndDropSupport(void) +void SDL_ToggleDragAndDropSupport(void) { if (_this && _this->AcceptDragAndDrop) { const SDL_bool enable = IsAcceptingDragAndDrop(); @@ -1563,8 +1520,7 @@ SDL_ToggleDragAndDropSupport(void) } } -static void -SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags) +static void SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags) { PrepareDragAndDropSupport(window); @@ -1593,15 +1549,16 @@ SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags) } } -static int -SDL_ContextNotSupported(const char *name) +static int SDL_ContextNotSupported(const char *name) { - return SDL_SetError("%s support is either not configured in SDL " "or not available in current SDL video driver " "(%s) or platform", name, + return SDL_SetError("%s support is either not configured in SDL " + "or not available in current SDL video driver " + "(%s) or platform", + name, _this->name); } -static int -SDL_DllNotSupported(const char *name) +static int SDL_DllNotSupported(const char *name) { return SDL_SetError("No dynamic %s support in current SDL video driver (%s)", name, _this->name); } @@ -1730,8 +1687,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) /* for real fullscreen we might switch the resolution, so get width and height * from closest supported mode and use that instead of current resolution */ - if ((flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP - && (bounds.w != w || bounds.h != h)) { + if ((flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP && (bounds.w != w || bounds.h != h)) { SDL_DisplayMode fullscreen_mode, closest_mode; SDL_zero(fullscreen_mode); fullscreen_mode.w = w; @@ -1869,8 +1825,7 @@ SDL_CreateWindowFrom(const void *data) return window; } -int -SDL_RecreateWindow(SDL_Window * window, Uint32 flags) +int SDL_RecreateWindow(SDL_Window *window, Uint32 flags) { SDL_bool loaded_opengl = SDL_FALSE; SDL_bool need_gl_unload = SDL_FALSE; @@ -1934,7 +1889,7 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags) } } else if (window->flags & SDL_WINDOW_OPENGL) { need_gl_unload = SDL_TRUE; - need_gl_load = SDL_TRUE; + need_gl_load = SDL_TRUE; } if ((window->flags & SDL_WINDOW_VULKAN) != (flags & SDL_WINDOW_VULKAN)) { @@ -1945,7 +1900,7 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags) } } else if (window->flags & SDL_WINDOW_VULKAN) { need_vulkan_unload = SDL_TRUE; - need_vulkan_load = SDL_TRUE; + need_vulkan_load = SDL_TRUE; } if (need_gl_unload) { @@ -2016,7 +1971,7 @@ SDL_HasWindows(void) } Uint32 -SDL_GetWindowID(SDL_Window * window) +SDL_GetWindowID(SDL_Window *window) { CHECK_WINDOW_MAGIC(window, 0); @@ -2040,17 +1995,16 @@ SDL_GetWindowFromID(Uint32 id) } Uint32 -SDL_GetWindowFlags(SDL_Window * window) +SDL_GetWindowFlags(SDL_Window *window) { CHECK_WINDOW_MAGIC(window, 0); return window->flags; } -void -SDL_SetWindowTitle(SDL_Window * window, const char *title) +void SDL_SetWindowTitle(SDL_Window *window, const char *title) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (title == window->title) { return; @@ -2065,17 +2019,16 @@ SDL_SetWindowTitle(SDL_Window * window, const char *title) } const char * -SDL_GetWindowTitle(SDL_Window * window) +SDL_GetWindowTitle(SDL_Window *window) { CHECK_WINDOW_MAGIC(window, ""); return window->title ? window->title : ""; } -void -SDL_SetWindowIcon(SDL_Window * window, SDL_Surface * icon) +void SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (icon == NULL) { return; @@ -2094,8 +2047,8 @@ SDL_SetWindowIcon(SDL_Window * window, SDL_Surface * icon) } } -void* -SDL_SetWindowData(SDL_Window * window, const char *name, void *userdata) +void * +SDL_SetWindowData(SDL_Window *window, const char *name, void *userdata) { SDL_WindowUserData *prev, *data; @@ -2103,8 +2056,8 @@ SDL_SetWindowData(SDL_Window * window, const char *name, void *userdata) /* Input validation */ if (name == NULL || name[0] == '\0') { - SDL_InvalidParamError("name"); - return NULL; + SDL_InvalidParamError("name"); + return NULL; } /* See if the named data already exists */ @@ -2142,7 +2095,7 @@ SDL_SetWindowData(SDL_Window * window, const char *name, void *userdata) } void * -SDL_GetWindowData(SDL_Window * window, const char *name) +SDL_GetWindowData(SDL_Window *window, const char *name) { SDL_WindowUserData *data; @@ -2150,8 +2103,8 @@ SDL_GetWindowData(SDL_Window * window, const char *name) /* Input validation */ if (name == NULL || name[0] == '\0') { - SDL_InvalidParamError("name"); - return NULL; + SDL_InvalidParamError("name"); + return NULL; } for (data = window->data; data; data = data->next) { @@ -2162,10 +2115,9 @@ SDL_GetWindowData(SDL_Window * window, const char *name) return NULL; } -void -SDL_SetWindowPosition(SDL_Window * window, int x, int y) +void SDL_SetWindowPosition(SDL_Window *window, int x, int y) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) { int displayIndex = (x & 0xFFFF); @@ -2206,15 +2158,14 @@ SDL_SetWindowPosition(SDL_Window * window, int x, int y) } } -void -SDL_GetWindowPosition(SDL_Window * window, int *x, int *y) +void SDL_GetWindowPosition(SDL_Window *window, int *x, int *y) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); /* Fullscreen windows are always at their display's origin */ if (window->flags & SDL_WINDOW_FULLSCREEN) { int displayIndex; - + if (x) { *x = 0; } @@ -2248,12 +2199,11 @@ SDL_GetWindowPosition(SDL_Window * window, int *x, int *y) } } -void -SDL_SetWindowBordered(SDL_Window * window, SDL_bool bordered) +void SDL_SetWindowBordered(SDL_Window *window, SDL_bool bordered) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { - const int want = (bordered != SDL_FALSE); /* normalize the flag. */ + const int want = (bordered != SDL_FALSE); /* normalize the flag. */ const int have = ((window->flags & SDL_WINDOW_BORDERLESS) == 0); if ((want != have) && (_this->SetWindowBordered)) { if (want) { @@ -2261,17 +2211,16 @@ SDL_SetWindowBordered(SDL_Window * window, SDL_bool bordered) } else { window->flags |= SDL_WINDOW_BORDERLESS; } - _this->SetWindowBordered(_this, window, (SDL_bool) want); + _this->SetWindowBordered(_this, window, (SDL_bool)want); } } } -void -SDL_SetWindowResizable(SDL_Window * window, SDL_bool resizable) +void SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { - const int want = (resizable != SDL_FALSE); /* normalize the flag. */ + const int want = (resizable != SDL_FALSE); /* normalize the flag. */ const int have = ((window->flags & SDL_WINDOW_RESIZABLE) != 0); if ((want != have) && (_this->SetWindowResizable)) { if (want) { @@ -2279,17 +2228,16 @@ SDL_SetWindowResizable(SDL_Window * window, SDL_bool resizable) } else { window->flags &= ~SDL_WINDOW_RESIZABLE; } - _this->SetWindowResizable(_this, window, (SDL_bool) want); + _this->SetWindowResizable(_this, window, (SDL_bool)want); } } } -void -SDL_SetWindowAlwaysOnTop(SDL_Window * window, SDL_bool on_top) +void SDL_SetWindowAlwaysOnTop(SDL_Window *window, SDL_bool on_top) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { - const int want = (on_top != SDL_FALSE); /* normalize the flag. */ + const int want = (on_top != SDL_FALSE); /* normalize the flag. */ const int have = ((window->flags & SDL_WINDOW_ALWAYS_ON_TOP) != 0); if ((want != have) && (_this->SetWindowAlwaysOnTop)) { if (want) { @@ -2297,16 +2245,15 @@ SDL_SetWindowAlwaysOnTop(SDL_Window * window, SDL_bool on_top) } else { window->flags &= ~SDL_WINDOW_ALWAYS_ON_TOP; } - - _this->SetWindowAlwaysOnTop(_this, window, (SDL_bool) want); + + _this->SetWindowAlwaysOnTop(_this, window, (SDL_bool)want); } } } -void -SDL_SetWindowSize(SDL_Window * window, int w, int h) +void SDL_SetWindowSize(SDL_Window *window, int w, int h) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (w <= 0) { SDL_InvalidParamError("w"); return; @@ -2353,10 +2300,9 @@ SDL_SetWindowSize(SDL_Window * window, int w, int h) } } -void -SDL_GetWindowSize(SDL_Window * window, int *w, int *h) +void SDL_GetWindowSize(SDL_Window *window, int *w, int *h) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (w) { *w = window->w; } @@ -2365,15 +2311,22 @@ SDL_GetWindowSize(SDL_Window * window, int *w, int *h) } } -int -SDL_GetWindowBordersSize(SDL_Window * window, int *top, int *left, int *bottom, int *right) +int SDL_GetWindowBordersSize(SDL_Window *window, int *top, int *left, int *bottom, int *right) { int dummy = 0; - if (top == NULL) { top = &dummy; } - if (left == NULL) { left = &dummy; } - if (right == NULL) { right = &dummy; } - if (bottom == NULL) { bottom = &dummy; } + if (top == NULL) { + top = &dummy; + } + if (left == NULL) { + left = &dummy; + } + if (right == NULL) { + right = &dummy; + } + if (bottom == NULL) { + bottom = &dummy; + } /* Always initialize, so applications don't have to care */ *top = *left = *bottom = *right = 0; @@ -2387,12 +2340,11 @@ SDL_GetWindowBordersSize(SDL_Window * window, int *top, int *left, int *bottom, return _this->GetWindowBordersSize(_this, window, top, left, bottom, right); } -void -SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h) +void SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h) { int filter; - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (w == NULL) { w = &filter; @@ -2409,10 +2361,9 @@ SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h) } } -void -SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h) +void SDL_SetWindowMinimumSize(SDL_Window *window, int min_w, int min_h) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (min_w <= 0) { SDL_InvalidParamError("min_w"); return; @@ -2440,10 +2391,9 @@ SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h) } } -void -SDL_GetWindowMinimumSize(SDL_Window * window, int *min_w, int *min_h) +void SDL_GetWindowMinimumSize(SDL_Window *window, int *min_w, int *min_h) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (min_w) { *min_w = window->min_w; } @@ -2452,10 +2402,9 @@ SDL_GetWindowMinimumSize(SDL_Window * window, int *min_w, int *min_h) } } -void -SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h) +void SDL_SetWindowMaximumSize(SDL_Window *window, int max_w, int max_h) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (max_w <= 0) { SDL_InvalidParamError("max_w"); return; @@ -2482,10 +2431,9 @@ SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h) } } -void -SDL_GetWindowMaximumSize(SDL_Window * window, int *max_w, int *max_h) +void SDL_GetWindowMaximumSize(SDL_Window *window, int *max_w, int *max_h) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (max_w) { *max_w = window->max_w; } @@ -2494,10 +2442,9 @@ SDL_GetWindowMaximumSize(SDL_Window * window, int *max_w, int *max_h) } } -void -SDL_ShowWindow(SDL_Window * window) +void SDL_ShowWindow(SDL_Window *window) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (window->flags & SDL_WINDOW_SHOWN) { return; @@ -2509,10 +2456,9 @@ SDL_ShowWindow(SDL_Window * window) SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SHOWN, 0, 0); } -void -SDL_HideWindow(SDL_Window * window) +void SDL_HideWindow(SDL_Window *window) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (!(window->flags & SDL_WINDOW_SHOWN)) { return; @@ -2528,10 +2474,9 @@ SDL_HideWindow(SDL_Window * window) SDL_SendWindowEvent(window, SDL_WINDOWEVENT_HIDDEN, 0, 0); } -void -SDL_RaiseWindow(SDL_Window * window) +void SDL_RaiseWindow(SDL_Window *window) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (!(window->flags & SDL_WINDOW_SHOWN)) { return; @@ -2541,10 +2486,9 @@ SDL_RaiseWindow(SDL_Window * window) } } -void -SDL_MaximizeWindow(SDL_Window * window) +void SDL_MaximizeWindow(SDL_Window *window) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (window->flags & SDL_WINDOW_MAXIMIZED) { return; @@ -2557,8 +2501,7 @@ SDL_MaximizeWindow(SDL_Window * window) } } -static SDL_bool -CanMinimizeWindow(SDL_Window * window) +static SDL_bool CanMinimizeWindow(SDL_Window *window) { if (!_this->MinimizeWindow) { return SDL_FALSE; @@ -2566,10 +2509,9 @@ CanMinimizeWindow(SDL_Window * window) return SDL_TRUE; } -void -SDL_MinimizeWindow(SDL_Window * window) +void SDL_MinimizeWindow(SDL_Window *window) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (window->flags & SDL_WINDOW_MINIMIZED) { return; @@ -2588,10 +2530,9 @@ SDL_MinimizeWindow(SDL_Window * window) } } -void -SDL_RestoreWindow(SDL_Window * window) +void SDL_RestoreWindow(SDL_Window *window) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (!(window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) { return; @@ -2602,8 +2543,7 @@ SDL_RestoreWindow(SDL_Window * window) } } -int -SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags) +int SDL_SetWindowFullscreen(SDL_Window *window, Uint32 flags) { Uint32 oldflags; CHECK_WINDOW_MAGIC(window, -1); @@ -2622,14 +2562,13 @@ SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags) if (SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window)) == 0) { return 0; } - + window->flags &= ~FULLSCREEN_MASK; window->flags |= oldflags; return -1; } -static SDL_Surface * -SDL_CreateWindowFramebuffer(SDL_Window * window) +static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) { Uint32 format = 0; void *pixels = NULL; @@ -2652,7 +2591,7 @@ SDL_CreateWindowFramebuffer(SDL_Window * window) } } - if (_this->is_dummy) { /* dummy driver never has GPU support, of course. */ + if (_this->is_dummy) { /* dummy driver never has GPU support, of course. */ attempt_texture_framebuffer = SDL_FALSE; } @@ -2694,7 +2633,7 @@ SDL_CreateWindowFramebuffer(SDL_Window * window) } } - _this->checked_texture_framebuffer = SDL_TRUE; /* don't check this again. */ + _this->checked_texture_framebuffer = SDL_TRUE; /* don't check this again. */ } if (!created_framebuffer) { @@ -2719,7 +2658,7 @@ SDL_CreateWindowFramebuffer(SDL_Window * window) } SDL_Surface * -SDL_GetWindowSurface(SDL_Window * window) +SDL_GetWindowSurface(SDL_Window *window) { CHECK_WINDOW_MAGIC(window, NULL); @@ -2738,8 +2677,7 @@ SDL_GetWindowSurface(SDL_Window * window) return window->surface; } -int -SDL_UpdateWindowSurface(SDL_Window * window) +int SDL_UpdateWindowSurface(SDL_Window *window) { SDL_Rect full_rect; @@ -2752,9 +2690,8 @@ SDL_UpdateWindowSurface(SDL_Window * window) return SDL_UpdateWindowSurfaceRects(window, &full_rect, 1); } -int -SDL_UpdateWindowSurfaceRects(SDL_Window * window, const SDL_Rect * rects, - int numrects) +int SDL_UpdateWindowSurfaceRects(SDL_Window *window, const SDL_Rect *rects, + int numrects) { CHECK_WINDOW_MAGIC(window, -1); @@ -2815,8 +2752,7 @@ SDL_SetWindowOpacity(SDL_Window * window, float opacity) return retval; } -int -SDL_GetWindowOpacity(SDL_Window * window, float * out_opacity) +int SDL_GetWindowOpacity(SDL_Window *window, float *out_opacity) { CHECK_WINDOW_MAGIC(window, -1); @@ -2827,8 +2763,7 @@ SDL_GetWindowOpacity(SDL_Window * window, float * out_opacity) return 0; } -int -SDL_SetWindowModalFor(SDL_Window * modal_window, SDL_Window * parent_window) +int SDL_SetWindowModalFor(SDL_Window *modal_window, SDL_Window *parent_window) { CHECK_WINDOW_MAGIC(modal_window, -1); CHECK_WINDOW_MAGIC(parent_window, -1); @@ -2836,19 +2771,18 @@ SDL_SetWindowModalFor(SDL_Window * modal_window, SDL_Window * parent_window) if (!_this->SetWindowModalFor) { return SDL_Unsupported(); } - + return _this->SetWindowModalFor(_this, modal_window, parent_window); } -int -SDL_SetWindowInputFocus(SDL_Window * window) +int SDL_SetWindowInputFocus(SDL_Window *window) { CHECK_WINDOW_MAGIC(window, -1); if (!_this->SetWindowInputFocus) { return SDL_Unsupported(); } - + return _this->SetWindowInputFocus(_this, window); } @@ -2967,7 +2901,7 @@ SDL_UpdateWindowGrab(SDL_Window * window) } _this->grabbed_window = window; } else if (_this->grabbed_window == window) { - _this->grabbed_window = NULL; /* ungrabbing input. */ + _this->grabbed_window = NULL; /* ungrabbing input. */ } if (_this->SetWindowMouseGrab) { @@ -2978,10 +2912,9 @@ SDL_UpdateWindowGrab(SDL_Window * window) } } -void -SDL_SetWindowGrab(SDL_Window * window, SDL_bool grabbed) +void SDL_SetWindowGrab(SDL_Window *window, SDL_bool grabbed) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); SDL_SetWindowMouseGrab(window, grabbed); @@ -2990,10 +2923,9 @@ SDL_SetWindowGrab(SDL_Window * window, SDL_bool grabbed) } } -void -SDL_SetWindowKeyboardGrab(SDL_Window * window, SDL_bool grabbed) +void SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_bool grabbed) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (!!grabbed == !!(window->flags & SDL_WINDOW_KEYBOARD_GRABBED)) { return; @@ -3006,10 +2938,9 @@ SDL_SetWindowKeyboardGrab(SDL_Window * window, SDL_bool grabbed) SDL_UpdateWindowGrab(window); } -void -SDL_SetWindowMouseGrab(SDL_Window * window, SDL_bool grabbed) +void SDL_SetWindowMouseGrab(SDL_Window *window, SDL_bool grabbed) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (!!grabbed == !!(window->flags & SDL_WINDOW_MOUSE_GRABBED)) { return; @@ -3023,20 +2954,20 @@ SDL_SetWindowMouseGrab(SDL_Window * window, SDL_bool grabbed) } SDL_bool -SDL_GetWindowGrab(SDL_Window * window) +SDL_GetWindowGrab(SDL_Window *window) { return SDL_GetWindowKeyboardGrab(window) || SDL_GetWindowMouseGrab(window); } SDL_bool -SDL_GetWindowKeyboardGrab(SDL_Window * window) +SDL_GetWindowKeyboardGrab(SDL_Window *window) { CHECK_WINDOW_MAGIC(window, SDL_FALSE); return window == _this->grabbed_window && ((_this->grabbed_window->flags & SDL_WINDOW_KEYBOARD_GRABBED) != 0); } SDL_bool -SDL_GetWindowMouseGrab(SDL_Window * window) +SDL_GetWindowMouseGrab(SDL_Window *window) { CHECK_WINDOW_MAGIC(window, SDL_FALSE); return window == _this->grabbed_window && ((_this->grabbed_window->flags & SDL_WINDOW_MOUSE_GRABBED) != 0); @@ -3046,15 +2977,14 @@ SDL_Window * SDL_GetGrabbedWindow(void) { if (_this->grabbed_window && - (_this->grabbed_window->flags & (SDL_WINDOW_MOUSE_GRABBED|SDL_WINDOW_KEYBOARD_GRABBED)) != 0) { + (_this->grabbed_window->flags & (SDL_WINDOW_MOUSE_GRABBED | SDL_WINDOW_KEYBOARD_GRABBED)) != 0) { return _this->grabbed_window; } else { return NULL; } } -int -SDL_SetWindowMouseRect(SDL_Window * window, const SDL_Rect * rect) +int SDL_SetWindowMouseRect(SDL_Window *window, const SDL_Rect *rect) { CHECK_WINDOW_MAGIC(window, -1); @@ -3071,7 +3001,7 @@ SDL_SetWindowMouseRect(SDL_Window * window, const SDL_Rect * rect) } const SDL_Rect * -SDL_GetWindowMouseRect(SDL_Window * window) +SDL_GetWindowMouseRect(SDL_Window *window) { CHECK_WINDOW_MAGIC(window, NULL); @@ -3082,8 +3012,7 @@ SDL_GetWindowMouseRect(SDL_Window * window) } } -int -SDL_FlashWindow(SDL_Window * window, SDL_FlashOperation operation) +int SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation) { CHECK_WINDOW_MAGIC(window, -1); @@ -3094,20 +3023,17 @@ SDL_FlashWindow(SDL_Window * window, SDL_FlashOperation operation) return SDL_Unsupported(); } -void -SDL_OnWindowShown(SDL_Window * window) +void SDL_OnWindowShown(SDL_Window *window) { SDL_OnWindowRestored(window); } -void -SDL_OnWindowHidden(SDL_Window * window) +void SDL_OnWindowHidden(SDL_Window *window) { SDL_UpdateFullscreenMode(window, SDL_FALSE); } -void -SDL_OnWindowResized(SDL_Window * window) +void SDL_OnWindowResized(SDL_Window *window) { int display_index = SDL_GetWindowDisplayIndex(window); window->surface_valid = SDL_FALSE; @@ -3122,8 +3048,7 @@ SDL_OnWindowResized(SDL_Window * window) } } -void -SDL_OnWindowMoved(SDL_Window * window) +void SDL_OnWindowMoved(SDL_Window *window) { int display_index = SDL_GetWindowDisplayIndex(window); @@ -3133,16 +3058,14 @@ SDL_OnWindowMoved(SDL_Window * window) } } -void -SDL_OnWindowMinimized(SDL_Window * window) +void SDL_OnWindowMinimized(SDL_Window *window) { if (!DisableUnsetFullscreenOnMinimize(_this)) { SDL_UpdateFullscreenMode(window, SDL_FALSE); } } -void -SDL_OnWindowRestored(SDL_Window * window) +void SDL_OnWindowRestored(SDL_Window *window) { /* * FIXME: Is this fine to just remove this, or should it be preserved just @@ -3157,21 +3080,18 @@ SDL_OnWindowRestored(SDL_Window * window) } } -void -SDL_OnWindowEnter(SDL_Window * window) +void SDL_OnWindowEnter(SDL_Window *window) { if (_this->OnWindowEnter) { _this->OnWindowEnter(_this, window); } } -void -SDL_OnWindowLeave(SDL_Window * window) +void SDL_OnWindowLeave(SDL_Window *window) { } -void -SDL_OnWindowFocusGained(SDL_Window * window) +void SDL_OnWindowFocusGained(SDL_Window *window) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -3182,15 +3102,14 @@ SDL_OnWindowFocusGained(SDL_Window * window) if (mouse && mouse->relative_mode) { SDL_SetMouseFocus(window); if (mouse->relative_mode_warp) { - SDL_PerformWarpMouseInWindow(window, window->w/2, window->h/2, SDL_TRUE); + SDL_PerformWarpMouseInWindow(window, window->w / 2, window->h / 2, SDL_TRUE); } } SDL_UpdateWindowGrab(window); } -static SDL_bool -ShouldMinimizeOnFocusLoss(SDL_Window * window) +static SDL_bool ShouldMinimizeOnFocusLoss(SDL_Window *window) { const char *hint; @@ -3228,8 +3147,7 @@ ShouldMinimizeOnFocusLoss(SDL_Window * window) return SDL_GetHintBoolean(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_FALSE); } -void -SDL_OnWindowFocusLost(SDL_Window * window) +void SDL_OnWindowFocusLost(SDL_Window *window) { if (window->gamma && _this->SetWindowGammaRamp) { _this->SetWindowGammaRamp(_this, window, window->saved_gamma); @@ -3260,12 +3178,11 @@ SDL_GetFocusWindow(void) return NULL; } -void -SDL_DestroyWindow(SDL_Window * window) +void SDL_DestroyWindow(SDL_Window *window) { SDL_VideoDisplay *display; - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); window->is_destroying = SDL_TRUE; @@ -3352,8 +3269,7 @@ SDL_IsScreenSaverEnabled() return _this->suspend_screensaver ? SDL_FALSE : SDL_TRUE; } -void -SDL_EnableScreenSaver() +void SDL_EnableScreenSaver() { if (_this == NULL) { return; @@ -3367,8 +3283,7 @@ SDL_EnableScreenSaver() } } -void -SDL_DisableScreenSaver() +void SDL_DisableScreenSaver() { if (_this == NULL) { return; @@ -3382,8 +3297,7 @@ SDL_DisableScreenSaver() } } -void -SDL_VideoQuit(void) +void SDL_VideoQuit(void) { int i; @@ -3427,8 +3341,7 @@ SDL_VideoQuit(void) _this = NULL; } -int -SDL_GL_LoadLibrary(const char *path) +int SDL_GL_LoadLibrary(const char *path) { int retval; @@ -3496,8 +3409,7 @@ SDL_GL_UnloadLibrary(void) } #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 -static SDL_INLINE SDL_bool -isAtLeastGL3(const char *verstr) +static SDL_INLINE SDL_bool isAtLeastGL3(const char *verstr) { return verstr && (SDL_atoi(verstr) >= 3); } @@ -3507,7 +3419,7 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) { #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 - const GLubyte *(APIENTRY * glGetStringFunc) (GLenum); + const GLubyte *(APIENTRY * glGetStringFunc)(GLenum); const char *extensions; const char *start; const char *where, *terminator; @@ -3530,9 +3442,9 @@ SDL_GL_ExtensionSupported(const char *extension) return SDL_FALSE; } - if (isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) { - const GLubyte *(APIENTRY * glGetStringiFunc) (GLenum, GLuint); - void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params); + if (isAtLeastGL3((const char *)glGetStringFunc(GL_VERSION))) { + const GLubyte *(APIENTRY * glGetStringiFunc)(GLenum, GLuint); + void(APIENTRY * glGetIntegervFunc)(GLenum pname, GLint * params); GLint num_exts = 0; GLint i; @@ -3542,12 +3454,12 @@ SDL_GL_ExtensionSupported(const char *extension) return SDL_FALSE; } - #ifndef GL_NUM_EXTENSIONS - #define GL_NUM_EXTENSIONS 0x821D - #endif +#ifndef GL_NUM_EXTENSIONS +#define GL_NUM_EXTENSIONS 0x821D +#endif glGetIntegervFunc(GL_NUM_EXTENSIONS, &num_exts); for (i = 0; i < num_exts; i++) { - const char *thisext = (const char *) glGetStringiFunc(GL_EXTENSIONS, i); + const char *thisext = (const char *)glGetStringiFunc(GL_EXTENSIONS, i); if (SDL_strcmp(thisext, extension) == 0) { return SDL_TRUE; } @@ -3558,7 +3470,7 @@ SDL_GL_ExtensionSupported(const char *extension) /* Try the old way with glGetString(GL_EXTENSIONS) ... */ - extensions = (const char *) glGetStringFunc(GL_EXTENSIONS); + extensions = (const char *)glGetStringFunc(GL_EXTENSIONS); if (extensions == NULL) { return SDL_FALSE; } @@ -3592,12 +3504,11 @@ SDL_GL_ExtensionSupported(const char *extension) /* Deduce supported ES profile versions from the supported ARB_ES*_compatibility extensions. There is no direct query. - + This is normally only called when the OpenGL driver supports {GLX,WGL}_EXT_create_context_es2_profile. */ -void -SDL_GL_DeduceMaxSupportedESProfile(int* major, int* minor) +void SDL_GL_DeduceMaxSupportedESProfile(int *major, int *minor) { /* THIS REQUIRES AN EXISTING GL CONTEXT THAT HAS BEEN MADE CURRENT. */ /* Please refer to https://bugzilla.libsdl.org/show_bug.cgi?id=3725 for discussion. */ @@ -3645,7 +3556,7 @@ SDL_GL_ResetAttributes() _this->gl_config.multisamplesamples = 0; _this->gl_config.floatbuffers = 0; _this->gl_config.retained_backing = 1; - _this->gl_config.accelerated = -1; /* accelerated or not, both are fine */ + _this->gl_config.accelerated = -1; /* accelerated or not, both are fine */ #if SDL_VIDEO_OPENGL _this->gl_config.major_version = 2; @@ -3676,8 +3587,7 @@ SDL_GL_ResetAttributes() _this->gl_config.share_with_current_context = 0; } -int -SDL_GL_SetAttribute(SDL_GLattr attr, int value) +int SDL_GL_SetAttribute(SDL_GLattr attr, int value) { #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 int retval; @@ -3800,11 +3710,10 @@ SDL_GL_SetAttribute(SDL_GLattr attr, int value) #endif /* SDL_VIDEO_OPENGL */ } -int -SDL_GL_GetAttribute(SDL_GLattr attr, int *value) +int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) { #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 - GLenum (APIENTRY *glGetErrorFunc) (void); + GLenum(APIENTRY * glGetErrorFunc)(void); GLenum attrib = 0; GLenum error = 0; @@ -3815,8 +3724,8 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value) * the function itself doesn't exist prior to OpenGL 3 and OpenGL ES 2. */ #if SDL_VIDEO_OPENGL - const GLubyte *(APIENTRY *glGetStringFunc) (GLenum name); - void (APIENTRY *glGetFramebufferAttachmentParameterivFunc) (GLenum target, GLenum attachment, GLenum pname, GLint* params); + const GLubyte *(APIENTRY * glGetStringFunc)(GLenum name); + void(APIENTRY * glGetFramebufferAttachmentParameterivFunc)(GLenum target, GLenum attachment, GLenum pname, GLint * params); GLenum attachment = GL_BACK_LEFT; GLenum attachmentattrib = 0; #endif @@ -3922,47 +3831,47 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value) #endif break; case SDL_GL_BUFFER_SIZE: - { - int rsize = 0, gsize = 0, bsize = 0, asize = 0; + { + int rsize = 0, gsize = 0, bsize = 0, asize = 0; - /* There doesn't seem to be a single flag in OpenGL for this! */ - if (SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &rsize) < 0) { - return -1; - } - if (SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &gsize) < 0) { - return -1; - } - if (SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &bsize) < 0) { - return -1; - } - if (SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &asize) < 0) { - return -1; - } - - *value = rsize + gsize + bsize + asize; - return 0; + /* There doesn't seem to be a single flag in OpenGL for this! */ + if (SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &rsize) < 0) { + return -1; } + if (SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &gsize) < 0) { + return -1; + } + if (SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &bsize) < 0) { + return -1; + } + if (SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &asize) < 0) { + return -1; + } + + *value = rsize + gsize + bsize + asize; + return 0; + } case SDL_GL_ACCELERATED_VISUAL: - { - /* FIXME: How do we get this information? */ - *value = (_this->gl_config.accelerated != 0); - return 0; - } + { + /* FIXME: How do we get this information? */ + *value = (_this->gl_config.accelerated != 0); + return 0; + } case SDL_GL_RETAINED_BACKING: - { - *value = _this->gl_config.retained_backing; - return 0; - } + { + *value = _this->gl_config.retained_backing; + return 0; + } case SDL_GL_CONTEXT_MAJOR_VERSION: - { - *value = _this->gl_config.major_version; - return 0; - } + { + *value = _this->gl_config.major_version; + return 0; + } case SDL_GL_CONTEXT_MINOR_VERSION: - { - *value = _this->gl_config.minor_version; - return 0; - } + { + *value = _this->gl_config.minor_version; + return 0; + } case SDL_GL_CONTEXT_EGL: /* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */ { @@ -3974,25 +3883,25 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value) return 0; } case SDL_GL_CONTEXT_FLAGS: - { - *value = _this->gl_config.flags; - return 0; - } + { + *value = _this->gl_config.flags; + return 0; + } case SDL_GL_CONTEXT_PROFILE_MASK: - { - *value = _this->gl_config.profile_mask; - return 0; - } + { + *value = _this->gl_config.profile_mask; + return 0; + } case SDL_GL_SHARE_WITH_CURRENT_CONTEXT: - { - *value = _this->gl_config.share_with_current_context; - return 0; - } + { + *value = _this->gl_config.share_with_current_context; + return 0; + } case SDL_GL_FRAMEBUFFER_SRGB_CAPABLE: - { - *value = _this->gl_config.framebuffer_srgb_capable; - return 0; - } + { + *value = _this->gl_config.framebuffer_srgb_capable; + return 0; + } case SDL_GL_CONTEXT_NO_ERROR: { *value = _this->gl_config.no_error; @@ -4008,11 +3917,11 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value) return -1; } - if (attachmentattrib && isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) { + if (attachmentattrib && isAtLeastGL3((const char *)glGetStringFunc(GL_VERSION))) { /* glGetFramebufferAttachmentParameteriv needs to operate on the window framebuffer for this, so bind FBO 0 if necessary. */ GLint current_fbo = 0; - void (APIENTRY *glGetIntegervFunc) (GLenum pname, GLint * params) = SDL_GL_GetProcAddress("glGetIntegerv"); - void (APIENTRY *glBindFramebufferFunc) (GLenum target, GLuint fbo) = SDL_GL_GetProcAddress("glBindFramebuffer"); + void(APIENTRY * glGetIntegervFunc)(GLenum pname, GLint * params) = SDL_GL_GetProcAddress("glGetIntegerv"); + void(APIENTRY * glBindFramebufferFunc)(GLenum target, GLuint fbo) = SDL_GL_GetProcAddress("glBindFramebuffer"); if (glGetIntegervFunc && glBindFramebufferFunc) { glGetIntegervFunc(GL_DRAW_FRAMEBUFFER_BINDING, ¤t_fbo); } @@ -4022,7 +3931,7 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value) if (glBindFramebufferFunc && (current_fbo != 0)) { glBindFramebufferFunc(GL_DRAW_FRAMEBUFFER, 0); } - glGetFramebufferAttachmentParameterivFunc(GL_FRAMEBUFFER, attachment, attachmentattrib, (GLint *) value); + glGetFramebufferAttachmentParameterivFunc(GL_FRAMEBUFFER, attachment, attachmentattrib, (GLint *)value); if (glBindFramebufferFunc && (current_fbo != 0)) { glBindFramebufferFunc(GL_DRAW_FRAMEBUFFER, current_fbo); } @@ -4032,10 +3941,10 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value) } else #endif { - void (APIENTRY *glGetIntegervFunc) (GLenum pname, GLint * params); + void(APIENTRY * glGetIntegervFunc)(GLenum pname, GLint * params); glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv"); if (glGetIntegervFunc) { - glGetIntegervFunc(attrib, (GLint *) value); + glGetIntegervFunc(attrib, (GLint *)value); } else { return -1; } @@ -4064,7 +3973,7 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value) #define NOT_AN_OPENGL_WINDOW "The specified window isn't an OpenGL window" SDL_GLContext -SDL_GL_CreateContext(SDL_Window * window) +SDL_GL_CreateContext(SDL_Window *window) { SDL_GLContext ctx = NULL; CHECK_WINDOW_MAGIC(window, NULL); @@ -4086,8 +3995,7 @@ SDL_GL_CreateContext(SDL_Window * window) return ctx; } -int -SDL_GL_MakeCurrent(SDL_Window * window, SDL_GLContext ctx) +int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext ctx) { int retval; @@ -4145,7 +4053,7 @@ SDL_GL_GetCurrentContext(void) void SDL_GL_GetDrawableSize(SDL_Window * window, int *w, int *h) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (_this->GL_GetDrawableSize) { _this->GL_GetDrawableSize(_this, window, w, h); @@ -4154,8 +4062,7 @@ void SDL_GL_GetDrawableSize(SDL_Window * window, int *w, int *h) } } -int -SDL_GL_SetSwapInterval(int interval) +int SDL_GL_SetSwapInterval(int interval) { if (_this == NULL) { return SDL_UninitializedVideo(); @@ -4168,8 +4075,7 @@ SDL_GL_SetSwapInterval(int interval) } } -int -SDL_GL_GetSwapInterval(void) +int SDL_GL_GetSwapInterval(void) { if (_this == NULL) { return 0; @@ -4182,8 +4088,7 @@ SDL_GL_GetSwapInterval(void) } } -int -SDL_GL_SwapWindowWithResult(SDL_Window * window) +int SDL_GL_SwapWindowWithResult(SDL_Window *window) { CHECK_WINDOW_MAGIC(window, -1); @@ -4198,14 +4103,12 @@ SDL_GL_SwapWindowWithResult(SDL_Window * window) return _this->GL_SwapWindow(_this, window); } -void -SDL_GL_SwapWindow(SDL_Window * window) +void SDL_GL_SwapWindow(SDL_Window *window) { SDL_GL_SwapWindowWithResult(window); } -void -SDL_GL_DeleteContext(SDL_GLContext context) +void SDL_GL_DeleteContext(SDL_GLContext context) { if (_this == NULL || !context) { return; @@ -4218,18 +4121,17 @@ SDL_GL_DeleteContext(SDL_GLContext context) _this->GL_DeleteContext(_this, context); } -#if 0 /* FIXME */ +#if 0 /* FIXME */ /* * Utility function used by SDL_WM_SetIcon(); flags & 1 for color key, flags * & 2 for alpha channel. */ -static void -CreateMaskFromColorKeyOrAlpha(SDL_Surface * icon, Uint8 * mask, int flags) +static void CreateMaskFromColorKeyOrAlpha(SDL_Surface * icon, Uint8 * mask, int flags) { int x, y; Uint32 colorkey; #define SET_MASKBIT(icon, x, y, mask) \ - mask[(y*((icon->w+7)/8))+(x/8)] &= ~(0x01<<(7-(x%8))) + mask[(y * ((icon->w + 7) / 8)) + (x / 8)] &= ~(0x01 << (7 - (x % 8))) colorkey = icon->format->colorkey; switch (icon->format->BytesPerPixel) { @@ -4335,8 +4237,7 @@ SDL_GetWindowWMInfo(SDL_Window * window, struct SDL_SysWMinfo *info) return (_this->GetWindowWMInfo(_this, window, info)); } -void -SDL_StartTextInput(void) +void SDL_StartTextInput(void) { SDL_Window *window; @@ -4356,8 +4257,7 @@ SDL_StartTextInput(void) } } -void -SDL_ClearComposition(void) +void SDL_ClearComposition(void) { if (_this && _this->ClearComposition) { _this->ClearComposition(_this); @@ -4380,8 +4280,7 @@ SDL_IsTextInputActive(void) return SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE; } -void -SDL_StopTextInput(void) +void SDL_StopTextInput(void) { SDL_Window *window; @@ -4401,8 +4300,7 @@ SDL_StopTextInput(void) (void)SDL_EventState(SDL_TEXTEDITING, SDL_DISABLE); } -void -SDL_SetTextInputRect(const SDL_Rect *rect) +void SDL_SetTextInputRect(const SDL_Rect *rect) { if (_this && _this->SetTextInputRect) { _this->SetTextInputRect(_this, rect); @@ -4427,8 +4325,7 @@ SDL_IsScreenKeyboardShown(SDL_Window *window) return SDL_FALSE; } -int -SDL_GetMessageBoxCount(void) +int SDL_GetMessageBoxCount(void) { return SDL_AtomicGet(&SDL_messagebox_count); } @@ -4486,8 +4383,7 @@ static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messagebo } #endif -int -SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) +int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { int dummybutton; int retval = -1; @@ -4627,8 +4523,7 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) return retval; } -int -SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window) +int SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window) { #ifdef __EMSCRIPTEN__ /* !!! FIXME: propose a browser API for this, get this #ifdef out of here? */ @@ -4643,7 +4538,8 @@ SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, S } EM_ASM_({ alert(UTF8ToString($0) + "\n\n" + UTF8ToString($1)); - }, title, message); + }, + title, message); return 0; #else SDL_MessageBoxData data; @@ -4672,8 +4568,7 @@ SDL_ShouldAllowTopmost(void) return SDL_GetHintBoolean(SDL_HINT_ALLOW_TOPMOST, SDL_TRUE); } -int -SDL_SetWindowHitTest(SDL_Window * window, SDL_HitTest callback, void *userdata) +int SDL_SetWindowHitTest(SDL_Window *window, SDL_HitTest callback, void *userdata) { CHECK_WINDOW_MAGIC(window, -1); @@ -4689,8 +4584,7 @@ SDL_SetWindowHitTest(SDL_Window * window, SDL_HitTest callback, void *userdata) return 0; } -float -SDL_ComputeDiagonalDPI(int hpix, int vpix, float hinches, float vinches) +float SDL_ComputeDiagonalDPI(int hpix, int vpix, float hinches, float vinches) { float den2 = hinches * hinches + vinches * vinches; if (den2 <= 0.0f) { @@ -4846,9 +4740,9 @@ SDL_bool SDL_Vulkan_CreateSurface(SDL_Window *window, return _this->Vulkan_CreateSurface(_this, window, instance, surface); } -void SDL_Vulkan_GetDrawableSize(SDL_Window * window, int *w, int *h) +void SDL_Vulkan_GetDrawableSize(SDL_Window *window, int *w, int *h) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (_this->Vulkan_GetDrawableSize) { _this->Vulkan_GetDrawableSize(_this, window, w, h); @@ -4858,7 +4752,7 @@ void SDL_Vulkan_GetDrawableSize(SDL_Window * window, int *w, int *h) } SDL_MetalView -SDL_Metal_CreateView(SDL_Window * window) +SDL_Metal_CreateView(SDL_Window *window) { CHECK_WINDOW_MAGIC(window, NULL); @@ -4878,8 +4772,7 @@ SDL_Metal_CreateView(SDL_Window * window) return _this->Metal_CreateView(_this, window); } -void -SDL_Metal_DestroyView(SDL_MetalView view) +void SDL_Metal_DestroyView(SDL_MetalView view) { if (_this && view && _this->Metal_DestroyView) { _this->Metal_DestroyView(_this, view); @@ -4902,9 +4795,9 @@ SDL_Metal_GetLayer(SDL_MetalView view) } } -void SDL_Metal_GetDrawableSize(SDL_Window * window, int *w, int *h) +void SDL_Metal_GetDrawableSize(SDL_Window *window, int *w, int *h) { - CHECK_WINDOW_MAGIC(window,); + CHECK_WINDOW_MAGIC(window, ); if (_this->Metal_GetDrawableSize) { _this->Metal_GetDrawableSize(_this, window, w, h); diff --git a/src/video/SDL_vulkan_internal.h b/src/video/SDL_vulkan_internal.h index ae9b96220..8b4c17e6f 100644 --- a/src/video/SDL_vulkan_internal.h +++ b/src/video/SDL_vulkan_internal.h @@ -62,7 +62,6 @@ #include "SDL_vulkan.h" - extern const char *SDL_Vulkan_GetResultString(VkResult result); extern VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList( @@ -88,8 +87,8 @@ extern SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr, /* No SDL Vulkan support, just include the header for typedefs */ #include "SDL_vulkan.h" -typedef void (*PFN_vkGetInstanceProcAddr) (void); -typedef int (*PFN_vkEnumerateInstanceExtensionProperties) (void); +typedef void (*PFN_vkGetInstanceProcAddr)(void); +typedef int (*PFN_vkEnumerateInstanceExtensionProperties)(void); #endif /* SDL_VIDEO_VULKAN */ diff --git a/src/video/SDL_vulkan_utils.c b/src/video/SDL_vulkan_utils.c index c7176e3dc..257a3ca37 100644 --- a/src/video/SDL_vulkan_utils.c +++ b/src/video/SDL_vulkan_utils.c @@ -28,88 +28,88 @@ const char *SDL_Vulkan_GetResultString(VkResult result) { switch ((int)result) { - case VK_SUCCESS: - return "VK_SUCCESS"; - case VK_NOT_READY: - return "VK_NOT_READY"; - case VK_TIMEOUT: - return "VK_TIMEOUT"; - case VK_EVENT_SET: - return "VK_EVENT_SET"; - case VK_EVENT_RESET: - return "VK_EVENT_RESET"; - case VK_INCOMPLETE: - return "VK_INCOMPLETE"; - case VK_ERROR_OUT_OF_HOST_MEMORY: - return "VK_ERROR_OUT_OF_HOST_MEMORY"; - case VK_ERROR_OUT_OF_DEVICE_MEMORY: - return "VK_ERROR_OUT_OF_DEVICE_MEMORY"; - case VK_ERROR_INITIALIZATION_FAILED: - return "VK_ERROR_INITIALIZATION_FAILED"; - case VK_ERROR_DEVICE_LOST: - return "VK_ERROR_DEVICE_LOST"; - case VK_ERROR_MEMORY_MAP_FAILED: - return "VK_ERROR_MEMORY_MAP_FAILED"; - case VK_ERROR_LAYER_NOT_PRESENT: - return "VK_ERROR_LAYER_NOT_PRESENT"; - case VK_ERROR_EXTENSION_NOT_PRESENT: - return "VK_ERROR_EXTENSION_NOT_PRESENT"; - case VK_ERROR_FEATURE_NOT_PRESENT: - return "VK_ERROR_FEATURE_NOT_PRESENT"; - case VK_ERROR_INCOMPATIBLE_DRIVER: - return "VK_ERROR_INCOMPATIBLE_DRIVER"; - case VK_ERROR_TOO_MANY_OBJECTS: - return "VK_ERROR_TOO_MANY_OBJECTS"; - case VK_ERROR_FORMAT_NOT_SUPPORTED: - return "VK_ERROR_FORMAT_NOT_SUPPORTED"; - case VK_ERROR_FRAGMENTED_POOL: - return "VK_ERROR_FRAGMENTED_POOL"; - case VK_ERROR_UNKNOWN: - return "VK_ERROR_UNKNOWN"; - case VK_ERROR_OUT_OF_POOL_MEMORY: - return "VK_ERROR_OUT_OF_POOL_MEMORY"; - case VK_ERROR_INVALID_EXTERNAL_HANDLE: - return "VK_ERROR_INVALID_EXTERNAL_HANDLE"; - case VK_ERROR_FRAGMENTATION: - return "VK_ERROR_FRAGMENTATION"; - case VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS: - return "VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS"; - case VK_ERROR_SURFACE_LOST_KHR: - return "VK_ERROR_SURFACE_LOST_KHR"; - case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR: - return "VK_ERROR_NATIVE_WINDOW_IN_USE_KHR"; - case VK_SUBOPTIMAL_KHR: - return "VK_SUBOPTIMAL_KHR"; - case VK_ERROR_OUT_OF_DATE_KHR: - return "VK_ERROR_OUT_OF_DATE_KHR"; - case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR: - return "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR"; - case VK_ERROR_VALIDATION_FAILED_EXT: - return "VK_ERROR_VALIDATION_FAILED_EXT"; - case VK_ERROR_INVALID_SHADER_NV: - return "VK_ERROR_INVALID_SHADER_NV"; + case VK_SUCCESS: + return "VK_SUCCESS"; + case VK_NOT_READY: + return "VK_NOT_READY"; + case VK_TIMEOUT: + return "VK_TIMEOUT"; + case VK_EVENT_SET: + return "VK_EVENT_SET"; + case VK_EVENT_RESET: + return "VK_EVENT_RESET"; + case VK_INCOMPLETE: + return "VK_INCOMPLETE"; + case VK_ERROR_OUT_OF_HOST_MEMORY: + return "VK_ERROR_OUT_OF_HOST_MEMORY"; + case VK_ERROR_OUT_OF_DEVICE_MEMORY: + return "VK_ERROR_OUT_OF_DEVICE_MEMORY"; + case VK_ERROR_INITIALIZATION_FAILED: + return "VK_ERROR_INITIALIZATION_FAILED"; + case VK_ERROR_DEVICE_LOST: + return "VK_ERROR_DEVICE_LOST"; + case VK_ERROR_MEMORY_MAP_FAILED: + return "VK_ERROR_MEMORY_MAP_FAILED"; + case VK_ERROR_LAYER_NOT_PRESENT: + return "VK_ERROR_LAYER_NOT_PRESENT"; + case VK_ERROR_EXTENSION_NOT_PRESENT: + return "VK_ERROR_EXTENSION_NOT_PRESENT"; + case VK_ERROR_FEATURE_NOT_PRESENT: + return "VK_ERROR_FEATURE_NOT_PRESENT"; + case VK_ERROR_INCOMPATIBLE_DRIVER: + return "VK_ERROR_INCOMPATIBLE_DRIVER"; + case VK_ERROR_TOO_MANY_OBJECTS: + return "VK_ERROR_TOO_MANY_OBJECTS"; + case VK_ERROR_FORMAT_NOT_SUPPORTED: + return "VK_ERROR_FORMAT_NOT_SUPPORTED"; + case VK_ERROR_FRAGMENTED_POOL: + return "VK_ERROR_FRAGMENTED_POOL"; + case VK_ERROR_UNKNOWN: + return "VK_ERROR_UNKNOWN"; + case VK_ERROR_OUT_OF_POOL_MEMORY: + return "VK_ERROR_OUT_OF_POOL_MEMORY"; + case VK_ERROR_INVALID_EXTERNAL_HANDLE: + return "VK_ERROR_INVALID_EXTERNAL_HANDLE"; + case VK_ERROR_FRAGMENTATION: + return "VK_ERROR_FRAGMENTATION"; + case VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS: + return "VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS"; + case VK_ERROR_SURFACE_LOST_KHR: + return "VK_ERROR_SURFACE_LOST_KHR"; + case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR: + return "VK_ERROR_NATIVE_WINDOW_IN_USE_KHR"; + case VK_SUBOPTIMAL_KHR: + return "VK_SUBOPTIMAL_KHR"; + case VK_ERROR_OUT_OF_DATE_KHR: + return "VK_ERROR_OUT_OF_DATE_KHR"; + case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR: + return "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR"; + case VK_ERROR_VALIDATION_FAILED_EXT: + return "VK_ERROR_VALIDATION_FAILED_EXT"; + case VK_ERROR_INVALID_SHADER_NV: + return "VK_ERROR_INVALID_SHADER_NV"; #if VK_HEADER_VERSION >= 135 && VK_HEADER_VERSION < 162 - case VK_ERROR_INCOMPATIBLE_VERSION_KHR: - return "VK_ERROR_INCOMPATIBLE_VERSION_KHR"; + case VK_ERROR_INCOMPATIBLE_VERSION_KHR: + return "VK_ERROR_INCOMPATIBLE_VERSION_KHR"; #endif - case VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT: - return "VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT"; - case VK_ERROR_NOT_PERMITTED_EXT: - return "VK_ERROR_NOT_PERMITTED_EXT"; - case VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT: - return "VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT"; - case VK_THREAD_IDLE_KHR: - return "VK_THREAD_IDLE_KHR"; - case VK_THREAD_DONE_KHR: - return "VK_THREAD_DONE_KHR"; - case VK_OPERATION_DEFERRED_KHR: - return "VK_OPERATION_DEFERRED_KHR"; - case VK_OPERATION_NOT_DEFERRED_KHR: - return "VK_OPERATION_NOT_DEFERRED_KHR"; - case VK_PIPELINE_COMPILE_REQUIRED_EXT: - return "VK_PIPELINE_COMPILE_REQUIRED_EXT"; - default: - break; + case VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT: + return "VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT"; + case VK_ERROR_NOT_PERMITTED_EXT: + return "VK_ERROR_NOT_PERMITTED_EXT"; + case VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT: + return "VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT"; + case VK_THREAD_IDLE_KHR: + return "VK_THREAD_IDLE_KHR"; + case VK_THREAD_DONE_KHR: + return "VK_THREAD_DONE_KHR"; + case VK_OPERATION_DEFERRED_KHR: + return "VK_OPERATION_DEFERRED_KHR"; + case VK_OPERATION_NOT_DEFERRED_KHR: + return "VK_OPERATION_NOT_DEFERRED_KHR"; + case VK_PIPELINE_COMPILE_REQUIRED_EXT: + return "VK_PIPELINE_COMPILE_REQUIRED_EXT"; + default: + break; } if (result < 0) { return "VK_ERROR_"; @@ -198,12 +198,12 @@ static const VkDisplayPlaneAlphaFlagBitsKHR alphaModes[4] = { }; SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, - VkInstance instance, - VkSurfaceKHR *surface) + VkInstance instance, + VkSurfaceKHR *surface) { PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)vkGetInstanceProcAddr_; -#define VULKAN_INSTANCE_FUNCTION(name) \ +#define VULKAN_INSTANCE_FUNCTION(name) \ PFN_##name name = (PFN_##name)vkGetInstanceProcAddr((VkInstance)instance, #name) VULKAN_INSTANCE_FUNCTION(vkEnumeratePhysicalDevices); VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceDisplayPropertiesKHR); @@ -222,12 +222,12 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, int displayId = 0; /* Counting from physical device 0, display 0 */ if (!vkEnumeratePhysicalDevices || - !vkGetPhysicalDeviceDisplayPropertiesKHR || - !vkGetDisplayModePropertiesKHR || - !vkGetPhysicalDeviceDisplayPlanePropertiesKHR || - !vkGetDisplayPlaneCapabilitiesKHR || - !vkGetDisplayPlaneSupportedDisplaysKHR || - !vkCreateDisplayPlaneSurfaceKHR) { + !vkGetPhysicalDeviceDisplayPropertiesKHR || + !vkGetDisplayModePropertiesKHR || + !vkGetPhysicalDeviceDisplayPlanePropertiesKHR || + !vkGetDisplayPlaneCapabilitiesKHR || + !vkGetDisplayPlaneSupportedDisplaysKHR || + !vkCreateDisplayPlaneSurfaceKHR) { SDL_SetError(VK_KHR_DISPLAY_EXTENSION_NAME " extension is not enabled in the Vulkan instance."); goto error; } @@ -283,9 +283,9 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, continue; } SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display properties for device %u: %u", - physicalDeviceIndex, displayPropertiesCount); + physicalDeviceIndex, displayPropertiesCount); - if (displayId < 0 || (uint32_t) displayId >= displayPropertiesCount) { + if (displayId < 0 || (uint32_t)displayId >= displayPropertiesCount) { /* Display id specified was higher than number of available displays, move to next physical device. */ displayId -= displayPropertiesCount; continue; @@ -307,7 +307,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, display = displayProperties[displayId].display; extent = displayProperties[displayId].physicalResolution; SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Display: %s Native resolution: %ux%u", - displayProperties[displayId].displayName, extent.width, extent.height); + displayProperties[displayId].displayName, extent.width, extent.height); SDL_free(displayProperties); displayProperties = NULL; @@ -352,9 +352,9 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, SDL_zero(createInfo); createInfo.displayMode = displayModeProperties[bestMatchIndex].displayMode; SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Matching mode %ux%u with refresh rate %u", - displayModeProperties[bestMatchIndex].parameters.visibleRegion.width, - displayModeProperties[bestMatchIndex].parameters.visibleRegion.height, - refreshRate); + displayModeProperties[bestMatchIndex].parameters.visibleRegion.width, + displayModeProperties[bestMatchIndex].parameters.visibleRegion.height, + refreshRate); SDL_free(displayModeProperties); displayModeProperties = NULL; @@ -393,7 +393,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, /* Check supported displays for this plane. */ result = vkGetDisplayPlaneSupportedDisplaysKHR(physicalDevice, i, &planeSupportedDisplaysCount, NULL); if (result != VK_SUCCESS || planeSupportedDisplaysCount == 0) { - continue; /* No supported displays, on to next plane. */ + continue; /* No supported displays, on to next plane. */ } SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of supported displays for plane %u: %u", i, planeSupportedDisplaysCount); @@ -436,8 +436,8 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, extent.width <= planeCaps.maxDstExtent.width && extent.height <= planeCaps.maxDstExtent.height) { /* If it does, choose this plane. */ SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Choosing plane %d, minimum extent %dx%d maximum extent %dx%d", i, - planeCaps.minDstExtent.width, planeCaps.minDstExtent.height, - planeCaps.maxDstExtent.width, planeCaps.maxDstExtent.height); + planeCaps.minDstExtent.width, planeCaps.minDstExtent.height, + planeCaps.maxDstExtent.width, planeCaps.maxDstExtent.height); planeIndex = i; break; } diff --git a/src/video/SDL_yuv.c b/src/video/SDL_yuv.c index be3ee0c57..275674282 100644 --- a/src/video/SDL_yuv.c +++ b/src/video/SDL_yuv.c @@ -27,12 +27,10 @@ #include "yuv2rgb/yuv_rgb.h" -#define SDL_YUV_SD_THRESHOLD 576 - +#define SDL_YUV_SD_THRESHOLD 576 static SDL_YUV_CONVERSION_MODE SDL_YUV_ConversionMode = SDL_YUV_CONVERSION_BT601; - void SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode) { SDL_YUV_ConversionMode = mode; @@ -178,9 +176,9 @@ static int GetYUVPlanes(int width, int height, Uint32 format, const void *yuv, i static SDL_bool yuv_rgb_sse( Uint32 src_format, Uint32 dst_format, - Uint32 width, Uint32 height, - const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride, - Uint8 *rgb, Uint32 rgb_stride, + Uint32 width, Uint32 height, + const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride, + Uint8 *rgb, Uint32 rgb_stride, YCbCrType yuv_type) { #ifdef __SSE2__ @@ -329,9 +327,9 @@ static SDL_bool yuv_rgb_lsx( static SDL_bool yuv_rgb_std( Uint32 src_format, Uint32 dst_format, - Uint32 width, Uint32 height, - const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride, - Uint8 *rgb, Uint32 rgb_stride, + Uint32 width, Uint32 height, + const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride, + Uint8 *rgb, Uint32 rgb_stride, YCbCrType yuv_type) { if (src_format == SDL_PIXELFORMAT_YV12 || @@ -430,10 +428,9 @@ static SDL_bool yuv_rgb_std( return SDL_FALSE; } -int -SDL_ConvertPixels_YUV_to_RGB(int width, int height, - Uint32 src_format, const void *src, int src_pitch, - Uint32 dst_format, void *dst, int dst_pitch) +int SDL_ConvertPixels_YUV_to_RGB(int width, int height, + Uint32 src_format, const void *src, int src_pitch, + Uint32 dst_format, void *dst, int dst_pitch) { const Uint8 *y = NULL; const Uint8 *u = NULL; @@ -450,15 +447,15 @@ SDL_ConvertPixels_YUV_to_RGB(int width, int height, return -1; } - if (yuv_rgb_sse(src_format, dst_format, width, height, y, u, v, y_stride, uv_stride, (Uint8*)dst, dst_pitch, yuv_type)) { + if (yuv_rgb_sse(src_format, dst_format, width, height, y, u, v, y_stride, uv_stride, (Uint8 *)dst, dst_pitch, yuv_type)) { return 0; } - if (yuv_rgb_lsx(src_format, dst_format, width, height, y, u, v, y_stride, uv_stride, (Uint8*)dst, dst_pitch, yuv_type)) { + if (yuv_rgb_lsx(src_format, dst_format, width, height, y, u, v, y_stride, uv_stride, (Uint8 *)dst, dst_pitch, yuv_type)) { return 0; } - if (yuv_rgb_std(src_format, dst_format, width, height, y, u, v, y_stride, uv_stride, (Uint8*)dst, dst_pitch, yuv_type)) { + if (yuv_rgb_std(src_format, dst_format, width, height, y, u, v, y_stride, uv_stride, (Uint8 *)dst, dst_pitch, yuv_type)) { return 0; } @@ -497,37 +494,35 @@ struct RGB2YUVFactors float v[3]; /* Rfactor, Gfactor, Bfactor */ }; -static int -SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch) +static int SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch) { - const int src_pitch_x_2 = src_pitch * 2; - const int height_half = height / 2; + const int src_pitch_x_2 = src_pitch * 2; + const int height_half = height / 2; const int height_remainder = (height & 0x1); - const int width_half = width / 2; - const int width_remainder = (width & 0x1); + const int width_half = width / 2; + const int width_remainder = (width & 0x1); int i, j; - - static struct RGB2YUVFactors RGB2YUVFactorTables[SDL_YUV_CONVERSION_BT709 + 1] = - { + + static struct RGB2YUVFactors RGB2YUVFactorTables[SDL_YUV_CONVERSION_BT709 + 1] = { /* ITU-T T.871 (JPEG) */ { 0, - { 0.2990f, 0.5870f, 0.1140f }, - { -0.1687f, -0.3313f, 0.5000f }, - { 0.5000f, -0.4187f, -0.0813f }, + { 0.2990f, 0.5870f, 0.1140f }, + { -0.1687f, -0.3313f, 0.5000f }, + { 0.5000f, -0.4187f, -0.0813f }, }, /* ITU-R BT.601-7 */ { 16, - { 0.2568f, 0.5041f, 0.0979f }, - { -0.1482f, -0.2910f, 0.4392f }, - { 0.4392f, -0.3678f, -0.0714f }, + { 0.2568f, 0.5041f, 0.0979f }, + { -0.1482f, -0.2910f, 0.4392f }, + { 0.4392f, -0.3678f, -0.0714f }, }, /* ITU-R BT.709-6 */ { 16, - { 0.1826f, 0.6142f, 0.0620f }, - {-0.1006f, -0.3386f, 0.4392f }, + { 0.1826f, 0.6142f, 0.0620f }, + { -0.1006f, -0.3386f, 0.4392f }, { 0.4392f, -0.3989f, -0.0403f }, }, }; @@ -537,269 +532,266 @@ SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void *src, int sr #define MAKE_U(r, g, b) (Uint8)((int)(cvt->u[0] * (r) + cvt->u[1] * (g) + cvt->u[2] * (b) + 0.5f) + 128) #define MAKE_V(r, g, b) (Uint8)((int)(cvt->v[0] * (r) + cvt->v[1] * (g) + cvt->v[2] * (b) + 0.5f) + 128) -#define READ_2x2_PIXELS \ - const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i]; \ - const Uint32 p2 = ((const Uint32 *)curr_row)[2 * i + 1]; \ - const Uint32 p3 = ((const Uint32 *)next_row)[2 * i]; \ - const Uint32 p4 = ((const Uint32 *)next_row)[2 * i + 1]; \ - const Uint32 r = ((p1 & 0x00ff0000) + (p2 & 0x00ff0000) + (p3 & 0x00ff0000) + (p4 & 0x00ff0000)) >> 18; \ - const Uint32 g = ((p1 & 0x0000ff00) + (p2 & 0x0000ff00) + (p3 & 0x0000ff00) + (p4 & 0x0000ff00)) >> 10; \ - const Uint32 b = ((p1 & 0x000000ff) + (p2 & 0x000000ff) + (p3 & 0x000000ff) + (p4 & 0x000000ff)) >> 2; \ +#define READ_2x2_PIXELS \ + const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i]; \ + const Uint32 p2 = ((const Uint32 *)curr_row)[2 * i + 1]; \ + const Uint32 p3 = ((const Uint32 *)next_row)[2 * i]; \ + const Uint32 p4 = ((const Uint32 *)next_row)[2 * i + 1]; \ + const Uint32 r = ((p1 & 0x00ff0000) + (p2 & 0x00ff0000) + (p3 & 0x00ff0000) + (p4 & 0x00ff0000)) >> 18; \ + const Uint32 g = ((p1 & 0x0000ff00) + (p2 & 0x0000ff00) + (p3 & 0x0000ff00) + (p4 & 0x0000ff00)) >> 10; \ + const Uint32 b = ((p1 & 0x000000ff) + (p2 & 0x000000ff) + (p3 & 0x000000ff) + (p4 & 0x000000ff)) >> 2; -#define READ_2x1_PIXELS \ - const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i]; \ - const Uint32 p2 = ((const Uint32 *)next_row)[2 * i]; \ - const Uint32 r = ((p1 & 0x00ff0000) + (p2 & 0x00ff0000)) >> 17; \ - const Uint32 g = ((p1 & 0x0000ff00) + (p2 & 0x0000ff00)) >> 9; \ - const Uint32 b = ((p1 & 0x000000ff) + (p2 & 0x000000ff)) >> 1; \ +#define READ_2x1_PIXELS \ + const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i]; \ + const Uint32 p2 = ((const Uint32 *)next_row)[2 * i]; \ + const Uint32 r = ((p1 & 0x00ff0000) + (p2 & 0x00ff0000)) >> 17; \ + const Uint32 g = ((p1 & 0x0000ff00) + (p2 & 0x0000ff00)) >> 9; \ + const Uint32 b = ((p1 & 0x000000ff) + (p2 & 0x000000ff)) >> 1; -#define READ_1x2_PIXELS \ - const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i]; \ - const Uint32 p2 = ((const Uint32 *)curr_row)[2 * i + 1]; \ - const Uint32 r = ((p1 & 0x00ff0000) + (p2 & 0x00ff0000)) >> 17; \ - const Uint32 g = ((p1 & 0x0000ff00) + (p2 & 0x0000ff00)) >> 9; \ - const Uint32 b = ((p1 & 0x000000ff) + (p2 & 0x000000ff)) >> 1; \ +#define READ_1x2_PIXELS \ + const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i]; \ + const Uint32 p2 = ((const Uint32 *)curr_row)[2 * i + 1]; \ + const Uint32 r = ((p1 & 0x00ff0000) + (p2 & 0x00ff0000)) >> 17; \ + const Uint32 g = ((p1 & 0x0000ff00) + (p2 & 0x0000ff00)) >> 9; \ + const Uint32 b = ((p1 & 0x000000ff) + (p2 & 0x000000ff)) >> 1; -#define READ_1x1_PIXEL \ - const Uint32 p = ((const Uint32 *)curr_row)[2 * i]; \ - const Uint32 r = (p & 0x00ff0000) >> 16; \ - const Uint32 g = (p & 0x0000ff00) >> 8; \ - const Uint32 b = (p & 0x000000ff); \ +#define READ_1x1_PIXEL \ + const Uint32 p = ((const Uint32 *)curr_row)[2 * i]; \ + const Uint32 r = (p & 0x00ff0000) >> 16; \ + const Uint32 g = (p & 0x0000ff00) >> 8; \ + const Uint32 b = (p & 0x000000ff); -#define READ_TWO_RGB_PIXELS \ - const Uint32 p = ((const Uint32 *)curr_row)[2 * i]; \ - const Uint32 r = (p & 0x00ff0000) >> 16; \ - const Uint32 g = (p & 0x0000ff00) >> 8; \ - const Uint32 b = (p & 0x000000ff); \ - const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i + 1]; \ - const Uint32 r1 = (p1 & 0x00ff0000) >> 16; \ - const Uint32 g1 = (p1 & 0x0000ff00) >> 8; \ - const Uint32 b1 = (p1 & 0x000000ff); \ - const Uint32 R = (r + r1)/2; \ - const Uint32 G = (g + g1)/2; \ - const Uint32 B = (b + b1)/2; \ +#define READ_TWO_RGB_PIXELS \ + const Uint32 p = ((const Uint32 *)curr_row)[2 * i]; \ + const Uint32 r = (p & 0x00ff0000) >> 16; \ + const Uint32 g = (p & 0x0000ff00) >> 8; \ + const Uint32 b = (p & 0x000000ff); \ + const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i + 1]; \ + const Uint32 r1 = (p1 & 0x00ff0000) >> 16; \ + const Uint32 g1 = (p1 & 0x0000ff00) >> 8; \ + const Uint32 b1 = (p1 & 0x000000ff); \ + const Uint32 R = (r + r1) / 2; \ + const Uint32 G = (g + g1) / 2; \ + const Uint32 B = (b + b1) / 2; -#define READ_ONE_RGB_PIXEL READ_1x1_PIXEL +#define READ_ONE_RGB_PIXEL READ_1x1_PIXEL - switch (dst_format) - { + switch (dst_format) { case SDL_PIXELFORMAT_YV12: case SDL_PIXELFORMAT_IYUV: case SDL_PIXELFORMAT_NV12: case SDL_PIXELFORMAT_NV21: - { - const Uint8 *curr_row, *next_row; - - Uint8 *plane_y; - Uint8 *plane_u; - Uint8 *plane_v; - Uint8 *plane_interleaved_uv; - Uint32 y_stride, uv_stride, y_skip, uv_skip; + { + const Uint8 *curr_row, *next_row; - if (GetYUVPlanes(width, height, dst_format, dst, dst_pitch, - (const Uint8 **)&plane_y, (const Uint8 **)&plane_u, (const Uint8 **)&plane_v, - &y_stride, &uv_stride) != 0) { - return -1; + Uint8 *plane_y; + Uint8 *plane_u; + Uint8 *plane_v; + Uint8 *plane_interleaved_uv; + Uint32 y_stride, uv_stride, y_skip, uv_skip; + + if (GetYUVPlanes(width, height, dst_format, dst, dst_pitch, + (const Uint8 **)&plane_y, (const Uint8 **)&plane_u, (const Uint8 **)&plane_v, + &y_stride, &uv_stride) != 0) { + return -1; + } + + plane_interleaved_uv = (plane_y + height * y_stride); + y_skip = (y_stride - width); + + curr_row = (const Uint8 *)src; + + /* Write Y plane */ + for (j = 0; j < height; j++) { + for (i = 0; i < width; i++) { + const Uint32 p1 = ((const Uint32 *)curr_row)[i]; + const Uint32 r = (p1 & 0x00ff0000) >> 16; + const Uint32 g = (p1 & 0x0000ff00) >> 8; + const Uint32 b = (p1 & 0x000000ff); + *plane_y++ = MAKE_Y(r, g, b); } + plane_y += y_skip; + curr_row += src_pitch; + } - plane_interleaved_uv = (plane_y + height * y_stride); - y_skip = (y_stride - width); + curr_row = (const Uint8 *)src; + next_row = (const Uint8 *)src; + next_row += src_pitch; - curr_row = (const Uint8*)src; - - /* Write Y plane */ - for (j = 0; j < height; j++) { - for (i = 0; i < width; i++) { - const Uint32 p1 = ((const Uint32 *)curr_row)[i]; - const Uint32 r = (p1 & 0x00ff0000) >> 16; - const Uint32 g = (p1 & 0x0000ff00) >> 8; - const Uint32 b = (p1 & 0x000000ff); - *plane_y++ = MAKE_Y(r, g, b); + if (dst_format == SDL_PIXELFORMAT_YV12 || dst_format == SDL_PIXELFORMAT_IYUV) { + /* Write UV planes, not interleaved */ + uv_skip = (uv_stride - (width + 1) / 2); + for (j = 0; j < height_half; j++) { + for (i = 0; i < width_half; i++) { + READ_2x2_PIXELS; + *plane_u++ = MAKE_U(r, g, b); + *plane_v++ = MAKE_V(r, g, b); } - plane_y += y_skip; - curr_row += src_pitch; + if (width_remainder) { + READ_2x1_PIXELS; + *plane_u++ = MAKE_U(r, g, b); + *plane_v++ = MAKE_V(r, g, b); + } + plane_u += uv_skip; + plane_v += uv_skip; + curr_row += src_pitch_x_2; + next_row += src_pitch_x_2; } - - curr_row = (const Uint8*)src; - next_row = (const Uint8*)src; - next_row += src_pitch; - - if (dst_format == SDL_PIXELFORMAT_YV12 || dst_format == SDL_PIXELFORMAT_IYUV) { - /* Write UV planes, not interleaved */ - uv_skip = (uv_stride - (width + 1)/2); - for (j = 0; j < height_half; j++) { - for (i = 0; i < width_half; i++) { - READ_2x2_PIXELS; - *plane_u++ = MAKE_U(r, g, b); - *plane_v++ = MAKE_V(r, g, b); - } - if (width_remainder) { - READ_2x1_PIXELS; - *plane_u++ = MAKE_U(r, g, b); - *plane_v++ = MAKE_V(r, g, b); - } - plane_u += uv_skip; - plane_v += uv_skip; - curr_row += src_pitch_x_2; - next_row += src_pitch_x_2; + if (height_remainder) { + for (i = 0; i < width_half; i++) { + READ_1x2_PIXELS; + *plane_u++ = MAKE_U(r, g, b); + *plane_v++ = MAKE_V(r, g, b); } - if (height_remainder) { - for (i = 0; i < width_half; i++) { - READ_1x2_PIXELS; - *plane_u++ = MAKE_U(r, g, b); - *plane_v++ = MAKE_V(r, g, b); - } - if (width_remainder) { - READ_1x1_PIXEL; - *plane_u++ = MAKE_U(r, g, b); - *plane_v++ = MAKE_V(r, g, b); - } - plane_u += uv_skip; - plane_v += uv_skip; + if (width_remainder) { + READ_1x1_PIXEL; + *plane_u++ = MAKE_U(r, g, b); + *plane_v++ = MAKE_V(r, g, b); } - } else if (dst_format == SDL_PIXELFORMAT_NV12) { - uv_skip = (uv_stride - ((width + 1)/2)*2); - for (j = 0; j < height_half; j++) { - for (i = 0; i < width_half; i++) { - READ_2x2_PIXELS; - *plane_interleaved_uv++ = MAKE_U(r, g, b); - *plane_interleaved_uv++ = MAKE_V(r, g, b); - } - if (width_remainder) { - READ_2x1_PIXELS; - *plane_interleaved_uv++ = MAKE_U(r, g, b); - *plane_interleaved_uv++ = MAKE_V(r, g, b); - } - plane_interleaved_uv += uv_skip; - curr_row += src_pitch_x_2; - next_row += src_pitch_x_2; + plane_u += uv_skip; + plane_v += uv_skip; + } + } else if (dst_format == SDL_PIXELFORMAT_NV12) { + uv_skip = (uv_stride - ((width + 1) / 2) * 2); + for (j = 0; j < height_half; j++) { + for (i = 0; i < width_half; i++) { + READ_2x2_PIXELS; + *plane_interleaved_uv++ = MAKE_U(r, g, b); + *plane_interleaved_uv++ = MAKE_V(r, g, b); } - if (height_remainder) { - for (i = 0; i < width_half; i++) { - READ_1x2_PIXELS; - *plane_interleaved_uv++ = MAKE_U(r, g, b); - *plane_interleaved_uv++ = MAKE_V(r, g, b); - } - if (width_remainder) { - READ_1x1_PIXEL; - *plane_interleaved_uv++ = MAKE_U(r, g, b); - *plane_interleaved_uv++ = MAKE_V(r, g, b); - } + if (width_remainder) { + READ_2x1_PIXELS; + *plane_interleaved_uv++ = MAKE_U(r, g, b); + *plane_interleaved_uv++ = MAKE_V(r, g, b); } - } else /* dst_format == SDL_PIXELFORMAT_NV21 */ { - uv_skip = (uv_stride - ((width + 1)/2)*2); - for (j = 0; j < height_half; j++) { - for (i = 0; i < width_half; i++) { - READ_2x2_PIXELS; - *plane_interleaved_uv++ = MAKE_V(r, g, b); - *plane_interleaved_uv++ = MAKE_U(r, g, b); - } - if (width_remainder) { - READ_2x1_PIXELS; - *plane_interleaved_uv++ = MAKE_V(r, g, b); - *plane_interleaved_uv++ = MAKE_U(r, g, b); - } - plane_interleaved_uv += uv_skip; - curr_row += src_pitch_x_2; - next_row += src_pitch_x_2; + plane_interleaved_uv += uv_skip; + curr_row += src_pitch_x_2; + next_row += src_pitch_x_2; + } + if (height_remainder) { + for (i = 0; i < width_half; i++) { + READ_1x2_PIXELS; + *plane_interleaved_uv++ = MAKE_U(r, g, b); + *plane_interleaved_uv++ = MAKE_V(r, g, b); } - if (height_remainder) { - for (i = 0; i < width_half; i++) { - READ_1x2_PIXELS; - *plane_interleaved_uv++ = MAKE_V(r, g, b); - *plane_interleaved_uv++ = MAKE_U(r, g, b); - } - if (width_remainder) { - READ_1x1_PIXEL; - *plane_interleaved_uv++ = MAKE_V(r, g, b); - *plane_interleaved_uv++ = MAKE_U(r, g, b); - } + if (width_remainder) { + READ_1x1_PIXEL; + *plane_interleaved_uv++ = MAKE_U(r, g, b); + *plane_interleaved_uv++ = MAKE_V(r, g, b); + } + } + } else /* dst_format == SDL_PIXELFORMAT_NV21 */ { + uv_skip = (uv_stride - ((width + 1) / 2) * 2); + for (j = 0; j < height_half; j++) { + for (i = 0; i < width_half; i++) { + READ_2x2_PIXELS; + *plane_interleaved_uv++ = MAKE_V(r, g, b); + *plane_interleaved_uv++ = MAKE_U(r, g, b); + } + if (width_remainder) { + READ_2x1_PIXELS; + *plane_interleaved_uv++ = MAKE_V(r, g, b); + *plane_interleaved_uv++ = MAKE_U(r, g, b); + } + plane_interleaved_uv += uv_skip; + curr_row += src_pitch_x_2; + next_row += src_pitch_x_2; + } + if (height_remainder) { + for (i = 0; i < width_half; i++) { + READ_1x2_PIXELS; + *plane_interleaved_uv++ = MAKE_V(r, g, b); + *plane_interleaved_uv++ = MAKE_U(r, g, b); + } + if (width_remainder) { + READ_1x1_PIXEL; + *plane_interleaved_uv++ = MAKE_V(r, g, b); + *plane_interleaved_uv++ = MAKE_U(r, g, b); } } } - break; + } break; case SDL_PIXELFORMAT_YUY2: case SDL_PIXELFORMAT_UYVY: case SDL_PIXELFORMAT_YVYU: - { - const Uint8 *curr_row = (const Uint8*) src; - Uint8 *plane = (Uint8*) dst; - const int row_size = (4 * ((width + 1) / 2)); - int plane_skip; + { + const Uint8 *curr_row = (const Uint8 *)src; + Uint8 *plane = (Uint8 *)dst; + const int row_size = (4 * ((width + 1) / 2)); + int plane_skip; - if (dst_pitch < row_size) { - return SDL_SetError("Destination pitch is too small, expected at least %d\n", row_size); + if (dst_pitch < row_size) { + return SDL_SetError("Destination pitch is too small, expected at least %d\n", row_size); + } + plane_skip = (dst_pitch - row_size); + + /* Write YUV plane, packed */ + if (dst_format == SDL_PIXELFORMAT_YUY2) { + for (j = 0; j < height; j++) { + for (i = 0; i < width_half; i++) { + READ_TWO_RGB_PIXELS; + /* Y U Y1 V */ + *plane++ = MAKE_Y(r, g, b); + *plane++ = MAKE_U(R, G, B); + *plane++ = MAKE_Y(r1, g1, b1); + *plane++ = MAKE_V(R, G, B); + } + if (width_remainder) { + READ_ONE_RGB_PIXEL; + /* Y U Y V */ + *plane++ = MAKE_Y(r, g, b); + *plane++ = MAKE_U(r, g, b); + *plane++ = MAKE_Y(r, g, b); + *plane++ = MAKE_V(r, g, b); + } + plane += plane_skip; + curr_row += src_pitch; } - plane_skip = (dst_pitch - row_size); - - /* Write YUV plane, packed */ - if (dst_format == SDL_PIXELFORMAT_YUY2) { - for (j = 0; j < height; j++) { - for (i = 0; i < width_half; i++) { - READ_TWO_RGB_PIXELS; - /* Y U Y1 V */ - *plane++ = MAKE_Y(r, g, b); - *plane++ = MAKE_U(R, G, B); - *plane++ = MAKE_Y(r1, g1, b1); - *plane++ = MAKE_V(R, G, B); - } - if (width_remainder) { - READ_ONE_RGB_PIXEL; - /* Y U Y V */ - *plane++ = MAKE_Y(r, g, b); - *plane++ = MAKE_U(r, g, b); - *plane++ = MAKE_Y(r, g, b); - *plane++ = MAKE_V(r, g, b); - } - plane += plane_skip; - curr_row += src_pitch; + } else if (dst_format == SDL_PIXELFORMAT_UYVY) { + for (j = 0; j < height; j++) { + for (i = 0; i < width_half; i++) { + READ_TWO_RGB_PIXELS; + /* U Y V Y1 */ + *plane++ = MAKE_U(R, G, B); + *plane++ = MAKE_Y(r, g, b); + *plane++ = MAKE_V(R, G, B); + *plane++ = MAKE_Y(r1, g1, b1); } - } else if (dst_format == SDL_PIXELFORMAT_UYVY) { - for (j = 0; j < height; j++) { - for (i = 0; i < width_half; i++) { - READ_TWO_RGB_PIXELS; - /* U Y V Y1 */ - *plane++ = MAKE_U(R, G, B); - *plane++ = MAKE_Y(r, g, b); - *plane++ = MAKE_V(R, G, B); - *plane++ = MAKE_Y(r1, g1, b1); - } - if (width_remainder) { - READ_ONE_RGB_PIXEL; - /* U Y V Y */ - *plane++ = MAKE_U(r, g, b); - *plane++ = MAKE_Y(r, g, b); - *plane++ = MAKE_V(r, g, b); - *plane++ = MAKE_Y(r, g, b); - } - plane += plane_skip; - curr_row += src_pitch; + if (width_remainder) { + READ_ONE_RGB_PIXEL; + /* U Y V Y */ + *plane++ = MAKE_U(r, g, b); + *plane++ = MAKE_Y(r, g, b); + *plane++ = MAKE_V(r, g, b); + *plane++ = MAKE_Y(r, g, b); } - } else if (dst_format == SDL_PIXELFORMAT_YVYU) { - for (j = 0; j < height; j++) { - for (i = 0; i < width_half; i++) { - READ_TWO_RGB_PIXELS; - /* Y V Y1 U */ - *plane++ = MAKE_Y(r, g, b); - *plane++ = MAKE_V(R, G, B); - *plane++ = MAKE_Y(r1, g1, b1); - *plane++ = MAKE_U(R, G, B); - } - if (width_remainder) { - READ_ONE_RGB_PIXEL; - /* Y V Y U */ - *plane++ = MAKE_Y(r, g, b); - *plane++ = MAKE_V(r, g, b); - *plane++ = MAKE_Y(r, g, b); - *plane++ = MAKE_U(r, g, b); - } - plane += plane_skip; - curr_row += src_pitch; + plane += plane_skip; + curr_row += src_pitch; + } + } else if (dst_format == SDL_PIXELFORMAT_YVYU) { + for (j = 0; j < height; j++) { + for (i = 0; i < width_half; i++) { + READ_TWO_RGB_PIXELS; + /* Y V Y1 U */ + *plane++ = MAKE_Y(r, g, b); + *plane++ = MAKE_V(R, G, B); + *plane++ = MAKE_Y(r1, g1, b1); + *plane++ = MAKE_U(R, G, B); } + if (width_remainder) { + READ_ONE_RGB_PIXEL; + /* Y V Y U */ + *plane++ = MAKE_Y(r, g, b); + *plane++ = MAKE_V(r, g, b); + *plane++ = MAKE_Y(r, g, b); + *plane++ = MAKE_U(r, g, b); + } + plane += plane_skip; + curr_row += src_pitch; } } - break; + } break; default: return SDL_SetError("Unsupported YUV destination format: %s", SDL_GetPixelFormatName(dst_format)); @@ -816,10 +808,9 @@ SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void *src, int sr return 0; } -int -SDL_ConvertPixels_RGB_to_YUV(int width, int height, - Uint32 src_format, const void *src, int src_pitch, - Uint32 dst_format, void *dst, int dst_pitch) +int SDL_ConvertPixels_RGB_to_YUV(int width, int height, + Uint32 src_format, const void *src, int src_pitch, + Uint32 dst_format, void *dst, int dst_pitch) { #if 0 /* Doesn't handle odd widths */ /* RGB24 to FOURCC */ @@ -874,9 +865,8 @@ SDL_ConvertPixels_RGB_to_YUV(int width, int height, } } -static int -SDL_ConvertPixels_YUV_to_YUV_Copy(int width, int height, Uint32 format, - const void *src, int src_pitch, void *dst, int dst_pitch) +static int SDL_ConvertPixels_YUV_to_YUV_Copy(int width, int height, Uint32 format, + const void *src, int src_pitch, void *dst, int dst_pitch) { int i; @@ -884,8 +874,8 @@ SDL_ConvertPixels_YUV_to_YUV_Copy(int width, int height, Uint32 format, /* Y plane */ for (i = height; i--;) { SDL_memcpy(dst, src, width); - src = (const Uint8*)src + src_pitch; - dst = (Uint8*)dst + dst_pitch; + src = (const Uint8 *)src + src_pitch; + dst = (Uint8 *)dst + dst_pitch; } if (format == SDL_PIXELFORMAT_YV12 || format == SDL_PIXELFORMAT_IYUV) { @@ -896,19 +886,19 @@ SDL_ConvertPixels_YUV_to_YUV_Copy(int width, int height, Uint32 format, dst_pitch = (dst_pitch + 1) / 2; for (i = height * 2; i--;) { SDL_memcpy(dst, src, width); - src = (const Uint8*)src + src_pitch; - dst = (Uint8*)dst + dst_pitch; + src = (const Uint8 *)src + src_pitch; + dst = (Uint8 *)dst + dst_pitch; } } else if (format == SDL_PIXELFORMAT_NV12 || format == SDL_PIXELFORMAT_NV21) { /* U/V plane is half the height of the Y plane, rounded up */ height = (height + 1) / 2; - width = ((width + 1) / 2)*2; - src_pitch = ((src_pitch + 1) / 2)*2; - dst_pitch = ((dst_pitch + 1) / 2)*2; + width = ((width + 1) / 2) * 2; + src_pitch = ((src_pitch + 1) / 2) * 2; + dst_pitch = ((dst_pitch + 1) / 2) * 2; for (i = height; i--;) { SDL_memcpy(dst, src, width); - src = (const Uint8*)src + src_pitch; - dst = (Uint8*)dst + dst_pitch; + src = (const Uint8 *)src + src_pitch; + dst = (Uint8 *)dst + dst_pitch; } } return 0; @@ -919,8 +909,8 @@ SDL_ConvertPixels_YUV_to_YUV_Copy(int width, int height, Uint32 format, width = 4 * ((width + 1) / 2); for (i = height; i--;) { SDL_memcpy(dst, src, width); - src = (const Uint8*)src + src_pitch; - dst = (Uint8*)dst + dst_pitch; + src = (const Uint8 *)src + src_pitch; + dst = (Uint8 *)dst + dst_pitch; } return 0; } @@ -928,19 +918,18 @@ SDL_ConvertPixels_YUV_to_YUV_Copy(int width, int height, Uint32 format, return SDL_SetError("SDL_ConvertPixels_YUV_to_YUV_Copy: Unsupported YUV format: %s", SDL_GetPixelFormatName(format)); } -static int -SDL_ConvertPixels_SwapUVPlanes(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +static int SDL_ConvertPixels_SwapUVPlanes(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) { int y; - const int UVwidth = (width + 1)/2; - const int UVheight = (height + 1)/2; + const int UVwidth = (width + 1) / 2; + const int UVheight = (height + 1) / 2; /* Skip the Y plane */ src = (const Uint8 *)src + height * src_pitch; dst = (Uint8 *)dst + height * dst_pitch; if (src == dst) { - int UVpitch = (dst_pitch + 1)/2; + int UVpitch = (dst_pitch + 1) / 2; Uint8 *tmp; Uint8 *row1 = dst; Uint8 *row2 = (Uint8 *)dst + UVheight * UVpitch; @@ -961,8 +950,8 @@ SDL_ConvertPixels_SwapUVPlanes(int width, int height, const void *src, int src_p } else { const Uint8 *srcUV; Uint8 *dstUV; - int srcUVPitch = ((src_pitch + 1)/2); - int dstUVPitch = ((dst_pitch + 1)/2); + int srcUVPitch = ((src_pitch + 1) / 2); + int dstUVPitch = ((dst_pitch + 1) / 2); /* Copy the first plane */ srcUV = (const Uint8 *)src; @@ -984,16 +973,15 @@ SDL_ConvertPixels_SwapUVPlanes(int width, int height, const void *src, int src_p return 0; } -static int -SDL_ConvertPixels_PackUVPlanes_to_NV(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, SDL_bool reverseUV) +static int SDL_ConvertPixels_PackUVPlanes_to_NV(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, SDL_bool reverseUV) { int x, y; - const int UVwidth = (width + 1)/2; - const int UVheight = (height + 1)/2; - const int srcUVPitch = ((src_pitch + 1)/2); + const int UVwidth = (width + 1) / 2; + const int UVheight = (height + 1) / 2; + const int srcUVPitch = ((src_pitch + 1) / 2); const int srcUVPitchLeft = srcUVPitch - UVwidth; - const int dstUVPitch = ((dst_pitch + 1)/2)*2; - const int dstUVPitchLeft = dstUVPitch - UVwidth*2; + const int dstUVPitch = ((dst_pitch + 1) / 2) * 2; + const int dstUVPitchLeft = dstUVPitch - UVwidth * 2; const Uint8 *src1, *src2; Uint8 *dstUV; Uint8 *tmp = NULL; @@ -1007,11 +995,11 @@ SDL_ConvertPixels_PackUVPlanes_to_NV(int width, int height, const void *src, int if (src == dst) { /* Need to make a copy of the buffer so we don't clobber it while converting */ - tmp = (Uint8 *)SDL_malloc(2*UVheight*srcUVPitch); + tmp = (Uint8 *)SDL_malloc(2 * UVheight * srcUVPitch); if (tmp == NULL) { return SDL_OutOfMemory(); } - SDL_memcpy(tmp, src, 2*UVheight*srcUVPitch); + SDL_memcpy(tmp, src, 2 * UVheight * srcUVPitch); src = tmp; } @@ -1034,8 +1022,8 @@ SDL_ConvertPixels_PackUVPlanes_to_NV(int width, int height, const void *src, int __m128i v = _mm_loadu_si128((__m128i *)src2); __m128i uv1 = _mm_unpacklo_epi8(u, v); __m128i uv2 = _mm_unpackhi_epi8(u, v); - _mm_storeu_si128((__m128i*)dstUV, uv1); - _mm_storeu_si128((__m128i*)(dstUV + 16), uv2); + _mm_storeu_si128((__m128i *)dstUV, uv1); + _mm_storeu_si128((__m128i *)(dstUV + 16), uv2); src1 += 16; src2 += 16; dstUV += 32; @@ -1058,15 +1046,14 @@ SDL_ConvertPixels_PackUVPlanes_to_NV(int width, int height, const void *src, int return 0; } -static int -SDL_ConvertPixels_SplitNV_to_UVPlanes(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, SDL_bool reverseUV) +static int SDL_ConvertPixels_SplitNV_to_UVPlanes(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, SDL_bool reverseUV) { int x, y; - const int UVwidth = (width + 1)/2; - const int UVheight = (height + 1)/2; - const int srcUVPitch = ((src_pitch + 1)/2)*2; - const int srcUVPitchLeft = srcUVPitch - UVwidth*2; - const int dstUVPitch = ((dst_pitch + 1)/2); + const int UVwidth = (width + 1) / 2; + const int UVheight = (height + 1) / 2; + const int srcUVPitch = ((src_pitch + 1) / 2) * 2; + const int srcUVPitchLeft = srcUVPitch - UVwidth * 2; + const int dstUVPitch = ((dst_pitch + 1) / 2); const int dstUVPitchLeft = dstUVPitch - UVwidth; const Uint8 *srcUV; Uint8 *dst1, *dst2; @@ -1081,11 +1068,11 @@ SDL_ConvertPixels_SplitNV_to_UVPlanes(int width, int height, const void *src, in if (src == dst) { /* Need to make a copy of the buffer so we don't clobber it while converting */ - tmp = (Uint8 *)SDL_malloc(UVheight*srcUVPitch); + tmp = (Uint8 *)SDL_malloc(UVheight * srcUVPitch); if (tmp == NULL) { return SDL_OutOfMemory(); } - SDL_memcpy(tmp, src, UVheight*srcUVPitch); + SDL_memcpy(tmp, src, UVheight * srcUVPitch); src = tmp; } @@ -1105,16 +1092,16 @@ SDL_ConvertPixels_SplitNV_to_UVPlanes(int width, int height, const void *src, in if (use_SSE2) { __m128i mask = _mm_set1_epi16(0x00FF); while (x >= 16) { - __m128i uv1 = _mm_loadu_si128((__m128i*)srcUV); - __m128i uv2 = _mm_loadu_si128((__m128i*)(srcUV+16)); + __m128i uv1 = _mm_loadu_si128((__m128i *)srcUV); + __m128i uv2 = _mm_loadu_si128((__m128i *)(srcUV + 16)); __m128i u1 = _mm_and_si128(uv1, mask); __m128i u2 = _mm_and_si128(uv2, mask); __m128i u = _mm_packus_epi16(u1, u2); __m128i v1 = _mm_srli_epi16(uv1, 8); __m128i v2 = _mm_srli_epi16(uv2, 8); __m128i v = _mm_packus_epi16(v1, v2); - _mm_storeu_si128((__m128i*)dst1, u); - _mm_storeu_si128((__m128i*)dst2, v); + _mm_storeu_si128((__m128i *)dst1, u); + _mm_storeu_si128((__m128i *)dst2, v); srcUV += 32; dst1 += 16; dst2 += 16; @@ -1137,16 +1124,15 @@ SDL_ConvertPixels_SplitNV_to_UVPlanes(int width, int height, const void *src, in return 0; } -static int -SDL_ConvertPixels_SwapNV(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +static int SDL_ConvertPixels_SwapNV(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) { int x, y; - const int UVwidth = (width + 1)/2; - const int UVheight = (height + 1)/2; - const int srcUVPitch = ((src_pitch + 1)/2)*2; - const int srcUVPitchLeft = (srcUVPitch - UVwidth*2)/sizeof(Uint16); - const int dstUVPitch = ((dst_pitch + 1)/2)*2; - const int dstUVPitchLeft = (dstUVPitch - UVwidth*2)/sizeof(Uint16); + const int UVwidth = (width + 1) / 2; + const int UVheight = (height + 1) / 2; + const int srcUVPitch = ((src_pitch + 1) / 2) * 2; + const int srcUVPitchLeft = (srcUVPitch - UVwidth * 2) / sizeof(Uint16); + const int dstUVPitch = ((dst_pitch + 1) / 2) * 2; + const int dstUVPitchLeft = (dstUVPitch - UVwidth * 2) / sizeof(Uint16); const Uint16 *srcUV; Uint16 *dstUV; #ifdef __SSE2__ @@ -1165,11 +1151,11 @@ SDL_ConvertPixels_SwapNV(int width, int height, const void *src, int src_pitch, #ifdef __SSE2__ if (use_SSE2) { while (x >= 8) { - __m128i uv = _mm_loadu_si128((__m128i*)srcUV); + __m128i uv = _mm_loadu_si128((__m128i *)srcUV); __m128i v = _mm_slli_epi16(uv, 8); __m128i u = _mm_srli_epi16(uv, 8); __m128i vu = _mm_or_si128(v, u); - _mm_storeu_si128((__m128i*)dstUV, vu); + _mm_storeu_si128((__m128i *)dstUV, vu); srcUV += 8; dstUV += 8; x -= 8; @@ -1185,17 +1171,16 @@ SDL_ConvertPixels_SwapNV(int width, int height, const void *src, int src_pitch, return 0; } -static int -SDL_ConvertPixels_Planar2x2_to_Planar2x2(int width, int height, - Uint32 src_format, const void *src, int src_pitch, - Uint32 dst_format, void *dst, int dst_pitch) +static int SDL_ConvertPixels_Planar2x2_to_Planar2x2(int width, int height, + Uint32 src_format, const void *src, int src_pitch, + Uint32 dst_format, void *dst, int dst_pitch) { if (src != dst) { /* Copy Y plane */ int i; const Uint8 *srcY = (const Uint8 *)src; Uint8 *dstY = (Uint8 *)dst; - for (i = height; i--; ) { + for (i = height; i--;) { SDL_memcpy(dstY, srcY, width); srcY += src_pitch; dstY += dst_pitch; @@ -1259,31 +1244,30 @@ SDL_ConvertPixels_Planar2x2_to_Planar2x2(int width, int height, } #ifdef __SSE2__ -#define PACKED4_TO_PACKED4_ROW_SSE2(shuffle) \ - while (x >= 4) { \ - __m128i yuv = _mm_loadu_si128((__m128i*)srcYUV); \ - __m128i lo = _mm_unpacklo_epi8(yuv, _mm_setzero_si128()); \ - __m128i hi = _mm_unpackhi_epi8(yuv, _mm_setzero_si128()); \ - lo = _mm_shufflelo_epi16(lo, shuffle); \ - lo = _mm_shufflehi_epi16(lo, shuffle); \ - hi = _mm_shufflelo_epi16(hi, shuffle); \ - hi = _mm_shufflehi_epi16(hi, shuffle); \ - yuv = _mm_packus_epi16(lo, hi); \ - _mm_storeu_si128((__m128i*)dstYUV, yuv); \ - srcYUV += 16; \ - dstYUV += 16; \ - x -= 4; \ - } \ +#define PACKED4_TO_PACKED4_ROW_SSE2(shuffle) \ + while (x >= 4) { \ + __m128i yuv = _mm_loadu_si128((__m128i *)srcYUV); \ + __m128i lo = _mm_unpacklo_epi8(yuv, _mm_setzero_si128()); \ + __m128i hi = _mm_unpackhi_epi8(yuv, _mm_setzero_si128()); \ + lo = _mm_shufflelo_epi16(lo, shuffle); \ + lo = _mm_shufflehi_epi16(lo, shuffle); \ + hi = _mm_shufflelo_epi16(hi, shuffle); \ + hi = _mm_shufflehi_epi16(hi, shuffle); \ + yuv = _mm_packus_epi16(lo, hi); \ + _mm_storeu_si128((__m128i *)dstYUV, yuv); \ + srcYUV += 16; \ + dstYUV += 16; \ + x -= 4; \ + } #endif -static int -SDL_ConvertPixels_YUY2_to_UYVY(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +static int SDL_ConvertPixels_YUY2_to_UYVY(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) { int x, y; - const int YUVwidth = (width + 1)/2; - const int srcYUVPitchLeft = (src_pitch - YUVwidth*4); - const int dstYUVPitchLeft = (dst_pitch - YUVwidth*4); + const int YUVwidth = (width + 1) / 2; + const int srcYUVPitchLeft = (src_pitch - YUVwidth * 4); + const int dstYUVPitchLeft = (dst_pitch - YUVwidth * 4); const Uint8 *srcYUV = (const Uint8 *)src; Uint8 *dstYUV = (Uint8 *)dst; #ifdef __SSE2__ @@ -1319,13 +1303,12 @@ SDL_ConvertPixels_YUY2_to_UYVY(int width, int height, const void *src, int src_p return 0; } -static int -SDL_ConvertPixels_YUY2_to_YVYU(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +static int SDL_ConvertPixels_YUY2_to_YVYU(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) { int x, y; - const int YUVwidth = (width + 1)/2; - const int srcYUVPitchLeft = (src_pitch - YUVwidth*4); - const int dstYUVPitchLeft = (dst_pitch - YUVwidth*4); + const int YUVwidth = (width + 1) / 2; + const int srcYUVPitchLeft = (src_pitch - YUVwidth * 4); + const int dstYUVPitchLeft = (dst_pitch - YUVwidth * 4); const Uint8 *srcYUV = (const Uint8 *)src; Uint8 *dstYUV = (Uint8 *)dst; #ifdef __SSE2__ @@ -1361,13 +1344,12 @@ SDL_ConvertPixels_YUY2_to_YVYU(int width, int height, const void *src, int src_p return 0; } -static int -SDL_ConvertPixels_UYVY_to_YUY2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +static int SDL_ConvertPixels_UYVY_to_YUY2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) { int x, y; - const int YUVwidth = (width + 1)/2; - const int srcYUVPitchLeft = (src_pitch - YUVwidth*4); - const int dstYUVPitchLeft = (dst_pitch - YUVwidth*4); + const int YUVwidth = (width + 1) / 2; + const int srcYUVPitchLeft = (src_pitch - YUVwidth * 4); + const int dstYUVPitchLeft = (dst_pitch - YUVwidth * 4); const Uint8 *srcYUV = (const Uint8 *)src; Uint8 *dstYUV = (Uint8 *)dst; #ifdef __SSE2__ @@ -1403,13 +1385,12 @@ SDL_ConvertPixels_UYVY_to_YUY2(int width, int height, const void *src, int src_p return 0; } -static int -SDL_ConvertPixels_UYVY_to_YVYU(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +static int SDL_ConvertPixels_UYVY_to_YVYU(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) { int x, y; - const int YUVwidth = (width + 1)/2; - const int srcYUVPitchLeft = (src_pitch - YUVwidth*4); - const int dstYUVPitchLeft = (dst_pitch - YUVwidth*4); + const int YUVwidth = (width + 1) / 2; + const int srcYUVPitchLeft = (src_pitch - YUVwidth * 4); + const int dstYUVPitchLeft = (dst_pitch - YUVwidth * 4); const Uint8 *srcYUV = (const Uint8 *)src; Uint8 *dstYUV = (Uint8 *)dst; #ifdef __SSE2__ @@ -1445,13 +1426,12 @@ SDL_ConvertPixels_UYVY_to_YVYU(int width, int height, const void *src, int src_p return 0; } -static int -SDL_ConvertPixels_YVYU_to_YUY2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +static int SDL_ConvertPixels_YVYU_to_YUY2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) { int x, y; - const int YUVwidth = (width + 1)/2; - const int srcYUVPitchLeft = (src_pitch - YUVwidth*4); - const int dstYUVPitchLeft = (dst_pitch - YUVwidth*4); + const int YUVwidth = (width + 1) / 2; + const int srcYUVPitchLeft = (src_pitch - YUVwidth * 4); + const int dstYUVPitchLeft = (dst_pitch - YUVwidth * 4); const Uint8 *srcYUV = (const Uint8 *)src; Uint8 *dstYUV = (Uint8 *)dst; #ifdef __SSE2__ @@ -1487,13 +1467,12 @@ SDL_ConvertPixels_YVYU_to_YUY2(int width, int height, const void *src, int src_p return 0; } -static int -SDL_ConvertPixels_YVYU_to_UYVY(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +static int SDL_ConvertPixels_YVYU_to_UYVY(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) { int x, y; - const int YUVwidth = (width + 1)/2; - const int srcYUVPitchLeft = (src_pitch - YUVwidth*4); - const int dstYUVPitchLeft = (dst_pitch - YUVwidth*4); + const int YUVwidth = (width + 1) / 2; + const int srcYUVPitchLeft = (src_pitch - YUVwidth * 4); + const int dstYUVPitchLeft = (dst_pitch - YUVwidth * 4); const Uint8 *srcYUV = (const Uint8 *)src; Uint8 *dstYUV = (Uint8 *)dst; #ifdef __SSE2__ @@ -1529,10 +1508,9 @@ SDL_ConvertPixels_YVYU_to_UYVY(int width, int height, const void *src, int src_p return 0; } -static int -SDL_ConvertPixels_Packed4_to_Packed4(int width, int height, - Uint32 src_format, const void *src, int src_pitch, - Uint32 dst_format, void *dst, int dst_pitch) +static int SDL_ConvertPixels_Packed4_to_Packed4(int width, int height, + Uint32 src_format, const void *src, int src_pitch, + Uint32 dst_format, void *dst, int dst_pitch) { switch (src_format) { case SDL_PIXELFORMAT_YUY2: @@ -1572,10 +1550,9 @@ SDL_ConvertPixels_Packed4_to_Packed4(int width, int height, SDL_GetPixelFormatName(dst_format)); } -static int -SDL_ConvertPixels_Planar2x2_to_Packed4(int width, int height, - Uint32 src_format, const void *src, int src_pitch, - Uint32 dst_format, void *dst, int dst_pitch) +static int SDL_ConvertPixels_Planar2x2_to_Packed4(int width, int height, + Uint32 src_format, const void *src, int src_pitch, + Uint32 dst_format, void *dst, int dst_pitch) { int x, y; const Uint8 *srcY1, *srcY2, *srcU, *srcV; @@ -1598,10 +1575,10 @@ SDL_ConvertPixels_Planar2x2_to_Packed4(int width, int height, if (src_format == SDL_PIXELFORMAT_NV12 || src_format == SDL_PIXELFORMAT_NV21) { srcUV_pixel_stride = 2; - srcUV_pitch_left = (srcUV_pitch - 2*((width + 1)/2)); + srcUV_pitch_left = (srcUV_pitch - 2 * ((width + 1) / 2)); } else { srcUV_pixel_stride = 1; - srcUV_pitch_left = (srcUV_pitch - ((width + 1)/2)); + srcUV_pitch_left = (srcUV_pitch - ((width + 1) / 2)); } if (GetYUVPlanes(width, height, dst_format, dst, dst_pitch, @@ -1612,7 +1589,7 @@ SDL_ConvertPixels_Planar2x2_to_Packed4(int width, int height, dstY2 = dstY1 + dstY_pitch; dstU2 = dstU1 + dstUV_pitch; dstV2 = dstV1 + dstUV_pitch; - dst_pitch_left = (dstY_pitch - 4*((width + 1)/2)); + dst_pitch_left = (dstY_pitch - 4 * ((width + 1) / 2)); /* Copy 2x2 blocks of pixels at a time */ for (y = 0; y < (height - 1); y += 2) { @@ -1715,10 +1692,9 @@ SDL_ConvertPixels_Planar2x2_to_Packed4(int width, int height, return 0; } -static int -SDL_ConvertPixels_Packed4_to_Planar2x2(int width, int height, - Uint32 src_format, const void *src, int src_pitch, - Uint32 dst_format, void *dst, int dst_pitch) +static int SDL_ConvertPixels_Packed4_to_Planar2x2(int width, int height, + Uint32 src_format, const void *src, int src_pitch, + Uint32 dst_format, void *dst, int dst_pitch) { int x, y; const Uint8 *srcY1, *srcY2, *srcU1, *srcU2, *srcV1, *srcV2; @@ -1739,7 +1715,7 @@ SDL_ConvertPixels_Packed4_to_Planar2x2(int width, int height, srcY2 = srcY1 + srcY_pitch; srcU2 = srcU1 + srcUV_pitch; srcV2 = srcV1 + srcUV_pitch; - src_pitch_left = (srcY_pitch - 4*((width + 1)/2)); + src_pitch_left = (srcY_pitch - 4 * ((width + 1) / 2)); if (GetYUVPlanes(width, height, dst_format, dst, dst_pitch, (const Uint8 **)&dstY1, (const Uint8 **)&dstU, (const Uint8 **)&dstV, @@ -1751,10 +1727,10 @@ SDL_ConvertPixels_Packed4_to_Planar2x2(int width, int height, if (dst_format == SDL_PIXELFORMAT_NV12 || dst_format == SDL_PIXELFORMAT_NV21) { dstUV_pixel_stride = 2; - dstUV_pitch_left = (dstUV_pitch - 2*((width + 1)/2)); + dstUV_pitch_left = (dstUV_pitch - 2 * ((width + 1) / 2)); } else { dstUV_pixel_stride = 1; - dstUV_pitch_left = (dstUV_pitch - ((width + 1)/2)); + dstUV_pitch_left = (dstUV_pitch - ((width + 1) / 2)); } /* Copy 2x2 blocks of pixels at a time */ @@ -1772,8 +1748,8 @@ SDL_ConvertPixels_Packed4_to_Planar2x2(int width, int height, *dstY2++ = *srcY2; srcY2 += 2; - *dstU = (Uint8)(((Uint32)*srcU1 + *srcU2)/2); - *dstV = (Uint8)(((Uint32)*srcV1 + *srcV2)/2); + *dstU = (Uint8)(((Uint32)*srcU1 + *srcU2) / 2); + *dstV = (Uint8)(((Uint32)*srcV1 + *srcV2) / 2); srcU1 += 4; srcU2 += 4; @@ -1797,8 +1773,8 @@ SDL_ConvertPixels_Packed4_to_Planar2x2(int width, int height, *dstY2++ = *srcY2; srcY2 += 2; - *dstU = (Uint8)(((Uint32)*srcU1 + *srcU2)/2); - *dstV = (Uint8)(((Uint32)*srcV1 + *srcV2)/2); + *dstU = (Uint8)(((Uint32)*srcU1 + *srcU2) / 2); + *dstV = (Uint8)(((Uint32)*srcV1 + *srcV2) / 2); srcU1 += 4; srcU2 += 4; @@ -1849,10 +1825,9 @@ SDL_ConvertPixels_Packed4_to_Planar2x2(int width, int height, #endif /* SDL_HAVE_YUV */ -int -SDL_ConvertPixels_YUV_to_YUV(int width, int height, - Uint32 src_format, const void *src, int src_pitch, - Uint32 dst_format, void *dst, int dst_pitch) +int SDL_ConvertPixels_YUV_to_YUV(int width, int height, + Uint32 src_format, const void *src, int src_pitch, + Uint32 dst_format, void *dst, int dst_pitch) { #if SDL_HAVE_YUV if (src_format == dst_format) { diff --git a/src/video/SDL_yuv_c.h b/src/video/SDL_yuv_c.h index d4e2c9108..29b56aeed 100644 --- a/src/video/SDL_yuv_c.h +++ b/src/video/SDL_yuv_c.h @@ -24,7 +24,6 @@ #include "../SDL_internal.h" - /* YUV conversion functions */ extern int SDL_ConvertPixels_YUV_to_RGB(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch); diff --git a/src/video/android/SDL_androidclipboard.c b/src/video/android/SDL_androidclipboard.c index 42460d723..394d1b955 100644 --- a/src/video/android/SDL_androidclipboard.c +++ b/src/video/android/SDL_androidclipboard.c @@ -26,8 +26,7 @@ #include "SDL_androidclipboard.h" #include "../../core/android/SDL_android.h" -int -Android_SetClipboardText(_THIS, const char *text) +int Android_SetClipboardText(_THIS, const char *text) { return Android_JNI_SetClipboardText(text); } diff --git a/src/video/android/SDL_androidevents.c b/src/video/android/SDL_androidevents.c index 3424a8254..2f74ae81d 100644 --- a/src/video/android/SDL_androidevents.c +++ b/src/video/android/SDL_androidevents.c @@ -44,40 +44,40 @@ static void ANDROIDAUDIO_PauseDevices(void) {} extern void openslES_ResumeDevices(void); extern void openslES_PauseDevices(void); #else -static void openslES_ResumeDevices(void) {} +static void openslES_ResumeDevices(void) +{ +} static void openslES_PauseDevices(void) {} #endif #if !SDL_AUDIO_DISABLED && SDL_AUDIO_DRIVER_AAUDIO extern void aaudio_ResumeDevices(void); extern void aaudio_PauseDevices(void); -SDL_bool aaudio_DetectBrokenPlayState( void ); +SDL_bool aaudio_DetectBrokenPlayState(void); #else -static void aaudio_ResumeDevices(void) {} +static void aaudio_ResumeDevices(void) +{ +} static void aaudio_PauseDevices(void) {} -static SDL_bool aaudio_DetectBrokenPlayState( void ) { return SDL_FALSE; } +static SDL_bool aaudio_DetectBrokenPlayState(void) { return SDL_FALSE; } #endif - - /* Number of 'type' events in the event queue */ -static int -SDL_NumberOfEvents(Uint32 type) +static int SDL_NumberOfEvents(Uint32 type) { return SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, type, type); } #if SDL_VIDEO_OPENGL_EGL -static void -android_egl_context_restore(SDL_Window *window) +static void android_egl_context_restore(SDL_Window *window) { if (window) { SDL_Event event; - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - if (SDL_GL_MakeCurrent(window, (SDL_GLContext) data->egl_context) < 0) { + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; + if (SDL_GL_MakeCurrent(window, (SDL_GLContext)data->egl_context) < 0) { /* The context is no longer valid, create a new one */ - data->egl_context = (EGLContext) SDL_GL_CreateContext(window); - SDL_GL_MakeCurrent(window, (SDL_GLContext) data->egl_context); + data->egl_context = (EGLContext)SDL_GL_CreateContext(window); + SDL_GL_MakeCurrent(window, (SDL_GLContext)data->egl_context); event.type = SDL_RENDER_DEVICE_RESET; SDL_PushEvent(&event); } @@ -85,12 +85,11 @@ android_egl_context_restore(SDL_Window *window) } } -static void -android_egl_context_backup(SDL_Window *window) +static void android_egl_context_backup(SDL_Window *window) { if (window) { /* Keep a copy of the EGL Context so we can try to restore it when we resume */ - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; data->egl_context = SDL_GL_GetCurrentContext(); /* We need to do this so the EGLSurface can be freed */ SDL_GL_MakeCurrent(window, NULL); @@ -106,8 +105,7 @@ android_egl_context_backup(SDL_Window *window) * No polling necessary */ -void -Android_PumpEvents_Blocking(_THIS) +void Android_PumpEvents_Blocking(_THIS) { SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; @@ -176,14 +174,13 @@ Android_PumpEvents_Blocking(_THIS) } } - if ( aaudio_DetectBrokenPlayState() ) { + if (aaudio_DetectBrokenPlayState()) { aaudio_PauseDevices(); aaudio_ResumeDevices(); } } -void -Android_PumpEvents_NonBlocking(_THIS) +void Android_PumpEvents_NonBlocking(_THIS) { SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; static int backup_context = 0; @@ -210,7 +207,6 @@ Android_PumpEvents_NonBlocking(_THIS) backup_context = 0; } - if (SDL_SemTryWait(Android_ResumeSem) == 0) { videodata->isPaused = 0; @@ -263,7 +259,7 @@ Android_PumpEvents_NonBlocking(_THIS) } } - if ( aaudio_DetectBrokenPlayState() ) { + if (aaudio_DetectBrokenPlayState()) { aaudio_PauseDevices(); aaudio_ResumeDevices(); } diff --git a/src/video/android/SDL_androidgl.c b/src/video/android/SDL_androidgl.c index fe1b17b26..18940a0b5 100644 --- a/src/video/android/SDL_androidgl.c +++ b/src/video/android/SDL_androidgl.c @@ -36,32 +36,30 @@ #include -int -Android_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) +int Android_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context) { if (window && context) { - return SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *) window->driverdata)->egl_surface, context); + return SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *)window->driverdata)->egl_surface, context); } else { return SDL_EGL_MakeCurrent(_this, NULL, NULL); } } SDL_GLContext -Android_GLES_CreateContext(_THIS, SDL_Window * window) +Android_GLES_CreateContext(_THIS, SDL_Window *window) { SDL_GLContext ret; Android_ActivityMutex_Lock_Running(); - ret = SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface); + ret = SDL_EGL_CreateContext(_this, ((SDL_WindowData *)window->driverdata)->egl_surface); SDL_UnlockMutex(Android_ActivityMutex); return ret; } -int -Android_GLES_SwapWindow(_THIS, SDL_Window * window) +int Android_GLES_SwapWindow(_THIS, SDL_Window *window) { int retval; @@ -74,16 +72,16 @@ Android_GLES_SwapWindow(_THIS, SDL_Window * window) /*_this->egl_data->eglWaitNative(EGL_CORE_NATIVE_ENGINE); _this->egl_data->eglWaitGL();*/ - retval = SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface); + retval = SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *)window->driverdata)->egl_surface); SDL_UnlockMutex(Android_ActivityMutex); return retval; } -int -Android_GLES_LoadLibrary(_THIS, const char *path) { - return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType) 0, 0); +int Android_GLES_LoadLibrary(_THIS, const char *path) +{ + return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)0, 0); } #endif /* SDL_VIDEO_DRIVER_ANDROID */ diff --git a/src/video/android/SDL_androidgl.h b/src/video/android/SDL_androidgl.h index 15225303b..c9a10da98 100644 --- a/src/video/android/SDL_androidgl.h +++ b/src/video/android/SDL_androidgl.h @@ -23,12 +23,11 @@ #ifndef SDL_androidgl_h_ #define SDL_androidgl_h_ -SDL_GLContext Android_GLES_CreateContext(_THIS, SDL_Window * window); -int Android_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); -int Android_GLES_SwapWindow(_THIS, SDL_Window * window); +SDL_GLContext Android_GLES_CreateContext(_THIS, SDL_Window *window); +int Android_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); +int Android_GLES_SwapWindow(_THIS, SDL_Window *window); int Android_GLES_LoadLibrary(_THIS, const char *path); - #endif /* SDL_androidgl_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/android/SDL_androidkeyboard.c b/src/video/android/SDL_androidkeyboard.c index 07f9672c4..bc970f798 100644 --- a/src/video/android/SDL_androidkeyboard.c +++ b/src/video/android/SDL_androidkeyboard.c @@ -31,290 +31,289 @@ #include "../../core/android/SDL_android.h" static SDL_Scancode Android_Keycodes[] = { - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_UNKNOWN */ - SDL_SCANCODE_SOFTLEFT, /* AKEYCODE_SOFT_LEFT */ - SDL_SCANCODE_SOFTRIGHT, /* AKEYCODE_SOFT_RIGHT */ - SDL_SCANCODE_AC_HOME, /* AKEYCODE_HOME */ - SDL_SCANCODE_AC_BACK, /* AKEYCODE_BACK */ - SDL_SCANCODE_CALL, /* AKEYCODE_CALL */ - SDL_SCANCODE_ENDCALL, /* AKEYCODE_ENDCALL */ - SDL_SCANCODE_0, /* AKEYCODE_0 */ - SDL_SCANCODE_1, /* AKEYCODE_1 */ - SDL_SCANCODE_2, /* AKEYCODE_2 */ - SDL_SCANCODE_3, /* AKEYCODE_3 */ - SDL_SCANCODE_4, /* AKEYCODE_4 */ - SDL_SCANCODE_5, /* AKEYCODE_5 */ - SDL_SCANCODE_6, /* AKEYCODE_6 */ - SDL_SCANCODE_7, /* AKEYCODE_7 */ - SDL_SCANCODE_8, /* AKEYCODE_8 */ - SDL_SCANCODE_9, /* AKEYCODE_9 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STAR */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_POUND */ - SDL_SCANCODE_UP, /* AKEYCODE_DPAD_UP */ - SDL_SCANCODE_DOWN, /* AKEYCODE_DPAD_DOWN */ - SDL_SCANCODE_LEFT, /* AKEYCODE_DPAD_LEFT */ - SDL_SCANCODE_RIGHT, /* AKEYCODE_DPAD_RIGHT */ - SDL_SCANCODE_SELECT, /* AKEYCODE_DPAD_CENTER */ - SDL_SCANCODE_VOLUMEUP, /* AKEYCODE_VOLUME_UP */ - SDL_SCANCODE_VOLUMEDOWN, /* AKEYCODE_VOLUME_DOWN */ - SDL_SCANCODE_POWER, /* AKEYCODE_POWER */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CAMERA */ - SDL_SCANCODE_CLEAR, /* AKEYCODE_CLEAR */ - SDL_SCANCODE_A, /* AKEYCODE_A */ - SDL_SCANCODE_B, /* AKEYCODE_B */ - SDL_SCANCODE_C, /* AKEYCODE_C */ - SDL_SCANCODE_D, /* AKEYCODE_D */ - SDL_SCANCODE_E, /* AKEYCODE_E */ - SDL_SCANCODE_F, /* AKEYCODE_F */ - SDL_SCANCODE_G, /* AKEYCODE_G */ - SDL_SCANCODE_H, /* AKEYCODE_H */ - SDL_SCANCODE_I, /* AKEYCODE_I */ - SDL_SCANCODE_J, /* AKEYCODE_J */ - SDL_SCANCODE_K, /* AKEYCODE_K */ - SDL_SCANCODE_L, /* AKEYCODE_L */ - SDL_SCANCODE_M, /* AKEYCODE_M */ - SDL_SCANCODE_N, /* AKEYCODE_N */ - SDL_SCANCODE_O, /* AKEYCODE_O */ - SDL_SCANCODE_P, /* AKEYCODE_P */ - SDL_SCANCODE_Q, /* AKEYCODE_Q */ - SDL_SCANCODE_R, /* AKEYCODE_R */ - SDL_SCANCODE_S, /* AKEYCODE_S */ - SDL_SCANCODE_T, /* AKEYCODE_T */ - SDL_SCANCODE_U, /* AKEYCODE_U */ - SDL_SCANCODE_V, /* AKEYCODE_V */ - SDL_SCANCODE_W, /* AKEYCODE_W */ - SDL_SCANCODE_X, /* AKEYCODE_X */ - SDL_SCANCODE_Y, /* AKEYCODE_Y */ - SDL_SCANCODE_Z, /* AKEYCODE_Z */ - SDL_SCANCODE_COMMA, /* AKEYCODE_COMMA */ - SDL_SCANCODE_PERIOD, /* AKEYCODE_PERIOD */ - SDL_SCANCODE_LALT, /* AKEYCODE_ALT_LEFT */ - SDL_SCANCODE_RALT, /* AKEYCODE_ALT_RIGHT */ - SDL_SCANCODE_LSHIFT, /* AKEYCODE_SHIFT_LEFT */ - SDL_SCANCODE_RSHIFT, /* AKEYCODE_SHIFT_RIGHT */ - SDL_SCANCODE_TAB, /* AKEYCODE_TAB */ - SDL_SCANCODE_SPACE, /* AKEYCODE_SPACE */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SYM */ - SDL_SCANCODE_WWW, /* AKEYCODE_EXPLORER */ - SDL_SCANCODE_MAIL, /* AKEYCODE_ENVELOPE */ - SDL_SCANCODE_RETURN, /* AKEYCODE_ENTER */ - SDL_SCANCODE_BACKSPACE, /* AKEYCODE_DEL */ - SDL_SCANCODE_GRAVE, /* AKEYCODE_GRAVE */ - SDL_SCANCODE_MINUS, /* AKEYCODE_MINUS */ - SDL_SCANCODE_EQUALS, /* AKEYCODE_EQUALS */ - SDL_SCANCODE_LEFTBRACKET, /* AKEYCODE_LEFT_BRACKET */ - SDL_SCANCODE_RIGHTBRACKET, /* AKEYCODE_RIGHT_BRACKET */ - SDL_SCANCODE_BACKSLASH, /* AKEYCODE_BACKSLASH */ - SDL_SCANCODE_SEMICOLON, /* AKEYCODE_SEMICOLON */ - SDL_SCANCODE_APOSTROPHE, /* AKEYCODE_APOSTROPHE */ - SDL_SCANCODE_SLASH, /* AKEYCODE_SLASH */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AT */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NUM */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_HEADSETHOOK */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_FOCUS */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PLUS */ - SDL_SCANCODE_MENU, /* AKEYCODE_MENU */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NOTIFICATION */ - SDL_SCANCODE_AC_SEARCH, /* AKEYCODE_SEARCH */ - SDL_SCANCODE_AUDIOPLAY, /* AKEYCODE_MEDIA_PLAY_PAUSE */ - SDL_SCANCODE_AUDIOSTOP, /* AKEYCODE_MEDIA_STOP */ - SDL_SCANCODE_AUDIONEXT, /* AKEYCODE_MEDIA_NEXT */ - SDL_SCANCODE_AUDIOPREV, /* AKEYCODE_MEDIA_PREVIOUS */ - SDL_SCANCODE_AUDIOREWIND, /* AKEYCODE_MEDIA_REWIND */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_UNKNOWN */ + SDL_SCANCODE_SOFTLEFT, /* AKEYCODE_SOFT_LEFT */ + SDL_SCANCODE_SOFTRIGHT, /* AKEYCODE_SOFT_RIGHT */ + SDL_SCANCODE_AC_HOME, /* AKEYCODE_HOME */ + SDL_SCANCODE_AC_BACK, /* AKEYCODE_BACK */ + SDL_SCANCODE_CALL, /* AKEYCODE_CALL */ + SDL_SCANCODE_ENDCALL, /* AKEYCODE_ENDCALL */ + SDL_SCANCODE_0, /* AKEYCODE_0 */ + SDL_SCANCODE_1, /* AKEYCODE_1 */ + SDL_SCANCODE_2, /* AKEYCODE_2 */ + SDL_SCANCODE_3, /* AKEYCODE_3 */ + SDL_SCANCODE_4, /* AKEYCODE_4 */ + SDL_SCANCODE_5, /* AKEYCODE_5 */ + SDL_SCANCODE_6, /* AKEYCODE_6 */ + SDL_SCANCODE_7, /* AKEYCODE_7 */ + SDL_SCANCODE_8, /* AKEYCODE_8 */ + SDL_SCANCODE_9, /* AKEYCODE_9 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STAR */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_POUND */ + SDL_SCANCODE_UP, /* AKEYCODE_DPAD_UP */ + SDL_SCANCODE_DOWN, /* AKEYCODE_DPAD_DOWN */ + SDL_SCANCODE_LEFT, /* AKEYCODE_DPAD_LEFT */ + SDL_SCANCODE_RIGHT, /* AKEYCODE_DPAD_RIGHT */ + SDL_SCANCODE_SELECT, /* AKEYCODE_DPAD_CENTER */ + SDL_SCANCODE_VOLUMEUP, /* AKEYCODE_VOLUME_UP */ + SDL_SCANCODE_VOLUMEDOWN, /* AKEYCODE_VOLUME_DOWN */ + SDL_SCANCODE_POWER, /* AKEYCODE_POWER */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CAMERA */ + SDL_SCANCODE_CLEAR, /* AKEYCODE_CLEAR */ + SDL_SCANCODE_A, /* AKEYCODE_A */ + SDL_SCANCODE_B, /* AKEYCODE_B */ + SDL_SCANCODE_C, /* AKEYCODE_C */ + SDL_SCANCODE_D, /* AKEYCODE_D */ + SDL_SCANCODE_E, /* AKEYCODE_E */ + SDL_SCANCODE_F, /* AKEYCODE_F */ + SDL_SCANCODE_G, /* AKEYCODE_G */ + SDL_SCANCODE_H, /* AKEYCODE_H */ + SDL_SCANCODE_I, /* AKEYCODE_I */ + SDL_SCANCODE_J, /* AKEYCODE_J */ + SDL_SCANCODE_K, /* AKEYCODE_K */ + SDL_SCANCODE_L, /* AKEYCODE_L */ + SDL_SCANCODE_M, /* AKEYCODE_M */ + SDL_SCANCODE_N, /* AKEYCODE_N */ + SDL_SCANCODE_O, /* AKEYCODE_O */ + SDL_SCANCODE_P, /* AKEYCODE_P */ + SDL_SCANCODE_Q, /* AKEYCODE_Q */ + SDL_SCANCODE_R, /* AKEYCODE_R */ + SDL_SCANCODE_S, /* AKEYCODE_S */ + SDL_SCANCODE_T, /* AKEYCODE_T */ + SDL_SCANCODE_U, /* AKEYCODE_U */ + SDL_SCANCODE_V, /* AKEYCODE_V */ + SDL_SCANCODE_W, /* AKEYCODE_W */ + SDL_SCANCODE_X, /* AKEYCODE_X */ + SDL_SCANCODE_Y, /* AKEYCODE_Y */ + SDL_SCANCODE_Z, /* AKEYCODE_Z */ + SDL_SCANCODE_COMMA, /* AKEYCODE_COMMA */ + SDL_SCANCODE_PERIOD, /* AKEYCODE_PERIOD */ + SDL_SCANCODE_LALT, /* AKEYCODE_ALT_LEFT */ + SDL_SCANCODE_RALT, /* AKEYCODE_ALT_RIGHT */ + SDL_SCANCODE_LSHIFT, /* AKEYCODE_SHIFT_LEFT */ + SDL_SCANCODE_RSHIFT, /* AKEYCODE_SHIFT_RIGHT */ + SDL_SCANCODE_TAB, /* AKEYCODE_TAB */ + SDL_SCANCODE_SPACE, /* AKEYCODE_SPACE */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SYM */ + SDL_SCANCODE_WWW, /* AKEYCODE_EXPLORER */ + SDL_SCANCODE_MAIL, /* AKEYCODE_ENVELOPE */ + SDL_SCANCODE_RETURN, /* AKEYCODE_ENTER */ + SDL_SCANCODE_BACKSPACE, /* AKEYCODE_DEL */ + SDL_SCANCODE_GRAVE, /* AKEYCODE_GRAVE */ + SDL_SCANCODE_MINUS, /* AKEYCODE_MINUS */ + SDL_SCANCODE_EQUALS, /* AKEYCODE_EQUALS */ + SDL_SCANCODE_LEFTBRACKET, /* AKEYCODE_LEFT_BRACKET */ + SDL_SCANCODE_RIGHTBRACKET, /* AKEYCODE_RIGHT_BRACKET */ + SDL_SCANCODE_BACKSLASH, /* AKEYCODE_BACKSLASH */ + SDL_SCANCODE_SEMICOLON, /* AKEYCODE_SEMICOLON */ + SDL_SCANCODE_APOSTROPHE, /* AKEYCODE_APOSTROPHE */ + SDL_SCANCODE_SLASH, /* AKEYCODE_SLASH */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AT */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NUM */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_HEADSETHOOK */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_FOCUS */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PLUS */ + SDL_SCANCODE_MENU, /* AKEYCODE_MENU */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NOTIFICATION */ + SDL_SCANCODE_AC_SEARCH, /* AKEYCODE_SEARCH */ + SDL_SCANCODE_AUDIOPLAY, /* AKEYCODE_MEDIA_PLAY_PAUSE */ + SDL_SCANCODE_AUDIOSTOP, /* AKEYCODE_MEDIA_STOP */ + SDL_SCANCODE_AUDIONEXT, /* AKEYCODE_MEDIA_NEXT */ + SDL_SCANCODE_AUDIOPREV, /* AKEYCODE_MEDIA_PREVIOUS */ + SDL_SCANCODE_AUDIOREWIND, /* AKEYCODE_MEDIA_REWIND */ SDL_SCANCODE_AUDIOFASTFORWARD, /* AKEYCODE_MEDIA_FAST_FORWARD */ - SDL_SCANCODE_MUTE, /* AKEYCODE_MUTE */ - SDL_SCANCODE_PAGEUP, /* AKEYCODE_PAGE_UP */ - SDL_SCANCODE_PAGEDOWN, /* AKEYCODE_PAGE_DOWN */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PICTSYMBOLS */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SWITCH_CHARSET */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_A */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_B */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_C */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_X */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_Y */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_Z */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_L1 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_R1 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_L2 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_R2 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_THUMBL */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_THUMBR */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_START */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_SELECT */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_MODE */ - SDL_SCANCODE_ESCAPE, /* AKEYCODE_ESCAPE */ - SDL_SCANCODE_DELETE, /* AKEYCODE_FORWARD_DEL */ - SDL_SCANCODE_LCTRL, /* AKEYCODE_CTRL_LEFT */ - SDL_SCANCODE_RCTRL, /* AKEYCODE_CTRL_RIGHT */ - SDL_SCANCODE_CAPSLOCK, /* AKEYCODE_CAPS_LOCK */ - SDL_SCANCODE_SCROLLLOCK, /* AKEYCODE_SCROLL_LOCK */ - SDL_SCANCODE_LGUI, /* AKEYCODE_META_LEFT */ - SDL_SCANCODE_RGUI, /* AKEYCODE_META_RIGHT */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_FUNCTION */ - SDL_SCANCODE_PRINTSCREEN, /* AKEYCODE_SYSRQ */ - SDL_SCANCODE_PAUSE, /* AKEYCODE_BREAK */ - SDL_SCANCODE_HOME, /* AKEYCODE_MOVE_HOME */ - SDL_SCANCODE_END, /* AKEYCODE_MOVE_END */ - SDL_SCANCODE_INSERT, /* AKEYCODE_INSERT */ - SDL_SCANCODE_AC_FORWARD, /* AKEYCODE_FORWARD */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_PLAY */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_PAUSE */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_CLOSE */ - SDL_SCANCODE_EJECT, /* AKEYCODE_MEDIA_EJECT */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_RECORD */ - SDL_SCANCODE_F1, /* AKEYCODE_F1 */ - SDL_SCANCODE_F2, /* AKEYCODE_F2 */ - SDL_SCANCODE_F3, /* AKEYCODE_F3 */ - SDL_SCANCODE_F4, /* AKEYCODE_F4 */ - SDL_SCANCODE_F5, /* AKEYCODE_F5 */ - SDL_SCANCODE_F6, /* AKEYCODE_F6 */ - SDL_SCANCODE_F7, /* AKEYCODE_F7 */ - SDL_SCANCODE_F8, /* AKEYCODE_F8 */ - SDL_SCANCODE_F9, /* AKEYCODE_F9 */ - SDL_SCANCODE_F10, /* AKEYCODE_F10 */ - SDL_SCANCODE_F11, /* AKEYCODE_F11 */ - SDL_SCANCODE_F12, /* AKEYCODE_F12 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NUM_LOCK */ - SDL_SCANCODE_KP_0, /* AKEYCODE_NUMPAD_0 */ - SDL_SCANCODE_KP_1, /* AKEYCODE_NUMPAD_1 */ - SDL_SCANCODE_KP_2, /* AKEYCODE_NUMPAD_2 */ - SDL_SCANCODE_KP_3, /* AKEYCODE_NUMPAD_3 */ - SDL_SCANCODE_KP_4, /* AKEYCODE_NUMPAD_4 */ - SDL_SCANCODE_KP_5, /* AKEYCODE_NUMPAD_5 */ - SDL_SCANCODE_KP_6, /* AKEYCODE_NUMPAD_6 */ - SDL_SCANCODE_KP_7, /* AKEYCODE_NUMPAD_7 */ - SDL_SCANCODE_KP_8, /* AKEYCODE_NUMPAD_8 */ - SDL_SCANCODE_KP_9, /* AKEYCODE_NUMPAD_9 */ - SDL_SCANCODE_KP_DIVIDE, /* AKEYCODE_NUMPAD_DIVIDE */ - SDL_SCANCODE_KP_MULTIPLY, /* AKEYCODE_NUMPAD_MULTIPLY */ - SDL_SCANCODE_KP_MINUS, /* AKEYCODE_NUMPAD_SUBTRACT */ - SDL_SCANCODE_KP_PLUS, /* AKEYCODE_NUMPAD_ADD */ - SDL_SCANCODE_KP_PERIOD, /* AKEYCODE_NUMPAD_DOT */ - SDL_SCANCODE_KP_COMMA, /* AKEYCODE_NUMPAD_COMMA */ - SDL_SCANCODE_KP_ENTER, /* AKEYCODE_NUMPAD_ENTER */ - SDL_SCANCODE_KP_EQUALS, /* AKEYCODE_NUMPAD_EQUALS */ - SDL_SCANCODE_KP_LEFTPAREN, /* AKEYCODE_NUMPAD_LEFT_PAREN */ - SDL_SCANCODE_KP_RIGHTPAREN, /* AKEYCODE_NUMPAD_RIGHT_PAREN */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_VOLUME_MUTE */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_INFO */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CHANNEL_UP */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CHANNEL_DOWN */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ZOOM_IN */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ZOOM_OUT */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_WINDOW */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_GUIDE */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_DVR */ - SDL_SCANCODE_AC_BOOKMARKS, /* AKEYCODE_BOOKMARK */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CAPTIONS */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SETTINGS */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_POWER */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STB_POWER */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STB_INPUT */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AVR_POWER */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AVR_INPUT */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_RED */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_GREEN */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_YELLOW */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_BLUE */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_APP_SWITCH */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_1 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_2 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_3 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_4 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_5 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_6 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_7 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_8 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_9 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_10 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_11 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_12 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_13 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_14 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_15 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_16 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_LANGUAGE_SWITCH */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MANNER_MODE */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_3D_MODE */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CONTACTS */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CALENDAR */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MUSIC */ - SDL_SCANCODE_CALCULATOR, /* AKEYCODE_CALCULATOR */ - SDL_SCANCODE_LANG5, /* AKEYCODE_ZENKAKU_HANKAKU */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_EISU */ - SDL_SCANCODE_INTERNATIONAL5, /* AKEYCODE_MUHENKAN */ - SDL_SCANCODE_INTERNATIONAL4, /* AKEYCODE_HENKAN */ - SDL_SCANCODE_LANG3, /* AKEYCODE_KATAKANA_HIRAGANA */ - SDL_SCANCODE_INTERNATIONAL3, /* AKEYCODE_YEN */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_RO */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_KANA */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ASSIST */ - SDL_SCANCODE_BRIGHTNESSDOWN, /* AKEYCODE_BRIGHTNESS_DOWN */ - SDL_SCANCODE_BRIGHTNESSUP, /* AKEYCODE_BRIGHTNESS_UP */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_AUDIO_TRACK */ - SDL_SCANCODE_SLEEP, /* AKEYCODE_SLEEP */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_WAKEUP */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PAIRING */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_TOP_MENU */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_11 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_12 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_LAST_CHANNEL */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_DATA_SERVICE */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_VOICE_ASSIST */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_RADIO_SERVICE */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TELETEXT */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_NUMBER_ENTRY */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TERRESTRIAL_ANALOG */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TERRESTRIAL_DIGITAL */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE_BS */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE_CS */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE_SERVICE */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_NETWORK */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_ANTENNA_CABLE */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_1 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_2 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_3 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_4 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPOSITE_1 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPOSITE_2 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPONENT_1 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPONENT_2 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_VGA_1 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_AUDIO_DESCRIPTION */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_ZOOM_MODE */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_CONTENTS_MENU */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_MEDIA_CONTEXT_MENU */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TIMER_PROGRAMMING */ - SDL_SCANCODE_HELP, /* AKEYCODE_HELP */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_PREVIOUS */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_NEXT */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_IN */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_OUT */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STEM_PRIMARY */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STEM_1 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STEM_2 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STEM_3 */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_DPAD_UP_LEFT */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_DPAD_DOWN_LEFT */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_DPAD_UP_RIGHT */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_DPAD_DOWN_RIGHT */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_SKIP_FORWARD */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_SKIP_BACKWARD */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_STEP_FORWARD */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_STEP_BACKWARD */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_SLEEP */ - SDL_SCANCODE_CUT, /* AKEYCODE_CUT */ - SDL_SCANCODE_COPY, /* AKEYCODE_COPY */ - SDL_SCANCODE_PASTE, /* AKEYCODE_PASTE */ + SDL_SCANCODE_MUTE, /* AKEYCODE_MUTE */ + SDL_SCANCODE_PAGEUP, /* AKEYCODE_PAGE_UP */ + SDL_SCANCODE_PAGEDOWN, /* AKEYCODE_PAGE_DOWN */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PICTSYMBOLS */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SWITCH_CHARSET */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_A */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_B */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_C */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_X */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_Y */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_Z */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_L1 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_R1 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_L2 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_R2 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_THUMBL */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_THUMBR */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_START */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_SELECT */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_MODE */ + SDL_SCANCODE_ESCAPE, /* AKEYCODE_ESCAPE */ + SDL_SCANCODE_DELETE, /* AKEYCODE_FORWARD_DEL */ + SDL_SCANCODE_LCTRL, /* AKEYCODE_CTRL_LEFT */ + SDL_SCANCODE_RCTRL, /* AKEYCODE_CTRL_RIGHT */ + SDL_SCANCODE_CAPSLOCK, /* AKEYCODE_CAPS_LOCK */ + SDL_SCANCODE_SCROLLLOCK, /* AKEYCODE_SCROLL_LOCK */ + SDL_SCANCODE_LGUI, /* AKEYCODE_META_LEFT */ + SDL_SCANCODE_RGUI, /* AKEYCODE_META_RIGHT */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_FUNCTION */ + SDL_SCANCODE_PRINTSCREEN, /* AKEYCODE_SYSRQ */ + SDL_SCANCODE_PAUSE, /* AKEYCODE_BREAK */ + SDL_SCANCODE_HOME, /* AKEYCODE_MOVE_HOME */ + SDL_SCANCODE_END, /* AKEYCODE_MOVE_END */ + SDL_SCANCODE_INSERT, /* AKEYCODE_INSERT */ + SDL_SCANCODE_AC_FORWARD, /* AKEYCODE_FORWARD */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_PLAY */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_PAUSE */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_CLOSE */ + SDL_SCANCODE_EJECT, /* AKEYCODE_MEDIA_EJECT */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_RECORD */ + SDL_SCANCODE_F1, /* AKEYCODE_F1 */ + SDL_SCANCODE_F2, /* AKEYCODE_F2 */ + SDL_SCANCODE_F3, /* AKEYCODE_F3 */ + SDL_SCANCODE_F4, /* AKEYCODE_F4 */ + SDL_SCANCODE_F5, /* AKEYCODE_F5 */ + SDL_SCANCODE_F6, /* AKEYCODE_F6 */ + SDL_SCANCODE_F7, /* AKEYCODE_F7 */ + SDL_SCANCODE_F8, /* AKEYCODE_F8 */ + SDL_SCANCODE_F9, /* AKEYCODE_F9 */ + SDL_SCANCODE_F10, /* AKEYCODE_F10 */ + SDL_SCANCODE_F11, /* AKEYCODE_F11 */ + SDL_SCANCODE_F12, /* AKEYCODE_F12 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NUM_LOCK */ + SDL_SCANCODE_KP_0, /* AKEYCODE_NUMPAD_0 */ + SDL_SCANCODE_KP_1, /* AKEYCODE_NUMPAD_1 */ + SDL_SCANCODE_KP_2, /* AKEYCODE_NUMPAD_2 */ + SDL_SCANCODE_KP_3, /* AKEYCODE_NUMPAD_3 */ + SDL_SCANCODE_KP_4, /* AKEYCODE_NUMPAD_4 */ + SDL_SCANCODE_KP_5, /* AKEYCODE_NUMPAD_5 */ + SDL_SCANCODE_KP_6, /* AKEYCODE_NUMPAD_6 */ + SDL_SCANCODE_KP_7, /* AKEYCODE_NUMPAD_7 */ + SDL_SCANCODE_KP_8, /* AKEYCODE_NUMPAD_8 */ + SDL_SCANCODE_KP_9, /* AKEYCODE_NUMPAD_9 */ + SDL_SCANCODE_KP_DIVIDE, /* AKEYCODE_NUMPAD_DIVIDE */ + SDL_SCANCODE_KP_MULTIPLY, /* AKEYCODE_NUMPAD_MULTIPLY */ + SDL_SCANCODE_KP_MINUS, /* AKEYCODE_NUMPAD_SUBTRACT */ + SDL_SCANCODE_KP_PLUS, /* AKEYCODE_NUMPAD_ADD */ + SDL_SCANCODE_KP_PERIOD, /* AKEYCODE_NUMPAD_DOT */ + SDL_SCANCODE_KP_COMMA, /* AKEYCODE_NUMPAD_COMMA */ + SDL_SCANCODE_KP_ENTER, /* AKEYCODE_NUMPAD_ENTER */ + SDL_SCANCODE_KP_EQUALS, /* AKEYCODE_NUMPAD_EQUALS */ + SDL_SCANCODE_KP_LEFTPAREN, /* AKEYCODE_NUMPAD_LEFT_PAREN */ + SDL_SCANCODE_KP_RIGHTPAREN, /* AKEYCODE_NUMPAD_RIGHT_PAREN */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_VOLUME_MUTE */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_INFO */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CHANNEL_UP */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CHANNEL_DOWN */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ZOOM_IN */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ZOOM_OUT */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_WINDOW */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_GUIDE */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_DVR */ + SDL_SCANCODE_AC_BOOKMARKS, /* AKEYCODE_BOOKMARK */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CAPTIONS */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SETTINGS */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_POWER */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STB_POWER */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STB_INPUT */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AVR_POWER */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AVR_INPUT */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_RED */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_GREEN */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_YELLOW */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_BLUE */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_APP_SWITCH */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_1 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_2 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_3 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_4 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_5 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_6 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_7 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_8 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_9 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_10 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_11 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_12 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_13 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_14 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_15 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_16 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_LANGUAGE_SWITCH */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MANNER_MODE */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_3D_MODE */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CONTACTS */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CALENDAR */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MUSIC */ + SDL_SCANCODE_CALCULATOR, /* AKEYCODE_CALCULATOR */ + SDL_SCANCODE_LANG5, /* AKEYCODE_ZENKAKU_HANKAKU */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_EISU */ + SDL_SCANCODE_INTERNATIONAL5, /* AKEYCODE_MUHENKAN */ + SDL_SCANCODE_INTERNATIONAL4, /* AKEYCODE_HENKAN */ + SDL_SCANCODE_LANG3, /* AKEYCODE_KATAKANA_HIRAGANA */ + SDL_SCANCODE_INTERNATIONAL3, /* AKEYCODE_YEN */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_RO */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_KANA */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ASSIST */ + SDL_SCANCODE_BRIGHTNESSDOWN, /* AKEYCODE_BRIGHTNESS_DOWN */ + SDL_SCANCODE_BRIGHTNESSUP, /* AKEYCODE_BRIGHTNESS_UP */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_AUDIO_TRACK */ + SDL_SCANCODE_SLEEP, /* AKEYCODE_SLEEP */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_WAKEUP */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PAIRING */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_TOP_MENU */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_11 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_12 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_LAST_CHANNEL */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_DATA_SERVICE */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_VOICE_ASSIST */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_RADIO_SERVICE */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TELETEXT */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_NUMBER_ENTRY */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TERRESTRIAL_ANALOG */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TERRESTRIAL_DIGITAL */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE_BS */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE_CS */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE_SERVICE */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_NETWORK */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_ANTENNA_CABLE */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_1 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_2 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_3 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_4 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPOSITE_1 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPOSITE_2 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPONENT_1 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPONENT_2 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_VGA_1 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_AUDIO_DESCRIPTION */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_ZOOM_MODE */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_CONTENTS_MENU */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_MEDIA_CONTEXT_MENU */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TIMER_PROGRAMMING */ + SDL_SCANCODE_HELP, /* AKEYCODE_HELP */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_PREVIOUS */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_NEXT */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_IN */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_OUT */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STEM_PRIMARY */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STEM_1 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STEM_2 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STEM_3 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_DPAD_UP_LEFT */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_DPAD_DOWN_LEFT */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_DPAD_UP_RIGHT */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_DPAD_DOWN_RIGHT */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_SKIP_FORWARD */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_SKIP_BACKWARD */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_STEP_FORWARD */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_STEP_BACKWARD */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_SLEEP */ + SDL_SCANCODE_CUT, /* AKEYCODE_CUT */ + SDL_SCANCODE_COPY, /* AKEYCODE_COPY */ + SDL_SCANCODE_PASTE, /* AKEYCODE_PASTE */ }; -static SDL_Scancode -TranslateKeycode(int keycode) +static SDL_Scancode TranslateKeycode(int keycode) { SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN; @@ -327,14 +326,12 @@ TranslateKeycode(int keycode) return scancode; } -int -Android_OnKeyDown(int keycode) +int Android_OnKeyDown(int keycode) { return SDL_SendKeyboardKey(SDL_PRESSED, TranslateKeycode(keycode)); } -int -Android_OnKeyUp(int keycode) +int Android_OnKeyUp(int keycode) { return SDL_SendKeyboardKey(SDL_RELEASED, TranslateKeycode(keycode)); } @@ -346,26 +343,23 @@ Android_HasScreenKeyboardSupport(_THIS) } SDL_bool -Android_IsScreenKeyboardShown(_THIS, SDL_Window * window) +Android_IsScreenKeyboardShown(_THIS, SDL_Window *window) { return Android_JNI_IsScreenKeyboardShown(); } -void -Android_StartTextInput(_THIS) +void Android_StartTextInput(_THIS) { SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; Android_JNI_ShowTextInput(&videodata->textRect); } -void -Android_StopTextInput(_THIS) +void Android_StopTextInput(_THIS) { Android_JNI_HideTextInput(); } -void -Android_SetTextInputRect(_THIS, const SDL_Rect *rect) +void Android_SetTextInputRect(_THIS, const SDL_Rect *rect) { SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; diff --git a/src/video/android/SDL_androidkeyboard.h b/src/video/android/SDL_androidkeyboard.h index 6bdcc87be..bf7d2034b 100644 --- a/src/video/android/SDL_androidkeyboard.h +++ b/src/video/android/SDL_androidkeyboard.h @@ -26,7 +26,7 @@ extern int Android_OnKeyDown(int keycode); extern int Android_OnKeyUp(int keycode); extern SDL_bool Android_HasScreenKeyboardSupport(_THIS); -extern SDL_bool Android_IsScreenKeyboardShown(_THIS, SDL_Window * window); +extern SDL_bool Android_IsScreenKeyboardShown(_THIS, SDL_Window *window); extern void Android_StartTextInput(_THIS); extern void Android_StopTextInput(_THIS); diff --git a/src/video/android/SDL_androidmessagebox.c b/src/video/android/SDL_androidmessagebox.c index dc8b8ad03..37211d397 100644 --- a/src/video/android/SDL_androidmessagebox.c +++ b/src/video/android/SDL_androidmessagebox.c @@ -26,8 +26,7 @@ #include "SDL_androidmessagebox.h" #include "../../core/android/SDL_android.h" -int -Android_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) +int Android_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { return Android_JNI_ShowMessageBox(messageboxdata, buttonid); } diff --git a/src/video/android/SDL_androidmouse.c b/src/video/android/SDL_androidmouse.c index 139a7348c..fa80daa4a 100644 --- a/src/video/android/SDL_androidmouse.c +++ b/src/video/android/SDL_androidmouse.c @@ -31,16 +31,16 @@ #include "../../core/android/SDL_android.h" /* See Android's MotionEvent class for constants */ -#define ACTION_DOWN 0 -#define ACTION_UP 1 -#define ACTION_MOVE 2 +#define ACTION_DOWN 0 +#define ACTION_UP 1 +#define ACTION_MOVE 2 #define ACTION_HOVER_MOVE 7 -#define ACTION_SCROLL 8 -#define BUTTON_PRIMARY 1 -#define BUTTON_SECONDARY 2 -#define BUTTON_TERTIARY 4 -#define BUTTON_BACK 8 -#define BUTTON_FORWARD 16 +#define ACTION_SCROLL 8 +#define BUTTON_PRIMARY 1 +#define BUTTON_SECONDARY 2 +#define BUTTON_TERTIARY 4 +#define BUTTON_BACK 8 +#define BUTTON_FORWARD 16 typedef struct { @@ -55,8 +55,7 @@ static int last_state; /* Blank cursor */ static SDL_Cursor *empty_cursor; -static SDL_Cursor * -Android_WrapCursor(int custom_cursor, int system_cursor) +static SDL_Cursor *Android_WrapCursor(int custom_cursor, int system_cursor) { SDL_Cursor *cursor; @@ -79,14 +78,12 @@ Android_WrapCursor(int custom_cursor, int system_cursor) return cursor; } -static SDL_Cursor * -Android_CreateDefaultCursor() +static SDL_Cursor *Android_CreateDefaultCursor() { return Android_WrapCursor(0, SDL_SYSTEM_CURSOR_ARROW); } -static SDL_Cursor * -Android_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) +static SDL_Cursor *Android_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) { int custom_cursor; SDL_Surface *converted; @@ -104,16 +101,14 @@ Android_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) return Android_WrapCursor(custom_cursor, 0); } -static SDL_Cursor * -Android_CreateSystemCursor(SDL_SystemCursor id) +static SDL_Cursor *Android_CreateSystemCursor(SDL_SystemCursor id) { return Android_WrapCursor(0, id); } -static void -Android_FreeCursor(SDL_Cursor * cursor) +static void Android_FreeCursor(SDL_Cursor *cursor) { - SDL_AndroidCursorData *data = (SDL_AndroidCursorData*) cursor->driverdata; + SDL_AndroidCursorData *data = (SDL_AndroidCursorData *)cursor->driverdata; if (data->custom_cursor != 0) { Android_JNI_DestroyCustomCursor(data->custom_cursor); } @@ -121,8 +116,7 @@ Android_FreeCursor(SDL_Cursor * cursor) SDL_free(cursor); } -static SDL_Cursor * -Android_CreateEmptyCursor() +static SDL_Cursor *Android_CreateEmptyCursor() { if (empty_cursor == NULL) { SDL_Surface *empty_surface = SDL_CreateRGBSurfaceWithFormat(0, 1, 1, 32, SDL_PIXELFORMAT_ARGB8888); @@ -135,8 +129,7 @@ Android_CreateEmptyCursor() return empty_cursor; } -static void -Android_DestroyEmptyCursor() +static void Android_DestroyEmptyCursor() { if (empty_cursor) { Android_FreeCursor(empty_cursor); @@ -144,8 +137,7 @@ Android_DestroyEmptyCursor() } } -static int -Android_ShowCursor(SDL_Cursor *cursor) +static int Android_ShowCursor(SDL_Cursor *cursor) { if (cursor == NULL) { cursor = Android_CreateEmptyCursor(); @@ -168,8 +160,7 @@ Android_ShowCursor(SDL_Cursor *cursor) } } -static int -Android_SetRelativeMouseMode(SDL_bool enabled) +static int Android_SetRelativeMouseMode(SDL_bool enabled) { if (!Android_JNI_SupportsRelativeMouse()) { return SDL_Unsupported(); @@ -182,8 +173,7 @@ Android_SetRelativeMouseMode(SDL_bool enabled) return 0; } -void -Android_InitMouse(void) +void Android_InitMouse(void) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -198,15 +188,13 @@ Android_InitMouse(void) last_state = 0; } -void -Android_QuitMouse(void) +void Android_QuitMouse(void) { Android_DestroyEmptyCursor(); } /* Translate Android mouse button state to SDL mouse button */ -static Uint8 -TranslateButton(int state) +static Uint8 TranslateButton(int state) { if (state & BUTTON_PRIMARY) { return SDL_BUTTON_LEFT; @@ -223,8 +211,7 @@ TranslateButton(int state) } } -void -Android_OnMouse(SDL_Window *window, int state, int action, float x, float y, SDL_bool relative) +void Android_OnMouse(SDL_Window *window, int state, int action, float x, float y, SDL_bool relative) { int changes; Uint8 button; @@ -233,38 +220,37 @@ Android_OnMouse(SDL_Window *window, int state, int action, float x, float y, SDL return; } - switch(action) { - case ACTION_DOWN: - changes = state & ~last_state; - button = TranslateButton(changes); - last_state = state; - SDL_SendMouseMotion(window, 0, relative, (int)x, (int)y); - SDL_SendMouseButton(window, 0, SDL_PRESSED, button); - break; + switch (action) { + case ACTION_DOWN: + changes = state & ~last_state; + button = TranslateButton(changes); + last_state = state; + SDL_SendMouseMotion(window, 0, relative, (int)x, (int)y); + SDL_SendMouseButton(window, 0, SDL_PRESSED, button); + break; - case ACTION_UP: - changes = last_state & ~state; - button = TranslateButton(changes); - last_state = state; - SDL_SendMouseMotion(window, 0, relative, (int)x, (int)y); - SDL_SendMouseButton(window, 0, SDL_RELEASED, button); - break; + case ACTION_UP: + changes = last_state & ~state; + button = TranslateButton(changes); + last_state = state; + SDL_SendMouseMotion(window, 0, relative, (int)x, (int)y); + SDL_SendMouseButton(window, 0, SDL_RELEASED, button); + break; - case ACTION_MOVE: - case ACTION_HOVER_MOVE: - SDL_SendMouseMotion(window, 0, relative, (int)x, (int)y); - break; + case ACTION_MOVE: + case ACTION_HOVER_MOVE: + SDL_SendMouseMotion(window, 0, relative, (int)x, (int)y); + break; - case ACTION_SCROLL: - SDL_SendMouseWheel(window, 0, x, y, SDL_MOUSEWHEEL_NORMAL); - break; + case ACTION_SCROLL: + SDL_SendMouseWheel(window, 0, x, y, SDL_MOUSEWHEEL_NORMAL); + break; - default: - break; + default: + break; } } #endif /* SDL_VIDEO_DRIVER_ANDROID */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/video/android/SDL_androidtouch.c b/src/video/android/SDL_androidtouch.c index 02c50356d..7c9d2c060 100644 --- a/src/video/android/SDL_androidtouch.c +++ b/src/video/android/SDL_androidtouch.c @@ -32,12 +32,12 @@ #include "../../core/android/SDL_android.h" #define ACTION_DOWN 0 -#define ACTION_UP 1 +#define ACTION_UP 1 #define ACTION_MOVE 2 /* #define ACTION_CANCEL 3 */ /* #define ACTION_OUTSIDE 4 */ #define ACTION_POINTER_DOWN 5 -#define ACTION_POINTER_UP 6 +#define ACTION_POINTER_UP 6 void Android_InitTouch(void) { @@ -65,22 +65,22 @@ void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_fin fingerId = (SDL_FingerID)pointer_finger_id_in; switch (action) { - case ACTION_DOWN: - case ACTION_POINTER_DOWN: - SDL_SendTouch(touchDeviceId, fingerId, window, SDL_TRUE, x, y, p); - break; + case ACTION_DOWN: + case ACTION_POINTER_DOWN: + SDL_SendTouch(touchDeviceId, fingerId, window, SDL_TRUE, x, y, p); + break; - case ACTION_MOVE: - SDL_SendTouchMotion(touchDeviceId, fingerId, window, x, y, p); - break; + case ACTION_MOVE: + SDL_SendTouchMotion(touchDeviceId, fingerId, window, x, y, p); + break; - case ACTION_UP: - case ACTION_POINTER_UP: - SDL_SendTouch(touchDeviceId, fingerId, window, SDL_FALSE, x, y, p); - break; + case ACTION_UP: + case ACTION_POINTER_UP: + SDL_SendTouch(touchDeviceId, fingerId, window, SDL_FALSE, x, y, p); + break; - default: - break; + default: + break; } } diff --git a/src/video/android/SDL_androidvideo.c b/src/video/android/SDL_androidvideo.c index 62354fe41..50e37e777 100644 --- a/src/video/android/SDL_androidvideo.c +++ b/src/video/android/SDL_androidvideo.c @@ -54,50 +54,46 @@ int Android_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, float * #define Android_GLES_UnloadLibrary SDL_EGL_UnloadLibrary #define Android_GLES_SetSwapInterval SDL_EGL_SetSwapInterval #define Android_GLES_GetSwapInterval SDL_EGL_GetSwapInterval -#define Android_GLES_DeleteContext SDL_EGL_DeleteContext +#define Android_GLES_DeleteContext SDL_EGL_DeleteContext /* Android driver bootstrap functions */ - /* These are filled in with real values in Android_SetScreenResolution on init (before SDL_main()) */ -int Android_SurfaceWidth = 0; -int Android_SurfaceHeight = 0; -static int Android_DeviceWidth = 0; -static int Android_DeviceHeight = 0; +int Android_SurfaceWidth = 0; +int Android_SurfaceHeight = 0; +static int Android_DeviceWidth = 0; +static int Android_DeviceHeight = 0; static Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_RGB565; /* Default SurfaceView format, in case this is queried before being filled */ -static int Android_ScreenRate = 0; -SDL_sem *Android_PauseSem = NULL; -SDL_sem *Android_ResumeSem = NULL; -SDL_mutex *Android_ActivityMutex = NULL; +static int Android_ScreenRate = 0; +SDL_sem *Android_PauseSem = NULL; +SDL_sem *Android_ResumeSem = NULL; +SDL_mutex *Android_ActivityMutex = NULL; -static void -Android_SuspendScreenSaver(_THIS) +static void Android_SuspendScreenSaver(_THIS) { Android_JNI_SuspendScreenSaver(_this->suspend_screensaver); } -static void -Android_DeleteDevice(SDL_VideoDevice *device) +static void Android_DeleteDevice(SDL_VideoDevice *device) { SDL_free(device->driverdata); SDL_free(device); } -static SDL_VideoDevice * -Android_CreateDevice(void) +static SDL_VideoDevice *Android_CreateDevice(void) { SDL_VideoDevice *device; SDL_VideoData *data; SDL_bool block_on_pause; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device == NULL) { SDL_OutOfMemory(); return NULL; } - data = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); + data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); if (data == NULL) { SDL_OutOfMemory(); SDL_free(device); @@ -173,24 +169,22 @@ VideoBootStrap Android_bootstrap = { Android_CreateDevice }; - -int -Android_VideoInit(_THIS) +int Android_VideoInit(_THIS) { SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; int display_index; SDL_VideoDisplay *display; SDL_DisplayMode mode; - videodata->isPaused = SDL_FALSE; + videodata->isPaused = SDL_FALSE; videodata->isPausing = SDL_FALSE; videodata->pauseAudio = SDL_GetHintBoolean(SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO, SDL_TRUE); - mode.format = Android_ScreenFormat; - mode.w = Android_DeviceWidth; - mode.h = Android_DeviceHeight; - mode.refresh_rate = Android_ScreenRate; - mode.driverdata = NULL; + mode.format = Android_ScreenFormat; + mode.w = Android_DeviceWidth; + mode.h = Android_DeviceHeight; + mode.refresh_rate = Android_ScreenRate; + mode.driverdata = NULL; display_index = SDL_AddBasicVideoDisplay(&mode); if (display_index < 0) { @@ -209,33 +203,30 @@ Android_VideoInit(_THIS) return 0; } -void -Android_VideoQuit(_THIS) +void Android_VideoQuit(_THIS) { Android_QuitMouse(); Android_QuitTouch(); } -int -Android_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi) +int Android_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi) { return Android_JNI_GetDisplayDPI(ddpi, hdpi, vdpi); } -void -Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, float rate) +void Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, float rate) { - Android_SurfaceWidth = surfaceWidth; + Android_SurfaceWidth = surfaceWidth; Android_SurfaceHeight = surfaceHeight; - Android_DeviceWidth = deviceWidth; - Android_DeviceHeight = deviceHeight; - Android_ScreenRate = (int)rate; + Android_DeviceWidth = deviceWidth; + Android_DeviceHeight = deviceHeight; + Android_ScreenRate = (int)rate; } -static -Uint32 format_to_pixelFormat(int format) { +static Uint32 format_to_pixelFormat(int format) +{ Uint32 pf; - if (format == AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM) { /* 1 */ + if (format == AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM) { /* 1 */ pf = SDL_PIXELFORMAT_RGBA8888; } else if (format == AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM) { /* 2 */ pf = SDL_PIXELFORMAT_RGBX8888; @@ -258,8 +249,7 @@ Uint32 format_to_pixelFormat(int format) { return pf; } -void -Android_SetFormat(int format_wanted, int format_got) +void Android_SetFormat(int format_wanted, int format_got) { Uint32 pf_wanted; Uint32 pf_got; @@ -284,22 +274,22 @@ void Android_SendResize(SDL_Window *window) */ SDL_VideoDevice *device = SDL_GetVideoDevice(); if (device && device->num_displays > 0) { - SDL_VideoDisplay *display = &device->displays[0]; - display->desktop_mode.format = Android_ScreenFormat; - display->desktop_mode.w = Android_DeviceWidth; - display->desktop_mode.h = Android_DeviceHeight; + SDL_VideoDisplay *display = &device->displays[0]; + display->desktop_mode.format = Android_ScreenFormat; + display->desktop_mode.w = Android_DeviceWidth; + display->desktop_mode.h = Android_DeviceHeight; display->desktop_mode.refresh_rate = Android_ScreenRate; } if (window) { /* Force the current mode to match the resize otherwise the SDL_WINDOWEVENT_RESTORED event * will fall back to the old mode */ - SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); - display->display_modes[0].format = Android_ScreenFormat; - display->display_modes[0].w = Android_DeviceWidth; - display->display_modes[0].h = Android_DeviceHeight; + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); + display->display_modes[0].format = Android_ScreenFormat; + display->display_modes[0].w = Android_DeviceWidth; + display->display_modes[0].h = Android_DeviceHeight; display->display_modes[0].refresh_rate = Android_ScreenRate; - display->current_mode = display->display_modes[0]; + display->current_mode = display->display_modes[0]; SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, Android_SurfaceWidth, Android_SurfaceHeight); } diff --git a/src/video/android/SDL_androidvideo.h b/src/video/android/SDL_androidvideo.h index 371419ba3..a3f5275c2 100644 --- a/src/video/android/SDL_androidvideo.h +++ b/src/video/android/SDL_androidvideo.h @@ -37,9 +37,9 @@ extern void Android_SendResize(SDL_Window *window); typedef struct SDL_VideoData { SDL_Rect textRect; - int isPaused; - int isPausing; - int pauseAudio; + int isPaused; + int isPausing; + int pauseAudio; } SDL_VideoData; extern int Android_SurfaceWidth; diff --git a/src/video/android/SDL_androidvulkan.c b/src/video/android/SDL_androidvulkan.c index 09c44b1f5..0bff90337 100644 --- a/src/video/android/SDL_androidvulkan.c +++ b/src/video/android/SDL_androidvulkan.c @@ -78,8 +78,7 @@ int Android_Vulkan_LoadLibrary(_THIS, const char *path) if (extensions == NULL) { goto fail; } - for (i = 0; i < extensionCount; i++) - { + for (i = 0; i < extensionCount; i++) { if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { hasSurfaceExtension = SDL_TRUE; } else if (SDL_strcmp(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { @@ -88,12 +87,10 @@ int Android_Vulkan_LoadLibrary(_THIS, const char *path) } SDL_free(extensions); if (!hasSurfaceExtension) { - SDL_SetError("Installed Vulkan doesn't implement the " - VK_KHR_SURFACE_EXTENSION_NAME " extension"); + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_SURFACE_EXTENSION_NAME " extension"); goto fail; } else if (!hasAndroidSurfaceExtension) { - SDL_SetError("Installed Vulkan doesn't implement the " - VK_KHR_ANDROID_SURFACE_EXTENSION_NAME "extension"); + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_ANDROID_SURFACE_EXTENSION_NAME "extension"); goto fail; } return 0; @@ -113,9 +110,9 @@ void Android_Vulkan_UnloadLibrary(_THIS) } SDL_bool Android_Vulkan_GetInstanceExtensions(_THIS, - SDL_Window *window, - unsigned *count, - const char **names) + SDL_Window *window, + unsigned *count, + const char **names) { static const char *const extensionsForAndroid[] = { VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_ANDROID_SURFACE_EXTENSION_NAME @@ -125,22 +122,22 @@ SDL_bool Android_Vulkan_GetInstanceExtensions(_THIS, return SDL_FALSE; } return SDL_Vulkan_GetInstanceExtensions_Helper( - count, names, SDL_arraysize(extensionsForAndroid), - extensionsForAndroid); + count, names, SDL_arraysize(extensionsForAndroid), + extensionsForAndroid); } SDL_bool Android_Vulkan_CreateSurface(_THIS, - SDL_Window *window, - VkInstance instance, - VkSurfaceKHR *surface) + SDL_Window *window, + VkInstance instance, + VkSurfaceKHR *surface) { SDL_WindowData *windowData = (SDL_WindowData *)window->driverdata; PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR)vkGetInstanceProcAddr( - instance, - "vkCreateAndroidSurfaceKHR"); + instance, + "vkCreateAndroidSurfaceKHR"); VkAndroidSurfaceCreateInfoKHR createInfo; VkResult result; diff --git a/src/video/android/SDL_androidvulkan.h b/src/video/android/SDL_androidvulkan.h index f8f23eee5..007c1404e 100644 --- a/src/video/android/SDL_androidvulkan.h +++ b/src/video/android/SDL_androidvulkan.h @@ -37,13 +37,13 @@ int Android_Vulkan_LoadLibrary(_THIS, const char *path); void Android_Vulkan_UnloadLibrary(_THIS); SDL_bool Android_Vulkan_GetInstanceExtensions(_THIS, - SDL_Window *window, - unsigned *count, - const char **names); + SDL_Window *window, + unsigned *count, + const char **names); SDL_bool Android_Vulkan_CreateSurface(_THIS, - SDL_Window *window, - VkInstance instance, - VkSurfaceKHR *surface); + SDL_Window *window, + VkInstance instance, + VkSurfaceKHR *surface); #endif diff --git a/src/video/android/SDL_androidwindow.c b/src/video/android/SDL_androidwindow.c index b94c38dff..db3d0b483 100644 --- a/src/video/android/SDL_androidwindow.c +++ b/src/video/android/SDL_androidwindow.c @@ -36,8 +36,7 @@ /* Currently only one window */ SDL_Window *Android_Window = NULL; -int -Android_CreateWindow(_THIS, SDL_Window * window) +int Android_CreateWindow(_THIS, SDL_Window *window) { SDL_WindowData *data; int retval = 0; @@ -59,13 +58,13 @@ Android_CreateWindow(_THIS, SDL_Window * window) window->h = Android_SurfaceHeight; window->flags &= ~SDL_WINDOW_HIDDEN; - window->flags |= SDL_WINDOW_SHOWN; /* only one window on Android */ + window->flags |= SDL_WINDOW_SHOWN; /* only one window on Android */ /* One window, it always has focus */ SDL_SetMouseFocus(window); SDL_SetKeyboardFocus(window); - data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data)); + data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data)); if (data == NULL) { retval = SDL_OutOfMemory(); goto endfunction; @@ -83,7 +82,7 @@ Android_CreateWindow(_THIS, SDL_Window * window) incompatible with vkCreateAndroidSurfaceKHR */ #if SDL_VIDEO_OPENGL_EGL if ((window->flags & SDL_WINDOW_OPENGL) != 0) { - data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->native_window); + data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType)data->native_window); if (data->egl_surface == EGL_NO_SURFACE) { ANativeWindow_release(data->native_window); @@ -104,14 +103,12 @@ endfunction: return retval; } -void -Android_SetWindowTitle(_THIS, SDL_Window *window) +void Android_SetWindowTitle(_THIS, SDL_Window *window) { Android_JNI_SetActivityTitle(window->title); } -void -Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen) +void Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen) { SDL_LockMutex(Android_ActivityMutex); @@ -162,8 +159,7 @@ endfunction: SDL_UnlockMutex(Android_ActivityMutex); } -void -Android_MinimizeWindow(_THIS, SDL_Window *window) +void Android_MinimizeWindow(_THIS, SDL_Window *window) { Android_JNI_MinizeWindow(); } @@ -174,8 +170,7 @@ void Android_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable) Android_JNI_SetOrientation(window->w, window->h, window->flags & SDL_WINDOW_RESIZABLE, SDL_GetHint(SDL_HINT_ORIENTATIONS)); } -void -Android_DestroyWindow(_THIS, SDL_Window *window) +void Android_DestroyWindow(_THIS, SDL_Window *window) { SDL_LockMutex(Android_ActivityMutex); @@ -183,7 +178,7 @@ Android_DestroyWindow(_THIS, SDL_Window *window) Android_Window = NULL; if (window->driverdata) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; #if SDL_VIDEO_OPENGL_EGL if (data->egl_surface != EGL_NO_SURFACE) { @@ -205,7 +200,7 @@ Android_DestroyWindow(_THIS, SDL_Window *window) SDL_bool Android_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; if (info->version.major == SDL_MAJOR_VERSION) { info->subsystem = SDL_SYSWM_ANDROID; diff --git a/src/video/android/SDL_androidwindow.h b/src/video/android/SDL_androidwindow.h index 58e459006..a2140b1ac 100644 --- a/src/video/android/SDL_androidwindow.h +++ b/src/video/android/SDL_androidwindow.h @@ -42,9 +42,9 @@ typedef struct EGLSurface egl_surface; EGLContext egl_context; /* We use this to preserve the context when losing focus */ #endif - SDL_bool backup_done; + SDL_bool backup_done; ANativeWindow *native_window; - + } SDL_WindowData; #endif /* SDL_androidwindow_h_ */ diff --git a/src/video/cocoa/SDL_cocoaclipboard.h b/src/video/cocoa/SDL_cocoaclipboard.h index c8c4d6808..30f588043 100644 --- a/src/video/cocoa/SDL_cocoaclipboard.h +++ b/src/video/cocoa/SDL_cocoaclipboard.h @@ -29,7 +29,7 @@ extern int Cocoa_SetClipboardText(_THIS, const char *text); extern char *Cocoa_GetClipboardText(_THIS); extern SDL_bool Cocoa_HasClipboardText(_THIS); -extern void Cocoa_CheckClipboardUpdate(SDL_VideoData * data); +extern void Cocoa_CheckClipboardUpdate(SDL_VideoData *data); #endif /* SDL_cocoaclipboard_h_ */ diff --git a/src/video/cocoa/SDL_cocoaclipboard.m b/src/video/cocoa/SDL_cocoaclipboard.m index e3878ce8f..98fc48d1b 100644 --- a/src/video/cocoa/SDL_cocoaclipboard.m +++ b/src/video/cocoa/SDL_cocoaclipboard.m @@ -25,53 +25,54 @@ #include "SDL_cocoavideo.h" #include "../../events/SDL_clipboardevents_c.h" -int -Cocoa_SetClipboardText(_THIS, const char *text) -{ @autoreleasepool +int Cocoa_SetClipboardText(_THIS, const char *text) { - SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata; - NSPasteboard *pasteboard; - NSString *format = NSPasteboardTypeString; - NSString *nsstr = [NSString stringWithUTF8String:text]; - if (nsstr == nil) { - return SDL_SetError("Couldn't create NSString; is your string data in UTF-8 format?"); + @autoreleasepool { + SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata; + NSPasteboard *pasteboard; + NSString *format = NSPasteboardTypeString; + NSString *nsstr = [NSString stringWithUTF8String:text]; + if (nsstr == nil) { + return SDL_SetError("Couldn't create NSString; is your string data in UTF-8 format?"); + } + + pasteboard = [NSPasteboard generalPasteboard]; + data.clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil]; + [pasteboard setString:nsstr forType:format]; + + return 0; } - - pasteboard = [NSPasteboard generalPasteboard]; - data.clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil]; - [pasteboard setString:nsstr forType:format]; - - return 0; -}} +} char * Cocoa_GetClipboardText(_THIS) -{ @autoreleasepool { - NSPasteboard *pasteboard; - NSString *format = NSPasteboardTypeString; - NSString *available; - char *text; + @autoreleasepool { + NSPasteboard *pasteboard; + NSString *format = NSPasteboardTypeString; + NSString *available; + char *text; - pasteboard = [NSPasteboard generalPasteboard]; - available = [pasteboard availableTypeFromArray:[NSArray arrayWithObject:format]]; - if ([available isEqualToString:format]) { - NSString* string; - const char *utf8; + pasteboard = [NSPasteboard generalPasteboard]; + available = [pasteboard availableTypeFromArray:[NSArray arrayWithObject:format]]; + if ([available isEqualToString:format]) { + NSString *string; + const char *utf8; - string = [pasteboard stringForType:format]; - if (string == nil) { - utf8 = ""; + string = [pasteboard stringForType:format]; + if (string == nil) { + utf8 = ""; + } else { + utf8 = [string UTF8String]; + } + text = SDL_strdup(utf8 ? utf8 : ""); } else { - utf8 = [string UTF8String]; + text = SDL_strdup(""); } - text = SDL_strdup(utf8 ? utf8 : ""); - } else { - text = SDL_strdup(""); - } - return text; -}} + return text; + } +} SDL_bool Cocoa_HasClipboardText(_THIS) @@ -85,22 +86,22 @@ Cocoa_HasClipboardText(_THIS) return result; } -void -Cocoa_CheckClipboardUpdate(SDL_VideoData * data) -{ @autoreleasepool +void Cocoa_CheckClipboardUpdate(SDL_VideoData *data) { - NSPasteboard *pasteboard; - NSInteger count; + @autoreleasepool { + NSPasteboard *pasteboard; + NSInteger count; - pasteboard = [NSPasteboard generalPasteboard]; - count = [pasteboard changeCount]; - if (count != data.clipboard_count) { - if (data.clipboard_count) { - SDL_SendClipboardUpdate(); + pasteboard = [NSPasteboard generalPasteboard]; + count = [pasteboard changeCount]; + if (count != data.clipboard_count) { + if (data.clipboard_count) { + SDL_SendClipboardUpdate(); + } + data.clipboard_count = count; } - data.clipboard_count = count; } -}} +} #endif /* SDL_VIDEO_DRIVER_COCOA */ diff --git a/src/video/cocoa/SDL_cocoaevents.h b/src/video/cocoa/SDL_cocoaevents.h index ae49be099..7187ce43f 100644 --- a/src/video/cocoa/SDL_cocoaevents.h +++ b/src/video/cocoa/SDL_cocoaevents.h @@ -25,7 +25,7 @@ extern void Cocoa_RegisterApp(void); extern void Cocoa_PumpEvents(_THIS); -extern int Cocoa_WaitEventTimeout(_THIS, int timeout); +extern int Cocoa_WaitEventTimeout(_THIS, int timeout); extern void Cocoa_SendWakeupEvent(_THIS, SDL_Window *window); extern void Cocoa_SuspendScreenSaver(_THIS); diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m index ed2aaa6c6..a959cebca 100644 --- a/src/video/cocoa/SDL_cocoaevents.m +++ b/src/video/cocoa/SDL_cocoaevents.m @@ -45,7 +45,7 @@ static SDL_Window *FindSDLWindowForNSWindow(NSWindow *win) SDL_VideoDevice *device = SDL_GetVideoDevice(); if (device && device->windows) { for (sdlwindow = device->windows; sdlwindow; sdlwindow = sdlwindow->next) { - NSWindow *nswindow = ((__bridge SDL_WindowData *) sdlwindow->driverdata).nswindow; + NSWindow *nswindow = ((__bridge SDL_WindowData *)sdlwindow->driverdata).nswindow; if (win == nswindow) return sdlwindow; } @@ -78,26 +78,26 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) SDL_VideoDevice *_this = SDL_GetVideoDevice(); switch ([theEvent type]) { - case NSEventTypeLeftMouseDown: - case NSEventTypeOtherMouseDown: - case NSEventTypeRightMouseDown: - case NSEventTypeLeftMouseUp: - case NSEventTypeOtherMouseUp: - case NSEventTypeRightMouseUp: - case NSEventTypeLeftMouseDragged: - case NSEventTypeRightMouseDragged: - case NSEventTypeOtherMouseDragged: /* usually middle mouse dragged */ - case NSEventTypeMouseMoved: - case NSEventTypeScrollWheel: - Cocoa_HandleMouseEvent(_this, theEvent); - break; - case NSEventTypeKeyDown: - case NSEventTypeKeyUp: - case NSEventTypeFlagsChanged: - Cocoa_HandleKeyEvent(_this, theEvent); - break; - default: - break; + case NSEventTypeLeftMouseDown: + case NSEventTypeOtherMouseDown: + case NSEventTypeRightMouseDown: + case NSEventTypeLeftMouseUp: + case NSEventTypeOtherMouseUp: + case NSEventTypeRightMouseUp: + case NSEventTypeLeftMouseDragged: + case NSEventTypeRightMouseDragged: + case NSEventTypeOtherMouseDragged: /* usually middle mouse dragged */ + case NSEventTypeMouseMoved: + case NSEventTypeScrollWheel: + Cocoa_HandleMouseEvent(_this, theEvent); + break; + case NSEventTypeKeyDown: + case NSEventTypeKeyUp: + case NSEventTypeFlagsChanged: + Cocoa_HandleKeyEvent(_this, theEvent); + break; + default: + break; } } @@ -116,22 +116,23 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) + (void)registerUserDefaults { NSDictionary *appDefaults = [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithBool:NO], @"AppleMomentumScrollSupported", - [NSNumber numberWithBool:NO], @"ApplePressAndHoldEnabled", - [NSNumber numberWithBool:YES], @"ApplePersistenceIgnoreState", - nil]; + [NSNumber numberWithBool:NO], @"AppleMomentumScrollSupported", + [NSNumber numberWithBool:NO], @"ApplePressAndHoldEnabled", + [NSNumber numberWithBool:YES], @"ApplePersistenceIgnoreState", + nil]; [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults]; } @end // SDLApplication /* setAppleMenu disappeared from the headers in 10.4 */ -@interface NSApplication(NSAppleMenu) +@interface NSApplication (NSAppleMenu) - (void)setAppleMenu:(NSMenu *)menu; @end -@interface SDLAppDelegate : NSObject { -@public +@interface SDLAppDelegate : NSObject +{ + @public BOOL seenFirstActivate; } @@ -185,7 +186,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) - (void)windowWillClose:(NSNotification *)notification; { - NSWindow *win = (NSWindow*)[notification object]; + NSWindow *win = (NSWindow *)[notification object]; if (![win isKeyWindow]) { return; @@ -292,7 +293,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) [i activateWithOptions:NSApplicationActivateIgnoringOtherApps]; break; } - SDL_Delay(300); /* !!! FIXME: this isn't right. */ + SDL_Delay(300); /* !!! FIXME: this isn't right. */ [NSApp activateIgnoringOtherApps:YES]; } @@ -303,7 +304,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) - (void)handleURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent { - NSString* path = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; + NSString *path = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; SDL_SendDropFile(NULL, [path UTF8String]); SDL_SendDropComplete(NULL); } @@ -312,8 +313,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) static SDLAppDelegate *appDelegate = nil; -static NSString * -GetApplicationName(void) +static NSString *GetApplicationName(void) { NSString *appName; @@ -330,8 +330,7 @@ GetApplicationName(void) return appName; } -static bool -LoadMainMenuNibIfAvailable(void) +static bool LoadMainMenuNibIfAvailable(void) { #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 NSDictionary *infoDict; @@ -344,20 +343,19 @@ LoadMainMenuNibIfAvailable(void) infoDict = [[NSBundle mainBundle] infoDictionary]; if (infoDict) { mainNibFileName = [infoDict valueForKey:@"NSMainNibFile"]; - + if (mainNibFileName) { success = [[NSBundle mainBundle] loadNibNamed:mainNibFileName owner:[NSApplication sharedApplication] topLevelObjects:nil]; } } - + return success; #else return false; #endif } -static void -CreateApplicationMenus(void) +static void CreateApplicationMenus(void) { NSString *appName; NSString *title; @@ -370,7 +368,7 @@ CreateApplicationMenus(void) if (NSApp == nil) { return; } - + mainMenu = [[NSMenu alloc] init]; /* Create the main menu bar */ @@ -402,7 +400,7 @@ CreateApplicationMenus(void) [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"]; menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; - [menuItem setKeyEquivalentModifierMask:(NSEventModifierFlagOption|NSEventModifierFlagCommand)]; + [menuItem setKeyEquivalentModifierMask:(NSEventModifierFlagOption | NSEventModifierFlagCommand)]; [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""]; @@ -428,7 +426,7 @@ CreateApplicationMenus(void) [windowMenu addItemWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; [windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""]; - + /* Add the fullscreen toggle menu option. */ /* Cocoa should update the title to Enter or Exit Full Screen automatically. * But if not, then just fallback to Toggle Full Screen. @@ -446,71 +444,70 @@ CreateApplicationMenus(void) [NSApp setWindowsMenu:windowMenu]; } -void -Cocoa_RegisterApp(void) -{ @autoreleasepool +void Cocoa_RegisterApp(void) { - /* This can get called more than once! Be careful what you initialize! */ + @autoreleasepool { + /* This can get called more than once! Be careful what you initialize! */ - if (NSApp == nil) { - [SDLApplication sharedApplication]; - SDL_assert(NSApp != nil); + if (NSApp == nil) { + [SDLApplication sharedApplication]; + SDL_assert(NSApp != nil); - s_bShouldHandleEventsInSDLApplication = SDL_TRUE; + s_bShouldHandleEventsInSDLApplication = SDL_TRUE; - if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) { - [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; - } + if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) { + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + } - /* If there aren't already menus in place, look to see if there's - * a nib we should use. If not, then manually create the basic - * menus we meed. - */ - if ([NSApp mainMenu] == nil) { - bool nibLoaded; - - nibLoaded = LoadMainMenuNibIfAvailable(); - if (!nibLoaded) { - CreateApplicationMenus(); + /* If there aren't already menus in place, look to see if there's + * a nib we should use. If not, then manually create the basic + * menus we meed. + */ + if ([NSApp mainMenu] == nil) { + bool nibLoaded; + + nibLoaded = LoadMainMenuNibIfAvailable(); + if (!nibLoaded) { + CreateApplicationMenus(); + } + } + [NSApp finishLaunching]; + if ([NSApp delegate]) { + /* The SDL app delegate calls this in didFinishLaunching if it's + * attached to the NSApp, otherwise we need to call it manually. + */ + [SDLApplication registerUserDefaults]; } } - [NSApp finishLaunching]; - if ([NSApp delegate]) { - /* The SDL app delegate calls this in didFinishLaunching if it's - * attached to the NSApp, otherwise we need to call it manually. + if (NSApp && !appDelegate) { + appDelegate = [[SDLAppDelegate alloc] init]; + + /* If someone else has an app delegate, it means we can't turn a + * termination into SDL_Quit, and we can't handle application:openFile: */ - [SDLApplication registerUserDefaults]; + if (![NSApp delegate]) { + /* Only register the URL event handler if we are being set as the + * app delegate to avoid replacing any existing event handler. + */ + [[NSAppleEventManager sharedAppleEventManager] + setEventHandler:appDelegate + andSelector:@selector(handleURLEvent:withReplyEvent:) + forEventClass:kInternetEventClass + andEventID:kAEGetURL]; + + [(NSApplication *)NSApp setDelegate:appDelegate]; + } else { + appDelegate->seenFirstActivate = YES; + } } } - if (NSApp && !appDelegate) { - appDelegate = [[SDLAppDelegate alloc] init]; +} - /* If someone else has an app delegate, it means we can't turn a - * termination into SDL_Quit, and we can't handle application:openFile: - */ - if (![NSApp delegate]) { - /* Only register the URL event handler if we are being set as the - * app delegate to avoid replacing any existing event handler. - */ - [[NSAppleEventManager sharedAppleEventManager] - setEventHandler:appDelegate - andSelector:@selector(handleURLEvent:withReplyEvent:) - forEventClass:kInternetEventClass - andEventID:kAEGetURL]; - - [(NSApplication *)NSApp setDelegate:appDelegate]; - } else { - appDelegate->seenFirstActivate = YES; - } - } -}} - -int -Cocoa_PumpEventsUntilDate(_THIS, NSDate *expiration, bool accumulate) +int Cocoa_PumpEventsUntilDate(_THIS, NSDate *expiration, bool accumulate) { - for ( ; ; ) { - NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:expiration inMode:NSDefaultRunLoopMode dequeue:YES ]; - if ( event == nil ) { + for (;;) { + NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:expiration inMode:NSDefaultRunLoopMode dequeue:YES]; + if (event == nil) { return 0; } @@ -520,62 +517,62 @@ Cocoa_PumpEventsUntilDate(_THIS, NSDate *expiration, bool accumulate) // Pass events down to SDLApplication to be handled in sendEvent: [NSApp sendEvent:event]; - if ( !accumulate) { + if (!accumulate) { break; } } return 1; } -int -Cocoa_WaitEventTimeout(_THIS, int timeout) -{ @autoreleasepool +int Cocoa_WaitEventTimeout(_THIS, int timeout) { - if (timeout > 0) { - NSDate *limitDate = [NSDate dateWithTimeIntervalSinceNow: (double) timeout / 1000.0]; - return Cocoa_PumpEventsUntilDate(_this, limitDate, false); - } else if (timeout == 0) { - return Cocoa_PumpEventsUntilDate(_this, [NSDate distantPast], false); - } else { - while (Cocoa_PumpEventsUntilDate(_this, [NSDate distantFuture], false) == 0) { + @autoreleasepool { + if (timeout > 0) { + NSDate *limitDate = [NSDate dateWithTimeIntervalSinceNow:(double)timeout / 1000.0]; + return Cocoa_PumpEventsUntilDate(_this, limitDate, false); + } else if (timeout == 0) { + return Cocoa_PumpEventsUntilDate(_this, [NSDate distantPast], false); + } else { + while (Cocoa_PumpEventsUntilDate(_this, [NSDate distantFuture], false) == 0) { + } } + return 1; } - return 1; -}} +} -void -Cocoa_PumpEvents(_THIS) -{ @autoreleasepool +void Cocoa_PumpEvents(_THIS) { - Cocoa_PumpEventsUntilDate(_this, [NSDate distantPast], true); -}} + @autoreleasepool { + Cocoa_PumpEventsUntilDate(_this, [NSDate distantPast], true); + } +} void Cocoa_SendWakeupEvent(_THIS, SDL_Window *window) -{ @autoreleasepool { - NSEvent* event = [NSEvent otherEventWithType: NSEventTypeApplicationDefined - location: NSMakePoint(0,0) - modifierFlags: 0 - timestamp: 0.0 - windowNumber: ((__bridge SDL_WindowData *) window->driverdata).window_number - context: nil - subtype: 0 - data1: 0 - data2: 0]; + @autoreleasepool { + NSEvent *event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined + location:NSMakePoint(0, 0) + modifierFlags:0 + timestamp:0.0 + windowNumber:((__bridge SDL_WindowData *)window->driverdata).window_number + context:nil + subtype:0 + data1:0 + data2:0]; - [NSApp postEvent: event atStart: YES]; -}} - -void -Cocoa_SuspendScreenSaver(_THIS) -{ @autoreleasepool -{ - SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata; - - if (data.screensaver_assertion) { - IOPMAssertionRelease(data.screensaver_assertion); - data.screensaver_assertion = kIOPMNullAssertionID; + [NSApp postEvent:event atStart:YES]; } +} + +void Cocoa_SuspendScreenSaver(_THIS) +{ + @autoreleasepool { + SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata; + + if (data.screensaver_assertion) { + IOPMAssertionRelease(data.screensaver_assertion); + data.screensaver_assertion = kIOPMNullAssertionID; + } if (_this->suspend_screensaver) { /* FIXME: this should ideally describe the real reason why the game @@ -591,7 +588,7 @@ Cocoa_SuspendScreenSaver(_THIS) &assertion); data.screensaver_assertion = assertion; } -}} +} #endif /* SDL_VIDEO_DRIVER_COCOA */ diff --git a/src/video/cocoa/SDL_cocoakeyboard.h b/src/video/cocoa/SDL_cocoakeyboard.h index e3b8460b7..8d068151f 100644 --- a/src/video/cocoa/SDL_cocoakeyboard.h +++ b/src/video/cocoa/SDL_cocoakeyboard.h @@ -24,14 +24,14 @@ #define SDL_cocoakeyboard_h_ extern void Cocoa_InitKeyboard(_THIS); -extern void Cocoa_HandleKeyEvent(_THIS, NSEvent * event); +extern void Cocoa_HandleKeyEvent(_THIS, NSEvent *event); extern void Cocoa_QuitKeyboard(_THIS); extern void Cocoa_StartTextInput(_THIS); extern void Cocoa_StopTextInput(_THIS); extern void Cocoa_SetTextInputRect(_THIS, const SDL_Rect *rect); -extern void Cocoa_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed); +extern void Cocoa_SetWindowKeyboardGrab(_THIS, SDL_Window *window, SDL_bool grabbed); #endif /* SDL_cocoakeyboard_h_ */ diff --git a/src/video/cocoa/SDL_cocoakeyboard.m b/src/video/cocoa/SDL_cocoakeyboard.m index 096b71a4c..43e3c9696 100644 --- a/src/video/cocoa/SDL_cocoakeyboard.m +++ b/src/video/cocoa/SDL_cocoakeyboard.m @@ -33,11 +33,12 @@ /*#define DEBUG_IME NSLog */ #define DEBUG_IME(...) -@interface SDLTranslatorResponder : NSView { +@interface SDLTranslatorResponder : NSView +{ NSString *_markedText; - NSRange _markedRange; - NSRange _selectedRange; - SDL_Rect _inputRect; + NSRange _markedRange; + NSRange _selectedRange; + SDL_Rect _inputRect; } - (void)doCommandBySelector:(SEL)myselector; - (void)setInputRect:(const SDL_Rect *)rect; @@ -60,7 +61,7 @@ /* Could be NSString or NSAttributedString, so we have * to test and convert it before return as SDL event */ - if ([aString isKindOfClass: [NSAttributedString class]]) { + if ([aString isKindOfClass:[NSAttributedString class]]) { str = [[aString string] UTF8String]; } else { str = [aString UTF8String]; @@ -116,10 +117,10 @@ _markedRange = NSMakeRange(0, [aString length]); SDL_SendEditingText([aString UTF8String], - (int) selectedRange.location, (int) selectedRange.length); + (int)selectedRange.location, (int)selectedRange.length); DEBUG_IME(@"setMarkedText: %@, (%d, %d)", _markedText, - selectedRange.location, selectedRange.length); + selectedRange.location, selectedRange.length); } - (void)unmarkText @@ -142,8 +143,8 @@ } DEBUG_IME(@"firstRectForCharacterRange: (%d, %d): windowHeight = %g, rect = %@", - aRange.location, aRange.length, windowHeight, - NSStringFromRect(rect)); + aRange.location, aRange.length, windowHeight, + NSStringFromRect(rect)); rect = [window convertRectToScreen:rect]; @@ -158,7 +159,7 @@ - (NSInteger)conversationIdentifier { - return (NSInteger) self; + return (NSInteger)self; } /* This method returns the index for character that is @@ -182,43 +183,42 @@ @end -static void -HandleModifiers(_THIS, unsigned short scancode, unsigned int modifierFlags) +static void HandleModifiers(_THIS, unsigned short scancode, unsigned int modifierFlags) { SDL_Scancode code = darwin_scancode_table[scancode]; - const SDL_Scancode codes[] = { - SDL_SCANCODE_LSHIFT, - SDL_SCANCODE_LCTRL, - SDL_SCANCODE_LALT, - SDL_SCANCODE_LGUI, - SDL_SCANCODE_RSHIFT, - SDL_SCANCODE_RCTRL, - SDL_SCANCODE_RALT, - SDL_SCANCODE_RGUI, - SDL_SCANCODE_LSHIFT, - SDL_SCANCODE_LCTRL, - SDL_SCANCODE_LALT, - SDL_SCANCODE_LGUI, }; + const SDL_Scancode codes[] = { + SDL_SCANCODE_LSHIFT, + SDL_SCANCODE_LCTRL, + SDL_SCANCODE_LALT, + SDL_SCANCODE_LGUI, + SDL_SCANCODE_RSHIFT, + SDL_SCANCODE_RCTRL, + SDL_SCANCODE_RALT, + SDL_SCANCODE_RGUI, + SDL_SCANCODE_LSHIFT, + SDL_SCANCODE_LCTRL, + SDL_SCANCODE_LALT, + SDL_SCANCODE_LGUI, + }; - const unsigned int modifiers[] = { - NX_DEVICELSHIFTKEYMASK, - NX_DEVICELCTLKEYMASK, - NX_DEVICELALTKEYMASK, - NX_DEVICELCMDKEYMASK, - NX_DEVICERSHIFTKEYMASK, - NX_DEVICERCTLKEYMASK, - NX_DEVICERALTKEYMASK, + const unsigned int modifiers[] = { + NX_DEVICELSHIFTKEYMASK, + NX_DEVICELCTLKEYMASK, + NX_DEVICELALTKEYMASK, + NX_DEVICELCMDKEYMASK, + NX_DEVICERSHIFTKEYMASK, + NX_DEVICERCTLKEYMASK, + NX_DEVICERALTKEYMASK, NX_DEVICERCMDKEYMASK, NX_SHIFTMASK, - NX_CONTROLMASK, + NX_CONTROLMASK, NX_ALTERNATEMASK, - NX_COMMANDMASK }; + NX_COMMANDMASK + }; - for (int i = 0; i < 12; i++) - { - if (code == codes[i]) - { + for (int i = 0; i < 12; i++) { + if (code == codes[i]) { if (modifierFlags & modifiers[i]) SDL_SendKeyboardKey(SDL_PRESSED, code); else @@ -227,8 +227,7 @@ HandleModifiers(_THIS, unsigned short scancode, unsigned int modifierFlags) } } -static void -UpdateKeymap(SDL_VideoData *data, SDL_bool send_event) +static void UpdateKeymap(SDL_VideoData *data, SDL_bool send_event) { TISInputSourceRef key_layout; const void *chr_data; @@ -271,11 +270,11 @@ UpdateKeymap(SDL_VideoData *data, SDL_bool send_event) } dead_key_state = 0; - err = UCKeyTranslate ((UCKeyboardLayout *) chr_data, - i, kUCKeyActionDown, - 0, keyboard_type, - kUCKeyTranslateNoDeadKeysMask, - &dead_key_state, 8, &len, s); + err = UCKeyTranslate((UCKeyboardLayout *)chr_data, + i, kUCKeyActionDown, + 0, keyboard_type, + kUCKeyTranslateNoDeadKeysMask, + &dead_key_state, 8, &len, s); if (err != noErr) { continue; } @@ -292,10 +291,9 @@ cleanup: CFRelease(key_layout); } -void -Cocoa_InitKeyboard(_THIS) +void Cocoa_InitKeyboard(_THIS) { - SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata; UpdateKeymap(data, SDL_FALSE); @@ -311,54 +309,53 @@ Cocoa_InitKeyboard(_THIS) SDL_ToggleModState(KMOD_CAPS, (data.modifierFlags & NSEventModifierFlagCapsLock) != 0); } -void -Cocoa_StartTextInput(_THIS) -{ @autoreleasepool +void Cocoa_StartTextInput(_THIS) { - NSView *parentView; - SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata; - SDL_Window *window = SDL_GetKeyboardFocus(); - NSWindow *nswindow = nil; - if (window) { - nswindow = ((__bridge SDL_WindowData*)window->driverdata).nswindow; + @autoreleasepool { + NSView *parentView; + SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata; + SDL_Window *window = SDL_GetKeyboardFocus(); + NSWindow *nswindow = nil; + if (window) { + nswindow = ((__bridge SDL_WindowData *)window->driverdata).nswindow; + } + + parentView = [nswindow contentView]; + + /* We only keep one field editor per process, since only the front most + * window can receive text input events, so it make no sense to keep more + * than one copy. When we switched to another window and requesting for + * text input, simply remove the field editor from its superview then add + * it to the front most window's content view */ + if (!data.fieldEdit) { + data.fieldEdit = + [[SDLTranslatorResponder alloc] initWithFrame:NSMakeRect(0.0, 0.0, 0.0, 0.0)]; + } + + if (![[data.fieldEdit superview] isEqual:parentView]) { + /* DEBUG_IME(@"add fieldEdit to window contentView"); */ + [data.fieldEdit removeFromSuperview]; + [parentView addSubview:data.fieldEdit]; + [nswindow makeFirstResponder:data.fieldEdit]; + } } +} - parentView = [nswindow contentView]; - - /* We only keep one field editor per process, since only the front most - * window can receive text input events, so it make no sense to keep more - * than one copy. When we switched to another window and requesting for - * text input, simply remove the field editor from its superview then add - * it to the front most window's content view */ - if (!data.fieldEdit) { - data.fieldEdit = - [[SDLTranslatorResponder alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)]; - } - - if (![[data.fieldEdit superview] isEqual:parentView]) { - /* DEBUG_IME(@"add fieldEdit to window contentView"); */ - [data.fieldEdit removeFromSuperview]; - [parentView addSubview: data.fieldEdit]; - [nswindow makeFirstResponder: data.fieldEdit]; - } -}} - -void -Cocoa_StopTextInput(_THIS) -{ @autoreleasepool +void Cocoa_StopTextInput(_THIS) { - SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata; + @autoreleasepool { + SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata; - if (data && data.fieldEdit) { - [data.fieldEdit removeFromSuperview]; - data.fieldEdit = nil; + if (data && data.fieldEdit) { + [data.fieldEdit removeFromSuperview]; + data.fieldEdit = nil; + } } -}} +} -void -Cocoa_SetTextInputRect(_THIS, const SDL_Rect *rect) +void Cocoa_SetTextInputRect(_THIS, const SDL_Rect *rect) { - SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata; if (!rect) { SDL_InvalidParamError("rect"); @@ -368,14 +365,13 @@ Cocoa_SetTextInputRect(_THIS, const SDL_Rect *rect) [data.fieldEdit setInputRect:rect]; } -void -Cocoa_HandleKeyEvent(_THIS, NSEvent *event) +void Cocoa_HandleKeyEvent(_THIS, NSEvent *event) { unsigned short scancode; SDL_Scancode code; - SDL_VideoData *data = _this ? ((__bridge SDL_VideoData *) _this->driverdata) : nil; + SDL_VideoData *data = _this ? ((__bridge SDL_VideoData *)_this->driverdata) : nil; if (!data) { - return; /* can happen when returning from fullscreen Space on shutdown */ + return; /* can happen when returning from fullscreen Space on shutdown */ } scancode = [event keyCode]; @@ -424,20 +420,20 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event) SDL_SendKeyboardKey(SDL_RELEASED, code); break; case NSEventTypeFlagsChanged: - HandleModifiers(_this, scancode, (unsigned int)[event modifierFlags]); + HandleModifiers(_this, scancode, (unsigned int)[event modifierFlags]); break; default: /* just to avoid compiler warnings */ break; } } -void -Cocoa_QuitKeyboard(_THIS) +void Cocoa_QuitKeyboard(_THIS) { } typedef int CGSConnection; -typedef enum { +typedef enum +{ CGSGlobalHotKeyEnable = 0, CGSGlobalHotKeyDisable = 1, } CGSGlobalHotKeyOperatingMode; @@ -445,8 +441,7 @@ typedef enum { extern CGSConnection _CGSDefaultConnection(void); extern CGError CGSSetGlobalHotKeyOperatingMode(CGSConnection connection, CGSGlobalHotKeyOperatingMode mode); -void -Cocoa_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed) +void Cocoa_SetWindowKeyboardGrab(_THIS, SDL_Window *window, SDL_bool grabbed) { #if SDL_MAC_NO_SANDBOX CGSSetGlobalHotKeyOperatingMode(_CGSDefaultConnection(), grabbed ? CGSGlobalHotKeyDisable : CGSGlobalHotKeyEnable); diff --git a/src/video/cocoa/SDL_cocoamessagebox.m b/src/video/cocoa/SDL_cocoamessagebox.m index 1f8eddc3a..1a3d622dd 100644 --- a/src/video/cocoa/SDL_cocoamessagebox.m +++ b/src/video/cocoa/SDL_cocoamessagebox.m @@ -27,17 +27,18 @@ #include "SDL_messagebox.h" #include "SDL_cocoavideo.h" -@interface SDLMessageBoxPresenter : NSObject { -@public +@interface SDLMessageBoxPresenter : NSObject +{ + @public NSInteger clicked; NSWindow *nswindow; } -- (id) initWithParentWindow:(SDL_Window *)window; -- (void) alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo; +- (id)initWithParentWindow:(SDL_Window *)window; +- (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo; @end @implementation SDLMessageBoxPresenter -- (id) initWithParentWindow:(SDL_Window *)window +- (id)initWithParentWindow:(SDL_Window *)window { self = [super init]; if (self) { @@ -45,7 +46,7 @@ /* Retain the NSWindow because we'll show the alert later on the main thread */ if (window) { - nswindow = ((__bridge SDL_WindowData *) window->driverdata).nswindow; + nswindow = ((__bridge SDL_WindowData *)window->driverdata).nswindow; } else { nswindow = nil; } @@ -54,19 +55,23 @@ return self; } -- (void)showAlert:(NSAlert*)alert +- (void)showAlert:(NSAlert *)alert { if (nswindow) { #ifdef MAC_OS_X_VERSION_10_9 if ([alert respondsToSelector:@selector(beginSheetModalForWindow:completionHandler:)]) { - [alert beginSheetModalForWindow:nswindow completionHandler:^(NSModalResponse returnCode) { - self->clicked = returnCode; - }]; + [alert beginSheetModalForWindow:nswindow + completionHandler:^(NSModalResponse returnCode) { + self->clicked = returnCode; + }]; } else #endif { #if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 - [alert beginSheetModalForWindow:nswindow modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:nil]; + [alert beginSheetModalForWindow:nswindow + modalDelegate:self + didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) + contextInfo:nil]; #endif } @@ -81,20 +86,18 @@ } } -- (void) alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo +- (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { clicked = returnCode; } @end - -static void -Cocoa_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid, int *returnValue) +static void Cocoa_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid, int *returnValue) { - NSAlert* alert; + NSAlert *alert; const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons; - SDLMessageBoxPresenter* presenter; + SDLMessageBoxPresenter *presenter; NSInteger clicked; int i; Cocoa_RegisterApp(); @@ -150,19 +153,21 @@ Cocoa_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid } /* Display a Cocoa message box */ -int -Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) -{ @autoreleasepool +int Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { - __block int returnValue = 0; + @autoreleasepool { + __block int returnValue = 0; - if ([NSThread isMainThread]) { - Cocoa_ShowMessageBoxImpl(messageboxdata, buttonid, &returnValue); - } else { - dispatch_sync(dispatch_get_main_queue(), ^{ Cocoa_ShowMessageBoxImpl(messageboxdata, buttonid, &returnValue); }); + if ([NSThread isMainThread]) { + Cocoa_ShowMessageBoxImpl(messageboxdata, buttonid, &returnValue); + } else { + dispatch_sync(dispatch_get_main_queue(), ^{ + Cocoa_ShowMessageBoxImpl(messageboxdata, buttonid, &returnValue); + }); + } + return returnValue; } - return returnValue; -}} +} #endif /* SDL_VIDEO_DRIVER_COCOA */ diff --git a/src/video/cocoa/SDL_cocoametalview.h b/src/video/cocoa/SDL_cocoametalview.h index 326c6a3ce..cbbc55bce 100644 --- a/src/video/cocoa/SDL_cocoametalview.h +++ b/src/video/cocoa/SDL_cocoametalview.h @@ -39,7 +39,6 @@ #import #import - @interface SDL_cocoametalview : NSView - (instancetype)initWithFrame:(NSRect)frame @@ -50,21 +49,20 @@ - (NSView *)hitTest:(NSPoint)point; /* Override superclass tag so this class can set it. */ -@property (assign, readonly) NSInteger tag; +@property(assign, readonly) NSInteger tag; -@property (nonatomic) BOOL highDPI; -@property (nonatomic) Uint32 sdlWindowID; +@property(nonatomic) BOOL highDPI; +@property(nonatomic) Uint32 sdlWindowID; @end -SDL_MetalView Cocoa_Metal_CreateView(_THIS, SDL_Window * window); +SDL_MetalView Cocoa_Metal_CreateView(_THIS, SDL_Window *window); void Cocoa_Metal_DestroyView(_THIS, SDL_MetalView view); void *Cocoa_Metal_GetLayer(_THIS, SDL_MetalView view); -void Cocoa_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h); +void Cocoa_Metal_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h); #endif /* SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) */ #endif /* SDL_cocoametalview_h_ */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/video/cocoa/SDL_cocoametalview.m b/src/video/cocoa/SDL_cocoametalview.m index 7c424ba19..2badd33f8 100644 --- a/src/video/cocoa/SDL_cocoametalview.m +++ b/src/video/cocoa/SDL_cocoametalview.m @@ -33,9 +33,7 @@ #include "SDL_events.h" #include "SDL_syswm.h" - -static int SDLCALL -SDL_MetalViewEventWatch(void *userdata, SDL_Event *event) +static int SDLCALL SDL_MetalViewEventWatch(void *userdata, SDL_Event *event) { /* Update the drawable size when SDL receives a size changed event for * the window that contains the metal view. It would be nice to use @@ -72,7 +70,7 @@ SDL_MetalViewEventWatch(void *userdata, SDL_Event *event) /* When the wantsLayer property is set to YES, this method will be invoked to * return a layer instance. */ -- (CALayer*)makeBackingLayer +- (CALayer *)makeBackingLayer { return [self.class.layerClass layer]; } @@ -93,7 +91,7 @@ SDL_MetalViewEventWatch(void *userdata, SDL_Event *event) [self updateDrawableSize]; } - + return self; } @@ -124,71 +122,78 @@ SDL_MetalViewEventWatch(void *userdata, SDL_Event *event) metalLayer.drawableSize = NSSizeToCGSize(backingSize); } -- (NSView *)hitTest:(NSPoint)point { +- (NSView *)hitTest:(NSPoint)point +{ return nil; } @end SDL_MetalView -Cocoa_Metal_CreateView(_THIS, SDL_Window * window) -{ @autoreleasepool { - SDL_WindowData* data = (__bridge SDL_WindowData *)window->driverdata; - NSView *view = data.nswindow.contentView; - BOOL highDPI = (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) != 0; - Uint32 windowID = SDL_GetWindowID(window); - SDL_cocoametalview *newview; - SDL_MetalView metalview; +Cocoa_Metal_CreateView(_THIS, SDL_Window *window) +{ + @autoreleasepool { + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; + NSView *view = data.nswindow.contentView; + BOOL highDPI = (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) != 0; + Uint32 windowID = SDL_GetWindowID(window); + SDL_cocoametalview *newview; + SDL_MetalView metalview; - newview = [[SDL_cocoametalview alloc] initWithFrame:view.frame - highDPI:highDPI - windowID:windowID]; - if (newview == nil) { - SDL_OutOfMemory(); - return NULL; + newview = [[SDL_cocoametalview alloc] initWithFrame:view.frame + highDPI:highDPI + windowID:windowID]; + if (newview == nil) { + SDL_OutOfMemory(); + return NULL; + } + + [view addSubview:newview]; + + metalview = (SDL_MetalView)CFBridgingRetain(newview); + + return metalview; } +} - [view addSubview:newview]; - - metalview = (SDL_MetalView)CFBridgingRetain(newview); - - return metalview; -}} - -void -Cocoa_Metal_DestroyView(_THIS, SDL_MetalView view) -{ @autoreleasepool { - SDL_cocoametalview *metalview = CFBridgingRelease(view); - [metalview removeFromSuperview]; -}} +void Cocoa_Metal_DestroyView(_THIS, SDL_MetalView view) +{ + @autoreleasepool { + SDL_cocoametalview *metalview = CFBridgingRelease(view); + [metalview removeFromSuperview]; + } +} void * Cocoa_Metal_GetLayer(_THIS, SDL_MetalView view) -{ @autoreleasepool { - SDL_cocoametalview *cocoaview = (__bridge SDL_cocoametalview *)view; - return (__bridge void *)cocoaview.layer; -}} - -void -Cocoa_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h) -{ @autoreleasepool { - SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; - NSView *contentView = data.sdlContentView; - SDL_cocoametalview* metalview = [contentView viewWithTag:SDL_METALVIEW_TAG]; - if (metalview) { - CAMetalLayer *layer = (CAMetalLayer*)metalview.layer; - SDL_assert(layer != NULL); - if (w) { - *w = layer.drawableSize.width; - } - if (h) { - *h = layer.drawableSize.height; - } - } else { - /* Fall back to the viewport size. */ - SDL_GetWindowSizeInPixels(window, w, h); +{ + @autoreleasepool { + SDL_cocoametalview *cocoaview = (__bridge SDL_cocoametalview *)view; + return (__bridge void *)cocoaview.layer; } -}} +} + +void Cocoa_Metal_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h) +{ + @autoreleasepool { + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; + NSView *contentView = data.sdlContentView; + SDL_cocoametalview *metalview = [contentView viewWithTag:SDL_METALVIEW_TAG]; + if (metalview) { + CAMetalLayer *layer = (CAMetalLayer *)metalview.layer; + SDL_assert(layer != NULL); + if (w) { + *w = layer.drawableSize.width; + } + if (h) { + *h = layer.drawableSize.height; + } + } else { + /* Fall back to the viewport size. */ + SDL_GetWindowSizeInPixels(window, w, h); + } + } +} #endif /* SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) */ diff --git a/src/video/cocoa/SDL_cocoamodes.h b/src/video/cocoa/SDL_cocoamodes.h index a4176dee8..ee1f95109 100644 --- a/src/video/cocoa/SDL_cocoamodes.h +++ b/src/video/cocoa/SDL_cocoamodes.h @@ -34,11 +34,11 @@ typedef struct } SDL_DisplayModeData; extern void Cocoa_InitModes(_THIS); -extern int Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect); -extern int Cocoa_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect); -extern void Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display); -extern int Cocoa_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hpdi, float * vdpi); -extern int Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); +extern int Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect); +extern int Cocoa_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect); +extern void Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay *display); +extern int Cocoa_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hpdi, float *vdpi); +extern int Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode); extern void Cocoa_QuitModes(_THIS); #endif /* SDL_cocoamodes_h_ */ diff --git a/src/video/cocoa/SDL_cocoamodes.m b/src/video/cocoa/SDL_cocoamodes.m index 072afc8e7..d91bf9f9e 100644 --- a/src/video/cocoa/SDL_cocoamodes.m +++ b/src/video/cocoa/SDL_cocoamodes.m @@ -41,9 +41,7 @@ #define kDisplayModeNativeFlag 0x02000000 #endif - -static int -CG_SetError(const char *prefix, CGDisplayErr result) +static int CG_SetError(const char *prefix, CGDisplayErr result) { const char *error; @@ -85,24 +83,22 @@ CG_SetError(const char *prefix, CGDisplayErr result) return SDL_SetError("%s: %s", prefix, error); } -static int -GetDisplayModeRefreshRate(CGDisplayModeRef vidmode, CVDisplayLinkRef link) +static int GetDisplayModeRefreshRate(CGDisplayModeRef vidmode, CVDisplayLinkRef link) { - int refreshRate = (int) (CGDisplayModeGetRefreshRate(vidmode) + 0.5); + int refreshRate = (int)(CGDisplayModeGetRefreshRate(vidmode) + 0.5); /* CGDisplayModeGetRefreshRate can return 0 (eg for built-in displays). */ if (refreshRate == 0 && link != NULL) { CVTime time = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link); if ((time.flags & kCVTimeIsIndefinite) == 0 && time.timeValue != 0) { - refreshRate = (int) ((time.timeScale / (double) time.timeValue) + 0.5); + refreshRate = (int)((time.timeScale / (double)time.timeValue) + 0.5); } } return refreshRate; } -static SDL_bool -HasValidDisplayModeFlags(CGDisplayModeRef vidmode) +static SDL_bool HasValidDisplayModeFlags(CGDisplayModeRef vidmode) { uint32_t ioflags = CGDisplayModeGetIOFlags(vidmode); @@ -119,8 +115,7 @@ HasValidDisplayModeFlags(CGDisplayModeRef vidmode) return SDL_TRUE; } -static Uint32 -GetDisplayModePixelFormat(CGDisplayModeRef vidmode) +static Uint32 GetDisplayModePixelFormat(CGDisplayModeRef vidmode) { /* This API is deprecated in 10.11 with no good replacement (as of 10.15). */ CFStringRef fmt = CGDisplayModeCopyPixelEncoding(vidmode); @@ -130,10 +125,10 @@ GetDisplayModePixelFormat(CGDisplayModeRef vidmode) kCFCompareCaseInsensitive) == kCFCompareEqualTo) { pixelformat = SDL_PIXELFORMAT_ARGB8888; } else if (CFStringCompare(fmt, CFSTR(IO16BitDirectPixels), - kCFCompareCaseInsensitive) == kCFCompareEqualTo) { + kCFCompareCaseInsensitive) == kCFCompareEqualTo) { pixelformat = SDL_PIXELFORMAT_ARGB1555; } else if (CFStringCompare(fmt, CFSTR(kIO30BitDirectPixels), - kCFCompareCaseInsensitive) == kCFCompareEqualTo) { + kCFCompareCaseInsensitive) == kCFCompareEqualTo) { pixelformat = SDL_PIXELFORMAT_ARGB2101010; } else { /* ignore 8-bit and such for now. */ @@ -144,13 +139,12 @@ GetDisplayModePixelFormat(CGDisplayModeRef vidmode) return pixelformat; } -static SDL_bool -GetDisplayMode(_THIS, CGDisplayModeRef vidmode, SDL_bool vidmodeCurrent, CFArrayRef modelist, CVDisplayLinkRef link, SDL_DisplayMode *mode) +static SDL_bool GetDisplayMode(_THIS, CGDisplayModeRef vidmode, SDL_bool vidmodeCurrent, CFArrayRef modelist, CVDisplayLinkRef link, SDL_DisplayMode *mode) { SDL_DisplayModeData *data; bool usableForGUI = CGDisplayModeIsUsableForDesktopGUI(vidmode); - int width = (int) CGDisplayModeGetWidth(vidmode); - int height = (int) CGDisplayModeGetHeight(vidmode); + int width = (int)CGDisplayModeGetWidth(vidmode); + int height = (int)CGDisplayModeGetHeight(vidmode); uint32_t ioflags = CGDisplayModeGetIOFlags(vidmode); int refreshrate = GetDisplayModeRefreshRate(vidmode, link); Uint32 format = GetDisplayModePixelFormat(vidmode); @@ -178,17 +172,17 @@ GetDisplayMode(_THIS, CGDisplayModeRef vidmode, SDL_bool vidmodeCurrent, CFArray * CGDisplayModeGetPixelWidth and friends are only available in 10.8+. */ #ifdef MAC_OS_X_VERSION_10_8 if (modelist != NULL && floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_7) { - int pixelW = (int) CGDisplayModeGetPixelWidth(vidmode); - int pixelH = (int) CGDisplayModeGetPixelHeight(vidmode); + int pixelW = (int)CGDisplayModeGetPixelWidth(vidmode); + int pixelH = (int)CGDisplayModeGetPixelHeight(vidmode); CFIndex modescount = CFArrayGetCount(modelist); - int i; + int i; for (i = 0; i < modescount; i++) { int otherW, otherH, otherpixelW, otherpixelH, otherrefresh; Uint32 otherformat; bool otherGUI; - CGDisplayModeRef othermode = (CGDisplayModeRef) CFArrayGetValueAtIndex(modelist, i); + CGDisplayModeRef othermode = (CGDisplayModeRef)CFArrayGetValueAtIndex(modelist, i); uint32_t otherioflags = CGDisplayModeGetIOFlags(othermode); if (CFEqual(vidmode, othermode)) { @@ -199,10 +193,10 @@ GetDisplayMode(_THIS, CGDisplayModeRef vidmode, SDL_bool vidmodeCurrent, CFArray continue; } - otherW = (int) CGDisplayModeGetWidth(othermode); - otherH = (int) CGDisplayModeGetHeight(othermode); - otherpixelW = (int) CGDisplayModeGetPixelWidth(othermode); - otherpixelH = (int) CGDisplayModeGetPixelHeight(othermode); + otherW = (int)CGDisplayModeGetWidth(othermode); + otherH = (int)CGDisplayModeGetHeight(othermode); + otherpixelW = (int)CGDisplayModeGetPixelWidth(othermode); + otherpixelH = (int)CGDisplayModeGetPixelHeight(othermode); otherrefresh = GetDisplayModeRefreshRate(othermode, link); otherformat = GetDisplayModePixelFormat(othermode); otherGUI = CGDisplayModeIsUsableForDesktopGUI(othermode); @@ -210,10 +204,7 @@ GetDisplayMode(_THIS, CGDisplayModeRef vidmode, SDL_bool vidmodeCurrent, CFArray /* Ignore this mode if it's low-dpi (@1x) and we have a high-dpi * mode in the list with the same size in points. */ - if (width == pixelW && height == pixelH - && width == otherW && height == otherH - && refreshrate == otherrefresh && format == otherformat - && (otherpixelW != otherW || otherpixelH != otherH)) { + if (width == pixelW && height == pixelH && width == otherW && height == otherH && refreshrate == otherrefresh && format == otherformat && (otherpixelW != otherW || otherpixelH != otherH)) { CFRelease(modes); return SDL_FALSE; } @@ -221,10 +212,7 @@ GetDisplayMode(_THIS, CGDisplayModeRef vidmode, SDL_bool vidmodeCurrent, CFArray /* Ignore this mode if it's interlaced and there's a non-interlaced * mode in the list with the same properties. */ - if (interlaced && ((otherioflags & kDisplayModeInterlacedFlag) == 0) - && width == otherW && height == otherH && pixelW == otherpixelW - && pixelH == otherpixelH && refreshrate == otherrefresh - && format == otherformat && usableForGUI == otherGUI) { + if (interlaced && ((otherioflags & kDisplayModeInterlacedFlag) == 0) && width == otherW && height == otherH && pixelW == otherpixelW && pixelH == otherpixelH && refreshrate == otherrefresh && format == otherformat && usableForGUI == otherGUI) { CFRelease(modes); return SDL_FALSE; } @@ -232,9 +220,7 @@ GetDisplayMode(_THIS, CGDisplayModeRef vidmode, SDL_bool vidmodeCurrent, CFArray /* Ignore this mode if it's not usable for desktop UI and its * properties are equal to another GUI-capable mode in the list. */ - if (width == otherW && height == otherH && pixelW == otherpixelW - && pixelH == otherpixelH && !usableForGUI && otherGUI - && refreshrate == otherrefresh && format == otherformat) { + if (width == otherW && height == otherH && pixelW == otherpixelW && pixelH == otherpixelH && !usableForGUI && otherGUI && refreshrate == otherrefresh && format == otherformat) { CFRelease(modes); return SDL_FALSE; } @@ -260,16 +246,14 @@ GetDisplayMode(_THIS, CGDisplayModeRef vidmode, SDL_bool vidmodeCurrent, CFArray * correct but it being filtered out by SDL_AddDisplayMode as being * a duplicate. */ - if (width == otherW && height == otherH && pixelW == otherpixelW - && pixelH == otherpixelH && usableForGUI == otherGUI - && refreshrate == otherrefresh && format == otherformat) { + if (width == otherW && height == otherH && pixelW == otherpixelW && pixelH == otherpixelH && usableForGUI == otherGUI && refreshrate == otherrefresh && format == otherformat) { CFArrayAppendValue(modes, othermode); } } } #endif - data = (SDL_DisplayModeData *) SDL_malloc(sizeof(*data)); + data = (SDL_DisplayModeData *)SDL_malloc(sizeof(*data)); if (!data) { CFRelease(modes); return SDL_FALSE; @@ -283,14 +267,13 @@ GetDisplayMode(_THIS, CGDisplayModeRef vidmode, SDL_bool vidmodeCurrent, CFArray return SDL_TRUE; } -static const char * -Cocoa_GetDisplayName(CGDirectDisplayID displayID) +static const char *Cocoa_GetDisplayName(CGDirectDisplayID displayID) { /* This API is deprecated in 10.9 with no good replacement (as of 10.15). */ io_service_t servicePort = CGDisplayIOServicePort(displayID); CFDictionaryRef deviceInfo = IODisplayCreateInfoDictionary(servicePort, kIODisplayOnlyPreferredName); NSDictionary *localizedNames = [(__bridge NSDictionary *)deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]]; - const char* displayName = NULL; + const char *displayName = NULL; if ([localizedNames count] > 0) { displayName = SDL_strdup([[localizedNames objectForKey:[[localizedNames allKeys] objectAtIndex:0]] UTF8String]); @@ -299,95 +282,94 @@ Cocoa_GetDisplayName(CGDirectDisplayID displayID) return displayName; } -void -Cocoa_InitModes(_THIS) -{ @autoreleasepool +void Cocoa_InitModes(_THIS) { - CGDisplayErr result; - CGDirectDisplayID *displays; - CGDisplayCount numDisplays; - SDL_bool isstack; - int pass, i; + @autoreleasepool { + CGDisplayErr result; + CGDirectDisplayID *displays; + CGDisplayCount numDisplays; + SDL_bool isstack; + int pass, i; - result = CGGetOnlineDisplayList(0, NULL, &numDisplays); - if (result != kCGErrorSuccess) { - CG_SetError("CGGetOnlineDisplayList()", result); - return; - } - displays = SDL_small_alloc(CGDirectDisplayID, numDisplays, &isstack); - result = CGGetOnlineDisplayList(numDisplays, displays, &numDisplays); - if (result != kCGErrorSuccess) { - CG_SetError("CGGetOnlineDisplayList()", result); - SDL_small_free(displays, isstack); - return; - } + result = CGGetOnlineDisplayList(0, NULL, &numDisplays); + if (result != kCGErrorSuccess) { + CG_SetError("CGGetOnlineDisplayList()", result); + return; + } + displays = SDL_small_alloc(CGDirectDisplayID, numDisplays, &isstack); + result = CGGetOnlineDisplayList(numDisplays, displays, &numDisplays); + if (result != kCGErrorSuccess) { + CG_SetError("CGGetOnlineDisplayList()", result); + SDL_small_free(displays, isstack); + return; + } - /* Pick up the primary display in the first pass, then get the rest */ - for (pass = 0; pass < 2; ++pass) { - for (i = 0; i < numDisplays; ++i) { - SDL_VideoDisplay display; - SDL_DisplayData *displaydata; - SDL_DisplayMode mode; - CGDisplayModeRef moderef = NULL; - CVDisplayLinkRef link = NULL; + /* Pick up the primary display in the first pass, then get the rest */ + for (pass = 0; pass < 2; ++pass) { + for (i = 0; i < numDisplays; ++i) { + SDL_VideoDisplay display; + SDL_DisplayData *displaydata; + SDL_DisplayMode mode; + CGDisplayModeRef moderef = NULL; + CVDisplayLinkRef link = NULL; - if (pass == 0) { - if (!CGDisplayIsMain(displays[i])) { + if (pass == 0) { + if (!CGDisplayIsMain(displays[i])) { + continue; + } + } else { + if (CGDisplayIsMain(displays[i])) { + continue; + } + } + + if (CGDisplayMirrorsDisplay(displays[i]) != kCGNullDirectDisplay) { continue; } - } else { - if (CGDisplayIsMain(displays[i])) { + + moderef = CGDisplayCopyDisplayMode(displays[i]); + + if (!moderef) { continue; } - } - if (CGDisplayMirrorsDisplay(displays[i]) != kCGNullDirectDisplay) { - continue; - } + displaydata = (SDL_DisplayData *)SDL_malloc(sizeof(*displaydata)); + if (!displaydata) { + CGDisplayModeRelease(moderef); + continue; + } + displaydata->display = displays[i]; - moderef = CGDisplayCopyDisplayMode(displays[i]); + CVDisplayLinkCreateWithCGDisplay(displays[i], &link); - if (!moderef) { - continue; - } + SDL_zero(display); + /* this returns a stddup'ed string */ + display.name = (char *)Cocoa_GetDisplayName(displays[i]); + if (!GetDisplayMode(_this, moderef, SDL_TRUE, NULL, link, &mode)) { + CVDisplayLinkRelease(link); + CGDisplayModeRelease(moderef); + SDL_free(display.name); + SDL_free(displaydata); + continue; + } - displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata)); - if (!displaydata) { - CGDisplayModeRelease(moderef); - continue; - } - displaydata->display = displays[i]; - - CVDisplayLinkCreateWithCGDisplay(displays[i], &link); - - SDL_zero(display); - /* this returns a stddup'ed string */ - display.name = (char *)Cocoa_GetDisplayName(displays[i]); - if (!GetDisplayMode(_this, moderef, SDL_TRUE, NULL, link, &mode)) { CVDisplayLinkRelease(link); CGDisplayModeRelease(moderef); + + display.desktop_mode = mode; + display.current_mode = mode; + display.driverdata = displaydata; + SDL_AddVideoDisplay(&display, SDL_FALSE); SDL_free(display.name); - SDL_free(displaydata); - continue; } - - CVDisplayLinkRelease(link); - CGDisplayModeRelease(moderef); - - display.desktop_mode = mode; - display.current_mode = mode; - display.driverdata = displaydata; - SDL_AddVideoDisplay(&display, SDL_FALSE); - SDL_free(display.name); } + SDL_small_free(displays, isstack); } - SDL_small_free(displays, isstack); -}} +} -int -Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect) +int Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) { - SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata; + SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata; CGRect cgrect; cgrect = CGDisplayBounds(displaydata->display); @@ -398,24 +380,23 @@ Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect) return 0; } -int -Cocoa_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect) +int Cocoa_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) { - SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata; + SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata; const CGDirectDisplayID cgdisplay = displaydata->display; NSArray *screens = [NSScreen screens]; NSScreen *screen = nil; /* !!! FIXME: maybe track the NSScreen in SDL_DisplayData? */ for (NSScreen *i in screens) { - const CGDirectDisplayID thisDisplay = (CGDirectDisplayID) [[[i deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; + const CGDirectDisplayID thisDisplay = (CGDirectDisplayID)[[[i deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; if (thisDisplay == cgdisplay) { screen = i; break; } } - SDL_assert(screen != nil); /* didn't find it?! */ + SDL_assert(screen != nil); /* didn't find it?! */ if (screen == nil) { return -1; } @@ -431,89 +412,88 @@ Cocoa_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect) return 0; } -int -Cocoa_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi) -{ @autoreleasepool +int Cocoa_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi) { - const float MM_IN_INCH = 25.4f; + @autoreleasepool { + const float MM_IN_INCH = 25.4f; - SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata; + SDL_DisplayData *data = (SDL_DisplayData *)display->driverdata; - /* we need the backingScaleFactor for Retina displays, which is only exposed through NSScreen, not CGDisplay, afaik, so find our screen... */ - CGFloat scaleFactor = 1.0f; - NSArray *screens = [NSScreen screens]; - NSSize displayNativeSize; - displayNativeSize.width = (int) CGDisplayPixelsWide(data->display); - displayNativeSize.height = (int) CGDisplayPixelsHigh(data->display); - - for (NSScreen *screen in screens) { - const CGDirectDisplayID dpyid = (const CGDirectDisplayID ) [[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; - if (dpyid == data->display) { + /* we need the backingScaleFactor for Retina displays, which is only exposed through NSScreen, not CGDisplay, afaik, so find our screen... */ + CGFloat scaleFactor = 1.0f; + NSArray *screens = [NSScreen screens]; + NSSize displayNativeSize; + displayNativeSize.width = (int)CGDisplayPixelsWide(data->display); + displayNativeSize.height = (int)CGDisplayPixelsHigh(data->display); + + for (NSScreen *screen in screens) { + const CGDirectDisplayID dpyid = (const CGDirectDisplayID)[[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; + if (dpyid == data->display) { #ifdef MAC_OS_X_VERSION_10_8 - /* Neither CGDisplayScreenSize(description's NSScreenNumber) nor [NSScreen backingScaleFactor] can calculate the correct dpi in macOS. E.g. backingScaleFactor is always 2 in all display modes for rMBP 16" */ - if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_7) { - CFStringRef dmKeys[1] = { kCGDisplayShowDuplicateLowResolutionModes }; - CFBooleanRef dmValues[1] = { kCFBooleanTrue }; - CFDictionaryRef dmOptions = CFDictionaryCreate(kCFAllocatorDefault, (const void**) dmKeys, (const void**) dmValues, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks ); - CFArrayRef allDisplayModes = CGDisplayCopyAllDisplayModes(dpyid, dmOptions); - CFIndex n = CFArrayGetCount(allDisplayModes); - for(CFIndex i = 0; i < n; ++i) { - CGDisplayModeRef m = (CGDisplayModeRef)CFArrayGetValueAtIndex(allDisplayModes, i); - CGFloat width = CGDisplayModeGetPixelWidth(m); - CGFloat height = CGDisplayModeGetPixelHeight(m); - CGFloat HiDPIWidth = CGDisplayModeGetWidth(m); - - //Only check 1x mode - if(width == HiDPIWidth) { - if (CGDisplayModeGetIOFlags(m) & kDisplayModeNativeFlag) { - displayNativeSize.width = width; - displayNativeSize.height = height; - break; - } - - //Get the largest size even if kDisplayModeNativeFlag is not present e.g. iMac 27-Inch with 5K Retina - if(width > displayNativeSize.width) { - displayNativeSize.width = width; - displayNativeSize.height = height; + /* Neither CGDisplayScreenSize(description's NSScreenNumber) nor [NSScreen backingScaleFactor] can calculate the correct dpi in macOS. E.g. backingScaleFactor is always 2 in all display modes for rMBP 16" */ + if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_7) { + CFStringRef dmKeys[1] = { kCGDisplayShowDuplicateLowResolutionModes }; + CFBooleanRef dmValues[1] = { kCFBooleanTrue }; + CFDictionaryRef dmOptions = CFDictionaryCreate(kCFAllocatorDefault, (const void **)dmKeys, (const void **)dmValues, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + CFArrayRef allDisplayModes = CGDisplayCopyAllDisplayModes(dpyid, dmOptions); + CFIndex n = CFArrayGetCount(allDisplayModes); + for (CFIndex i = 0; i < n; ++i) { + CGDisplayModeRef m = (CGDisplayModeRef)CFArrayGetValueAtIndex(allDisplayModes, i); + CGFloat width = CGDisplayModeGetPixelWidth(m); + CGFloat height = CGDisplayModeGetPixelHeight(m); + CGFloat HiDPIWidth = CGDisplayModeGetWidth(m); + + // Only check 1x mode + if (width == HiDPIWidth) { + if (CGDisplayModeGetIOFlags(m) & kDisplayModeNativeFlag) { + displayNativeSize.width = width; + displayNativeSize.height = height; + break; + } + + // Get the largest size even if kDisplayModeNativeFlag is not present e.g. iMac 27-Inch with 5K Retina + if (width > displayNativeSize.width) { + displayNativeSize.width = width; + displayNativeSize.height = height; + } } } - } - CFRelease(allDisplayModes); - CFRelease(dmOptions); - } else + CFRelease(allDisplayModes); + CFRelease(dmOptions); + } else #endif - { - // fallback for 10.7 - scaleFactor = [screen backingScaleFactor]; - displayNativeSize.width = displayNativeSize.width * scaleFactor; - displayNativeSize.height = displayNativeSize.height * scaleFactor; - break; + { + // fallback for 10.7 + scaleFactor = [screen backingScaleFactor]; + displayNativeSize.width = displayNativeSize.width * scaleFactor; + displayNativeSize.height = displayNativeSize.height * scaleFactor; + break; + } } } + + { + const CGSize displaySize = CGDisplayScreenSize(data->display); + const int pixelWidth = displayNativeSize.width; + const int pixelHeight = displayNativeSize.height; + + if (ddpi) { + *ddpi = (SDL_ComputeDiagonalDPI(pixelWidth, pixelHeight, displaySize.width / MM_IN_INCH, displaySize.height / MM_IN_INCH)); + } + if (hdpi) { + *hdpi = (pixelWidth * MM_IN_INCH / displaySize.width); + } + if (vdpi) { + *vdpi = (pixelHeight * MM_IN_INCH / displaySize.height); + } + } + return 0; } +} - { - const CGSize displaySize = CGDisplayScreenSize(data->display); - const int pixelWidth = displayNativeSize.width; - const int pixelHeight = displayNativeSize.height; - - if (ddpi) { - *ddpi = (SDL_ComputeDiagonalDPI(pixelWidth, pixelHeight, displaySize.width / MM_IN_INCH, displaySize.height / MM_IN_INCH)); - } - if (hdpi) { - *hdpi = (pixelWidth * MM_IN_INCH / displaySize.width); - } - if (vdpi) { - *vdpi = (pixelHeight * MM_IN_INCH / displaySize.height); - } - } - return 0; -}} - -void -Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display) +void Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay *display) { - SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata; + SDL_DisplayData *data = (SDL_DisplayData *)display->driverdata; CVDisplayLinkRef link = NULL; CGDisplayModeRef desktopmoderef; SDL_DisplayMode desktopmode; @@ -532,7 +512,7 @@ Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display) */ if (desktopmoderef && GetDisplayMode(_this, desktopmoderef, SDL_TRUE, NULL, link, &desktopmode)) { if (!SDL_AddDisplayMode(display, &desktopmode)) { - CFRelease(((SDL_DisplayModeData*)desktopmode.driverdata)->modes); + CFRelease(((SDL_DisplayModeData *)desktopmode.driverdata)->modes); SDL_free(desktopmode.driverdata); } } @@ -552,8 +532,8 @@ Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display) */ #ifdef MAC_OS_X_VERSION_10_8 if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_7) { - const CFStringRef dictkeys[] = {kCGDisplayShowDuplicateLowResolutionModes}; - const CFBooleanRef dictvalues[] = {kCFBooleanTrue}; + const CFStringRef dictkeys[] = { kCGDisplayShowDuplicateLowResolutionModes }; + const CFBooleanRef dictvalues[] = { kCFBooleanTrue }; dict = CFDictionaryCreate(NULL, (const void **)dictkeys, (const void **)dictvalues, @@ -574,12 +554,12 @@ Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display) const CFIndex count = CFArrayGetCount(modes); for (i = 0; i < count; i++) { - CGDisplayModeRef moderef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i); + CGDisplayModeRef moderef = (CGDisplayModeRef)CFArrayGetValueAtIndex(modes, i); SDL_DisplayMode mode; if (GetDisplayMode(_this, moderef, SDL_FALSE, modes, link, &mode)) { if (!SDL_AddDisplayMode(display, &mode)) { - CFRelease(((SDL_DisplayModeData*)mode.driverdata)->modes); + CFRelease(((SDL_DisplayModeData *)mode.driverdata)->modes); SDL_free(mode.driverdata); } } @@ -591,8 +571,7 @@ Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display) CVDisplayLinkRelease(link); } -static CGError -SetDisplayModeForDisplay(CGDirectDisplayID display, SDL_DisplayModeData *data) +static CGError SetDisplayModeForDisplay(CGDirectDisplayID display, SDL_DisplayModeData *data) { /* SDL_DisplayModeData can contain multiple CGDisplayModes to try (with * identical properties), some of which might not work. See GetDisplayMode. @@ -610,11 +589,10 @@ SetDisplayModeForDisplay(CGDirectDisplayID display, SDL_DisplayModeData *data) return result; } -int -Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +int Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) { - SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata; - SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata; + SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata; + SDL_DisplayModeData *data = (SDL_DisplayModeData *)mode->driverdata; CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken; CGError result; @@ -646,7 +624,7 @@ Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) } /* Do the physical switch */ - result = SetDisplayModeForDisplay(displaydata->display, data); + result = SetDisplayModeForDisplay(displaydata->display, data); if (result != kCGErrorSuccess) { CG_SetError("CGDisplaySwitchToMode()", result); goto ERR_NO_SWITCH; @@ -670,14 +648,13 @@ ERR_NO_SWITCH: } ERR_NO_CAPTURE: if (fade_token != kCGDisplayFadeReservationInvalidToken) { - CGDisplayFade (fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE); + CGDisplayFade(fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE); CGReleaseDisplayFadeReservation(fade_token); } return -1; } -void -Cocoa_QuitModes(_THIS) +void Cocoa_QuitModes(_THIS) { int i, j; @@ -689,11 +666,11 @@ Cocoa_QuitModes(_THIS) Cocoa_SetDisplayMode(_this, display, &display->desktop_mode); } - mode = (SDL_DisplayModeData *) display->desktop_mode.driverdata; + mode = (SDL_DisplayModeData *)display->desktop_mode.driverdata; CFRelease(mode->modes); for (j = 0; j < display->num_display_modes; j++) { - mode = (SDL_DisplayModeData*) display->display_modes[j].driverdata; + mode = (SDL_DisplayModeData *)display->display_modes[j].driverdata; CFRelease(mode->modes); } } diff --git a/src/video/cocoa/SDL_cocoamouse.h b/src/video/cocoa/SDL_cocoamouse.h index f6dcdc045..c1fab08c6 100644 --- a/src/video/cocoa/SDL_cocoamouse.h +++ b/src/video/cocoa/SDL_cocoamouse.h @@ -26,12 +26,13 @@ #include "SDL_cocoavideo.h" extern int Cocoa_InitMouse(_THIS); -extern void Cocoa_HandleMouseEvent(_THIS, NSEvent * event); -extern void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent * event); +extern void Cocoa_HandleMouseEvent(_THIS, NSEvent *event); +extern void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event); extern void Cocoa_HandleMouseWarp(CGFloat x, CGFloat y); extern void Cocoa_QuitMouse(_THIS); -typedef struct { +typedef struct +{ /* Whether we've seen a cursor warp since the last move event. */ SDL_bool seenWarp; /* What location our last cursor warp was to. */ diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index da5ffac69..090f01de3 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -33,7 +33,9 @@ #ifdef DEBUG_COCOAMOUSE #define DLog(fmt, ...) printf("%s: " fmt "\n", __func__, ##__VA_ARGS__) #else -#define DLog(...) do { } while (0) +#define DLog(...) \ + do { \ + } while (0) #endif @implementation NSCursor (InvisibleCursor) @@ -62,54 +64,52 @@ } @end - -static SDL_Cursor * -Cocoa_CreateDefaultCursor() -{ @autoreleasepool +static SDL_Cursor *Cocoa_CreateDefaultCursor() { - NSCursor *nscursor; - SDL_Cursor *cursor = NULL; + @autoreleasepool { + NSCursor *nscursor; + SDL_Cursor *cursor = NULL; - nscursor = [NSCursor arrowCursor]; + nscursor = [NSCursor arrowCursor]; - if (nscursor) { - cursor = SDL_calloc(1, sizeof(*cursor)); - if (cursor) { - cursor->driverdata = (void *)CFBridgingRetain(nscursor); + if (nscursor) { + cursor = SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + cursor->driverdata = (void *)CFBridgingRetain(nscursor); + } } + + return cursor; } +} - return cursor; -}} - -static SDL_Cursor * -Cocoa_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) -{ @autoreleasepool +static SDL_Cursor *Cocoa_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) { - NSImage *nsimage; - NSCursor *nscursor = NULL; - SDL_Cursor *cursor = NULL; + @autoreleasepool { + NSImage *nsimage; + NSCursor *nscursor = NULL; + SDL_Cursor *cursor = NULL; - nsimage = Cocoa_CreateImage(surface); - if (nsimage) { - nscursor = [[NSCursor alloc] initWithImage: nsimage hotSpot: NSMakePoint(hot_x, hot_y)]; - } - - if (nscursor) { - cursor = SDL_calloc(1, sizeof(*cursor)); - if (cursor) { - cursor->driverdata = (void *)CFBridgingRetain(nscursor); + nsimage = Cocoa_CreateImage(surface); + if (nsimage) { + nscursor = [[NSCursor alloc] initWithImage:nsimage hotSpot:NSMakePoint(hot_x, hot_y)]; } - } - return cursor; -}} + if (nscursor) { + cursor = SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + cursor->driverdata = (void *)CFBridgingRetain(nscursor); + } + } + + return cursor; + } +} /* there are .pdf files of some of the cursors we need, installed by default on macOS, but not available through NSCursor. If we can load them ourselves, use them, otherwise fallback to something standard but not super-great. Since these are under /System, they should be available even to sandboxed apps. */ -static NSCursor * -LoadHiddenSystemCursor(NSString *cursorName, SEL fallback) +static NSCursor *LoadHiddenSystemCursor(NSString *cursorName, SEL fallback) { NSString *cursorPath = [@"/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/Resources/cursors" stringByAppendingPathComponent:cursorName]; NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:[cursorPath stringByAppendingPathComponent:@"info.plist"]]; @@ -122,12 +122,12 @@ LoadHiddenSystemCursor(NSString *cursorName, SEL fallback) } if (frames > 1) { - #ifdef MAC_OS_VERSION_12_0 /* same value as deprecated symbol. */ +#ifdef MAC_OS_VERSION_12_0 /* same value as deprecated symbol. */ const NSCompositingOperation operation = NSCompositingOperationCopy; - #else +#else const NSCompositingOperation operation = NSCompositeCopy; - #endif - const NSSize cropped_size = NSMakeSize(image.size.width, (int) (image.size.height / frames)); +#endif + const NSSize cropped_size = NSMakeSize(image.size.width, (int)(image.size.height / frames)); NSImage *cropped = [[NSImage alloc] initWithSize:cropped_size]; if (cropped == nil) { return [NSCursor performSelector:fallback]; @@ -146,93 +146,92 @@ LoadHiddenSystemCursor(NSString *cursorName, SEL fallback) return cursor; } -static SDL_Cursor * -Cocoa_CreateSystemCursor(SDL_SystemCursor id) -{ @autoreleasepool +static SDL_Cursor *Cocoa_CreateSystemCursor(SDL_SystemCursor id) { - NSCursor *nscursor = NULL; - SDL_Cursor *cursor = NULL; + @autoreleasepool { + NSCursor *nscursor = NULL; + SDL_Cursor *cursor = NULL; - switch(id) { - case SDL_SYSTEM_CURSOR_ARROW: - nscursor = [NSCursor arrowCursor]; - break; - case SDL_SYSTEM_CURSOR_IBEAM: - nscursor = [NSCursor IBeamCursor]; - break; - case SDL_SYSTEM_CURSOR_CROSSHAIR: - nscursor = [NSCursor crosshairCursor]; - break; - case SDL_SYSTEM_CURSOR_WAIT: /* !!! FIXME: this is more like WAITARROW */ - nscursor = LoadHiddenSystemCursor(@"busybutclickable", @selector(arrowCursor)); - break; - case SDL_SYSTEM_CURSOR_WAITARROW: /* !!! FIXME: this is meant to be animated */ - nscursor = LoadHiddenSystemCursor(@"busybutclickable", @selector(arrowCursor)); - break; - case SDL_SYSTEM_CURSOR_SIZENWSE: - nscursor = LoadHiddenSystemCursor(@"resizenorthwestsoutheast", @selector(closedHandCursor)); - break; - case SDL_SYSTEM_CURSOR_SIZENESW: - nscursor = LoadHiddenSystemCursor(@"resizenortheastsouthwest", @selector(closedHandCursor)); - break; - case SDL_SYSTEM_CURSOR_SIZEWE: - nscursor = LoadHiddenSystemCursor(@"resizeeastwest", @selector(resizeLeftRightCursor)); - break; - case SDL_SYSTEM_CURSOR_SIZENS: - nscursor = LoadHiddenSystemCursor(@"resizenorthsouth", @selector(resizeUpDownCursor)); - break; - case SDL_SYSTEM_CURSOR_SIZEALL: - nscursor = LoadHiddenSystemCursor(@"move", @selector(closedHandCursor)); - break; - case SDL_SYSTEM_CURSOR_NO: - nscursor = [NSCursor operationNotAllowedCursor]; - break; - case SDL_SYSTEM_CURSOR_HAND: - nscursor = [NSCursor pointingHandCursor]; - break; - default: - SDL_assert(!"Unknown system cursor"); - return NULL; - } - - if (nscursor) { - cursor = SDL_calloc(1, sizeof(*cursor)); - if (cursor) { - /* We'll free it later, so retain it here */ - cursor->driverdata = (void *)CFBridgingRetain(nscursor); + switch (id) { + case SDL_SYSTEM_CURSOR_ARROW: + nscursor = [NSCursor arrowCursor]; + break; + case SDL_SYSTEM_CURSOR_IBEAM: + nscursor = [NSCursor IBeamCursor]; + break; + case SDL_SYSTEM_CURSOR_CROSSHAIR: + nscursor = [NSCursor crosshairCursor]; + break; + case SDL_SYSTEM_CURSOR_WAIT: /* !!! FIXME: this is more like WAITARROW */ + nscursor = LoadHiddenSystemCursor(@"busybutclickable", @selector(arrowCursor)); + break; + case SDL_SYSTEM_CURSOR_WAITARROW: /* !!! FIXME: this is meant to be animated */ + nscursor = LoadHiddenSystemCursor(@"busybutclickable", @selector(arrowCursor)); + break; + case SDL_SYSTEM_CURSOR_SIZENWSE: + nscursor = LoadHiddenSystemCursor(@"resizenorthwestsoutheast", @selector(closedHandCursor)); + break; + case SDL_SYSTEM_CURSOR_SIZENESW: + nscursor = LoadHiddenSystemCursor(@"resizenortheastsouthwest", @selector(closedHandCursor)); + break; + case SDL_SYSTEM_CURSOR_SIZEWE: + nscursor = LoadHiddenSystemCursor(@"resizeeastwest", @selector(resizeLeftRightCursor)); + break; + case SDL_SYSTEM_CURSOR_SIZENS: + nscursor = LoadHiddenSystemCursor(@"resizenorthsouth", @selector(resizeUpDownCursor)); + break; + case SDL_SYSTEM_CURSOR_SIZEALL: + nscursor = LoadHiddenSystemCursor(@"move", @selector(closedHandCursor)); + break; + case SDL_SYSTEM_CURSOR_NO: + nscursor = [NSCursor operationNotAllowedCursor]; + break; + case SDL_SYSTEM_CURSOR_HAND: + nscursor = [NSCursor pointingHandCursor]; + break; + default: + SDL_assert(!"Unknown system cursor"); + return NULL; } - } - return cursor; -}} - -static void -Cocoa_FreeCursor(SDL_Cursor * cursor) -{ @autoreleasepool -{ - CFBridgingRelease(cursor->driverdata); - SDL_free(cursor); -}} - -static int -Cocoa_ShowCursor(SDL_Cursor * cursor) -{ @autoreleasepool -{ - SDL_VideoDevice *device = SDL_GetVideoDevice(); - SDL_Window *window = (device ? device->windows : NULL); - for (; window != NULL; window = window->next) { - SDL_WindowData *driverdata = (__bridge SDL_WindowData *)window->driverdata; - if (driverdata) { - [driverdata.nswindow performSelectorOnMainThread:@selector(invalidateCursorRectsForView:) - withObject:[driverdata.nswindow contentView] - waitUntilDone:NO]; + if (nscursor) { + cursor = SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + /* We'll free it later, so retain it here */ + cursor->driverdata = (void *)CFBridgingRetain(nscursor); + } } - } - return 0; -}} -static SDL_Window * -SDL_FindWindowAtPoint(const int x, const int y) + return cursor; + } +} + +static void Cocoa_FreeCursor(SDL_Cursor *cursor) +{ + @autoreleasepool { + CFBridgingRelease(cursor->driverdata); + SDL_free(cursor); + } +} + +static int Cocoa_ShowCursor(SDL_Cursor *cursor) +{ + @autoreleasepool { + SDL_VideoDevice *device = SDL_GetVideoDevice(); + SDL_Window *window = (device ? device->windows : NULL); + for (; window != NULL; window = window->next) { + SDL_WindowData *driverdata = (__bridge SDL_WindowData *)window->driverdata; + if (driverdata) { + [driverdata.nswindow performSelectorOnMainThread:@selector(invalidateCursorRectsForView:) + withObject:[driverdata.nswindow contentView] + waitUntilDone:NO]; + } + } + return 0; + } +} + +static SDL_Window *SDL_FindWindowAtPoint(const int x, const int y) { const SDL_Point pt = { x, y }; SDL_Window *i; @@ -246,13 +245,12 @@ SDL_FindWindowAtPoint(const int x, const int y) return NULL; } -static int -Cocoa_WarpMouseGlobal(int x, int y) +static int Cocoa_WarpMouseGlobal(int x, int y) { CGPoint point; SDL_Mouse *mouse = SDL_GetMouse(); if (mouse->focus) { - SDL_WindowData *data = (__bridge SDL_WindowData *) mouse->focus->driverdata; + SDL_WindowData *data = (__bridge SDL_WindowData *)mouse->focus->driverdata; if ([data.listener isMovingOrFocusClickPending]) { DLog("Postponing warp, window being moved or focused."); [data.listener setPendingMoveX:x Y:y]; @@ -288,14 +286,12 @@ Cocoa_WarpMouseGlobal(int x, int y) return 0; } -static void -Cocoa_WarpMouse(SDL_Window * window, int x, int y) +static void Cocoa_WarpMouse(SDL_Window *window, int x, int y) { Cocoa_WarpMouseGlobal(window->x + x, window->y + y); } -static int -Cocoa_SetRelativeMouseMode(SDL_bool enabled) +static int Cocoa_SetRelativeMouseMode(SDL_bool enabled) { CGError result; SDL_Window *window; @@ -322,7 +318,7 @@ Cocoa_SetRelativeMouseMode(SDL_bool enabled) /* We will re-apply the non-relative mode when the window finishes being moved, * if it is being moved right now. */ - data = (__bridge SDL_WindowData *) window->driverdata; + data = (__bridge SDL_WindowData *)window->driverdata; if ([data.listener isMovingOrFocusClickPending]) { return 0; } @@ -338,23 +334,21 @@ Cocoa_SetRelativeMouseMode(SDL_bool enabled) return 0; } -static int -Cocoa_CaptureMouse(SDL_Window *window) +static int Cocoa_CaptureMouse(SDL_Window *window) { /* our Cocoa event code already tracks the mouse outside the window, so all we have to do here is say "okay" and do what we always do. */ return 0; } -static Uint32 -Cocoa_GetGlobalMouseState(int *x, int *y) +static Uint32 Cocoa_GetGlobalMouseState(int *x, int *y) { const NSUInteger cocoaButtons = [NSEvent pressedMouseButtons]; const NSPoint cocoaLocation = [NSEvent mouseLocation]; Uint32 retval = 0; - *x = (int) cocoaLocation.x; - *y = (int) (CGDisplayPixelsHigh(kCGDirectMainDisplay) - cocoaLocation.y); + *x = (int)cocoaLocation.x; + *y = (int)(CGDisplayPixelsHigh(kCGDirectMainDisplay) - cocoaLocation.y); retval |= (cocoaButtons & (1 << 0)) ? SDL_BUTTON_LMASK : 0; retval |= (cocoaButtons & (1 << 1)) ? SDL_BUTTON_RMASK : 0; @@ -365,12 +359,11 @@ Cocoa_GetGlobalMouseState(int *x, int *y) return retval; } -int -Cocoa_InitMouse(_THIS) +int Cocoa_InitMouse(_THIS) { NSPoint location; SDL_Mouse *mouse = SDL_GetMouse(); - SDL_MouseData *driverdata = (SDL_MouseData*) SDL_calloc(1, sizeof(SDL_MouseData)); + SDL_MouseData *driverdata = (SDL_MouseData *)SDL_calloc(1, sizeof(SDL_MouseData)); if (driverdata == NULL) { return SDL_OutOfMemory(); } @@ -388,14 +381,13 @@ Cocoa_InitMouse(_THIS) SDL_SetDefaultCursor(Cocoa_CreateDefaultCursor()); - location = [NSEvent mouseLocation]; + location = [NSEvent mouseLocation]; driverdata->lastMoveX = location.x; driverdata->lastMoveY = location.y; return 0; } -static void -Cocoa_HandleTitleButtonEvent(_THIS, NSEvent *event) +static void Cocoa_HandleTitleButtonEvent(_THIS, NSEvent *event) { SDL_Window *window; NSWindow *nswindow = [event window]; @@ -428,8 +420,7 @@ Cocoa_HandleTitleButtonEvent(_THIS, NSEvent *event) } } -void -Cocoa_HandleMouseEvent(_THIS, NSEvent *event) +void Cocoa_HandleMouseEvent(_THIS, NSEvent *event) { SDL_Mouse *mouse; SDL_MouseData *driverdata; @@ -439,43 +430,43 @@ Cocoa_HandleMouseEvent(_THIS, NSEvent *event) float deltaX, deltaY; SDL_bool seenWarp; switch ([event type]) { - case NSEventTypeMouseMoved: - case NSEventTypeLeftMouseDragged: - case NSEventTypeRightMouseDragged: - case NSEventTypeOtherMouseDragged: - break; + case NSEventTypeMouseMoved: + case NSEventTypeLeftMouseDragged: + case NSEventTypeRightMouseDragged: + case NSEventTypeOtherMouseDragged: + break; - case NSEventTypeLeftMouseDown: - case NSEventTypeLeftMouseUp: - case NSEventTypeRightMouseDown: - case NSEventTypeRightMouseUp: - case NSEventTypeOtherMouseDown: - case NSEventTypeOtherMouseUp: - if ([event window]) { - NSRect windowRect = [[[event window] contentView] frame]; - if (!NSMouseInRect([event locationInWindow], windowRect, NO)) { - Cocoa_HandleTitleButtonEvent(_this, event); - return; - } + case NSEventTypeLeftMouseDown: + case NSEventTypeLeftMouseUp: + case NSEventTypeRightMouseDown: + case NSEventTypeRightMouseUp: + case NSEventTypeOtherMouseDown: + case NSEventTypeOtherMouseUp: + if ([event window]) { + NSRect windowRect = [[[event window] contentView] frame]; + if (!NSMouseInRect([event locationInWindow], windowRect, NO)) { + Cocoa_HandleTitleButtonEvent(_this, event); + return; } - return; + } + return; - default: - /* Ignore any other events. */ - return; + default: + /* Ignore any other events. */ + return; } mouse = SDL_GetMouse(); - driverdata = (SDL_MouseData*)mouse->driverdata; + driverdata = (SDL_MouseData *)mouse->driverdata; if (!driverdata) { - return; /* can happen when returning from fullscreen Space on shutdown */ + return; /* can happen when returning from fullscreen Space on shutdown */ } mouseID = mouse ? mouse->mouseID : 0; seenWarp = driverdata->seenWarp; driverdata->seenWarp = NO; - location = [NSEvent mouseLocation]; + location = [NSEvent mouseLocation]; lastMoveX = driverdata->lastMoveX; lastMoveY = driverdata->lastMoveY; driverdata->lastMoveX = location.x; @@ -508,8 +499,7 @@ Cocoa_HandleMouseEvent(_THIS, NSEvent *event) SDL_SendMouseMotion(mouse->focus, mouseID, 1, (int)deltaX, (int)deltaY); } -void -Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event) +void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event) { SDL_MouseID mouseID; SDL_MouseWheelDirection direction; @@ -546,13 +536,12 @@ Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event) SDL_SendMouseWheel(window, mouseID, x, y, direction); } -void -Cocoa_HandleMouseWarp(CGFloat x, CGFloat y) +void Cocoa_HandleMouseWarp(CGFloat x, CGFloat y) { /* This makes Cocoa_HandleMouseEvent ignore the delta caused by the warp, * since it gets included in the next movement event. */ - SDL_MouseData *driverdata = (SDL_MouseData*)SDL_GetMouse()->driverdata; + SDL_MouseData *driverdata = (SDL_MouseData *)SDL_GetMouse()->driverdata; driverdata->lastWarpX = x; driverdata->lastWarpY = y; driverdata->seenWarp = SDL_TRUE; @@ -560,8 +549,7 @@ Cocoa_HandleMouseWarp(CGFloat x, CGFloat y) DLog("(%g, %g)", x, y); } -void -Cocoa_QuitMouse(_THIS) +void Cocoa_QuitMouse(_THIS) { SDL_Mouse *mouse = SDL_GetMouse(); if (mouse) { diff --git a/src/video/cocoa/SDL_cocoaopengl.h b/src/video/cocoa/SDL_cocoaopengl.h index 9330b5744..d32c049ac 100644 --- a/src/video/cocoa/SDL_cocoaopengl.h +++ b/src/video/cocoa/SDL_cocoaopengl.h @@ -40,14 +40,19 @@ struct SDL_GLDriverData int initialized; }; -@interface SDLOpenGLContext : NSOpenGLContext { +@interface SDLOpenGLContext : NSOpenGLContext +{ SDL_atomic_t dirty; SDL_Window *window; CVDisplayLinkRef displayLink; - @public SDL_mutex *swapIntervalMutex; - @public SDL_cond *swapIntervalCond; - @public SDL_atomic_t swapIntervalSetting; - @public SDL_atomic_t swapIntervalsPassed; + @public + SDL_mutex *swapIntervalMutex; + @public + SDL_cond *swapIntervalCond; + @public + SDL_atomic_t swapIntervalSetting; + @public + SDL_atomic_t swapIntervalsPassed; } - (id)initWithFormat:(NSOpenGLPixelFormat *)format @@ -56,11 +61,11 @@ struct SDL_GLDriverData - (void)updateIfNeeded; - (void)movedToNewScreen; - (void)setWindow:(SDL_Window *)window; -- (SDL_Window*)window; +- (SDL_Window *)window; - (void)explicitUpdate; - (void)dealloc; -@property (retain, nonatomic) NSOpenGLPixelFormat* openglPixelFormat; // macOS 10.10 has -[NSOpenGLContext pixelFormat] but this handles older OS releases. +@property(retain, nonatomic) NSOpenGLPixelFormat *openglPixelFormat; // macOS 10.10 has -[NSOpenGLContext pixelFormat] but this handles older OS releases. @end @@ -68,12 +73,12 @@ struct SDL_GLDriverData extern int Cocoa_GL_LoadLibrary(_THIS, const char *path); extern void *Cocoa_GL_GetProcAddress(_THIS, const char *proc); extern void Cocoa_GL_UnloadLibrary(_THIS); -extern SDL_GLContext Cocoa_GL_CreateContext(_THIS, SDL_Window * window); -extern int Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, +extern SDL_GLContext Cocoa_GL_CreateContext(_THIS, SDL_Window *window); +extern int Cocoa_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); extern int Cocoa_GL_SetSwapInterval(_THIS, int interval); extern int Cocoa_GL_GetSwapInterval(_THIS); -extern int Cocoa_GL_SwapWindow(_THIS, SDL_Window * window); +extern int Cocoa_GL_SwapWindow(_THIS, SDL_Window *window); extern void Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context); #ifdef __clang__ diff --git a/src/video/cocoa/SDL_cocoaopengl.m b/src/video/cocoa/SDL_cocoaopengl.m index 58df449a3..b99aa0e0c 100644 --- a/src/video/cocoa/SDL_cocoaopengl.m +++ b/src/video/cocoa/SDL_cocoaopengl.m @@ -36,7 +36,7 @@ #include "SDL_opengl.h" #include "../../SDL_hints_c.h" -#define DEFAULT_OPENGL "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib" +#define DEFAULT_OPENGL "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib" /* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */ #ifdef __clang__ @@ -56,16 +56,14 @@ static SDL_bool SDL_opengl_async_dispatch = SDL_FALSE; -static void SDLCALL -SDL_OpenGLAsyncDispatchChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_OpenGLAsyncDispatchChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_opengl_async_dispatch = SDL_GetStringBoolean(hint, SDL_FALSE); } -static CVReturn -DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, const CVTimeStamp* outputTime, CVOptionFlags flagsIn, CVOptionFlags* flagsOut, void* displayLinkContext) +static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp *now, const CVTimeStamp *outputTime, CVOptionFlags flagsIn, CVOptionFlags *flagsOut, void *displayLinkContext) { - SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *) displayLinkContext; + SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *)displayLinkContext; /*printf("DISPLAY LINK! %u\n", (unsigned int) SDL_GetTicks()); */ const int setting = SDL_AtomicGet(&nscontext->swapIntervalSetting); @@ -99,7 +97,7 @@ DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, const /* !!! FIXME: check return values. */ CVDisplayLinkCreateWithActiveCGDisplays(&self->displayLink); - CVDisplayLinkSetOutputCallback(self->displayLink, &DisplayLinkCallback, (__bridge void * _Nullable) self); + CVDisplayLinkSetOutputCallback(self->displayLink, &DisplayLinkCallback, (__bridge void *_Nullable)self); CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(self->displayLink, [self CGLContextObj], [format CGLPixelFormatObj]); CVDisplayLinkStart(displayLink); } @@ -146,7 +144,7 @@ DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, const /* Make sure to remove us from the old window's context list, or we'll get scheduled updates from it too. */ NSMutableArray *contexts = oldwindowdata.nscontexts; - @synchronized (contexts) { + @synchronized(contexts) { [contexts removeObject:self]; } } @@ -159,7 +157,7 @@ DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, const /* Now sign up for scheduled updates for the new window. */ NSMutableArray *contexts = windowdata.nscontexts; - @synchronized (contexts) { + @synchronized(contexts) { [contexts addObject:self]; } @@ -167,7 +165,9 @@ DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, const if ([NSThread isMainThread]) { [self setView:contentview]; } else { - dispatch_sync(dispatch_get_main_queue(), ^{ [self setView:contentview]; }); + dispatch_sync(dispatch_get_main_queue(), ^{ + [self setView:contentview]; + }); } if (self == [NSOpenGLContext currentContext]) { [self explicitUpdate]; @@ -185,7 +185,7 @@ DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, const } } -- (SDL_Window*)window +- (SDL_Window *)window { return self->window; } @@ -196,9 +196,13 @@ DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, const [super update]; } else { if (SDL_opengl_async_dispatch) { - dispatch_async(dispatch_get_main_queue(), ^{ [super update]; }); + dispatch_async(dispatch_get_main_queue(), ^{ + [super update]; + }); } else { - dispatch_sync(dispatch_get_main_queue(), ^{ [super update]; }); + dispatch_sync(dispatch_get_main_queue(), ^{ + [super update]; + }); } } } @@ -219,9 +223,7 @@ DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, const @end - -int -Cocoa_GL_LoadLibrary(_THIS, const char *path) +int Cocoa_GL_LoadLibrary(_THIS, const char *path) { /* Load the OpenGL library */ if (path == NULL) { @@ -245,280 +247,280 @@ Cocoa_GL_GetProcAddress(_THIS, const char *proc) return SDL_LoadFunction(_this->gl_config.dll_handle, proc); } -void -Cocoa_GL_UnloadLibrary(_THIS) +void Cocoa_GL_UnloadLibrary(_THIS) { SDL_UnloadObject(_this->gl_config.dll_handle); _this->gl_config.dll_handle = NULL; } SDL_GLContext -Cocoa_GL_CreateContext(_THIS, SDL_Window * window) -{ @autoreleasepool +Cocoa_GL_CreateContext(_THIS, SDL_Window *window) { - SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); - SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata; - NSOpenGLPixelFormatAttribute attr[32]; - NSOpenGLPixelFormat *fmt; - SDLOpenGLContext *context; - SDL_GLContext sdlcontext; - NSOpenGLContext *share_context = nil; - int i = 0; - const char *glversion; - int glversion_major; - int glversion_minor; - NSOpenGLPixelFormatAttribute profile; - int interval; + @autoreleasepool { + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); + SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata; + NSOpenGLPixelFormatAttribute attr[32]; + NSOpenGLPixelFormat *fmt; + SDLOpenGLContext *context; + SDL_GLContext sdlcontext; + NSOpenGLContext *share_context = nil; + int i = 0; + const char *glversion; + int glversion_major; + int glversion_minor; + NSOpenGLPixelFormatAttribute profile; + int interval; - if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { + if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { #if SDL_VIDEO_OPENGL_EGL - /* Switch to EGL based functions */ - Cocoa_GL_UnloadLibrary(_this); - _this->GL_LoadLibrary = Cocoa_GLES_LoadLibrary; - _this->GL_GetProcAddress = Cocoa_GLES_GetProcAddress; - _this->GL_UnloadLibrary = Cocoa_GLES_UnloadLibrary; - _this->GL_CreateContext = Cocoa_GLES_CreateContext; - _this->GL_MakeCurrent = Cocoa_GLES_MakeCurrent; - _this->GL_SetSwapInterval = Cocoa_GLES_SetSwapInterval; - _this->GL_GetSwapInterval = Cocoa_GLES_GetSwapInterval; - _this->GL_SwapWindow = Cocoa_GLES_SwapWindow; - _this->GL_DeleteContext = Cocoa_GLES_DeleteContext; - - if (Cocoa_GLES_LoadLibrary(_this, NULL) != 0) { - return NULL; - } - return Cocoa_GLES_CreateContext(_this, window); + /* Switch to EGL based functions */ + Cocoa_GL_UnloadLibrary(_this); + _this->GL_LoadLibrary = Cocoa_GLES_LoadLibrary; + _this->GL_GetProcAddress = Cocoa_GLES_GetProcAddress; + _this->GL_UnloadLibrary = Cocoa_GLES_UnloadLibrary; + _this->GL_CreateContext = Cocoa_GLES_CreateContext; + _this->GL_MakeCurrent = Cocoa_GLES_MakeCurrent; + _this->GL_SetSwapInterval = Cocoa_GLES_SetSwapInterval; + _this->GL_GetSwapInterval = Cocoa_GLES_GetSwapInterval; + _this->GL_SwapWindow = Cocoa_GLES_SwapWindow; + _this->GL_DeleteContext = Cocoa_GLES_DeleteContext; + + if (Cocoa_GLES_LoadLibrary(_this, NULL) != 0) { + return NULL; + } + return Cocoa_GLES_CreateContext(_this, window); #else - SDL_SetError("SDL not configured with EGL support"); - return NULL; + SDL_SetError("SDL not configured with EGL support"); + return NULL; #endif - } + } - attr[i++] = NSOpenGLPFAAllowOfflineRenderers; + attr[i++] = NSOpenGLPFAAllowOfflineRenderers; - profile = NSOpenGLProfileVersionLegacy; - if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) { - profile = NSOpenGLProfileVersion3_2Core; - } - attr[i++] = NSOpenGLPFAOpenGLProfile; - attr[i++] = profile; + profile = NSOpenGLProfileVersionLegacy; + if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) { + profile = NSOpenGLProfileVersion3_2Core; + } + attr[i++] = NSOpenGLPFAOpenGLProfile; + attr[i++] = profile; - attr[i++] = NSOpenGLPFAColorSize; - attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8; + attr[i++] = NSOpenGLPFAColorSize; + attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format) * 8; - attr[i++] = NSOpenGLPFADepthSize; - attr[i++] = _this->gl_config.depth_size; + attr[i++] = NSOpenGLPFADepthSize; + attr[i++] = _this->gl_config.depth_size; - if (_this->gl_config.double_buffer) { - attr[i++] = NSOpenGLPFADoubleBuffer; - } + if (_this->gl_config.double_buffer) { + attr[i++] = NSOpenGLPFADoubleBuffer; + } - if (_this->gl_config.stereo) { - attr[i++] = NSOpenGLPFAStereo; - } + if (_this->gl_config.stereo) { + attr[i++] = NSOpenGLPFAStereo; + } - if (_this->gl_config.stencil_size) { - attr[i++] = NSOpenGLPFAStencilSize; - attr[i++] = _this->gl_config.stencil_size; - } + if (_this->gl_config.stencil_size) { + attr[i++] = NSOpenGLPFAStencilSize; + attr[i++] = _this->gl_config.stencil_size; + } - if ((_this->gl_config.accum_red_size + - _this->gl_config.accum_green_size + - _this->gl_config.accum_blue_size + - _this->gl_config.accum_alpha_size) > 0) { - attr[i++] = NSOpenGLPFAAccumSize; - attr[i++] = _this->gl_config.accum_red_size + _this->gl_config.accum_green_size + _this->gl_config.accum_blue_size + _this->gl_config.accum_alpha_size; - } + if ((_this->gl_config.accum_red_size + + _this->gl_config.accum_green_size + + _this->gl_config.accum_blue_size + + _this->gl_config.accum_alpha_size) > 0) { + attr[i++] = NSOpenGLPFAAccumSize; + attr[i++] = _this->gl_config.accum_red_size + _this->gl_config.accum_green_size + _this->gl_config.accum_blue_size + _this->gl_config.accum_alpha_size; + } - if (_this->gl_config.multisamplebuffers) { - attr[i++] = NSOpenGLPFASampleBuffers; - attr[i++] = _this->gl_config.multisamplebuffers; - } + if (_this->gl_config.multisamplebuffers) { + attr[i++] = NSOpenGLPFASampleBuffers; + attr[i++] = _this->gl_config.multisamplebuffers; + } - if (_this->gl_config.multisamplesamples) { - attr[i++] = NSOpenGLPFASamples; - attr[i++] = _this->gl_config.multisamplesamples; - attr[i++] = NSOpenGLPFANoRecovery; - } - if (_this->gl_config.floatbuffers) { - attr[i++] = NSOpenGLPFAColorFloat; - } + if (_this->gl_config.multisamplesamples) { + attr[i++] = NSOpenGLPFASamples; + attr[i++] = _this->gl_config.multisamplesamples; + attr[i++] = NSOpenGLPFANoRecovery; + } + if (_this->gl_config.floatbuffers) { + attr[i++] = NSOpenGLPFAColorFloat; + } - if (_this->gl_config.accelerated >= 0) { - if (_this->gl_config.accelerated) { - attr[i++] = NSOpenGLPFAAccelerated; + if (_this->gl_config.accelerated >= 0) { + if (_this->gl_config.accelerated) { + attr[i++] = NSOpenGLPFAAccelerated; + } else { + attr[i++] = NSOpenGLPFARendererID; + attr[i++] = kCGLRendererGenericFloatID; + } + } + + attr[i++] = NSOpenGLPFAScreenMask; + attr[i++] = CGDisplayIDToOpenGLDisplayMask(displaydata->display); + attr[i] = 0; + + fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr]; + if (fmt == nil) { + SDL_SetError("Failed creating OpenGL pixel format"); + return NULL; + } + + if (_this->gl_config.share_with_current_context) { + share_context = (__bridge NSOpenGLContext *)SDL_GL_GetCurrentContext(); + } + + context = [[SDLOpenGLContext alloc] initWithFormat:fmt shareContext:share_context]; + + if (context == nil) { + SDL_SetError("Failed creating OpenGL context"); + return NULL; + } + + sdlcontext = (SDL_GLContext)CFBridgingRetain(context); + + /* vsync is handled separately by synchronizing with a display link. */ + interval = 0; + [context setValues:&interval forParameter:NSOpenGLCPSwapInterval]; + + if (Cocoa_GL_MakeCurrent(_this, window, (__bridge SDL_GLContext)context) < 0) { + Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context); + SDL_SetError("Failed making OpenGL context current"); + return NULL; + } + + if (_this->gl_config.major_version < 3 && + _this->gl_config.profile_mask == 0 && + _this->gl_config.flags == 0) { + /* This is a legacy profile, so to match other backends, we're done. */ } else { - attr[i++] = NSOpenGLPFARendererID; - attr[i++] = kCGLRendererGenericFloatID; + const GLubyte *(APIENTRY * glGetStringFunc)(GLenum); + + glGetStringFunc = (const GLubyte *(APIENTRY *)(GLenum))SDL_GL_GetProcAddress("glGetString"); + if (!glGetStringFunc) { + Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context); + SDL_SetError("Failed getting OpenGL glGetString entry point"); + return NULL; + } + + glversion = (const char *)glGetStringFunc(GL_VERSION); + if (glversion == NULL) { + Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context); + SDL_SetError("Failed getting OpenGL context version"); + return NULL; + } + + if (SDL_sscanf(glversion, "%d.%d", &glversion_major, &glversion_minor) != 2) { + Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context); + SDL_SetError("Failed parsing OpenGL context version"); + return NULL; + } + + if ((glversion_major < _this->gl_config.major_version) || + ((glversion_major == _this->gl_config.major_version) && (glversion_minor < _this->gl_config.minor_version))) { + Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context); + SDL_SetError("Failed creating OpenGL context at version requested"); + return NULL; + } + + /* In the future we'll want to do this, but to match other platforms + we'll leave the OpenGL version the way it is for now + */ + /*_this->gl_config.major_version = glversion_major;*/ + /*_this->gl_config.minor_version = glversion_minor;*/ } + return sdlcontext; } +} - attr[i++] = NSOpenGLPFAScreenMask; - attr[i++] = CGDisplayIDToOpenGLDisplayMask(displaydata->display); - attr[i] = 0; - - fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr]; - if (fmt == nil) { - SDL_SetError("Failed creating OpenGL pixel format"); - return NULL; - } - - if (_this->gl_config.share_with_current_context) { - share_context = (__bridge NSOpenGLContext*)SDL_GL_GetCurrentContext(); - } - - context = [[SDLOpenGLContext alloc] initWithFormat:fmt shareContext:share_context]; - - if (context == nil) { - SDL_SetError("Failed creating OpenGL context"); - return NULL; - } - - sdlcontext = (SDL_GLContext)CFBridgingRetain(context); - - /* vsync is handled separately by synchronizing with a display link. */ - interval = 0; - [context setValues:&interval forParameter:NSOpenGLCPSwapInterval]; - - if ( Cocoa_GL_MakeCurrent(_this, window, (__bridge SDL_GLContext)context) < 0 ) { - Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context); - SDL_SetError("Failed making OpenGL context current"); - return NULL; - } - - if (_this->gl_config.major_version < 3 && - _this->gl_config.profile_mask == 0 && - _this->gl_config.flags == 0) { - /* This is a legacy profile, so to match other backends, we're done. */ - } else { - const GLubyte *(APIENTRY * glGetStringFunc)(GLenum); - - glGetStringFunc = (const GLubyte *(APIENTRY *)(GLenum)) SDL_GL_GetProcAddress("glGetString"); - if (!glGetStringFunc) { - Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context); - SDL_SetError ("Failed getting OpenGL glGetString entry point"); - return NULL; - } - - glversion = (const char *)glGetStringFunc(GL_VERSION); - if (glversion == NULL) { - Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context); - SDL_SetError ("Failed getting OpenGL context version"); - return NULL; - } - - if (SDL_sscanf(glversion, "%d.%d", &glversion_major, &glversion_minor) != 2) { - Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context); - SDL_SetError ("Failed parsing OpenGL context version"); - return NULL; - } - - if ((glversion_major < _this->gl_config.major_version) || - ((glversion_major == _this->gl_config.major_version) && (glversion_minor < _this->gl_config.minor_version))) { - Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context); - SDL_SetError ("Failed creating OpenGL context at version requested"); - return NULL; - } - - /* In the future we'll want to do this, but to match other platforms - we'll leave the OpenGL version the way it is for now - */ - /*_this->gl_config.major_version = glversion_major;*/ - /*_this->gl_config.minor_version = glversion_minor;*/ - } - return sdlcontext; -}} - -int -Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) -{ @autoreleasepool +int Cocoa_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context) { - if (context) { - SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *)context; - if ([nscontext window] != window) { - [nscontext setWindow:window]; - [nscontext updateIfNeeded]; + @autoreleasepool { + if (context) { + SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *)context; + if ([nscontext window] != window) { + [nscontext setWindow:window]; + [nscontext updateIfNeeded]; + } + [nscontext makeCurrentContext]; + } else { + [NSOpenGLContext clearCurrentContext]; } - [nscontext makeCurrentContext]; - } else { - [NSOpenGLContext clearCurrentContext]; + + return 0; } +} - return 0; -}} - -int -Cocoa_GL_SetSwapInterval(_THIS, int interval) -{ @autoreleasepool +int Cocoa_GL_SetSwapInterval(_THIS, int interval) { - SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *) SDL_GL_GetCurrentContext(); - int status; + @autoreleasepool { + SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *)SDL_GL_GetCurrentContext(); + int status; - if (nscontext == nil) { - status = SDL_SetError("No current OpenGL context"); - } else { - SDL_LockMutex(nscontext->swapIntervalMutex); - SDL_AtomicSet(&nscontext->swapIntervalsPassed, 0); - SDL_AtomicSet(&nscontext->swapIntervalSetting, interval); - SDL_UnlockMutex(nscontext->swapIntervalMutex); - status = 0; - } - - return status; -}} - -int -Cocoa_GL_GetSwapInterval(_THIS) -{ @autoreleasepool -{ - SDLOpenGLContext* nscontext = (__bridge SDLOpenGLContext*)SDL_GL_GetCurrentContext(); - return nscontext ? SDL_AtomicGet(&nscontext->swapIntervalSetting) : 0; -}} - -int -Cocoa_GL_SwapWindow(_THIS, SDL_Window * window) -{ @autoreleasepool -{ - SDLOpenGLContext* nscontext = (__bridge SDLOpenGLContext*)SDL_GL_GetCurrentContext(); - SDL_VideoData *videodata = (__bridge SDL_VideoData *) _this->driverdata; - const int setting = SDL_AtomicGet(&nscontext->swapIntervalSetting); - - if (setting == 0) { - /* nothing to do if vsync is disabled, don't even lock */ - } else if (setting < 0) { /* late swap tearing */ - SDL_LockMutex(nscontext->swapIntervalMutex); - while (SDL_AtomicGet(&nscontext->swapIntervalsPassed) == 0) { - SDL_CondWait(nscontext->swapIntervalCond, nscontext->swapIntervalMutex); + if (nscontext == nil) { + status = SDL_SetError("No current OpenGL context"); + } else { + SDL_LockMutex(nscontext->swapIntervalMutex); + SDL_AtomicSet(&nscontext->swapIntervalsPassed, 0); + SDL_AtomicSet(&nscontext->swapIntervalSetting, interval); + SDL_UnlockMutex(nscontext->swapIntervalMutex); + status = 0; } - SDL_AtomicSet(&nscontext->swapIntervalsPassed, 0); - SDL_UnlockMutex(nscontext->swapIntervalMutex); - } else { - SDL_LockMutex(nscontext->swapIntervalMutex); - do { /* always wait here so we know we just hit a swap interval. */ - SDL_CondWait(nscontext->swapIntervalCond, nscontext->swapIntervalMutex); - } while ((SDL_AtomicGet(&nscontext->swapIntervalsPassed) % setting) != 0); - SDL_AtomicSet(&nscontext->swapIntervalsPassed, 0); - SDL_UnlockMutex(nscontext->swapIntervalMutex); + + return status; } +} - /*{ static Uint64 prev = 0; const Uint64 now = SDL_GetTicks64(); const unsigned int diff = (unsigned int) (now - prev); prev = now; printf("GLSWAPBUFFERS TICKS %u\n", diff); }*/ - - /* on 10.14 ("Mojave") and later, this deadlocks if two contexts in two - threads try to swap at the same time, so put a mutex around it. */ - SDL_LockMutex(videodata.swaplock); - [nscontext flushBuffer]; - [nscontext updateIfNeeded]; - SDL_UnlockMutex(videodata.swaplock); - return 0; -}} - -void -Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context) -{ @autoreleasepool +int Cocoa_GL_GetSwapInterval(_THIS) { - SDLOpenGLContext *nscontext = (SDLOpenGLContext *)CFBridgingRelease(context); - [nscontext setWindow:NULL]; -}} + @autoreleasepool { + SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *)SDL_GL_GetCurrentContext(); + return nscontext ? SDL_AtomicGet(&nscontext->swapIntervalSetting) : 0; + } +} + +int Cocoa_GL_SwapWindow(_THIS, SDL_Window *window) +{ + @autoreleasepool { + SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *)SDL_GL_GetCurrentContext(); + SDL_VideoData *videodata = (__bridge SDL_VideoData *)_this->driverdata; + const int setting = SDL_AtomicGet(&nscontext->swapIntervalSetting); + + if (setting == 0) { + /* nothing to do if vsync is disabled, don't even lock */ + } else if (setting < 0) { /* late swap tearing */ + SDL_LockMutex(nscontext->swapIntervalMutex); + while (SDL_AtomicGet(&nscontext->swapIntervalsPassed) == 0) { + SDL_CondWait(nscontext->swapIntervalCond, nscontext->swapIntervalMutex); + } + SDL_AtomicSet(&nscontext->swapIntervalsPassed, 0); + SDL_UnlockMutex(nscontext->swapIntervalMutex); + } else { + SDL_LockMutex(nscontext->swapIntervalMutex); + do { /* always wait here so we know we just hit a swap interval. */ + SDL_CondWait(nscontext->swapIntervalCond, nscontext->swapIntervalMutex); + } while ((SDL_AtomicGet(&nscontext->swapIntervalsPassed) % setting) != 0); + SDL_AtomicSet(&nscontext->swapIntervalsPassed, 0); + SDL_UnlockMutex(nscontext->swapIntervalMutex); + } + + /*{ static Uint64 prev = 0; const Uint64 now = SDL_GetTicks64(); const unsigned int diff = (unsigned int) (now - prev); prev = now; printf("GLSWAPBUFFERS TICKS %u\n", diff); }*/ + + /* on 10.14 ("Mojave") and later, this deadlocks if two contexts in two + threads try to swap at the same time, so put a mutex around it. */ + SDL_LockMutex(videodata.swaplock); + [nscontext flushBuffer]; + [nscontext updateIfNeeded]; + SDL_UnlockMutex(videodata.swaplock); + return 0; + } +} + +void Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context) +{ + @autoreleasepool { + SDLOpenGLContext *nscontext = (SDLOpenGLContext *)CFBridgingRelease(context); + [nscontext setWindow:NULL]; + } +} /* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */ #ifdef __clang__ diff --git a/src/video/cocoa/SDL_cocoaopengles.m b/src/video/cocoa/SDL_cocoaopengles.m index bdf2e9a08..9b6d21088 100644 --- a/src/video/cocoa/SDL_cocoaopengles.m +++ b/src/video/cocoa/SDL_cocoaopengles.m @@ -28,8 +28,7 @@ /* EGL implementation of SDL OpenGL support */ -int -Cocoa_GLES_LoadLibrary(_THIS, const char *path) +int Cocoa_GLES_LoadLibrary(_THIS, const char *path) { /* If the profile requested is not GL ES, switch over to WIN_GL functions */ if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) { @@ -49,7 +48,7 @@ Cocoa_GLES_LoadLibrary(_THIS, const char *path) return SDL_SetError("SDL not configured with OpenGL/CGL support"); #endif } - + if (_this->egl_data == NULL) { return SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, 0); } @@ -58,11 +57,11 @@ Cocoa_GLES_LoadLibrary(_THIS, const char *path) } SDL_GLContext -Cocoa_GLES_CreateContext(_THIS, SDL_Window * window) -{ @autoreleasepool +Cocoa_GLES_CreateContext(_THIS, SDL_Window *window) { - SDL_GLContext context; - SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; + @autoreleasepool { + SDL_GLContext context; + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; #if SDL_VIDEO_OPENGL_CGL if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) { @@ -78,12 +77,12 @@ Cocoa_GLES_CreateContext(_THIS, SDL_Window * window) _this->GL_SwapWindow = Cocoa_GL_SwapWindow; _this->GL_DeleteContext = Cocoa_GL_DeleteContext; - if (Cocoa_GL_LoadLibrary(_this, NULL) != 0) { - return NULL; - } + if (Cocoa_GL_LoadLibrary(_this, NULL) != 0) { + return NULL; + } - return Cocoa_GL_CreateContext(_this, window); - } + return Cocoa_GL_CreateContext(_this, window); + } #endif context = SDL_EGL_CreateContext(_this, data.egl_surface); @@ -115,12 +114,18 @@ Cocoa_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) int Cocoa_GLES_SetupWindow(_THIS, SDL_Window * window) { - NSView* v; - /* The current context is lost in here; save it and reset it. */ - SDL_WindowData *windowdata = (__bridge SDL_WindowData *) window->driverdata; - SDL_Window *current_win = SDL_GL_GetCurrentWindow(); - SDL_GLContext current_ctx = SDL_GL_GetCurrentContext(); + @autoreleasepool { + SDL_EGL_DeleteContext(_this, context); + Cocoa_GLES_UnloadLibrary(_this); + } +} +int Cocoa_GLES_SwapWindow(_THIS, SDL_Window *window) +{ + @autoreleasepool { + return SDL_EGL_SwapBuffers(_this, ((__bridge SDL_WindowData *)window->driverdata).egl_surface); + } +} if (_this->egl_data == NULL) { /* !!! FIXME: commenting out this assertion is (I think) incorrect; figure out why driver_loaded is wrong for ANGLE instead. --ryan. */ @@ -131,16 +136,12 @@ Cocoa_GLES_SetupWindow(_THIS, SDL_Window * window) SDL_EGL_UnloadLibrary(_this); return -1; } - _this->gl_config.driver_loaded = 1; - } - - /* Create the GLES window surface */ - v = windowdata.nswindow.contentView; - windowdata.egl_surface = SDL_EGL_CreateSurface(_this, (__bridge NativeWindowType)[v layer]); - if (windowdata.egl_surface == EGL_NO_SURFACE) { - return SDL_SetError("Could not create GLES window surface"); + if (h) { + *h = height; + } } +} return Cocoa_GLES_MakeCurrent(_this, current_win, current_ctx); } diff --git a/src/video/cocoa/SDL_cocoashape.h b/src/video/cocoa/SDL_cocoashape.h index 358d878ef..93957c522 100644 --- a/src/video/cocoa/SDL_cocoashape.h +++ b/src/video/cocoa/SDL_cocoashape.h @@ -30,13 +30,13 @@ #include "../SDL_shape_internals.h" @interface SDL_ShapeData : NSObject - @property (nonatomic) NSGraphicsContext* context; - @property (nonatomic) SDL_bool saved; - @property (nonatomic) SDL_ShapeTree* shape; +@property(nonatomic) NSGraphicsContext *context; +@property(nonatomic) SDL_bool saved; +@property(nonatomic) SDL_ShapeTree *shape; @end -extern SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window); -extern int Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode); +extern SDL_WindowShaper *Cocoa_CreateShaper(SDL_Window *window); +extern int Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode); extern int Cocoa_ResizeWindowShape(SDL_Window *window); #endif /* SDL_cocoashape_h_ */ diff --git a/src/video/cocoa/SDL_cocoashape.m b/src/video/cocoa/SDL_cocoashape.m index ac3459c56..0d85f4fd9 100644 --- a/src/video/cocoa/SDL_cocoashape.m +++ b/src/video/cocoa/SDL_cocoashape.m @@ -31,100 +31,101 @@ @end @interface SDL_CocoaClosure : NSObject - @property (nonatomic) NSView* view; - @property (nonatomic) NSBezierPath* path; - @property (nonatomic) SDL_Window* window; +@property(nonatomic) NSView *view; +@property(nonatomic) NSBezierPath *path; +@property(nonatomic) SDL_Window *window; @end @implementation SDL_CocoaClosure @end -SDL_WindowShaper* -Cocoa_CreateShaper(SDL_Window* window) -{ @autoreleasepool +SDL_WindowShaper * +Cocoa_CreateShaper(SDL_Window *window) { - SDL_WindowShaper* result; - SDL_ShapeData* data; - int resized_properly; - SDL_WindowData* windata = (__bridge SDL_WindowData*)window->driverdata; + @autoreleasepool { + SDL_WindowShaper *result; + SDL_ShapeData *data; + int resized_properly; + SDL_WindowData *windata = (__bridge SDL_WindowData *)window->driverdata; - result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper)); - if (!result) { - SDL_OutOfMemory(); - return NULL; + result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper)); + if (!result) { + SDL_OutOfMemory(); + return NULL; + } + + [windata.nswindow setOpaque:NO]; + + [windata.nswindow setStyleMask:NSWindowStyleMaskBorderless]; + + result->window = window; + result->mode.mode = ShapeModeDefault; + result->mode.parameters.binarizationCutoff = 1; + result->userx = result->usery = 0; + window->shaper = result; + + data = [[SDL_ShapeData alloc] init]; + data.context = [windata.nswindow graphicsContext]; + data.saved = SDL_FALSE; + data.shape = NULL; + + /* TODO: There's no place to release this... */ + result->driverdata = (void *)CFBridgingRetain(data); + + resized_properly = Cocoa_ResizeWindowShape(window); + SDL_assert(resized_properly == 0); + return result; } +} - [windata.nswindow setOpaque:NO]; - - [windata.nswindow setStyleMask:NSWindowStyleMaskBorderless]; - - result->window = window; - result->mode.mode = ShapeModeDefault; - result->mode.parameters.binarizationCutoff = 1; - result->userx = result->usery = 0; - window->shaper = result; - - data = [[SDL_ShapeData alloc] init]; - data.context = [windata.nswindow graphicsContext]; - data.saved = SDL_FALSE; - data.shape = NULL; - - /* TODO: There's no place to release this... */ - result->driverdata = (void*) CFBridgingRetain(data); - - resized_properly = Cocoa_ResizeWindowShape(window); - SDL_assert(resized_properly == 0); - return result; -}} - -void -ConvertRects(SDL_ShapeTree* tree, void* closure) +void ConvertRects(SDL_ShapeTree *tree, void *closure) { - SDL_CocoaClosure* data = (__bridge SDL_CocoaClosure*)closure; - if(tree->kind == OpaqueShape) { + SDL_CocoaClosure *data = (__bridge SDL_CocoaClosure *)closure; + if (tree->kind == OpaqueShape) { NSRect rect = NSMakeRect(tree->data.shape.x, data.window->h - tree->data.shape.y, tree->data.shape.w, tree->data.shape.h); [data.path appendBezierPathWithRect:[data.view convertRect:rect toView:nil]]; } } -int -Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode) -{ @autoreleasepool +int Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode) { - SDL_ShapeData* data = (__bridge SDL_ShapeData*)shaper->driverdata; - SDL_WindowData* windata = (__bridge SDL_WindowData*)shaper->window->driverdata; - SDL_CocoaClosure* closure; - if(data.saved == SDL_TRUE) { - [data.context restoreGraphicsState]; - data.saved = SDL_FALSE; + @autoreleasepool { + SDL_ShapeData *data = (__bridge SDL_ShapeData *)shaper->driverdata; + SDL_WindowData *windata = (__bridge SDL_WindowData *)shaper->window->driverdata; + SDL_CocoaClosure *closure; + if (data.saved == SDL_TRUE) { + [data.context restoreGraphicsState]; + data.saved = SDL_FALSE; + } + + /*[data.context saveGraphicsState];*/ + /*data.saved = SDL_TRUE;*/ + [NSGraphicsContext setCurrentContext:data.context]; + + [[NSColor clearColor] set]; + NSRectFill([windata.sdlContentView frame]); + data.shape = SDL_CalculateShapeTree(*shape_mode, shape); + + closure = [[SDL_CocoaClosure alloc] init]; + + closure.view = windata.sdlContentView; + closure.path = [NSBezierPath bezierPath]; + closure.window = shaper->window; + SDL_TraverseShapeTree(data.shape, &ConvertRects, (__bridge void *)closure); + [closure.path addClip]; + + return 0; } +} - /*[data.context saveGraphicsState];*/ - /*data.saved = SDL_TRUE;*/ - [NSGraphicsContext setCurrentContext:data.context]; - - [[NSColor clearColor] set]; - NSRectFill([windata.sdlContentView frame]); - data.shape = SDL_CalculateShapeTree(*shape_mode, shape); - - closure = [[SDL_CocoaClosure alloc] init]; - - closure.view = windata.sdlContentView; - closure.path = [NSBezierPath bezierPath]; - closure.window = shaper->window; - SDL_TraverseShapeTree(data.shape, &ConvertRects, (__bridge void*)closure); - [closure.path addClip]; - - return 0; -}} - -int -Cocoa_ResizeWindowShape(SDL_Window *window) -{ @autoreleasepool { - SDL_ShapeData* data = (__bridge SDL_ShapeData*)window->shaper->driverdata; - SDL_assert(data != NULL); - return 0; -}} +int Cocoa_ResizeWindowShape(SDL_Window *window) +{ + @autoreleasepool { + SDL_ShapeData *data = (__bridge SDL_ShapeData *)window->shaper->driverdata; + SDL_assert(data != NULL); + return 0; + } +} #endif /* SDL_VIDEO_DRIVER_COCOA */ diff --git a/src/video/cocoa/SDL_cocoavideo.h b/src/video/cocoa/SDL_cocoavideo.h index 8f4a413e9..959fd59c9 100644 --- a/src/video/cocoa/SDL_cocoavideo.h +++ b/src/video/cocoa/SDL_cocoavideo.h @@ -98,18 +98,18 @@ DECLARE_ALERT_STYLE(Critical); @class SDLTranslatorResponder; @interface SDL_VideoData : NSObject - @property (nonatomic) int allow_spaces; - @property (nonatomic) int trackpad_is_touch_only; - @property (nonatomic) unsigned int modifierFlags; - @property (nonatomic) void *key_layout; - @property (nonatomic) SDLTranslatorResponder *fieldEdit; - @property (nonatomic) NSInteger clipboard_count; - @property (nonatomic) IOPMAssertionID screensaver_assertion; - @property (nonatomic) SDL_mutex *swaplock; +@property(nonatomic) int allow_spaces; +@property(nonatomic) int trackpad_is_touch_only; +@property(nonatomic) unsigned int modifierFlags; +@property(nonatomic) void *key_layout; +@property(nonatomic) SDLTranslatorResponder *fieldEdit; +@property(nonatomic) NSInteger clipboard_count; +@property(nonatomic) IOPMAssertionID screensaver_assertion; +@property(nonatomic) SDL_mutex *swaplock; @end /* Utility functions */ -extern NSImage * Cocoa_CreateImage(SDL_Surface * surface); +extern NSImage *Cocoa_CreateImage(SDL_Surface *surface); /* Fix build with the 10.11 SDK */ #if MAC_OS_X_VERSION_MAX_ALLOWED < 101200 diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m index 6c3d44efa..d4dc7bf5f 100644 --- a/src/video/cocoa/SDL_cocoavideo.m +++ b/src/video/cocoa/SDL_cocoavideo.m @@ -44,53 +44,22 @@ static void Cocoa_VideoQuit(_THIS); /* Cocoa driver bootstrap functions */ -static void -Cocoa_DeleteDevice(SDL_VideoDevice * device) -{ @autoreleasepool +static void Cocoa_DeleteDevice(SDL_VideoDevice *device) { - if (device->wakeup_lock) { - SDL_DestroyMutex(device->wakeup_lock); - } - CFBridgingRelease(device->driverdata); - SDL_free(device); -}} - -static SDL_VideoDevice * -Cocoa_CreateDevice(void) -{ @autoreleasepool -{ - SDL_VideoDevice *device; - SDL_VideoData *data; - - Cocoa_RegisterApp(); - - /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device) { - data = [[SDL_VideoData alloc] init]; - } else { - data = nil; - } - if (!data) { - SDL_OutOfMemory(); + @autoreleasepool { + if (device->wakeup_lock) { + SDL_DestroyMutex(device->wakeup_lock); + } + CFBridgingRelease(device->driverdata); SDL_free(device); - return NULL; } - device->driverdata = (void *)CFBridgingRetain(data); - device->wakeup_lock = SDL_CreateMutex(); +} - /* Set the function pointers */ - device->VideoInit = Cocoa_VideoInit; - device->VideoQuit = Cocoa_VideoQuit; - device->GetDisplayBounds = Cocoa_GetDisplayBounds; - device->GetDisplayUsableBounds = Cocoa_GetDisplayUsableBounds; - device->GetDisplayDPI = Cocoa_GetDisplayDPI; - device->GetDisplayModes = Cocoa_GetDisplayModes; - device->SetDisplayMode = Cocoa_SetDisplayMode; - device->PumpEvents = Cocoa_PumpEvents; - device->WaitEventTimeout = Cocoa_WaitEventTimeout; - device->SendWakeupEvent = Cocoa_SendWakeupEvent; - device->SuspendScreenSaver = Cocoa_SuspendScreenSaver; +static SDL_VideoDevice *Cocoa_CreateDevice(void) +{ + @autoreleasepool { + SDL_VideoDevice *device; + SDL_VideoData *data; device->CreateSDLWindow = Cocoa_CreateWindow; device->CreateSDLWindowFrom = Cocoa_CreateWindowFrom; @@ -125,9 +94,68 @@ Cocoa_CreateDevice(void) device->AcceptDragAndDrop = Cocoa_AcceptDragAndDrop; device->FlashWindow = Cocoa_FlashWindow; - device->shape_driver.CreateShaper = Cocoa_CreateShaper; - device->shape_driver.SetWindowShape = Cocoa_SetWindowShape; - device->shape_driver.ResizeWindowShape = Cocoa_ResizeWindowShape; + /* Initialize all variables that we clean on shutdown */ + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (device) { + data = [[SDL_VideoData alloc] init]; + } else { + data = nil; + } + if (!data) { + SDL_OutOfMemory(); + SDL_free(device); + return NULL; + } + device->driverdata = (void *)CFBridgingRetain(data); + device->wakeup_lock = SDL_CreateMutex(); + + /* Set the function pointers */ + device->VideoInit = Cocoa_VideoInit; + device->VideoQuit = Cocoa_VideoQuit; + device->GetDisplayBounds = Cocoa_GetDisplayBounds; + device->GetDisplayUsableBounds = Cocoa_GetDisplayUsableBounds; + device->GetDisplayDPI = Cocoa_GetDisplayDPI; + device->GetDisplayModes = Cocoa_GetDisplayModes; + device->SetDisplayMode = Cocoa_SetDisplayMode; + device->PumpEvents = Cocoa_PumpEvents; + device->WaitEventTimeout = Cocoa_WaitEventTimeout; + device->SendWakeupEvent = Cocoa_SendWakeupEvent; + device->SuspendScreenSaver = Cocoa_SuspendScreenSaver; + + device->CreateSDLWindow = Cocoa_CreateWindow; + device->CreateSDLWindowFrom = Cocoa_CreateWindowFrom; + device->SetWindowTitle = Cocoa_SetWindowTitle; + device->SetWindowIcon = Cocoa_SetWindowIcon; + device->SetWindowPosition = Cocoa_SetWindowPosition; + device->SetWindowSize = Cocoa_SetWindowSize; + device->SetWindowMinimumSize = Cocoa_SetWindowMinimumSize; + device->SetWindowMaximumSize = Cocoa_SetWindowMaximumSize; + device->SetWindowOpacity = Cocoa_SetWindowOpacity; + device->GetWindowSizeInPixels = Cocoa_GetWindowSizeInPixels; + device->ShowWindow = Cocoa_ShowWindow; + device->HideWindow = Cocoa_HideWindow; + device->RaiseWindow = Cocoa_RaiseWindow; + device->MaximizeWindow = Cocoa_MaximizeWindow; + device->MinimizeWindow = Cocoa_MinimizeWindow; + device->RestoreWindow = Cocoa_RestoreWindow; + device->SetWindowBordered = Cocoa_SetWindowBordered; + device->SetWindowResizable = Cocoa_SetWindowResizable; + device->SetWindowAlwaysOnTop = Cocoa_SetWindowAlwaysOnTop; + device->SetWindowFullscreen = Cocoa_SetWindowFullscreen; + device->GetWindowICCProfile = Cocoa_GetWindowICCProfile; + device->GetWindowDisplayIndex = Cocoa_GetWindowDisplayIndex; + device->SetWindowMouseRect = Cocoa_SetWindowMouseRect; + device->SetWindowMouseGrab = Cocoa_SetWindowMouseGrab; + device->SetWindowKeyboardGrab = Cocoa_SetWindowKeyboardGrab; + device->DestroyWindow = Cocoa_DestroyWindow; + device->GetWindowWMInfo = Cocoa_GetWindowWMInfo; + device->SetWindowHitTest = Cocoa_SetWindowHitTest; + device->AcceptDragAndDrop = Cocoa_AcceptDragAndDrop; + device->FlashWindow = Cocoa_FlashWindow; + + device->shape_driver.CreateShaper = Cocoa_CreateShaper; + device->shape_driver.SetWindowShape = Cocoa_SetWindowShape; + device->shape_driver.ResizeWindowShape = Cocoa_ResizeWindowShape; #if SDL_VIDEO_OPENGL_CGL device->GL_LoadLibrary = Cocoa_GL_LoadLibrary; @@ -152,77 +180,77 @@ Cocoa_CreateDevice(void) #endif #if SDL_VIDEO_VULKAN - device->Vulkan_LoadLibrary = Cocoa_Vulkan_LoadLibrary; - device->Vulkan_UnloadLibrary = Cocoa_Vulkan_UnloadLibrary; - device->Vulkan_GetInstanceExtensions = Cocoa_Vulkan_GetInstanceExtensions; - device->Vulkan_CreateSurface = Cocoa_Vulkan_CreateSurface; - device->Vulkan_GetDrawableSize = Cocoa_Vulkan_GetDrawableSize; + device->Vulkan_LoadLibrary = Cocoa_Vulkan_LoadLibrary; + device->Vulkan_UnloadLibrary = Cocoa_Vulkan_UnloadLibrary; + device->Vulkan_GetInstanceExtensions = Cocoa_Vulkan_GetInstanceExtensions; + device->Vulkan_CreateSurface = Cocoa_Vulkan_CreateSurface; + device->Vulkan_GetDrawableSize = Cocoa_Vulkan_GetDrawableSize; #endif #if SDL_VIDEO_METAL - device->Metal_CreateView = Cocoa_Metal_CreateView; - device->Metal_DestroyView = Cocoa_Metal_DestroyView; - device->Metal_GetLayer = Cocoa_Metal_GetLayer; - device->Metal_GetDrawableSize = Cocoa_Metal_GetDrawableSize; + device->Metal_CreateView = Cocoa_Metal_CreateView; + device->Metal_DestroyView = Cocoa_Metal_DestroyView; + device->Metal_GetLayer = Cocoa_Metal_GetLayer; + device->Metal_GetDrawableSize = Cocoa_Metal_GetDrawableSize; #endif - device->StartTextInput = Cocoa_StartTextInput; - device->StopTextInput = Cocoa_StopTextInput; - device->SetTextInputRect = Cocoa_SetTextInputRect; + device->StartTextInput = Cocoa_StartTextInput; + device->StopTextInput = Cocoa_StopTextInput; + device->SetTextInputRect = Cocoa_SetTextInputRect; - device->SetClipboardText = Cocoa_SetClipboardText; - device->GetClipboardText = Cocoa_GetClipboardText; - device->HasClipboardText = Cocoa_HasClipboardText; + device->SetClipboardText = Cocoa_SetClipboardText; + device->GetClipboardText = Cocoa_GetClipboardText; + device->HasClipboardText = Cocoa_HasClipboardText; - device->free = Cocoa_DeleteDevice; + device->free = Cocoa_DeleteDevice; - return device; -}} + return device; + } +} VideoBootStrap COCOA_bootstrap = { "cocoa", "SDL Cocoa video driver", Cocoa_CreateDevice }; - -int -Cocoa_VideoInit(_THIS) -{ @autoreleasepool +int Cocoa_VideoInit(_THIS) { - SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata; + @autoreleasepool { + SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata; - Cocoa_InitModes(_this); - Cocoa_InitKeyboard(_this); - if (Cocoa_InitMouse(_this) < 0) { - return -1; + Cocoa_InitModes(_this); + Cocoa_InitKeyboard(_this); + if (Cocoa_InitMouse(_this) < 0) { + return -1; + } + + data.allow_spaces = SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE); + data.trackpad_is_touch_only = SDL_GetHintBoolean(SDL_HINT_TRACKPAD_IS_TOUCH_ONLY, SDL_FALSE); + + data.swaplock = SDL_CreateMutex(); + if (!data.swaplock) { + return -1; + } + + return 0; } +} - data.allow_spaces = SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE); - data.trackpad_is_touch_only = SDL_GetHintBoolean(SDL_HINT_TRACKPAD_IS_TOUCH_ONLY, SDL_FALSE); - - data.swaplock = SDL_CreateMutex(); - if (!data.swaplock) { - return -1; - } - - return 0; -}} - -void -Cocoa_VideoQuit(_THIS) -{ @autoreleasepool +void Cocoa_VideoQuit(_THIS) { - SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata; - Cocoa_QuitModes(_this); - Cocoa_QuitKeyboard(_this); - Cocoa_QuitMouse(_this); - SDL_DestroyMutex(data.swaplock); - data.swaplock = NULL; -}} + @autoreleasepool { + SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata; + Cocoa_QuitModes(_this); + Cocoa_QuitKeyboard(_this); + Cocoa_QuitMouse(_this); + SDL_DestroyMutex(data.swaplock); + data.swaplock = NULL; + } +} /* This function assumes that it's called from within an autorelease pool */ NSImage * -Cocoa_CreateImage(SDL_Surface * surface) +Cocoa_CreateImage(SDL_Surface *surface) { SDL_Surface *converted; NSBitmapImageRep *imgrep; @@ -235,16 +263,16 @@ Cocoa_CreateImage(SDL_Surface * surface) return nil; } - imgrep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL - pixelsWide: converted->w - pixelsHigh: converted->h - bitsPerSample: 8 - samplesPerPixel: 4 - hasAlpha: YES - isPlanar: NO - colorSpaceName: NSDeviceRGBColorSpace - bytesPerRow: converted->pitch - bitsPerPixel: converted->format->BitsPerPixel]; + imgrep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL + pixelsWide:converted->w + pixelsHigh:converted->h + bitsPerSample:8 + samplesPerPixel:4 + hasAlpha:YES + isPlanar:NO + colorSpaceName:NSDeviceRGBColorSpace + bytesPerRow:converted->pitch + bitsPerPixel:converted->format->BitsPerPixel]; if (imgrep == nil) { SDL_FreeSurface(converted); return nil; @@ -256,7 +284,7 @@ Cocoa_CreateImage(SDL_Surface * surface) SDL_FreeSurface(converted); /* Premultiply the alpha channel */ - for (i = (surface->h * surface->w); i--; ) { + for (i = (surface->h * surface->w); i--;) { Uint8 alpha = pixels[3]; pixels[0] = (Uint8)(((Uint16)pixels[0] * alpha) / 255); pixels[1] = (Uint8)(((Uint16)pixels[1] * alpha) / 255); @@ -264,9 +292,9 @@ Cocoa_CreateImage(SDL_Surface * surface) pixels += 4; } - img = [[NSImage alloc] initWithSize: NSMakeSize(surface->w, surface->h)]; + img = [[NSImage alloc] initWithSize:NSMakeSize(surface->w, surface->h)]; if (img != nil) { - [img addRepresentation: imgrep]; + [img addRepresentation:imgrep]; } return img; } diff --git a/src/video/cocoa/SDL_cocoavulkan.h b/src/video/cocoa/SDL_cocoavulkan.h index 9ddc70996..819009985 100644 --- a/src/video/cocoa/SDL_cocoavulkan.h +++ b/src/video/cocoa/SDL_cocoavulkan.h @@ -38,13 +38,13 @@ int Cocoa_Vulkan_LoadLibrary(_THIS, const char *path); void Cocoa_Vulkan_UnloadLibrary(_THIS); SDL_bool Cocoa_Vulkan_GetInstanceExtensions(_THIS, - SDL_Window *window, - unsigned *count, - const char **names); + SDL_Window *window, + unsigned *count, + const char **names); SDL_bool Cocoa_Vulkan_CreateSurface(_THIS, - SDL_Window *window, - VkInstance instance, - VkSurfaceKHR *surface); + SDL_Window *window, + VkInstance instance, + VkSurfaceKHR *surface); void Cocoa_Vulkan_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h); diff --git a/src/video/cocoa/SDL_cocoavulkan.m b/src/video/cocoa/SDL_cocoavulkan.m index 02817f8f1..c502d2d71 100644 --- a/src/video/cocoa/SDL_cocoavulkan.m +++ b/src/video/cocoa/SDL_cocoavulkan.m @@ -37,7 +37,7 @@ #include -const char* defaultPaths[] = { +const char *defaultPaths[] = { "vulkan.framework/vulkan", "libvulkan.1.dylib", "libvulkan.dylib", @@ -69,14 +69,14 @@ int Cocoa_Vulkan_LoadLibrary(_THIS, const char *path) if (!path) { /* Handle the case where Vulkan Portability is linked statically. */ vkGetInstanceProcAddr = - (PFN_vkGetInstanceProcAddr)dlsym(DEFAULT_HANDLE, - "vkGetInstanceProcAddr"); + (PFN_vkGetInstanceProcAddr)dlsym(DEFAULT_HANDLE, + "vkGetInstanceProcAddr"); } if (vkGetInstanceProcAddr) { _this->vulkan_config.loader_handle = DEFAULT_HANDLE; } else { - const char** paths; + const char **paths; const char *foundPath = NULL; int numPaths; int i; @@ -110,7 +110,7 @@ int Cocoa_Vulkan_LoadLibrary(_THIS, const char *path) SDL_SetError("Failed to find %s in either executable or %s: %s", "vkGetInstanceProcAddr", _this->vulkan_config.loader_path, - (const char *) dlerror()); + (const char *)dlerror()); goto fail; } @@ -139,13 +139,10 @@ int Cocoa_Vulkan_LoadLibrary(_THIS, const char *path) } SDL_free(extensions); if (!hasSurfaceExtension) { - SDL_SetError("Installed Vulkan Portability library doesn't implement the " - VK_KHR_SURFACE_EXTENSION_NAME " extension"); + SDL_SetError("Installed Vulkan Portability library doesn't implement the " VK_KHR_SURFACE_EXTENSION_NAME " extension"); goto fail; } else if (!hasMetalSurfaceExtension && !hasMacOSSurfaceExtension) { - SDL_SetError("Installed Vulkan Portability library doesn't implement the " - VK_EXT_METAL_SURFACE_EXTENSION_NAME " or " - VK_MVK_MACOS_SURFACE_EXTENSION_NAME " extensions"); + SDL_SetError("Installed Vulkan Portability library doesn't implement the " VK_EXT_METAL_SURFACE_EXTENSION_NAME " or " VK_MVK_MACOS_SURFACE_EXTENSION_NAME " extensions"); goto fail; } return 0; @@ -167,9 +164,9 @@ void Cocoa_Vulkan_UnloadLibrary(_THIS) } SDL_bool Cocoa_Vulkan_GetInstanceExtensions(_THIS, - SDL_Window *window, - unsigned *count, - const char **names) + SDL_Window *window, + unsigned *count, + const char **names) { static const char *const extensionsForCocoa[] = { VK_KHR_SURFACE_EXTENSION_NAME, VK_EXT_METAL_SURFACE_EXTENSION_NAME @@ -179,8 +176,8 @@ SDL_bool Cocoa_Vulkan_GetInstanceExtensions(_THIS, return SDL_FALSE; } return SDL_Vulkan_GetInstanceExtensions_Helper( - count, names, SDL_arraysize(extensionsForCocoa), - extensionsForCocoa); + count, names, SDL_arraysize(extensionsForCocoa), + extensionsForCocoa); } SDL_bool Cocoa_Vulkan_CreateSurface(_THIS, @@ -224,7 +221,7 @@ SDL_bool Cocoa_Vulkan_CreateSurface(_THIS, createInfo.pNext = NULL; createInfo.flags = 0; createInfo.pLayer = (__bridge const CAMetalLayer *) - Cocoa_Metal_GetLayer(_this, metalview); + Cocoa_Metal_GetLayer(_this, metalview); result = vkCreateMetalSurfaceEXT(instance, &createInfo, NULL, surface); if (result != VK_SUCCESS) { Cocoa_Metal_DestroyView(_this, metalview); @@ -239,7 +236,7 @@ SDL_bool Cocoa_Vulkan_CreateSurface(_THIS, createInfo.flags = 0; createInfo.pView = (const void *)metalview; result = vkCreateMacOSSurfaceMVK(instance, &createInfo, - NULL, surface); + NULL, surface); if (result != VK_SUCCESS) { Cocoa_Metal_DestroyView(_this, metalview); SDL_SetError("vkCreateMacOSSurfaceMVK failed: %s", diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h index 18f7d8587..bf7c4409e 100644 --- a/src/video/cocoa/SDL_cocoawindow.h +++ b/src/video/cocoa/SDL_cocoawindow.h @@ -39,7 +39,8 @@ typedef enum PENDING_OPERATION_MINIMIZE } PendingWindowOperation; -@interface Cocoa_WindowListener : NSResponder { +@interface Cocoa_WindowListener : NSResponder +{ /* SDL_WindowData owns this Listener and has a strong reference to it. * To avoid reference cycles, we could have either a weak or an * unretained ref to the WindowData. */ @@ -56,64 +57,64 @@ typedef enum BOOL isDragAreaRunning; } --(BOOL) isTouchFromTrackpad:(NSEvent *)theEvent; --(void) listen:(SDL_WindowData *) data; --(void) pauseVisibleObservation; --(void) resumeVisibleObservation; --(BOOL) setFullscreenSpace:(BOOL) state; --(BOOL) isInFullscreenSpace; --(BOOL) isInFullscreenSpaceTransition; --(void) addPendingWindowOperation:(PendingWindowOperation) operation; --(void) close; +- (BOOL)isTouchFromTrackpad:(NSEvent *)theEvent; +- (void)listen:(SDL_WindowData *)data; +- (void)pauseVisibleObservation; +- (void)resumeVisibleObservation; +- (BOOL)setFullscreenSpace:(BOOL)state; +- (BOOL)isInFullscreenSpace; +- (BOOL)isInFullscreenSpaceTransition; +- (void)addPendingWindowOperation:(PendingWindowOperation)operation; +- (void)close; --(BOOL) isMoving; --(BOOL) isMovingOrFocusClickPending; --(void) setFocusClickPending:(NSInteger) button; --(void) clearFocusClickPending:(NSInteger) button; --(void) setPendingMoveX:(int)x Y:(int)y; --(void) windowDidFinishMoving; --(void) onMovingOrFocusClickPendingStateCleared; +- (BOOL)isMoving; +- (BOOL)isMovingOrFocusClickPending; +- (void)setFocusClickPending:(NSInteger)button; +- (void)clearFocusClickPending:(NSInteger)button; +- (void)setPendingMoveX:(int)x Y:(int)y; +- (void)windowDidFinishMoving; +- (void)onMovingOrFocusClickPendingStateCleared; /* Window delegate functionality */ --(BOOL) windowShouldClose:(id) sender; --(void) windowDidExpose:(NSNotification *) aNotification; --(void) windowDidMove:(NSNotification *) aNotification; --(void) windowDidResize:(NSNotification *) aNotification; --(void) windowDidMiniaturize:(NSNotification *) aNotification; --(void) windowDidDeminiaturize:(NSNotification *) aNotification; --(void) windowDidBecomeKey:(NSNotification *) aNotification; --(void) windowDidResignKey:(NSNotification *) aNotification; --(void) windowDidChangeBackingProperties:(NSNotification *) aNotification; --(void) windowDidChangeScreenProfile:(NSNotification *) aNotification; --(void) windowDidChangeScreen:(NSNotification *) aNotification; --(void) windowWillEnterFullScreen:(NSNotification *) aNotification; --(void) windowDidEnterFullScreen:(NSNotification *) aNotification; --(void) windowWillExitFullScreen:(NSNotification *) aNotification; --(void) windowDidExitFullScreen:(NSNotification *) aNotification; --(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions; +- (BOOL)windowShouldClose:(id)sender; +- (void)windowDidExpose:(NSNotification *)aNotification; +- (void)windowDidMove:(NSNotification *)aNotification; +- (void)windowDidResize:(NSNotification *)aNotification; +- (void)windowDidMiniaturize:(NSNotification *)aNotification; +- (void)windowDidDeminiaturize:(NSNotification *)aNotification; +- (void)windowDidBecomeKey:(NSNotification *)aNotification; +- (void)windowDidResignKey:(NSNotification *)aNotification; +- (void)windowDidChangeBackingProperties:(NSNotification *)aNotification; +- (void)windowDidChangeScreenProfile:(NSNotification *)aNotification; +- (void)windowDidChangeScreen:(NSNotification *)aNotification; +- (void)windowWillEnterFullScreen:(NSNotification *)aNotification; +- (void)windowDidEnterFullScreen:(NSNotification *)aNotification; +- (void)windowWillExitFullScreen:(NSNotification *)aNotification; +- (void)windowDidExitFullScreen:(NSNotification *)aNotification; +- (NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions; /* See if event is in a drag area, toggle on window dragging. */ --(BOOL) processHitTest:(NSEvent *)theEvent; +- (BOOL)processHitTest:(NSEvent *)theEvent; /* Window event handling */ --(void) mouseDown:(NSEvent *) theEvent; --(void) rightMouseDown:(NSEvent *) theEvent; --(void) otherMouseDown:(NSEvent *) theEvent; --(void) mouseUp:(NSEvent *) theEvent; --(void) rightMouseUp:(NSEvent *) theEvent; --(void) otherMouseUp:(NSEvent *) theEvent; --(void) mouseMoved:(NSEvent *) theEvent; --(void) mouseDragged:(NSEvent *) theEvent; --(void) rightMouseDragged:(NSEvent *) theEvent; --(void) otherMouseDragged:(NSEvent *) theEvent; --(void) scrollWheel:(NSEvent *) theEvent; --(void) touchesBeganWithEvent:(NSEvent *) theEvent; --(void) touchesMovedWithEvent:(NSEvent *) theEvent; --(void) touchesEndedWithEvent:(NSEvent *) theEvent; --(void) touchesCancelledWithEvent:(NSEvent *) theEvent; +- (void)mouseDown:(NSEvent *)theEvent; +- (void)rightMouseDown:(NSEvent *)theEvent; +- (void)otherMouseDown:(NSEvent *)theEvent; +- (void)mouseUp:(NSEvent *)theEvent; +- (void)rightMouseUp:(NSEvent *)theEvent; +- (void)otherMouseUp:(NSEvent *)theEvent; +- (void)mouseMoved:(NSEvent *)theEvent; +- (void)mouseDragged:(NSEvent *)theEvent; +- (void)rightMouseDragged:(NSEvent *)theEvent; +- (void)otherMouseDragged:(NSEvent *)theEvent; +- (void)scrollWheel:(NSEvent *)theEvent; +- (void)touchesBeganWithEvent:(NSEvent *)theEvent; +- (void)touchesMovedWithEvent:(NSEvent *)theEvent; +- (void)touchesEndedWithEvent:(NSEvent *)theEvent; +- (void)touchesCancelledWithEvent:(NSEvent *)theEvent; /* Touch event handling */ --(void) handleTouches:(NSTouchPhase) phase withEvent:(NSEvent*) theEvent; +- (void)handleTouches:(NSTouchPhase)phase withEvent:(NSEvent *)theEvent; @end /* *INDENT-ON* */ @@ -122,23 +123,23 @@ typedef enum @class SDL_VideoData; @interface SDL_WindowData : NSObject - @property (nonatomic) SDL_Window *window; - @property (nonatomic) NSWindow *nswindow; - @property (nonatomic) NSView *sdlContentView; - @property (nonatomic) NSMutableArray *nscontexts; - @property (nonatomic) SDL_bool created; - @property (nonatomic) SDL_bool inWindowFullscreenTransition; - @property (nonatomic) NSInteger window_number; - @property (nonatomic) NSInteger flash_request; - @property (nonatomic) Cocoa_WindowListener *listener; - @property (nonatomic) SDL_VideoData *videodata; +@property(nonatomic) SDL_Window *window; +@property(nonatomic) NSWindow *nswindow; +@property(nonatomic) NSView *sdlContentView; +@property(nonatomic) NSMutableArray *nscontexts; +@property(nonatomic) SDL_bool created; +@property(nonatomic) SDL_bool inWindowFullscreenTransition; +@property(nonatomic) NSInteger window_number; +@property(nonatomic) NSInteger flash_request; +@property(nonatomic) Cocoa_WindowListener *listener; +@property(nonatomic) SDL_VideoData *videodata; #if SDL_VIDEO_OPENGL_EGL - @property (nonatomic) EGLSurface egl_surface; +@property(nonatomic) EGLSurface egl_surface; #endif @end -extern int Cocoa_CreateWindow(_THIS, SDL_Window * window); -extern int Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, +extern int Cocoa_CreateWindow(_THIS, SDL_Window *window); +extern int Cocoa_CreateWindowFrom(_THIS, SDL_Window *window, const void *data); extern void Cocoa_SetWindowTitle(_THIS, SDL_Window * window); extern void Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon); @@ -167,8 +168,8 @@ extern void Cocoa_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbe extern void Cocoa_DestroyWindow(_THIS, SDL_Window * window); extern SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info); extern int Cocoa_SetWindowHitTest(SDL_Window *window, SDL_bool enabled); -extern void Cocoa_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept); -extern int Cocoa_FlashWindow(_THIS, SDL_Window * window, SDL_FlashOperation operation); +extern void Cocoa_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept); +extern int Cocoa_FlashWindow(_THIS, SDL_Window *window, SDL_FlashOperation operation); #endif /* SDL_cocoawindow_h_ */ diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index c73827656..785ad6ef5 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -46,20 +46,21 @@ #ifdef DEBUG_COCOAWINDOW #define DLog(fmt, ...) printf("%s: " fmt "\n", __func__, ##__VA_ARGS__) #else -#define DLog(...) do { } while (0) +#define DLog(...) \ + do { \ + } while (0) #endif - #define FULLSCREEN_MASK (SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN) #ifndef MAC_OS_X_VERSION_10_12 #define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask #endif #ifndef NSAppKitVersionNumber10_13_2 -#define NSAppKitVersionNumber10_13_2 1561.2 +#define NSAppKitVersionNumber10_13_2 1561.2 #endif #ifndef NSAppKitVersionNumber10_14 -#define NSAppKitVersionNumber10_14 1671 +#define NSAppKitVersionNumber10_14 1671 #endif @implementation SDL_WindowData @@ -68,11 +69,11 @@ @interface NSWindow (SDL) #if MAC_OS_X_VERSION_MAX_ALLOWED < 101000 /* Added in the 10.10 SDK */ -@property (readonly) NSRect contentLayoutRect; +@property(readonly) NSRect contentLayoutRect; #endif /* This is available as of 10.13.2, but isn't in public headers */ -@property (nonatomic) NSRect mouseConfinementRect; +@property(nonatomic) NSRect mouseConfinementRect; @end @interface SDLWindow : NSWindow @@ -83,12 +84,12 @@ - (void)doCommandBySelector:(SEL)aSelector; /* Handle drag-and-drop of files onto the SDL window. */ -- (NSDragOperation)draggingEntered:(id )sender; -- (BOOL)performDragOperation:(id )sender; +- (NSDragOperation)draggingEntered:(id)sender; +- (BOOL)performDragOperation:(id)sender; - (BOOL)wantsPeriodicDraggingUpdates; - (BOOL)validateMenuItem:(NSMenuItem *)menuItem; -- (SDL_Window*)findSDLWindow; +- (SDL_Window *)findSDLWindow; @end @implementation SDLWindow @@ -102,7 +103,7 @@ SDL_Window *window = [self findSDLWindow]; if (window == NULL) { return NO; - } else if ((window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_FULLSCREEN_DESKTOP)) != 0) { + } else if ((window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP)) != 0) { return NO; } else if ((window->flags & SDL_WINDOW_RESIZABLE) == 0) { return NO; @@ -148,7 +149,7 @@ /*NSLog(@"doCommandBySelector: %@\n", NSStringFromSelector(aSelector));*/ } -- (NSDragOperation)draggingEntered:(id )sender +- (NSDragOperation)draggingEntered:(id)sender { if (([sender draggingSourceOperationMask] & NSDragOperationGeneric) == NSDragOperationGeneric) { return NSDragOperationGeneric; @@ -157,79 +158,80 @@ return NSDragOperationNone; /* no idea what to do with this, reject it. */ } -- (BOOL)performDragOperation:(id )sender -{ @autoreleasepool +- (BOOL)performDragOperation:(id)sender { - NSPasteboard *pasteboard = [sender draggingPasteboard]; - NSArray *types = [NSArray arrayWithObject:NSFilenamesPboardType]; - NSString *desiredType = [pasteboard availableTypeFromArray:types]; - SDL_Window *sdlwindow = [self findSDLWindow]; - NSData *data; - NSArray *array; - NSPoint point; - SDL_Mouse *mouse; - int x, y; + @autoreleasepool { + NSPasteboard *pasteboard = [sender draggingPasteboard]; + NSArray *types = [NSArray arrayWithObject:NSFilenamesPboardType]; + NSString *desiredType = [pasteboard availableTypeFromArray:types]; + SDL_Window *sdlwindow = [self findSDLWindow]; + NSData *data; + NSArray *array; + NSPoint point; + SDL_Mouse *mouse; + int x, y; - if (desiredType == nil) { - return NO; /* can't accept anything that's being dropped here. */ - } + if (desiredType == nil) { + return NO; /* can't accept anything that's being dropped here. */ + } - data = [pasteboard dataForType:desiredType]; - if (data == nil) { - return NO; - } + data = [pasteboard dataForType:desiredType]; + if (data == nil) { + return NO; + } - SDL_assert([desiredType isEqualToString:NSFilenamesPboardType]); - array = [pasteboard propertyListForType:@"NSFilenamesPboardType"]; + SDL_assert([desiredType isEqualToString:NSFilenamesPboardType]); + array = [pasteboard propertyListForType:@"NSFilenamesPboardType"]; - /* Code addon to update the mouse location */ - point = [sender draggingLocation]; - mouse = SDL_GetMouse(); - x = (int)point.x; - y = (int)(sdlwindow->h - point.y); - if (x >= 0 && x < sdlwindow->w && y >= 0 && y < sdlwindow->h) { - SDL_SendMouseMotion(sdlwindow, mouse->mouseID, 0, x, y); - } - /* Code addon to update the mouse location */ + /* Code addon to update the mouse location */ + point = [sender draggingLocation]; + mouse = SDL_GetMouse(); + x = (int)point.x; + y = (int)(sdlwindow->h - point.y); + if (x >= 0 && x < sdlwindow->w && y >= 0 && y < sdlwindow->h) { + SDL_SendMouseMotion(sdlwindow, mouse->mouseID, 0, x, y); + } + /* Code addon to update the mouse location */ - for (NSString *path in array) { - NSURL *fileURL = [NSURL fileURLWithPath:path]; - NSNumber *isAlias = nil; + for (NSString *path in array) { + NSURL *fileURL = [NSURL fileURLWithPath:path]; + NSNumber *isAlias = nil; - [fileURL getResourceValue:&isAlias forKey:NSURLIsAliasFileKey error:nil]; + [fileURL getResourceValue:&isAlias forKey:NSURLIsAliasFileKey error:nil]; - /* If the URL is an alias, resolve it. */ - if ([isAlias boolValue]) { - NSURLBookmarkResolutionOptions opts = NSURLBookmarkResolutionWithoutMounting | NSURLBookmarkResolutionWithoutUI; - NSData *bookmark = [NSURL bookmarkDataWithContentsOfURL:fileURL error:nil]; - if (bookmark != nil) { - NSURL *resolvedURL = [NSURL URLByResolvingBookmarkData:bookmark - options:opts - relativeToURL:nil - bookmarkDataIsStale:nil - error:nil]; + /* If the URL is an alias, resolve it. */ + if ([isAlias boolValue]) { + NSURLBookmarkResolutionOptions opts = NSURLBookmarkResolutionWithoutMounting | NSURLBookmarkResolutionWithoutUI; + NSData *bookmark = [NSURL bookmarkDataWithContentsOfURL:fileURL error:nil]; + if (bookmark != nil) { + NSURL *resolvedURL = [NSURL URLByResolvingBookmarkData:bookmark + options:opts + relativeToURL:nil + bookmarkDataIsStale:nil + error:nil]; - if (resolvedURL != nil) { - fileURL = resolvedURL; + if (resolvedURL != nil) { + fileURL = resolvedURL; + } } } + + if (!SDL_SendDropFile(sdlwindow, [[fileURL path] UTF8String])) { + return NO; + } } - if (!SDL_SendDropFile(sdlwindow, [[fileURL path] UTF8String])) { - return NO; - } + SDL_SendDropComplete(sdlwindow); + return YES; } - - SDL_SendDropComplete(sdlwindow); - return YES; -}} +} - (BOOL)wantsPeriodicDraggingUpdates { return NO; } -- (SDL_Window*)findSDLWindow +- (SDL_Window *)findSDLWindow { SDL_Window *sdlwindow = NULL; SDL_VideoDevice *_this = SDL_GetVideoDevice(); @@ -237,7 +239,7 @@ /* !!! FIXME: is there a better way to do this? */ if (_this) { for (sdlwindow = _this->windows; sdlwindow; sdlwindow = sdlwindow->next) { - NSWindow *nswindow = ((__bridge SDL_WindowData *) sdlwindow->driverdata).nswindow; + NSWindow *nswindow = ((__bridge SDL_WindowData *)sdlwindow->driverdata).nswindow; if (nswindow == self) { break; } @@ -249,7 +251,6 @@ @end - static Uint32 s_moveHack; static void ConvertNSRect(NSScreen *screen, BOOL fullscreen, NSRect *r) @@ -257,16 +258,15 @@ static void ConvertNSRect(NSScreen *screen, BOOL fullscreen, NSRect *r) r->origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - r->origin.y - r->size.height; } -static void -ScheduleContextUpdates(SDL_WindowData *data) +static void ScheduleContextUpdates(SDL_WindowData *data) { - /* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */ - #if SDL_VIDEO_OPENGL +/* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */ +#if SDL_VIDEO_OPENGL - #ifdef __clang__ - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wdeprecated-declarations" - #endif +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif NSOpenGLContext *currentContext; NSMutableArray *contexts; @@ -276,7 +276,7 @@ ScheduleContextUpdates(SDL_WindowData *data) currentContext = [NSOpenGLContext currentContext]; contexts = data.nscontexts; - @synchronized (contexts) { + @synchronized(contexts) { for (SDLOpenGLContext *context in contexts) { if (context == currentContext) { [context update]; @@ -286,22 +286,20 @@ ScheduleContextUpdates(SDL_WindowData *data) } } - #ifdef __clang__ - #pragma clang diagnostic pop - #endif +#ifdef __clang__ +#pragma clang diagnostic pop +#endif - #endif /* SDL_VIDEO_OPENGL */ +#endif /* SDL_VIDEO_OPENGL */ } /* !!! FIXME: this should use a hint callback. */ -static int -GetHintCtrlClickEmulateRightClick() +static int GetHintCtrlClickEmulateRightClick() { return SDL_GetHintBoolean(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, SDL_FALSE); } -static NSUInteger -GetWindowWindowedStyle(SDL_Window * window) +static NSUInteger GetWindowWindowedStyle(SDL_Window *window) { /* IF YOU CHANGE ANY FLAGS IN HERE, PLEASE READ the NSWindowStyleMaskBorderless comments in SetupWindowData()! */ @@ -313,7 +311,7 @@ GetWindowWindowedStyle(SDL_Window * window) if (window->flags & SDL_WINDOW_BORDERLESS) { style |= NSWindowStyleMaskBorderless; } else { - style |= (NSWindowStyleMaskTitled|NSWindowStyleMaskClosable); + style |= (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable); } if (window->flags & SDL_WINDOW_RESIZABLE) { style |= NSWindowStyleMaskResizable; @@ -321,8 +319,7 @@ GetWindowWindowedStyle(SDL_Window * window) return style; } -static NSUInteger -GetWindowStyle(SDL_Window * window) +static NSUInteger GetWindowStyle(SDL_Window *window) { NSUInteger style = 0; @@ -334,10 +331,9 @@ GetWindowStyle(SDL_Window * window) return style; } -static SDL_bool -SetWindowStyle(SDL_Window * window, NSUInteger style) +static SDL_bool SetWindowStyle(SDL_Window *window, NSUInteger style) { - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; NSWindow *nswindow = data.nswindow; /* The view responder chain gets messed with during setStyleMask */ @@ -355,10 +351,9 @@ SetWindowStyle(SDL_Window * window, NSUInteger style) return SDL_TRUE; } -static SDL_bool -ShouldAdjustCoordinatesForGrab(SDL_Window * window) +static SDL_bool ShouldAdjustCoordinatesForGrab(SDL_Window *window) { - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; if (!data || [data.listener isMovingOrFocusClickPending]) { return SDL_FALSE; @@ -374,8 +369,7 @@ ShouldAdjustCoordinatesForGrab(SDL_Window * window) return SDL_FALSE; } -static SDL_bool -AdjustCoordinatesForGrab(SDL_Window * window, int x, int y, CGPoint *adjusted) +static SDL_bool AdjustCoordinatesForGrab(SDL_Window *window, int x, int y, CGPoint *adjusted) { if (window->mouse_rect.w > 0 && window->mouse_rect.h > 0) { SDL_Rect window_rect; @@ -414,10 +408,9 @@ AdjustCoordinatesForGrab(SDL_Window * window, int x, int y, CGPoint *adjusted) return SDL_FALSE; } -static void -Cocoa_UpdateClipCursor(SDL_Window * window) +static void Cocoa_UpdateClipCursor(SDL_Window *window) { - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_13_2) { NSWindow *nswindow = data.nswindow; @@ -468,7 +461,6 @@ Cocoa_UpdateClipCursor(SDL_Window * window) } } - @implementation Cocoa_WindowListener - (void)listen:(SDL_WindowData *)data @@ -547,13 +539,13 @@ Cocoa_UpdateClipCursor(SDL_Window * window) } } --(void) pauseVisibleObservation +- (void)pauseVisibleObservation { observingVisible = NO; wasVisible = [_data.nswindow isVisible]; } --(void) resumeVisibleObservation +- (void)resumeVisibleObservation { BOOL isVisible = [_data.nswindow isVisible]; observingVisible = YES; @@ -568,20 +560,20 @@ Cocoa_UpdateClipCursor(SDL_Window * window) } } --(BOOL) setFullscreenSpace:(BOOL) state +- (BOOL)setFullscreenSpace:(BOOL)state { SDL_Window *window = _data.window; NSWindow *nswindow = _data.nswindow; - SDL_VideoData *videodata = ((__bridge SDL_WindowData *) window->driverdata).videodata; + SDL_VideoData *videodata = ((__bridge SDL_WindowData *)window->driverdata).videodata; if (!videodata.allow_spaces) { - return NO; /* Spaces are forcibly disabled. */ + return NO; /* Spaces are forcibly disabled. */ } else if (state && ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP)) { - return NO; /* we only allow you to make a Space on FULLSCREEN_DESKTOP windows. */ + return NO; /* we only allow you to make a Space on FULLSCREEN_DESKTOP windows. */ } else if (!state && ((window->last_fullscreen_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP)) { - return NO; /* we only handle leaving the Space on windows that were previously FULLSCREEN_DESKTOP. */ + return NO; /* we only handle leaving the Space on windows that were previously FULLSCREEN_DESKTOP. */ } else if (state == isFullscreenSpace) { - return YES; /* already there. */ + return YES; /* already there. */ } if (inFullscreenTransition) { @@ -596,21 +588,21 @@ Cocoa_UpdateClipCursor(SDL_Window * window) /* you need to be FullScreenPrimary, or toggleFullScreen doesn't work. Unset it again in windowDidExitFullScreen. */ [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; - [nswindow performSelectorOnMainThread: @selector(toggleFullScreen:) withObject:nswindow waitUntilDone:NO]; + [nswindow performSelectorOnMainThread:@selector(toggleFullScreen:) withObject:nswindow waitUntilDone:NO]; return YES; } --(BOOL) isInFullscreenSpace +- (BOOL)isInFullscreenSpace { return isFullscreenSpace; } --(BOOL) isInFullscreenSpaceTransition +- (BOOL)isInFullscreenSpaceTransition { return inFullscreenTransition; } --(void) addPendingWindowOperation:(PendingWindowOperation) operation +- (void)addPendingWindowOperation:(PendingWindowOperation)operation { pendingWindowOperation = operation; } @@ -664,12 +656,12 @@ Cocoa_UpdateClipCursor(SDL_Window * window) return isMoving || (focusClickPending != 0); } --(void) setFocusClickPending:(NSInteger) button +- (void)setFocusClickPending:(NSInteger)button { focusClickPending |= (1 << button); } --(void) clearFocusClickPending:(NSInteger) button +- (void)clearFocusClickPending:(NSInteger)button { if ((focusClickPending & (1 << button)) != 0) { focusClickPending &= ~(1 << button); @@ -679,7 +671,7 @@ Cocoa_UpdateClipCursor(SDL_Window * window) } } --(void) setPendingMoveX:(int)x Y:(int)y +- (void)setPendingMoveX:(int)x Y:(int)y { pendingWindowWarpX = x; pendingWindowWarpY = y; @@ -936,7 +928,7 @@ Cocoa_UpdateClipCursor(SDL_Window * window) { SDL_Window *window = _data.window; - SetWindowStyle(window, (NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskResizable)); + SetWindowStyle(window, (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable)); isFullscreenSpace = YES; inFullscreenTransition = YES; @@ -954,7 +946,7 @@ Cocoa_UpdateClipCursor(SDL_Window * window) isFullscreenSpace = NO; inFullscreenTransition = NO; - + [self windowDidExitFullScreen:nil]; } @@ -1004,16 +996,16 @@ Cocoa_UpdateClipCursor(SDL_Window * window) - (void)windowDidFailToExitFullScreen:(NSNotification *)aNotification { SDL_Window *window = _data.window; - + if (window->is_destroying) { return; } - SetWindowStyle(window, (NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskResizable)); - + SetWindowStyle(window, (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable)); + isFullscreenSpace = YES; inFullscreenTransition = NO; - + [self windowDidEnterFullScreen:nil]; } @@ -1111,7 +1103,7 @@ Cocoa_UpdateClipCursor(SDL_Window * window) } } --(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions +- (NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions { if ((_data.window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) { return NSApplicationPresentationFullScreen | NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar; @@ -1165,33 +1157,32 @@ Cocoa_UpdateClipCursor(SDL_Window * window) { SDL_assert(isDragAreaRunning == [_data.nswindow isMovableByWindowBackground]); - if (_data.window->hit_test) { /* if no hit-test, skip this. */ + if (_data.window->hit_test) { /* if no hit-test, skip this. */ const NSPoint location = [theEvent locationInWindow]; - const SDL_Point point = { (int) location.x, _data.window->h - (((int) location.y)-1) }; + const SDL_Point point = { (int)location.x, _data.window->h - (((int)location.y) - 1) }; const SDL_HitTestResult rc = _data.window->hit_test(_data.window, &point, _data.window->hit_test_data); if (rc == SDL_HITTEST_DRAGGABLE) { if (!isDragAreaRunning) { isDragAreaRunning = YES; [_data.nswindow setMovableByWindowBackground:YES]; } - return YES; /* dragging! */ + return YES; /* dragging! */ } } if (isDragAreaRunning) { isDragAreaRunning = NO; [_data.nswindow setMovableByWindowBackground:NO]; - return YES; /* was dragging, drop event. */ + return YES; /* was dragging, drop event. */ } - return NO; /* not a special area, carry on. */ + return NO; /* not a special area, carry on. */ } -static int -Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL_Window * window, const Uint8 state, const Uint8 button) +static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_Window *window, const Uint8 state, const Uint8 button) { const SDL_MouseID mouseID = mouse->mouseID; - const int clicks = (int) [theEvent clickCount]; + const int clicks = (int)[theEvent clickCount]; SDL_Window *focus = SDL_GetKeyboardFocus(); int rc; @@ -1200,14 +1191,14 @@ Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL_Window * w // the position in the currently-focused window. We don't (currently) send a mousemove // event for the background window, this just makes sure the button is reported at the // correct position in its own event. - if ( focus && ([theEvent window] == ((__bridge SDL_WindowData *) focus->driverdata).nswindow) ) { + if (focus && ([theEvent window] == ((__bridge SDL_WindowData *)focus->driverdata).nswindow)) { rc = SDL_SendMouseButtonClicks(window, mouseID, state, button, clicks); } else { const int orig_x = mouse->x; const int orig_y = mouse->y; const NSPoint point = [theEvent locationInWindow]; - mouse->x = (int) point.x; - mouse->y = (int) (window->h - point.y); + mouse->x = (int)point.x; + mouse->y = (int)(window->h - point.y); rc = SDL_SendMouseButtonClicks(window, mouseID, state, button, clicks); mouse->x = orig_x; mouse->y = orig_y; @@ -1235,7 +1226,7 @@ Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL_Window * w if ([self processHitTest:theEvent]) { SDL_SendWindowEvent(_data.window, SDL_WINDOWEVENT_HIT_TEST, 0, 0); - return; /* dragging, drop event. */ + return; /* dragging, drop event. */ } switch ([theEvent buttonNumber]) { @@ -1256,7 +1247,7 @@ Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL_Window * w button = SDL_BUTTON_MIDDLE; break; default: - button = (int) [theEvent buttonNumber] + 1; + button = (int)[theEvent buttonNumber] + 1; break; } @@ -1284,7 +1275,7 @@ Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL_Window * w if ([self processHitTest:theEvent]) { SDL_SendWindowEvent(_data.window, SDL_WINDOWEVENT_HIT_TEST, 0, 0); - return; /* stopped dragging, drop event. */ + return; /* stopped dragging, drop event. */ } switch ([theEvent buttonNumber]) { @@ -1303,7 +1294,7 @@ Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL_Window * w button = SDL_BUTTON_MIDDLE; break; default: - button = (int) [theEvent buttonNumber] + 1; + button = (int)[theEvent buttonNumber] + 1; break; } @@ -1337,7 +1328,7 @@ Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL_Window * w if ([self processHitTest:theEvent]) { SDL_SendWindowEvent(window, SDL_WINDOWEVENT_HIT_TEST, 0, 0); - return; /* dragging, drop event. */ + return; /* dragging, drop event. */ } if (mouse->relative_mode) { @@ -1383,11 +1374,10 @@ Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL_Window * w Cocoa_HandleMouseWheel(_data.window, theEvent); } - - (BOOL)isTouchFromTrackpad:(NSEvent *)theEvent { SDL_Window *window = _data.window; - SDL_VideoData *videodata = ((__bridge SDL_WindowData *) window->driverdata).videodata; + SDL_VideoData *videodata = ((__bridge SDL_WindowData *)window->driverdata).videodata; /* if this a MacBook trackpad, we'll make input look like a synthesized event. This is backwards from reality, but better matches user @@ -1410,7 +1400,7 @@ Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL_Window * w return istrackpad; } -- (void)touchesBeganWithEvent:(NSEvent *) theEvent +- (void)touchesBeganWithEvent:(NSEvent *)theEvent { NSSet *touches; SDL_TouchID touchID; @@ -1421,7 +1411,7 @@ Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL_Window * w touchID = istrackpad ? SDL_MOUSE_TOUCHID : (SDL_TouchID)(intptr_t)[[touches anyObject] device]; existingTouchCount = 0; - for (NSTouch* touch in touches) { + for (NSTouch *touch in touches) { if ([touch phase] != NSTouchPhaseBegan) { existingTouchCount++; } @@ -1430,7 +1420,7 @@ Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL_Window * w int numFingers = SDL_GetNumTouchFingers(touchID); DLog("Reset Lost Fingers: %d", numFingers); for (--numFingers; numFingers >= 0; --numFingers) { - SDL_Finger* finger = SDL_GetTouchFinger(touchID, numFingers); + SDL_Finger *finger = SDL_GetTouchFinger(touchID, numFingers); /* trackpad touches have no window. If we really wanted one we could * use the window that has mouse or keyboard focus. * Sending a null window currently also prevents synthetic mouse @@ -1445,22 +1435,22 @@ Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL_Window * w [self handleTouches:NSTouchPhaseBegan withEvent:theEvent]; } -- (void)touchesMovedWithEvent:(NSEvent *) theEvent +- (void)touchesMovedWithEvent:(NSEvent *)theEvent { [self handleTouches:NSTouchPhaseMoved withEvent:theEvent]; } -- (void)touchesEndedWithEvent:(NSEvent *) theEvent +- (void)touchesEndedWithEvent:(NSEvent *)theEvent { [self handleTouches:NSTouchPhaseEnded withEvent:theEvent]; } -- (void)touchesCancelledWithEvent:(NSEvent *) theEvent +- (void)touchesCancelledWithEvent:(NSEvent *)theEvent { [self handleTouches:NSTouchPhaseCancelled withEvent:theEvent]; } -- (void)handleTouches:(NSTouchPhase) phase withEvent:(NSEvent *) theEvent +- (void)handleTouches:(NSTouchPhase)phase withEvent:(NSEvent *)theEvent { NSSet *touches = [theEvent touchesMatchingPhase:phase inView:nil]; const BOOL istrackpad = [self isTouchFromTrackpad:theEvent]; @@ -1522,11 +1512,12 @@ Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL_Window * w @end -@interface SDLView : NSView { +@interface SDLView : NSView +{ SDL_Window *_sdlWindow; } -- (void)setSDLWindow:(SDL_Window*)window; +- (void)setSDLWindow:(SDL_Window *)window; /* The default implementation doesn't pass rightMouseDown to responder chain */ - (void)rightMouseDown:(NSEvent *)theEvent; @@ -1539,7 +1530,7 @@ Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL_Window * w @implementation SDLView -- (void)setSDLWindow:(SDL_Window*)window +- (void)setSDLWindow:(SDL_Window *)window { _sdlWindow = window; } @@ -1575,7 +1566,7 @@ Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL_Window * w white until the app is ready to draw. In practice on modern macOS, this only gets called for window creation and other extraordinary events. */ self.layer.backgroundColor = CGColorGetConstantColor(kCGColorBlack); - ScheduleContextUpdates((__bridge SDL_WindowData *) _sdlWindow->driverdata); + ScheduleContextUpdates((__bridge SDL_WindowData *)_sdlWindow->driverdata); SDL_SendWindowEvent(_sdlWindow, SDL_WINDOWEVENT_EXPOSED, 0, 0); } @@ -1617,182 +1608,181 @@ Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL_Window * w } @end -static int -SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, NSView *nsview, SDL_bool created) -{ @autoreleasepool +static int SetupWindowData(_THIS, SDL_Window *window, NSWindow *nswindow, NSView *nsview, SDL_bool created) { - SDL_VideoData *videodata = (__bridge SDL_VideoData *) _this->driverdata; - SDL_WindowData *data; + @autoreleasepool { + SDL_VideoData *videodata = (__bridge SDL_VideoData *)_this->driverdata; + SDL_WindowData *data; - /* Allocate the window data */ - data = [[SDL_WindowData alloc] init]; - if (!data) { - return SDL_OutOfMemory(); - } - data.window = window; - data.nswindow = nswindow; - data.created = created; - data.videodata = videodata; - data.window_number = nswindow.windowNumber; - data.nscontexts = [[NSMutableArray alloc] init]; - data.sdlContentView = nsview; - - /* Create an event listener for the window */ - data.listener = [[Cocoa_WindowListener alloc] init]; - - /* Fill in the SDL window with the window data */ - { - NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]]; - ConvertNSRect([nswindow screen], (window->flags & FULLSCREEN_MASK), &rect); - window->x = (int)rect.origin.x; - window->y = (int)rect.origin.y; - window->w = (int)rect.size.width; - window->h = (int)rect.size.height; - } - - /* Set up the listener after we create the view */ - [data.listener listen:data]; - - if ([nswindow isVisible]) { - window->flags |= SDL_WINDOW_SHOWN; - } else { - window->flags &= ~SDL_WINDOW_SHOWN; - } - - { - unsigned long style = [nswindow styleMask]; - - /* NSWindowStyleMaskBorderless is zero, and it's possible to be - Resizeable _and_ borderless, so we can't do a simple bitwise AND - of NSWindowStyleMaskBorderless here. */ - if ((style & ~(NSWindowStyleMaskResizable|NSWindowStyleMaskMiniaturizable)) == NSWindowStyleMaskBorderless) { - window->flags |= SDL_WINDOW_BORDERLESS; - } else { - window->flags &= ~SDL_WINDOW_BORDERLESS; + /* Allocate the window data */ + data = [[SDL_WindowData alloc] init]; + if (!data) { + return SDL_OutOfMemory(); } - if (style & NSWindowStyleMaskResizable) { - window->flags |= SDL_WINDOW_RESIZABLE; - } else { - window->flags &= ~SDL_WINDOW_RESIZABLE; + data.window = window; + data.nswindow = nswindow; + data.created = created; + data.videodata = videodata; + data.window_number = nswindow.windowNumber; + data.nscontexts = [[NSMutableArray alloc] init]; + data.sdlContentView = nsview; + + /* Create an event listener for the window */ + data.listener = [[Cocoa_WindowListener alloc] init]; + + /* Fill in the SDL window with the window data */ + { + NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]]; + ConvertNSRect([nswindow screen], (window->flags & FULLSCREEN_MASK), &rect); + window->x = (int)rect.origin.x; + window->y = (int)rect.origin.y; + window->w = (int)rect.size.width; + window->h = (int)rect.size.height; } + + /* Set up the listener after we create the view */ + [data.listener listen:data]; + + if ([nswindow isVisible]) { + window->flags |= SDL_WINDOW_SHOWN; + } else { + window->flags &= ~SDL_WINDOW_SHOWN; + } + + { + unsigned long style = [nswindow styleMask]; + + /* NSWindowStyleMaskBorderless is zero, and it's possible to be + Resizeable _and_ borderless, so we can't do a simple bitwise AND + of NSWindowStyleMaskBorderless here. */ + if ((style & ~(NSWindowStyleMaskResizable | NSWindowStyleMaskMiniaturizable)) == NSWindowStyleMaskBorderless) { + window->flags |= SDL_WINDOW_BORDERLESS; + } else { + window->flags &= ~SDL_WINDOW_BORDERLESS; + } + if (style & NSWindowStyleMaskResizable) { + window->flags |= SDL_WINDOW_RESIZABLE; + } else { + window->flags &= ~SDL_WINDOW_RESIZABLE; + } + } + + /* isZoomed always returns true if the window is not resizable */ + if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) { + window->flags |= SDL_WINDOW_MAXIMIZED; + } else { + window->flags &= ~SDL_WINDOW_MAXIMIZED; + } + + if ([nswindow isMiniaturized]) { + window->flags |= SDL_WINDOW_MINIMIZED; + } else { + window->flags &= ~SDL_WINDOW_MINIMIZED; + } + + if ([nswindow isKeyWindow]) { + window->flags |= SDL_WINDOW_INPUT_FOCUS; + SDL_SetKeyboardFocus(data.window); + } + + /* SDL_WindowData will be holding a strong reference to the NSWindow, and + * it will also call [NSWindow close] in DestroyWindow before releasing the + * NSWindow, so the extra release provided by releasedWhenClosed isn't + * necessary. */ + nswindow.releasedWhenClosed = NO; + + /* Prevents the window's "window device" from being destroyed when it is + * hidden. See http://www.mikeash.com/pyblog/nsopenglcontext-and-one-shot.html + */ + [nswindow setOneShot:NO]; + + /* All done! */ + window->driverdata = (void *)CFBridgingRetain(data); + return 0; } +} - /* isZoomed always returns true if the window is not resizable */ - if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) { - window->flags |= SDL_WINDOW_MAXIMIZED; - } else { - window->flags &= ~SDL_WINDOW_MAXIMIZED; - } - - if ([nswindow isMiniaturized]) { - window->flags |= SDL_WINDOW_MINIMIZED; - } else { - window->flags &= ~SDL_WINDOW_MINIMIZED; - } - - if ([nswindow isKeyWindow]) { - window->flags |= SDL_WINDOW_INPUT_FOCUS; - SDL_SetKeyboardFocus(data.window); - } - - /* SDL_WindowData will be holding a strong reference to the NSWindow, and - * it will also call [NSWindow close] in DestroyWindow before releasing the - * NSWindow, so the extra release provided by releasedWhenClosed isn't - * necessary. */ - nswindow.releasedWhenClosed = NO; - - /* Prevents the window's "window device" from being destroyed when it is - * hidden. See http://www.mikeash.com/pyblog/nsopenglcontext-and-one-shot.html - */ - [nswindow setOneShot:NO]; - - /* All done! */ - window->driverdata = (void *)CFBridgingRetain(data); - return 0; -}} - -int -Cocoa_CreateWindow(_THIS, SDL_Window * window) -{ @autoreleasepool +int Cocoa_CreateWindow(_THIS, SDL_Window *window) { - SDL_VideoData *videodata = (__bridge SDL_VideoData *) _this->driverdata; - NSWindow *nswindow; - SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); - NSRect rect; - SDL_Rect bounds; - NSUInteger style; - NSArray *screens = [NSScreen screens]; - NSScreen *screen = nil; - SDLView *contentView; - BOOL highdpi; + @autoreleasepool { + SDL_VideoData *videodata = (__bridge SDL_VideoData *)_this->driverdata; + NSWindow *nswindow; + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); + NSRect rect; + SDL_Rect bounds; + NSUInteger style; + NSArray *screens = [NSScreen screens]; + NSScreen *screen = nil; + SDLView *contentView; + BOOL highdpi; - Cocoa_GetDisplayBounds(_this, display, &bounds); - rect.origin.x = window->x; - rect.origin.y = window->y; - rect.size.width = window->w; - rect.size.height = window->h; - ConvertNSRect([screens objectAtIndex:0], (window->flags & FULLSCREEN_MASK), &rect); + Cocoa_GetDisplayBounds(_this, display, &bounds); + rect.origin.x = window->x; + rect.origin.y = window->y; + rect.size.width = window->w; + rect.size.height = window->h; + ConvertNSRect([screens objectAtIndex:0], (window->flags & FULLSCREEN_MASK), &rect); - style = GetWindowStyle(window); + style = GetWindowStyle(window); - /* Figure out which screen to place this window */ - for (NSScreen *candidate in screens) { - NSRect screenRect = [candidate frame]; - if (rect.origin.x >= screenRect.origin.x && - rect.origin.x < screenRect.origin.x + screenRect.size.width && - rect.origin.y >= screenRect.origin.y && - rect.origin.y < screenRect.origin.y + screenRect.size.height) { - screen = candidate; - rect.origin.x -= screenRect.origin.x; - rect.origin.y -= screenRect.origin.y; + /* Figure out which screen to place this window */ + for (NSScreen *candidate in screens) { + NSRect screenRect = [candidate frame]; + if (rect.origin.x >= screenRect.origin.x && + rect.origin.x < screenRect.origin.x + screenRect.size.width && + rect.origin.y >= screenRect.origin.y && + rect.origin.y < screenRect.origin.y + screenRect.size.height) { + screen = candidate; + rect.origin.x -= screenRect.origin.x; + rect.origin.y -= screenRect.origin.y; + } } - } - @try { - nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:NO screen:screen]; - } - @catch (NSException *e) { - return SDL_SetError("%s", [[e reason] UTF8String]); - } + @try { + nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:NO screen:screen]; + } + @catch (NSException *e) { + return SDL_SetError("%s", [[e reason] UTF8String]); + } - [nswindow setColorSpace:[NSColorSpace sRGBColorSpace]]; + [nswindow setColorSpace:[NSColorSpace sRGBColorSpace]]; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 /* Added in the 10.12.0 SDK. */ - /* By default, don't allow users to make our window tabbed in 10.12 or later */ - if ([nswindow respondsToSelector:@selector(setTabbingMode:)]) { - [nswindow setTabbingMode:NSWindowTabbingModeDisallowed]; - } + /* By default, don't allow users to make our window tabbed in 10.12 or later */ + if ([nswindow respondsToSelector:@selector(setTabbingMode:)]) { + [nswindow setTabbingMode:NSWindowTabbingModeDisallowed]; + } #endif - if (videodata.allow_spaces) { - /* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */ - if (window->flags & SDL_WINDOW_RESIZABLE) { - /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */ - [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; + if (videodata.allow_spaces) { + /* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */ + if (window->flags & SDL_WINDOW_RESIZABLE) { + /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */ + [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; + } } - } - if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) { - [nswindow setLevel:NSFloatingWindowLevel]; - } + if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) { + [nswindow setLevel:NSFloatingWindowLevel]; + } - /* Create a default view for this window */ - rect = [nswindow contentRectForFrameRect:[nswindow frame]]; - contentView = [[SDLView alloc] initWithFrame:rect]; - [contentView setSDLWindow:window]; + /* Create a default view for this window */ + rect = [nswindow contentRectForFrameRect:[nswindow frame]]; + contentView = [[SDLView alloc] initWithFrame:rect]; + [contentView setSDLWindow:window]; - /* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */ - #ifdef __clang__ - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wdeprecated-declarations" - #endif - /* Note: as of the macOS 10.15 SDK, this defaults to YES instead of NO when - * the NSHighResolutionCapable boolean is set in Info.plist. */ - highdpi = (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) != 0; - [contentView setWantsBestResolutionOpenGLSurface:highdpi]; - #ifdef __clang__ - #pragma clang diagnostic pop - #endif +/* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */ +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif + /* Note: as of the macOS 10.15 SDK, this defaults to YES instead of NO when + * the NSHighResolutionCapable boolean is set in Info.plist. */ + highdpi = (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) != 0; + [contentView setWantsBestResolutionOpenGLSurface:highdpi]; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif #if SDL_VIDEO_OPENGL_ES2 #if SDL_VIDEO_OPENGL_EGL @@ -1800,329 +1790,42 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window) _this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { [contentView setWantsLayer:TRUE]; } -#endif /* SDL_VIDEO_OPENGL_EGL */ -#endif /* SDL_VIDEO_OPENGL_ES2 */ - [nswindow setContentView:contentView]; +} - if (SetupWindowData(_this, window, nswindow, contentView, SDL_TRUE) < 0) { - return -1; - } - - if (!(window->flags & SDL_WINDOW_OPENGL)) { - return 0; - } - - /* The rest of this macro mess is for OpenGL or OpenGL ES windows */ -#if SDL_VIDEO_OPENGL_ES2 - if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { -#if SDL_VIDEO_OPENGL_EGL - if (Cocoa_GLES_SetupWindow(_this, window) < 0) { - Cocoa_DestroyWindow(_this, window); - return -1; +void Cocoa_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable) +{ + @autoreleasepool { + /* Don't set this if we're in a space! + * The window will get permanently stuck if resizable is false. + * -flibit + */ + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; + Cocoa_WindowListener *listener = data.listener; + NSWindow *nswindow = data.nswindow; + SDL_VideoData *videodata = data.videodata; + if (![listener isInFullscreenSpace]) { + SetWindowStyle(window, GetWindowStyle(window)); } - return 0; -#else - return SDL_SetError("Could not create GLES window surface (EGL support not configured)"); -#endif /* SDL_VIDEO_OPENGL_EGL */ - } -#endif /* SDL_VIDEO_OPENGL_ES2 */ - return 0; -}} - -int -Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) -{ @autoreleasepool -{ - NSView* nsview = nil; - NSWindow *nswindow = nil; - NSString *title; - BOOL highdpi; - - if ([(__bridge id)data isKindOfClass:[NSWindow class]]) { - nswindow = (__bridge NSWindow*)data; - nsview = [nswindow contentView]; - } else if ([(__bridge id)data isKindOfClass:[NSView class]]) { - nsview = (__bridge NSView*)data; - nswindow = [nsview window]; - } else { - SDL_assert(false); - } - - /* Query the title from the existing window */ - title = [nswindow title]; - if (title) { - window->title = SDL_strdup([title UTF8String]); - } - - /* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */ - #ifdef __clang__ - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wdeprecated-declarations" - #endif - /* Note: as of the macOS 10.15 SDK, this defaults to YES instead of NO when - * the NSHighResolutionCapable boolean is set in Info.plist. */ - highdpi = (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) != 0; - [nsview setWantsBestResolutionOpenGLSurface:highdpi]; - #ifdef __clang__ - #pragma clang diagnostic pop - #endif - - return SetupWindowData(_this, window, nswindow, nsview, SDL_FALSE); -}} - -void -Cocoa_SetWindowTitle(_THIS, SDL_Window * window) -{ @autoreleasepool -{ - const char *title = window->title ? window->title : ""; - NSWindow *nswindow = ((__bridge SDL_WindowData *) window->driverdata).nswindow; - NSString *string = [[NSString alloc] initWithUTF8String:title]; - [nswindow setTitle:string]; -}} - -void -Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) -{ @autoreleasepool -{ - NSImage *nsimage = Cocoa_CreateImage(icon); - - if (nsimage) { - [NSApp setApplicationIconImage:nsimage]; - } -}} - -void -Cocoa_SetWindowPosition(_THIS, SDL_Window * window) -{ @autoreleasepool -{ - SDL_WindowData *windata = (__bridge SDL_WindowData *) window->driverdata; - NSWindow *nswindow = windata.nswindow; - NSRect rect; - Uint32 moveHack; - - rect.origin.x = window->x; - rect.origin.y = window->y; - rect.size.width = window->w; - rect.size.height = window->h; - ConvertNSRect([nswindow screen], (window->flags & FULLSCREEN_MASK), &rect); - - moveHack = s_moveHack; - s_moveHack = 0; - [nswindow setFrameOrigin:rect.origin]; - s_moveHack = moveHack; - - ScheduleContextUpdates(windata); -}} - -void -Cocoa_SetWindowSize(_THIS, SDL_Window * window) -{ @autoreleasepool -{ - SDL_WindowData *windata = (__bridge SDL_WindowData *) window->driverdata; - NSWindow *nswindow = windata.nswindow; - NSRect rect; - Uint32 moveHack; - - /* Cocoa will resize the window from the bottom-left rather than the - * top-left when -[nswindow setContentSize:] is used, so we must set the - * entire frame based on the new size, in order to preserve the position. - */ - rect.origin.x = window->x; - rect.origin.y = window->y; - rect.size.width = window->w; - rect.size.height = window->h; - ConvertNSRect([nswindow screen], (window->flags & FULLSCREEN_MASK), &rect); - - moveHack = s_moveHack; - s_moveHack = 0; - [nswindow setFrame:[nswindow frameRectForContentRect:rect] display:YES]; - s_moveHack = moveHack; - - ScheduleContextUpdates(windata); -}} - -void -Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window) -{ @autoreleasepool -{ - SDL_WindowData *windata = (__bridge SDL_WindowData *) window->driverdata; - - NSSize minSize; - minSize.width = window->min_w; - minSize.height = window->min_h; - - [windata.nswindow setContentMinSize:minSize]; -}} - -void -Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window) -{ @autoreleasepool -{ - SDL_WindowData *windata = (__bridge SDL_WindowData *) window->driverdata; - - NSSize maxSize; - maxSize.width = window->max_w; - maxSize.height = window->max_h; - - [windata.nswindow setContentMaxSize:maxSize]; -}} - -void -Cocoa_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h) -{ @autoreleasepool -{ - SDL_WindowData *windata = (__bridge SDL_WindowData *) window->driverdata; - NSView *contentView = windata.sdlContentView; - NSRect viewport = [contentView bounds]; - - if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) { - /* This gives us the correct viewport for a Retina-enabled view. */ - viewport = [contentView convertRectToBacking:viewport]; - } - - *w = viewport.size.width; - *h = viewport.size.height; -}} - - -void -Cocoa_ShowWindow(_THIS, SDL_Window * window) -{ @autoreleasepool -{ - SDL_WindowData *windowData = ((__bridge SDL_WindowData *) window->driverdata); - NSWindow *nswindow = windowData.nswindow; - - if (![nswindow isMiniaturized]) { - [windowData.listener pauseVisibleObservation]; - [nswindow makeKeyAndOrderFront:nil]; - [windowData.listener resumeVisibleObservation]; - } -}} - -void -Cocoa_HideWindow(_THIS, SDL_Window * window) -{ @autoreleasepool -{ - NSWindow *nswindow = ((__bridge SDL_WindowData *) window->driverdata).nswindow; - - [nswindow orderOut:nil]; -}} - -void -Cocoa_RaiseWindow(_THIS, SDL_Window * window) -{ @autoreleasepool -{ - SDL_WindowData *windowData = ((__bridge SDL_WindowData *) window->driverdata); - NSWindow *nswindow = windowData.nswindow; - - /* makeKeyAndOrderFront: has the side-effect of deminiaturizing and showing - a minimized or hidden window, so check for that before showing it. - */ - [windowData.listener pauseVisibleObservation]; - if (![nswindow isMiniaturized] && [nswindow isVisible]) { - [NSApp activateIgnoringOtherApps:YES]; - [nswindow makeKeyAndOrderFront:nil]; - } - [windowData.listener resumeVisibleObservation]; -}} - -void -Cocoa_MaximizeWindow(_THIS, SDL_Window * window) -{ @autoreleasepool -{ - SDL_WindowData *windata = (__bridge SDL_WindowData *) window->driverdata; - NSWindow *nswindow = windata.nswindow; - - [nswindow zoom:nil]; - - ScheduleContextUpdates(windata); -}} - -void -Cocoa_MinimizeWindow(_THIS, SDL_Window * window) -{ @autoreleasepool -{ - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; - NSWindow *nswindow = data.nswindow; - if ([data.listener isInFullscreenSpaceTransition]) { - [data.listener addPendingWindowOperation:PENDING_OPERATION_MINIMIZE]; - } else { - [nswindow miniaturize:nil]; - } -}} - -void -Cocoa_RestoreWindow(_THIS, SDL_Window * window) -{ @autoreleasepool -{ - NSWindow *nswindow = ((__bridge SDL_WindowData *) window->driverdata).nswindow; - - if ([nswindow isMiniaturized]) { - [nswindow deminiaturize:nil]; - } else if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) { - [nswindow zoom:nil]; - } -}} - -void -Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) -{ @autoreleasepool -{ - if (SetWindowStyle(window, GetWindowStyle(window))) { - if (bordered) { - Cocoa_SetWindowTitle(_this, window); /* this got blanked out. */ + if (videodata.allow_spaces) { + if (resizable) { + /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */ + [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; + } else { + [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged]; + } } } -}} +} -void -Cocoa_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable) -{ @autoreleasepool +void Cocoa_SetWindowAlwaysOnTop(_THIS, SDL_Window *window, SDL_bool on_top) { - /* Don't set this if we're in a space! - * The window will get permanently stuck if resizable is false. - * -flibit - */ - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; - Cocoa_WindowListener *listener = data.listener; - NSWindow *nswindow = data.nswindow; - SDL_VideoData *videodata = data.videodata; - if (![listener isInFullscreenSpace]) { - SetWindowStyle(window, GetWindowStyle(window)); - } - if (videodata.allow_spaces) { - if (resizable) { - /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */ - [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; - } else { - [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged]; - } - } -}} - -void -Cocoa_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top) -{ @autoreleasepool - { - NSWindow *nswindow = ((__bridge SDL_WindowData *) window->driverdata).nswindow; + @autoreleasepool { + NSWindow *nswindow = ((__bridge SDL_WindowData *)window->driverdata).nswindow; if (on_top) { [nswindow setLevel:NSFloatingWindowLevel]; } else { [nswindow setLevel:kCGNormalWindowLevel]; } - }} - -void -Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen) -{ @autoreleasepool -{ - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; - NSWindow *nswindow = data.nswindow; - NSRect rect; - - /* The view responder chain gets messed with during setStyleMask */ - if ([data.sdlContentView nextResponder] == data.listener) { - [data.sdlContentView setNextResponder:nil]; } if (fullscreen) { @@ -2334,54 +2037,27 @@ Cocoa_SetWindowMouseRect(_THIS, SDL_Window * window) Cocoa_UpdateClipCursor(window); } -void -Cocoa_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed) -{ @autoreleasepool +void Cocoa_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen) { - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; + @autoreleasepool { + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; + NSWindow *nswindow = data.nswindow; + NSRect rect; - Cocoa_UpdateClipCursor(window); - - if (data && (window->flags & SDL_WINDOW_FULLSCREEN)) { - if (SDL_ShouldAllowTopmost() && (window->flags & SDL_WINDOW_INPUT_FOCUS) - && ![data.listener isInFullscreenSpace]) { - /* OpenGL is rendering to the window, so make it visible! */ - /* Doing this in 10.11 while in a Space breaks things (bug #3152) */ - [data.nswindow setLevel:CGShieldingWindowLevel()]; - } else if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) { - [data.nswindow setLevel:NSFloatingWindowLevel]; - } else { - [data.nswindow setLevel:kCGNormalWindowLevel]; - } - } -}} - -void -Cocoa_DestroyWindow(_THIS, SDL_Window * window) -{ @autoreleasepool -{ - SDL_WindowData *data = (SDL_WindowData *) CFBridgingRelease(window->driverdata); - - if (data) { - NSArray *contexts; - if ([data.listener isInFullscreenSpace]) { - [NSMenu setMenuBarVisible:YES]; - } - [data.listener close]; - data.listener = nil; - if (data.created) { - /* Release the content view to avoid further updateLayer callbacks */ - [data.nswindow setContentView:nil]; - [data.nswindow close]; + /* The view responder chain gets messed with during setStyleMask */ + if ([data.sdlContentView nextResponder] == data.listener) { + [data.sdlContentView setNextResponder:nil]; } - #if SDL_VIDEO_OPENGL + if (fullscreen) { + SDL_Rect bounds; - contexts = [data.nscontexts copy]; - for (SDLOpenGLContext *context in contexts) { - /* Calling setWindow:NULL causes the context to remove itself from the context list. */ - [context setWindow:NULL]; - } + Cocoa_GetDisplayBounds(_this, display, &bounds); + rect.origin.x = bounds.x; + rect.origin.y = bounds.y; + rect.size.width = bounds.w; + rect.size.height = bounds.h; + ConvertNSRect([nswindow screen], fullscreen, &rect); #endif /* SDL_VIDEO_OPENGL */ @@ -2443,84 +2119,333 @@ Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state) /* Wait for the transition to complete, so application changes take effect properly (e.g. setting the window size, etc.) */ - const int limit = 10000; - int count = 0; - while ([data.listener isInFullscreenSpaceTransition]) { - if ( ++count == limit ) { - /* Uh oh, transition isn't completing. Should we assert? */ - break; + if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_14) { + NSRect screenRect = [[nswindow screen] frame]; + if (screenRect.size.height >= 1.0f) { + rect.origin.y += (screenRect.size.height - rect.size.height); } - SDL_Delay(1); - SDL_PumpEvents(); } - if ([data.listener isInFullscreenSpace] == (state ? YES : NO)) - break; - /* Try again, the last attempt was interrupted by user gestures */ - if (![data.listener setFullscreenSpace:(state ? YES : NO)]) - break; /* ??? */ + + [nswindow setStyleMask:NSWindowStyleMaskBorderless]; + } else { + NSRect frameRect; + rect.origin.x = window->windowed.x; + rect.origin.y = window->windowed.y; + rect.size.width = window->windowed.w; + rect.size.height = window->windowed.h; + ConvertNSRect([nswindow screen], fullscreen, &rect); + + /* The window is not meant to be fullscreen, but its flags might have a + * fullscreen bit set if it's scheduled to go fullscreen immediately + * after. Always using the windowed mode style here works around bugs in + * macOS 10.15 where the window doesn't properly restore the windowed + * mode decorations after exiting fullscreen-desktop, when the window + * was created as fullscreen-desktop. */ + [nswindow setStyleMask:GetWindowWindowedStyle(window)]; + + /* Hack to restore window decorations on macOS 10.10 */ + frameRect = [nswindow frame]; + [nswindow setFrame:NSMakeRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width + 1, frameRect.size.height) display:NO]; + [nswindow setFrame:frameRect display:NO]; } - /* Return TRUE to prevent non-space fullscreen logic from running */ - succeeded = SDL_TRUE; + + /* The view responder chain gets messed with during setStyleMask */ + if ([data.sdlContentView nextResponder] != data.listener) { + [data.sdlContentView setNextResponder:data.listener]; + } + + s_moveHack = 0; + [nswindow setContentSize:rect.size]; + [nswindow setFrameOrigin:rect.origin]; + s_moveHack = SDL_GetTicks(); + + /* When the window style changes the title is cleared */ + if (!fullscreen) { + Cocoa_SetWindowTitle(_this, window); + } + + if (SDL_ShouldAllowTopmost() && fullscreen) { + /* OpenGL is rendering to the window, so make it visible! */ + [nswindow setLevel:CGShieldingWindowLevel()]; + } else if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) { + [nswindow setLevel:NSFloatingWindowLevel]; + } else { + [nswindow setLevel:kCGNormalWindowLevel]; + } + + if ([nswindow isVisible] || fullscreen) { + [data.listener pauseVisibleObservation]; + [nswindow makeKeyAndOrderFront:nil]; + [data.listener resumeVisibleObservation]; + } + + ScheduleContextUpdates(data); } - data.inWindowFullscreenTransition = SDL_FALSE; - - return succeeded; -}} - -int -Cocoa_SetWindowHitTest(SDL_Window * window, SDL_bool enabled) -{ - return 0; /* just succeed, the real work is done elsewhere. */ } -void -Cocoa_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept) -{ @autoreleasepool +void * +Cocoa_GetWindowICCProfile(_THIS, SDL_Window *window, size_t *size) { - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; - if (accept) { - [data.nswindow registerForDraggedTypes:[NSArray arrayWithObject:(NSString *)kUTTypeFileURL]]; - } else { - [data.nswindow unregisterDraggedTypes]; - } -}} + @autoreleasepool { + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; + NSWindow *nswindow = data.nswindow; + NSScreen *screen = [nswindow screen]; + NSData *iccProfileData = nil; + void *retIccProfileData = NULL; -int -Cocoa_FlashWindow(_THIS, SDL_Window *window, SDL_FlashOperation operation) -{ @autoreleasepool + if (screen == nil) { + SDL_SetError("Could not get screen of window."); + return NULL; + } + + if ([screen colorSpace] == nil) { + SDL_SetError("Could not get colorspace information of screen."); + return NULL; + } + + iccProfileData = [[screen colorSpace] ICCProfileData]; + if (iccProfileData == nil) { + SDL_SetError("Could not get ICC profile data."); + return NULL; + } + + retIccProfileData = SDL_malloc([iccProfileData length]); + if (!retIccProfileData) { + SDL_OutOfMemory(); + return NULL; + } + + [iccProfileData getBytes:retIccProfileData length:[iccProfileData length]]; + *size = [iccProfileData length]; + return retIccProfileData; + } +} + +int Cocoa_GetWindowDisplayIndex(_THIS, SDL_Window *window) { - /* Note that this is app-wide and not window-specific! */ - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; + @autoreleasepool { + NSScreen *screen; + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; - if (data.flash_request) { - [NSApp cancelUserAttentionRequest:data.flash_request]; - data.flash_request = 0; + /* Not recognized via CHECK_WINDOW_MAGIC */ + if (data == nil) { + /* Don't set the error here, it hides other errors and is ignored anyway */ + /*return SDL_SetError("Window data not set");*/ + return -1; + } + + /* NSWindow.screen may be nil when the window is off-screen. */ + screen = data.nswindow.screen; + + if (screen != nil) { + CGDirectDisplayID displayid; + int i; + + /* https://developer.apple.com/documentation/appkit/nsscreen/1388360-devicedescription?language=objc */ + displayid = [[screen.deviceDescription objectForKey:@"NSScreenNumber"] unsignedIntValue]; + + for (i = 0; i < _this->num_displays; i++) { + SDL_DisplayData *displaydata = (SDL_DisplayData *)_this->displays[i].driverdata; + if (displaydata != NULL && displaydata->display == displayid) { + return i; + } + } + } + + /* Other code may expect SDL_GetWindowDisplayIndex to always return a valid + * index for a window. The higher level GetWindowDisplayIndex code will fall + * back to a generic position-based query if the backend implementation + * fails. */ + return SDL_SetError("Couldn't find the display where the window is located."); } +} - switch (operation) { - case SDL_FLASH_CANCEL: - /* Canceled above */ - break; - case SDL_FLASH_BRIEFLY: - data.flash_request = [NSApp requestUserAttention:NSInformationalRequest]; - break; - case SDL_FLASH_UNTIL_FOCUSED: - data.flash_request = [NSApp requestUserAttention:NSCriticalRequest]; - break; - default: - return SDL_Unsupported(); - } - return 0; -}} - -int -Cocoa_SetWindowOpacity(_THIS, SDL_Window * window, float opacity) -{ @autoreleasepool +void Cocoa_SetWindowMouseRect(_THIS, SDL_Window *window) { - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; - [data.nswindow setAlphaValue:opacity]; - return 0; -}} + Cocoa_UpdateClipCursor(window); +} + +void Cocoa_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed) +{ + @autoreleasepool { + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; + + Cocoa_UpdateClipCursor(window); + + if (data && (window->flags & SDL_WINDOW_FULLSCREEN)) { + if (SDL_ShouldAllowTopmost() && (window->flags & SDL_WINDOW_INPUT_FOCUS) && ![data.listener isInFullscreenSpace]) { + /* OpenGL is rendering to the window, so make it visible! */ + /* Doing this in 10.11 while in a Space breaks things (bug #3152) */ + [data.nswindow setLevel:CGShieldingWindowLevel()]; + } else if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) { + [data.nswindow setLevel:NSFloatingWindowLevel]; + } else { + [data.nswindow setLevel:kCGNormalWindowLevel]; + } + } + } +} + +void Cocoa_DestroyWindow(_THIS, SDL_Window *window) +{ + @autoreleasepool { + SDL_WindowData *data = (SDL_WindowData *)CFBridgingRelease(window->driverdata); + + if (data) { + NSArray *contexts; + if ([data.listener isInFullscreenSpace]) { + [NSMenu setMenuBarVisible:YES]; + } + [data.listener close]; + data.listener = nil; + if (data.created) { + /* Release the content view to avoid further updateLayer callbacks */ + [data.nswindow setContentView:nil]; + [data.nswindow close]; + } + +#if SDL_VIDEO_OPENGL + + contexts = [data.nscontexts copy]; + for (SDLOpenGLContext *context in contexts) { + /* Calling setWindow:NULL causes the context to remove itself from the context list. */ + [context setWindow:NULL]; + } + +#endif /* SDL_VIDEO_OPENGL */ + + if (window->shaper) { + CFBridgingRelease(window->shaper->driverdata); + SDL_free(window->shaper); + window->shaper = NULL; + } + } + window->driverdata = NULL; + } +} + +int Cocoa_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info) +{ + @autoreleasepool { + NSWindow *nswindow = ((__bridge SDL_WindowData *)window->driverdata).nswindow; + + info->subsystem = SDL_SYSWM_COCOA; + info->info.cocoa.window = nswindow; + return 0; + } +} + +SDL_bool +Cocoa_IsWindowInFullscreenSpace(SDL_Window *window) +{ + @autoreleasepool { + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; + + if ([data.listener isInFullscreenSpace]) { + return SDL_TRUE; + } else { + return SDL_FALSE; + } + } +} + +SDL_bool +Cocoa_SetWindowFullscreenSpace(SDL_Window *window, SDL_bool state) +{ + @autoreleasepool { + SDL_bool succeeded = SDL_FALSE; + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; + + if (data.inWindowFullscreenTransition) { + return SDL_FALSE; + } + + data.inWindowFullscreenTransition = SDL_TRUE; + if ([data.listener setFullscreenSpace:(state ? YES : NO)]) { + const int maxattempts = 3; + int attempt = 0; + while (++attempt <= maxattempts) { + /* Wait for the transition to complete, so application changes + take effect properly (e.g. setting the window size, etc.) + */ + const int limit = 10000; + int count = 0; + while ([data.listener isInFullscreenSpaceTransition]) { + if (++count == limit) { + /* Uh oh, transition isn't completing. Should we assert? */ + break; + } + SDL_Delay(1); + SDL_PumpEvents(); + } + if ([data.listener isInFullscreenSpace] == (state ? YES : NO)) + break; + /* Try again, the last attempt was interrupted by user gestures */ + if (![data.listener setFullscreenSpace:(state ? YES : NO)]) + break; /* ??? */ + } + /* Return TRUE to prevent non-space fullscreen logic from running */ + succeeded = SDL_TRUE; + } + data.inWindowFullscreenTransition = SDL_FALSE; + + return succeeded; + } +} + +int Cocoa_SetWindowHitTest(SDL_Window *window, SDL_bool enabled) +{ + return 0; /* just succeed, the real work is done elsewhere. */ +} + +void Cocoa_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept) +{ + @autoreleasepool { + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; + if (accept) { + [data.nswindow registerForDraggedTypes:[NSArray arrayWithObject:(NSString *)kUTTypeFileURL]]; + } else { + [data.nswindow unregisterDraggedTypes]; + } + } +} + +int Cocoa_FlashWindow(_THIS, SDL_Window *window, SDL_FlashOperation operation) +{ + @autoreleasepool { + /* Note that this is app-wide and not window-specific! */ + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; + + if (data.flash_request) { + [NSApp cancelUserAttentionRequest:data.flash_request]; + data.flash_request = 0; + } + + switch (operation) { + case SDL_FLASH_CANCEL: + /* Canceled above */ + break; + case SDL_FLASH_BRIEFLY: + data.flash_request = [NSApp requestUserAttention:NSInformationalRequest]; + break; + case SDL_FLASH_UNTIL_FOCUSED: + data.flash_request = [NSApp requestUserAttention:NSCriticalRequest]; + break; + default: + return SDL_Unsupported(); + } + return 0; + } +} + +int Cocoa_SetWindowOpacity(_THIS, SDL_Window *window, float opacity) +{ + @autoreleasepool { + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; + [data.nswindow setAlphaValue:opacity]; + return 0; + } +} #endif /* SDL_VIDEO_DRIVER_COCOA */ diff --git a/src/video/dummy/SDL_nullevents.c b/src/video/dummy/SDL_nullevents.c index e58ba2978..86c4a06a6 100644 --- a/src/video/dummy/SDL_nullevents.c +++ b/src/video/dummy/SDL_nullevents.c @@ -30,8 +30,7 @@ #include "SDL_nullvideo.h" #include "SDL_nullevents_c.h" -void -DUMMY_PumpEvents(_THIS) +void DUMMY_PumpEvents(_THIS) { /* do nothing. */ } diff --git a/src/video/dummy/SDL_nullframebuffer.c b/src/video/dummy/SDL_nullframebuffer.c index 16b5db8de..d85924987 100644 --- a/src/video/dummy/SDL_nullframebuffer.c +++ b/src/video/dummy/SDL_nullframebuffer.c @@ -25,10 +25,9 @@ #include "../SDL_sysvideo.h" #include "SDL_nullframebuffer_c.h" +#define DUMMY_SURFACE "_SDL_DummySurface" -#define DUMMY_SURFACE "_SDL_DummySurface" - -int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch) +int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch) { SDL_Surface *surface; const Uint32 surface_format = SDL_PIXELFORMAT_RGB888; @@ -52,12 +51,12 @@ int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * forma return 0; } -int SDL_DUMMY_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects) +int SDL_DUMMY_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects) { static int frame_number; SDL_Surface *surface; - surface = (SDL_Surface *) SDL_GetWindowData(window, DUMMY_SURFACE); + surface = (SDL_Surface *)SDL_GetWindowData(window, DUMMY_SURFACE); if (surface == NULL) { return SDL_SetError("Couldn't find dummy surface for window"); } @@ -72,11 +71,11 @@ int SDL_DUMMY_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect return 0; } -void SDL_DUMMY_DestroyWindowFramebuffer(_THIS, SDL_Window * window) +void SDL_DUMMY_DestroyWindowFramebuffer(_THIS, SDL_Window *window) { SDL_Surface *surface; - surface = (SDL_Surface *) SDL_SetWindowData(window, DUMMY_SURFACE, NULL); + surface = (SDL_Surface *)SDL_SetWindowData(window, DUMMY_SURFACE, NULL); SDL_FreeSurface(surface); } diff --git a/src/video/dummy/SDL_nullframebuffer_c.h b/src/video/dummy/SDL_nullframebuffer_c.h index cd8158e47..a37567614 100644 --- a/src/video/dummy/SDL_nullframebuffer_c.h +++ b/src/video/dummy/SDL_nullframebuffer_c.h @@ -24,9 +24,9 @@ #include "../../SDL_internal.h" -extern int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch); -extern int SDL_DUMMY_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects); -extern void SDL_DUMMY_DestroyWindowFramebuffer(_THIS, SDL_Window * window); +extern int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch); +extern int SDL_DUMMY_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects); +extern void SDL_DUMMY_DestroyWindowFramebuffer(_THIS, SDL_Window *window); #endif /* SDL_nullframebuffer_c_h_ */ diff --git a/src/video/dummy/SDL_nullvideo.c b/src/video/dummy/SDL_nullvideo.c index e9417350f..d5f768423 100644 --- a/src/video/dummy/SDL_nullvideo.c +++ b/src/video/dummy/SDL_nullvideo.c @@ -48,12 +48,12 @@ #include "SDL_nullframebuffer_c.h" #include "SDL_hints.h" -#define DUMMYVID_DRIVER_NAME "dummy" +#define DUMMYVID_DRIVER_NAME "dummy" #define DUMMYVID_DRIVER_EVDEV_NAME "evdev" /* Initialization/Query functions */ static int DUMMY_VideoInit(_THIS); -static int DUMMY_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); +static int DUMMY_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode); static void DUMMY_VideoQuit(_THIS); #if SDL_INPUT_LINUXEV @@ -63,32 +63,29 @@ static void DUMMY_EVDEV_Poll(_THIS); /* DUMMY driver bootstrap functions */ -static int -DUMMY_Available(void) +static int DUMMY_Available(void) { const char *envr = SDL_GetHint(SDL_HINT_VIDEODRIVER); if (envr) { if (SDL_strcmp(envr, DUMMYVID_DRIVER_NAME) == 0) { return 1; } - #if SDL_INPUT_LINUXEV +#if SDL_INPUT_LINUXEV if (SDL_strcmp(envr, DUMMYVID_DRIVER_EVDEV_NAME) == 0) { evdev = 1; return 1; } - #endif +#endif } return 0; } -static void -DUMMY_DeleteDevice(SDL_VideoDevice * device) +static void DUMMY_DeleteDevice(SDL_VideoDevice *device) { SDL_free(device); } -static SDL_VideoDevice * -DUMMY_CreateDevice(void) +static SDL_VideoDevice *DUMMY_CreateDevice(void) { SDL_VideoDevice *device; @@ -97,7 +94,7 @@ DUMMY_CreateDevice(void) } /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device == NULL) { SDL_OutOfMemory(); return 0; @@ -109,11 +106,11 @@ DUMMY_CreateDevice(void) device->VideoQuit = DUMMY_VideoQuit; device->SetDisplayMode = DUMMY_SetDisplayMode; device->PumpEvents = DUMMY_PumpEvents; - #if SDL_INPUT_LINUXEV +#if SDL_INPUT_LINUXEV if (evdev) { device->PumpEvents = DUMMY_EVDEV_Poll; } - #endif +#endif device->CreateWindowFramebuffer = SDL_DUMMY_CreateWindowFramebuffer; device->UpdateWindowFramebuffer = SDL_DUMMY_UpdateWindowFramebuffer; device->DestroyWindowFramebuffer = SDL_DUMMY_DestroyWindowFramebuffer; @@ -136,14 +133,14 @@ VideoBootStrap DUMMY_evdev_bootstrap = { void SDL_EVDEV_Init(void); void SDL_EVDEV_Poll(); void SDL_EVDEV_Quit(void); -static void DUMMY_EVDEV_Poll(_THIS) { - (void) _this; +static void DUMMY_EVDEV_Poll(_THIS) +{ + (void)_this; SDL_EVDEV_Poll(); } #endif -int -DUMMY_VideoInit(_THIS) +int DUMMY_VideoInit(_THIS) { SDL_DisplayMode mode; @@ -160,27 +157,24 @@ DUMMY_VideoInit(_THIS) SDL_AddDisplayMode(&_this->displays[0], &mode); - #if SDL_INPUT_LINUXEV +#if SDL_INPUT_LINUXEV SDL_EVDEV_Init(); - #endif +#endif /* We're done! */ return 0; } -static int -DUMMY_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +static int DUMMY_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) { return 0; } - -void -DUMMY_VideoQuit(_THIS) +void DUMMY_VideoQuit(_THIS) { - #if SDL_INPUT_LINUXEV +#if SDL_INPUT_LINUXEV SDL_EVDEV_Quit(); - #endif +#endif } #endif /* SDL_VIDEO_DRIVER_DUMMY */ diff --git a/src/video/emscripten/SDL_emscriptenevents.c b/src/video/emscripten/SDL_emscriptenevents.c index cba2ae5b0..5b097db17 100644 --- a/src/video/emscripten/SDL_emscriptenevents.c +++ b/src/video/emscripten/SDL_emscriptenevents.c @@ -44,232 +44,231 @@ https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode */ static const SDL_Keycode emscripten_keycode_table[] = { - /* 0 */ SDLK_UNKNOWN, - /* 1 */ SDLK_UNKNOWN, - /* 2 */ SDLK_UNKNOWN, - /* 3 */ SDLK_CANCEL, - /* 4 */ SDLK_UNKNOWN, - /* 5 */ SDLK_UNKNOWN, - /* 6 */ SDLK_HELP, - /* 7 */ SDLK_UNKNOWN, - /* 8 */ SDLK_BACKSPACE, - /* 9 */ SDLK_TAB, - /* 10 */ SDLK_UNKNOWN, - /* 11 */ SDLK_UNKNOWN, - /* 12 */ SDLK_KP_5, - /* 13 */ SDLK_RETURN, - /* 14 */ SDLK_UNKNOWN, - /* 15 */ SDLK_UNKNOWN, - /* 16 */ SDLK_LSHIFT, - /* 17 */ SDLK_LCTRL, - /* 18 */ SDLK_LALT, - /* 19 */ SDLK_PAUSE, - /* 20 */ SDLK_CAPSLOCK, - /* 21 */ SDLK_UNKNOWN, - /* 22 */ SDLK_UNKNOWN, - /* 23 */ SDLK_UNKNOWN, - /* 24 */ SDLK_UNKNOWN, - /* 25 */ SDLK_UNKNOWN, - /* 26 */ SDLK_UNKNOWN, - /* 27 */ SDLK_ESCAPE, - /* 28 */ SDLK_UNKNOWN, - /* 29 */ SDLK_UNKNOWN, - /* 30 */ SDLK_UNKNOWN, - /* 31 */ SDLK_UNKNOWN, - /* 32 */ SDLK_SPACE, - /* 33 */ SDLK_PAGEUP, - /* 34 */ SDLK_PAGEDOWN, - /* 35 */ SDLK_END, - /* 36 */ SDLK_HOME, - /* 37 */ SDLK_LEFT, - /* 38 */ SDLK_UP, - /* 39 */ SDLK_RIGHT, - /* 40 */ SDLK_DOWN, - /* 41 */ SDLK_UNKNOWN, - /* 42 */ SDLK_UNKNOWN, - /* 43 */ SDLK_UNKNOWN, - /* 44 */ SDLK_UNKNOWN, - /* 45 */ SDLK_INSERT, - /* 46 */ SDLK_DELETE, - /* 47 */ SDLK_UNKNOWN, - /* 48 */ SDLK_0, - /* 49 */ SDLK_1, - /* 50 */ SDLK_2, - /* 51 */ SDLK_3, - /* 52 */ SDLK_4, - /* 53 */ SDLK_5, - /* 54 */ SDLK_6, - /* 55 */ SDLK_7, - /* 56 */ SDLK_8, - /* 57 */ SDLK_9, - /* 58 */ SDLK_UNKNOWN, - /* 59 */ SDLK_SEMICOLON, - /* 60 */ SDLK_BACKSLASH /*SDL_SCANCODE_NONUSBACKSLASH*/, - /* 61 */ SDLK_EQUALS, - /* 62 */ SDLK_UNKNOWN, - /* 63 */ SDLK_MINUS, - /* 64 */ SDLK_UNKNOWN, - /* 65 */ SDLK_a, - /* 66 */ SDLK_b, - /* 67 */ SDLK_c, - /* 68 */ SDLK_d, - /* 69 */ SDLK_e, - /* 70 */ SDLK_f, - /* 71 */ SDLK_g, - /* 72 */ SDLK_h, - /* 73 */ SDLK_i, - /* 74 */ SDLK_j, - /* 75 */ SDLK_k, - /* 76 */ SDLK_l, - /* 77 */ SDLK_m, - /* 78 */ SDLK_n, - /* 79 */ SDLK_o, - /* 80 */ SDLK_p, - /* 81 */ SDLK_q, - /* 82 */ SDLK_r, - /* 83 */ SDLK_s, - /* 84 */ SDLK_t, - /* 85 */ SDLK_u, - /* 86 */ SDLK_v, - /* 87 */ SDLK_w, - /* 88 */ SDLK_x, - /* 89 */ SDLK_y, - /* 90 */ SDLK_z, - /* 91 */ SDLK_LGUI, - /* 92 */ SDLK_UNKNOWN, - /* 93 */ SDLK_APPLICATION, - /* 94 */ SDLK_UNKNOWN, - /* 95 */ SDLK_UNKNOWN, - /* 96 */ SDLK_KP_0, - /* 97 */ SDLK_KP_1, - /* 98 */ SDLK_KP_2, - /* 99 */ SDLK_KP_3, - /* 100 */ SDLK_KP_4, - /* 101 */ SDLK_KP_5, - /* 102 */ SDLK_KP_6, - /* 103 */ SDLK_KP_7, - /* 104 */ SDLK_KP_8, - /* 105 */ SDLK_KP_9, - /* 106 */ SDLK_KP_MULTIPLY, - /* 107 */ SDLK_KP_PLUS, - /* 108 */ SDLK_UNKNOWN, - /* 109 */ SDLK_KP_MINUS, - /* 110 */ SDLK_KP_PERIOD, - /* 111 */ SDLK_KP_DIVIDE, - /* 112 */ SDLK_F1, - /* 113 */ SDLK_F2, - /* 114 */ SDLK_F3, - /* 115 */ SDLK_F4, - /* 116 */ SDLK_F5, - /* 117 */ SDLK_F6, - /* 118 */ SDLK_F7, - /* 119 */ SDLK_F8, - /* 120 */ SDLK_F9, - /* 121 */ SDLK_F10, - /* 122 */ SDLK_F11, - /* 123 */ SDLK_F12, - /* 124 */ SDLK_F13, - /* 125 */ SDLK_F14, - /* 126 */ SDLK_F15, - /* 127 */ SDLK_F16, - /* 128 */ SDLK_F17, - /* 129 */ SDLK_F18, - /* 130 */ SDLK_F19, - /* 131 */ SDLK_F20, - /* 132 */ SDLK_F21, - /* 133 */ SDLK_F22, - /* 134 */ SDLK_F23, - /* 135 */ SDLK_F24, - /* 136 */ SDLK_UNKNOWN, - /* 137 */ SDLK_UNKNOWN, - /* 138 */ SDLK_UNKNOWN, - /* 139 */ SDLK_UNKNOWN, - /* 140 */ SDLK_UNKNOWN, - /* 141 */ SDLK_UNKNOWN, - /* 142 */ SDLK_UNKNOWN, - /* 143 */ SDLK_UNKNOWN, - /* 144 */ SDLK_NUMLOCKCLEAR, - /* 145 */ SDLK_SCROLLLOCK, - /* 146 */ SDLK_UNKNOWN, - /* 147 */ SDLK_UNKNOWN, - /* 148 */ SDLK_UNKNOWN, - /* 149 */ SDLK_UNKNOWN, - /* 150 */ SDLK_UNKNOWN, - /* 151 */ SDLK_UNKNOWN, - /* 152 */ SDLK_UNKNOWN, - /* 153 */ SDLK_UNKNOWN, - /* 154 */ SDLK_UNKNOWN, - /* 155 */ SDLK_UNKNOWN, - /* 156 */ SDLK_UNKNOWN, - /* 157 */ SDLK_UNKNOWN, - /* 158 */ SDLK_UNKNOWN, - /* 159 */ SDLK_UNKNOWN, - /* 160 */ SDLK_BACKQUOTE, - /* 161 */ SDLK_UNKNOWN, - /* 162 */ SDLK_UNKNOWN, - /* 163 */ SDLK_KP_HASH, /*KaiOS phone keypad*/ - /* 164 */ SDLK_UNKNOWN, - /* 165 */ SDLK_UNKNOWN, - /* 166 */ SDLK_UNKNOWN, - /* 167 */ SDLK_UNKNOWN, - /* 168 */ SDLK_UNKNOWN, - /* 169 */ SDLK_UNKNOWN, - /* 170 */ SDLK_KP_MULTIPLY, /*KaiOS phone keypad*/ - /* 171 */ SDLK_RIGHTBRACKET, - /* 172 */ SDLK_UNKNOWN, - /* 173 */ SDLK_MINUS, /*FX*/ - /* 174 */ SDLK_VOLUMEDOWN, /*IE, Chrome*/ - /* 175 */ SDLK_VOLUMEUP, /*IE, Chrome*/ - /* 176 */ SDLK_AUDIONEXT, /*IE, Chrome*/ - /* 177 */ SDLK_AUDIOPREV, /*IE, Chrome*/ - /* 178 */ SDLK_UNKNOWN, - /* 179 */ SDLK_AUDIOPLAY, /*IE, Chrome*/ - /* 180 */ SDLK_UNKNOWN, - /* 181 */ SDLK_AUDIOMUTE, /*FX*/ - /* 182 */ SDLK_VOLUMEDOWN, /*FX*/ - /* 183 */ SDLK_VOLUMEUP, /*FX*/ - /* 184 */ SDLK_UNKNOWN, - /* 185 */ SDLK_UNKNOWN, - /* 186 */ SDLK_SEMICOLON, /*IE, Chrome, D3E legacy*/ - /* 187 */ SDLK_EQUALS, /*IE, Chrome, D3E legacy*/ - /* 188 */ SDLK_COMMA, - /* 189 */ SDLK_MINUS, /*IE, Chrome, D3E legacy*/ - /* 190 */ SDLK_PERIOD, - /* 191 */ SDLK_SLASH, - /* 192 */ SDLK_BACKQUOTE, /*FX, D3E legacy (SDLK_APOSTROPHE in IE/Chrome)*/ - /* 193 */ SDLK_UNKNOWN, - /* 194 */ SDLK_UNKNOWN, - /* 195 */ SDLK_UNKNOWN, - /* 196 */ SDLK_UNKNOWN, - /* 197 */ SDLK_UNKNOWN, - /* 198 */ SDLK_UNKNOWN, - /* 199 */ SDLK_UNKNOWN, - /* 200 */ SDLK_UNKNOWN, - /* 201 */ SDLK_UNKNOWN, - /* 202 */ SDLK_UNKNOWN, - /* 203 */ SDLK_UNKNOWN, - /* 204 */ SDLK_UNKNOWN, - /* 205 */ SDLK_UNKNOWN, - /* 206 */ SDLK_UNKNOWN, - /* 207 */ SDLK_UNKNOWN, - /* 208 */ SDLK_UNKNOWN, - /* 209 */ SDLK_UNKNOWN, - /* 210 */ SDLK_UNKNOWN, - /* 211 */ SDLK_UNKNOWN, - /* 212 */ SDLK_UNKNOWN, - /* 213 */ SDLK_UNKNOWN, - /* 214 */ SDLK_UNKNOWN, - /* 215 */ SDLK_UNKNOWN, - /* 216 */ SDLK_UNKNOWN, - /* 217 */ SDLK_UNKNOWN, - /* 218 */ SDLK_UNKNOWN, - /* 219 */ SDLK_LEFTBRACKET, - /* 220 */ SDLK_BACKSLASH, - /* 221 */ SDLK_RIGHTBRACKET, - /* 222 */ SDLK_QUOTE, /*FX, D3E legacy*/ + /* 0 */ SDLK_UNKNOWN, + /* 1 */ SDLK_UNKNOWN, + /* 2 */ SDLK_UNKNOWN, + /* 3 */ SDLK_CANCEL, + /* 4 */ SDLK_UNKNOWN, + /* 5 */ SDLK_UNKNOWN, + /* 6 */ SDLK_HELP, + /* 7 */ SDLK_UNKNOWN, + /* 8 */ SDLK_BACKSPACE, + /* 9 */ SDLK_TAB, + /* 10 */ SDLK_UNKNOWN, + /* 11 */ SDLK_UNKNOWN, + /* 12 */ SDLK_KP_5, + /* 13 */ SDLK_RETURN, + /* 14 */ SDLK_UNKNOWN, + /* 15 */ SDLK_UNKNOWN, + /* 16 */ SDLK_LSHIFT, + /* 17 */ SDLK_LCTRL, + /* 18 */ SDLK_LALT, + /* 19 */ SDLK_PAUSE, + /* 20 */ SDLK_CAPSLOCK, + /* 21 */ SDLK_UNKNOWN, + /* 22 */ SDLK_UNKNOWN, + /* 23 */ SDLK_UNKNOWN, + /* 24 */ SDLK_UNKNOWN, + /* 25 */ SDLK_UNKNOWN, + /* 26 */ SDLK_UNKNOWN, + /* 27 */ SDLK_ESCAPE, + /* 28 */ SDLK_UNKNOWN, + /* 29 */ SDLK_UNKNOWN, + /* 30 */ SDLK_UNKNOWN, + /* 31 */ SDLK_UNKNOWN, + /* 32 */ SDLK_SPACE, + /* 33 */ SDLK_PAGEUP, + /* 34 */ SDLK_PAGEDOWN, + /* 35 */ SDLK_END, + /* 36 */ SDLK_HOME, + /* 37 */ SDLK_LEFT, + /* 38 */ SDLK_UP, + /* 39 */ SDLK_RIGHT, + /* 40 */ SDLK_DOWN, + /* 41 */ SDLK_UNKNOWN, + /* 42 */ SDLK_UNKNOWN, + /* 43 */ SDLK_UNKNOWN, + /* 44 */ SDLK_UNKNOWN, + /* 45 */ SDLK_INSERT, + /* 46 */ SDLK_DELETE, + /* 47 */ SDLK_UNKNOWN, + /* 48 */ SDLK_0, + /* 49 */ SDLK_1, + /* 50 */ SDLK_2, + /* 51 */ SDLK_3, + /* 52 */ SDLK_4, + /* 53 */ SDLK_5, + /* 54 */ SDLK_6, + /* 55 */ SDLK_7, + /* 56 */ SDLK_8, + /* 57 */ SDLK_9, + /* 58 */ SDLK_UNKNOWN, + /* 59 */ SDLK_SEMICOLON, + /* 60 */ SDLK_BACKSLASH /*SDL_SCANCODE_NONUSBACKSLASH*/, + /* 61 */ SDLK_EQUALS, + /* 62 */ SDLK_UNKNOWN, + /* 63 */ SDLK_MINUS, + /* 64 */ SDLK_UNKNOWN, + /* 65 */ SDLK_a, + /* 66 */ SDLK_b, + /* 67 */ SDLK_c, + /* 68 */ SDLK_d, + /* 69 */ SDLK_e, + /* 70 */ SDLK_f, + /* 71 */ SDLK_g, + /* 72 */ SDLK_h, + /* 73 */ SDLK_i, + /* 74 */ SDLK_j, + /* 75 */ SDLK_k, + /* 76 */ SDLK_l, + /* 77 */ SDLK_m, + /* 78 */ SDLK_n, + /* 79 */ SDLK_o, + /* 80 */ SDLK_p, + /* 81 */ SDLK_q, + /* 82 */ SDLK_r, + /* 83 */ SDLK_s, + /* 84 */ SDLK_t, + /* 85 */ SDLK_u, + /* 86 */ SDLK_v, + /* 87 */ SDLK_w, + /* 88 */ SDLK_x, + /* 89 */ SDLK_y, + /* 90 */ SDLK_z, + /* 91 */ SDLK_LGUI, + /* 92 */ SDLK_UNKNOWN, + /* 93 */ SDLK_APPLICATION, + /* 94 */ SDLK_UNKNOWN, + /* 95 */ SDLK_UNKNOWN, + /* 96 */ SDLK_KP_0, + /* 97 */ SDLK_KP_1, + /* 98 */ SDLK_KP_2, + /* 99 */ SDLK_KP_3, + /* 100 */ SDLK_KP_4, + /* 101 */ SDLK_KP_5, + /* 102 */ SDLK_KP_6, + /* 103 */ SDLK_KP_7, + /* 104 */ SDLK_KP_8, + /* 105 */ SDLK_KP_9, + /* 106 */ SDLK_KP_MULTIPLY, + /* 107 */ SDLK_KP_PLUS, + /* 108 */ SDLK_UNKNOWN, + /* 109 */ SDLK_KP_MINUS, + /* 110 */ SDLK_KP_PERIOD, + /* 111 */ SDLK_KP_DIVIDE, + /* 112 */ SDLK_F1, + /* 113 */ SDLK_F2, + /* 114 */ SDLK_F3, + /* 115 */ SDLK_F4, + /* 116 */ SDLK_F5, + /* 117 */ SDLK_F6, + /* 118 */ SDLK_F7, + /* 119 */ SDLK_F8, + /* 120 */ SDLK_F9, + /* 121 */ SDLK_F10, + /* 122 */ SDLK_F11, + /* 123 */ SDLK_F12, + /* 124 */ SDLK_F13, + /* 125 */ SDLK_F14, + /* 126 */ SDLK_F15, + /* 127 */ SDLK_F16, + /* 128 */ SDLK_F17, + /* 129 */ SDLK_F18, + /* 130 */ SDLK_F19, + /* 131 */ SDLK_F20, + /* 132 */ SDLK_F21, + /* 133 */ SDLK_F22, + /* 134 */ SDLK_F23, + /* 135 */ SDLK_F24, + /* 136 */ SDLK_UNKNOWN, + /* 137 */ SDLK_UNKNOWN, + /* 138 */ SDLK_UNKNOWN, + /* 139 */ SDLK_UNKNOWN, + /* 140 */ SDLK_UNKNOWN, + /* 141 */ SDLK_UNKNOWN, + /* 142 */ SDLK_UNKNOWN, + /* 143 */ SDLK_UNKNOWN, + /* 144 */ SDLK_NUMLOCKCLEAR, + /* 145 */ SDLK_SCROLLLOCK, + /* 146 */ SDLK_UNKNOWN, + /* 147 */ SDLK_UNKNOWN, + /* 148 */ SDLK_UNKNOWN, + /* 149 */ SDLK_UNKNOWN, + /* 150 */ SDLK_UNKNOWN, + /* 151 */ SDLK_UNKNOWN, + /* 152 */ SDLK_UNKNOWN, + /* 153 */ SDLK_UNKNOWN, + /* 154 */ SDLK_UNKNOWN, + /* 155 */ SDLK_UNKNOWN, + /* 156 */ SDLK_UNKNOWN, + /* 157 */ SDLK_UNKNOWN, + /* 158 */ SDLK_UNKNOWN, + /* 159 */ SDLK_UNKNOWN, + /* 160 */ SDLK_BACKQUOTE, + /* 161 */ SDLK_UNKNOWN, + /* 162 */ SDLK_UNKNOWN, + /* 163 */ SDLK_KP_HASH, /*KaiOS phone keypad*/ + /* 164 */ SDLK_UNKNOWN, + /* 165 */ SDLK_UNKNOWN, + /* 166 */ SDLK_UNKNOWN, + /* 167 */ SDLK_UNKNOWN, + /* 168 */ SDLK_UNKNOWN, + /* 169 */ SDLK_UNKNOWN, + /* 170 */ SDLK_KP_MULTIPLY, /*KaiOS phone keypad*/ + /* 171 */ SDLK_RIGHTBRACKET, + /* 172 */ SDLK_UNKNOWN, + /* 173 */ SDLK_MINUS, /*FX*/ + /* 174 */ SDLK_VOLUMEDOWN, /*IE, Chrome*/ + /* 175 */ SDLK_VOLUMEUP, /*IE, Chrome*/ + /* 176 */ SDLK_AUDIONEXT, /*IE, Chrome*/ + /* 177 */ SDLK_AUDIOPREV, /*IE, Chrome*/ + /* 178 */ SDLK_UNKNOWN, + /* 179 */ SDLK_AUDIOPLAY, /*IE, Chrome*/ + /* 180 */ SDLK_UNKNOWN, + /* 181 */ SDLK_AUDIOMUTE, /*FX*/ + /* 182 */ SDLK_VOLUMEDOWN, /*FX*/ + /* 183 */ SDLK_VOLUMEUP, /*FX*/ + /* 184 */ SDLK_UNKNOWN, + /* 185 */ SDLK_UNKNOWN, + /* 186 */ SDLK_SEMICOLON, /*IE, Chrome, D3E legacy*/ + /* 187 */ SDLK_EQUALS, /*IE, Chrome, D3E legacy*/ + /* 188 */ SDLK_COMMA, + /* 189 */ SDLK_MINUS, /*IE, Chrome, D3E legacy*/ + /* 190 */ SDLK_PERIOD, + /* 191 */ SDLK_SLASH, + /* 192 */ SDLK_BACKQUOTE, /*FX, D3E legacy (SDLK_APOSTROPHE in IE/Chrome)*/ + /* 193 */ SDLK_UNKNOWN, + /* 194 */ SDLK_UNKNOWN, + /* 195 */ SDLK_UNKNOWN, + /* 196 */ SDLK_UNKNOWN, + /* 197 */ SDLK_UNKNOWN, + /* 198 */ SDLK_UNKNOWN, + /* 199 */ SDLK_UNKNOWN, + /* 200 */ SDLK_UNKNOWN, + /* 201 */ SDLK_UNKNOWN, + /* 202 */ SDLK_UNKNOWN, + /* 203 */ SDLK_UNKNOWN, + /* 204 */ SDLK_UNKNOWN, + /* 205 */ SDLK_UNKNOWN, + /* 206 */ SDLK_UNKNOWN, + /* 207 */ SDLK_UNKNOWN, + /* 208 */ SDLK_UNKNOWN, + /* 209 */ SDLK_UNKNOWN, + /* 210 */ SDLK_UNKNOWN, + /* 211 */ SDLK_UNKNOWN, + /* 212 */ SDLK_UNKNOWN, + /* 213 */ SDLK_UNKNOWN, + /* 214 */ SDLK_UNKNOWN, + /* 215 */ SDLK_UNKNOWN, + /* 216 */ SDLK_UNKNOWN, + /* 217 */ SDLK_UNKNOWN, + /* 218 */ SDLK_UNKNOWN, + /* 219 */ SDLK_LEFTBRACKET, + /* 220 */ SDLK_BACKSLASH, + /* 221 */ SDLK_RIGHTBRACKET, + /* 222 */ SDLK_QUOTE, /*FX, D3E legacy*/ }; - /* Emscripten PK code to scancode https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent @@ -405,8 +404,7 @@ static const SDL_Scancode emscripten_scancode_table[] = { /* 0x7E "NumpadComma" */ SDL_SCANCODE_KP_COMMA }; -static SDL_Scancode -Emscripten_MapScanCode(const char *code) +static SDL_Scancode Emscripten_MapScanCode(const char *code) { const DOM_PK_CODE_TYPE pk_code = emscripten_compute_dom_pk_code(code); if (pk_code < SDL_arraysize(emscripten_scancode_table)) { @@ -414,97 +412,96 @@ Emscripten_MapScanCode(const char *code) } switch (pk_code) { - case DOM_PK_PASTE: - return SDL_SCANCODE_PASTE; - case DOM_PK_MEDIA_TRACK_PREVIOUS: - return SDL_SCANCODE_AUDIOPREV; - case DOM_PK_CUT: - return SDL_SCANCODE_CUT; - case DOM_PK_COPY: - return SDL_SCANCODE_COPY; - case DOM_PK_MEDIA_TRACK_NEXT: - return SDL_SCANCODE_AUDIONEXT; - case DOM_PK_NUMPAD_ENTER: - return SDL_SCANCODE_KP_ENTER; - case DOM_PK_CONTROL_RIGHT: - return SDL_SCANCODE_RCTRL; - case DOM_PK_AUDIO_VOLUME_MUTE: - return SDL_SCANCODE_AUDIOMUTE; - case DOM_PK_LAUNCH_APP_2: - return SDL_SCANCODE_CALCULATOR; - case DOM_PK_MEDIA_PLAY_PAUSE: - return SDL_SCANCODE_AUDIOPLAY; - case DOM_PK_MEDIA_STOP: - return SDL_SCANCODE_AUDIOSTOP; - case DOM_PK_EJECT: - return SDL_SCANCODE_EJECT; - case DOM_PK_AUDIO_VOLUME_DOWN: - return SDL_SCANCODE_VOLUMEDOWN; - case DOM_PK_AUDIO_VOLUME_UP: - return SDL_SCANCODE_VOLUMEUP; - case DOM_PK_BROWSER_HOME: - return SDL_SCANCODE_AC_HOME; - case DOM_PK_NUMPAD_DIVIDE: - return SDL_SCANCODE_KP_DIVIDE; - case DOM_PK_ALT_RIGHT: - return SDL_SCANCODE_RALT; - case DOM_PK_HELP: - return SDL_SCANCODE_HELP; - case DOM_PK_NUM_LOCK: - return SDL_SCANCODE_NUMLOCKCLEAR; - case DOM_PK_HOME: - return SDL_SCANCODE_HOME; - case DOM_PK_ARROW_UP: - return SDL_SCANCODE_UP; - case DOM_PK_PAGE_UP: - return SDL_SCANCODE_PAGEUP; - case DOM_PK_ARROW_LEFT: - return SDL_SCANCODE_LEFT; - case DOM_PK_ARROW_RIGHT: - return SDL_SCANCODE_RIGHT; - case DOM_PK_END: - return SDL_SCANCODE_END; - case DOM_PK_ARROW_DOWN: - return SDL_SCANCODE_DOWN; - case DOM_PK_PAGE_DOWN: - return SDL_SCANCODE_PAGEDOWN; - case DOM_PK_INSERT: - return SDL_SCANCODE_INSERT; - case DOM_PK_DELETE: - return SDL_SCANCODE_DELETE; - case DOM_PK_META_LEFT: - return SDL_SCANCODE_LGUI; - case DOM_PK_META_RIGHT: - return SDL_SCANCODE_RGUI; - case DOM_PK_CONTEXT_MENU: - return SDL_SCANCODE_APPLICATION; - case DOM_PK_POWER: - return SDL_SCANCODE_POWER; - case DOM_PK_BROWSER_SEARCH: - return SDL_SCANCODE_AC_SEARCH; - case DOM_PK_BROWSER_FAVORITES: - return SDL_SCANCODE_AC_BOOKMARKS; - case DOM_PK_BROWSER_REFRESH: - return SDL_SCANCODE_AC_REFRESH; - case DOM_PK_BROWSER_STOP: - return SDL_SCANCODE_AC_STOP; - case DOM_PK_BROWSER_FORWARD: - return SDL_SCANCODE_AC_FORWARD; - case DOM_PK_BROWSER_BACK: - return SDL_SCANCODE_AC_BACK; - case DOM_PK_LAUNCH_APP_1: - return SDL_SCANCODE_COMPUTER; - case DOM_PK_LAUNCH_MAIL: - return SDL_SCANCODE_MAIL; - case DOM_PK_MEDIA_SELECT: - return SDL_SCANCODE_MEDIASELECT; + case DOM_PK_PASTE: + return SDL_SCANCODE_PASTE; + case DOM_PK_MEDIA_TRACK_PREVIOUS: + return SDL_SCANCODE_AUDIOPREV; + case DOM_PK_CUT: + return SDL_SCANCODE_CUT; + case DOM_PK_COPY: + return SDL_SCANCODE_COPY; + case DOM_PK_MEDIA_TRACK_NEXT: + return SDL_SCANCODE_AUDIONEXT; + case DOM_PK_NUMPAD_ENTER: + return SDL_SCANCODE_KP_ENTER; + case DOM_PK_CONTROL_RIGHT: + return SDL_SCANCODE_RCTRL; + case DOM_PK_AUDIO_VOLUME_MUTE: + return SDL_SCANCODE_AUDIOMUTE; + case DOM_PK_LAUNCH_APP_2: + return SDL_SCANCODE_CALCULATOR; + case DOM_PK_MEDIA_PLAY_PAUSE: + return SDL_SCANCODE_AUDIOPLAY; + case DOM_PK_MEDIA_STOP: + return SDL_SCANCODE_AUDIOSTOP; + case DOM_PK_EJECT: + return SDL_SCANCODE_EJECT; + case DOM_PK_AUDIO_VOLUME_DOWN: + return SDL_SCANCODE_VOLUMEDOWN; + case DOM_PK_AUDIO_VOLUME_UP: + return SDL_SCANCODE_VOLUMEUP; + case DOM_PK_BROWSER_HOME: + return SDL_SCANCODE_AC_HOME; + case DOM_PK_NUMPAD_DIVIDE: + return SDL_SCANCODE_KP_DIVIDE; + case DOM_PK_ALT_RIGHT: + return SDL_SCANCODE_RALT; + case DOM_PK_HELP: + return SDL_SCANCODE_HELP; + case DOM_PK_NUM_LOCK: + return SDL_SCANCODE_NUMLOCKCLEAR; + case DOM_PK_HOME: + return SDL_SCANCODE_HOME; + case DOM_PK_ARROW_UP: + return SDL_SCANCODE_UP; + case DOM_PK_PAGE_UP: + return SDL_SCANCODE_PAGEUP; + case DOM_PK_ARROW_LEFT: + return SDL_SCANCODE_LEFT; + case DOM_PK_ARROW_RIGHT: + return SDL_SCANCODE_RIGHT; + case DOM_PK_END: + return SDL_SCANCODE_END; + case DOM_PK_ARROW_DOWN: + return SDL_SCANCODE_DOWN; + case DOM_PK_PAGE_DOWN: + return SDL_SCANCODE_PAGEDOWN; + case DOM_PK_INSERT: + return SDL_SCANCODE_INSERT; + case DOM_PK_DELETE: + return SDL_SCANCODE_DELETE; + case DOM_PK_META_LEFT: + return SDL_SCANCODE_LGUI; + case DOM_PK_META_RIGHT: + return SDL_SCANCODE_RGUI; + case DOM_PK_CONTEXT_MENU: + return SDL_SCANCODE_APPLICATION; + case DOM_PK_POWER: + return SDL_SCANCODE_POWER; + case DOM_PK_BROWSER_SEARCH: + return SDL_SCANCODE_AC_SEARCH; + case DOM_PK_BROWSER_FAVORITES: + return SDL_SCANCODE_AC_BOOKMARKS; + case DOM_PK_BROWSER_REFRESH: + return SDL_SCANCODE_AC_REFRESH; + case DOM_PK_BROWSER_STOP: + return SDL_SCANCODE_AC_STOP; + case DOM_PK_BROWSER_FORWARD: + return SDL_SCANCODE_AC_FORWARD; + case DOM_PK_BROWSER_BACK: + return SDL_SCANCODE_AC_BACK; + case DOM_PK_LAUNCH_APP_1: + return SDL_SCANCODE_COMPUTER; + case DOM_PK_LAUNCH_MAIL: + return SDL_SCANCODE_MAIL; + case DOM_PK_MEDIA_SELECT: + return SDL_SCANCODE_MEDIASELECT; } return SDL_SCANCODE_UNKNOWN; } -static SDL_Keycode -Emscripten_MapKeyCode(const EmscriptenKeyboardEvent *keyEvent) +static SDL_Keycode Emscripten_MapKeyCode(const EmscriptenKeyboardEvent *keyEvent) { SDL_Keycode keycode = SDLK_UNKNOWN; if (keyEvent->keyCode < SDL_arraysize(emscripten_keycode_table)) { @@ -512,66 +509,66 @@ Emscripten_MapKeyCode(const EmscriptenKeyboardEvent *keyEvent) if (keycode != SDLK_UNKNOWN) { if (keyEvent->location == DOM_KEY_LOCATION_RIGHT) { switch (keycode) { - case SDLK_LSHIFT: - keycode = SDLK_RSHIFT; - break; - case SDLK_LCTRL: - keycode = SDLK_RCTRL; - break; - case SDLK_LALT: - keycode = SDLK_RALT; - break; - case SDLK_LGUI: - keycode = SDLK_RGUI; - break; + case SDLK_LSHIFT: + keycode = SDLK_RSHIFT; + break; + case SDLK_LCTRL: + keycode = SDLK_RCTRL; + break; + case SDLK_LALT: + keycode = SDLK_RALT; + break; + case SDLK_LGUI: + keycode = SDLK_RGUI; + break; } } else if (keyEvent->location == DOM_KEY_LOCATION_NUMPAD) { switch (keycode) { - case SDLK_0: - case SDLK_INSERT: - keycode = SDLK_KP_0; - break; - case SDLK_1: - case SDLK_END: - keycode = SDLK_KP_1; - break; - case SDLK_2: - case SDLK_DOWN: - keycode = SDLK_KP_2; - break; - case SDLK_3: - case SDLK_PAGEDOWN: - keycode = SDLK_KP_3; - break; - case SDLK_4: - case SDLK_LEFT: - keycode = SDLK_KP_4; - break; - case SDLK_5: - keycode = SDLK_KP_5; - break; - case SDLK_6: - case SDLK_RIGHT: - keycode = SDLK_KP_6; - break; - case SDLK_7: - case SDLK_HOME: - keycode = SDLK_KP_7; - break; - case SDLK_8: - case SDLK_UP: - keycode = SDLK_KP_8; - break; - case SDLK_9: - case SDLK_PAGEUP: - keycode = SDLK_KP_9; - break; - case SDLK_RETURN: - keycode = SDLK_KP_ENTER; - break; - case SDLK_DELETE: - keycode = SDLK_KP_PERIOD; - break; + case SDLK_0: + case SDLK_INSERT: + keycode = SDLK_KP_0; + break; + case SDLK_1: + case SDLK_END: + keycode = SDLK_KP_1; + break; + case SDLK_2: + case SDLK_DOWN: + keycode = SDLK_KP_2; + break; + case SDLK_3: + case SDLK_PAGEDOWN: + keycode = SDLK_KP_3; + break; + case SDLK_4: + case SDLK_LEFT: + keycode = SDLK_KP_4; + break; + case SDLK_5: + keycode = SDLK_KP_5; + break; + case SDLK_6: + case SDLK_RIGHT: + keycode = SDLK_KP_6; + break; + case SDLK_7: + case SDLK_HOME: + keycode = SDLK_KP_7; + break; + case SDLK_8: + case SDLK_UP: + keycode = SDLK_KP_8; + break; + case SDLK_9: + case SDLK_PAGEUP: + keycode = SDLK_KP_9; + break; + case SDLK_RETURN: + keycode = SDLK_KP_ENTER; + break; + case SDLK_DELETE: + keycode = SDLK_KP_PERIOD; + break; } } } @@ -581,26 +578,25 @@ Emscripten_MapKeyCode(const EmscriptenKeyboardEvent *keyEvent) } /* "borrowed" from SDL_windowsevents.c */ -static int -Emscripten_ConvertUTF32toUTF8(Uint32 codepoint, char * text) +static int Emscripten_ConvertUTF32toUTF8(Uint32 codepoint, char *text) { if (codepoint <= 0x7F) { - text[0] = (char) codepoint; + text[0] = (char)codepoint; text[1] = '\0'; } else if (codepoint <= 0x7FF) { - text[0] = 0xC0 | (char) ((codepoint >> 6) & 0x1F); - text[1] = 0x80 | (char) (codepoint & 0x3F); + text[0] = 0xC0 | (char)((codepoint >> 6) & 0x1F); + text[1] = 0x80 | (char)(codepoint & 0x3F); text[2] = '\0'; } else if (codepoint <= 0xFFFF) { - text[0] = 0xE0 | (char) ((codepoint >> 12) & 0x0F); - text[1] = 0x80 | (char) ((codepoint >> 6) & 0x3F); - text[2] = 0x80 | (char) (codepoint & 0x3F); + text[0] = 0xE0 | (char)((codepoint >> 12) & 0x0F); + text[1] = 0x80 | (char)((codepoint >> 6) & 0x3F); + text[2] = 0x80 | (char)(codepoint & 0x3F); text[3] = '\0'; } else if (codepoint <= 0x10FFFF) { - text[0] = 0xF0 | (char) ((codepoint >> 18) & 0x0F); - text[1] = 0x80 | (char) ((codepoint >> 12) & 0x3F); - text[2] = 0x80 | (char) ((codepoint >> 6) & 0x3F); - text[3] = 0x80 | (char) (codepoint & 0x3F); + text[0] = 0xF0 | (char)((codepoint >> 18) & 0x0F); + text[1] = 0x80 | (char)((codepoint >> 12) & 0x3F); + text[2] = 0x80 | (char)((codepoint >> 6) & 0x3F); + text[3] = 0x80 | (char)(codepoint & 0x3F); text[4] = '\0'; } else { return SDL_FALSE; @@ -608,18 +604,15 @@ Emscripten_ConvertUTF32toUTF8(Uint32 codepoint, char * text) return SDL_TRUE; } -static EM_BOOL -Emscripten_HandlePointerLockChange(int eventType, const EmscriptenPointerlockChangeEvent *changeEvent, void *userData) +static EM_BOOL Emscripten_HandlePointerLockChange(int eventType, const EmscriptenPointerlockChangeEvent *changeEvent, void *userData) { - SDL_WindowData *window_data = (SDL_WindowData *) userData; + SDL_WindowData *window_data = (SDL_WindowData *)userData; /* keep track of lock losses, so we can regrab if/when appropriate. */ window_data->has_pointer_lock = changeEvent->isActive; return 0; } - -static EM_BOOL -Emscripten_HandleMouseMove(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) +static EM_BOOL Emscripten_HandleMouseMove(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) { SDL_WindowData *window_data = userData; const int isPointerLocked = window_data->has_pointer_lock; @@ -649,8 +642,7 @@ Emscripten_HandleMouseMove(int eventType, const EmscriptenMouseEvent *mouseEvent return 0; } -static EM_BOOL -Emscripten_HandleMouseButton(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) +static EM_BOOL Emscripten_HandleMouseButton(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) { SDL_WindowData *window_data = userData; Uint8 sdl_button; @@ -659,22 +651,22 @@ Emscripten_HandleMouseButton(int eventType, const EmscriptenMouseEvent *mouseEve double css_w, css_h; switch (mouseEvent->button) { - case 0: - sdl_button = SDL_BUTTON_LEFT; - break; - case 1: - sdl_button = SDL_BUTTON_MIDDLE; - break; - case 2: - sdl_button = SDL_BUTTON_RIGHT; - break; - default: - return 0; + case 0: + sdl_button = SDL_BUTTON_LEFT; + break; + case 1: + sdl_button = SDL_BUTTON_MIDDLE; + break; + case 2: + sdl_button = SDL_BUTTON_RIGHT; + break; + default: + return 0; } if (eventType == EMSCRIPTEN_EVENT_MOUSEDOWN) { if (SDL_GetMouse()->relative_mode && !window_data->has_pointer_lock) { - emscripten_request_pointerlock(window_data->canvas_id, 0); /* try to regrab lost pointer lock. */ + emscripten_request_pointerlock(window_data->canvas_id, 0); /* try to regrab lost pointer lock. */ } sdl_button_state = SDL_PRESSED; sdl_event_type = SDL_MOUSEBUTTONDOWN; @@ -694,8 +686,7 @@ Emscripten_HandleMouseButton(int eventType, const EmscriptenMouseEvent *mouseEve return SDL_GetEventState(sdl_event_type) == SDL_ENABLE; } -static EM_BOOL -Emscripten_HandleMouseFocus(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) +static EM_BOOL Emscripten_HandleMouseFocus(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) { SDL_WindowData *window_data = userData; @@ -716,31 +707,29 @@ Emscripten_HandleMouseFocus(int eventType, const EmscriptenMouseEvent *mouseEven return SDL_GetEventState(SDL_WINDOWEVENT) == SDL_ENABLE; } -static EM_BOOL -Emscripten_HandleWheel(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData) +static EM_BOOL Emscripten_HandleWheel(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData) { SDL_WindowData *window_data = userData; float deltaY = wheelEvent->deltaY; switch (wheelEvent->deltaMode) { - case DOM_DELTA_PIXEL: - deltaY /= 100; /* 100 pixels make up a step */ - break; - case DOM_DELTA_LINE: - deltaY /= 3; /* 3 lines make up a step */ - break; - case DOM_DELTA_PAGE: - deltaY *= 80; /* A page makes up 80 steps */ - break; + case DOM_DELTA_PIXEL: + deltaY /= 100; /* 100 pixels make up a step */ + break; + case DOM_DELTA_LINE: + deltaY /= 3; /* 3 lines make up a step */ + break; + case DOM_DELTA_PAGE: + deltaY *= 80; /* A page makes up 80 steps */ + break; } SDL_SendMouseWheel(window_data->window, 0, (float)wheelEvent->deltaX, -deltaY, SDL_MOUSEWHEEL_NORMAL); return SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE; } -static EM_BOOL -Emscripten_HandleFocus(int eventType, const EmscriptenFocusEvent *wheelEvent, void *userData) +static EM_BOOL Emscripten_HandleFocus(int eventType, const EmscriptenFocusEvent *wheelEvent, void *userData) { SDL_WindowData *window_data = userData; /* If the user switches away while keys are pressed (such as @@ -749,22 +738,20 @@ Emscripten_HandleFocus(int eventType, const EmscriptenFocusEvent *wheelEvent, vo SDL_ResetKeyboard(); } - SDL_SendWindowEvent(window_data->window, eventType == EMSCRIPTEN_EVENT_FOCUS ? SDL_WINDOWEVENT_FOCUS_GAINED : SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); return SDL_GetEventState(SDL_WINDOWEVENT) == SDL_ENABLE; } -static EM_BOOL -Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData) +static EM_BOOL Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData) { - SDL_WindowData *window_data = (SDL_WindowData *) userData; + SDL_WindowData *window_data = (SDL_WindowData *)userData; int i; double client_w, client_h; int preventDefault = 0; SDL_TouchID deviceId = 1; if (SDL_AddTouch(deviceId, SDL_TOUCH_DEVICE_DIRECT, "") < 0) { - return 0; + return 0; } emscripten_get_element_css_size(window_data->canvas_id, &client_w, &client_h); @@ -801,8 +788,7 @@ Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent *touchEvent, vo return preventDefault; } -static EM_BOOL -Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData) +static EM_BOOL Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData) { const SDL_Keycode keycode = Emscripten_MapKeyCode(keyEvent); SDL_Scancode scancode = Emscripten_MapScanCode(keyEvent->code); @@ -825,14 +811,14 @@ Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent *keyEvent, voi /* if TEXTINPUT events are enabled we can't prevent keydown or we won't get keypress * we need to ALWAYS prevent backspace and tab otherwise chrome takes action and does bad navigation UX */ - if ( (scancode == SDL_SCANCODE_BACKSPACE) || - (scancode == SDL_SCANCODE_TAB) || - (scancode == SDL_SCANCODE_LEFT) || - (scancode == SDL_SCANCODE_UP) || - (scancode == SDL_SCANCODE_RIGHT) || - (scancode == SDL_SCANCODE_DOWN) || - ((scancode >= SDL_SCANCODE_F1) && (scancode <= SDL_SCANCODE_F15)) || - keyEvent->ctrlKey ) { + if ((scancode == SDL_SCANCODE_BACKSPACE) || + (scancode == SDL_SCANCODE_TAB) || + (scancode == SDL_SCANCODE_LEFT) || + (scancode == SDL_SCANCODE_UP) || + (scancode == SDL_SCANCODE_RIGHT) || + (scancode == SDL_SCANCODE_DOWN) || + ((scancode >= SDL_SCANCODE_F1) && (scancode <= SDL_SCANCODE_F15)) || + keyEvent->ctrlKey) { is_nav_key = SDL_TRUE; } @@ -843,8 +829,7 @@ Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent *keyEvent, voi return prevent_default; } -static EM_BOOL -Emscripten_HandleKeyPress(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData) +static EM_BOOL Emscripten_HandleKeyPress(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData) { char text[5]; if (Emscripten_ConvertUTF32toUTF8(keyEvent->charCode, text)) { @@ -853,8 +838,7 @@ Emscripten_HandleKeyPress(int eventType, const EmscriptenKeyboardEvent *keyEvent return SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE; } -static EM_BOOL -Emscripten_HandleFullscreenChange(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent, void *userData) +static EM_BOOL Emscripten_HandleFullscreenChange(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent, void *userData) { SDL_WindowData *window_data = userData; SDL_VideoDisplay *display; @@ -877,8 +861,7 @@ Emscripten_HandleFullscreenChange(int eventType, const EmscriptenFullscreenChang return 0; } -static EM_BOOL -Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *uiEvent, void *userData) +static EM_BOOL Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *uiEvent, void *userData) { SDL_WindowData *window_data = userData; SDL_bool force = SDL_FALSE; @@ -909,9 +892,9 @@ Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *uiEvent, void *u } if (force) { - /* force the event to trigger, so pixel ratio changes can be handled */ - window_data->window->w = 0; - window_data->window->h = 0; + /* force the event to trigger, so pixel ratio changes can be handled */ + window_data->window->w = 0; + window_data->window->h = 0; } SDL_SendWindowEvent(window_data->window, SDL_WINDOWEVENT_RESIZED, w, h); @@ -936,16 +919,14 @@ Emscripten_HandleCanvasResize(int eventType, const void *reserved, void *userDat return 0; } -static EM_BOOL -Emscripten_HandleVisibilityChange(int eventType, const EmscriptenVisibilityChangeEvent *visEvent, void *userData) +static EM_BOOL Emscripten_HandleVisibilityChange(int eventType, const EmscriptenVisibilityChangeEvent *visEvent, void *userData) { SDL_WindowData *window_data = userData; SDL_SendWindowEvent(window_data->window, visEvent->hidden ? SDL_WINDOWEVENT_HIDDEN : SDL_WINDOWEVENT_SHOWN, 0, 0); return 0; } -static const char* -Emscripten_HandleBeforeUnload(int eventType, const void *reserved, void *userData) +static const char *Emscripten_HandleBeforeUnload(int eventType, const void *reserved, void *userData) { /* This event will need to be handled synchronously, e.g. using SDL_AddEventWatch, as the page is being closed *now*. */ @@ -954,8 +935,7 @@ Emscripten_HandleBeforeUnload(int eventType, const void *reserved, void *userDat return ""; /* don't trigger confirmation dialog */ } -void -Emscripten_RegisterEventHandlers(SDL_WindowData *data) +void Emscripten_RegisterEventHandlers(SDL_WindowData *data) { const char *keyElement; @@ -999,8 +979,7 @@ Emscripten_RegisterEventHandlers(SDL_WindowData *data) emscripten_set_beforeunload_callback(data, Emscripten_HandleBeforeUnload); } -void -Emscripten_UnregisterEventHandlers(SDL_WindowData *data) +void Emscripten_UnregisterEventHandlers(SDL_WindowData *data) { const char *target; diff --git a/src/video/emscripten/SDL_emscriptenevents.h b/src/video/emscripten/SDL_emscriptenevents.h index cc93e1a79..261a4f0b9 100644 --- a/src/video/emscripten/SDL_emscriptenevents.h +++ b/src/video/emscripten/SDL_emscriptenevents.h @@ -19,7 +19,6 @@ 3. This notice may not be removed or altered from any source distribution. */ - #ifndef SDL_emscriptenevents_h_ #define SDL_emscriptenevents_h_ @@ -37,4 +36,3 @@ Emscripten_HandleCanvasResize(int eventType, const void *reserved, void *userDat #endif /* SDL_emscriptenevents_h_ */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/video/emscripten/SDL_emscriptenframebuffer.c b/src/video/emscripten/SDL_emscriptenframebuffer.c index cb07a38f5..2e215d45d 100644 --- a/src/video/emscripten/SDL_emscriptenframebuffer.c +++ b/src/video/emscripten/SDL_emscriptenframebuffer.c @@ -28,8 +28,7 @@ #include - -int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch) +int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch) { SDL_Surface *surface; const Uint32 surface_format = SDL_PIXELFORMAT_BGR888; @@ -38,7 +37,7 @@ int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * form Uint32 Rmask, Gmask, Bmask, Amask; /* Free the old framebuffer surface */ - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; surface = data->surface; SDL_FreeSurface(surface); @@ -59,11 +58,11 @@ int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * form return 0; } -int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects) +int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects) { SDL_Surface *surface; - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; surface = data->surface; if (surface == NULL) { return SDL_SetError("Couldn't find framebuffer surface for window"); @@ -71,6 +70,7 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rec /* Send the data to the display */ + /* *INDENT-OFF* */ /* clang-format off */ MAIN_THREAD_EM_ASM({ var w = $0; var h = $1; @@ -166,9 +166,9 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rec return 0; } -void Emscripten_DestroyWindowFramebuffer(_THIS, SDL_Window * window) +void Emscripten_DestroyWindowFramebuffer(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_FreeSurface(data->surface); data->surface = NULL; diff --git a/src/video/emscripten/SDL_emscriptenframebuffer.h b/src/video/emscripten/SDL_emscriptenframebuffer.h index ec59281af..99cf7c6bc 100644 --- a/src/video/emscripten/SDL_emscriptenframebuffer.h +++ b/src/video/emscripten/SDL_emscriptenframebuffer.h @@ -23,9 +23,9 @@ #ifndef SDL_emscriptenframebuffer_h_ #define SDL_emscriptenframebuffer_h_ -extern int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch); -extern int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects); -extern void Emscripten_DestroyWindowFramebuffer(_THIS, SDL_Window * window); +extern int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch); +extern int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects); +extern void Emscripten_DestroyWindowFramebuffer(_THIS, SDL_Window *window); #endif /* SDL_emscriptenframebuffer_h_ */ diff --git a/src/video/emscripten/SDL_emscriptenmouse.c b/src/video/emscripten/SDL_emscriptenmouse.c index b172b9998..f1552a1c3 100644 --- a/src/video/emscripten/SDL_emscriptenmouse.c +++ b/src/video/emscripten/SDL_emscriptenmouse.c @@ -31,15 +31,14 @@ #include "../../events/SDL_mouse_c.h" -static SDL_Cursor* -Emscripten_CreateCursorFromString(const char* cursor_str, SDL_bool is_custom) +static SDL_Cursor *Emscripten_CreateCursorFromString(const char *cursor_str, SDL_bool is_custom) { - SDL_Cursor* cursor; + SDL_Cursor *cursor; Emscripten_CursorData *curdata; cursor = SDL_calloc(1, sizeof(SDL_Cursor)); if (cursor) { - curdata = (Emscripten_CursorData *) SDL_calloc(1, sizeof(*curdata)); + curdata = (Emscripten_CursorData *)SDL_calloc(1, sizeof(*curdata)); if (curdata == NULL) { SDL_OutOfMemory(); SDL_free(cursor); @@ -56,15 +55,12 @@ Emscripten_CreateCursorFromString(const char* cursor_str, SDL_bool is_custom) return cursor; } -static SDL_Cursor* -Emscripten_CreateDefaultCursor() +static SDL_Cursor *Emscripten_CreateDefaultCursor() { return Emscripten_CreateCursorFromString("default", SDL_FALSE); } - -static SDL_Cursor* -Emscripten_CreateCursor(SDL_Surface* surface, int hot_x, int hot_y) +static SDL_Cursor *Emscripten_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) { const char *cursor_url = NULL; SDL_Surface *conv_surf; @@ -75,6 +71,7 @@ Emscripten_CreateCursor(SDL_Surface* surface, int hot_x, int hot_y) return NULL; } + /* *INDENT-OFF* */ /* clang-format off */ cursor_url = (const char *)MAIN_THREAD_EM_ASM_INT({ var w = $0; var h = $1; @@ -124,68 +121,67 @@ Emscripten_CreateCursor(SDL_Surface* surface, int hot_x, int hot_y) return urlBuf; }, surface->w, surface->h, hot_x, hot_y, conv_surf->pixels); + /* *INDENT-ON* */ /* clang-format on */ SDL_FreeSurface(conv_surf); return Emscripten_CreateCursorFromString(cursor_url, SDL_TRUE); } -static SDL_Cursor* -Emscripten_CreateSystemCursor(SDL_SystemCursor id) +static SDL_Cursor *Emscripten_CreateSystemCursor(SDL_SystemCursor id) { const char *cursor_name = NULL; - switch(id) { - case SDL_SYSTEM_CURSOR_ARROW: - cursor_name = "default"; - break; - case SDL_SYSTEM_CURSOR_IBEAM: - cursor_name = "text"; - break; - case SDL_SYSTEM_CURSOR_WAIT: - cursor_name = "wait"; - break; - case SDL_SYSTEM_CURSOR_CROSSHAIR: - cursor_name = "crosshair"; - break; - case SDL_SYSTEM_CURSOR_WAITARROW: - cursor_name = "progress"; - break; - case SDL_SYSTEM_CURSOR_SIZENWSE: - cursor_name = "nwse-resize"; - break; - case SDL_SYSTEM_CURSOR_SIZENESW: - cursor_name = "nesw-resize"; - break; - case SDL_SYSTEM_CURSOR_SIZEWE: - cursor_name = "ew-resize"; - break; - case SDL_SYSTEM_CURSOR_SIZENS: - cursor_name = "ns-resize"; - break; - case SDL_SYSTEM_CURSOR_SIZEALL: - cursor_name = "move"; - break; - case SDL_SYSTEM_CURSOR_NO: - cursor_name = "not-allowed"; - break; - case SDL_SYSTEM_CURSOR_HAND: - cursor_name = "pointer"; - break; - default: - SDL_assert(0); - return NULL; + switch (id) { + case SDL_SYSTEM_CURSOR_ARROW: + cursor_name = "default"; + break; + case SDL_SYSTEM_CURSOR_IBEAM: + cursor_name = "text"; + break; + case SDL_SYSTEM_CURSOR_WAIT: + cursor_name = "wait"; + break; + case SDL_SYSTEM_CURSOR_CROSSHAIR: + cursor_name = "crosshair"; + break; + case SDL_SYSTEM_CURSOR_WAITARROW: + cursor_name = "progress"; + break; + case SDL_SYSTEM_CURSOR_SIZENWSE: + cursor_name = "nwse-resize"; + break; + case SDL_SYSTEM_CURSOR_SIZENESW: + cursor_name = "nesw-resize"; + break; + case SDL_SYSTEM_CURSOR_SIZEWE: + cursor_name = "ew-resize"; + break; + case SDL_SYSTEM_CURSOR_SIZENS: + cursor_name = "ns-resize"; + break; + case SDL_SYSTEM_CURSOR_SIZEALL: + cursor_name = "move"; + break; + case SDL_SYSTEM_CURSOR_NO: + cursor_name = "not-allowed"; + break; + case SDL_SYSTEM_CURSOR_HAND: + cursor_name = "pointer"; + break; + default: + SDL_assert(0); + return NULL; } return Emscripten_CreateCursorFromString(cursor_name, SDL_FALSE); } -static void -Emscripten_FreeCursor(SDL_Cursor* cursor) +static void Emscripten_FreeCursor(SDL_Cursor *cursor) { Emscripten_CursorData *curdata; if (cursor) { - curdata = (Emscripten_CursorData *) cursor->driverdata; + curdata = (Emscripten_CursorData *)cursor->driverdata; if (curdata != NULL) { if (curdata->is_custom) { @@ -198,40 +194,41 @@ Emscripten_FreeCursor(SDL_Cursor* cursor) } } -static int -Emscripten_ShowCursor(SDL_Cursor* cursor) +static int Emscripten_ShowCursor(SDL_Cursor *cursor) { Emscripten_CursorData *curdata; if (SDL_GetMouseFocus() != NULL) { if (cursor && cursor->driverdata) { - curdata = (Emscripten_CursorData *) cursor->driverdata; + curdata = (Emscripten_CursorData *)cursor->driverdata; if (curdata->system_cursor) { + /* *INDENT-OFF* */ /* clang-format off */ MAIN_THREAD_EM_ASM({ if (Module['canvas']) { Module['canvas'].style['cursor'] = UTF8ToString($0); } }, curdata->system_cursor); + /* *INDENT-ON* */ /* clang-format on */ } } else { + /* *INDENT-OFF* */ /* clang-format off */ MAIN_THREAD_EM_ASM( if (Module['canvas']) { Module['canvas'].style['cursor'] = 'none'; } ); + /* *INDENT-ON* */ /* clang-format on */ } } return 0; } -static void -Emscripten_WarpMouse(SDL_Window* window, int x, int y) +static void Emscripten_WarpMouse(SDL_Window *window, int x, int y) { SDL_Unsupported(); } -static int -Emscripten_SetRelativeMouseMode(SDL_bool enabled) +static int Emscripten_SetRelativeMouseMode(SDL_bool enabled) { SDL_Window *window; SDL_WindowData *window_data; @@ -243,7 +240,7 @@ Emscripten_SetRelativeMouseMode(SDL_bool enabled) return -1; } - window_data = (SDL_WindowData *) window->driverdata; + window_data = (SDL_WindowData *)window->driverdata; if (emscripten_request_pointerlock(window_data->canvas_id, 1) >= EMSCRIPTEN_RESULT_SUCCESS) { return 0; @@ -256,27 +253,24 @@ Emscripten_SetRelativeMouseMode(SDL_bool enabled) return -1; } -void -Emscripten_InitMouse() +void Emscripten_InitMouse() { - SDL_Mouse* mouse = SDL_GetMouse(); + SDL_Mouse *mouse = SDL_GetMouse(); - mouse->CreateCursor = Emscripten_CreateCursor; - mouse->ShowCursor = Emscripten_ShowCursor; - mouse->FreeCursor = Emscripten_FreeCursor; - mouse->WarpMouse = Emscripten_WarpMouse; - mouse->CreateSystemCursor = Emscripten_CreateSystemCursor; + mouse->CreateCursor = Emscripten_CreateCursor; + mouse->ShowCursor = Emscripten_ShowCursor; + mouse->FreeCursor = Emscripten_FreeCursor; + mouse->WarpMouse = Emscripten_WarpMouse; + mouse->CreateSystemCursor = Emscripten_CreateSystemCursor; mouse->SetRelativeMouseMode = Emscripten_SetRelativeMouseMode; SDL_SetDefaultCursor(Emscripten_CreateDefaultCursor()); } -void -Emscripten_FiniMouse() +void Emscripten_FiniMouse() { } #endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/video/emscripten/SDL_emscriptenmouse.h b/src/video/emscripten/SDL_emscriptenmouse.h index cfc36aee3..bf02ba3e1 100644 --- a/src/video/emscripten/SDL_emscriptenmouse.h +++ b/src/video/emscripten/SDL_emscriptenmouse.h @@ -19,7 +19,6 @@ 3. This notice may not be removed or altered from any source distribution. */ - #ifndef SDL_emscriptenmouse_h_ #define SDL_emscriptenmouse_h_ diff --git a/src/video/emscripten/SDL_emscriptenopengles.c b/src/video/emscripten/SDL_emscriptenopengles.c index 10c6285cf..9415c4e43 100644 --- a/src/video/emscripten/SDL_emscriptenopengles.c +++ b/src/video/emscripten/SDL_emscriptenopengles.c @@ -85,8 +85,7 @@ Emscripten_GLES_LoadLibrary(_THIS, const char *path) { SDL_EGL_CreateContext_impl(Emscripten) SDL_EGL_MakeCurrent_impl(Emscripten) -int -Emscripten_GLES_SwapWindow(_THIS, SDL_Window * window) +int Emscripten_GLES_SwapWindow(_THIS, SDL_Window *window) { EGLBoolean ret = SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface); if (emscripten_has_asyncify() && SDL_GetHintBoolean(SDL_HINT_EMSCRIPTEN_ASYNCIFY, SDL_TRUE)) { @@ -99,4 +98,3 @@ Emscripten_GLES_SwapWindow(_THIS, SDL_Window * window) #endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN && SDL_VIDEO_OPENGL_EGL */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/video/emscripten/SDL_emscriptenvideo.c b/src/video/emscripten/SDL_emscriptenvideo.c index 04c4fac6b..bba83d4b2 100644 --- a/src/video/emscripten/SDL_emscriptenvideo.c +++ b/src/video/emscripten/SDL_emscriptenvideo.c @@ -40,35 +40,32 @@ /* Initialization/Query functions */ static int Emscripten_VideoInit(_THIS); -static int Emscripten_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); +static int Emscripten_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode); static void Emscripten_VideoQuit(_THIS); -static int Emscripten_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect); -static int Emscripten_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi); +static int Emscripten_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect); +static int Emscripten_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi); -static int Emscripten_CreateWindow(_THIS, SDL_Window * window); -static void Emscripten_SetWindowSize(_THIS, SDL_Window * window); -static void Emscripten_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h); -static void Emscripten_DestroyWindow(_THIS, SDL_Window * window); -static void Emscripten_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen); +static int Emscripten_CreateWindow(_THIS, SDL_Window *window); +static void Emscripten_SetWindowSize(_THIS, SDL_Window *window); +static void Emscripten_GetWindowSizeInPixels(_THIS, SDL_Window *window, int *w, int *h); +static void Emscripten_DestroyWindow(_THIS, SDL_Window *window); +static void Emscripten_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen); static void Emscripten_PumpEvents(_THIS); -static void Emscripten_SetWindowTitle(_THIS, SDL_Window * window); - +static void Emscripten_SetWindowTitle(_THIS, SDL_Window *window); /* Emscripten driver bootstrap functions */ -static void -Emscripten_DeleteDevice(SDL_VideoDevice * device) +static void Emscripten_DeleteDevice(SDL_VideoDevice *device) { SDL_free(device); } -static SDL_VideoDevice * -Emscripten_CreateDevice(void) +static SDL_VideoDevice *Emscripten_CreateDevice(void) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device == NULL) { SDL_OutOfMemory(); return 0; @@ -77,7 +74,7 @@ Emscripten_CreateDevice(void) /* Firefox sends blur event which would otherwise prevent full screen * when the user clicks to allow full screen. * See https://bugzilla.mozilla.org/show_bug.cgi?id=1144964 - */ + */ SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); /* Set the function pointers */ @@ -87,7 +84,6 @@ Emscripten_CreateDevice(void) device->GetDisplayDPI = Emscripten_GetDisplayDPI; device->SetDisplayMode = Emscripten_SetDisplayMode; - device->PumpEvents = Emscripten_PumpEvents; device->CreateSDLWindow = Emscripten_CreateWindow; @@ -132,9 +128,7 @@ VideoBootStrap Emscripten_bootstrap = { Emscripten_CreateDevice }; - -int -Emscripten_VideoInit(_THIS) +int Emscripten_VideoInit(_THIS) { SDL_DisplayMode mode; @@ -156,21 +150,18 @@ Emscripten_VideoInit(_THIS) return 0; } -static int -Emscripten_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +static int Emscripten_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) { /* can't do this */ return 0; } -static void -Emscripten_VideoQuit(_THIS) +static void Emscripten_VideoQuit(_THIS) { Emscripten_FiniMouse(); } -static int -Emscripten_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect) +static int Emscripten_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) { if (rect) { rect->x = 0; @@ -185,8 +176,7 @@ Emscripten_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * return 0; } -static int -Emscripten_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi_out, float * hdpi_out, float * vdpi_out) +static int Emscripten_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi_out, float *hdpi_out, float *vdpi_out) { const float dpi_reference = 96.0f; float dpi; @@ -206,21 +196,19 @@ Emscripten_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi_out, fl return 0; } -static void -Emscripten_PumpEvents(_THIS) +static void Emscripten_PumpEvents(_THIS) { /* do nothing. */ } -static int -Emscripten_CreateWindow(_THIS, SDL_Window * window) +static int Emscripten_CreateWindow(_THIS, SDL_Window *window) { SDL_WindowData *wdata; double scaled_w, scaled_h; double css_w, css_h; /* Allocate window internal data */ - wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); + wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); if (wdata == NULL) { return SDL_OutOfMemory(); } @@ -289,12 +277,12 @@ Emscripten_CreateWindow(_THIS, SDL_Window * window) return 0; } -static void Emscripten_SetWindowSize(_THIS, SDL_Window * window) +static void Emscripten_SetWindowSize(_THIS, SDL_Window *window) { SDL_WindowData *data; if (window->driverdata) { - data = (SDL_WindowData *) window->driverdata; + data = (SDL_WindowData *)window->driverdata; /* update pixel ratio */ if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) { data->pixel_ratio = emscripten_get_device_pixel_ratio(); @@ -308,25 +296,22 @@ static void Emscripten_SetWindowSize(_THIS, SDL_Window * window) } } - -static void -Emscripten_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h) +static void Emscripten_GetWindowSizeInPixels(_THIS, SDL_Window *window, int *w, int *h) { SDL_WindowData *data; if (window->driverdata) { - data = (SDL_WindowData *) window->driverdata; + data = (SDL_WindowData *)window->driverdata; *w = window->w * data->pixel_ratio; *h = window->h * data->pixel_ratio; } } -static void -Emscripten_DestroyWindow(_THIS, SDL_Window * window) +static void Emscripten_DestroyWindow(_THIS, SDL_Window *window) { SDL_WindowData *data; if (window->driverdata) { - data = (SDL_WindowData *) window->driverdata; + data = (SDL_WindowData *)window->driverdata; Emscripten_UnregisterEventHandlers(data); #if SDL_VIDEO_OPENGL_EGL @@ -345,12 +330,11 @@ Emscripten_DestroyWindow(_THIS, SDL_Window * window) } } -static void -Emscripten_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen) +static void Emscripten_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen) { SDL_WindowData *data; if (window->driverdata) { - data = (SDL_WindowData *) window->driverdata; + data = (SDL_WindowData *)window->driverdata; if (fullscreen) { EmscriptenFullscreenStrategy strategy; @@ -385,8 +369,8 @@ Emscripten_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * di } } -static void -Emscripten_SetWindowTitle(_THIS, SDL_Window * window) { +static void Emscripten_SetWindowTitle(_THIS, SDL_Window *window) +{ emscripten_set_window_title(window->title); } diff --git a/src/video/haiku/SDL_BApp.h b/src/video/haiku/SDL_BApp.h index 215f83662..416ebbb2d 100644 --- a/src/video/haiku/SDL_BApp.h +++ b/src/video/haiku/SDL_BApp.h @@ -30,7 +30,6 @@ #include "../../video/haiku/SDL_bkeyboard.h" - #ifdef __cplusplus extern "C" { #endif @@ -49,65 +48,63 @@ extern "C" { #include - - - /* Forward declarations */ class SDL_BWin; /* Message constants */ -enum ToSDL { +enum ToSDL +{ /* Intercepted by BWindow on its way to BView */ BAPP_MOUSE_MOVED, BAPP_MOUSE_BUTTON, BAPP_MOUSE_WHEEL, BAPP_KEY, - BAPP_REPAINT, /* from _UPDATE_ */ + BAPP_REPAINT, /* from _UPDATE_ */ /* From BWindow */ - BAPP_MAXIMIZE, /* from B_ZOOM */ + BAPP_MAXIMIZE, /* from B_ZOOM */ BAPP_MINIMIZE, - BAPP_RESTORE, /* TODO: IMPLEMENT! */ + BAPP_RESTORE, /* TODO: IMPLEMENT! */ BAPP_SHOW, BAPP_HIDE, - BAPP_MOUSE_FOCUS, /* caused by MOUSE_MOVE */ - BAPP_KEYBOARD_FOCUS, /* from WINDOW_ACTIVATED */ + BAPP_MOUSE_FOCUS, /* caused by MOUSE_MOVE */ + BAPP_KEYBOARD_FOCUS, /* from WINDOW_ACTIVATED */ BAPP_WINDOW_CLOSE_REQUESTED, BAPP_WINDOW_MOVED, BAPP_WINDOW_RESIZED, BAPP_SCREEN_CHANGED }; - - /* Create a descendant of BApplication */ -class SDL_BApp : public BApplication { -public: - SDL_BApp(const char* signature) : - BApplication(signature) { +class SDL_BApp : public BApplication +{ + public: + SDL_BApp(const char *signature) : BApplication(signature) + { #if SDL_VIDEO_OPENGL _current_context = NULL; #endif } - - virtual ~SDL_BApp() { + virtual ~SDL_BApp() + { } + virtual void RefsReceived(BMessage *message) + { + char filePath[512]; + entry_ref entryRef; + for (int32 i = 0; message->FindRef("refs", i, &entryRef) == B_OK; i++) { + BPath referencePath = BPath(&entryRef); + SDL_SendDropFile(NULL, referencePath.Path()); + } + return; + } - virtual void RefsReceived(BMessage* message) { - char filePath[512]; - entry_ref entryRef; - for (int32 i = 0; message->FindRef("refs", i, &entryRef) == B_OK; i++) { - BPath referencePath = BPath(&entryRef); - SDL_SendDropFile(NULL, referencePath.Path()); - } - return; - } - - /* Event-handling functions */ - virtual void MessageReceived(BMessage* message) { + /* Event-handling functions */ + virtual void MessageReceived(BMessage *message) + { /* Sort out SDL-related messages */ - switch ( message->what ) { + switch (message->what) { case BAPP_MOUSE_MOVED: _HandleMouseMove(message); break; @@ -173,23 +170,24 @@ public: break; default: - BApplication::MessageReceived(message); - break; + BApplication::MessageReceived(message); + break; } } /* Window creation/destruction methods */ - int32 GetID(SDL_Window *win) { + int32 GetID(SDL_Window *win) + { int32 i; - for(i = 0; i < _GetNumWindowSlots(); ++i) { - if( GetSDLWindow(i) == NULL ) { + for (i = 0; i < _GetNumWindowSlots(); ++i) { + if (GetSDLWindow(i) == NULL) { _SetSDLWindow(win, i); return i; } } /* Expand the vector if all slots are full */ - if( i == _GetNumWindowSlots() ) { + if (i == _GetNumWindowSlots()) { _PushBackWindow(win); return i; } @@ -202,18 +200,20 @@ public: there another way to do this? */ void ClearID(SDL_BWin *bwin); /* Defined in SDL_BeApp.cc */ - - SDL_Window *GetSDLWindow(int32 winID) { + SDL_Window *GetSDLWindow(int32 winID) + { return _window_map[winID]; } #if SDL_VIDEO_OPENGL - BGLView *GetCurrentContext() { + BGLView *GetCurrentContext() + { return _current_context; } - - void SetCurrentContext(BGLView *newContext) { - if(_current_context) + + void SetCurrentContext(BGLView *newContext) + { + if (_current_context) _current_context->UnlockGL(); _current_context = newContext; if (_current_context) @@ -221,25 +221,26 @@ public: } #endif -private: + private: /* Event management */ - void _HandleBasicWindowEvent(BMessage *msg, int32 sdlEventType) { + void _HandleBasicWindowEvent(BMessage *msg, int32 sdlEventType) + { SDL_Window *win; int32 winID; - if( - !_GetWinID(msg, &winID) - ) { + if ( + !_GetWinID(msg, &winID)) { return; } win = GetSDLWindow(winID); SDL_SendWindowEvent(win, sdlEventType, 0, 0); } - void _HandleMouseMove(BMessage *msg) { + void _HandleMouseMove(BMessage *msg) + { SDL_Window *win; int32 winID; int32 x = 0, y = 0; - if( + if ( !_GetWinID(msg, &winID) || msg->FindInt32("x", &x) != B_OK || /* x movement */ msg->FindInt32("y", &y) != B_OK /* y movement */ @@ -266,47 +267,47 @@ private: } } - void _HandleMouseButton(BMessage *msg) { + void _HandleMouseButton(BMessage *msg) + { SDL_Window *win; int32 winID; - int32 button, state; /* left/middle/right, pressed/released */ - if( + int32 button, state; /* left/middle/right, pressed/released */ + if ( !_GetWinID(msg, &winID) || msg->FindInt32("button-id", &button) != B_OK || - msg->FindInt32("button-state", &state) != B_OK - ) { + msg->FindInt32("button-state", &state) != B_OK) { return; } win = GetSDLWindow(winID); SDL_SendMouseButton(win, 0, state, button); } - void _HandleMouseWheel(BMessage *msg) { + void _HandleMouseWheel(BMessage *msg) + { SDL_Window *win; int32 winID; int32 xTicks, yTicks; - if( + if ( !_GetWinID(msg, &winID) || msg->FindInt32("xticks", &xTicks) != B_OK || - msg->FindInt32("yticks", &yTicks) != B_OK - ) { + msg->FindInt32("yticks", &yTicks) != B_OK) { return; } win = GetSDLWindow(winID); SDL_SendMouseWheel(win, 0, xTicks, -yTicks, SDL_MOUSEWHEEL_NORMAL); } - void _HandleKey(BMessage *msg) { - int32 scancode, state; /* scancode, pressed/released */ - if( + void _HandleKey(BMessage *msg) + { + int32 scancode, state; /* scancode, pressed/released */ + if ( msg->FindInt32("key-state", &state) != B_OK || - msg->FindInt32("key-scancode", &scancode) != B_OK - ) { + msg->FindInt32("key-scancode", &scancode) != B_OK) { return; } /* Make sure this isn't a repeated event (key pressed and held) */ - if(state == SDL_PRESSED && HAIKU_GetKeyState(scancode) == SDL_PRESSED) { + if (state == SDL_PRESSED && HAIKU_GetKeyState(scancode) == SDL_PRESSED) { return; } HAIKU_SetKeyState(scancode, state); @@ -315,7 +316,7 @@ private: if (state == SDL_PRESSED && SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { const int8 *keyUtf8; ssize_t count; - if (msg->FindData("key-utf8", B_INT8_TYPE, (const void**)&keyUtf8, &count) == B_OK) { + if (msg->FindData("key-utf8", B_INT8_TYPE, (const void **)&keyUtf8, &count) == B_OK) { char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; SDL_zeroa(text); SDL_memcpy(text, keyUtf8, count); @@ -324,107 +325,108 @@ private: } } - void _HandleMouseFocus(BMessage *msg) { + void _HandleMouseFocus(BMessage *msg) + { SDL_Window *win; int32 winID; bool bSetFocus; /* If false, lose focus */ - if( + if ( !_GetWinID(msg, &winID) || - msg->FindBool("focusGained", &bSetFocus) != B_OK - ) { + msg->FindBool("focusGained", &bSetFocus) != B_OK) { return; } win = GetSDLWindow(winID); - if(bSetFocus) { + if (bSetFocus) { SDL_SetMouseFocus(win); - } else if(SDL_GetMouseFocus() == win) { + } else if (SDL_GetMouseFocus() == win) { /* Only lose all focus if this window was the current focus */ SDL_SetMouseFocus(NULL); } } - void _HandleKeyboardFocus(BMessage *msg) { + void _HandleKeyboardFocus(BMessage *msg) + { SDL_Window *win; int32 winID; bool bSetFocus; /* If false, lose focus */ - if( + if ( !_GetWinID(msg, &winID) || - msg->FindBool("focusGained", &bSetFocus) != B_OK - ) { + msg->FindBool("focusGained", &bSetFocus) != B_OK) { return; } win = GetSDLWindow(winID); - if(bSetFocus) { + if (bSetFocus) { SDL_SetKeyboardFocus(win); - } else if(SDL_GetKeyboardFocus() == win) { + } else if (SDL_GetKeyboardFocus() == win) { /* Only lose all focus if this window was the current focus */ SDL_SetKeyboardFocus(NULL); } } - void _HandleWindowMoved(BMessage *msg) { + void _HandleWindowMoved(BMessage *msg) + { SDL_Window *win; int32 winID; int32 xPos, yPos; /* Get the window id and new x/y position of the window */ - if( + if ( !_GetWinID(msg, &winID) || msg->FindInt32("window-x", &xPos) != B_OK || - msg->FindInt32("window-y", &yPos) != B_OK - ) { + msg->FindInt32("window-y", &yPos) != B_OK) { return; } win = GetSDLWindow(winID); SDL_SendWindowEvent(win, SDL_WINDOWEVENT_MOVED, xPos, yPos); } - void _HandleWindowResized(BMessage *msg) { + void _HandleWindowResized(BMessage *msg) + { SDL_Window *win; int32 winID; int32 w, h; /* Get the window id ]and new x/y position of the window */ - if( + if ( !_GetWinID(msg, &winID) || msg->FindInt32("window-w", &w) != B_OK || - msg->FindInt32("window-h", &h) != B_OK - ) { + msg->FindInt32("window-h", &h) != B_OK) { return; } win = GetSDLWindow(winID); SDL_SendWindowEvent(win, SDL_WINDOWEVENT_RESIZED, w, h); } - bool _GetWinID(BMessage *msg, int32 *winID) { + bool _GetWinID(BMessage *msg, int32 *winID) + { return msg->FindInt32("window-id", winID) == B_OK; } - - /* Vector functions: Wraps vector stuff in case we need to change implementation */ - void _SetSDLWindow(SDL_Window *win, int32 winID) { + void _SetSDLWindow(SDL_Window *win, int32 winID) + { _window_map[winID] = win; } - int32 _GetNumWindowSlots() { + int32 _GetNumWindowSlots() + { return _window_map.size(); } - - void _PopBackWindow() { + void _PopBackWindow() + { _window_map.pop_back(); } - void _PushBackWindow(SDL_Window *win) { + void _PushBackWindow(SDL_Window *win) + { _window_map.push_back(win); } - /* Members */ - std::vector _window_map; /* Keeps track of SDL_Windows by index-id */ + std::vector _window_map; /* Keeps track of SDL_Windows by index-id */ #if SDL_VIDEO_OPENGL - BGLView *_current_context; + BGLView *_current_context; #endif }; diff --git a/src/video/haiku/SDL_BWin.h b/src/video/haiku/SDL_BWin.h index 1ac517164..f4d528d6b 100644 --- a/src/video/haiku/SDL_BWin.h +++ b/src/video/haiku/SDL_BWin.h @@ -45,8 +45,8 @@ extern "C" { #include "SDL_events.h" #include "../../main/haiku/SDL_BApp.h" - -enum WinCommands { +enum WinCommands +{ BWIN_MOVE_WINDOW, BWIN_RESIZE_WINDOW, BWIN_SHOW_WINDOW, @@ -63,12 +63,12 @@ enum WinCommands { }; // non-OpenGL framebuffer view -class SDL_BView: public BView +class SDL_BView : public BView { -public: - SDL_BView(BRect frame, const char* name, uint32 resizingMode) + public: + SDL_BView(BRect frame, const char *name, uint32 resizingMode) : BView(frame, name, resizingMode, B_WILL_DRAW), - fBitmap(NULL) + fBitmap(NULL) { } @@ -83,11 +83,11 @@ public: fBitmap = bitmap; } -private: + private: BBitmap *fBitmap; }; -class SDL_BWin: public BWindow +class SDL_BWin : public BWindow { public: /* Constructor/Destructor */ @@ -114,10 +114,10 @@ class SDL_BWin: public BWindow _bitmap = NULL; } - virtual ~ SDL_BWin() + virtual ~SDL_BWin() { Lock(); - + if (_SDL_View != NULL && _SDL_View != _cur_view) { delete _SDL_View; _SDL_View = NULL; @@ -125,8 +125,8 @@ class SDL_BWin: public BWindow #if SDL_VIDEO_OPENGL if (_SDL_GLView) { - if (((SDL_BApp*)be_app)->GetCurrentContext() == _SDL_GLView) - ((SDL_BApp*)be_app)->SetCurrentContext(NULL); + if (((SDL_BApp *)be_app)->GetCurrentContext() == _SDL_GLView) + ((SDL_BApp *)be_app)->SetCurrentContext(NULL); if (_SDL_GLView == _cur_view) RemoveChild(_SDL_GLView); _SDL_GLView = NULL; @@ -142,7 +142,7 @@ class SDL_BWin: public BWindow _buffer_locker->Lock(); delete _buffer_locker; } - + void SetCurrentView(BView *view) { if (_cur_view != view) { @@ -165,7 +165,8 @@ class SDL_BWin: public BWindow } } - SDL_BView *CreateView() { + SDL_BView *CreateView() + { Lock(); if (_SDL_View == NULL) { _SDL_View = new SDL_BView(Bounds(), "SDL View", B_FOLLOW_ALL_SIDES); @@ -175,9 +176,10 @@ class SDL_BWin: public BWindow return _SDL_View; } - void RemoveView() { + void RemoveView() + { Lock(); - if(_SDL_View != NULL) { + if (_SDL_View != NULL) { SDL_BView *oldView = _SDL_View; _SDL_View = NULL; UpdateCurrentView(); @@ -188,13 +190,14 @@ class SDL_BWin: public BWindow /* * * * * OpenGL functionality * * * * */ #if SDL_VIDEO_OPENGL - BGLView *CreateGLView(Uint32 gl_flags) { + BGLView *CreateGLView(Uint32 gl_flags) + { Lock(); if (_SDL_GLView == NULL) { _SDL_GLView = new BGLView(Bounds(), "SDL GLView", - B_FOLLOW_ALL_SIDES, - (B_WILL_DRAW | B_FRAME_EVENTS), - gl_flags); + B_FOLLOW_ALL_SIDES, + (B_WILL_DRAW | B_FRAME_EVENTS), + gl_flags); _gl_type = gl_flags; UpdateCurrentView(); } @@ -202,11 +205,12 @@ class SDL_BWin: public BWindow return _SDL_GLView; } - void RemoveGLView() { + void RemoveGLView() + { Lock(); - if(_SDL_GLView != NULL) { - if (((SDL_BApp*)be_app)->GetCurrentContext() == _SDL_GLView) - ((SDL_BApp*)be_app)->SetCurrentContext(NULL); + if (_SDL_GLView != NULL) { + if (((SDL_BApp *)be_app)->GetCurrentContext() == _SDL_GLView) + ((SDL_BApp *)be_app)->SetCurrentContext(NULL); _SDL_GLView = NULL; UpdateCurrentView(); // _SDL_GLView deleted by HAIKU_GL_DeleteContext @@ -214,14 +218,16 @@ class SDL_BWin: public BWindow Unlock(); } - void SwapBuffers(void) { + void SwapBuffers(void) + { _SDL_GLView->SwapBuffers(); } #endif /* * * * * Event sending * * * * */ /* Hook functions */ - virtual void FrameMoved(BPoint origin) { + virtual void FrameMoved(BPoint origin) + { /* Post a message to the BApp so that it can handle the window event */ BMessage msg(BAPP_WINDOW_MOVED); msg.AddInt32("window-x", (int)origin.x); @@ -232,7 +238,8 @@ class SDL_BWin: public BWindow BWindow::FrameMoved(origin); } - void FrameResized(float width, float height) { + void FrameResized(float width, float height) + { /* Post a message to the BApp so that it can handle the window event */ BMessage msg(BAPP_WINDOW_RESIZED); @@ -244,7 +251,8 @@ class SDL_BWin: public BWindow BWindow::FrameResized(width, height); } - bool QuitRequested() { + bool QuitRequested() + { BMessage msg(BAPP_WINDOW_CLOSE_REQUESTED); _PostWindowEvent(msg); @@ -252,20 +260,22 @@ class SDL_BWin: public BWindow return false; } - void WindowActivated(bool active) { - BMessage msg(BAPP_KEYBOARD_FOCUS); /* Mouse focus sold separately */ + void WindowActivated(bool active) + { + BMessage msg(BAPP_KEYBOARD_FOCUS); /* Mouse focus sold separately */ msg.AddBool("focusGained", active); _PostWindowEvent(msg); } void Zoom(BPoint origin, - float width, - float height) { - BMessage msg(BAPP_MAXIMIZE); /* Closest thing to maximization Haiku has */ + float width, + float height) + { + BMessage msg(BAPP_MAXIMIZE); /* Closest thing to maximization Haiku has */ _PostWindowEvent(msg); /* Before the window zooms, record its size */ - if( !_prev_frame ) + if (!_prev_frame) _prev_frame = new BRect(Frame()); /* Perform normal hook operations */ @@ -273,8 +283,9 @@ class SDL_BWin: public BWindow } /* Member functions */ - void Show() { - while(IsHidden()) { + void Show() + { + while (IsHidden()) { BWindow::Show(); } _shown = true; @@ -283,7 +294,8 @@ class SDL_BWin: public BWindow _PostWindowEvent(msg); } - void Hide() { + void Hide() + { BWindow::Hide(); _shown = false; @@ -291,7 +303,8 @@ class SDL_BWin: public BWindow _PostWindowEvent(msg); } - void Minimize(bool minimize) { + void Minimize(bool minimize) + { BWindow::Minimize(minimize); int32 minState = (minimize ? BAPP_MINIMIZE : BAPP_RESTORE); @@ -307,19 +320,17 @@ class SDL_BWin: public BWindow } } - /* BView message interruption */ - void DispatchMessage(BMessage * msg, BHandler * target) + void DispatchMessage(BMessage *msg, BHandler *target) { - BPoint where; /* Used by mouse moved */ - int32 buttons; /* Used for mouse button events */ - int32 key; /* Used for key events */ + BPoint where; /* Used by mouse moved */ + int32 buttons; /* Used for mouse button events */ + int32 key; /* Used for key events */ switch (msg->what) { case B_MOUSE_MOVED: int32 transit; - if (msg->FindPoint("where", &where) == B_OK - && msg->FindInt32("be:transit", &transit) == B_OK) { + if (msg->FindPoint("where", &where) == B_OK && msg->FindInt32("be:transit", &transit) == B_OK) { _MouseMotionEvent(where, transit); } break; @@ -338,35 +349,33 @@ class SDL_BWin: public BWindow case B_MOUSE_WHEEL_CHANGED: float x, y; - if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK - && msg->FindFloat("be:wheel_delta_y", &y) == B_OK) { - _MouseWheelEvent((int)x, (int)y); + if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK && msg->FindFloat("be:wheel_delta_y", &y) == B_OK) { + _MouseWheelEvent((int)x, (int)y); } break; case B_KEY_DOWN: - { - int32 i = 0; - int8 byte; - int8 bytes[4] = { 0, 0, 0, 0 }; - while (i < 4 && msg->FindInt8("byte", i, &byte) == B_OK) { - bytes[i] = byte; - i++; - } - if (msg->FindInt32("key", &key) == B_OK) { - _KeyEvent((SDL_Scancode)key, &bytes[0], i, SDL_PRESSED); - } + { + int32 i = 0; + int8 byte; + int8 bytes[4] = { 0, 0, 0, 0 }; + while (i < 4 && msg->FindInt8("byte", i, &byte) == B_OK) { + bytes[i] = byte; + i++; } - break; + if (msg->FindInt32("key", &key) == B_OK) { + _KeyEvent((SDL_Scancode)key, &bytes[0], i, SDL_PRESSED); + } + } break; - case B_UNMAPPED_KEY_DOWN: /* modifier keys are unmapped */ + case B_UNMAPPED_KEY_DOWN: /* modifier keys are unmapped */ if (msg->FindInt32("key", &key) == B_OK) { _KeyEvent((SDL_Scancode)key, NULL, 0, SDL_PRESSED); } break; case B_KEY_UP: - case B_UNMAPPED_KEY_UP: /* modifier keys are unmapped */ + case B_UNMAPPED_KEY_UP: /* modifier keys are unmapped */ if (msg->FindInt32("key", &key) == B_OK) { _KeyEvent(key, NULL, 0, SDL_RELEASED); } @@ -386,80 +395,81 @@ class SDL_BWin: public BWindow } /* Handle command messages */ - void MessageReceived(BMessage* message) { + void MessageReceived(BMessage *message) + { switch (message->what) { - /* Handle commands from SDL */ - case BWIN_SET_TITLE: - _SetTitle(message); - break; - case BWIN_MOVE_WINDOW: - _MoveTo(message); - break; - case BWIN_RESIZE_WINDOW: - _ResizeTo(message); - break; - case BWIN_SET_BORDERED: { - bool bEnabled; - if (message->FindBool("window-border", &bEnabled) == B_OK) - _SetBordered(bEnabled); - break; - } - case BWIN_SET_RESIZABLE: { - bool bEnabled; - if (message->FindBool("window-resizable", &bEnabled) == B_OK) - _SetResizable(bEnabled); - break; - } - case BWIN_SHOW_WINDOW: - Show(); - break; - case BWIN_HIDE_WINDOW: - Hide(); - break; - case BWIN_MAXIMIZE_WINDOW: - BWindow::Zoom(); - break; - case BWIN_MINIMIZE_WINDOW: - Minimize(true); - break; - case BWIN_RESTORE_WINDOW: - _Restore(); - break; - case BWIN_FULLSCREEN: { - bool fullscreen; - if (message->FindBool("fullscreen", &fullscreen) == B_OK) - _SetFullScreen(fullscreen); - break; - } - case BWIN_MINIMUM_SIZE_WINDOW: - _SetMinimumSize(message); - break; - case BWIN_UPDATE_FRAMEBUFFER: { - BMessage* pendingMessage; - while ((pendingMessage - = MessageQueue()->FindMessage(BWIN_UPDATE_FRAMEBUFFER, 0))) { - MessageQueue()->RemoveMessage(pendingMessage); - delete pendingMessage; - } - if (_bitmap != NULL) { - if (_SDL_View != NULL && _cur_view == _SDL_View) - _SDL_View->Draw(Bounds()); - else if (_SDL_GLView != NULL && _cur_view == _SDL_GLView) { - _SDL_GLView->CopyPixelsIn(_bitmap, B_ORIGIN); - } - } - break; - } - default: - /* Perform normal message handling */ - BWindow::MessageReceived(message); - break; + /* Handle commands from SDL */ + case BWIN_SET_TITLE: + _SetTitle(message); + break; + case BWIN_MOVE_WINDOW: + _MoveTo(message); + break; + case BWIN_RESIZE_WINDOW: + _ResizeTo(message); + break; + case BWIN_SET_BORDERED: + { + bool bEnabled; + if (message->FindBool("window-border", &bEnabled) == B_OK) + _SetBordered(bEnabled); + break; + } + case BWIN_SET_RESIZABLE: + { + bool bEnabled; + if (message->FindBool("window-resizable", &bEnabled) == B_OK) + _SetResizable(bEnabled); + break; + } + case BWIN_SHOW_WINDOW: + Show(); + break; + case BWIN_HIDE_WINDOW: + Hide(); + break; + case BWIN_MAXIMIZE_WINDOW: + BWindow::Zoom(); + break; + case BWIN_MINIMIZE_WINDOW: + Minimize(true); + break; + case BWIN_RESTORE_WINDOW: + _Restore(); + break; + case BWIN_FULLSCREEN: + { + bool fullscreen; + if (message->FindBool("fullscreen", &fullscreen) == B_OK) + _SetFullScreen(fullscreen); + break; + } + case BWIN_MINIMUM_SIZE_WINDOW: + _SetMinimumSize(message); + break; + case BWIN_UPDATE_FRAMEBUFFER: + { + BMessage *pendingMessage; + while ((pendingMessage = MessageQueue()->FindMessage(BWIN_UPDATE_FRAMEBUFFER, 0))) { + MessageQueue()->RemoveMessage(pendingMessage); + delete pendingMessage; + } + if (_bitmap != NULL) { + if (_SDL_View != NULL && _cur_view == _SDL_View) + _SDL_View->Draw(Bounds()); + else if (_SDL_GLView != NULL && _cur_view == _SDL_GLView) { + _SDL_GLView->CopyPixelsIn(_bitmap, B_ORIGIN); + } + } + break; + } + default: + /* Perform normal message handling */ + BWindow::MessageReceived(message); + break; } - } - - /* Accessor methods */ bool IsShown() { return _shown; } int32 GetID() { return _id; } @@ -467,7 +477,10 @@ class SDL_BWin: public BWindow BView *GetCurView() { return _cur_view; } SDL_BView *GetView() { return _SDL_View; } #if SDL_VIDEO_OPENGL - BGLView *GetGLView() { return _SDL_GLView; } + BGLView *GetGLView() + { + return _SDL_GLView; + } Uint32 GetGLType() { return _gl_type; } #endif @@ -475,15 +488,20 @@ class SDL_BWin: public BWindow void SetID(int32 id) { _id = id; } void LockBuffer() { _buffer_locker->Lock(); } void UnlockBuffer() { _buffer_locker->Unlock(); } - void SetBitmap(BBitmap *bitmap) { _bitmap = bitmap; if (_SDL_View != NULL) _SDL_View->SetBitmap(bitmap); } + void SetBitmap(BBitmap *bitmap) + { + _bitmap = bitmap; + if (_SDL_View != NULL) + _SDL_View->SetBitmap(bitmap); + } - -private: + private: /* Event redirection */ - void _MouseMotionEvent(BPoint &where, int32 transit) { - if(transit == B_EXITED_VIEW) { + void _MouseMotionEvent(BPoint &where, int32 transit) + { + if (transit == B_EXITED_VIEW) { /* Change mouse focus */ - if(_mouse_focused) { + if (_mouse_focused) { _MouseFocusEvent(false); } } else { @@ -499,41 +517,45 @@ private: } } - void _MouseFocusEvent(bool focusGained) { + void _MouseFocusEvent(bool focusGained) + { _mouse_focused = focusGained; BMessage msg(BAPP_MOUSE_FOCUS); msg.AddBool("focusGained", focusGained); _PostWindowEvent(msg); -/* FIXME: Why were these here? - if false: be_app->SetCursor(B_HAND_CURSOR); - if true: SDL_SetCursor(NULL); */ + /* FIXME: Why were these here? + if false: be_app->SetCursor(B_HAND_CURSOR); + if true: SDL_SetCursor(NULL); */ } - void _MouseButtonEvent(int32 buttons, Uint8 state) { + void _MouseButtonEvent(int32 buttons, Uint8 state) + { int32 buttonStateChange = buttons ^ _last_buttons; - if(buttonStateChange & B_PRIMARY_MOUSE_BUTTON) { + if (buttonStateChange & B_PRIMARY_MOUSE_BUTTON) { _SendMouseButton(SDL_BUTTON_LEFT, state); } - if(buttonStateChange & B_SECONDARY_MOUSE_BUTTON) { + if (buttonStateChange & B_SECONDARY_MOUSE_BUTTON) { _SendMouseButton(SDL_BUTTON_RIGHT, state); } - if(buttonStateChange & B_TERTIARY_MOUSE_BUTTON) { + if (buttonStateChange & B_TERTIARY_MOUSE_BUTTON) { _SendMouseButton(SDL_BUTTON_MIDDLE, state); } _last_buttons = buttons; } - void _SendMouseButton(int32 button, int32 state) { + void _SendMouseButton(int32 button, int32 state) + { BMessage msg(BAPP_MOUSE_BUTTON); msg.AddInt32("button-id", button); msg.AddInt32("button-state", state); _PostWindowEvent(msg); } - void _MouseWheelEvent(int32 x, int32 y) { + void _MouseWheelEvent(int32 x, int32 y) + { /* Create a message to pass along to the BeApp thread */ BMessage msg(BAPP_MOUSE_WHEEL); msg.AddInt32("xticks", x); @@ -541,44 +563,47 @@ private: _PostWindowEvent(msg); } - void _KeyEvent(int32 keyCode, const int8 *keyUtf8, const ssize_t & len, int32 keyState) { + void _KeyEvent(int32 keyCode, const int8 *keyUtf8, const ssize_t &len, int32 keyState) + { /* Create a message to pass along to the BeApp thread */ BMessage msg(BAPP_KEY); msg.AddInt32("key-state", keyState); msg.AddInt32("key-scancode", keyCode); if (keyUtf8 != NULL) { - msg.AddData("key-utf8", B_INT8_TYPE, (const void*)keyUtf8, len); + msg.AddData("key-utf8", B_INT8_TYPE, (const void *)keyUtf8, len); } be_app->PostMessage(&msg); } - void _RepaintEvent() { + void _RepaintEvent() + { /* Force a repaint: Call the SDL exposed event */ BMessage msg(BAPP_REPAINT); _PostWindowEvent(msg); } - void _PostWindowEvent(BMessage &msg) { + void _PostWindowEvent(BMessage &msg) + { msg.AddInt32("window-id", _id); be_app->PostMessage(&msg); } /* Command methods (functions called upon by SDL) */ - void _SetTitle(BMessage *msg) { + void _SetTitle(BMessage *msg) + { const char *title; - if( - msg->FindString("window-title", &title) != B_OK - ) { + if ( + msg->FindString("window-title", &title) != B_OK) { return; } SetTitle(title); } - void _MoveTo(BMessage *msg) { + void _MoveTo(BMessage *msg) + { int32 x, y; - if( + if ( msg->FindInt32("window-x", &x) != B_OK || - msg->FindInt32("window-y", &y) != B_OK - ) { + msg->FindInt32("window-y", &y) != B_OK) { return; } if (_fullscreen) @@ -587,12 +612,12 @@ private: MoveTo(x, y); } - void _ResizeTo(BMessage *msg) { + void _ResizeTo(BMessage *msg) + { int32 w, h; - if( + if ( msg->FindInt32("window-w", &w) != B_OK || - msg->FindInt32("window-h", &h) != B_OK - ) { + msg->FindInt32("window-h", &h) != B_OK) { return; } if (_fullscreen) { @@ -602,14 +627,16 @@ private: ResizeTo(w, h); } - void _SetBordered(bool bEnabled) { + void _SetBordered(bool bEnabled) + { if (_fullscreen) _bordered = bEnabled; else SetLook(bEnabled ? B_TITLED_WINDOW_LOOK : B_NO_BORDER_WINDOW_LOOK); } - void _SetResizable(bool bEnabled) { + void _SetResizable(bool bEnabled) + { if (_fullscreen) _resizable = bEnabled; else { @@ -621,7 +648,8 @@ private: } } - void _SetMinimumSize(BMessage *msg) { + void _SetMinimumSize(BMessage *msg) + { float maxHeight; float maxWidth; float _; @@ -639,25 +667,29 @@ private: UpdateSizeLimits(); } - void _Restore() { - if(IsMinimized()) { + void _Restore() + { + if (IsMinimized()) { Minimize(false); - } else if(IsHidden()) { + } else if (IsHidden()) { Show(); } else if (_fullscreen) { - } else if(_prev_frame != NULL) { /* Zoomed */ + } else if (_prev_frame != NULL) { /* Zoomed */ MoveTo(_prev_frame->left, _prev_frame->top); ResizeTo(_prev_frame->Width(), _prev_frame->Height()); } } - void _SetFullScreen(bool fullscreen) { + void _SetFullScreen(bool fullscreen) + { if (fullscreen != _fullscreen) { if (fullscreen) { BScreen screen(this); BRect screenFrame = screen.Frame(); - printf("screen frame: "); screenFrame.PrintToStream(); printf("\n"); + printf("screen frame: "); + screenFrame.PrintToStream(); + printf("\n"); _bordered = Look() != B_NO_BORDER_WINDOW_LOOK; _resizable = !(Flags() & B_NOT_RESIZABLE); _non_fullscreen_frame = Frame(); @@ -678,18 +710,18 @@ private: /* Members */ - BView* _cur_view; - SDL_BView* _SDL_View; + BView *_cur_view; + SDL_BView *_SDL_View; #if SDL_VIDEO_OPENGL - BGLView * _SDL_GLView; + BGLView *_SDL_GLView; Uint32 _gl_type; #endif int32 _last_buttons; - int32 _id; /* Window id used by SDL_BApp */ - bool _mouse_focused; /* Does this window have mouse focus? */ - bool _shown; - bool _inhibit_resize; + int32 _id; /* Window id used by SDL_BApp */ + bool _mouse_focused; /* Does this window have mouse focus? */ + bool _shown; + bool _inhibit_resize; BRect *_prev_frame; /* Previous position and size of the window */ bool _fullscreen; @@ -703,7 +735,6 @@ private: BBitmap *_bitmap; }; - /* FIXME: * An explanation of framebuffer flags. * diff --git a/src/video/haiku/SDL_bframebuffer.h b/src/video/haiku/SDL_bframebuffer.h index 4361a39df..c0afd520c 100644 --- a/src/video/haiku/SDL_bframebuffer.h +++ b/src/video/haiku/SDL_bframebuffer.h @@ -30,12 +30,12 @@ extern "C" { #include "../SDL_sysvideo.h" -extern int HAIKU_CreateWindowFramebuffer(_THIS, SDL_Window * window, - Uint32 * format, - void ** pixels, int *pitch); -extern int HAIKU_UpdateWindowFramebuffer(_THIS, SDL_Window * window, - const SDL_Rect * rects, int numrects); -extern void HAIKU_DestroyWindowFramebuffer(_THIS, SDL_Window * window); +extern int HAIKU_CreateWindowFramebuffer(_THIS, SDL_Window *window, + Uint32 *format, + void **pixels, int *pitch); +extern int HAIKU_UpdateWindowFramebuffer(_THIS, SDL_Window *window, + const SDL_Rect *rects, int numrects); +extern void HAIKU_DestroyWindowFramebuffer(_THIS, SDL_Window *window); extern int32 HAIKU_DrawThread(void *data); #ifdef __cplusplus diff --git a/src/video/haiku/SDL_bmodes.h b/src/video/haiku/SDL_bmodes.h index 5b4041833..ead381772 100644 --- a/src/video/haiku/SDL_bmodes.h +++ b/src/video/haiku/SDL_bmodes.h @@ -33,10 +33,10 @@ extern int32 HAIKU_ColorSpaceToSDLPxFormat(uint32 colorspace); extern int HAIKU_InitModes(_THIS); extern int HAIKU_QuitModes(_THIS); extern int HAIKU_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, - SDL_Rect *rect); + SDL_Rect *rect); extern void HAIKU_GetDisplayModes(_THIS, SDL_VideoDisplay *display); extern int HAIKU_SetDisplayMode(_THIS, SDL_VideoDisplay *display, - SDL_DisplayMode *mode); + SDL_DisplayMode *mode); #ifdef __cplusplus } diff --git a/src/video/haiku/SDL_bopengl.h b/src/video/haiku/SDL_bopengl.h index 4723ae6b5..298d27b09 100644 --- a/src/video/haiku/SDL_bopengl.h +++ b/src/video/haiku/SDL_bopengl.h @@ -30,16 +30,15 @@ extern "C" { #include "../SDL_sysvideo.h" - -extern int HAIKU_GL_LoadLibrary(_THIS, const char *path); /* FIXME */ -extern void *HAIKU_GL_GetProcAddress(_THIS, const char *proc); /* FIXME */ -extern void HAIKU_GL_UnloadLibrary(_THIS); /* TODO */ -extern int HAIKU_GL_MakeCurrent(_THIS, SDL_Window * window, - SDL_GLContext context); -extern int HAIKU_GL_SetSwapInterval(_THIS, int interval); /* TODO */ -extern int HAIKU_GL_GetSwapInterval(_THIS); /* TODO */ -extern int HAIKU_GL_SwapWindow(_THIS, SDL_Window * window); -extern SDL_GLContext HAIKU_GL_CreateContext(_THIS, SDL_Window * window); +extern int HAIKU_GL_LoadLibrary(_THIS, const char *path); /* FIXME */ +extern void *HAIKU_GL_GetProcAddress(_THIS, const char *proc); /* FIXME */ +extern void HAIKU_GL_UnloadLibrary(_THIS); /* TODO */ +extern int HAIKU_GL_MakeCurrent(_THIS, SDL_Window *window, + SDL_GLContext context); +extern int HAIKU_GL_SetSwapInterval(_THIS, int interval); /* TODO */ +extern int HAIKU_GL_GetSwapInterval(_THIS); /* TODO */ +extern int HAIKU_GL_SwapWindow(_THIS, SDL_Window *window); +extern SDL_GLContext HAIKU_GL_CreateContext(_THIS, SDL_Window *window); extern void HAIKU_GL_DeleteContext(_THIS, SDL_GLContext context); extern void HAIKU_GL_RebootContexts(_THIS); diff --git a/src/video/haiku/SDL_bvideo.cc b/src/video/haiku/SDL_bvideo.cc index 337175d73..548dd0981 100644 --- a/src/video/haiku/SDL_bvideo.cc +++ b/src/video/haiku/SDL_bvideo.cc @@ -54,8 +54,7 @@ static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) { /* End undefined functions */ -static SDL_VideoDevice * -HAIKU_CreateDevice(void) +static SDL_VideoDevice * HAIKU_CreateDevice(void) { SDL_VideoDevice *device; /*SDL_VideoData *data;*/ @@ -141,8 +140,7 @@ void HAIKU_DeleteDevice(SDL_VideoDevice * device) SDL_free(device); } -static SDL_Cursor * -HAIKU_CreateSystemCursor(SDL_SystemCursor id) +static SDL_Cursor * HAIKU_CreateSystemCursor(SDL_SystemCursor id) { SDL_Cursor *cursor; BCursorID cursorId = B_CURSOR_ID_SYSTEM_DEFAULT; @@ -176,14 +174,12 @@ HAIKU_CreateSystemCursor(SDL_SystemCursor id) return cursor; } -static SDL_Cursor * -HAIKU_CreateDefaultCursor() +static SDL_Cursor * HAIKU_CreateDefaultCursor() { return HAIKU_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); } -static void -HAIKU_FreeCursor(SDL_Cursor * cursor) +static void HAIKU_FreeCursor(SDL_Cursor * cursor) { if (cursor->driverdata) { delete (BCursor*) cursor->driverdata; @@ -191,8 +187,7 @@ HAIKU_FreeCursor(SDL_Cursor * cursor) SDL_free(cursor); } -static SDL_Cursor * -HAIKU_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) +static SDL_Cursor * HAIKU_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) { SDL_Cursor *cursor; SDL_Surface *converted; @@ -236,8 +231,7 @@ static int HAIKU_ShowCursor(SDL_Cursor *cursor) return 0; } -static int -HAIKU_SetRelativeMouseMode(SDL_bool enabled) +static int HAIKU_SetRelativeMouseMode(SDL_bool enabled) { SDL_Window *window = SDL_GetMouseFocus(); if (window == NULL) { diff --git a/src/video/haiku/SDL_bvideo.h b/src/video/haiku/SDL_bvideo.h index d0d7bfea5..94b86b02f 100644 --- a/src/video/haiku/SDL_bvideo.h +++ b/src/video/haiku/SDL_bvideo.h @@ -29,7 +29,6 @@ extern "C" { #include "../../main/haiku/SDL_BeApp.h" #include "../SDL_sysvideo.h" - extern void HAIKU_VideoQuit(_THIS); extern int HAIKU_VideoInit(_THIS); extern void HAIKU_DeleteDevice(_THIS); diff --git a/src/video/haiku/SDL_bwindow.h b/src/video/haiku/SDL_bwindow.h index 58a85d872..3a3445ef5 100644 --- a/src/video/haiku/SDL_bwindow.h +++ b/src/video/haiku/SDL_bwindow.h @@ -22,10 +22,8 @@ #ifndef SDL_BWINDOW_H #define SDL_BWINDOW_H - #include "../SDL_sysvideo.h" - extern int HAIKU_CreateWindow(_THIS, SDL_Window *window); extern int HAIKU_CreateWindowFrom(_THIS, SDL_Window * window, const void *data); extern void HAIKU_SetWindowTitle(_THIS, SDL_Window * window); @@ -49,8 +47,6 @@ extern void HAIKU_DestroyWindow(_THIS, SDL_Window * window); extern SDL_bool HAIKU_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info); - - #endif /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/kmsdrm/SDL_kmsdrmdyn.c b/src/video/kmsdrm/SDL_kmsdrmdyn.c index de8c2e4fd..39fa2683d 100644 --- a/src/video/kmsdrm/SDL_kmsdrmdyn.c +++ b/src/video/kmsdrm/SDL_kmsdrmdyn.c @@ -46,12 +46,11 @@ typedef struct #endif static kmsdrmdynlib kmsdrmlibs[] = { - {NULL, SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM}, - {NULL, SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC} + { NULL, SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM }, + { NULL, SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC } }; -static void * -KMSDRM_GetSym(const char *fnname, int *pHasModule) +static void *KMSDRM_GetSym(const char *fnname, int *pHasModule) { int i; void *fn = NULL; @@ -73,7 +72,7 @@ KMSDRM_GetSym(const char *fnname, int *pHasModule) if (fn == NULL) { *pHasModule = 0; /* kill this module. */ - } + } return fn; } @@ -81,15 +80,14 @@ KMSDRM_GetSym(const char *fnname, int *pHasModule) #endif /* SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC */ /* Define all the function pointers and wrappers... */ -#define SDL_KMSDRM_MODULE(modname) int SDL_KMSDRM_HAVE_##modname = 0; -#define SDL_KMSDRM_SYM(rc,fn,params) SDL_DYNKMSDRMFN_##fn KMSDRM_##fn = NULL; -#define SDL_KMSDRM_SYM_CONST(type,name) SDL_DYNKMSDRMCONST_##name KMSDRM_##name = NULL; +#define SDL_KMSDRM_MODULE(modname) int SDL_KMSDRM_HAVE_##modname = 0; +#define SDL_KMSDRM_SYM(rc, fn, params) SDL_DYNKMSDRMFN_##fn KMSDRM_##fn = NULL; +#define SDL_KMSDRM_SYM_CONST(type, name) SDL_DYNKMSDRMCONST_##name KMSDRM_##name = NULL; #include "SDL_kmsdrmsym.h" static int kmsdrm_load_refcount = 0; -void -SDL_KMSDRM_UnloadSymbols(void) +void SDL_KMSDRM_UnloadSymbols(void) { /* Don't actually unload if more than one module is using the libs... */ if (kmsdrm_load_refcount > 0) { @@ -99,12 +97,11 @@ SDL_KMSDRM_UnloadSymbols(void) #endif /* set all the function pointers to NULL. */ -#define SDL_KMSDRM_MODULE(modname) SDL_KMSDRM_HAVE_##modname = 0; -#define SDL_KMSDRM_SYM(rc,fn,params) KMSDRM_##fn = NULL; -#define SDL_KMSDRM_SYM_CONST(type,name) KMSDRM_##name = NULL; +#define SDL_KMSDRM_MODULE(modname) SDL_KMSDRM_HAVE_##modname = 0; +#define SDL_KMSDRM_SYM(rc, fn, params) KMSDRM_##fn = NULL; +#define SDL_KMSDRM_SYM_CONST(type, name) KMSDRM_##name = NULL; #include "SDL_kmsdrmsym.h" - #ifdef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC for (i = 0; i < SDL_TABLESIZE(kmsdrmlibs); i++) { if (kmsdrmlibs[i].lib != NULL) { @@ -118,10 +115,9 @@ SDL_KMSDRM_UnloadSymbols(void) } /* returns non-zero if all needed symbols were loaded. */ -int -SDL_KMSDRM_LoadSymbols(void) +int SDL_KMSDRM_LoadSymbols(void) { - int rc = 1; /* always succeed if not using Dynamic KMSDRM stuff. */ + int rc = 1; /* always succeed if not using Dynamic KMSDRM stuff. */ /* deal with multiple modules needing these symbols... */ if (kmsdrm_load_refcount++ == 0) { @@ -137,9 +133,9 @@ SDL_KMSDRM_LoadSymbols(void) #define SDL_KMSDRM_MODULE(modname) SDL_KMSDRM_HAVE_##modname = 1; /* default yes */ #include "SDL_kmsdrmsym.h" -#define SDL_KMSDRM_MODULE(modname) thismod = &SDL_KMSDRM_HAVE_##modname; -#define SDL_KMSDRM_SYM(rc,fn,params) KMSDRM_##fn = (SDL_DYNKMSDRMFN_##fn) KMSDRM_GetSym(#fn,thismod); -#define SDL_KMSDRM_SYM_CONST(type,name) KMSDRM_##name = *(SDL_DYNKMSDRMCONST_##name*) KMSDRM_GetSym(#name,thismod); +#define SDL_KMSDRM_MODULE(modname) thismod = &SDL_KMSDRM_HAVE_##modname; +#define SDL_KMSDRM_SYM(rc, fn, params) KMSDRM_##fn = (SDL_DYNKMSDRMFN_##fn)KMSDRM_GetSym(#fn, thismod); +#define SDL_KMSDRM_SYM_CONST(type, name) KMSDRM_##name = *(SDL_DYNKMSDRMCONST_##name *)KMSDRM_GetSym(#name, thismod); #include "SDL_kmsdrmsym.h" if ((SDL_KMSDRM_HAVE_LIBDRM) && (SDL_KMSDRM_HAVE_GBM)) { @@ -151,11 +147,11 @@ SDL_KMSDRM_LoadSymbols(void) rc = 0; } -#else /* no dynamic KMSDRM */ +#else /* no dynamic KMSDRM */ -#define SDL_KMSDRM_MODULE(modname) SDL_KMSDRM_HAVE_##modname = 1; /* default yes */ -#define SDL_KMSDRM_SYM(rc,fn,params) KMSDRM_##fn = fn; -#define SDL_KMSDRM_SYM_CONST(type,name) KMSDRM_##name = name; +#define SDL_KMSDRM_MODULE(modname) SDL_KMSDRM_HAVE_##modname = 1; /* default yes */ +#define SDL_KMSDRM_SYM(rc, fn, params) KMSDRM_##fn = fn; +#define SDL_KMSDRM_SYM_CONST(type, name) KMSDRM_##name = name; #include "SDL_kmsdrmsym.h" #endif diff --git a/src/video/kmsdrm/SDL_kmsdrmdyn.h b/src/video/kmsdrm/SDL_kmsdrmdyn.h index 65de02e1b..11976b8fd 100644 --- a/src/video/kmsdrm/SDL_kmsdrmdyn.h +++ b/src/video/kmsdrm/SDL_kmsdrmdyn.h @@ -36,10 +36,10 @@ int SDL_KMSDRM_LoadSymbols(void); void SDL_KMSDRM_UnloadSymbols(void); /* Declare all the function pointers and wrappers... */ -#define SDL_KMSDRM_SYM(rc,fn,params) \ - typedef rc (*SDL_DYNKMSDRMFN_##fn) params; \ +#define SDL_KMSDRM_SYM(rc, fn, params) \ + typedef rc(*SDL_DYNKMSDRMFN_##fn) params; \ extern SDL_DYNKMSDRMFN_##fn KMSDRM_##fn; -#define SDL_KMSDRM_SYM_CONST(type, name) \ +#define SDL_KMSDRM_SYM_CONST(type, name) \ typedef type SDL_DYNKMSDRMCONST_##name; \ extern SDL_DYNKMSDRMCONST_##name KMSDRM_##name; #include "SDL_kmsdrmsym.h" diff --git a/src/video/kmsdrm/SDL_kmsdrmevents.c b/src/video/kmsdrm/SDL_kmsdrmevents.c index 10773a760..94bc36860 100644 --- a/src/video/kmsdrm/SDL_kmsdrmevents.c +++ b/src/video/kmsdrm/SDL_kmsdrmevents.c @@ -39,8 +39,6 @@ void KMSDRM_PumpEvents(_THIS) #elif defined SDL_INPUT_WSCONS SDL_WSCONS_PumpEvents(); #endif - } #endif /* SDL_VIDEO_DRIVER_KMSDRM */ - diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c index 08cf26c72..d3f983ae3 100644 --- a/src/video/kmsdrm/SDL_kmsdrmmouse.c +++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c @@ -33,11 +33,11 @@ #include "../SDL_pixels_c.h" static SDL_Cursor *KMSDRM_CreateDefaultCursor(void); -static SDL_Cursor *KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y); -static int KMSDRM_ShowCursor(SDL_Cursor * cursor); -static void KMSDRM_MoveCursor(SDL_Cursor * cursor); -static void KMSDRM_FreeCursor(SDL_Cursor * cursor); -static void KMSDRM_WarpMouse(SDL_Window * window, int x, int y); +static SDL_Cursor *KMSDRM_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y); +static int KMSDRM_ShowCursor(SDL_Cursor *cursor); +static void KMSDRM_MoveCursor(SDL_Cursor *cursor); +static void KMSDRM_FreeCursor(SDL_Cursor *cursor); +static void KMSDRM_WarpMouse(SDL_Window *window, int x, int y); static int KMSDRM_WarpMouseGlobal(int x, int y); /**************************************************************************************/ @@ -55,8 +55,7 @@ static int KMSDRM_WarpMouseGlobal(int x, int y); /* and mouse->cursor_shown is 1. */ /**************************************************************************************/ -static SDL_Cursor * -KMSDRM_CreateDefaultCursor(void) +static SDL_Cursor *KMSDRM_CreateDefaultCursor(void) { return SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH, DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY); } @@ -64,11 +63,10 @@ KMSDRM_CreateDefaultCursor(void) /* Given a display's driverdata, destroy the cursor BO for it. To be called from KMSDRM_DestroyWindow(), as that's where we destroy the driverdata for the window's display. */ -void -KMSDRM_DestroyCursorBO (_THIS, SDL_VideoDisplay *display) +void KMSDRM_DestroyCursorBO(_THIS, SDL_VideoDisplay *display) { - SDL_DisplayData *dispdata = (SDL_DisplayData *) display->driverdata; - + SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata; + /* Destroy the curso GBM BO. */ if (dispdata->cursor_bo) { KMSDRM_gbm_bo_destroy(dispdata->cursor_bo); @@ -80,26 +78,24 @@ KMSDRM_DestroyCursorBO (_THIS, SDL_VideoDisplay *display) /* Given a display's driverdata, create the cursor BO for it. To be called from KMSDRM_CreateWindow(), as that's where we build a window and assign a display to it. */ -void -KMSDRM_CreateCursorBO (SDL_VideoDisplay *display) { +void KMSDRM_CreateCursorBO(SDL_VideoDisplay *display) +{ SDL_VideoDevice *dev = SDL_GetVideoDevice(); SDL_VideoData *viddata = ((SDL_VideoData *)dev->driverdata); - SDL_DisplayData *dispdata = (SDL_DisplayData *) display->driverdata; + SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata; if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev, - GBM_FORMAT_ARGB8888, - GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE)) - { + GBM_FORMAT_ARGB8888, + GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE)) { SDL_SetError("Unsupported pixel format for cursor"); return; } if (KMSDRM_drmGetCap(viddata->drm_fd, - DRM_CAP_CURSOR_WIDTH, &dispdata->cursor_w) || - KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_HEIGHT, - &dispdata->cursor_h)) - { + DRM_CAP_CURSOR_WIDTH, &dispdata->cursor_w) || + KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_HEIGHT, + &dispdata->cursor_h)) { SDL_SetError("Could not get the recommended GBM cursor size"); return; } @@ -110,8 +106,8 @@ KMSDRM_CreateCursorBO (SDL_VideoDisplay *display) { } dispdata->cursor_bo = KMSDRM_gbm_bo_create(viddata->gbm_dev, - dispdata->cursor_w, dispdata->cursor_h, - GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE | GBM_BO_USE_LINEAR); + dispdata->cursor_w, dispdata->cursor_h, + GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE | GBM_BO_USE_LINEAR); if (!dispdata->cursor_bo) { SDL_SetError("Could not create GBM cursor BO"); @@ -119,19 +115,18 @@ KMSDRM_CreateCursorBO (SDL_VideoDisplay *display) { } dispdata->cursor_bo_drm_fd = viddata->drm_fd; -} +} /* Remove a cursor buffer from a display's DRM cursor BO. */ -static int -KMSDRM_RemoveCursorFromBO(SDL_VideoDisplay *display) +static int KMSDRM_RemoveCursorFromBO(SDL_VideoDisplay *display) { int ret = 0; - SDL_DisplayData *dispdata = (SDL_DisplayData *) display->driverdata; + SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata; SDL_VideoDevice *video_device = SDL_GetVideoDevice(); SDL_VideoData *viddata = ((SDL_VideoData *)video_device->driverdata); ret = KMSDRM_drmModeSetCursor(viddata->drm_fd, - dispdata->crtc->crtc_id, 0, 0, 0); + dispdata->crtc->crtc_id, 0, 0, 0); if (ret) { ret = SDL_SetError("Could not hide current cursor with drmModeSetCursor()."); @@ -141,11 +136,10 @@ KMSDRM_RemoveCursorFromBO(SDL_VideoDisplay *display) } /* Dump a cursor buffer to a display's DRM cursor BO. */ -static int -KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor) +static int KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor) { - SDL_DisplayData *dispdata = (SDL_DisplayData *) display->driverdata; - KMSDRM_CursorData *curdata = (KMSDRM_CursorData *) cursor->driverdata; + SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata; + KMSDRM_CursorData *curdata = (KMSDRM_CursorData *)cursor->driverdata; SDL_VideoDevice *video_device = SDL_GetVideoDevice(); SDL_VideoData *viddata = ((SDL_VideoData *)video_device->driverdata); @@ -167,7 +161,7 @@ KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor) bo_stride = KMSDRM_gbm_bo_get_stride(dispdata->cursor_bo); bufsize = bo_stride * dispdata->cursor_h; - ready_buffer = (uint8_t*)SDL_calloc(1, bufsize); + ready_buffer = (uint8_t *)SDL_calloc(1, bufsize); if (ready_buffer == NULL) { ret = SDL_OutOfMemory(); @@ -176,7 +170,7 @@ KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor) /* Copy from the cursor buffer to a buffer that we can dump to the GBM BO. */ for (i = 0; i < curdata->h; i++) { - src_row = &((uint8_t*)curdata->buffer)[i * curdata->w * 4]; + src_row = &((uint8_t *)curdata->buffer)[i * curdata->w * 4]; SDL_memcpy(ready_buffer + (i * bo_stride), src_row, 4 * curdata->w); } @@ -190,10 +184,10 @@ KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor) bo_handle = KMSDRM_gbm_bo_get_handle(dispdata->cursor_bo).u32; if (curdata->hot_x == 0 && curdata->hot_y == 0) { ret = KMSDRM_drmModeSetCursor(viddata->drm_fd, dispdata->crtc->crtc_id, - bo_handle, dispdata->cursor_w, dispdata->cursor_h); + bo_handle, dispdata->cursor_w, dispdata->cursor_h); } else { ret = KMSDRM_drmModeSetCursor2(viddata->drm_fd, dispdata->crtc->crtc_id, - bo_handle, dispdata->cursor_w, dispdata->cursor_h, curdata->hot_x, curdata->hot_y); + bo_handle, dispdata->cursor_w, dispdata->cursor_h, curdata->hot_x, curdata->hot_y); } if (ret) { @@ -215,14 +209,13 @@ cleanup: } /* This is only for freeing the SDL_cursor.*/ -static void -KMSDRM_FreeCursor(SDL_Cursor * cursor) +static void KMSDRM_FreeCursor(SDL_Cursor *cursor) { KMSDRM_CursorData *curdata; /* Even if the cursor is not ours, free it. */ if (cursor) { - curdata = (KMSDRM_CursorData *) cursor->driverdata; + curdata = (KMSDRM_CursorData *)cursor->driverdata; /* Free cursor buffer */ if (curdata->buffer) { SDL_free(curdata->buffer); @@ -239,8 +232,7 @@ KMSDRM_FreeCursor(SDL_Cursor * cursor) /* This simply gets the cursor soft-buffer ready. We don't copy it to a GBO BO until ShowCursor() because the cusor GBM BO (living in dispata) is destroyed and recreated when we recreate windows, etc. */ -static SDL_Cursor * -KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) +static SDL_Cursor *KMSDRM_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) { KMSDRM_CursorData *curdata; SDL_Cursor *cursor, *ret; @@ -248,12 +240,12 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) curdata = NULL; ret = NULL; - cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor)); + cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor)); if (cursor == NULL) { SDL_OutOfMemory(); goto cleanup; } - curdata = (KMSDRM_CursorData *) SDL_calloc(1, sizeof(*curdata)); + curdata = (KMSDRM_CursorData *)SDL_calloc(1, sizeof(*curdata)); if (curdata == NULL) { SDL_OutOfMemory(); goto cleanup; @@ -270,7 +262,7 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) This buffer has the original size of the cursor surface we are given. */ curdata->buffer_pitch = surface->w; curdata->buffer_size = surface->w * surface->h * 4; - curdata->buffer = (uint32_t*)SDL_malloc(curdata->buffer_size); + curdata->buffer = (uint32_t *)SDL_malloc(curdata->buffer_size); if (!curdata->buffer) { SDL_OutOfMemory(); @@ -280,7 +272,7 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) /* All code below assumes ARGB8888 format for the cursor surface, like other backends do. Also, the GBM BO pixels have to be alpha-premultiplied, but the SDL surface we receive has - straight-alpha pixels, so we always have to convert. */ + straight-alpha pixels, so we always have to convert. */ SDL_PremultiplyAlpha(surface->w, surface->h, surface->format->format, surface->pixels, surface->pitch, SDL_PIXELFORMAT_ARGB8888, curdata->buffer, surface->w * 4); @@ -306,8 +298,7 @@ cleanup: } /* Show the specified cursor, or hide if cursor is NULL or has no focus. */ -static int -KMSDRM_ShowCursor(SDL_Cursor * cursor) +static int KMSDRM_ShowCursor(SDL_Cursor *cursor) { SDL_VideoDisplay *display; SDL_Window *window; @@ -327,20 +318,20 @@ KMSDRM_ShowCursor(SDL_Cursor * cursor) if (window == NULL || cursor == NULL) { - /* If no window is focused by mouse or cursor is NULL, - since we have no window (no mouse->focus) and hence - we have no display, we simply hide mouse on all displays. - This happens on video quit, where we get here after - the mouse focus has been unset, yet SDL wants to - restore the system default cursor (makes no sense here). */ + /* If no window is focused by mouse or cursor is NULL, + since we have no window (no mouse->focus) and hence + we have no display, we simply hide mouse on all displays. + This happens on video quit, where we get here after + the mouse focus has been unset, yet SDL wants to + restore the system default cursor (makes no sense here). */ - num_displays = SDL_GetNumVideoDisplays(); + num_displays = SDL_GetNumVideoDisplays(); - /* Iterate on the displays hidding the cursor. */ - for (i = 0; i < num_displays; i++) { - display = SDL_GetDisplay(i); - ret = KMSDRM_RemoveCursorFromBO(display); - } + /* Iterate on the displays hidding the cursor. */ + for (i = 0; i < num_displays; i++) { + display = SDL_GetDisplay(i); + ret = KMSDRM_RemoveCursorFromBO(display); + } } else { @@ -357,30 +348,28 @@ KMSDRM_ShowCursor(SDL_Cursor * cursor) /* Hide the cursor on that display. */ ret = KMSDRM_RemoveCursorFromBO(display); } - } + } } return ret; } /* Warp the mouse to (x,y) */ -static void -KMSDRM_WarpMouse(SDL_Window * window, int x, int y) +static void KMSDRM_WarpMouse(SDL_Window *window, int x, int y) { /* Only one global/fullscreen window is supported */ KMSDRM_WarpMouseGlobal(x, y); } /* Warp the mouse to (x,y) */ -static int -KMSDRM_WarpMouseGlobal(int x, int y) +static int KMSDRM_WarpMouseGlobal(int x, int y) { SDL_Mouse *mouse = SDL_GetMouse(); if (mouse && mouse->cur_cursor && mouse->focus) { SDL_Window *window = mouse->focus; - SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; + SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata; /* Update internal mouse position. */ SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 0, x, y); @@ -406,11 +395,10 @@ KMSDRM_WarpMouseGlobal(int x, int y) } } -void -KMSDRM_InitMouse(_THIS, SDL_VideoDisplay *display) +void KMSDRM_InitMouse(_THIS, SDL_VideoDisplay *display) { SDL_Mouse *mouse = SDL_GetMouse(); - SDL_DisplayData *dispdata = (SDL_DisplayData *) display->driverdata; + SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata; mouse->CreateCursor = KMSDRM_CreateCursor; mouse->ShowCursor = KMSDRM_ShowCursor; @@ -427,15 +415,13 @@ KMSDRM_InitMouse(_THIS, SDL_VideoDisplay *display) } } -void -KMSDRM_QuitMouse(_THIS) +void KMSDRM_QuitMouse(_THIS) { /* TODO: ? */ } /* This is called when a mouse motion event occurs */ -static void -KMSDRM_MoveCursor(SDL_Cursor * cursor) +static void KMSDRM_MoveCursor(SDL_Cursor *cursor) { SDL_Mouse *mouse = SDL_GetMouse(); int ret = 0; @@ -445,7 +431,7 @@ KMSDRM_MoveCursor(SDL_Cursor * cursor) if (mouse && mouse->cur_cursor && mouse->focus) { SDL_Window *window = mouse->focus; - SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; + SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata; if (!dispdata->cursor_bo) { SDL_SetError("Cursor not initialized properly."); diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.h b/src/video/kmsdrm/SDL_kmsdrmmouse.h index 3879f7a06..1d0890d99 100644 --- a/src/video/kmsdrm/SDL_kmsdrmmouse.h +++ b/src/video/kmsdrm/SDL_kmsdrmmouse.h @@ -31,12 +31,12 @@ typedef struct _KMSDRM_CursorData { - int hot_x, hot_y; - int w, h; + int hot_x, hot_y; + int w, h; /* The buffer where we store the mouse bitmap ready to be used. We get it ready and filled in CreateCursor(), and copy it - to a GBM BO in ShowCursor().*/ + to a GBM BO in ShowCursor().*/ uint32_t *buffer; size_t buffer_size; size_t buffer_pitch; diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c index 6657da427..5ae154320 100644 --- a/src/video/kmsdrm/SDL_kmsdrmopengles.c +++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c @@ -36,8 +36,7 @@ /* EGL implementation of SDL OpenGL support */ -void -KMSDRM_GLES_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor) +void KMSDRM_GLES_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor) { /* if SDL was _also_ built with the Raspberry Pi driver (so we're definitely a Pi device), default to GLES2. */ @@ -48,8 +47,8 @@ KMSDRM_GLES_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor) #endif } -int -KMSDRM_GLES_LoadLibrary(_THIS, const char *path) { +int KMSDRM_GLES_LoadLibrary(_THIS, const char *path) +{ /* Just pretend you do this here, but don't do it until KMSDRM_CreateWindow(), where we do the same library load we would normally do here. because this gets called by SDL_CreateWindow() before KMSDR_CreateWindow(), @@ -62,15 +61,16 @@ KMSDRM_GLES_LoadLibrary(_THIS, const char *path) { return 0; } -void -KMSDRM_GLES_UnloadLibrary(_THIS) { +void KMSDRM_GLES_UnloadLibrary(_THIS) +{ /* As with KMSDRM_GLES_LoadLibrary(), we define our own "dummy" unloading function so we manually unload the library whenever we want. */ } SDL_EGL_CreateContext_impl(KMSDRM) -int KMSDRM_GLES_SetSwapInterval(_THIS, int interval) { + int KMSDRM_GLES_SetSwapInterval(_THIS, int interval) +{ if (!_this->egl_data) { return SDL_SetError("EGL not initialized"); @@ -85,10 +85,10 @@ int KMSDRM_GLES_SetSwapInterval(_THIS, int interval) { return 0; } -int -KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) { - SDL_WindowData *windata = ((SDL_WindowData *) window->driverdata); - SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; +int KMSDRM_GLES_SwapWindow(_THIS, SDL_Window *window) +{ + SDL_WindowData *windata = ((SDL_WindowData *)window->driverdata); + SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata; SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); KMSDRM_FBInfo *fb_info; int ret = 0; @@ -120,7 +120,7 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) { /* Mark a buffer to becume the next front buffer. This won't happen until pagelip completes. */ if (!(_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, - windata->egl_surface))) { + windata->egl_surface))) { SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "eglSwapBuffers failed"); return 0; } @@ -146,8 +146,8 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) { drmModePageFlip can be used the CRTC has to be configured to use the current connector and mode with drmModeSetCrtc */ ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd, - dispdata->crtc->crtc_id, fb_info->fb_id, 0, 0, - &dispdata->connector->connector_id, 1, &dispdata->mode); + dispdata->crtc->crtc_id, fb_info->fb_id, 0, 0, + &dispdata->connector->connector_id, 1, &dispdata->mode); if (ret) { SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not set videomode on CRTC."); @@ -171,7 +171,7 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) { } ret = KMSDRM_drmModePageFlip(viddata->drm_fd, dispdata->crtc->crtc_id, - fb_info->fb_id, flip_flags, &windata->waiting_for_flip); + fb_info->fb_id, flip_flags, &windata->waiting_for_flip); if (ret == 0) { windata->waiting_for_flip = SDL_TRUE; @@ -203,4 +203,4 @@ SDL_EGL_MakeCurrent_impl(KMSDRM) #endif /* SDL_VIDEO_DRIVER_KMSDRM */ -/* vi: set ts=4 sw=4 expandtab: */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.h b/src/video/kmsdrm/SDL_kmsdrmopengles.h index a762ab0f3..91b80fd46 100644 --- a/src/video/kmsdrm/SDL_kmsdrmopengles.h +++ b/src/video/kmsdrm/SDL_kmsdrmopengles.h @@ -37,9 +37,9 @@ extern void KMSDRM_GLES_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor); extern int KMSDRM_GLES_SetSwapInterval(_THIS, int interval); extern int KMSDRM_GLES_LoadLibrary(_THIS, const char *path); -extern SDL_GLContext KMSDRM_GLES_CreateContext(_THIS, SDL_Window * window); -extern int KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window); -extern int KMSDRM_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); +extern SDL_GLContext KMSDRM_GLES_CreateContext(_THIS, SDL_Window *window); +extern int KMSDRM_GLES_SwapWindow(_THIS, SDL_Window *window); +extern int KMSDRM_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); #endif /* SDL_VIDEO_DRIVER_KMSDRM */ diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index db1b9429f..da825315a 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -68,8 +68,7 @@ static char kmsdrm_dri_cardpath[32]; #define EGL_PLATFORM_GBM_MESA 0x31D7 #endif -static int -get_driindex(void) +static int get_driindex(void) { int available = -ENOENT; char device[sizeof(kmsdrm_dri_cardpath)]; @@ -82,9 +81,9 @@ get_driindex(void) hint = SDL_GetHint(SDL_HINT_KMSDRM_DEVICE_INDEX); if (hint && *hint) { char *endptr = NULL; - const int idx = (int) SDL_strtol(hint, &endptr, 10); - if ((*endptr == '\0') && (idx >= 0)) { /* *endptr==0 means "whole string was a valid number" */ - return idx; /* we'll take the user's request here. */ + const int idx = (int)SDL_strtol(hint, &endptr, 10); + if ((*endptr == '\0') && (idx >= 0)) { /* *endptr==0 means "whole string was a valid number" */ + return idx; /* we'll take the user's request here. */ } } @@ -171,8 +170,7 @@ get_driindex(void) return available; } -static int -KMSDRM_Available(void) +static int KMSDRM_Available(void) { #ifdef __OpenBSD__ struct utsname nameofsystem; @@ -210,8 +208,7 @@ KMSDRM_Available(void) return ret; } -static void -KMSDRM_DeleteDevice(SDL_VideoDevice * device) +static void KMSDRM_DeleteDevice(SDL_VideoDevice *device) { if (device->driverdata) { SDL_free(device->driverdata); @@ -223,8 +220,7 @@ KMSDRM_DeleteDevice(SDL_VideoDevice * device) SDL_KMSDRM_UnloadSymbols(); } -static SDL_VideoDevice * -KMSDRM_CreateDevice(void) +static SDL_VideoDevice *KMSDRM_CreateDevice(void) { SDL_VideoDevice *device; SDL_VideoData *viddata; @@ -244,13 +240,13 @@ KMSDRM_CreateDevice(void) return NULL; } - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device == NULL) { SDL_OutOfMemory(); return NULL; } - viddata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); + viddata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); if (viddata == NULL) { SDL_OutOfMemory(); goto cleanup; @@ -322,8 +318,7 @@ VideoBootStrap KMSDRM_bootstrap = { KMSDRM_CreateDevice }; -static void -KMSDRM_FBDestroyCallback(struct gbm_bo *bo, void *data) +static void KMSDRM_FBDestroyCallback(struct gbm_bo *bo, void *data) { KMSDRM_FBInfo *fb_info = (KMSDRM_FBInfo *)data; @@ -339,7 +334,7 @@ KMSDRM_FBInfo * KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo) { SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - unsigned w,h; + unsigned w, h; int ret; Uint32 stride, handle; @@ -367,10 +362,10 @@ KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo) stride = KMSDRM_gbm_bo_get_stride(bo); handle = KMSDRM_gbm_bo_get_handle(bo).u32; ret = KMSDRM_drmModeAddFB(viddata->drm_fd, w, h, 24, 32, stride, handle, - &fb_info->fb_id); + &fb_info->fb_id); if (ret) { - SDL_free(fb_info); - return NULL; + SDL_free(fb_info); + return NULL; } SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "New DRM FB (%u): %ux%u, stride %u from BO %p", @@ -382,18 +377,18 @@ KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo) return fb_info; } -static void -KMSDRM_FlipHandler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void *data) +static void KMSDRM_FlipHandler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void *data) { - *((SDL_bool *) data) = SDL_FALSE; + *((SDL_bool *)data) = SDL_FALSE; } SDL_bool -KMSDRM_WaitPageflip(_THIS, SDL_WindowData *windata) { +KMSDRM_WaitPageflip(_THIS, SDL_WindowData *windata) +{ SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - drmEventContext ev = {0}; - struct pollfd pfd = {0}; + drmEventContext ev = { 0 }; + struct pollfd pfd = { 0 }; int ret; ev.version = DRM_EVENT_CONTEXT_VERSION; @@ -455,7 +450,7 @@ KMSDRM_WaitPageflip(_THIS, SDL_WindowData *windata) { If it's not, we keep iterating on the loop. */ KMSDRM_drmHandleEvent(viddata->drm_fd, &ev); } - + /* If we got to this point in the loop, we may iterate or exit the loop: -A legit (non-error) event arrived, and it was a POLLING event, and it was consumed by drmHandleEvent(). @@ -465,8 +460,7 @@ KMSDRM_WaitPageflip(_THIS, SDL_WindowData *windata) { iterare back to polling. -A legit (non-error) event arrived, but it's not a POLLIN event, so it hasn't to be consumed by drmHandleEvent(), so waiting_for_flip isn't set and we iterate back - to polling. */ - + to polling. */ } return SDL_TRUE; @@ -476,11 +470,11 @@ KMSDRM_WaitPageflip(_THIS, SDL_WindowData *windata) { available on the DRM connector of the display. We use the SDL mode list (which we filled in KMSDRM_GetDisplayModes) because it's ordered, while the list on the connector is mostly random.*/ -static drmModeModeInfo* -KMSDRM_GetClosestDisplayMode(SDL_VideoDisplay * display, -uint32_t width, uint32_t height, uint32_t refresh_rate) { +static drmModeModeInfo *KMSDRM_GetClosestDisplayMode(SDL_VideoDisplay *display, + uint32_t width, uint32_t height, uint32_t refresh_rate) +{ - SDL_DisplayData *dispdata = (SDL_DisplayData *) display->driverdata; + SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata; drmModeConnector *connector = dispdata->connector; SDL_DisplayMode target, closest; @@ -507,8 +501,8 @@ uint32_t width, uint32_t height, uint32_t refresh_rate) { /*****************************************************************************/ /* Deinitializes the driverdata of the SDL Displays in the SDL display list. */ -static void -KMSDRM_DeinitDisplays (_THIS) { +static void KMSDRM_DeinitDisplays(_THIS) +{ SDL_DisplayData *dispdata; int num_displays, i; @@ -517,8 +511,8 @@ KMSDRM_DeinitDisplays (_THIS) { /* Iterate on the SDL Display list. */ for (i = 0; i < num_displays; i++) { - - /* Get the driverdata for this display */ + + /* Get the driverdata for this display */ dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(i); /* Free connector */ @@ -535,16 +529,15 @@ KMSDRM_DeinitDisplays (_THIS) { } } -static uint32_t -KMSDRM_CrtcGetPropId(uint32_t drm_fd, - drmModeObjectPropertiesPtr props, - char const* name) +static uint32_t KMSDRM_CrtcGetPropId(uint32_t drm_fd, + drmModeObjectPropertiesPtr props, + char const *name) { uint32_t i, prop_id = 0; for (i = 0; !prop_id && i < props->count_props; ++i) { drmModePropertyPtr drm_prop = - KMSDRM_drmModeGetProperty(drm_fd, props->props[i]); + KMSDRM_drmModeGetProperty(drm_fd, props->props[i]); if (!drm_prop) { continue; @@ -555,44 +548,43 @@ KMSDRM_CrtcGetPropId(uint32_t drm_fd, } KMSDRM_drmModeFreeProperty(drm_prop); - } + } return prop_id; } -static SDL_bool KMSDRM_VrrPropId(uint32_t drm_fd, uint32_t crtc_id, uint32_t *vrr_prop_id) { +static SDL_bool KMSDRM_VrrPropId(uint32_t drm_fd, uint32_t crtc_id, uint32_t *vrr_prop_id) +{ drmModeObjectPropertiesPtr drm_props; drm_props = KMSDRM_drmModeObjectGetProperties(drm_fd, - crtc_id, - DRM_MODE_OBJECT_CRTC); + crtc_id, + DRM_MODE_OBJECT_CRTC); if (!drm_props) { return SDL_FALSE; } *vrr_prop_id = KMSDRM_CrtcGetPropId(drm_fd, - drm_props, - "VRR_ENABLED"); + drm_props, + "VRR_ENABLED"); KMSDRM_drmModeFreeObjectProperties(drm_props); return SDL_TRUE; } -static SDL_bool -KMSDRM_ConnectorCheckVrrCapable(uint32_t drm_fd, - uint32_t output_id, - char const* name) +static SDL_bool KMSDRM_ConnectorCheckVrrCapable(uint32_t drm_fd, + uint32_t output_id, + char const *name) { uint32_t i; SDL_bool found = SDL_FALSE; uint64_t prop_value = 0; - drmModeObjectPropertiesPtr props = KMSDRM_drmModeObjectGetProperties(drm_fd, - output_id, - DRM_MODE_OBJECT_CONNECTOR); + output_id, + DRM_MODE_OBJECT_CONNECTOR); if (!props) { return SDL_FALSE; @@ -619,8 +611,7 @@ KMSDRM_ConnectorCheckVrrCapable(uint32_t drm_fd, return SDL_FALSE; } -void -KMSDRM_CrtcSetVrr(uint32_t drm_fd, uint32_t crtc_id, SDL_bool enabled) +void KMSDRM_CrtcSetVrr(uint32_t drm_fd, uint32_t crtc_id, SDL_bool enabled) { uint32_t vrr_prop_id; if (!KMSDRM_VrrPropId(drm_fd, crtc_id, &vrr_prop_id)) { @@ -628,14 +619,13 @@ KMSDRM_CrtcSetVrr(uint32_t drm_fd, uint32_t crtc_id, SDL_bool enabled) } KMSDRM_drmModeObjectSetProperty(drm_fd, - crtc_id, - DRM_MODE_OBJECT_CRTC, - vrr_prop_id, - enabled); + crtc_id, + DRM_MODE_OBJECT_CRTC, + vrr_prop_id, + enabled); } -static SDL_bool -KMSDRM_CrtcGetVrr(uint32_t drm_fd, uint32_t crtc_id) +static SDL_bool KMSDRM_CrtcGetVrr(uint32_t drm_fd, uint32_t crtc_id) { uint32_t object_prop_id, vrr_prop_id; drmModeObjectPropertiesPtr props; @@ -646,10 +636,9 @@ KMSDRM_CrtcGetVrr(uint32_t drm_fd, uint32_t crtc_id) return SDL_FALSE; } - props = KMSDRM_drmModeObjectGetProperties(drm_fd, - crtc_id, - DRM_MODE_OBJECT_CRTC); + crtc_id, + DRM_MODE_OBJECT_CRTC); if (!props) { return SDL_FALSE; @@ -676,12 +665,11 @@ KMSDRM_CrtcGetVrr(uint32_t drm_fd, uint32_t crtc_id) /* Gets a DRM connector, builds an SDL_Display with it, and adds it to the list of SDL Displays in _this->displays[] */ -static void -KMSDRM_AddDisplay (_THIS, drmModeConnector *connector, drmModeRes *resources) +static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *resources) { SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); SDL_DisplayData *dispdata = NULL; - SDL_VideoDisplay display = {0}; + SDL_VideoDisplay display = { 0 }; SDL_DisplayModeData *modedata = NULL; drmModeEncoder *encoder = NULL; drmModeCrtc *crtc = NULL; @@ -690,7 +678,7 @@ KMSDRM_AddDisplay (_THIS, drmModeConnector *connector, drmModeRes *resources) int ret = 0; /* Reserve memory for the new display's driverdata. */ - dispdata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData)); + dispdata = (SDL_DisplayData *)SDL_calloc(1, sizeof(SDL_DisplayData)); if (dispdata == NULL) { ret = SDL_OutOfMemory(); goto cleanup; @@ -713,7 +701,7 @@ KMSDRM_AddDisplay (_THIS, drmModeConnector *connector, drmModeRes *resources) encoder = KMSDRM_drmModeGetEncoder(viddata->drm_fd, resources->encoders[i]); if (encoder == NULL) { - continue; + continue; } if (encoder->encoder_id == connector->encoder_id) { @@ -728,7 +716,7 @@ KMSDRM_AddDisplay (_THIS, drmModeConnector *connector, drmModeRes *resources) /* No encoder was connected, find the first supported one */ for (i = 0; i < resources->count_encoders; i++) { encoder = KMSDRM_drmModeGetEncoder(viddata->drm_fd, - resources->encoders[i]); + resources->encoders[i]); if (encoder == NULL) { continue; @@ -829,7 +817,7 @@ KMSDRM_AddDisplay (_THIS, drmModeConnector *connector, drmModeRes *resources) dispdata->original_mode = crtc->mode; dispdata->fullscreen_mode = crtc->mode; - if (dispdata->mode.hdisplay == 0 || dispdata->mode.vdisplay == 0 ) { + if (dispdata->mode.hdisplay == 0 || dispdata->mode.vdisplay == 0) { ret = SDL_SetError("Couldn't get a valid connector videomode."); goto cleanup; } @@ -898,8 +886,8 @@ cleanup: closed when we get to the end of this function. This is to be called early, in VideoInit(), because it gets us the videomode information, which SDL needs immediately after VideoInit(). */ -static int -KMSDRM_InitDisplays (_THIS) { +static int KMSDRM_InitDisplays(_THIS) +{ SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); drmModeRes *resources = NULL; @@ -933,7 +921,7 @@ KMSDRM_InitDisplays (_THIS) { we create an SDL_Display and add it to the list of SDL Displays. */ for (i = 0; i < resources->count_connectors; i++) { drmModeConnector *connector = KMSDRM_drmModeGetConnector(viddata->drm_fd, - resources->connectors[i]); + resources->connectors[i]); if (connector == NULL) { continue; @@ -970,7 +958,7 @@ KMSDRM_InitDisplays (_THIS) { /* THIS IS FOR VULKAN! Leave the FD closed, so VK can work. Will reopen this in CreateWindow, but only if requested a non-VK window. */ - close (viddata->drm_fd); + close(viddata->drm_fd); viddata->drm_fd = -1; cleanup: @@ -994,8 +982,7 @@ cleanup: These things are incompatible with Vulkan, which accesses the same resources internally so they must be free when trying to build a Vulkan surface. */ -static int -KMSDRM_GBMInit (_THIS, SDL_DisplayData *dispdata) +static int KMSDRM_GBMInit(_THIS, SDL_DisplayData *dispdata) { SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata; int ret = 0; @@ -1018,8 +1005,7 @@ KMSDRM_GBMInit (_THIS, SDL_DisplayData *dispdata) } /* Deinit the Vulkan-incompatible KMSDRM stuff. */ -static void -KMSDRM_GBMDeinit (_THIS, SDL_DisplayData *dispdata) +static void KMSDRM_GBMDeinit(_THIS, SDL_DisplayData *dispdata) { SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); @@ -1039,12 +1025,11 @@ KMSDRM_GBMDeinit (_THIS, SDL_DisplayData *dispdata) viddata->gbm_init = SDL_FALSE; } -static void -KMSDRM_DestroySurfaces(_THIS, SDL_Window *window) +static void KMSDRM_DestroySurfaces(_THIS, SDL_Window *window) { SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - SDL_WindowData *windata = (SDL_WindowData *) window->driverdata; - SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; + SDL_WindowData *windata = (SDL_WindowData *)window->driverdata; + SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata; int ret; /**********************************************/ @@ -1058,14 +1043,14 @@ KMSDRM_DestroySurfaces(_THIS, SDL_Window *window) /***********************************************************************/ ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd, dispdata->crtc->crtc_id, - dispdata->crtc->buffer_id, 0, 0, &dispdata->connector->connector_id, 1, - &dispdata->original_mode); + dispdata->crtc->buffer_id, 0, 0, &dispdata->connector->connector_id, 1, + &dispdata->original_mode); /* If we failed to set the original mode, try to set the connector prefered mode. */ if (ret && (dispdata->crtc->mode_valid == 0)) { ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd, dispdata->crtc->crtc_id, - dispdata->crtc->buffer_id, 0, 0, &dispdata->connector->connector_id, 1, - &dispdata->original_mode); + dispdata->crtc->buffer_id, 0, 0, &dispdata->connector->connector_id, 1, + &dispdata->original_mode); } if (ret) { @@ -1107,8 +1092,8 @@ KMSDRM_DestroySurfaces(_THIS, SDL_Window *window) } } -static void -KMSDRM_GetModeToSet(SDL_Window *window, drmModeModeInfo *out_mode) { +static void KMSDRM_GetModeToSet(SDL_Window *window, drmModeModeInfo *out_mode) +{ SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata; @@ -1118,7 +1103,7 @@ KMSDRM_GetModeToSet(SDL_Window *window, drmModeModeInfo *out_mode) { drmModeModeInfo *mode; mode = KMSDRM_GetClosestDisplayMode(display, - window->windowed.w, window->windowed.h, 0); + window->windowed.w, window->windowed.h, 0); if (mode) { *out_mode = *mode; @@ -1128,8 +1113,8 @@ KMSDRM_GetModeToSet(SDL_Window *window, drmModeModeInfo *out_mode) { } } -static void -KMSDRM_DirtySurfaces(SDL_Window *window) { +static void KMSDRM_DirtySurfaces(SDL_Window *window) +{ SDL_WindowData *windata = (SDL_WindowData *)window->driverdata; drmModeModeInfo mode; @@ -1146,8 +1131,7 @@ KMSDRM_DirtySurfaces(SDL_Window *window) { /* This determines the size of the fb, which comes from the GBM surface that we create here. */ -int -KMSDRM_CreateSurfaces(_THIS, SDL_Window * window) +int KMSDRM_CreateSurfaces(_THIS, SDL_Window *window) { SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); SDL_WindowData *windata = (SDL_WindowData *)window->driverdata; @@ -1167,9 +1151,9 @@ KMSDRM_CreateSurfaces(_THIS, SDL_Window * window) } if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev, - surface_fmt, surface_flags)) { + surface_fmt, surface_flags)) { SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, - "GBM surface format not supported. Trying anyway."); + "GBM surface format not supported. Trying anyway."); } /* The KMSDRM backend doesn't always set the mode the higher-level code in @@ -1183,8 +1167,8 @@ KMSDRM_CreateSurfaces(_THIS, SDL_Window * window) display->current_mode.format = SDL_PIXELFORMAT_ARGB8888; windata->gs = KMSDRM_gbm_surface_create(viddata->gbm_dev, - dispdata->mode.hdisplay, dispdata->mode.vdisplay, - surface_fmt, surface_flags); + dispdata->mode.hdisplay, dispdata->mode.vdisplay, + surface_fmt, surface_flags); if (!windata->gs) { return SDL_SetError("Could not create GBM surface"); @@ -1224,8 +1208,7 @@ cleanup: return ret; } -int -KMSDRM_VideoInit(_THIS) +int KMSDRM_VideoInit(_THIS) { int ret = 0; @@ -1256,8 +1239,7 @@ KMSDRM_VideoInit(_THIS) /* The driverdata pointers, like dispdata, viddata, windata, etc... are freed by SDL internals, so not our job. */ -void -KMSDRM_VideoQuit(_THIS) +void KMSDRM_VideoQuit(_THIS) { SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); @@ -1278,8 +1260,7 @@ KMSDRM_VideoQuit(_THIS) } /* Read modes from the connector modes, and store them in display->display_modes. */ -void -KMSDRM_GetDisplayModes(_THIS, SDL_VideoDisplay * display) +void KMSDRM_GetDisplayModes(_THIS, SDL_VideoDisplay *display) { SDL_DisplayData *dispdata = display->driverdata; drmModeConnector *conn = dispdata->connector; @@ -1305,8 +1286,7 @@ KMSDRM_GetDisplayModes(_THIS, SDL_VideoDisplay * display) } } -int -KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +int KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) { /* Set the dispdata->mode to the new mode and leave actual modesetting pending to be done on SwapWindow() via drmModeSetCrtc() */ @@ -1337,11 +1317,10 @@ KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) return 0; } -void -KMSDRM_DestroyWindow(_THIS, SDL_Window *window) +void KMSDRM_DestroyWindow(_THIS, SDL_Window *window) { - SDL_WindowData *windata = (SDL_WindowData *) window->driverdata; - SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; + SDL_WindowData *windata = (SDL_WindowData *)window->driverdata; + SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata; SDL_VideoData *viddata; SDL_bool is_vulkan = window->flags & SDL_WINDOW_VULKAN; /* Is this a VK window? */ unsigned int i, j; @@ -1355,7 +1334,7 @@ KMSDRM_DestroyWindow(_THIS, SDL_Window *window) viddata = windata->viddata; - if ( !is_vulkan && viddata->gbm_init) { + if (!is_vulkan && viddata->gbm_init) { /* Destroy cursor GBM BO of the display of this window. */ KMSDRM_DestroyCursorBO(_this, SDL_GetDisplayForWindow(window)); @@ -1370,15 +1349,15 @@ KMSDRM_DestroyWindow(_THIS, SDL_Window *window) added to the windows list. */ if (viddata->num_windows <= 1) { - /* Unload EGL/GL library and free egl_data. */ - if (_this->egl_data) { - SDL_EGL_UnloadLibrary(_this); - _this->gl_config.driver_loaded = 0; - } + /* Unload EGL/GL library and free egl_data. */ + if (_this->egl_data) { + SDL_EGL_UnloadLibrary(_this); + _this->gl_config.driver_loaded = 0; + } - /* Free display plane, and destroy GBM device. */ - KMSDRM_GBMDeinit(_this, dispdata); - } + /* Free display plane, and destroy GBM device. */ + KMSDRM_GBMDeinit(_this, dispdata); + } } else { @@ -1415,16 +1394,15 @@ KMSDRM_DestroyWindow(_THIS, SDL_Window *window) /* We simply IGNORE if it's a fullscreen window, window->flags don't */ /* reflect it: if it's fullscreen, KMSDRM_SetWindwoFullscreen() will */ /* be called by SDL later, and we can manage it there. */ -/**********************************************************************/ -int -KMSDRM_CreateWindow(_THIS, SDL_Window * window) +/**********************************************************************/ +int KMSDRM_CreateWindow(_THIS, SDL_Window *window) { SDL_WindowData *windata = NULL; SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata; SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); SDL_DisplayData *dispdata = display->driverdata; SDL_bool is_vulkan = window->flags & SDL_WINDOW_VULKAN; /* Is this a VK window? */ - SDL_bool vulkan_mode = viddata->vulkan_mode; /* Do we have any Vulkan windows? */ + SDL_bool vulkan_mode = viddata->vulkan_mode; /* Do we have any Vulkan windows? */ NativeDisplayType egl_display; drmModeModeInfo *mode; int ret = 0; @@ -1450,7 +1428,7 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window) /* After SDL_CreateWindow, most SDL2 programs will do SDL_CreateRenderer(), which will in turn call GL_CreateRenderer() or GLES2_CreateRenderer(). In order for the GL_CreateRenderer() or GLES2_CreateRenderer() call to - succeed without an unnecessary window re-creation, we must: + succeed without an unnecessary window re-creation, we must: -Mark the window as being OPENGL -Load the GL library (which can't be done until the GBM device has been created, so we have to do it here instead of doing it on VideoInit()) @@ -1484,9 +1462,8 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window) return SDL_SetError("Can't load EGL/GL library on window creation."); } } - - _this->gl_config.driver_loaded = 1; + _this->gl_config.driver_loaded = 1; } /* Create the cursor BO for the display of this window, @@ -1503,7 +1480,7 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window) If a window is fullscreen, SDL internals will call KMSDRM_SetWindowFullscreen() to reconfigure it if necessary. */ mode = KMSDRM_GetClosestDisplayMode(display, - window->windowed.w, window->windowed.h, 0 ); + window->windowed.w, window->windowed.h, 0); if (mode) { dispdata->fullscreen_mode = *mode; @@ -1524,7 +1501,7 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window) if (viddata->num_windows >= viddata->max_windows) { unsigned int new_max_windows = viddata->max_windows + 1; viddata->windows = (SDL_Window **)SDL_realloc(viddata->windows, - new_max_windows * sizeof(SDL_Window *)); + new_max_windows * sizeof(SDL_Window *)); viddata->max_windows = new_max_windows; if (!viddata->windows) { @@ -1547,7 +1524,7 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window) /* Allocated windata will be freed in KMSDRM_DestroyWindow, and KMSDRM_DestroyWindow() will be called by SDL_CreateWindow() - if we return error on any of the previous returns of the function. */ + if we return error on any of the previous returns of the function. */ return ret; } @@ -1593,28 +1570,23 @@ KMSDRM_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) return -1; } -void -KMSDRM_SetWindowTitle(_THIS, SDL_Window * window) +void KMSDRM_SetWindowTitle(_THIS, SDL_Window *window) { } -void -KMSDRM_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) +void KMSDRM_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon) { } -void -KMSDRM_SetWindowPosition(_THIS, SDL_Window * window) +void KMSDRM_SetWindowPosition(_THIS, SDL_Window *window) { } -void -KMSDRM_SetWindowSize(_THIS, SDL_Window * window) +void KMSDRM_SetWindowSize(_THIS, SDL_Window *window) { SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); if (!viddata->vulkan_mode) { KMSDRM_DirtySurfaces(window); } } -void -KMSDRM_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen) +void KMSDRM_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen) { SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); @@ -1622,28 +1594,22 @@ KMSDRM_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * displa KMSDRM_DirtySurfaces(window); } } -void -KMSDRM_ShowWindow(_THIS, SDL_Window * window) +void KMSDRM_ShowWindow(_THIS, SDL_Window *window) { } -void -KMSDRM_HideWindow(_THIS, SDL_Window * window) +void KMSDRM_HideWindow(_THIS, SDL_Window *window) { } -void -KMSDRM_RaiseWindow(_THIS, SDL_Window * window) +void KMSDRM_RaiseWindow(_THIS, SDL_Window *window) { } -void -KMSDRM_MaximizeWindow(_THIS, SDL_Window * window) +void KMSDRM_MaximizeWindow(_THIS, SDL_Window *window) { } -void -KMSDRM_MinimizeWindow(_THIS, SDL_Window * window) +void KMSDRM_MinimizeWindow(_THIS, SDL_Window *window) { } -void -KMSDRM_RestoreWindow(_THIS, SDL_Window * window) +void KMSDRM_RestoreWindow(_THIS, SDL_Window *window) { } @@ -1663,10 +1629,10 @@ KMSDRM_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) return SDL_FALSE; } - info->subsystem = SDL_SYSWM_KMSDRM; - info->info.kmsdrm.dev_index = viddata->devindex; - info->info.kmsdrm.drm_fd = viddata->drm_fd; - info->info.kmsdrm.gbm_dev = viddata->gbm_dev; + info->subsystem = SDL_SYSWM_KMSDRM; + info->info.kmsdrm.dev_index = viddata->devindex; + info->info.kmsdrm.drm_fd = viddata->drm_fd; + info->info.kmsdrm.gbm_dev = viddata->gbm_dev; return SDL_TRUE; } diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.h b/src/video/kmsdrm/SDL_kmsdrmvideo.h index b3e719cc5..32b987e9f 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.h +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h @@ -35,15 +35,15 @@ typedef struct SDL_VideoData { - int devindex; /* device index that was passed on creation */ - int drm_fd; /* DRM file desc */ - char devpath[32]; /* DRM dev path. */ + int devindex; /* device index that was passed on creation */ + int drm_fd; /* DRM file desc */ + char devpath[32]; /* DRM dev path. */ struct gbm_device *gbm_dev; SDL_bool video_init; /* Has VideoInit succeeded? */ SDL_bool vulkan_mode; /* Are we in Vulkan mode? One VK window is enough to be. */ - SDL_bool async_pageflip_support; /* Does the hardware support async. pageflips? */ + SDL_bool async_pageflip_support; /* Does the hardware support async. pageflips? */ SDL_Window **windows; int max_windows; @@ -55,13 +55,11 @@ typedef struct SDL_VideoData } SDL_VideoData; - typedef struct SDL_DisplayModeData { int mode_index; } SDL_DisplayModeData; - typedef struct SDL_DisplayData { drmModeConnector *connector; @@ -70,7 +68,7 @@ typedef struct SDL_DisplayData drmModeModeInfo original_mode; drmModeModeInfo fullscreen_mode; - drmModeCrtc *saved_crtc; /* CRTC to restore on quit */ + drmModeCrtc *saved_crtc; /* CRTC to restore on quit */ SDL_bool saved_vrr; /* DRM & GBM cursor stuff lives here, not in an SDL_Cursor's driverdata struct, @@ -104,12 +102,12 @@ typedef struct SDL_WindowData typedef struct KMSDRM_FBInfo { - int drm_fd; /* DRM file desc */ - uint32_t fb_id; /* DRM framebuffer ID */ + int drm_fd; /* DRM file desc */ + uint32_t fb_id; /* DRM framebuffer ID */ } KMSDRM_FBInfo; /* Helper functions */ -int KMSDRM_CreateSurfaces(_THIS, SDL_Window * window); +int KMSDRM_CreateSurfaces(_THIS, SDL_Window *window); KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo); KMSDRM_FBInfo *KMSDRM_FBFromBO2(_THIS, struct gbm_bo *bo, int w, int h); SDL_bool KMSDRM_WaitPageflip(_THIS, SDL_WindowData *windata); @@ -148,11 +146,11 @@ SDL_bool KMSDRM_GetWindowWMInfo(_THIS, SDL_Window * window, int KMSDRM_GLES_LoadLibrary(_THIS, const char *path); void *KMSDRM_GLES_GetProcAddress(_THIS, const char *proc); void KMSDRM_GLES_UnloadLibrary(_THIS); -SDL_GLContext KMSDRM_GLES_CreateContext(_THIS, SDL_Window * window); -int KMSDRM_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); +SDL_GLContext KMSDRM_GLES_CreateContext(_THIS, SDL_Window *window); +int KMSDRM_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); int KMSDRM_GLES_SetSwapInterval(_THIS, int interval); int KMSDRM_GLES_GetSwapInterval(_THIS); -int KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window); +int KMSDRM_GLES_SwapWindow(_THIS, SDL_Window *window); void KMSDRM_GLES_DeleteContext(_THIS, SDL_GLContext context); #endif /* __SDL_KMSDRMVIDEO_H__ */ diff --git a/src/video/kmsdrm/SDL_kmsdrmvulkan.c b/src/video/kmsdrm/SDL_kmsdrmvulkan.c index 4c64c9441..6490fee13 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvulkan.c +++ b/src/video/kmsdrm/SDL_kmsdrmvulkan.c @@ -38,9 +38,9 @@ #include "sys/ioctl.h" #if defined(__OpenBSD__) -#define DEFAULT_VULKAN "libvulkan.so" +#define DEFAULT_VULKAN "libvulkan.so" #else -#define DEFAULT_VULKAN "libvulkan.so.1" +#define DEFAULT_VULKAN "libvulkan.so.1" #endif int KMSDRM_Vulkan_LoadLibrary(_THIS, const char *path) @@ -97,8 +97,7 @@ int KMSDRM_Vulkan_LoadLibrary(_THIS, const char *path) goto fail; } - for (i = 0; i < extensionCount; i++) - { + for (i = 0; i < extensionCount; i++) { if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { hasSurfaceExtension = SDL_TRUE; } else if (SDL_strcmp(VK_KHR_DISPLAY_EXTENSION_NAME, extensions[i].extensionName) == 0) { @@ -109,12 +108,10 @@ int KMSDRM_Vulkan_LoadLibrary(_THIS, const char *path) SDL_free(extensions); if (!hasSurfaceExtension) { - SDL_SetError("Installed Vulkan doesn't implement the " - VK_KHR_SURFACE_EXTENSION_NAME " extension"); + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_SURFACE_EXTENSION_NAME " extension"); goto fail; } else if (!hasDisplayExtension) { - SDL_SetError("Installed Vulkan doesn't implement the " - VK_KHR_DISPLAY_EXTENSION_NAME "extension"); + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_DISPLAY_EXTENSION_NAME "extension"); goto fail; } @@ -145,9 +142,9 @@ void KMSDRM_Vulkan_UnloadLibrary(_THIS) /* vkCreateInstance(). */ /*********************************************************************/ SDL_bool KMSDRM_Vulkan_GetInstanceExtensions(_THIS, - SDL_Window *window, - unsigned *count, - const char **names) + SDL_Window *window, + unsigned *count, + const char **names) { static const char *const extensionsForKMSDRM[] = { VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_DISPLAY_EXTENSION_NAME @@ -157,8 +154,8 @@ SDL_bool KMSDRM_Vulkan_GetInstanceExtensions(_THIS, return SDL_FALSE; } return SDL_Vulkan_GetInstanceExtensions_Helper( - count, names, SDL_arraysize(extensionsForKMSDRM), - extensionsForKMSDRM); + count, names, SDL_arraysize(extensionsForKMSDRM), + extensionsForKMSDRM); } void KMSDRM_Vulkan_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h) @@ -178,12 +175,12 @@ void KMSDRM_Vulkan_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h) /* and we get it here, ready to use. */ /* Extensions specific for this platform are activated in */ /* KMSDRM_Vulkan_GetInstanceExtensions(), like we do with */ -/* VK_KHR_DISPLAY_EXTENSION_NAME, which is what we need for x-less VK. */ +/* VK_KHR_DISPLAY_EXTENSION_NAME, which is what we need for x-less VK. */ /***********************************************************************/ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, - SDL_Window *window, - VkInstance instance, - VkSurfaceKHR *surface) + SDL_Window *window, + VkInstance instance, + VkSurfaceKHR *surface) { VkPhysicalDevice gpu = NULL; uint32_t gpu_count; @@ -205,8 +202,8 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, VkExtent2D image_size; VkDisplayKHR display; VkDisplayModeKHR display_mode = (VkDisplayModeKHR)0; - VkDisplayModePropertiesKHR display_mode_props = {0}; - VkDisplayModeParametersKHR new_mode_parameters = { {0, 0}, 0}; + VkDisplayModePropertiesKHR display_mode_props = { 0 }; + VkDisplayModeParametersKHR new_mode_parameters = { { 0, 0 }, 0 }; /* Prefer a plane that supports per-pixel alpha. */ VkDisplayPlaneAlphaFlagBitsKHR alpha_mode = VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR; @@ -307,13 +304,11 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, /* Get the physical device properties. */ vkGetPhysicalDeviceProperties( physical_devices[i], - device_props - ); + device_props); /* Is this device a real GPU that supports API version 1 at least? */ - if (device_props->apiVersion >= 1 && - (device_props->deviceType == 1 || device_props->deviceType == 2)) - { + if (device_props->apiVersion >= 1 && + (device_props->deviceType == 1 || device_props->deviceType == 2)) { gpu = physical_devices[i]; valid_gpu = SDL_TRUE; break; @@ -335,29 +330,29 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, } /* Get the props of the displays of the physical device. */ - display_props = (VkDisplayPropertiesKHR *) SDL_malloc(display_count * sizeof(*display_props)); + display_props = (VkDisplayPropertiesKHR *)SDL_malloc(display_count * sizeof(*display_props)); vkGetPhysicalDeviceDisplayPropertiesKHR(gpu, - &display_count, - display_props); + &display_count, + display_props); /* Get the chosen display based on the display index. */ display = display_props[display_index].display; /* Get the list of the display videomodes. */ vkGetDisplayModePropertiesKHR(gpu, - display, - &mode_count, NULL); + display, + &mode_count, NULL); if (mode_count == 0) { SDL_SetError("Vulkan can't find any video modes for display %i (%s)\n", 0, - display_props[display_index].displayName); + display_props[display_index].displayName); goto clean; } - mode_props = (VkDisplayModePropertiesKHR *) SDL_malloc(mode_count * sizeof(*mode_props)); + mode_props = (VkDisplayModePropertiesKHR *)SDL_malloc(mode_count * sizeof(*mode_props)); vkGetDisplayModePropertiesKHR(gpu, - display, - &mode_count, mode_props); + display, + &mode_count, mode_props); /* Get a video mode equal to the window size among the predefined ones, if possible. @@ -367,8 +362,7 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, buffer, and Vulkan would give us a confusing VK_ERROR_SURFACE_LOST_KHR). */ for (i = 0; i < mode_count; i++) { if (mode_props[i].parameters.visibleRegion.width == window->w && - mode_props[i].parameters.visibleRegion.height == window->h) - { + mode_props[i].parameters.visibleRegion.height == window->h) { display_mode_props = mode_props[i]; mode_found = SDL_TRUE; break; @@ -377,7 +371,7 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, if (mode_found && display_mode_props.parameters.visibleRegion.width > 0 && - display_mode_props.parameters.visibleRegion.height > 0 ) { + display_mode_props.parameters.visibleRegion.height > 0) { /* Found a suitable mode among the predefined ones. Use that. */ display_mode = display_mode_props.displayMode; } else { @@ -407,8 +401,8 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, /* Just in case we get here without a display_mode. */ if (!display_mode) { - SDL_SetError("Vulkan couldn't get a display mode."); - goto clean; + SDL_SetError("Vulkan couldn't get a display mode."); + goto clean; } /* Get the list of the physical device planes. */ @@ -428,7 +422,7 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, for (i = 0; i < plane_count; i++) { uint32_t supported_displays_count = 0; - VkDisplayKHR* supported_displays; + VkDisplayKHR *supported_displays; /* See if the plane is compatible with the current display. */ vkGetDisplayPlaneSupportedDisplaysKHR(gpu, i, &supported_displays_count, NULL); @@ -438,9 +432,9 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, } /* Get the list of displays supported by this plane. */ - supported_displays = (VkDisplayKHR*)SDL_malloc(sizeof(VkDisplayKHR) * supported_displays_count); + supported_displays = (VkDisplayKHR *)SDL_malloc(sizeof(VkDisplayKHR) * supported_displays_count); vkGetDisplayPlaneSupportedDisplaysKHR(gpu, i, - &supported_displays_count, supported_displays); + &supported_displays_count, supported_displays); /* The plane must be bound to the chosen display, or not in use. If none of these is true, iterate to another plane. */ @@ -489,7 +483,7 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, image_size.width = window->w; image_size.height = window->h; - + SDL_zero(display_plane_surface_create_info); display_plane_surface_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR; display_plane_surface_create_info.displayMode = display_mode; @@ -498,12 +492,12 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, display_plane_surface_create_info.transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; display_plane_surface_create_info.alphaMode = alpha_mode; result = vkCreateDisplayPlaneSurfaceKHR(instance, - &display_plane_surface_create_info, - NULL, - surface); + &display_plane_surface_create_info, + NULL, + surface); if (result != VK_SUCCESS) { SDL_SetError("vkCreateDisplayPlaneSurfaceKHR failed: %s", - SDL_Vulkan_GetResultString(result)); + SDL_Vulkan_GetResultString(result)); goto clean; } diff --git a/src/video/kmsdrm/SDL_kmsdrmvulkan.h b/src/video/kmsdrm/SDL_kmsdrmvulkan.h index 92d08732c..82f011372 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvulkan.h +++ b/src/video/kmsdrm/SDL_kmsdrmvulkan.h @@ -37,14 +37,14 @@ int KMSDRM_Vulkan_LoadLibrary(_THIS, const char *path); void KMSDRM_Vulkan_UnloadLibrary(_THIS); SDL_bool KMSDRM_Vulkan_GetInstanceExtensions(_THIS, - SDL_Window *window, - unsigned *count, - const char **names); + SDL_Window *window, + unsigned *count, + const char **names); void KMSDRM_Vulkan_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h); SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, - SDL_Window *window, - VkInstance instance, - VkSurfaceKHR *surface); + SDL_Window *window, + VkInstance instance, + VkSurfaceKHR *surface); #endif diff --git a/src/video/n3ds/SDL_n3dsevents.c b/src/video/n3ds/SDL_n3dsevents.c index 6b2126b1b..34ce4fab0 100644 --- a/src/video/n3ds/SDL_n3dsevents.c +++ b/src/video/n3ds/SDL_n3dsevents.c @@ -28,8 +28,7 @@ #include "SDL_n3dsevents_c.h" #include "SDL_n3dstouch.h" -void -N3DS_PumpEvents(_THIS) +void N3DS_PumpEvents(_THIS) { hidScanInput(); N3DS_PollTouch(); diff --git a/src/video/n3ds/SDL_n3dsframebuffer.c b/src/video/n3ds/SDL_n3dsframebuffer.c index 1de24d023..c69d3a8a1 100644 --- a/src/video/n3ds/SDL_n3dsframebuffer.c +++ b/src/video/n3ds/SDL_n3dsframebuffer.c @@ -40,8 +40,7 @@ SDL_FORCE_INLINE int GetDestOffset(int x, int y, int dest_width); SDL_FORCE_INLINE int GetSourceOffset(int x, int y, int source_width); SDL_FORCE_INLINE void FlushN3DSBuffer(const void *buffer, u32 bufsize, gfxScreen_t screen); -int -SDL_N3DS_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch) +int SDL_N3DS_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch) { SDL_Surface *framebuffer; @@ -62,7 +61,7 @@ SDL_N3DS_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void SDL_FORCE_INLINE void FreePreviousWindowFramebuffer(SDL_Window *window) { - SDL_Surface *surface = (SDL_Surface *) SDL_GetWindowData(window, N3DS_SURFACE); + SDL_Surface *surface = (SDL_Surface *)SDL_GetWindowData(window, N3DS_SURFACE); SDL_FreeSurface(surface); } @@ -76,26 +75,25 @@ CreateNewWindowFramebuffer(SDL_Window *window) return SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask); } -int -SDL_N3DS_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects) +int SDL_N3DS_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects) { - SDL_WindowData *drv_data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *drv_data = (SDL_WindowData *)window->driverdata; SDL_Surface *surface; u16 width, height; u32 *framebuffer; u32 bufsize; - surface = (SDL_Surface *) SDL_GetWindowData(window, N3DS_SURFACE); + surface = (SDL_Surface *)SDL_GetWindowData(window, N3DS_SURFACE); if (surface == NULL) { return SDL_SetError("%s: Unable to get the window surface.", __func__); } /* Get the N3DS internal framebuffer and its size */ - framebuffer = (u32 *) gfxGetFramebuffer(drv_data->screen, GFX_LEFT, &width, &height); + framebuffer = (u32 *)gfxGetFramebuffer(drv_data->screen, GFX_LEFT, &width, &height); bufsize = width * height * 4; - CopyFramebuffertoN3DS(framebuffer, (Dimensions) { width, height }, - surface->pixels, (Dimensions) { surface->w, surface->h }); + CopyFramebuffertoN3DS(framebuffer, (Dimensions){ width, height }, + surface->pixels, (Dimensions){ surface->w, surface->h }); FlushN3DSBuffer(framebuffer, bufsize, drv_data->screen); return 0; @@ -135,11 +133,10 @@ FlushN3DSBuffer(const void *buffer, u32 bufsize, gfxScreen_t screen) gfxScreenSwapBuffers(screen, false); } -void -SDL_N3DS_DestroyWindowFramebuffer(_THIS, SDL_Window *window) +void SDL_N3DS_DestroyWindowFramebuffer(_THIS, SDL_Window *window) { SDL_Surface *surface; - surface = (SDL_Surface *) SDL_SetWindowData(window, N3DS_SURFACE, NULL); + surface = (SDL_Surface *)SDL_SetWindowData(window, N3DS_SURFACE, NULL); SDL_FreeSurface(surface); } diff --git a/src/video/n3ds/SDL_n3dsswkb.c b/src/video/n3ds/SDL_n3dsswkb.c index b577a3639..7560d39c2 100644 --- a/src/video/n3ds/SDL_n3dsswkb.c +++ b/src/video/n3ds/SDL_n3dsswkb.c @@ -30,20 +30,17 @@ static SwkbdState sw_keyboard; const static size_t BUFFER_SIZE = 256; -void -N3DS_SwkbInit() +void N3DS_SwkbInit() { swkbdInit(&sw_keyboard, SWKBD_TYPE_NORMAL, 2, -1); } -void -N3DS_SwkbPoll() +void N3DS_SwkbPoll() { return; } -void -N3DS_SwkbQuit() +void N3DS_SwkbQuit() { return; } @@ -54,8 +51,7 @@ N3DS_HasScreenKeyboardSupport(_THIS) return SDL_TRUE; } -void -N3DS_StartTextInput(_THIS) +void N3DS_StartTextInput(_THIS) { char buffer[BUFFER_SIZE]; SwkbdButton button_pressed; @@ -65,8 +61,7 @@ N3DS_StartTextInput(_THIS) } } -void -N3DS_StopTextInput(_THIS) +void N3DS_StopTextInput(_THIS) { return; } diff --git a/src/video/n3ds/SDL_n3dstouch.c b/src/video/n3ds/SDL_n3dstouch.c index fca0ae30f..a6e41bfbb 100644 --- a/src/video/n3ds/SDL_n3dstouch.c +++ b/src/video/n3ds/SDL_n3dstouch.c @@ -39,20 +39,17 @@ #define TOUCHSCREEN_SCALE_X 1.0f / GSP_SCREEN_HEIGHT_BOTTOM #define TOUCHSCREEN_SCALE_Y 1.0f / GSP_SCREEN_WIDTH -void -N3DS_InitTouch(void) +void N3DS_InitTouch(void) { SDL_AddTouch(N3DS_TOUCH_ID, SDL_TOUCH_DEVICE_DIRECT, "Touchscreen"); } -void -N3DS_QuitTouch(void) +void N3DS_QuitTouch(void) { SDL_DelTouch(N3DS_TOUCH_ID); } -void -N3DS_PollTouch(void) +void N3DS_PollTouch(void) { touchPosition touch; static SDL_bool was_pressed = SDL_FALSE; diff --git a/src/video/n3ds/SDL_n3dsvideo.c b/src/video/n3ds/SDL_n3dsvideo.c index 490e4110b..e342acbd3 100644 --- a/src/video/n3ds/SDL_n3dsvideo.c +++ b/src/video/n3ds/SDL_n3dsvideo.c @@ -47,18 +47,16 @@ typedef struct /* N3DS driver bootstrap functions */ -static void -N3DS_DeleteDevice(SDL_VideoDevice *device) +static void N3DS_DeleteDevice(SDL_VideoDevice *device) { SDL_free(device->displays); SDL_free(device->driverdata); SDL_free(device); } -static SDL_VideoDevice * -N3DS_CreateDevice(void) +static SDL_VideoDevice *N3DS_CreateDevice(void) { - SDL_VideoDevice *device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + SDL_VideoDevice *device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device == NULL) { SDL_OutOfMemory(); return 0; @@ -90,8 +88,7 @@ N3DS_CreateDevice(void) VideoBootStrap N3DS_bootstrap = { N3DSVID_DRIVER_NAME, "N3DS Video Driver", N3DS_CreateDevice }; -static int -N3DS_VideoInit(_THIS) +static int N3DS_VideoInit(_THIS) { gfxInit(GSP_RGBA8_OES, GSP_RGBA8_OES, false); hidInit(); @@ -135,8 +132,7 @@ AddN3DSDisplay(gfxScreen_t screen) SDL_AddVideoDisplay(&display, SDL_FALSE); } -static void -N3DS_VideoQuit(_THIS) +static void N3DS_VideoQuit(_THIS) { N3DS_SwkbQuit(); N3DS_QuitTouch(); @@ -145,17 +141,15 @@ N3DS_VideoQuit(_THIS) gfxExit(); } -static void -N3DS_GetDisplayModes(_THIS, SDL_VideoDisplay *display) +static void N3DS_GetDisplayModes(_THIS, SDL_VideoDisplay *display) { /* Each display only has a single mode */ SDL_AddDisplayMode(display, &display->current_mode); } -static int -N3DS_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) +static int N3DS_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) { - DisplayDriverData *driver_data = (DisplayDriverData *) display->driverdata; + DisplayDriverData *driver_data = (DisplayDriverData *)display->driverdata; if (driver_data == NULL) { return -1; } @@ -167,23 +161,21 @@ N3DS_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) return 0; } -static int -N3DS_CreateWindow(_THIS, SDL_Window *window) +static int N3DS_CreateWindow(_THIS, SDL_Window *window) { DisplayDriverData *display_data; - SDL_WindowData *window_data = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); + SDL_WindowData *window_data = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); if (window_data == NULL) { return SDL_OutOfMemory(); } - display_data = (DisplayDriverData *) SDL_GetDisplayDriverData(window->display_index); + display_data = (DisplayDriverData *)SDL_GetDisplayDriverData(window->display_index); window_data->screen = display_data->screen; window->driverdata = window_data; SDL_SetKeyboardFocus(window); return 0; } -static void -N3DS_DestroyWindow(_THIS, SDL_Window *window) +static void N3DS_DestroyWindow(_THIS, SDL_Window *window) { if (window == NULL) { return; diff --git a/src/video/ngage/SDL_ngageevents.cpp b/src/video/ngage/SDL_ngageevents.cpp index 71d9975db..728101581 100644 --- a/src/video/ngage/SDL_ngageevents.cpp +++ b/src/video/ngage/SDL_ngageevents.cpp @@ -40,12 +40,11 @@ extern "C" { #include "SDL_ngagevideo.h" #include "SDL_ngageevents_c.h" -int HandleWsEvent(_THIS, const TWsEvent& aWsEvent); +int HandleWsEvent(_THIS, const TWsEvent &aWsEvent); -void -NGAGE_PumpEvents(_THIS) +void NGAGE_PumpEvents(_THIS) { - SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata; + SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata; while (phdata->NGAGE_WsEventStatus != KRequestPending) { phdata->NGAGE_WsSession.GetEvent(phdata->NGAGE_WsEvent); @@ -73,123 +72,121 @@ static SDL_Scancode ConvertScancode(_THIS, int key) { SDL_Keycode keycode; - switch(key) - { - case EStdKeyBackspace: // Clear key - keycode = SDLK_BACKSPACE; - break; - case 0x31: // 1 - keycode = SDLK_1; - break; - case 0x32: // 2 - keycode = SDLK_2; - break; - case 0x33: // 3 - keycode = SDLK_3; - break; - case 0x34: // 4 - keycode = SDLK_4; - break; - case 0x35: // 5 - keycode = SDLK_5; - break; - case 0x36: // 6 - keycode = SDLK_6; - break; - case 0x37: // 7 - keycode = SDLK_7; - break; - case 0x38: // 8 - keycode = SDLK_8; - break; - case 0x39: // 9 - keycode = SDLK_9; - break; - case 0x30: // 0 - keycode = SDLK_0; - break; - case 0x2a: // Asterisk - keycode = SDLK_ASTERISK; - break; - case EStdKeyHash: // Hash - keycode = SDLK_HASH; - break; - case EStdKeyDevice0: // Left softkey - keycode = SDLK_SOFTLEFT; - break; - case EStdKeyDevice1: // Right softkey - keycode = SDLK_SOFTRIGHT; - break; - case EStdKeyApplication0: // Call softkey - keycode = SDLK_CALL; - break; - case EStdKeyApplication1: // End call softkey - keycode = SDLK_ENDCALL; - break; - case EStdKeyDevice3: // Middle softkey - keycode = SDLK_SELECT; - break; - case EStdKeyUpArrow: // Up arrow - keycode = SDLK_UP; - break; - case EStdKeyDownArrow: // Down arrow - keycode = SDLK_DOWN; - break; - case EStdKeyLeftArrow: // Left arrow - keycode = SDLK_LEFT; - break; - case EStdKeyRightArrow: // Right arrow - keycode = SDLK_RIGHT; - break; - default: - keycode = SDLK_UNKNOWN; - break; + switch (key) { + case EStdKeyBackspace: // Clear key + keycode = SDLK_BACKSPACE; + break; + case 0x31: // 1 + keycode = SDLK_1; + break; + case 0x32: // 2 + keycode = SDLK_2; + break; + case 0x33: // 3 + keycode = SDLK_3; + break; + case 0x34: // 4 + keycode = SDLK_4; + break; + case 0x35: // 5 + keycode = SDLK_5; + break; + case 0x36: // 6 + keycode = SDLK_6; + break; + case 0x37: // 7 + keycode = SDLK_7; + break; + case 0x38: // 8 + keycode = SDLK_8; + break; + case 0x39: // 9 + keycode = SDLK_9; + break; + case 0x30: // 0 + keycode = SDLK_0; + break; + case 0x2a: // Asterisk + keycode = SDLK_ASTERISK; + break; + case EStdKeyHash: // Hash + keycode = SDLK_HASH; + break; + case EStdKeyDevice0: // Left softkey + keycode = SDLK_SOFTLEFT; + break; + case EStdKeyDevice1: // Right softkey + keycode = SDLK_SOFTRIGHT; + break; + case EStdKeyApplication0: // Call softkey + keycode = SDLK_CALL; + break; + case EStdKeyApplication1: // End call softkey + keycode = SDLK_ENDCALL; + break; + case EStdKeyDevice3: // Middle softkey + keycode = SDLK_SELECT; + break; + case EStdKeyUpArrow: // Up arrow + keycode = SDLK_UP; + break; + case EStdKeyDownArrow: // Down arrow + keycode = SDLK_DOWN; + break; + case EStdKeyLeftArrow: // Left arrow + keycode = SDLK_LEFT; + break; + case EStdKeyRightArrow: // Right arrow + keycode = SDLK_RIGHT; + break; + default: + keycode = SDLK_UNKNOWN; + break; } return SDL_GetScancodeFromKey(keycode); } -int HandleWsEvent(_THIS, const TWsEvent& aWsEvent) +int HandleWsEvent(_THIS, const TWsEvent &aWsEvent) { - SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata; - int posted = 0; + SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata; + int posted = 0; - switch (aWsEvent.Type()) + switch (aWsEvent.Type()) { + case EEventKeyDown: /* Key events */ + SDL_SendKeyboardKey(SDL_PRESSED, ConvertScancode(_this, aWsEvent.Key()->iScanCode)); + break; + case EEventKeyUp: /* Key events */ + SDL_SendKeyboardKey(SDL_RELEASED, ConvertScancode(_this, aWsEvent.Key()->iScanCode)); + break; + case EEventFocusGained: /* SDL window got focus */ + phdata->NGAGE_IsWindowFocused = ETrue; + /* Draw window background and screen buffer */ + DisableKeyBlocking(_this); + RedrawWindowL(_this); + break; + case EEventFocusLost: /* SDL window lost focus */ { - case EEventKeyDown: /* Key events */ - SDL_SendKeyboardKey(SDL_PRESSED, ConvertScancode(_this, aWsEvent.Key()->iScanCode)); - break; - case EEventKeyUp: /* Key events */ - SDL_SendKeyboardKey(SDL_RELEASED, ConvertScancode(_this, aWsEvent.Key()->iScanCode)); - break; - case EEventFocusGained: /* SDL window got focus */ - phdata->NGAGE_IsWindowFocused = ETrue; - /* Draw window background and screen buffer */ - DisableKeyBlocking(_this); - RedrawWindowL(_this); - break; - case EEventFocusLost: /* SDL window lost focus */ - { - phdata->NGAGE_IsWindowFocused = EFalse; - RWsSession s; - s.Connect(); - RWindowGroup g(s); - g.Construct(TUint32(&g), EFalse); - g.EnableReceiptOfFocus(EFalse); - RWindow w(s); - w.Construct(g, TUint32(&w)); - w.SetExtent(TPoint(0, 0), phdata->NGAGE_WsWindow.Size()); - w.SetOrdinalPosition(0); - w.Activate(); - w.Close(); - g.Close(); - s.Close(); - break; - } - case EEventModifiersChanged: - break; - default: - break; + phdata->NGAGE_IsWindowFocused = EFalse; + RWsSession s; + s.Connect(); + RWindowGroup g(s); + g.Construct(TUint32(&g), EFalse); + g.EnableReceiptOfFocus(EFalse); + RWindow w(s); + w.Construct(g, TUint32(&w)); + w.SetExtent(TPoint(0, 0), phdata->NGAGE_WsWindow.Size()); + w.SetOrdinalPosition(0); + w.Activate(); + w.Close(); + g.Close(); + s.Close(); + break; + } + case EEventModifiersChanged: + break; + default: + break; } return posted; } diff --git a/src/video/ngage/SDL_ngageframebuffer.cpp b/src/video/ngage/SDL_ngageframebuffer.cpp index f8cea52bd..00747557c 100644 --- a/src/video/ngage/SDL_ngageframebuffer.cpp +++ b/src/video/ngage/SDL_ngageframebuffer.cpp @@ -38,17 +38,17 @@ */ static TUint32 NGAGE_HWPalette_256_to_Screen[256]; -int GetBpp(TDisplayMode displaymode); +int GetBpp(TDisplayMode displaymode); void DirectUpdate(_THIS, int numrects, SDL_Rect *rects); void DrawBackground(_THIS); -void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer); +void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16 *screenBuffer); void RedrawWindowL(_THIS); -int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch) +int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch) { - SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata; - SDL_Surface *surface; - const Uint32 surface_format = SDL_PIXELFORMAT_RGB444; + SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata; + SDL_Surface *surface; + const Uint32 surface_format = SDL_PIXELFORMAT_RGB444; int w, h; /* Free the old framebuffer surface */ @@ -65,24 +65,24 @@ int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * forma SDL_SetWindowData(window, NGAGE_SURFACE, surface); *format = surface_format; *pixels = surface->pixels; - *pitch = surface->pitch; + *pitch = surface->pitch; /* Initialise Epoc frame buffer */ - TDisplayMode displayMode = phdata->NGAGE_WsScreen->DisplayMode(); + TDisplayMode displayMode = phdata->NGAGE_WsScreen->DisplayMode(); - TScreenInfoV01 screenInfo; + TScreenInfoV01 screenInfo; TPckg sInfo(screenInfo); UserSvr::ScreenInfo(sInfo); - phdata->NGAGE_ScreenSize = screenInfo.iScreenSize; - phdata->NGAGE_DisplayMode = displayMode; - phdata->NGAGE_HasFrameBuffer = screenInfo.iScreenAddressValid; - phdata->NGAGE_FrameBuffer = phdata->NGAGE_HasFrameBuffer ? (TUint8*) screenInfo.iScreenAddress : NULL; - phdata->NGAGE_BytesPerPixel = ((GetBpp(displayMode)-1) / 8) + 1; + phdata->NGAGE_ScreenSize = screenInfo.iScreenSize; + phdata->NGAGE_DisplayMode = displayMode; + phdata->NGAGE_HasFrameBuffer = screenInfo.iScreenAddressValid; + phdata->NGAGE_FrameBuffer = phdata->NGAGE_HasFrameBuffer ? (TUint8 *)screenInfo.iScreenAddress : NULL; + phdata->NGAGE_BytesPerPixel = ((GetBpp(displayMode) - 1) / 8) + 1; phdata->NGAGE_BytesPerScanLine = screenInfo.iScreenSize.iWidth * phdata->NGAGE_BytesPerPixel; - phdata->NGAGE_BytesPerScreen = phdata->NGAGE_BytesPerScanLine * phdata->NGAGE_ScreenSize.iHeight; + phdata->NGAGE_BytesPerScreen = phdata->NGAGE_BytesPerScanLine * phdata->NGAGE_ScreenSize.iHeight; SDL_Log("Screen width %d", screenInfo.iScreenSize.iWidth); SDL_Log("Screen height %d", screenInfo.iScreenSize.iHeight); @@ -103,14 +103,14 @@ int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * forma } else { phdata->NGAGE_FrameBuffer += 32; } - #if 0 +#if 0 if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 12) { phdata->NGAGE_FrameBuffer += 16 * 2; } if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 16) { phdata->NGAGE_FrameBuffer += 16 * 2; } - #endif +#endif // Get draw device for updating the screen TScreenInfoV01 screenInfo2; @@ -143,12 +143,12 @@ int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * forma return 0; } -int SDL_NGAGE_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects) +int SDL_NGAGE_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects) { - static int frame_number; + static int frame_number; SDL_Surface *surface; - surface = (SDL_Surface *) SDL_GetWindowData(window, NGAGE_SURFACE); + surface = (SDL_Surface *)SDL_GetWindowData(window, NGAGE_SURFACE); if (surface == NULL) { return SDL_SetError("Couldn't find ngage surface for window"); } @@ -161,16 +161,16 @@ int SDL_NGAGE_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect SDL_SaveBMP(surface, file); } - DirectUpdate(_this, numrects, (SDL_Rect*)rects); + DirectUpdate(_this, numrects, (SDL_Rect *)rects); return 0; } -void SDL_NGAGE_DestroyWindowFramebuffer(_THIS, SDL_Window * window) +void SDL_NGAGE_DestroyWindowFramebuffer(_THIS, SDL_Window *window) { SDL_Surface *surface; - surface = (SDL_Surface *) SDL_SetWindowData(window, NGAGE_SURFACE, NULL); + surface = (SDL_Surface *)SDL_SetWindowData(window, NGAGE_SURFACE, NULL); SDL_FreeSurface(surface); } @@ -182,7 +182,7 @@ void SDL_NGAGE_DestroyWindowFramebuffer(_THIS, SDL_Window * window) #include #include -EXPORT_C void NGAGE_Runtime::GetScreenInfo(TScreenInfoV01& screenInfo2) +EXPORT_C void NGAGE_Runtime::GetScreenInfo(TScreenInfoV01 &screenInfo2) { TPckg sInfo2(screenInfo2); UserSvr::ScreenInfo(sInfo2); @@ -199,34 +199,34 @@ int GetBpp(TDisplayMode displaymode) void DrawBackground(_THIS) { - SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata; + SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata; /* Draw background */ - TUint16* screenBuffer = (TUint16*)phdata->NGAGE_FrameBuffer; + TUint16 *screenBuffer = (TUint16 *)phdata->NGAGE_FrameBuffer; /* Draw black background */ Mem::FillZ(screenBuffer, phdata->NGAGE_BytesPerScreen); } -void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer) +void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16 *screenBuffer) { - SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata; - SDL_Surface *screen = (SDL_Surface*)SDL_GetWindowData(_this->windows, NGAGE_SURFACE); + SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata; + SDL_Surface *screen = (SDL_Surface *)SDL_GetWindowData(_this->windows, NGAGE_SURFACE); TInt i; - TDisplayMode displayMode = phdata->NGAGE_DisplayMode; - const TInt sourceNumBytesPerPixel = ((GetBpp(displayMode)-1) / 8) + 1; + TDisplayMode displayMode = phdata->NGAGE_DisplayMode; + const TInt sourceNumBytesPerPixel = ((GetBpp(displayMode) - 1) / 8) + 1; - const TPoint fixedOffset = phdata->NGAGE_ScreenOffset; - const TInt screenW = screen->w; - const TInt screenH = screen->h; - const TInt sourceScanlineLength = screenW; - const TInt targetScanlineLength = phdata->NGAGE_ScreenSize.iWidth; + const TPoint fixedOffset = phdata->NGAGE_ScreenOffset; + const TInt screenW = screen->w; + const TInt screenH = screen->h; + const TInt sourceScanlineLength = screenW; + const TInt targetScanlineLength = phdata->NGAGE_ScreenSize.iWidth; /* Render the rectangles in the list */ for (i = 0; i < numrects; ++i) { - const SDL_Rect& currentRect = rects[i]; - SDL_Rect rect2; + const SDL_Rect ¤tRect = rects[i]; + SDL_Rect rect2; rect2.x = currentRect.x; rect2.y = currentRect.y; rect2.w = currentRect.w; @@ -246,105 +246,96 @@ void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer) } /* Clip from bottom */ - maxY = Min(maxY, phdata->NGAGE_ScreenSize.iHeight-1); + maxY = Min(maxY, phdata->NGAGE_ScreenSize.iHeight - 1); /* TODO: Clip from the right side */ - const TInt sourceRectWidth = maxX - rect2.x + 1; - const TInt sourceRectWidthInBytes = sourceRectWidth * sourceNumBytesPerPixel; - const TInt sourceRectHeight = maxY - rect2.y + 1; - const TInt sourceStartOffset = rect2.x + rect2.y * sourceScanlineLength; - const TUint skipValue = 1; /* 1 = No skip */ + const TInt sourceRectWidth = maxX - rect2.x + 1; + const TInt sourceRectWidthInBytes = sourceRectWidth * sourceNumBytesPerPixel; + const TInt sourceRectHeight = maxY - rect2.y + 1; + const TInt sourceStartOffset = rect2.x + rect2.y * sourceScanlineLength; + const TUint skipValue = 1; /* 1 = No skip */ - TInt targetStartOffset = fixedOffset.iX + rect2.x + (fixedOffset.iY +rect2.y) * targetScanlineLength; + TInt targetStartOffset = fixedOffset.iX + rect2.x + (fixedOffset.iY + rect2.y) * targetScanlineLength; - switch (screen->format->BitsPerPixel) + switch (screen->format->BitsPerPixel) { + case 12: { - case 12: - { - TUint16* bitmapLine = (TUint16*)screen->pixels + sourceStartOffset; - TUint16* screenMemory = screenBuffer + targetStartOffset; + TUint16 *bitmapLine = (TUint16 *)screen->pixels + sourceStartOffset; + TUint16 *screenMemory = screenBuffer + targetStartOffset; - if (skipValue == 1) { - for (TInt y = 0 ; y < sourceRectHeight ; y++) - { - Mem::Copy(screenMemory, bitmapLine, sourceRectWidthInBytes); - bitmapLine += sourceScanlineLength; - screenMemory += targetScanlineLength; - } - } else { - for (TInt y = 0 ; y < sourceRectHeight ; y++) - { - TUint16* bitmapPos = bitmapLine; /* 2 bytes per pixel */ - TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */ - for (TInt x = 0 ; x < sourceRectWidth ; x++) - { - __ASSERT_DEBUG(screenMemory < (screenBuffer + phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight), User::Panic(_L("SDL"), KErrCorrupt)); - __ASSERT_DEBUG(screenMemory >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt)); - __ASSERT_DEBUG(bitmapLine < ((TUint16*)screen->pixels + (screen->w * screen->h)), User::Panic(_L("SDL"), KErrCorrupt)); - __ASSERT_DEBUG(bitmapLine >= (TUint16*)screen->pixels, User::Panic(_L("SDL"), KErrCorrupt)); + if (skipValue == 1) { + for (TInt y = 0; y < sourceRectHeight; y++) { + Mem::Copy(screenMemory, bitmapLine, sourceRectWidthInBytes); + bitmapLine += sourceScanlineLength; + screenMemory += targetScanlineLength; + } + } else { + for (TInt y = 0; y < sourceRectHeight; y++) { + TUint16 *bitmapPos = bitmapLine; /* 2 bytes per pixel */ + TUint16 *screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */ + for (TInt x = 0; x < sourceRectWidth; x++) { + __ASSERT_DEBUG(screenMemory < (screenBuffer + phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight), User::Panic(_L("SDL"), KErrCorrupt)); + __ASSERT_DEBUG(screenMemory >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt)); + __ASSERT_DEBUG(bitmapLine < ((TUint16 *)screen->pixels + (screen->w * screen->h)), User::Panic(_L("SDL"), KErrCorrupt)); + __ASSERT_DEBUG(bitmapLine >= (TUint16 *)screen->pixels, User::Panic(_L("SDL"), KErrCorrupt)); - *screenMemoryLinePos++ = *bitmapPos; - bitmapPos += skipValue; - } - bitmapLine += sourceScanlineLength; - screenMemory += targetScanlineLength; + *screenMemoryLinePos++ = *bitmapPos; + bitmapPos += skipValue; } + bitmapLine += sourceScanlineLength; + screenMemory += targetScanlineLength; } } - break; - // 256 color paletted mode: 8 bpp --> 12 bpp - default: - { - if (phdata->NGAGE_BytesPerPixel <= 2) { - TUint8* bitmapLine = (TUint8*)screen->pixels + sourceStartOffset; - TUint16* screenMemory = screenBuffer + targetStartOffset; + } break; + // 256 color paletted mode: 8 bpp --> 12 bpp + default: + { + if (phdata->NGAGE_BytesPerPixel <= 2) { + TUint8 *bitmapLine = (TUint8 *)screen->pixels + sourceStartOffset; + TUint16 *screenMemory = screenBuffer + targetStartOffset; - for (TInt y = 0 ; y < sourceRectHeight ; y++) - { - TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */ - TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */ - /* Convert each pixel from 256 palette to 4k color values */ - for (TInt x = 0 ; x < sourceRectWidth ; x++) - { - __ASSERT_DEBUG(screenMemoryLinePos < (screenBuffer + (phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt)); - __ASSERT_DEBUG(screenMemoryLinePos >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt)); - __ASSERT_DEBUG(bitmapPos < ((TUint8*)screen->pixels + (screen->w * screen->h)), User::Panic(_L("SDL"), KErrCorrupt)); - __ASSERT_DEBUG(bitmapPos >= (TUint8*)screen->pixels, User::Panic(_L("SDL"), KErrCorrupt)); - *screenMemoryLinePos++ = NGAGE_HWPalette_256_to_Screen[*bitmapPos++]; - } - bitmapLine += sourceScanlineLength; - screenMemory += targetScanlineLength; + for (TInt y = 0; y < sourceRectHeight; y++) { + TUint8 *bitmapPos = bitmapLine; /* 1 byte per pixel */ + TUint16 *screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */ + /* Convert each pixel from 256 palette to 4k color values */ + for (TInt x = 0; x < sourceRectWidth; x++) { + __ASSERT_DEBUG(screenMemoryLinePos < (screenBuffer + (phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt)); + __ASSERT_DEBUG(screenMemoryLinePos >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt)); + __ASSERT_DEBUG(bitmapPos < ((TUint8 *)screen->pixels + (screen->w * screen->h)), User::Panic(_L("SDL"), KErrCorrupt)); + __ASSERT_DEBUG(bitmapPos >= (TUint8 *)screen->pixels, User::Panic(_L("SDL"), KErrCorrupt)); + *screenMemoryLinePos++ = NGAGE_HWPalette_256_to_Screen[*bitmapPos++]; } - } else { - TUint8* bitmapLine = (TUint8*)screen->pixels + sourceStartOffset; - TUint32* screenMemory = reinterpret_cast(screenBuffer + targetStartOffset); - for (TInt y = 0 ; y < sourceRectHeight ; y++) - { - TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */ - TUint32* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */ - /* Convert each pixel from 256 palette to 4k color values */ - for (TInt x = 0 ; x < sourceRectWidth ; x++) - { - __ASSERT_DEBUG(screenMemoryLinePos < (reinterpret_cast(screenBuffer) + (phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt)); - __ASSERT_DEBUG(screenMemoryLinePos >= reinterpret_cast(screenBuffer), User::Panic(_L("SDL"), KErrCorrupt)); - __ASSERT_DEBUG(bitmapPos < ((TUint8*)screen->pixels + (screen->w * screen->h)), User::Panic(_L("SDL"), KErrCorrupt)); - __ASSERT_DEBUG(bitmapPos >= (TUint8*)screen->pixels, User::Panic(_L("SDL"), KErrCorrupt)); - *screenMemoryLinePos++ = NGAGE_HWPalette_256_to_Screen[*bitmapPos++]; - } - bitmapLine += sourceScanlineLength; - screenMemory += targetScanlineLength; + bitmapLine += sourceScanlineLength; + screenMemory += targetScanlineLength; + } + } else { + TUint8 *bitmapLine = (TUint8 *)screen->pixels + sourceStartOffset; + TUint32 *screenMemory = reinterpret_cast(screenBuffer + targetStartOffset); + for (TInt y = 0; y < sourceRectHeight; y++) { + TUint8 *bitmapPos = bitmapLine; /* 1 byte per pixel */ + TUint32 *screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */ + /* Convert each pixel from 256 palette to 4k color values */ + for (TInt x = 0; x < sourceRectWidth; x++) { + __ASSERT_DEBUG(screenMemoryLinePos < (reinterpret_cast(screenBuffer) + (phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt)); + __ASSERT_DEBUG(screenMemoryLinePos >= reinterpret_cast(screenBuffer), User::Panic(_L("SDL"), KErrCorrupt)); + __ASSERT_DEBUG(bitmapPos < ((TUint8 *)screen->pixels + (screen->w * screen->h)), User::Panic(_L("SDL"), KErrCorrupt)); + __ASSERT_DEBUG(bitmapPos >= (TUint8 *)screen->pixels, User::Panic(_L("SDL"), KErrCorrupt)); + *screenMemoryLinePos++ = NGAGE_HWPalette_256_to_Screen[*bitmapPos++]; } + bitmapLine += sourceScanlineLength; + screenMemory += targetScanlineLength; } } } + } } } void DirectUpdate(_THIS, int numrects, SDL_Rect *rects) { - SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata; + SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata; - if (! phdata->NGAGE_IsWindowFocused) { + if (!phdata->NGAGE_IsWindowFocused) { SDL_PauseAudio(1); SDL_Delay(1000); return; @@ -352,7 +343,7 @@ void DirectUpdate(_THIS, int numrects, SDL_Rect *rects) SDL_PauseAudio(0); - TUint16* screenBuffer = (TUint16*)phdata->NGAGE_FrameBuffer; + TUint16 *screenBuffer = (TUint16 *)phdata->NGAGE_FrameBuffer; #if 0 if (phdata->NGAGE_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270) { @@ -364,10 +355,10 @@ void DirectUpdate(_THIS, int numrects, SDL_Rect *rects) } for (int i = 0; i < numrects; ++i) { - TInt aAx = rects[i].x; - TInt aAy = rects[i].y; - TInt aBx = rects[i].w; - TInt aBy = rects[i].h; + TInt aAx = rects[i].x; + TInt aAy = rects[i].y; + TInt aBx = rects[i].w; + TInt aBy = rects[i].h; TRect rect2 = TRect(aAx, aAy, aBx, aBy); phdata->NGAGE_DrawDevice->UpdateRegion(rect2); /* Should we update rects parameter area only? */ @@ -377,8 +368,8 @@ void DirectUpdate(_THIS, int numrects, SDL_Rect *rects) void RedrawWindowL(_THIS) { - SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata; - SDL_Surface *screen = (SDL_Surface*)SDL_GetWindowData(_this->windows, NGAGE_SURFACE); + SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata; + SDL_Surface *screen = (SDL_Surface *)SDL_GetWindowData(_this->windows, NGAGE_SURFACE); int w = screen->w; int h = screen->h; @@ -386,13 +377,12 @@ void RedrawWindowL(_THIS) w = screen->h; h = screen->w; } - if ((w < phdata->NGAGE_ScreenSize.iWidth) - || (h < phdata->NGAGE_ScreenSize.iHeight)) { + if ((w < phdata->NGAGE_ScreenSize.iWidth) || (h < phdata->NGAGE_ScreenSize.iHeight)) { DrawBackground(_this); } /* Tell the system that something has been drawn */ - TRect rect = TRect(phdata->NGAGE_WsWindow.Size()); + TRect rect = TRect(phdata->NGAGE_WsWindow.Size()); phdata->NGAGE_WsWindow.Invalidate(rect); /* Draw current buffer */ diff --git a/src/video/ngage/SDL_ngageframebuffer_c.h b/src/video/ngage/SDL_ngageframebuffer_c.h index c2f0768ca..7549242b1 100644 --- a/src/video/ngage/SDL_ngageframebuffer_c.h +++ b/src/video/ngage/SDL_ngageframebuffer_c.h @@ -21,9 +21,9 @@ #include "../../SDL_internal.h" -extern int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch); -extern int SDL_NGAGE_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects); -extern void SDL_NGAGE_DestroyWindowFramebuffer(_THIS, SDL_Window * window); +extern int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch); +extern int SDL_NGAGE_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects); +extern void SDL_NGAGE_DestroyWindowFramebuffer(_THIS, SDL_Window *window); /****************************************************************************/ /* Runtime */ @@ -31,8 +31,8 @@ extern void SDL_NGAGE_DestroyWindowFramebuffer(_THIS, SDL_Window * window); class NGAGE_Runtime { -public: - IMPORT_C static void GetScreenInfo(TScreenInfoV01& screenInfo2); + public: + IMPORT_C static void GetScreenInfo(TScreenInfoV01 &screenInfo2); }; /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ngage/SDL_ngagevideo.cpp b/src/video/ngage/SDL_ngagevideo.cpp index 0f753da63..3fffd2021 100644 --- a/src/video/ngage/SDL_ngagevideo.cpp +++ b/src/video/ngage/SDL_ngagevideo.cpp @@ -48,16 +48,15 @@ extern "C" { #define NGAGEVID_DRIVER_NAME "ngage" /* Initialization/Query functions */ -static int NGAGE_VideoInit(_THIS); -static int NGAGE_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); +static int NGAGE_VideoInit(_THIS); +static int NGAGE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode); static void NGAGE_VideoQuit(_THIS); /* NGAGE driver bootstrap functions */ -static void -NGAGE_DeleteDevice(SDL_VideoDevice * device) +static void NGAGE_DeleteDevice(SDL_VideoDevice *device) { - SDL_VideoData *phdata = (SDL_VideoData*)device->driverdata; + SDL_VideoData *phdata = (SDL_VideoData *)device->driverdata; if (phdata) { /* Free Epoc resources */ @@ -100,21 +99,20 @@ NGAGE_DeleteDevice(SDL_VideoDevice * device) } } -static SDL_VideoDevice * -NGAGE_CreateDevice(void) +static SDL_VideoDevice *NGAGE_CreateDevice(void) { SDL_VideoDevice *device; - SDL_VideoData *phdata; + SDL_VideoData *phdata; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device == NULL) { SDL_OutOfMemory(); return 0; } /* Initialize internal N-Gage specific data */ - phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); + phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); if (phdata == NULL) { SDL_OutOfMemory(); SDL_free(device); @@ -122,18 +120,18 @@ NGAGE_CreateDevice(void) } /* General video */ - device->VideoInit = NGAGE_VideoInit; - device->VideoQuit = NGAGE_VideoQuit; - device->SetDisplayMode = NGAGE_SetDisplayMode; - device->PumpEvents = NGAGE_PumpEvents; - device->CreateWindowFramebuffer = SDL_NGAGE_CreateWindowFramebuffer; - device->UpdateWindowFramebuffer = SDL_NGAGE_UpdateWindowFramebuffer; + device->VideoInit = NGAGE_VideoInit; + device->VideoQuit = NGAGE_VideoQuit; + device->SetDisplayMode = NGAGE_SetDisplayMode; + device->PumpEvents = NGAGE_PumpEvents; + device->CreateWindowFramebuffer = SDL_NGAGE_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = SDL_NGAGE_UpdateWindowFramebuffer; device->DestroyWindowFramebuffer = SDL_NGAGE_DestroyWindowFramebuffer; - device->free = NGAGE_DeleteDevice; + device->free = NGAGE_DeleteDevice; /* "Window" */ device->CreateSDLWindow = NGAGE_CreateWindow; - device->DestroyWindow = NGAGE_DestroyWindow; + device->DestroyWindow = NGAGE_DestroyWindow; /* N-Gage specific data */ device->driverdata = phdata; @@ -146,17 +144,16 @@ VideoBootStrap NGAGE_bootstrap = { NGAGE_CreateDevice }; -int -NGAGE_VideoInit(_THIS) +int NGAGE_VideoInit(_THIS) { SDL_DisplayMode mode; /* Use 12-bpp desktop mode */ - mode.format = SDL_PIXELFORMAT_RGB444; - mode.w = 176; - mode.h = 208; + mode.format = SDL_PIXELFORMAT_RGB444; + mode.w = 176; + mode.h = 208; mode.refresh_rate = 0; - mode.driverdata = NULL; + mode.driverdata = NULL; if (SDL_AddBasicVideoDisplay(&mode) < 0) { return -1; } @@ -168,14 +165,12 @@ NGAGE_VideoInit(_THIS) return 0; } -static int -NGAGE_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +static int NGAGE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) { return 0; } -void -NGAGE_VideoQuit(_THIS) +void NGAGE_VideoQuit(_THIS) { } diff --git a/src/video/ngage/SDL_ngagevideo.h b/src/video/ngage/SDL_ngagevideo.h index e74038bb2..172880dae 100644 --- a/src/video/ngage/SDL_ngagevideo.h +++ b/src/video/ngage/SDL_ngagevideo.h @@ -37,27 +37,27 @@ typedef struct SDL_VideoData { /* Epoc window server info */ - RWsSession NGAGE_WsSession; - RWindowGroup NGAGE_WsWindowGroup; - TInt NGAGE_WsWindowGroupID; - RWindow NGAGE_WsWindow; - CWsScreenDevice* NGAGE_WsScreen; - CWindowGc* NGAGE_WindowGc; - TRequestStatus NGAGE_WsEventStatus; - TRequestStatus NGAGE_RedrawEventStatus; - TWsEvent NGAGE_WsEvent; - CFbsDrawDevice* NGAGE_DrawDevice; - TBool NGAGE_IsWindowFocused; /* Not used yet */ + RWsSession NGAGE_WsSession; + RWindowGroup NGAGE_WsWindowGroup; + TInt NGAGE_WsWindowGroupID; + RWindow NGAGE_WsWindow; + CWsScreenDevice *NGAGE_WsScreen; + CWindowGc *NGAGE_WindowGc; + TRequestStatus NGAGE_WsEventStatus; + TRequestStatus NGAGE_RedrawEventStatus; + TWsEvent NGAGE_WsEvent; + CFbsDrawDevice *NGAGE_DrawDevice; + TBool NGAGE_IsWindowFocused; /* Not used yet */ /* Screen hardware frame buffer info */ - TBool NGAGE_HasFrameBuffer; - TInt NGAGE_BytesPerPixel; - TInt NGAGE_BytesPerScanLine; - TInt NGAGE_BytesPerScreen; - TDisplayMode NGAGE_DisplayMode; - TSize NGAGE_ScreenSize; - TUint8* NGAGE_FrameBuffer; - TPoint NGAGE_ScreenOffset; + TBool NGAGE_HasFrameBuffer; + TInt NGAGE_BytesPerPixel; + TInt NGAGE_BytesPerScanLine; + TInt NGAGE_BytesPerScreen; + TDisplayMode NGAGE_DisplayMode; + TSize NGAGE_ScreenSize; + TUint8 *NGAGE_FrameBuffer; + TPoint NGAGE_ScreenOffset; CFbsBitGc::TGraphicsOrientation NGAGE_ScreenOrientation; diff --git a/src/video/ngage/SDL_ngagewindow.cpp b/src/video/ngage/SDL_ngagewindow.cpp index 206e8b83d..0f29a2ff7 100644 --- a/src/video/ngage/SDL_ngagewindow.cpp +++ b/src/video/ngage/SDL_ngagewindow.cpp @@ -32,10 +32,9 @@ const TUint32 WindowClientHandle = 9210; void DisableKeyBlocking(_THIS); void ConstructWindowL(_THIS); -int -NGAGE_CreateWindow(_THIS, SDL_Window* window) +int NGAGE_CreateWindow(_THIS, SDL_Window *window) { - NGAGE_Window* ngage_window = (NGAGE_Window*)SDL_calloc(1, sizeof(NGAGE_Window)); + NGAGE_Window *ngage_window = (NGAGE_Window *)SDL_calloc(1, sizeof(NGAGE_Window)); if (ngage_window == NULL) { return SDL_OutOfMemory(); @@ -58,10 +57,9 @@ NGAGE_CreateWindow(_THIS, SDL_Window* window) return 0; } -void -NGAGE_DestroyWindow(_THIS, SDL_Window* window) +void NGAGE_DestroyWindow(_THIS, SDL_Window *window) { - NGAGE_Window* ngage_window = (NGAGE_Window*)window->driverdata; + NGAGE_Window *ngage_window = (NGAGE_Window *)window->driverdata; if (ngage_window) { SDL_free(ngage_window); @@ -76,8 +74,8 @@ NGAGE_DestroyWindow(_THIS, SDL_Window* window) void DisableKeyBlocking(_THIS) { - SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata; - TRawEvent event; + SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata; + TRawEvent event; event.Set((TRawEvent::TType) /*EDisableKeyBlock*/ 51); phdata->NGAGE_WsSession.SimulateRawEvent(event); @@ -85,34 +83,34 @@ void DisableKeyBlocking(_THIS) void ConstructWindowL(_THIS) { - SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata; - TInt error; + SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata; + TInt error; error = phdata->NGAGE_WsSession.Connect(); User::LeaveIfError(error); - phdata->NGAGE_WsScreen=new(ELeave) CWsScreenDevice(phdata->NGAGE_WsSession); + phdata->NGAGE_WsScreen = new (ELeave) CWsScreenDevice(phdata->NGAGE_WsSession); User::LeaveIfError(phdata->NGAGE_WsScreen->Construct()); User::LeaveIfError(phdata->NGAGE_WsScreen->CreateContext(phdata->NGAGE_WindowGc)); - phdata->NGAGE_WsWindowGroup=RWindowGroup(phdata->NGAGE_WsSession); + phdata->NGAGE_WsWindowGroup = RWindowGroup(phdata->NGAGE_WsSession); User::LeaveIfError(phdata->NGAGE_WsWindowGroup.Construct(WindowClientHandle)); phdata->NGAGE_WsWindowGroup.SetOrdinalPosition(0); RProcess thisProcess; - TParse exeName; + TParse exeName; exeName.Set(thisProcess.FileName(), NULL, NULL); TBuf<32> winGroupName; winGroupName.Append(0); winGroupName.Append(0); - winGroupName.Append(0); // UID + winGroupName.Append(0); // UID winGroupName.Append(0); winGroupName.Append(exeName.Name()); // Caption winGroupName.Append(0); - winGroupName.Append(0); // DOC name + winGroupName.Append(0); // DOC name phdata->NGAGE_WsWindowGroup.SetName(winGroupName); - phdata->NGAGE_WsWindow=RWindow(phdata->NGAGE_WsSession); - User::LeaveIfError(phdata->NGAGE_WsWindow.Construct(phdata->NGAGE_WsWindowGroup,WindowClientHandle - 1)); + phdata->NGAGE_WsWindow = RWindow(phdata->NGAGE_WsSession); + User::LeaveIfError(phdata->NGAGE_WsWindow.Construct(phdata->NGAGE_WsWindowGroup, WindowClientHandle - 1)); phdata->NGAGE_WsWindow.SetBackgroundColor(KRgbWhite); phdata->NGAGE_WsWindow.Activate(); phdata->NGAGE_WsWindow.SetSize(phdata->NGAGE_WsScreen->SizeInPixels()); diff --git a/src/video/ngage/SDL_ngagewindow.h b/src/video/ngage/SDL_ngagewindow.h index 148c79986..777984aa0 100644 --- a/src/video/ngage/SDL_ngagewindow.h +++ b/src/video/ngage/SDL_ngagewindow.h @@ -27,19 +27,18 @@ #include "SDL_ngagevideo.h" -typedef struct { - SDL_Window* sdl_window; +typedef struct +{ + SDL_Window *sdl_window; } NGAGE_Window; - extern int -NGAGE_CreateWindow(_THIS, SDL_Window* window); +NGAGE_CreateWindow(_THIS, SDL_Window *window); extern void -NGAGE_DestroyWindow(_THIS, SDL_Window* window); +NGAGE_DestroyWindow(_THIS, SDL_Window *window); #endif /* _SDL_ngagewindow */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/video/offscreen/SDL_offscreenevents.c b/src/video/offscreen/SDL_offscreenevents.c index 092f19b2b..0621fb970 100644 --- a/src/video/offscreen/SDL_offscreenevents.c +++ b/src/video/offscreen/SDL_offscreenevents.c @@ -30,8 +30,7 @@ #include "SDL_offscreenvideo.h" #include "SDL_offscreenevents_c.h" -void -OFFSCREEN_PumpEvents(_THIS) +void OFFSCREEN_PumpEvents(_THIS) { /* do nothing. */ } diff --git a/src/video/offscreen/SDL_offscreenframebuffer.c b/src/video/offscreen/SDL_offscreenframebuffer.c index 2e97e58f3..b6dc22452 100644 --- a/src/video/offscreen/SDL_offscreenframebuffer.c +++ b/src/video/offscreen/SDL_offscreenframebuffer.c @@ -25,10 +25,9 @@ #include "../SDL_sysvideo.h" #include "SDL_offscreenframebuffer_c.h" +#define OFFSCREEN_SURFACE "_SDL_DummySurface" -#define OFFSCREEN_SURFACE "_SDL_DummySurface" - -int SDL_OFFSCREEN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch) +int SDL_OFFSCREEN_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch) { SDL_Surface *surface; const Uint32 surface_format = SDL_PIXELFORMAT_RGB888; @@ -52,12 +51,12 @@ int SDL_OFFSCREEN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * f return 0; } -int SDL_OFFSCREEN_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects) +int SDL_OFFSCREEN_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects) { static int frame_number; SDL_Surface *surface; - surface = (SDL_Surface *) SDL_GetWindowData(window, OFFSCREEN_SURFACE); + surface = (SDL_Surface *)SDL_GetWindowData(window, OFFSCREEN_SURFACE); if (surface == NULL) { return SDL_SetError("Couldn't find offscreen surface for window"); } @@ -72,11 +71,11 @@ int SDL_OFFSCREEN_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_ return 0; } -void SDL_OFFSCREEN_DestroyWindowFramebuffer(_THIS, SDL_Window * window) +void SDL_OFFSCREEN_DestroyWindowFramebuffer(_THIS, SDL_Window *window) { SDL_Surface *surface; - surface = (SDL_Surface *) SDL_SetWindowData(window, OFFSCREEN_SURFACE, NULL); + surface = (SDL_Surface *)SDL_SetWindowData(window, OFFSCREEN_SURFACE, NULL); SDL_FreeSurface(surface); } diff --git a/src/video/offscreen/SDL_offscreenframebuffer_c.h b/src/video/offscreen/SDL_offscreenframebuffer_c.h index ae1ad7ba9..02a10d964 100644 --- a/src/video/offscreen/SDL_offscreenframebuffer_c.h +++ b/src/video/offscreen/SDL_offscreenframebuffer_c.h @@ -20,8 +20,8 @@ */ #include "../../SDL_internal.h" -extern int SDL_OFFSCREEN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch); -extern int SDL_OFFSCREEN_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects); -extern void SDL_OFFSCREEN_DestroyWindowFramebuffer(_THIS, SDL_Window * window); +extern int SDL_OFFSCREEN_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch); +extern int SDL_OFFSCREEN_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects); +extern void SDL_OFFSCREEN_DestroyWindowFramebuffer(_THIS, SDL_Window *window); /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/offscreen/SDL_offscreenopengles.c b/src/video/offscreen/SDL_offscreenopengles.c index a379ad7b0..cdf4e0be7 100644 --- a/src/video/offscreen/SDL_offscreenopengles.c +++ b/src/video/offscreen/SDL_offscreenopengles.c @@ -28,8 +28,7 @@ /* EGL implementation of SDL OpenGL support */ -int -OFFSCREEN_GLES_LoadLibrary(_THIS, const char* path) +int OFFSCREEN_GLES_LoadLibrary(_THIS, const char *path) { int ret = SDL_EGL_LoadLibraryOnly(_this, path); if (ret != 0) { @@ -56,9 +55,9 @@ OFFSCREEN_GLES_LoadLibrary(_THIS, const char* path) } SDL_GLContext -OFFSCREEN_GLES_CreateContext(_THIS, SDL_Window* window) +OFFSCREEN_GLES_CreateContext(_THIS, SDL_Window *window) { - OFFSCREEN_Window* offscreen_window = window->driverdata; + OFFSCREEN_Window *offscreen_window = window->driverdata; SDL_GLContext context; context = SDL_EGL_CreateContext(_this, offscreen_window->egl_surface); @@ -66,21 +65,19 @@ OFFSCREEN_GLES_CreateContext(_THIS, SDL_Window* window) return context; } -int -OFFSCREEN_GLES_MakeCurrent(_THIS, SDL_Window* window, SDL_GLContext context) +int OFFSCREEN_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context) { if (window) { - EGLSurface egl_surface = ((OFFSCREEN_Window*)window->driverdata)->egl_surface; + EGLSurface egl_surface = ((OFFSCREEN_Window *)window->driverdata)->egl_surface; return SDL_EGL_MakeCurrent(_this, egl_surface, context); } else { return SDL_EGL_MakeCurrent(_this, NULL, NULL); } } -int -OFFSCREEN_GLES_SwapWindow(_THIS, SDL_Window* window) +int OFFSCREEN_GLES_SwapWindow(_THIS, SDL_Window *window) { - OFFSCREEN_Window* offscreen_wind = window->driverdata; + OFFSCREEN_Window *offscreen_wind = window->driverdata; return SDL_EGL_SwapBuffers(_this, offscreen_wind->egl_surface); } diff --git a/src/video/offscreen/SDL_offscreenopengles.h b/src/video/offscreen/SDL_offscreenopengles.h index 6c9e51820..0d5bc6e02 100644 --- a/src/video/offscreen/SDL_offscreenopengles.h +++ b/src/video/offscreen/SDL_offscreenopengles.h @@ -44,4 +44,3 @@ extern int OFFSCREEN_GLES_SwapWindow(_THIS, SDL_Window *window); #endif /* _SDL_offscreenopengles_h */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/video/offscreen/SDL_offscreenvideo.c b/src/video/offscreen/SDL_offscreenvideo.c index 84439fb64..a0e93f9ea 100644 --- a/src/video/offscreen/SDL_offscreenvideo.c +++ b/src/video/offscreen/SDL_offscreenvideo.c @@ -42,24 +42,22 @@ /* Initialization/Query functions */ static int OFFSCREEN_VideoInit(_THIS); -static int OFFSCREEN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); +static int OFFSCREEN_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode); static void OFFSCREEN_VideoQuit(_THIS); /* OFFSCREEN driver bootstrap functions */ -static void -OFFSCREEN_DeleteDevice(SDL_VideoDevice * device) +static void OFFSCREEN_DeleteDevice(SDL_VideoDevice *device) { SDL_free(device); } -static SDL_VideoDevice * -OFFSCREEN_CreateDevice(void) +static SDL_VideoDevice *OFFSCREEN_CreateDevice(void) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device == NULL) { SDL_OutOfMemory(); return 0; @@ -100,8 +98,7 @@ VideoBootStrap OFFSCREEN_bootstrap = { OFFSCREEN_CreateDevice }; -int -OFFSCREEN_VideoInit(_THIS) +int OFFSCREEN_VideoInit(_THIS) { SDL_DisplayMode mode; @@ -122,14 +119,12 @@ OFFSCREEN_VideoInit(_THIS) return 0; } -static int -OFFSCREEN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +static int OFFSCREEN_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) { return 0; } -void -OFFSCREEN_VideoQuit(_THIS) +void OFFSCREEN_VideoQuit(_THIS) { } diff --git a/src/video/offscreen/SDL_offscreenwindow.c b/src/video/offscreen/SDL_offscreenwindow.c index a6aa4d463..d6bce4446 100644 --- a/src/video/offscreen/SDL_offscreenwindow.c +++ b/src/video/offscreen/SDL_offscreenwindow.c @@ -27,8 +27,7 @@ #include "SDL_offscreenwindow.h" -int -OFFSCREEN_CreateWindow(_THIS, SDL_Window* window) +int OFFSCREEN_CreateWindow(_THIS, SDL_Window *window) { OFFSCREEN_Window *offscreen_window = SDL_calloc(1, sizeof(OFFSCREEN_Window)); @@ -69,10 +68,9 @@ OFFSCREEN_CreateWindow(_THIS, SDL_Window* window) return 0; } -void -OFFSCREEN_DestroyWindow(_THIS, SDL_Window* window) +void OFFSCREEN_DestroyWindow(_THIS, SDL_Window *window) { - OFFSCREEN_Window* offscreen_window = window->driverdata; + OFFSCREEN_Window *offscreen_window = window->driverdata; if (offscreen_window) { #if SDL_VIDEO_OPENGL_EGL diff --git a/src/video/offscreen/SDL_offscreenwindow.h b/src/video/offscreen/SDL_offscreenwindow.h index 554079454..1577baaa3 100644 --- a/src/video/offscreen/SDL_offscreenwindow.h +++ b/src/video/offscreen/SDL_offscreenwindow.h @@ -25,19 +25,18 @@ #include "SDL_offscreenvideo.h" -typedef struct { - SDL_Window* sdl_window; +typedef struct +{ + SDL_Window *sdl_window; #if SDL_VIDEO_OPENGL_EGL EGLSurface egl_surface; #endif } OFFSCREEN_Window; - extern int OFFSCREEN_CreateWindow(_THIS, SDL_Window *window); extern void OFFSCREEN_DestroyWindow(_THIS, SDL_Window *window); #endif /* _SDL_offscreenwindow */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/video/ps2/SDL_ps2video.c b/src/video/ps2/SDL_ps2video.c index 2cecf7f42..267b13e95 100644 --- a/src/video/ps2/SDL_ps2video.c +++ b/src/video/ps2/SDL_ps2video.c @@ -48,17 +48,17 @@ /* PS2 driver bootstrap functions */ -static int PS2_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +static int PS2_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) { return 0; } -static void PS2_DeleteDevice(SDL_VideoDevice * device) +static void PS2_DeleteDevice(SDL_VideoDevice *device) { SDL_free(device); } -static int PS2_CreateWindow(_THIS, SDL_Window * window) +static int PS2_CreateWindow(_THIS, SDL_Window *window) { SDL_SetKeyboardFocus(window); @@ -76,7 +76,7 @@ static int PS2_VideoInit(_THIS) current_mode.w = 640; current_mode.h = 480; current_mode.refresh_rate = 60; - + /* 32 bpp for default */ current_mode.format = SDL_PIXELFORMAT_ABGR8888; current_mode.driverdata = NULL; @@ -94,7 +94,6 @@ static int PS2_VideoInit(_THIS) static void PS2_VideoQuit(_THIS) { - } static void PS2_PumpEvents(_THIS) @@ -107,7 +106,7 @@ static SDL_VideoDevice *PS2_CreateDevice(void) SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device == NULL) { SDL_OutOfMemory(); return 0; @@ -125,7 +124,7 @@ static SDL_VideoDevice *PS2_CreateDevice(void) } VideoBootStrap PS2_bootstrap = { - "PS2", + "PS2", "PS2 Video Driver", PS2_CreateDevice }; diff --git a/src/video/psp/SDL_pspevents.c b/src/video/psp/SDL_pspevents.c index f5022f4bc..6b3ef31a4 100644 --- a/src/video/psp/SDL_pspevents.c +++ b/src/video/psp/SDL_pspevents.c @@ -40,7 +40,7 @@ #include #include -#define IRKBD_CONFIG_FILE NULL /* this will take ms0:/seplugins/pspirkeyb.ini */ +#define IRKBD_CONFIG_FILE NULL /* this will take ms0:/seplugins/pspirkeyb.ini */ static int irkbd_ready = 0; static SDL_Keycode keymap[256]; @@ -50,24 +50,24 @@ static enum PspHprmKeys hprm = 0; static SDL_sem *event_sem = NULL; static SDL_Thread *thread = NULL; static int running = 0; -static struct { +static struct +{ enum PspHprmKeys id; SDL_Keycode sym; } keymap_psp[] = { { PSP_HPRM_PLAYPAUSE, SDLK_F10 }, - { PSP_HPRM_FORWARD, SDLK_F11 }, - { PSP_HPRM_BACK, SDLK_F12 }, - { PSP_HPRM_VOL_UP, SDLK_F13 }, - { PSP_HPRM_VOL_DOWN, SDLK_F14 }, - { PSP_HPRM_HOLD, SDLK_F15 } + { PSP_HPRM_FORWARD, SDLK_F11 }, + { PSP_HPRM_BACK, SDLK_F12 }, + { PSP_HPRM_VOL_UP, SDLK_F13 }, + { PSP_HPRM_VOL_DOWN, SDLK_F14 }, + { PSP_HPRM_HOLD, SDLK_F15 } }; -int -EventUpdate(void *data) +int EventUpdate(void *data) { while (running) { SDL_SemWait(event_sem); - sceHprmPeekCurrentKey((u32 *) &hprm); + sceHprmPeekCurrentKey((u32 *)&hprm); SDL_SemPost(event_sem); /* Delay 1/60th of a second */ sceKernelDelayThread(1000000 / 60); @@ -90,35 +90,32 @@ void PSP_PumpEvents(_THIS) changed = old_keys ^ keys; old_keys = keys; if (changed) { - for (i=0; i= 0) { - if ((length % sizeof(SIrKeybScanCodeData)) == 0) { - count = length / sizeof(SIrKeybScanCodeData); - for ( i=0; i < count; i++ ) { - unsigned char raw, pressed; - scanData=(SIrKeybScanCodeData*) buffer+i; - raw = scanData->raw; - pressed = scanData->pressed; - sym.scancode = raw; - sym.sym = keymap[raw]; - /* not tested */ - /* SDL_PrivateKeyboard(pressed?SDL_PRESSED:SDL_RELEASED, &sym); */ - SDL_SendKeyboardKey((keys & keymap_psp[i].id) ? - SDL_PRESSED : SDL_RELEASED, SDL_GetScancodeFromKey(keymap[raw])); - + if (pspIrKeybReadinput(buffer, &length) >= 0) { + if ((length % sizeof(SIrKeybScanCodeData)) == 0) { + count = length / sizeof(SIrKeybScanCodeData); + for (i = 0; i < count; i++) { + unsigned char raw, pressed; + scanData = (SIrKeybScanCodeData *)buffer + i; + raw = scanData->raw; + pressed = scanData->pressed; + sym.scancode = raw; + sym.sym = keymap[raw]; + /* not tested */ + /* SDL_PrivateKeyboard(pressed?SDL_PRESSED:SDL_RELEASED, &sym); */ + SDL_SendKeyboardKey((keys & keymap_psp[i].id) ? SDL_PRESSED : SDL_RELEASED, SDL_GetScancodeFromKey(keymap[raw])); } } } @@ -246,14 +243,14 @@ void PSP_EventInit(_THIS) int outputmode = PSP_IRKBD_OUTPUT_MODE_SCANCODE; int ret = pspIrKeybInit(IRKBD_CONFIG_FILE, 0); if (ret == PSP_IRKBD_RESULT_OK) { - pspIrKeybOutputMode(outputmode); + pspIrKeybOutputMode(outputmode); irkbd_ready = 1; } else { irkbd_ready = 0; } #endif /* Start thread to read data */ - if ((event_sem = SDL_CreateSemaphore(1)) == NULL) { + if ((event_sem = SDL_CreateSemaphore(1)) == NULL) { SDL_SetError("Can't create input semaphore"); return; } @@ -271,7 +268,7 @@ void PSP_EventQuit(_THIS) SDL_DestroySemaphore(event_sem); #ifdef PSPIRKEYB if (irkbd_ready) { - pspIrKeybFinish(); + pspIrKeybFinish(); irkbd_ready = 0; } #endif diff --git a/src/video/psp/SDL_pspevents_c.h b/src/video/psp/SDL_pspevents_c.h index 1e1b490f7..dbf515015 100644 --- a/src/video/psp/SDL_pspevents_c.h +++ b/src/video/psp/SDL_pspevents_c.h @@ -25,4 +25,3 @@ extern void PSP_InitOSKeymap(_THIS); extern void PSP_PumpEvents(_THIS); /* end of SDL_pspevents_c.h ... */ - diff --git a/src/video/psp/SDL_pspgl.c b/src/video/psp/SDL_pspgl.c index abbae8353..b3a9500da 100644 --- a/src/video/psp/SDL_pspgl.c +++ b/src/video/psp/SDL_pspgl.c @@ -32,22 +32,21 @@ /*****************************************************************************/ /* SDL OpenGL/OpenGL ES functions */ /*****************************************************************************/ -#define EGLCHK(stmt) \ - do { \ - EGLint err; \ - \ - stmt; \ - err = eglGetError(); \ - if (err != EGL_SUCCESS) { \ - SDL_SetError("EGL error %d", err); \ - return 0; \ - } \ +#define EGLCHK(stmt) \ + do { \ + EGLint err; \ + \ + stmt; \ + err = eglGetError(); \ + if (err != EGL_SUCCESS) { \ + SDL_SetError("EGL error %d", err); \ + return 0; \ + } \ } while (0) -int -PSP_GL_LoadLibrary(_THIS, const char *path) +int PSP_GL_LoadLibrary(_THIS, const char *path) { - return 0; + return 0; } /* pspgl doesn't provide this call, so stub it out since SDL requires it. @@ -59,96 +58,90 @@ GLSTUB(glOrtho,(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, void * PSP_GL_GetProcAddress(_THIS, const char *proc) { - return eglGetProcAddress(proc); + return eglGetProcAddress(proc); } -void -PSP_GL_UnloadLibrary(_THIS) +void PSP_GL_UnloadLibrary(_THIS) { - eglTerminate(_this->gl_data->display); + eglTerminate(_this->gl_data->display); } static EGLint width = 480; static EGLint height = 272; SDL_GLContext -PSP_GL_CreateContext(_THIS, SDL_Window * window) +PSP_GL_CreateContext(_THIS, SDL_Window *window) { - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - - EGLint attribs[32]; - EGLDisplay display; - EGLContext context; - EGLSurface surface; - EGLConfig config; - EGLint num_configs; - int i; + SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata; + EGLint attribs[32]; + EGLDisplay display; + EGLContext context; + EGLSurface surface; + EGLConfig config; + EGLint num_configs; + int i; /* EGL init taken from glutCreateWindow() in PSPGL's glut.c. */ - EGLCHK(display = eglGetDisplay(0)); - EGLCHK(eglInitialize(display, NULL, NULL)); + EGLCHK(display = eglGetDisplay(0)); + EGLCHK(eglInitialize(display, NULL, NULL)); wdata->uses_gles = SDL_TRUE; - window->flags |= SDL_WINDOW_FULLSCREEN; + window->flags |= SDL_WINDOW_FULLSCREEN; - /* Setup the config based on SDL's current values. */ - i = 0; - attribs[i++] = EGL_RED_SIZE; - attribs[i++] = _this->gl_config.red_size; - attribs[i++] = EGL_GREEN_SIZE; - attribs[i++] = _this->gl_config.green_size; - attribs[i++] = EGL_BLUE_SIZE; - attribs[i++] = _this->gl_config.blue_size; - attribs[i++] = EGL_DEPTH_SIZE; - attribs[i++] = _this->gl_config.depth_size; + /* Setup the config based on SDL's current values. */ + i = 0; + attribs[i++] = EGL_RED_SIZE; + attribs[i++] = _this->gl_config.red_size; + attribs[i++] = EGL_GREEN_SIZE; + attribs[i++] = _this->gl_config.green_size; + attribs[i++] = EGL_BLUE_SIZE; + attribs[i++] = _this->gl_config.blue_size; + attribs[i++] = EGL_DEPTH_SIZE; + attribs[i++] = _this->gl_config.depth_size; - if (_this->gl_config.alpha_size) { - attribs[i++] = EGL_ALPHA_SIZE; - attribs[i++] = _this->gl_config.alpha_size; - } - if (_this->gl_config.stencil_size) { - attribs[i++] = EGL_STENCIL_SIZE; - attribs[i++] = _this->gl_config.stencil_size; - } + if (_this->gl_config.alpha_size) { + attribs[i++] = EGL_ALPHA_SIZE; + attribs[i++] = _this->gl_config.alpha_size; + } + if (_this->gl_config.stencil_size) { + attribs[i++] = EGL_STENCIL_SIZE; + attribs[i++] = _this->gl_config.stencil_size; + } - attribs[i++] = EGL_NONE; + attribs[i++] = EGL_NONE; - EGLCHK(eglChooseConfig(display, attribs, &config, 1, &num_configs)); + EGLCHK(eglChooseConfig(display, attribs, &config, 1, &num_configs)); - if (num_configs == 0) { - SDL_SetError("No valid EGL configs for requested mode"); - return 0; - } + if (num_configs == 0) { + SDL_SetError("No valid EGL configs for requested mode"); + return 0; + } - EGLCHK(eglGetConfigAttrib(display, config, EGL_WIDTH, &width)); - EGLCHK(eglGetConfigAttrib(display, config, EGL_HEIGHT, &height)); + EGLCHK(eglGetConfigAttrib(display, config, EGL_WIDTH, &width)); + EGLCHK(eglGetConfigAttrib(display, config, EGL_HEIGHT, &height)); - EGLCHK(context = eglCreateContext(display, config, NULL, NULL)); - EGLCHK(surface = eglCreateWindowSurface(display, config, 0, NULL)); - EGLCHK(eglMakeCurrent(display, surface, surface, context)); - - _this->gl_data->display = display; - _this->gl_data->context = context; - _this->gl_data->surface = surface; + EGLCHK(context = eglCreateContext(display, config, NULL, NULL)); + EGLCHK(surface = eglCreateWindowSurface(display, config, 0, NULL)); + EGLCHK(eglMakeCurrent(display, surface, surface, context)); + _this->gl_data->display = display; + _this->gl_data->context = context; + _this->gl_data->surface = surface; return context; } -int -PSP_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) +int PSP_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context) { - if (!eglMakeCurrent(_this->gl_data->display, _this->gl_data->surface, - _this->gl_data->surface, _this->gl_data->context)) - { - return SDL_SetError("Unable to make EGL context current"); - } + if (!eglMakeCurrent(_this->gl_data->display, _this->gl_data->surface, + _this->gl_data->surface, _this->gl_data->context)) { + return SDL_SetError("Unable to make EGL context current"); + } return 0; } -int -PSP_GL_SetSwapInterval(_THIS, int interval) +int PSP_GL_SetSwapInterval(_THIS, int interval) { EGLBoolean status; status = eglSwapInterval(_this->gl_data->display, interval); @@ -161,14 +154,12 @@ PSP_GL_SetSwapInterval(_THIS, int interval) return SDL_SetError("Unable to set the EGL swap interval"); } -int -PSP_GL_GetSwapInterval(_THIS) +int PSP_GL_GetSwapInterval(_THIS) { return _this->gl_data->swapinterval; } -int -PSP_GL_SwapWindow(_THIS, SDL_Window * window) +int PSP_GL_SwapWindow(_THIS, SDL_Window *window) { if (!eglSwapBuffers(_this->gl_data->display, _this->gl_data->surface)) { return SDL_SetError("eglSwapBuffers() failed"); @@ -176,10 +167,9 @@ PSP_GL_SwapWindow(_THIS, SDL_Window * window) return 0; } -void -PSP_GL_DeleteContext(_THIS, SDL_GLContext context) +void PSP_GL_DeleteContext(_THIS, SDL_GLContext context) { - SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata; EGLBoolean status; if (phdata->egl_initialized != SDL_TRUE) { diff --git a/src/video/psp/SDL_pspgl_c.h b/src/video/psp/SDL_pspgl_c.h index 06822f37e..3d0429ef3 100644 --- a/src/video/psp/SDL_pspgl_c.h +++ b/src/video/psp/SDL_pspgl_c.h @@ -22,33 +22,31 @@ #ifndef SDL_pspgl_c_h_ #define SDL_pspgl_c_h_ - #include #include #include "SDL_pspvideo.h" - -typedef struct SDL_GLDriverData { - EGLDisplay display; - EGLContext context; - EGLSurface surface; +typedef struct SDL_GLDriverData +{ + EGLDisplay display; + EGLContext context; + EGLSurface surface; uint32_t swapinterval; -}SDL_GLDriverData; +} SDL_GLDriverData; -extern void * PSP_GL_GetProcAddress(_THIS, const char *proc); -extern int PSP_GL_MakeCurrent(_THIS,SDL_Window * window, SDL_GLContext context); +extern void *PSP_GL_GetProcAddress(_THIS, const char *proc); +extern int PSP_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); extern void PSP_GL_SwapBuffers(_THIS); -extern int PSP_GL_SwapWindow(_THIS, SDL_Window * window); -extern SDL_GLContext PSP_GL_CreateContext(_THIS, SDL_Window * window); +extern int PSP_GL_SwapWindow(_THIS, SDL_Window *window); +extern SDL_GLContext PSP_GL_CreateContext(_THIS, SDL_Window *window); extern int PSP_GL_LoadLibrary(_THIS, const char *path); extern void PSP_GL_UnloadLibrary(_THIS); extern int PSP_GL_SetSwapInterval(_THIS, int interval); extern int PSP_GL_GetSwapInterval(_THIS); - #endif /* SDL_pspgl_c_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/psp/SDL_pspmouse.c b/src/video/psp/SDL_pspmouse.c index 926f63977..e9f618910 100644 --- a/src/video/psp/SDL_pspmouse.c +++ b/src/video/psp/SDL_pspmouse.c @@ -30,9 +30,9 @@ #include "SDL_pspmouse_c.h" - /* The implementation dependent data for the window manager cursor */ -struct WMcursor { +struct WMcursor +{ int unused; }; diff --git a/src/video/psp/SDL_pspvideo.c b/src/video/psp/SDL_pspvideo.c index de31a2012..1dddc4b0d 100644 --- a/src/video/psp/SDL_pspvideo.c +++ b/src/video/psp/SDL_pspvideo.c @@ -33,7 +33,6 @@ #include "../../events/SDL_keyboard_c.h" - /* PSP declarations */ #include "SDL_pspvideo.h" #include "SDL_pspevents_c.h" @@ -43,39 +42,37 @@ static SDL_bool PSP_initialized = SDL_FALSE; */ -static void -PSP_Destroy(SDL_VideoDevice * device) +static void PSP_Destroy(SDL_VideoDevice *device) { -/* SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */ + /* SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */ if (device->driverdata != NULL) { device->driverdata = NULL; } } -static SDL_VideoDevice * -PSP_Create() +static SDL_VideoDevice *PSP_Create() { SDL_VideoDevice *device; SDL_VideoData *phdata; SDL_GLDriverData *gldata; /* Initialize SDL_VideoDevice structure */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device == NULL) { SDL_OutOfMemory(); return NULL; } /* Initialize internal PSP specific data */ - phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); + phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); if (phdata == NULL) { SDL_OutOfMemory(); SDL_free(device); return NULL; } - gldata = (SDL_GLDriverData *) SDL_calloc(1, sizeof(SDL_GLDriverData)); + gldata = (SDL_GLDriverData *)SDL_calloc(1, sizeof(SDL_GLDriverData)); if (gldata == NULL) { SDL_OutOfMemory(); SDL_free(device); @@ -88,7 +85,6 @@ PSP_Create() phdata->egl_initialized = SDL_TRUE; - /* Setup amount of available displays */ device->num_displays = 0; @@ -144,8 +140,7 @@ VideoBootStrap PSP_bootstrap = { /*****************************************************************************/ /* SDL Video and Display initialization/handling functions */ /*****************************************************************************/ -int -PSP_VideoInit(_THIS) +int PSP_VideoInit(_THIS) { SDL_VideoDisplay display; SDL_DisplayMode current_mode; @@ -177,42 +172,36 @@ PSP_VideoInit(_THIS) return 1; } -void -PSP_VideoQuit(_THIS) +void PSP_VideoQuit(_THIS) { - } -void -PSP_GetDisplayModes(_THIS, SDL_VideoDisplay * display) +void PSP_GetDisplayModes(_THIS, SDL_VideoDisplay *display) { - } -int -PSP_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +int PSP_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) { return 0; } -#define EGLCHK(stmt) \ - do { \ - EGLint err; \ - \ - stmt; \ - err = eglGetError(); \ - if (err != EGL_SUCCESS) { \ - SDL_SetError("EGL error %d", err); \ - return 0; \ - } \ +#define EGLCHK(stmt) \ + do { \ + EGLint err; \ + \ + stmt; \ + err = eglGetError(); \ + if (err != EGL_SUCCESS) { \ + SDL_SetError("EGL error %d", err); \ + return 0; \ + } \ } while (0) -int -PSP_CreateWindow(_THIS, SDL_Window * window) +int PSP_CreateWindow(_THIS, SDL_Window *window) { SDL_WindowData *wdata; /* Allocate window internal data */ - wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); + wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); if (wdata == NULL) { return SDL_OutOfMemory(); } @@ -226,54 +215,42 @@ PSP_CreateWindow(_THIS, SDL_Window * window) return 0; } -int -PSP_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) +int PSP_CreateWindowFrom(_THIS, SDL_Window *window, const void *data) { return SDL_Unsupported(); } -void -PSP_SetWindowTitle(_THIS, SDL_Window * window) +void PSP_SetWindowTitle(_THIS, SDL_Window *window) { } -void -PSP_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) +void PSP_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon) { } -void -PSP_SetWindowPosition(_THIS, SDL_Window * window) +void PSP_SetWindowPosition(_THIS, SDL_Window *window) { } -void -PSP_SetWindowSize(_THIS, SDL_Window * window) +void PSP_SetWindowSize(_THIS, SDL_Window *window) { } -void -PSP_ShowWindow(_THIS, SDL_Window * window) +void PSP_ShowWindow(_THIS, SDL_Window *window) { } -void -PSP_HideWindow(_THIS, SDL_Window * window) +void PSP_HideWindow(_THIS, SDL_Window *window) { } -void -PSP_RaiseWindow(_THIS, SDL_Window * window) +void PSP_RaiseWindow(_THIS, SDL_Window *window) { } -void -PSP_MaximizeWindow(_THIS, SDL_Window * window) +void PSP_MaximizeWindow(_THIS, SDL_Window *window) { } -void -PSP_MinimizeWindow(_THIS, SDL_Window * window) +void PSP_MinimizeWindow(_THIS, SDL_Window *window) { } -void -PSP_RestoreWindow(_THIS, SDL_Window * window) +void PSP_RestoreWindow(_THIS, SDL_Window *window) { } -void -PSP_DestroyWindow(_THIS, SDL_Window * window) +void PSP_DestroyWindow(_THIS, SDL_Window *window) { } @@ -314,7 +291,6 @@ SDL_bool PSP_IsScreenKeyboardShown(_THIS, SDL_Window *window) return SDL_FALSE; } - #endif /* SDL_VIDEO_DRIVER_PSP */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/psp/SDL_pspvideo.h b/src/video/psp/SDL_pspvideo.h index e046c891e..6123e2854 100644 --- a/src/video/psp/SDL_pspvideo.h +++ b/src/video/psp/SDL_pspvideo.h @@ -29,29 +29,22 @@ typedef struct SDL_VideoData { - SDL_bool egl_initialized; /* OpenGL ES device initialization status */ - uint32_t egl_refcount; /* OpenGL ES reference count */ - - + SDL_bool egl_initialized; /* OpenGL ES device initialization status */ + uint32_t egl_refcount; /* OpenGL ES reference count */ } SDL_VideoData; - typedef struct SDL_DisplayData { } SDL_DisplayData; - typedef struct SDL_WindowData { - SDL_bool uses_gles; /* if true window must support OpenGL ES */ + SDL_bool uses_gles; /* if true window must support OpenGL ES */ } SDL_WindowData; - - - /****************************************************************************/ /* SDL_VideoDevice functions declaration */ /****************************************************************************/ @@ -59,21 +52,21 @@ typedef struct SDL_WindowData /* Display and window functions */ int PSP_VideoInit(_THIS); void PSP_VideoQuit(_THIS); -void PSP_GetDisplayModes(_THIS, SDL_VideoDisplay * display); -int PSP_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); -int PSP_CreateWindow(_THIS, SDL_Window * window); -int PSP_CreateWindowFrom(_THIS, SDL_Window * window, const void *data); -void PSP_SetWindowTitle(_THIS, SDL_Window * window); -void PSP_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon); -void PSP_SetWindowPosition(_THIS, SDL_Window * window); -void PSP_SetWindowSize(_THIS, SDL_Window * window); -void PSP_ShowWindow(_THIS, SDL_Window * window); -void PSP_HideWindow(_THIS, SDL_Window * window); -void PSP_RaiseWindow(_THIS, SDL_Window * window); -void PSP_MaximizeWindow(_THIS, SDL_Window * window); -void PSP_MinimizeWindow(_THIS, SDL_Window * window); -void PSP_RestoreWindow(_THIS, SDL_Window * window); -void PSP_DestroyWindow(_THIS, SDL_Window * window); +void PSP_GetDisplayModes(_THIS, SDL_VideoDisplay *display); +int PSP_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode); +int PSP_CreateWindow(_THIS, SDL_Window *window); +int PSP_CreateWindowFrom(_THIS, SDL_Window *window, const void *data); +void PSP_SetWindowTitle(_THIS, SDL_Window *window); +void PSP_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon); +void PSP_SetWindowPosition(_THIS, SDL_Window *window); +void PSP_SetWindowSize(_THIS, SDL_Window *window); +void PSP_ShowWindow(_THIS, SDL_Window *window); +void PSP_HideWindow(_THIS, SDL_Window *window); +void PSP_RaiseWindow(_THIS, SDL_Window *window); +void PSP_MaximizeWindow(_THIS, SDL_Window *window); +void PSP_MinimizeWindow(_THIS, SDL_Window *window); +void PSP_RestoreWindow(_THIS, SDL_Window *window); +void PSP_DestroyWindow(_THIS, SDL_Window *window); /* Window manager function */ SDL_bool PSP_GetWindowWMInfo(_THIS, SDL_Window * window, @@ -83,11 +76,11 @@ SDL_bool PSP_GetWindowWMInfo(_THIS, SDL_Window * window, int PSP_GL_LoadLibrary(_THIS, const char *path); void *PSP_GL_GetProcAddress(_THIS, const char *proc); void PSP_GL_UnloadLibrary(_THIS); -SDL_GLContext PSP_GL_CreateContext(_THIS, SDL_Window * window); -int PSP_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); +SDL_GLContext PSP_GL_CreateContext(_THIS, SDL_Window *window); +int PSP_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); int PSP_GL_SetSwapInterval(_THIS, int interval); int PSP_GL_GetSwapInterval(_THIS); -int PSP_GL_SwapWindow(_THIS, SDL_Window * window); +int PSP_GL_SwapWindow(_THIS, SDL_Window *window); void PSP_GL_DeleteContext(_THIS, SDL_GLContext context); /* PSP on screen keyboard */ diff --git a/src/video/raspberry/SDL_rpievents.c b/src/video/raspberry/SDL_rpievents.c index c1c7bb724..edf556b63 100644 --- a/src/video/raspberry/SDL_rpievents.c +++ b/src/video/raspberry/SDL_rpievents.c @@ -38,8 +38,6 @@ void RPI_PumpEvents(_THIS) #ifdef SDL_INPUT_LINUXEV SDL_EVDEV_Poll(); #endif - } #endif /* SDL_VIDEO_DRIVER_RPI */ - diff --git a/src/video/raspberry/SDL_rpimouse.c b/src/video/raspberry/SDL_rpimouse.c index 7614fb8c0..d24097b1e 100644 --- a/src/video/raspberry/SDL_rpimouse.c +++ b/src/video/raspberry/SDL_rpimouse.c @@ -34,49 +34,47 @@ /* Copied from vc_vchi_dispmanx.h which is bugged and tries to include a non existing file */ /* Attributes changes flag mask */ -#define ELEMENT_CHANGE_LAYER (1<<0) -#define ELEMENT_CHANGE_OPACITY (1<<1) -#define ELEMENT_CHANGE_DEST_RECT (1<<2) -#define ELEMENT_CHANGE_SRC_RECT (1<<3) -#define ELEMENT_CHANGE_MASK_RESOURCE (1<<4) -#define ELEMENT_CHANGE_TRANSFORM (1<<5) +#define ELEMENT_CHANGE_LAYER (1 << 0) +#define ELEMENT_CHANGE_OPACITY (1 << 1) +#define ELEMENT_CHANGE_DEST_RECT (1 << 2) +#define ELEMENT_CHANGE_SRC_RECT (1 << 3) +#define ELEMENT_CHANGE_MASK_RESOURCE (1 << 4) +#define ELEMENT_CHANGE_TRANSFORM (1 << 5) /* End copied from vc_vchi_dispmanx.h */ static SDL_Cursor *RPI_CreateDefaultCursor(void); -static SDL_Cursor *RPI_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y); -static int RPI_ShowCursor(SDL_Cursor * cursor); -static void RPI_MoveCursor(SDL_Cursor * cursor); -static void RPI_FreeCursor(SDL_Cursor * cursor); -static void RPI_WarpMouse(SDL_Window * window, int x, int y); +static SDL_Cursor *RPI_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y); +static int RPI_ShowCursor(SDL_Cursor *cursor); +static void RPI_MoveCursor(SDL_Cursor *cursor); +static void RPI_FreeCursor(SDL_Cursor *cursor); +static void RPI_WarpMouse(SDL_Window *window, int x, int y); static int RPI_WarpMouseGlobal(int x, int y); static SDL_Cursor *global_cursor; -static SDL_Cursor * -RPI_CreateDefaultCursor(void) +static SDL_Cursor *RPI_CreateDefaultCursor(void) { return SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH, DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY); } /* Create a cursor from a surface */ -static SDL_Cursor * -RPI_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) +static SDL_Cursor *RPI_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) { RPI_CursorData *curdata; SDL_Cursor *cursor; int ret; VC_RECT_T dst_rect; Uint32 dummy; - + SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888); SDL_assert(surface->pitch == surface->w * 4); - - cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor)); + + cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor)); if (cursor == NULL) { SDL_OutOfMemory(); return NULL; } - curdata = (RPI_CursorData *) SDL_calloc(1, sizeof(*curdata)); + curdata = (RPI_CursorData *)SDL_calloc(1, sizeof(*curdata)); if (curdata == NULL) { SDL_OutOfMemory(); SDL_free(cursor); @@ -87,29 +85,27 @@ RPI_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) curdata->hot_y = hot_y; curdata->w = surface->w; curdata->h = surface->h; - + /* This usage is inspired by Wayland/Weston RPI code, how they figured this out is anyone's guess */ curdata->resource = vc_dispmanx_resource_create(VC_IMAGE_ARGB8888, surface->w | (surface->pitch << 16), surface->h | (surface->h << 16), &dummy); SDL_assert(curdata->resource); vc_dispmanx_rect_set(&dst_rect, 0, 0, curdata->w, curdata->h); - /* A note from Weston: + /* A note from Weston: * vc_dispmanx_resource_write_data() ignores ifmt, * rect.x, rect.width, and uses stride only for computing * the size of the transfer as rect.height * stride. * Therefore we can only write rows starting at x=0. */ ret = vc_dispmanx_resource_write_data(curdata->resource, VC_IMAGE_ARGB8888, surface->pitch, surface->pixels, &dst_rect); - SDL_assert (ret == DISPMANX_SUCCESS); - - cursor->driverdata = curdata; - - return cursor; + SDL_assert(ret == DISPMANX_SUCCESS); + cursor->driverdata = curdata; + + return cursor; } /* Show the specified cursor, or hide if cursor is NULL */ -static int -RPI_ShowCursor(SDL_Cursor * cursor) +static int RPI_ShowCursor(SDL_Cursor *cursor) { int ret; DISPMANX_UPDATE_HANDLE_T update; @@ -118,7 +114,7 @@ RPI_ShowCursor(SDL_Cursor * cursor) SDL_Mouse *mouse; SDL_VideoDisplay *display; SDL_DisplayData *data; - VC_DISPMANX_ALPHA_T alpha = { DISPMANX_FLAGS_ALPHA_FROM_SOURCE /* flags */ , 255 /*opacity 0->255*/, 0 /* mask */ }; + VC_DISPMANX_ALPHA_T alpha = { DISPMANX_FLAGS_ALPHA_FROM_SOURCE /* flags */, 255 /*opacity 0->255*/, 0 /* mask */ }; uint32_t layer = SDL_RPI_MOUSELAYER; const char *env; @@ -126,10 +122,10 @@ RPI_ShowCursor(SDL_Cursor * cursor) if (mouse == NULL) { return -1; } - + if (cursor != global_cursor) { if (global_cursor != NULL) { - curdata = (RPI_CursorData *) global_cursor->driverdata; + curdata = (RPI_CursorData *)global_cursor->driverdata; if (curdata && curdata->element > DISPMANX_NO_HANDLE) { update = vc_dispmanx_update_start(0); SDL_assert(update); @@ -146,12 +142,12 @@ RPI_ShowCursor(SDL_Cursor * cursor) if (cursor == NULL) { return 0; } - - curdata = (RPI_CursorData *) cursor->driverdata; + + curdata = (RPI_CursorData *)cursor->driverdata; if (curdata == NULL) { return -1; } - + if (mouse->focus == NULL) { return -1; } @@ -160,16 +156,16 @@ RPI_ShowCursor(SDL_Cursor * cursor) if (display == NULL) { return -1; } - - data = (SDL_DisplayData*) display->driverdata; + + data = (SDL_DisplayData *)display->driverdata; if (data == NULL) { return -1; } - + if (curdata->element == DISPMANX_NO_HANDLE) { vc_dispmanx_rect_set(&src_rect, 0, 0, curdata->w << 16, curdata->h << 16); vc_dispmanx_rect_set(&dst_rect, mouse->x - curdata->hot_x, mouse->y - curdata->hot_y, curdata->w, curdata->h); - + update = vc_dispmanx_update_start(0); SDL_assert(update); @@ -179,34 +175,33 @@ RPI_ShowCursor(SDL_Cursor * cursor) } curdata->element = vc_dispmanx_element_add(update, - data->dispman_display, - layer, - &dst_rect, - curdata->resource, - &src_rect, - DISPMANX_PROTECTION_NONE, - &alpha, - DISPMANX_NO_HANDLE, // clamp - DISPMANX_NO_ROTATE); + data->dispman_display, + layer, + &dst_rect, + curdata->resource, + &src_rect, + DISPMANX_PROTECTION_NONE, + &alpha, + DISPMANX_NO_HANDLE, // clamp + DISPMANX_NO_ROTATE); SDL_assert(curdata->element > DISPMANX_NO_HANDLE); ret = vc_dispmanx_update_submit_sync(update); SDL_assert(ret == DISPMANX_SUCCESS); } - + return 0; } /* Free a window manager cursor */ -static void -RPI_FreeCursor(SDL_Cursor * cursor) +static void RPI_FreeCursor(SDL_Cursor *cursor) { int ret; DISPMANX_UPDATE_HANDLE_T update; RPI_CursorData *curdata; - + if (cursor != NULL) { - curdata = (RPI_CursorData *) cursor->driverdata; - + curdata = (RPI_CursorData *)cursor->driverdata; + if (curdata != NULL) { if (curdata->element != DISPMANX_NO_HANDLE) { update = vc_dispmanx_update_start(0); @@ -216,12 +211,12 @@ RPI_FreeCursor(SDL_Cursor * cursor) ret = vc_dispmanx_update_submit_sync(update); SDL_assert(ret == DISPMANX_SUCCESS); } - + if (curdata->resource != DISPMANX_NO_HANDLE) { ret = vc_dispmanx_resource_delete(curdata->resource); SDL_assert(ret == DISPMANX_SUCCESS); } - + SDL_free(cursor->driverdata); } SDL_free(cursor); @@ -232,15 +227,13 @@ RPI_FreeCursor(SDL_Cursor * cursor) } /* Warp the mouse to (x,y) */ -static void -RPI_WarpMouse(SDL_Window * window, int x, int y) +static void RPI_WarpMouse(SDL_Window *window, int x, int y) { RPI_WarpMouseGlobal(x, y); } /* Warp the mouse to (x,y) */ -static int -RPI_WarpMouseGlobal(int x, int y) +static int RPI_WarpMouseGlobal(int x, int y) { RPI_CursorData *curdata; DISPMANX_UPDATE_HANDLE_T update; @@ -248,7 +241,7 @@ RPI_WarpMouseGlobal(int x, int y) VC_RECT_T dst_rect; VC_RECT_T src_rect; SDL_Mouse *mouse = SDL_GetMouse(); - + if (mouse == NULL || mouse->cur_cursor == NULL || mouse->cur_cursor->driverdata == NULL) { return 0; } @@ -256,7 +249,7 @@ RPI_WarpMouseGlobal(int x, int y) /* Update internal mouse position. */ SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 0, x, y); - curdata = (RPI_CursorData *) mouse->cur_cursor->driverdata; + curdata = (RPI_CursorData *)mouse->cur_cursor->driverdata; if (curdata->element == DISPMANX_NO_HANDLE) { return 0; } @@ -268,11 +261,11 @@ RPI_WarpMouseGlobal(int x, int y) src_rect.x = 0; src_rect.y = 0; - src_rect.width = curdata->w << 16; + src_rect.width = curdata->w << 16; src_rect.height = curdata->h << 16; dst_rect.x = x - curdata->hot_x; dst_rect.y = y - curdata->hot_y; - dst_rect.width = curdata->w; + dst_rect.width = curdata->w; dst_rect.height = curdata->h; ret = vc_dispmanx_element_change_attributes( @@ -298,8 +291,7 @@ RPI_WarpMouseGlobal(int x, int y) } /* Warp the mouse to (x,y) */ -static int -RPI_WarpMouseGlobalGraphicOnly(int x, int y) +static int RPI_WarpMouseGlobalGraphicOnly(int x, int y) { RPI_CursorData *curdata; DISPMANX_UPDATE_HANDLE_T update; @@ -307,12 +299,12 @@ RPI_WarpMouseGlobalGraphicOnly(int x, int y) VC_RECT_T dst_rect; VC_RECT_T src_rect; SDL_Mouse *mouse = SDL_GetMouse(); - + if (mouse == NULL || mouse->cur_cursor == NULL || mouse->cur_cursor->driverdata == NULL) { return 0; } - curdata = (RPI_CursorData *) mouse->cur_cursor->driverdata; + curdata = (RPI_CursorData *)mouse->cur_cursor->driverdata; if (curdata->element == DISPMANX_NO_HANDLE) { return 0; } @@ -324,11 +316,11 @@ RPI_WarpMouseGlobalGraphicOnly(int x, int y) src_rect.x = 0; src_rect.y = 0; - src_rect.width = curdata->w << 16; + src_rect.width = curdata->w << 16; src_rect.height = curdata->h << 16; dst_rect.x = x - curdata->hot_x; dst_rect.y = y - curdata->hot_y; - dst_rect.width = curdata->w; + dst_rect.width = curdata->w; dst_rect.height = curdata->h; ret = vc_dispmanx_element_change_attributes( @@ -353,10 +345,9 @@ RPI_WarpMouseGlobalGraphicOnly(int x, int y) return 0; } -void -RPI_InitMouse(_THIS) +void RPI_InitMouse(_THIS) { - /* FIXME: Using UDEV it should be possible to scan all mice + /* FIXME: Using UDEV it should be possible to scan all mice * but there's no point in doing so as there's no multimice support...yet! */ SDL_Mouse *mouse = SDL_GetMouse(); @@ -371,17 +362,15 @@ RPI_InitMouse(_THIS) SDL_SetDefaultCursor(RPI_CreateDefaultCursor()); } -void -RPI_QuitMouse(_THIS) +void RPI_QuitMouse(_THIS) { } /* This is called when a mouse motion event occurs */ -static void -RPI_MoveCursor(SDL_Cursor * cursor) +static void RPI_MoveCursor(SDL_Cursor *cursor) { SDL_Mouse *mouse = SDL_GetMouse(); - /* We must NOT call SDL_SendMouseMotion() on the next call or we will enter recursivity, + /* We must NOT call SDL_SendMouseMotion() on the next call or we will enter recursivity, * so we create a version of WarpMouseGlobal without it. */ RPI_WarpMouseGlobalGraphicOnly(mouse->x, mouse->y); } diff --git a/src/video/raspberry/SDL_rpimouse.h b/src/video/raspberry/SDL_rpimouse.h index 40701e126..eb6fa8a24 100644 --- a/src/video/raspberry/SDL_rpimouse.h +++ b/src/video/raspberry/SDL_rpimouse.h @@ -27,13 +27,13 @@ typedef struct _RPI_CursorData RPI_CursorData; struct _RPI_CursorData { - DISPMANX_RESOURCE_HANDLE_T resource; - DISPMANX_ELEMENT_HANDLE_T element; - int hot_x, hot_y; - int w, h; + DISPMANX_RESOURCE_HANDLE_T resource; + DISPMANX_ELEMENT_HANDLE_T element; + int hot_x, hot_y; + int w, h; }; -#define SDL_RPI_CURSORDATA(curs) RPI_CursorData *curdata = (RPI_CursorData *) ((curs) ? (curs)->driverdata : NULL) +#define SDL_RPI_CURSORDATA(curs) RPI_CursorData *curdata = (RPI_CursorData *)((curs) ? (curs)->driverdata : NULL) extern void RPI_InitMouse(_THIS); extern void RPI_QuitMouse(_THIS); diff --git a/src/video/raspberry/SDL_rpiopengles.c b/src/video/raspberry/SDL_rpiopengles.c index 7b62b3e43..dfc461e9b 100644 --- a/src/video/raspberry/SDL_rpiopengles.c +++ b/src/video/raspberry/SDL_rpiopengles.c @@ -29,22 +29,21 @@ /* EGL implementation of SDL OpenGL support */ -void -RPI_GLES_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor) +void RPI_GLES_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor) { *mask = SDL_GL_CONTEXT_PROFILE_ES; *major = 2; *minor = 0; } -int -RPI_GLES_LoadLibrary(_THIS, const char *path) { +int RPI_GLES_LoadLibrary(_THIS, const char *path) +{ return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY, 0); } -int -RPI_GLES_SwapWindow(_THIS, SDL_Window * window) { - SDL_WindowData *wdata = ((SDL_WindowData *) window->driverdata); +int RPI_GLES_SwapWindow(_THIS, SDL_Window *window) +{ + SDL_WindowData *wdata = ((SDL_WindowData *)window->driverdata); if (!(_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, wdata->egl_surface))) { SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "eglSwapBuffers failed."); @@ -63,9 +62,8 @@ RPI_GLES_SwapWindow(_THIS, SDL_Window * window) { } SDL_EGL_CreateContext_impl(RPI) -SDL_EGL_MakeCurrent_impl(RPI) + SDL_EGL_MakeCurrent_impl(RPI) #endif /* SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL */ -/* vi: set ts=4 sw=4 expandtab: */ - + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/raspberry/SDL_rpiopengles.h b/src/video/raspberry/SDL_rpiopengles.h index 2cdf0fdcf..4b8538a34 100644 --- a/src/video/raspberry/SDL_rpiopengles.h +++ b/src/video/raspberry/SDL_rpiopengles.h @@ -34,12 +34,12 @@ #define RPI_GLES_UnloadLibrary SDL_EGL_UnloadLibrary #define RPI_GLES_SetSwapInterval SDL_EGL_SetSwapInterval #define RPI_GLES_GetSwapInterval SDL_EGL_GetSwapInterval -#define RPI_GLES_DeleteContext SDL_EGL_DeleteContext +#define RPI_GLES_DeleteContext SDL_EGL_DeleteContext extern int RPI_GLES_LoadLibrary(_THIS, const char *path); -extern SDL_GLContext RPI_GLES_CreateContext(_THIS, SDL_Window * window); -extern int RPI_GLES_SwapWindow(_THIS, SDL_Window * window); -extern int RPI_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); +extern SDL_GLContext RPI_GLES_CreateContext(_THIS, SDL_Window *window); +extern int RPI_GLES_SwapWindow(_THIS, SDL_Window *window); +extern int RPI_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); extern void RPI_GLES_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor); #endif /* SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL */ diff --git a/src/video/raspberry/SDL_rpivideo.c b/src/video/raspberry/SDL_rpivideo.c index 39a7db0f9..8ab8e8fa6 100644 --- a/src/video/raspberry/SDL_rpivideo.c +++ b/src/video/raspberry/SDL_rpivideo.c @@ -50,45 +50,40 @@ #include "SDL_rpiopengles.h" #include "SDL_rpimouse.h" -static void -RPI_Destroy(SDL_VideoDevice * device) +static void RPI_Destroy(SDL_VideoDevice *device) { SDL_free(device->driverdata); SDL_free(device); } -static int -RPI_GetRefreshRate() +static int RPI_GetRefreshRate() { TV_DISPLAY_STATE_T tvstate; - if (vc_tv_get_display_state( &tvstate ) == 0) { - //The width/height parameters are in the same position in the union - //for HDMI and SDTV + if (vc_tv_get_display_state(&tvstate) == 0) { + // The width/height parameters are in the same position in the union + // for HDMI and SDTV HDMI_PROPERTY_PARAM_T property; property.property = HDMI_PROPERTY_PIXEL_CLOCK_TYPE; vc_tv_hdmi_get_property(&property); - return property.param1 == HDMI_PIXEL_CLOCK_TYPE_NTSC ? - tvstate.display.hdmi.frame_rate * (1000.0f/1001.0f) : - tvstate.display.hdmi.frame_rate; - } - return 60; /* Failed to get display state, default to 60 */ + return property.param1 == HDMI_PIXEL_CLOCK_TYPE_NTSC ? tvstate.display.hdmi.frame_rate * (1000.0f / 1001.0f) : tvstate.display.hdmi.frame_rate; + } + return 60; /* Failed to get display state, default to 60 */ } -static SDL_VideoDevice * -RPI_Create() +static SDL_VideoDevice *RPI_Create() { SDL_VideoDevice *device; SDL_VideoData *phdata; /* Initialize SDL_VideoDevice structure */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device == NULL) { SDL_OutOfMemory(); return NULL; } /* Initialize internal data */ - phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); + phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); if (phdata == NULL) { SDL_OutOfMemory(); SDL_free(device); @@ -146,13 +141,11 @@ VideoBootStrap RPI_bootstrap = { RPI_Create }; - /*****************************************************************************/ /* SDL Video and Display initialization/handling functions */ /*****************************************************************************/ -static void -AddDispManXDisplay(const int display_id) +static void AddDispManXDisplay(const int display_id) { DISPMANX_MODEINFO_T modeinfo; DISPMANX_DISPLAY_HANDLE_T handle; @@ -162,7 +155,7 @@ AddDispManXDisplay(const int display_id) handle = vc_dispmanx_display_open(display_id); if (!handle) { - return; /* this display isn't available */ + return; /* this display isn't available */ } if (vc_dispmanx_display_get_info(handle, &modeinfo) < 0) { @@ -185,10 +178,10 @@ AddDispManXDisplay(const int display_id) display.current_mode = current_mode; /* Allocate display internal data */ - data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData)); + data = (SDL_DisplayData *)SDL_calloc(1, sizeof(SDL_DisplayData)); if (data == NULL) { vc_dispmanx_display_close(handle); - return; /* oh well */ + return; /* oh well */ } data->dispman_display = handle; @@ -198,82 +191,76 @@ AddDispManXDisplay(const int display_id) SDL_AddVideoDisplay(&display, SDL_FALSE); } -int -RPI_VideoInit(_THIS) +int RPI_VideoInit(_THIS) { /* Initialize BCM Host */ bcm_host_init(); - AddDispManXDisplay(DISPMANX_ID_MAIN_LCD); /* your default display */ - AddDispManXDisplay(DISPMANX_ID_FORCE_OTHER); /* an "other" display...maybe DSI-connected screen while HDMI is your main */ + AddDispManXDisplay(DISPMANX_ID_MAIN_LCD); /* your default display */ + AddDispManXDisplay(DISPMANX_ID_FORCE_OTHER); /* an "other" display...maybe DSI-connected screen while HDMI is your main */ -#ifdef SDL_INPUT_LINUXEV +#ifdef SDL_INPUT_LINUXEV if (SDL_EVDEV_Init() < 0) { return -1; } -#endif - +#endif + RPI_InitMouse(_this); return 1; } -void -RPI_VideoQuit(_THIS) +void RPI_VideoQuit(_THIS) { -#ifdef SDL_INPUT_LINUXEV +#ifdef SDL_INPUT_LINUXEV SDL_EVDEV_Quit(); -#endif +#endif } -void -RPI_GetDisplayModes(_THIS, SDL_VideoDisplay * display) +void RPI_GetDisplayModes(_THIS, SDL_VideoDisplay *display) { /* Only one display mode available, the current one */ SDL_AddDisplayMode(display, &display->current_mode); } -int -RPI_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +int RPI_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) { return 0; } -static void -RPI_vsync_callback(DISPMANX_UPDATE_HANDLE_T u, void *data) +static void RPI_vsync_callback(DISPMANX_UPDATE_HANDLE_T u, void *data) { - SDL_WindowData *wdata = ((SDL_WindowData *) data); + SDL_WindowData *wdata = ((SDL_WindowData *)data); - SDL_LockMutex(wdata->vsync_cond_mutex); - SDL_CondSignal(wdata->vsync_cond); - SDL_UnlockMutex(wdata->vsync_cond_mutex); + SDL_LockMutex(wdata->vsync_cond_mutex); + SDL_CondSignal(wdata->vsync_cond); + SDL_UnlockMutex(wdata->vsync_cond_mutex); } -int -RPI_CreateWindow(_THIS, SDL_Window * window) +int RPI_CreateWindow(_THIS, SDL_Window *window) { SDL_WindowData *wdata; SDL_VideoDisplay *display; SDL_DisplayData *displaydata; VC_RECT_T dst_rect; VC_RECT_T src_rect; - VC_DISPMANX_ALPHA_T dispman_alpha; + VC_DISPMANX_ALPHA_T dispman_alpha; DISPMANX_UPDATE_HANDLE_T dispman_update; uint32_t layer = SDL_RPI_VIDEOLAYER; const char *env; /* Disable alpha, otherwise the app looks composed with whatever dispman is showing (X11, console,etc) */ - dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS; - dispman_alpha.opacity = 0xFF; + dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS; + dispman_alpha.opacity = 0xFF; dispman_alpha.mask = 0; /* Allocate window internal data */ - wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); + wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); if (wdata == NULL) { return SDL_OutOfMemory(); } display = SDL_GetDisplayForWindow(window); - displaydata = (SDL_DisplayData *) display->driverdata; + displaydata = (SDL_DisplayData *)display->driverdata; /* Windows have one size for now */ window->w = display->desktop_mode.w; @@ -298,27 +285,27 @@ RPI_CreateWindow(_THIS, SDL_Window * window) layer = SDL_atoi(env); } - dispman_update = vc_dispmanx_update_start( 0 ); - wdata->dispman_window.element = vc_dispmanx_element_add (dispman_update, - displaydata->dispman_display, - layer /* layer */, - &dst_rect, - 0 /*src*/, - &src_rect, - DISPMANX_PROTECTION_NONE, - &dispman_alpha /*alpha*/, - 0 /*clamp*/, - 0 /*transform*/); + dispman_update = vc_dispmanx_update_start(0); + wdata->dispman_window.element = vc_dispmanx_element_add(dispman_update, + displaydata->dispman_display, + layer /* layer */, + &dst_rect, + 0 /*src*/, + &src_rect, + DISPMANX_PROTECTION_NONE, + &dispman_alpha /*alpha*/, + 0 /*clamp*/, + 0 /*transform*/); wdata->dispman_window.width = window->w; wdata->dispman_window.height = window->h; vc_dispmanx_update_submit_sync(dispman_update); - + if (!_this->egl_data) { if (SDL_GL_LoadLibrary(NULL) < 0) { return -1; } } - wdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) &wdata->dispman_window); + wdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType)&wdata->dispman_window); if (wdata->egl_surface == EGL_NO_SURFACE) { return SDL_SetError("Could not create GLES window surface"); @@ -330,7 +317,7 @@ RPI_CreateWindow(_THIS, SDL_Window * window) wdata->vsync_cond = SDL_CreateCond(); wdata->vsync_cond_mutex = SDL_CreateMutex(); wdata->double_buffer = SDL_TRUE; - vc_dispmanx_vsync_callback(displaydata->dispman_display, RPI_vsync_callback, (void*)wdata); + vc_dispmanx_vsync_callback(displaydata->dispman_display, RPI_vsync_callback, (void *)wdata); } /* Setup driver data for this window */ @@ -344,12 +331,11 @@ RPI_CreateWindow(_THIS, SDL_Window * window) return 0; } -void -RPI_DestroyWindow(_THIS, SDL_Window * window) +void RPI_DestroyWindow(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); - SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata; + SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata; if (data) { if (data->double_buffer) { @@ -374,50 +360,39 @@ RPI_DestroyWindow(_THIS, SDL_Window * window) } } -int -RPI_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) +int RPI_CreateWindowFrom(_THIS, SDL_Window *window, const void *data) { return -1; } -void -RPI_SetWindowTitle(_THIS, SDL_Window * window) +void RPI_SetWindowTitle(_THIS, SDL_Window *window) { } -void -RPI_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) +void RPI_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon) { } -void -RPI_SetWindowPosition(_THIS, SDL_Window * window) +void RPI_SetWindowPosition(_THIS, SDL_Window *window) { } -void -RPI_SetWindowSize(_THIS, SDL_Window * window) +void RPI_SetWindowSize(_THIS, SDL_Window *window) { } -void -RPI_ShowWindow(_THIS, SDL_Window * window) +void RPI_ShowWindow(_THIS, SDL_Window *window) { } -void -RPI_HideWindow(_THIS, SDL_Window * window) +void RPI_HideWindow(_THIS, SDL_Window *window) { } -void -RPI_RaiseWindow(_THIS, SDL_Window * window) +void RPI_RaiseWindow(_THIS, SDL_Window *window) { } -void -RPI_MaximizeWindow(_THIS, SDL_Window * window) +void RPI_MaximizeWindow(_THIS, SDL_Window *window) { } -void -RPI_MinimizeWindow(_THIS, SDL_Window * window) +void RPI_MinimizeWindow(_THIS, SDL_Window *window) { } -void -RPI_RestoreWindow(_THIS, SDL_Window * window) +void RPI_RestoreWindow(_THIS, SDL_Window *window) { } diff --git a/src/video/raspberry/SDL_rpivideo.h b/src/video/raspberry/SDL_rpivideo.h index 2b5f40f4d..ad56c6a46 100644 --- a/src/video/raspberry/SDL_rpivideo.h +++ b/src/video/raspberry/SDL_rpivideo.h @@ -32,25 +32,23 @@ typedef struct SDL_VideoData { - uint32_t egl_refcount; /* OpenGL ES reference count */ + uint32_t egl_refcount; /* OpenGL ES reference count */ } SDL_VideoData; - typedef struct SDL_DisplayData { DISPMANX_DISPLAY_HANDLE_T dispman_display; } SDL_DisplayData; - typedef struct SDL_WindowData { EGL_DISPMANX_WINDOW_T dispman_window; -#if SDL_VIDEO_OPENGL_EGL +#if SDL_VIDEO_OPENGL_EGL EGLSurface egl_surface; -#endif +#endif /* Vsync callback cond and mutex */ - SDL_cond *vsync_cond; + SDL_cond *vsync_cond; SDL_mutex *vsync_cond_mutex; SDL_bool double_buffer; @@ -59,7 +57,6 @@ typedef struct SDL_WindowData #define SDL_RPI_VIDEOLAYER 10000 /* High enough so to occlude everything */ #define SDL_RPI_MOUSELAYER SDL_RPI_VIDEOLAYER + 1 - /****************************************************************************/ /* SDL_VideoDevice functions declaration */ /****************************************************************************/ @@ -67,21 +64,21 @@ typedef struct SDL_WindowData /* Display and window functions */ int RPI_VideoInit(_THIS); void RPI_VideoQuit(_THIS); -void RPI_GetDisplayModes(_THIS, SDL_VideoDisplay * display); -int RPI_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); -int RPI_CreateWindow(_THIS, SDL_Window * window); -int RPI_CreateWindowFrom(_THIS, SDL_Window * window, const void *data); -void RPI_SetWindowTitle(_THIS, SDL_Window * window); -void RPI_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon); -void RPI_SetWindowPosition(_THIS, SDL_Window * window); -void RPI_SetWindowSize(_THIS, SDL_Window * window); -void RPI_ShowWindow(_THIS, SDL_Window * window); -void RPI_HideWindow(_THIS, SDL_Window * window); -void RPI_RaiseWindow(_THIS, SDL_Window * window); -void RPI_MaximizeWindow(_THIS, SDL_Window * window); -void RPI_MinimizeWindow(_THIS, SDL_Window * window); -void RPI_RestoreWindow(_THIS, SDL_Window * window); -void RPI_DestroyWindow(_THIS, SDL_Window * window); +void RPI_GetDisplayModes(_THIS, SDL_VideoDisplay *display); +int RPI_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode); +int RPI_CreateWindow(_THIS, SDL_Window *window); +int RPI_CreateWindowFrom(_THIS, SDL_Window *window, const void *data); +void RPI_SetWindowTitle(_THIS, SDL_Window *window); +void RPI_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon); +void RPI_SetWindowPosition(_THIS, SDL_Window *window); +void RPI_SetWindowSize(_THIS, SDL_Window *window); +void RPI_ShowWindow(_THIS, SDL_Window *window); +void RPI_HideWindow(_THIS, SDL_Window *window); +void RPI_RaiseWindow(_THIS, SDL_Window *window); +void RPI_MaximizeWindow(_THIS, SDL_Window *window); +void RPI_MinimizeWindow(_THIS, SDL_Window *window); +void RPI_RestoreWindow(_THIS, SDL_Window *window); +void RPI_DestroyWindow(_THIS, SDL_Window *window); /* Window manager function */ SDL_bool RPI_GetWindowWMInfo(_THIS, SDL_Window * window, @@ -91,11 +88,11 @@ SDL_bool RPI_GetWindowWMInfo(_THIS, SDL_Window * window, int RPI_GLES_LoadLibrary(_THIS, const char *path); void *RPI_GLES_GetProcAddress(_THIS, const char *proc); void RPI_GLES_UnloadLibrary(_THIS); -SDL_GLContext RPI_GLES_CreateContext(_THIS, SDL_Window * window); -int RPI_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); +SDL_GLContext RPI_GLES_CreateContext(_THIS, SDL_Window *window); +int RPI_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); int RPI_GLES_SetSwapInterval(_THIS, int interval); int RPI_GLES_GetSwapInterval(_THIS); -int RPI_GLES_SwapWindow(_THIS, SDL_Window * window); +int RPI_GLES_SwapWindow(_THIS, SDL_Window *window); void RPI_GLES_DeleteContext(_THIS, SDL_GLContext context); #endif /* __SDL_RPIVIDEO_H__ */ diff --git a/src/video/riscos/SDL_riscosdefs.h b/src/video/riscos/SDL_riscosdefs.h index 89a51f2b8..a01e77953 100644 --- a/src/video/riscos/SDL_riscosdefs.h +++ b/src/video/riscos/SDL_riscosdefs.h @@ -23,7 +23,8 @@ #ifndef SDL_riscosdefs_h_ #define SDL_riscosdefs_h_ -typedef struct sprite_area { +typedef struct sprite_area +{ int size; /* +0 */ int count; /* +4 */ int start; /* +8 */ @@ -32,7 +33,8 @@ typedef struct sprite_area { SDL_COMPILE_TIME_ASSERT(sprite_area, sizeof(sprite_area) == 16); -typedef struct sprite_header { +typedef struct sprite_header +{ int next; /* +0 */ char name[12]; /* +4 */ int width; /* +16 */ diff --git a/src/video/riscos/SDL_riscosevents.c b/src/video/riscos/SDL_riscosevents.c index 362a67c0a..926369f90 100644 --- a/src/video/riscos/SDL_riscosevents.c +++ b/src/video/riscos/SDL_riscosevents.c @@ -32,8 +32,7 @@ #include #include -static SDL_Scancode -SDL_RISCOS_translate_keycode(int keycode) +static SDL_Scancode SDL_RISCOS_translate_keycode(int keycode) { SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN; @@ -50,8 +49,7 @@ SDL_RISCOS_translate_keycode(int keycode) return scancode; } -void -RISCOS_PollKeyboard(_THIS) +void RISCOS_PollKeyboard(_THIS) { SDL_VideoData *driverdata = (SDL_VideoData *)_this->driverdata; Uint8 key = 2; @@ -111,8 +109,7 @@ static const Uint8 mouse_button_map[] = { SDL_BUTTON_X2 + 3 }; -void -RISCOS_PollMouse(_THIS) +void RISCOS_PollMouse(_THIS) { SDL_VideoData *driverdata = (SDL_VideoData *)_this->driverdata; SDL_Mouse *mouse = SDL_GetMouse(); @@ -141,10 +138,9 @@ RISCOS_PollMouse(_THIS) } } -int -RISCOS_InitEvents(_THIS) +int RISCOS_InitEvents(_THIS) { - SDL_VideoData *driverdata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *driverdata = (SDL_VideoData *)_this->driverdata; _kernel_swi_regs regs; int i, status; @@ -153,8 +149,8 @@ RISCOS_InitEvents(_THIS) } status = (_kernel_osbyte(202, 0, 255) & 0xFF); - SDL_ToggleModState(KMOD_NUM, (status & (1 << 2)) == 0); - SDL_ToggleModState(KMOD_CAPS, (status & (1 << 4)) == 0); + SDL_ToggleModState(KMOD_NUM, (status & (1 << 2)) == 0); + SDL_ToggleModState(KMOD_CAPS, (status & (1 << 4)) == 0); SDL_ToggleModState(KMOD_SCROLL, (status & (1 << 1)) != 0); _kernel_swi(OS_Mouse, ®s, ®s); @@ -166,15 +162,13 @@ RISCOS_InitEvents(_THIS) return 0; } -void -RISCOS_PumpEvents(_THIS) +void RISCOS_PumpEvents(_THIS) { RISCOS_PollMouse(_this); RISCOS_PollKeyboard(_this); } -void -RISCOS_QuitEvents(_THIS) +void RISCOS_QuitEvents(_THIS) { /* Re-enable escape. */ _kernel_osbyte(229, 0, 0); diff --git a/src/video/riscos/SDL_riscosframebuffer.c b/src/video/riscos/SDL_riscosframebuffer.c index 59841992f..667fd90fd 100644 --- a/src/video/riscos/SDL_riscosframebuffer.c +++ b/src/video/riscos/SDL_riscosframebuffer.c @@ -30,9 +30,9 @@ #include #include -int RISCOS_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch) +int RISCOS_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch) { - SDL_WindowData *driverdata = (SDL_WindowData *) window->driverdata; + SDL_WindowData *driverdata = (SDL_WindowData *)window->driverdata; const char *sprite_name = "display"; unsigned int sprite_mode; _kernel_oserror *error; @@ -63,13 +63,13 @@ int RISCOS_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, return SDL_OutOfMemory(); } - driverdata->fb_area->size = size; + driverdata->fb_area->size = size; driverdata->fb_area->count = 0; driverdata->fb_area->start = 16; - driverdata->fb_area->end = 16; + driverdata->fb_area->end = 16; /* Create the actual image */ - regs.r[0] = 256+15; + regs.r[0] = 256 + 15; regs.r[1] = (int)driverdata->fb_area; regs.r[2] = (int)sprite_name; regs.r[3] = 0; @@ -88,13 +88,13 @@ int RISCOS_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, return 0; } -int RISCOS_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects) +int RISCOS_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects) { - SDL_WindowData *driverdata = (SDL_WindowData *) window->driverdata; + SDL_WindowData *driverdata = (SDL_WindowData *)window->driverdata; _kernel_swi_regs regs; _kernel_oserror *error; - regs.r[0] = 512+52; + regs.r[0] = 512 + 52; regs.r[1] = (int)driverdata->fb_area; regs.r[2] = (int)driverdata->fb_sprite; regs.r[3] = 0; /* window->x << 1; */ @@ -110,9 +110,9 @@ int RISCOS_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * return 0; } -void RISCOS_DestroyWindowFramebuffer(_THIS, SDL_Window * window) +void RISCOS_DestroyWindowFramebuffer(_THIS, SDL_Window *window) { - SDL_WindowData *driverdata = (SDL_WindowData *) window->driverdata; + SDL_WindowData *driverdata = (SDL_WindowData *)window->driverdata; if (driverdata->fb_area) { SDL_free(driverdata->fb_area); diff --git a/src/video/riscos/SDL_riscosframebuffer_c.h b/src/video/riscos/SDL_riscosframebuffer_c.h index 100461608..926c7a531 100644 --- a/src/video/riscos/SDL_riscosframebuffer_c.h +++ b/src/video/riscos/SDL_riscosframebuffer_c.h @@ -24,9 +24,9 @@ #include "../../SDL_internal.h" -extern int RISCOS_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch); -extern int RISCOS_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects); -extern void RISCOS_DestroyWindowFramebuffer(_THIS, SDL_Window * window); +extern int RISCOS_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch); +extern int RISCOS_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects); +extern void RISCOS_DestroyWindowFramebuffer(_THIS, SDL_Window *window); #endif /* SDL_riscosframebuffer_c_h_ */ diff --git a/src/video/riscos/SDL_riscosmessagebox.c b/src/video/riscos/SDL_riscosmessagebox.c index de465d5a9..c59c2db17 100644 --- a/src/video/riscos/SDL_riscosmessagebox.c +++ b/src/video/riscos/SDL_riscosmessagebox.c @@ -28,8 +28,7 @@ #include #include -int -RISCOS_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) +int RISCOS_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { _kernel_swi_regs regs; _kernel_oserror error; @@ -46,12 +45,12 @@ RISCOS_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) } else if (messageboxdata->flags == SDL_MESSAGEBOX_WARNING) { regs.r[1] |= (2 << 9); } - + regs.r[2] = (unsigned int)messageboxdata->title; regs.r[3] = 0; regs.r[4] = 0; - SDL_strlcpy(buttonstring, "" , 1024); + SDL_strlcpy(buttonstring, "", 1024); for (i = 0; i < messageboxdata->numbuttons; i++) { SDL_strlcat(buttonstring, messageboxdata->buttons[i].text, 1024); if (i + 1 < messageboxdata->numbuttons) { diff --git a/src/video/riscos/SDL_riscosmodes.c b/src/video/riscos/SDL_riscosmodes.c index 383a4bdf8..e166529b0 100644 --- a/src/video/riscos/SDL_riscosmodes.c +++ b/src/video/riscos/SDL_riscosmodes.c @@ -31,7 +31,8 @@ #include #include -enum { +enum +{ MODE_FLAG_565 = 1 << 7, MODE_FLAG_COLOUR_SPACE = 0xF << 12, @@ -42,7 +43,8 @@ enum { MODE_FLAG_ARGB = MODE_FLAG_TRGB | MODE_FLAG_ABGR }; -static const struct { +static const struct +{ SDL_PixelFormatEnum pixel_format; int modeflags, ncolour, log2bpp; } mode_to_pixelformat[] = { @@ -50,33 +52,32 @@ static const struct { /* { SDL_PIXELFORMAT_INDEX2LSB, 0, 3, 1 }, */ /* { SDL_PIXELFORMAT_INDEX4LSB, 0, 15, 2 }, */ /* { SDL_PIXELFORMAT_INDEX8, MODE_FLAG_565, 255, 3 }, */ - { SDL_PIXELFORMAT_XBGR1555, MODE_FLAG_TBGR, 65535, 4 }, - { SDL_PIXELFORMAT_XRGB1555, MODE_FLAG_TRGB, 65535, 4 }, - { SDL_PIXELFORMAT_ABGR1555, MODE_FLAG_ABGR, 65535, 4 }, - { SDL_PIXELFORMAT_ARGB1555, MODE_FLAG_ARGB, 65535, 4 }, - { SDL_PIXELFORMAT_XBGR4444, MODE_FLAG_TBGR, 4095, 4 }, - { SDL_PIXELFORMAT_XRGB4444, MODE_FLAG_TRGB, 4095, 4 }, - { SDL_PIXELFORMAT_ABGR4444, MODE_FLAG_ABGR, 4095, 4 }, - { SDL_PIXELFORMAT_ARGB4444, MODE_FLAG_ARGB, 4095, 4 }, - { SDL_PIXELFORMAT_BGR565, MODE_FLAG_TBGR | MODE_FLAG_565, 65535, 4 }, - { SDL_PIXELFORMAT_RGB565, MODE_FLAG_TRGB | MODE_FLAG_565, 65535, 4 }, - { SDL_PIXELFORMAT_BGR24, MODE_FLAG_TBGR, 16777215, 6 }, - { SDL_PIXELFORMAT_RGB24, MODE_FLAG_TRGB, 16777215, 6 }, - { SDL_PIXELFORMAT_XBGR8888, MODE_FLAG_TBGR, -1, 5 }, - { SDL_PIXELFORMAT_XRGB8888, MODE_FLAG_TRGB, -1, 5 }, - { SDL_PIXELFORMAT_ABGR8888, MODE_FLAG_ABGR, -1, 5 }, - { SDL_PIXELFORMAT_ARGB8888, MODE_FLAG_ARGB, -1, 5 } + { SDL_PIXELFORMAT_XBGR1555, MODE_FLAG_TBGR, 65535, 4 }, + { SDL_PIXELFORMAT_XRGB1555, MODE_FLAG_TRGB, 65535, 4 }, + { SDL_PIXELFORMAT_ABGR1555, MODE_FLAG_ABGR, 65535, 4 }, + { SDL_PIXELFORMAT_ARGB1555, MODE_FLAG_ARGB, 65535, 4 }, + { SDL_PIXELFORMAT_XBGR4444, MODE_FLAG_TBGR, 4095, 4 }, + { SDL_PIXELFORMAT_XRGB4444, MODE_FLAG_TRGB, 4095, 4 }, + { SDL_PIXELFORMAT_ABGR4444, MODE_FLAG_ABGR, 4095, 4 }, + { SDL_PIXELFORMAT_ARGB4444, MODE_FLAG_ARGB, 4095, 4 }, + { SDL_PIXELFORMAT_BGR565, MODE_FLAG_TBGR | MODE_FLAG_565, 65535, 4 }, + { SDL_PIXELFORMAT_RGB565, MODE_FLAG_TRGB | MODE_FLAG_565, 65535, 4 }, + { SDL_PIXELFORMAT_BGR24, MODE_FLAG_TBGR, 16777215, 6 }, + { SDL_PIXELFORMAT_RGB24, MODE_FLAG_TRGB, 16777215, 6 }, + { SDL_PIXELFORMAT_XBGR8888, MODE_FLAG_TBGR, -1, 5 }, + { SDL_PIXELFORMAT_XRGB8888, MODE_FLAG_TRGB, -1, 5 }, + { SDL_PIXELFORMAT_ABGR8888, MODE_FLAG_ABGR, -1, 5 }, + { SDL_PIXELFORMAT_ARGB8888, MODE_FLAG_ARGB, -1, 5 } }; -static SDL_PixelFormatEnum -RISCOS_ModeToPixelFormat(int ncolour, int modeflags, int log2bpp) +static SDL_PixelFormatEnum RISCOS_ModeToPixelFormat(int ncolour, int modeflags, int log2bpp) { int i; for (i = 0; i < SDL_arraysize(mode_to_pixelformat); i++) { if (log2bpp == mode_to_pixelformat[i].log2bpp && - (ncolour == mode_to_pixelformat[i].ncolour || ncolour == 0) && - (modeflags & (MODE_FLAG_565 | MODE_FLAG_COLOUR_SPACE)) == mode_to_pixelformat[i].modeflags) { + (ncolour == mode_to_pixelformat[i].ncolour || ncolour == 0) && + (modeflags & (MODE_FLAG_565 | MODE_FLAG_COLOUR_SPACE)) == mode_to_pixelformat[i].modeflags) { return mode_to_pixelformat[i].pixel_format; } } @@ -96,8 +97,7 @@ measure_mode_block(const int *block) return blockSize * 4; } -static int -read_mode_variable(int *block, int var) +static int read_mode_variable(int *block, int var) { _kernel_swi_regs regs; regs.r[0] = (int)block; @@ -106,8 +106,7 @@ read_mode_variable(int *block, int var) return regs.r[2]; } -static SDL_bool -read_mode_block(int *block, SDL_DisplayMode *mode, SDL_bool extended) +static SDL_bool read_mode_block(int *block, SDL_DisplayMode *mode, SDL_bool extended) { int xres, yres, ncolour, modeflags, log2bpp, rate; @@ -145,8 +144,7 @@ read_mode_block(int *block, SDL_DisplayMode *mode, SDL_bool extended) return SDL_TRUE; } -static void * -convert_mode_block(const int *block) +static void *convert_mode_block(const int *block) { int xres, yres, log2bpp, rate, ncolour = 0, modeflags = 0; size_t pos = 0; @@ -191,8 +189,7 @@ convert_mode_block(const int *block) return dst; } -static void * -copy_memory(const void *src, size_t size, size_t alloc) +static void *copy_memory(const void *src, size_t size, size_t alloc) { void *dst = SDL_malloc(alloc); if (dst) { @@ -201,8 +198,7 @@ copy_memory(const void *src, size_t size, size_t alloc) return dst; } -int -RISCOS_InitModes(_THIS) +int RISCOS_InitModes(_THIS) { SDL_DisplayMode mode; int *current_mode; @@ -230,8 +226,7 @@ RISCOS_InitModes(_THIS) return SDL_AddBasicVideoDisplay(&mode); } -void -RISCOS_GetDisplayModes(_THIS, SDL_VideoDisplay * display) +void RISCOS_GetDisplayModes(_THIS, SDL_VideoDisplay *display) { SDL_DisplayMode mode; _kernel_swi_regs regs; @@ -286,8 +281,7 @@ RISCOS_GetDisplayModes(_THIS, SDL_VideoDisplay * display) SDL_free(block); } -int -RISCOS_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +int RISCOS_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) { const char disable_cursor[] = { 23, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; _kernel_swi_regs regs; diff --git a/src/video/riscos/SDL_riscosmodes.h b/src/video/riscos/SDL_riscosmodes.h index eb5347286..92205d913 100644 --- a/src/video/riscos/SDL_riscosmodes.h +++ b/src/video/riscos/SDL_riscosmodes.h @@ -24,9 +24,9 @@ #define SDL_riscosmodes_h_ extern int RISCOS_InitModes(_THIS); -extern void RISCOS_GetDisplayModes(_THIS, SDL_VideoDisplay * display); -extern int RISCOS_SetDisplayMode(_THIS, SDL_VideoDisplay * display, - SDL_DisplayMode * mode); +extern void RISCOS_GetDisplayModes(_THIS, SDL_VideoDisplay *display); +extern int RISCOS_SetDisplayMode(_THIS, SDL_VideoDisplay *display, + SDL_DisplayMode *mode); #endif /* SDL_riscosmodes_h_ */ diff --git a/src/video/riscos/SDL_riscosmouse.c b/src/video/riscos/SDL_riscosmouse.c index 072f8a7a1..6ade1ca2c 100644 --- a/src/video/riscos/SDL_riscosmouse.c +++ b/src/video/riscos/SDL_riscosmouse.c @@ -26,9 +26,7 @@ #include - -static SDL_Cursor * -RISCOS_CreateDefaultCursor() +static SDL_Cursor *RISCOS_CreateDefaultCursor() { SDL_Cursor *cursor; @@ -43,14 +41,12 @@ RISCOS_CreateDefaultCursor() return cursor; } -static void -RISCOS_FreeCursor(SDL_Cursor * cursor) +static void RISCOS_FreeCursor(SDL_Cursor *cursor) { SDL_free(cursor); } -static int -RISCOS_ShowCursor(SDL_Cursor * cursor) +static int RISCOS_ShowCursor(SDL_Cursor *cursor) { if (cursor) { /* Turn the mouse pointer on */ @@ -63,8 +59,7 @@ RISCOS_ShowCursor(SDL_Cursor * cursor) return 0; } -int -RISCOS_InitMouse(_THIS) +int RISCOS_InitMouse(_THIS) { SDL_Mouse *mouse = SDL_GetMouse(); diff --git a/src/video/riscos/SDL_riscosvideo.c b/src/video/riscos/SDL_riscosvideo.c index 7ae30e478..89989f530 100644 --- a/src/video/riscos/SDL_riscosvideo.c +++ b/src/video/riscos/SDL_riscosvideo.c @@ -43,28 +43,26 @@ static void RISCOS_VideoQuit(_THIS); /* RISC OS driver bootstrap functions */ -static void -RISCOS_DeleteDevice(SDL_VideoDevice * device) +static void RISCOS_DeleteDevice(SDL_VideoDevice *device) { SDL_free(device->driverdata); SDL_free(device); } -static SDL_VideoDevice * -RISCOS_CreateDevice(void) +static SDL_VideoDevice *RISCOS_CreateDevice(void) { SDL_VideoDevice *device; SDL_VideoData *phdata; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device == NULL) { SDL_OutOfMemory(); return 0; } /* Initialize internal data */ - phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); + phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); if (phdata == NULL) { SDL_OutOfMemory(); SDL_free(device); @@ -99,8 +97,7 @@ VideoBootStrap RISCOS_bootstrap = { RISCOS_CreateDevice }; -static int -RISCOS_VideoInit(_THIS) +static int RISCOS_VideoInit(_THIS) { if (RISCOS_InitEvents(_this) < 0) { return -1; @@ -118,8 +115,7 @@ RISCOS_VideoInit(_THIS) return 0; } -static void -RISCOS_VideoQuit(_THIS) +static void RISCOS_VideoQuit(_THIS) { RISCOS_QuitEvents(_this); } diff --git a/src/video/riscos/SDL_riscoswindow.c b/src/video/riscos/SDL_riscoswindow.c index 290c72feb..7ff3e62ea 100644 --- a/src/video/riscos/SDL_riscoswindow.c +++ b/src/video/riscos/SDL_riscoswindow.c @@ -31,12 +31,11 @@ #include "SDL_riscosvideo.h" #include "SDL_riscoswindow.h" -int -RISCOS_CreateWindow(_THIS, SDL_Window * window) +int RISCOS_CreateWindow(_THIS, SDL_Window *window) { SDL_WindowData *driverdata; - driverdata = (SDL_WindowData *) SDL_calloc(1, sizeof(*driverdata)); + driverdata = (SDL_WindowData *)SDL_calloc(1, sizeof(*driverdata)); if (driverdata == NULL) { return SDL_OutOfMemory(); } @@ -51,10 +50,9 @@ RISCOS_CreateWindow(_THIS, SDL_Window * window) return 0; } -void -RISCOS_DestroyWindow(_THIS, SDL_Window * window) +void RISCOS_DestroyWindow(_THIS, SDL_Window *window) { - SDL_WindowData *driverdata = (SDL_WindowData *) window->driverdata; + SDL_WindowData *driverdata = (SDL_WindowData *)window->driverdata; if (driverdata == NULL) { return; diff --git a/src/video/uikit/SDL_uikitappdelegate.h b/src/video/uikit/SDL_uikitappdelegate.h index ee2b5b6a8..f734ce247 100644 --- a/src/video/uikit/SDL_uikitappdelegate.h +++ b/src/video/uikit/SDL_uikitappdelegate.h @@ -29,7 +29,7 @@ @end -@interface SDLUIKitDelegate : NSObject +@interface SDLUIKitDelegate : NSObject + (id)sharedAppDelegate; + (NSString *)getAppDelegateClassName; @@ -40,7 +40,7 @@ * the app's UI is storyboard-based. SDL is not storyboard-based, however * several major third-party ad APIs (e.g. Google admob) incorrectly assume this * property always exists, and will crash if it doesn't. */ -@property (nonatomic) UIWindow *window; +@property(nonatomic) UIWindow *window; @end diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m index 3186cc6e8..be0d6f745 100644 --- a/src/video/uikit/SDL_uikitappdelegate.m +++ b/src/video/uikit/SDL_uikitappdelegate.m @@ -36,9 +36,9 @@ #if !TARGET_OS_TV #include -# ifndef __IPHONE_13_0 -# define __IPHONE_13_0 130000 -# endif +#ifndef __IPHONE_13_0 +#define __IPHONE_13_0 130000 +#endif #endif #ifdef main @@ -57,9 +57,9 @@ int SDL_UIKitRunApp(int argc, char *argv[], SDL_main_func mainFunction) /* store arguments */ forward_main = mainFunction; forward_argc = argc; - forward_argv = (char **)malloc((argc+1) * sizeof(char *)); + forward_argv = (char **)malloc((argc + 1) * sizeof(char *)); for (i = 0; i < argc; i++) { - forward_argv[i] = malloc( (strlen(argv[i])+1) * sizeof(char)); + forward_argv[i] = malloc((strlen(argv[i]) + 1) * sizeof(char)); strcpy(forward_argv[i], argv[i]); } forward_argv[i] = NULL; @@ -87,8 +87,7 @@ SDL_IdleTimerDisabledChanged(void *userdata, const char *name, const char *oldVa #if !TARGET_OS_TV /* Load a launch image using the old UILaunchImageFile-era naming rules. */ -static UIImage * -SDL_LoadLaunchImageNamed(NSString *name, int screenh) +static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) { UIInterfaceOrientation curorient = [UIApplication sharedApplication].statusBarOrientation; UIUserInterfaceIdiom idiom = [UIDevice currentDevice].userInterfaceIdiom; @@ -126,19 +125,21 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh) } @interface SDLLaunchStoryboardViewController : UIViewController -@property (nonatomic, strong) UIViewController *storyboardViewController; +@property(nonatomic, strong) UIViewController *storyboardViewController; - (instancetype)initWithStoryboardViewController:(UIViewController *)storyboardViewController; @end @implementation SDLLaunchStoryboardViewController -- (instancetype)initWithStoryboardViewController:(UIViewController *)storyboardViewController { +- (instancetype)initWithStoryboardViewController:(UIViewController *)storyboardViewController +{ self = [super init]; self.storyboardViewController = storyboardViewController; return self; } -- (void)viewDidLoad { +- (void)viewDidLoad +{ [super viewDidLoad]; [self addChildViewController:self.storyboardViewController]; @@ -151,11 +152,13 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh) UIApplication.sharedApplication.statusBarStyle = self.preferredStatusBarStyle; } -- (BOOL)prefersStatusBarHidden { +- (BOOL)prefersStatusBarHidden +{ return [[NSBundle.mainBundle objectForInfoDictionaryKey:@"UIStatusBarHidden"] boolValue]; } -- (UIStatusBarStyle)preferredStatusBarStyle { +- (UIStatusBarStyle)preferredStatusBarStyle +{ NSString *statusBarStyle = [NSBundle.mainBundle objectForInfoDictionaryKey:@"UIStatusBarStyle"]; if ([statusBarStyle isEqualToString:@"UIStatusBarStyleLightContent"]) { return UIStatusBarStyleLightContent; @@ -344,7 +347,8 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh) @end -@implementation SDLUIKitDelegate { +@implementation SDLUIKitDelegate +{ UIWindow *launchWindow; } @@ -375,12 +379,14 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh) launchWindow = nil; /* Do a nice animated fade-out (roughly matches the real launch behavior.) */ - [UIView animateWithDuration:0.2 animations:^{ - window.alpha = 0.0; - } completion:^(BOOL finished) { - window.hidden = YES; - UIKit_ForceUpdateHomeIndicator(); /* Wait for launch screen to hide so settings are applied to the actual view controller. */ - }]; + [UIView animateWithDuration:0.2 + animations:^{ + window.alpha = 0.0; + } + completion:^(BOOL finished) { + window.hidden = YES; + UIKit_ForceUpdateHomeIndicator(); /* Wait for launch screen to hide so settings are applied to the actual view controller. */ + }]; } - (void)postFinishLaunch @@ -476,7 +482,7 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh) if (_this) { SDL_Window *window = NULL; for (window = _this->windows; window != NULL; window = window->next) { - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; if (data != nil) { return data.uiwindow; } @@ -503,7 +509,7 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh) #if TARGET_OS_TV || (defined(__IPHONE_9_0) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0) -- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options +- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options { /* TODO: Handle options */ [self sendDropFileForURL:url]; diff --git a/src/video/uikit/SDL_uikitclipboard.m b/src/video/uikit/SDL_uikitclipboard.m index dde939dfb..1ecce72b0 100644 --- a/src/video/uikit/SDL_uikitclipboard.m +++ b/src/video/uikit/SDL_uikitclipboard.m @@ -27,8 +27,7 @@ #import -int -UIKit_SetClipboardText(_THIS, const char *text) +int UIKit_SetClipboardText(_THIS, const char *text) { #if TARGET_OS_TV return SDL_SetError("The clipboard is not available on tvOS"); @@ -72,31 +71,29 @@ UIKit_HasClipboardText(_THIS) } } -void -UIKit_InitClipboard(_THIS) +void UIKit_InitClipboard(_THIS) { #if !TARGET_OS_TV @autoreleasepool { - SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata; NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; id observer = [center addObserverForName:UIPasteboardChangedNotification - object:nil - queue:nil - usingBlock:^(NSNotification *note) { - SDL_SendClipboardUpdate(); - }]; + object:nil + queue:nil + usingBlock:^(NSNotification *note) { + SDL_SendClipboardUpdate(); + }]; data.pasteboardObserver = observer; } #endif } -void -UIKit_QuitClipboard(_THIS) +void UIKit_QuitClipboard(_THIS) { @autoreleasepool { - SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata; if (data.pasteboardObserver != nil) { [[NSNotificationCenter defaultCenter] removeObserver:data.pasteboardObserver]; diff --git a/src/video/uikit/SDL_uikitevents.m b/src/video/uikit/SDL_uikitevents.m index e1bc5a29e..95943ccc8 100644 --- a/src/video/uikit/SDL_uikitevents.m +++ b/src/video/uikit/SDL_uikitevents.m @@ -41,9 +41,8 @@ static BOOL UIKit_EventPumpEnabled = YES; - @interface SDL_LifecycleObserver : NSObject -@property (nonatomic, assign) BOOL isObservingNotifications; +@property(nonatomic, assign) BOOL isObservingNotifications; @end @implementation SDL_LifecycleObserver @@ -60,7 +59,10 @@ static BOOL UIKit_EventPumpEnabled = YES; [notificationCenter addObserver:self selector:@selector(applicationWillTerminate) name:UIApplicationWillTerminateNotification object:nil]; [notificationCenter addObserver:self selector:@selector(applicationDidReceiveMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; #if !TARGET_OS_TV - [notificationCenter addObserver:self selector:@selector(applicationDidChangeStatusBarOrientation) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; + [notificationCenter addObserver:self + selector:@selector(applicationDidChangeStatusBarOrientation) + name:UIApplicationDidChangeStatusBarOrientationNotification + object:nil]; #endif } else if (!UIKit_EventPumpEnabled && self.isObservingNotifications) { self.isObservingNotifications = NO; @@ -107,22 +109,19 @@ static BOOL UIKit_EventPumpEnabled = YES; @end - -void -SDL_iPhoneSetEventPump(SDL_bool enabled) +void SDL_iPhoneSetEventPump(SDL_bool enabled) { UIKit_EventPumpEnabled = enabled; static SDL_LifecycleObserver *lifecycleObserver; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - lifecycleObserver = [SDL_LifecycleObserver new]; + lifecycleObserver = [SDL_LifecycleObserver new]; }); [lifecycleObserver eventPumpChanged]; } -void -UIKit_PumpEvents(_THIS) +void UIKit_PumpEvents(_THIS) { if (!UIKit_EventPumpEnabled) { return; @@ -145,7 +144,7 @@ UIKit_PumpEvents(_THIS) /* Make sure UIScrollView objects scroll properly. */ do { result = CFRunLoopRunInMode((CFStringRef)UITrackingRunLoopMode, seconds, TRUE); - } while(result == kCFRunLoopRunHandledSource); + } while (result == kCFRunLoopRunHandledSource); /* See the comment in the function definition. */ #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 @@ -162,13 +161,12 @@ static id keyboard_disconnect_observer = nil; static void OnGCKeyboardConnected(GCKeyboard *keyboard) API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) { keyboard_connected = SDL_TRUE; - keyboard.keyboardInput.keyChangedHandler = ^(GCKeyboardInput *kbrd, GCControllerButtonInput *key, GCKeyCode keyCode, BOOL pressed) - { - SDL_SendKeyboardKey(pressed ? SDL_PRESSED : SDL_RELEASED, (SDL_Scancode)keyCode); + keyboard.keyboardInput.keyChangedHandler = ^(GCKeyboardInput *kbrd, GCControllerButtonInput *key, GCKeyCode keyCode, BOOL pressed) { + SDL_SendKeyboardKey(pressed ? SDL_PRESSED : SDL_RELEASED, (SDL_Scancode)keyCode); }; - dispatch_queue_t queue = dispatch_queue_create( "org.libsdl.input.keyboard", DISPATCH_QUEUE_SERIAL ); - dispatch_set_target_queue( queue, dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_HIGH, 0 ) ); + dispatch_queue_t queue = dispatch_queue_create("org.libsdl.input.keyboard", DISPATCH_QUEUE_SERIAL); + dispatch_set_target_queue(queue, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)); keyboard.handlerQueue = queue; } @@ -188,16 +186,16 @@ void SDL_InitGCKeyboard(void) object:nil queue:nil usingBlock:^(NSNotification *note) { - GCKeyboard *keyboard = note.object; - OnGCKeyboardConnected(keyboard); + GCKeyboard *keyboard = note.object; + OnGCKeyboardConnected(keyboard); }]; keyboard_disconnect_observer = [center addObserverForName:GCKeyboardDidDisconnectNotification object:nil queue:nil usingBlock:^(NSNotification *note) { - GCKeyboard *keyboard = note.object; - OnGCKeyboardDisconnected(keyboard); + GCKeyboard *keyboard = note.object; + OnGCKeyboardDisconnected(keyboard); }]; if (GCKeyboard.coalescedKeyboard != nil) { @@ -252,7 +250,6 @@ void SDL_QuitGCKeyboard(void) #endif /* ENABLE_GCKEYBOARD */ - #ifdef ENABLE_GCMOUSE static int mice_connected = 0; @@ -286,42 +283,36 @@ static void OnGCMouseConnected(GCMouse *mouse) API_AVAILABLE(macos(11.0), ios(14 { SDL_MouseID mouseID = mice_connected; - mouse.mouseInput.leftButton.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) - { - OnGCMouseButtonChanged(mouseID, SDL_BUTTON_LEFT, pressed); + mouse.mouseInput.leftButton.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) { + OnGCMouseButtonChanged(mouseID, SDL_BUTTON_LEFT, pressed); }; - mouse.mouseInput.middleButton.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) - { - OnGCMouseButtonChanged(mouseID, SDL_BUTTON_MIDDLE, pressed); + mouse.mouseInput.middleButton.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) { + OnGCMouseButtonChanged(mouseID, SDL_BUTTON_MIDDLE, pressed); }; - mouse.mouseInput.rightButton.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) - { - OnGCMouseButtonChanged(mouseID, SDL_BUTTON_RIGHT, pressed); + mouse.mouseInput.rightButton.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) { + OnGCMouseButtonChanged(mouseID, SDL_BUTTON_RIGHT, pressed); }; int auxiliary_button = SDL_BUTTON_X1; for (GCControllerButtonInput *btn in mouse.mouseInput.auxiliaryButtons) { - btn.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) - { - OnGCMouseButtonChanged(mouseID, auxiliary_button, pressed); + btn.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) { + OnGCMouseButtonChanged(mouseID, auxiliary_button, pressed); }; ++auxiliary_button; } - mouse.mouseInput.mouseMovedHandler = ^(GCMouseInput *mouseInput, float deltaX, float deltaY) - { - if (SDL_GCMouseRelativeMode()) { - SDL_SendMouseMotion(SDL_GetMouseFocus(), mouseID, 1, (int)deltaX, -(int)deltaY); - } + mouse.mouseInput.mouseMovedHandler = ^(GCMouseInput *mouseInput, float deltaX, float deltaY) { + if (SDL_GCMouseRelativeMode()) { + SDL_SendMouseMotion(SDL_GetMouseFocus(), mouseID, 1, (int)deltaX, -(int)deltaY); + } }; - mouse.mouseInput.scroll.valueChangedHandler = ^(GCControllerDirectionPad *dpad, float xValue, float yValue) - { - SDL_SendMouseWheel(SDL_GetMouseFocus(), 0, xValue, yValue, SDL_MOUSEWHEEL_NORMAL); + mouse.mouseInput.scroll.valueChangedHandler = ^(GCControllerDirectionPad *dpad, float xValue, float yValue) { + SDL_SendMouseWheel(SDL_GetMouseFocus(), 0, xValue, yValue, SDL_MOUSEWHEEL_NORMAL); }; - dispatch_queue_t queue = dispatch_queue_create( "org.libsdl.input.mouse", DISPATCH_QUEUE_SERIAL ); - dispatch_set_target_queue( queue, dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_HIGH, 0 ) ); + dispatch_queue_t queue = dispatch_queue_create("org.libsdl.input.mouse", DISPATCH_QUEUE_SERIAL); + dispatch_set_target_queue(queue, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)); mouse.handlerQueue = queue; ++mice_connected; @@ -362,17 +353,17 @@ void SDL_InitGCMouse(void) object:nil queue:nil usingBlock:^(NSNotification *note) { - GCMouse *mouse = note.object; - OnGCMouseConnected(mouse); + GCMouse *mouse = note.object; + OnGCMouseConnected(mouse); }]; mouse_disconnect_observer = [center addObserverForName:GCMouseDidDisconnectNotification object:nil queue:nil usingBlock:^(NSNotification *note) { - GCMouse *mouse = note.object; - OnGCMouseDisconnected(mouse); - }]; + GCMouse *mouse = note.object; + OnGCMouseDisconnected(mouse); + }]; for (GCMouse *mouse in [GCMouse mice]) { OnGCMouseConnected(mouse); diff --git a/src/video/uikit/SDL_uikitmessagebox.m b/src/video/uikit/SDL_uikitmessagebox.m index 2c42ba746..354a66b8d 100644 --- a/src/video/uikit/SDL_uikitmessagebox.m +++ b/src/video/uikit/SDL_uikitmessagebox.m @@ -36,8 +36,7 @@ UIKit_ShowingMessageBox(void) return s_showingMessageBox; } -static void -UIKit_WaitUntilMessageBoxClosed(const SDL_MessageBoxData *messageboxdata, int *clickedindex) +static void UIKit_WaitUntilMessageBoxClosed(const SDL_MessageBoxData *messageboxdata, int *clickedindex) { *clickedindex = messageboxdata->numbuttons; @@ -52,8 +51,7 @@ UIKit_WaitUntilMessageBoxClosed(const SDL_MessageBoxData *messageboxdata, int *c } } -static BOOL -UIKit_ShowMessageBoxAlertController(const SDL_MessageBoxData *messageboxdata, int *buttonid) +static BOOL UIKit_ShowMessageBoxAlertController(const SDL_MessageBoxData *messageboxdata, int *buttonid) { int i; int __block clickedindex = messageboxdata->numbuttons; @@ -85,10 +83,10 @@ UIKit_ShowMessageBoxAlertController(const SDL_MessageBoxData *messageboxdata, in } action = [UIAlertAction actionWithTitle:@(sdlButton->text) - style:style - handler:^(UIAlertAction *alertAction) { - clickedindex = (int)(sdlButton - messageboxdata->buttons); - }]; + style:style + handler:^(UIAlertAction *alertAction) { + clickedindex = (int)(sdlButton - messageboxdata->buttons); + }]; [alert addAction:action]; if (sdlButton->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) { @@ -97,7 +95,7 @@ UIKit_ShowMessageBoxAlertController(const SDL_MessageBoxData *messageboxdata, in } if (messageboxdata->window) { - SDL_WindowData *data = (__bridge SDL_WindowData *) messageboxdata->window->driverdata; + SDL_WindowData *data = (__bridge SDL_WindowData *)messageboxdata->window->driverdata; window = data.uiwindow; } @@ -124,30 +122,32 @@ UIKit_ShowMessageBoxAlertController(const SDL_MessageBoxData *messageboxdata, in return YES; } -static void -UIKit_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid, int *returnValue) -{ @autoreleasepool +static void UIKit_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid, int *returnValue) { - if (UIKit_ShowMessageBoxAlertController(messageboxdata, buttonid)) { - *returnValue = 0; - } else { - *returnValue = SDL_SetError("Could not show message box."); + @autoreleasepool { + if (UIKit_ShowMessageBoxAlertController(messageboxdata, buttonid)) { + *returnValue = 0; + } else { + *returnValue = SDL_SetError("Could not show message box."); + } } -}} +} -int -UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) -{ @autoreleasepool +int UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { - __block int returnValue = 0; + @autoreleasepool { + __block int returnValue = 0; - if ([NSThread isMainThread]) { - UIKit_ShowMessageBoxImpl(messageboxdata, buttonid, &returnValue); - } else { - dispatch_sync(dispatch_get_main_queue(), ^{ UIKit_ShowMessageBoxImpl(messageboxdata, buttonid, &returnValue); }); + if ([NSThread isMainThread]) { + UIKit_ShowMessageBoxImpl(messageboxdata, buttonid, &returnValue); + } else { + dispatch_sync(dispatch_get_main_queue(), ^{ + UIKit_ShowMessageBoxImpl(messageboxdata, buttonid, &returnValue); + }); + } + return returnValue; } - return returnValue; -}} +} #endif /* SDL_VIDEO_DRIVER_UIKIT */ diff --git a/src/video/uikit/SDL_uikitmetalview.h b/src/video/uikit/SDL_uikitmetalview.h index a4d7026d8..fc0cc70b5 100644 --- a/src/video/uikit/SDL_uikitmetalview.h +++ b/src/video/uikit/SDL_uikitmetalview.h @@ -1,15 +1,15 @@ /* Simple DirectMedia Layer Copyright (C) 1997-2022 Sam Lantinga - + This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. - + Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - + 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be @@ -38,7 +38,6 @@ #import #import - @interface SDL_uikitmetalview : SDL_uikitview - (instancetype)initWithFrame:(CGRect)frame @@ -46,10 +45,10 @@ @end -SDL_MetalView UIKit_Metal_CreateView(_THIS, SDL_Window * window); +SDL_MetalView UIKit_Metal_CreateView(_THIS, SDL_Window *window); void UIKit_Metal_DestroyView(_THIS, SDL_MetalView view); void *UIKit_Metal_GetLayer(_THIS, SDL_MetalView view); -void UIKit_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h); +void UIKit_Metal_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h); #endif /* SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) */ diff --git a/src/video/uikit/SDL_uikitmetalview.m b/src/video/uikit/SDL_uikitmetalview.m index e2e7015e7..e2599f08b 100644 --- a/src/video/uikit/SDL_uikitmetalview.m +++ b/src/video/uikit/SDL_uikitmetalview.m @@ -1,15 +1,15 @@ /* Simple DirectMedia Layer Copyright (C) 1997-2022 Sam Lantinga - + This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. - + Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - + 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be @@ -75,59 +75,63 @@ @end SDL_MetalView -UIKit_Metal_CreateView(_THIS, SDL_Window * window) -{ @autoreleasepool { - SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; - CGFloat scale = 1.0; - SDL_uikitmetalview *metalview; - - if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) { - /* Set the scale to the natural scale factor of the screen - then - * the backing dimensions of the Metal view will match the pixel - * dimensions of the screen rather than the dimensions in points - * yielding high resolution on retine displays. - */ - scale = data.uiwindow.screen.nativeScale; - } - - metalview = [[SDL_uikitmetalview alloc] initWithFrame:data.uiwindow.bounds - scale:scale]; - if (metalview == nil) { - SDL_OutOfMemory(); - return NULL; - } - - [metalview setSDLWindow:window]; - - return (void*)CFBridgingRetain(metalview); -}} - -void -UIKit_Metal_DestroyView(_THIS, SDL_MetalView view) -{ @autoreleasepool { - SDL_uikitmetalview *metalview = CFBridgingRelease(view); - - if ([metalview isKindOfClass:[SDL_uikitmetalview class]]) { - [metalview setSDLWindow:NULL]; - } -}} - -void * -UIKit_Metal_GetLayer(_THIS, SDL_MetalView view) -{ @autoreleasepool { - SDL_uikitview *uiview = (__bridge SDL_uikitview *)view; - return (__bridge void *)uiview.layer; -}} - -void -UIKit_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h) +UIKit_Metal_CreateView(_THIS, SDL_Window *window) { @autoreleasepool { SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; - SDL_uikitview *view = (SDL_uikitview*)data.uiwindow.rootViewController.view; - SDL_uikitmetalview* metalview = [view viewWithTag:SDL_METALVIEW_TAG]; + CGFloat scale = 1.0; + SDL_uikitmetalview *metalview; + + if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) { + /* Set the scale to the natural scale factor of the screen - then + * the backing dimensions of the Metal view will match the pixel + * dimensions of the screen rather than the dimensions in points + * yielding high resolution on retine displays. + */ + scale = data.uiwindow.screen.nativeScale; + } + + metalview = [[SDL_uikitmetalview alloc] initWithFrame:data.uiwindow.bounds + scale:scale]; + if (metalview == nil) { + SDL_OutOfMemory(); + return NULL; + } + + [metalview setSDLWindow:window]; + + return (void *)CFBridgingRetain(metalview); + } +} + +void UIKit_Metal_DestroyView(_THIS, SDL_MetalView view) +{ + @autoreleasepool { + SDL_uikitmetalview *metalview = CFBridgingRelease(view); + + if ([metalview isKindOfClass:[SDL_uikitmetalview class]]) { + [metalview setSDLWindow:NULL]; + } + } +} + +void * +UIKit_Metal_GetLayer(_THIS, SDL_MetalView view) +{ + @autoreleasepool { + SDL_uikitview *uiview = (__bridge SDL_uikitview *)view; + return (__bridge void *)uiview.layer; + } +} + +void UIKit_Metal_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h) +{ + @autoreleasepool { + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; + SDL_uikitview *view = (SDL_uikitview *)data.uiwindow.rootViewController.view; + SDL_uikitmetalview *metalview = [view viewWithTag:SDL_METALVIEW_TAG]; if (metalview) { - CAMetalLayer *layer = (CAMetalLayer*)metalview.layer; + CAMetalLayer *layer = (CAMetalLayer *)metalview.layer; assert(layer != NULL); if (w) { *w = layer.drawableSize.width; diff --git a/src/video/uikit/SDL_uikitmodes.h b/src/video/uikit/SDL_uikitmodes.h index d4f3b20ef..83830ff99 100644 --- a/src/video/uikit/SDL_uikitmodes.h +++ b/src/video/uikit/SDL_uikitmodes.h @@ -27,16 +27,16 @@ @interface SDL_DisplayData : NSObject -- (instancetype)initWithScreen:(UIScreen*)screen; +- (instancetype)initWithScreen:(UIScreen *)screen; -@property (nonatomic, strong) UIScreen *uiscreen; -@property (nonatomic) float screenDPI; +@property(nonatomic, strong) UIScreen *uiscreen; +@property(nonatomic) float screenDPI; @end @interface SDL_DisplayModeData : NSObject -@property (nonatomic, strong) UIScreenMode *uiscreenmode; +@property(nonatomic, strong) UIScreenMode *uiscreenmode; @end @@ -45,11 +45,11 @@ extern SDL_bool UIKit_IsDisplayLandscape(UIScreen *uiscreen); extern int UIKit_InitModes(_THIS); extern int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event); extern void UIKit_DelDisplay(UIScreen *uiscreen); -extern void UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay * display); -extern int UIKit_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi); -extern int UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); +extern void UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay *display); +extern int UIKit_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi); +extern int UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode); extern void UIKit_QuitModes(_THIS); -extern int UIKit_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect); +extern int UIKit_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect); #endif /* SDL_uikitmodes_h_ */ diff --git a/src/video/uikit/SDL_uikitmodes.m b/src/video/uikit/SDL_uikitmodes.m index 322240d18..65f91d4f8 100644 --- a/src/video/uikit/SDL_uikitmodes.m +++ b/src/video/uikit/SDL_uikitmodes.m @@ -31,7 +31,7 @@ @implementation SDL_DisplayData -- (instancetype)initWithScreen:(UIScreen*)screen +- (instancetype)initWithScreen:(UIScreen *)screen { if (self = [super init]) { self.uiscreen = screen; @@ -40,108 +40,109 @@ * A well up to date list of device info can be found here: * https://github.com/lmirosevic/GBDeviceInfo/blob/master/GBDeviceInfo/GBDeviceInfo_iOS.m */ - NSDictionary* devices = @{ - @"iPhone1,1": @163, - @"iPhone1,2": @163, - @"iPhone2,1": @163, - @"iPhone3,1": @326, - @"iPhone3,2": @326, - @"iPhone3,3": @326, - @"iPhone4,1": @326, - @"iPhone5,1": @326, - @"iPhone5,2": @326, - @"iPhone5,3": @326, - @"iPhone5,4": @326, - @"iPhone6,1": @326, - @"iPhone6,2": @326, - @"iPhone7,1": @401, - @"iPhone7,2": @326, - @"iPhone8,1": @326, - @"iPhone8,2": @401, - @"iPhone8,4": @326, - @"iPhone9,1": @326, - @"iPhone9,2": @401, - @"iPhone9,3": @326, - @"iPhone9,4": @401, - @"iPhone10,1": @326, - @"iPhone10,2": @401, - @"iPhone10,3": @458, - @"iPhone10,4": @326, - @"iPhone10,5": @401, - @"iPhone10,6": @458, - @"iPhone11,2": @458, - @"iPhone11,4": @458, - @"iPhone11,6": @458, - @"iPhone11,8": @326, - @"iPhone12,1": @326, - @"iPhone12,3": @458, - @"iPhone12,5": @458, - @"iPad1,1": @132, - @"iPad2,1": @132, - @"iPad2,2": @132, - @"iPad2,3": @132, - @"iPad2,4": @132, - @"iPad2,5": @163, - @"iPad2,6": @163, - @"iPad2,7": @163, - @"iPad3,1": @264, - @"iPad3,2": @264, - @"iPad3,3": @264, - @"iPad3,4": @264, - @"iPad3,5": @264, - @"iPad3,6": @264, - @"iPad4,1": @264, - @"iPad4,2": @264, - @"iPad4,3": @264, - @"iPad4,4": @326, - @"iPad4,5": @326, - @"iPad4,6": @326, - @"iPad4,7": @326, - @"iPad4,8": @326, - @"iPad4,9": @326, - @"iPad5,1": @326, - @"iPad5,2": @326, - @"iPad5,3": @264, - @"iPad5,4": @264, - @"iPad6,3": @264, - @"iPad6,4": @264, - @"iPad6,7": @264, - @"iPad6,8": @264, - @"iPad6,11": @264, - @"iPad6,12": @264, - @"iPad7,1": @264, - @"iPad7,2": @264, - @"iPad7,3": @264, - @"iPad7,4": @264, - @"iPad7,5": @264, - @"iPad7,6": @264, - @"iPad7,11": @264, - @"iPad7,12": @264, - @"iPad8,1": @264, - @"iPad8,2": @264, - @"iPad8,3": @264, - @"iPad8,4": @264, - @"iPad8,5": @264, - @"iPad8,6": @264, - @"iPad8,7": @264, - @"iPad8,8": @264, - @"iPad11,1": @326, - @"iPad11,2": @326, - @"iPad11,3": @326, - @"iPad11,4": @326, - @"iPod1,1": @163, - @"iPod2,1": @163, - @"iPod3,1": @163, - @"iPod4,1": @326, - @"iPod5,1": @326, - @"iPod7,1": @326, - @"iPod9,1": @326, + NSDictionary *devices = @{ + @"iPhone1,1" : @163, + @"iPhone1,2" : @163, + @"iPhone2,1" : @163, + @"iPhone3,1" : @326, + @"iPhone3,2" : @326, + @"iPhone3,3" : @326, + @"iPhone4,1" : @326, + @"iPhone5,1" : @326, + @"iPhone5,2" : @326, + @"iPhone5,3" : @326, + @"iPhone5,4" : @326, + @"iPhone6,1" : @326, + @"iPhone6,2" : @326, + @"iPhone7,1" : @401, + @"iPhone7,2" : @326, + @"iPhone8,1" : @326, + @"iPhone8,2" : @401, + @"iPhone8,4" : @326, + @"iPhone9,1" : @326, + @"iPhone9,2" : @401, + @"iPhone9,3" : @326, + @"iPhone9,4" : @401, + @"iPhone10,1" : @326, + @"iPhone10,2" : @401, + @"iPhone10,3" : @458, + @"iPhone10,4" : @326, + @"iPhone10,5" : @401, + @"iPhone10,6" : @458, + @"iPhone11,2" : @458, + @"iPhone11,4" : @458, + @"iPhone11,6" : @458, + @"iPhone11,8" : @326, + @"iPhone12,1" : @326, + @"iPhone12,3" : @458, + @"iPhone12,5" : @458, + @"iPad1,1" : @132, + @"iPad2,1" : @132, + @"iPad2,2" : @132, + @"iPad2,3" : @132, + @"iPad2,4" : @132, + @"iPad2,5" : @163, + @"iPad2,6" : @163, + @"iPad2,7" : @163, + @"iPad3,1" : @264, + @"iPad3,2" : @264, + @"iPad3,3" : @264, + @"iPad3,4" : @264, + @"iPad3,5" : @264, + @"iPad3,6" : @264, + @"iPad4,1" : @264, + @"iPad4,2" : @264, + @"iPad4,3" : @264, + @"iPad4,4" : @326, + @"iPad4,5" : @326, + @"iPad4,6" : @326, + @"iPad4,7" : @326, + @"iPad4,8" : @326, + @"iPad4,9" : @326, + @"iPad5,1" : @326, + @"iPad5,2" : @326, + @"iPad5,3" : @264, + @"iPad5,4" : @264, + @"iPad6,3" : @264, + @"iPad6,4" : @264, + @"iPad6,7" : @264, + @"iPad6,8" : @264, + @"iPad6,11" : @264, + @"iPad6,12" : @264, + @"iPad7,1" : @264, + @"iPad7,2" : @264, + @"iPad7,3" : @264, + @"iPad7,4" : @264, + @"iPad7,5" : @264, + @"iPad7,6" : @264, + @"iPad7,11" : @264, + @"iPad7,12" : @264, + @"iPad8,1" : @264, + @"iPad8,2" : @264, + @"iPad8,3" : @264, + @"iPad8,4" : @264, + @"iPad8,5" : @264, + @"iPad8,6" : @264, + @"iPad8,7" : @264, + @"iPad8,8" : @264, + @"iPad11,1" : @326, + @"iPad11,2" : @326, + @"iPad11,3" : @326, + @"iPad11,4" : @326, + @"iPod1,1" : @163, + @"iPod2,1" : @163, + @"iPod3,1" : @163, + @"iPod4,1" : @326, + @"iPod5,1" : @326, + @"iPod7,1" : @326, + @"iPod9,1" : @326, }; struct utsname systemInfo; uname(&systemInfo); - NSString* deviceName = - [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; + NSString *deviceName = + [NSString stringWithCString:systemInfo.machine + encoding:NSUTF8StringEncoding]; id foundDPI = devices[deviceName]; if (foundDPI) { self.screenDPI = (float)[foundDPI integerValue]; @@ -185,10 +186,14 @@ { NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; - [center addObserver:self selector:@selector(screenConnected:) - name:UIScreenDidConnectNotification object:nil]; - [center addObserver:self selector:@selector(screenDisconnected:) - name:UIScreenDidDisconnectNotification object:nil]; + [center addObserver:self + selector:@selector(screenConnected:) + name:UIScreenDidConnectNotification + object:nil]; + [center addObserver:self + selector:@selector(screenDisconnected:) + name:UIScreenDidDisconnectNotification + object:nil]; } + (void)stop @@ -196,18 +201,20 @@ NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; [center removeObserver:self - name:UIScreenDidConnectNotification object:nil]; + name:UIScreenDidConnectNotification + object:nil]; [center removeObserver:self - name:UIScreenDidDisconnectNotification object:nil]; + name:UIScreenDidDisconnectNotification + object:nil]; } -+ (void)screenConnected:(NSNotification*)notification ++ (void)screenConnected:(NSNotification *)notification { UIScreen *uiscreen = [notification object]; UIKit_AddDisplay(uiscreen, SDL_TRUE); } -+ (void)screenDisconnected:(NSNotification*)notification ++ (void)screenDisconnected:(NSNotification *)notification { UIScreen *uiscreen = [notification object]; UIKit_DelDisplay(uiscreen); @@ -215,9 +222,8 @@ @end -static int -UIKit_AllocateDisplayModeData(SDL_DisplayMode * mode, - UIScreenMode * uiscreenmode) +static int UIKit_AllocateDisplayModeData(SDL_DisplayMode *mode, + UIScreenMode *uiscreenmode) { SDL_DisplayModeData *data = nil; @@ -231,13 +237,12 @@ UIKit_AllocateDisplayModeData(SDL_DisplayMode * mode, data.uiscreenmode = uiscreenmode; } - mode->driverdata = (void *) CFBridgingRetain(data); + mode->driverdata = (void *)CFBridgingRetain(data); return 0; } -static void -UIKit_FreeDisplayModeData(SDL_DisplayMode * mode) +static void UIKit_FreeDisplayModeData(SDL_DisplayMode *mode) { if (mode->driverdata != NULL) { CFRelease(mode->driverdata); @@ -245,8 +250,7 @@ UIKit_FreeDisplayModeData(SDL_DisplayMode * mode) } } -static NSUInteger -UIKit_GetDisplayModeRefreshRate(UIScreen *uiscreen) +static NSUInteger UIKit_GetDisplayModeRefreshRate(UIScreen *uiscreen) { #ifdef __IPHONE_10_3 if ([uiscreen respondsToSelector:@selector(maximumFramesPerSecond)]) { @@ -256,9 +260,8 @@ UIKit_GetDisplayModeRefreshRate(UIScreen *uiscreen) return 0; } -static int -UIKit_AddSingleDisplayMode(SDL_VideoDisplay * display, int w, int h, - UIScreen * uiscreen, UIScreenMode * uiscreenmode) +static int UIKit_AddSingleDisplayMode(SDL_VideoDisplay *display, int w, int h, + UIScreen *uiscreen, UIScreenMode *uiscreenmode) { SDL_DisplayMode mode; SDL_zero(mode); @@ -268,7 +271,7 @@ UIKit_AddSingleDisplayMode(SDL_VideoDisplay * display, int w, int h, } mode.format = SDL_PIXELFORMAT_ABGR8888; - mode.refresh_rate = (int) UIKit_GetDisplayModeRefreshRate(uiscreen); + mode.refresh_rate = (int)UIKit_GetDisplayModeRefreshRate(uiscreen); mode.w = w; mode.h = h; @@ -280,9 +283,8 @@ UIKit_AddSingleDisplayMode(SDL_VideoDisplay * display, int w, int h, } } -static int -UIKit_AddDisplayMode(SDL_VideoDisplay * display, int w, int h, UIScreen * uiscreen, - UIScreenMode * uiscreenmode, SDL_bool addRotation) +static int UIKit_AddDisplayMode(SDL_VideoDisplay *display, int w, int h, UIScreen *uiscreen, + UIScreenMode *uiscreenmode, SDL_bool addRotation) { if (UIKit_AddSingleDisplayMode(display, w, h, uiscreen, uiscreenmode) < 0) { return -1; @@ -298,8 +300,7 @@ UIKit_AddDisplayMode(SDL_VideoDisplay * display, int w, int h, UIScreen * uiscre return 0; } -int -UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event) +int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event) { UIScreenMode *uiscreenmode = uiscreen.currentMode; CGSize size = uiscreen.bounds.size; @@ -315,9 +316,9 @@ UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event) } mode.format = SDL_PIXELFORMAT_ABGR8888; - mode.refresh_rate = (int) UIKit_GetDisplayModeRefreshRate(uiscreen); - mode.w = (int) size.width; - mode.h = (int) size.height; + mode.refresh_rate = (int)UIKit_GetDisplayModeRefreshRate(uiscreen); + mode.w = (int)size.width; + mode.h = (int)size.height; if (UIKit_AllocateDisplayModeData(&mode, uiscreenmode) < 0) { return -1; @@ -334,14 +335,13 @@ UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event) return SDL_OutOfMemory(); } - display.driverdata = (void *) CFBridgingRetain(data); + display.driverdata = (void *)CFBridgingRetain(data); SDL_AddVideoDisplay(&display, send_event); return 0; } -void -UIKit_DelDisplay(UIScreen *uiscreen) +void UIKit_DelDisplay(UIScreen *uiscreen) { int i; @@ -370,8 +370,7 @@ UIKit_IsDisplayLandscape(UIScreen *uiscreen) } } -int -UIKit_InitModes(_THIS) +int UIKit_InitModes(_THIS) { @autoreleasepool { for (UIScreen *uiscreen in [UIScreen screens]) { @@ -389,11 +388,10 @@ UIKit_InitModes(_THIS) return 0; } -void -UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay * display) +void UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay *display) { @autoreleasepool { - SDL_DisplayData *data = (__bridge SDL_DisplayData *) display->driverdata; + SDL_DisplayData *data = (__bridge SDL_DisplayData *)display->driverdata; SDL_bool isLandscape = UIKit_IsDisplayLandscape(data.uiscreen); SDL_bool addRotation = (data.uiscreen == [UIScreen mainScreen]); @@ -402,7 +400,7 @@ UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay * display) #if TARGET_OS_TV addRotation = SDL_FALSE; - availableModes = @[data.uiscreen.currentMode]; + availableModes = @[ data.uiscreen.currentMode ]; #else availableModes = data.uiscreen.availableModes; #endif @@ -434,11 +432,10 @@ UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay * display) } } -int -UIKit_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi) +int UIKit_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi) { @autoreleasepool { - SDL_DisplayData *data = (__bridge SDL_DisplayData *) display->driverdata; + SDL_DisplayData *data = (__bridge SDL_DisplayData *)display->driverdata; float dpi = data.screenDPI; if (ddpi) { @@ -455,11 +452,10 @@ UIKit_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdp return 0; } -int -UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +int UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) { @autoreleasepool { - SDL_DisplayData *data = (__bridge SDL_DisplayData *) display->driverdata; + SDL_DisplayData *data = (__bridge SDL_DisplayData *)display->driverdata; #if !TARGET_OS_TV SDL_DisplayModeData *modedata = (__bridge SDL_DisplayModeData *)mode->driverdata; @@ -485,12 +481,11 @@ UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) return 0; } -int -UIKit_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect) +int UIKit_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) { @autoreleasepool { - int displayIndex = (int) (display - _this->displays); - SDL_DisplayData *data = (__bridge SDL_DisplayData *) display->driverdata; + int displayIndex = (int)(display - _this->displays); + SDL_DisplayData *data = (__bridge SDL_DisplayData *)display->driverdata; CGRect frame = data.uiscreen.bounds; /* the default function iterates displays to make a fake offset, @@ -508,8 +503,7 @@ UIKit_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect) return 0; } -void -UIKit_QuitModes(_THIS) +void UIKit_QuitModes(_THIS) { [SDL_DisplayWatch stop]; diff --git a/src/video/uikit/SDL_uikitopengles.h b/src/video/uikit/SDL_uikitopengles.h index c2e6d571c..4cd683282 100644 --- a/src/video/uikit/SDL_uikitopengles.h +++ b/src/video/uikit/SDL_uikitopengles.h @@ -25,12 +25,12 @@ #include "../SDL_sysvideo.h" -extern int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, +extern int UIKit_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); -extern void UIKit_GL_GetDrawableSize(_THIS, SDL_Window * window, - int * w, int * h); -extern int UIKit_GL_SwapWindow(_THIS, SDL_Window * window); -extern SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window); +extern void UIKit_GL_GetDrawableSize(_THIS, SDL_Window *window, + int *w, int *h); +extern int UIKit_GL_SwapWindow(_THIS, SDL_Window *window); +extern SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window *window); extern void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context); extern void *UIKit_GL_GetProcAddress(_THIS, const char *proc); extern int UIKit_GL_LoadLibrary(_THIS, const char *path); diff --git a/src/video/uikit/SDL_uikitopengles.m b/src/video/uikit/SDL_uikitopengles.m index 15ea2e350..81bf46630 100644 --- a/src/video/uikit/SDL_uikitopengles.m +++ b/src/video/uikit/SDL_uikitopengles.m @@ -37,7 +37,7 @@ @interface SDLEAGLContext : EAGLContext /* The OpenGL ES context owns a view / drawable. */ -@property (nonatomic, strong) SDL_uikitopenglview *sdlView; +@property(nonatomic, strong) SDL_uikitopenglview *sdlView; @end @@ -64,11 +64,10 @@ UIKit_GL_GetProcAddress(_THIS, const char *proc) /* note that SDL_GL_DeleteContext makes it current without passing the window */ -int -UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) +int UIKit_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context) { @autoreleasepool { - SDLEAGLContext *eaglcontext = (__bridge SDLEAGLContext *) context; + SDLEAGLContext *eaglcontext = (__bridge SDLEAGLContext *)context; if (![EAGLContext setCurrentContext:eaglcontext]) { return SDL_SetError("Could not make EAGL context current"); @@ -82,14 +81,13 @@ UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) return 0; } -void -UIKit_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h) +void UIKit_GL_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h) { @autoreleasepool { SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; UIView *view = data.viewcontroller.view; if ([view isKindOfClass:[SDL_uikitopenglview class]]) { - SDL_uikitopenglview *glview = (SDL_uikitopenglview *) view; + SDL_uikitopenglview *glview = (SDL_uikitopenglview *)view; if (w) { *w = glview.backingWidth; } @@ -102,8 +100,7 @@ UIKit_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h) } } -int -UIKit_GL_LoadLibrary(_THIS, const char *path) +int UIKit_GL_LoadLibrary(_THIS, const char *path) { /* We shouldn't pass a path to this function, since we've already loaded the * library. */ @@ -113,10 +110,10 @@ UIKit_GL_LoadLibrary(_THIS, const char *path) return 0; } -int UIKit_GL_SwapWindow(_THIS, SDL_Window * window) +int UIKit_GL_SwapWindow(_THIS, SDL_Window *window) { @autoreleasepool { - SDLEAGLContext *context = (__bridge SDLEAGLContext *) SDL_GL_GetCurrentContext(); + SDLEAGLContext *context = (__bridge SDLEAGLContext *)SDL_GL_GetCurrentContext(); #if SDL_POWER_UIKIT /* Check once a frame to see if we should turn off the battery monitor. */ @@ -133,12 +130,12 @@ int UIKit_GL_SwapWindow(_THIS, SDL_Window * window) } SDL_GLContext -UIKit_GL_CreateContext(_THIS, SDL_Window * window) +UIKit_GL_CreateContext(_THIS, SDL_Window *window) { @autoreleasepool { SDLEAGLContext *context = nil; SDL_uikitopenglview *view; - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; CGRect frame = UIKit_ComputeViewFrame(window, data.uiwindow.screen); EAGLSharegroup *sharegroup = nil; CGFloat scale = 1.0; @@ -161,7 +158,7 @@ UIKit_GL_CreateContext(_THIS, SDL_Window * window) } if (_this->gl_config.share_with_current_context) { - EAGLContext *currContext = (__bridge EAGLContext *) SDL_GL_GetCurrentContext(); + EAGLContext *currContext = (__bridge EAGLContext *)SDL_GL_GetCurrentContext(); sharegroup = currContext.sharegroup; } @@ -199,19 +196,18 @@ UIKit_GL_CreateContext(_THIS, SDL_Window * window) /* The context owns the view / drawable. */ context.sdlView = view; - if (UIKit_GL_MakeCurrent(_this, window, (__bridge SDL_GLContext) context) < 0) { - UIKit_GL_DeleteContext(_this, (SDL_GLContext) CFBridgingRetain(context)); + if (UIKit_GL_MakeCurrent(_this, window, (__bridge SDL_GLContext)context) < 0) { + UIKit_GL_DeleteContext(_this, (SDL_GLContext)CFBridgingRetain(context)); return NULL; } /* We return a +1'd context. The window's driverdata owns the view (via * MakeCurrent.) */ - return (SDL_GLContext) CFBridgingRetain(context); + return (SDL_GLContext)CFBridgingRetain(context); } } -void -UIKit_GL_DeleteContext(_THIS, SDL_GLContext context) +void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context) { @autoreleasepool { /* The context was retained in SDL_GL_CreateContext, so we release it @@ -221,8 +217,7 @@ UIKit_GL_DeleteContext(_THIS, SDL_GLContext context) } } -void -UIKit_GL_RestoreCurrentContext(void) +void UIKit_GL_RestoreCurrentContext(void) { @autoreleasepool { /* Some iOS system functionality (such as Dictation on the on-screen @@ -232,7 +227,7 @@ UIKit_GL_RestoreCurrentContext(void) finished running its own code for the frame. If this isn't done, the app may crash or have other nasty symptoms when Dictation is used. */ - EAGLContext *context = (__bridge EAGLContext *) SDL_GL_GetCurrentContext(); + EAGLContext *context = (__bridge EAGLContext *)SDL_GL_GetCurrentContext(); if (context != NULL && [EAGLContext currentContext] != context) { [EAGLContext setCurrentContext:context]; } diff --git a/src/video/uikit/SDL_uikitopenglview.h b/src/video/uikit/SDL_uikitopenglview.h index df659a1f1..519fd328f 100644 --- a/src/video/uikit/SDL_uikitopenglview.h +++ b/src/video/uikit/SDL_uikitopenglview.h @@ -43,15 +43,15 @@ multisamples:(int)multisamples context:(EAGLContext *)glcontext; -@property (nonatomic, readonly, weak) EAGLContext *context; +@property(nonatomic, readonly, weak) EAGLContext *context; /* The width and height of the drawable in pixels (as opposed to points.) */ -@property (nonatomic, readonly) int backingWidth; -@property (nonatomic, readonly) int backingHeight; +@property(nonatomic, readonly) int backingWidth; +@property(nonatomic, readonly) int backingHeight; -@property (nonatomic, readonly) GLuint drawableRenderbuffer; -@property (nonatomic, readonly) GLuint drawableFramebuffer; -@property (nonatomic, readonly) GLuint msaaResolveFramebuffer; +@property(nonatomic, readonly) GLuint drawableRenderbuffer; +@property(nonatomic, readonly) GLuint drawableFramebuffer; +@property(nonatomic, readonly) GLuint msaaResolveFramebuffer; - (void)swapBuffers; diff --git a/src/video/uikit/SDL_uikitopenglview.m b/src/video/uikit/SDL_uikitopenglview.m index ea4db411a..8756a8e1b 100644 --- a/src/video/uikit/SDL_uikitopenglview.m +++ b/src/video/uikit/SDL_uikitopenglview.m @@ -27,7 +27,8 @@ #import "SDL_uikitopenglview.h" #include "SDL_uikitwindow.h" -@implementation SDL_uikitopenglview { +@implementation SDL_uikitopenglview +{ /* The renderbuffer and framebuffer used to render to this layer. */ GLuint viewRenderbuffer, viewFramebuffer; @@ -109,8 +110,8 @@ eaglLayer.opaque = YES; eaglLayer.drawableProperties = @{ - kEAGLDrawablePropertyRetainedBacking:@(retained), - kEAGLDrawablePropertyColorFormat:colorFormat + kEAGLDrawablePropertyRetainedBacking : @(retained), + kEAGLDrawablePropertyColorFormat : colorFormat }; /* Set the appropriate scale (for retina display support) */ @@ -279,7 +280,7 @@ - (void)swapBuffers { if (msaaFramebuffer) { - const GLenum attachments[] = {GL_COLOR_ATTACHMENT0}; + const GLenum attachments[] = { GL_COLOR_ATTACHMENT0 }; glBindFramebuffer(GL_DRAW_FRAMEBUFFER, viewFramebuffer); @@ -317,8 +318,8 @@ { [super layoutSubviews]; - int width = (int) (self.bounds.size.width * self.contentScaleFactor); - int height = (int) (self.bounds.size.height * self.contentScaleFactor); + int width = (int)(self.bounds.size.width * self.contentScaleFactor); + int height = (int)(self.bounds.size.height * self.contentScaleFactor); /* Update the color and depth buffer storage if the layer size has changed. */ if (width != backingWidth || height != backingHeight) { diff --git a/src/video/uikit/SDL_uikitvideo.h b/src/video/uikit/SDL_uikitvideo.h index b684e23a8..a41ff3f18 100644 --- a/src/video/uikit/SDL_uikitvideo.h +++ b/src/video/uikit/SDL_uikitvideo.h @@ -29,7 +29,7 @@ @interface SDL_VideoData : NSObject -@property (nonatomic, assign) id pasteboardObserver; +@property(nonatomic, assign) id pasteboardObserver; @end diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m index 4e8a57755..bce7d676a 100644 --- a/src/video/uikit/SDL_uikitvideo.m +++ b/src/video/uikit/SDL_uikitvideo.m @@ -52,7 +52,7 @@ static void UIKit_VideoQuit(_THIS); /* DUMMY driver bootstrap functions */ -static void UIKit_DeleteDevice(SDL_VideoDevice * device) +static void UIKit_DeleteDevice(SDL_VideoDevice *device) { @autoreleasepool { CFRelease(device->driverdata); @@ -60,15 +60,14 @@ static void UIKit_DeleteDevice(SDL_VideoDevice * device) } } -static SDL_VideoDevice * -UIKit_CreateDevice(void) +static SDL_VideoDevice *UIKit_CreateDevice(void) { @autoreleasepool { SDL_VideoDevice *device; SDL_VideoData *data; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device) { data = [SDL_VideoData new]; } else { @@ -77,7 +76,7 @@ UIKit_CreateDevice(void) return (0); } - device->driverdata = (void *) CFBridgingRetain(data); + device->driverdata = (void *)CFBridgingRetain(data); /* Set the function pointers */ device->VideoInit = UIKit_VideoInit; @@ -114,21 +113,20 @@ UIKit_CreateDevice(void) /* OpenGL (ES) functions */ #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 - device->GL_MakeCurrent = UIKit_GL_MakeCurrent; - device->GL_GetDrawableSize = UIKit_GL_GetDrawableSize; - device->GL_SwapWindow = UIKit_GL_SwapWindow; - device->GL_CreateContext = UIKit_GL_CreateContext; - device->GL_DeleteContext = UIKit_GL_DeleteContext; - device->GL_GetProcAddress = UIKit_GL_GetProcAddress; - device->GL_LoadLibrary = UIKit_GL_LoadLibrary; + device->GL_MakeCurrent = UIKit_GL_MakeCurrent; + device->GL_GetDrawableSize = UIKit_GL_GetDrawableSize; + device->GL_SwapWindow = UIKit_GL_SwapWindow; + device->GL_CreateContext = UIKit_GL_CreateContext; + device->GL_DeleteContext = UIKit_GL_DeleteContext; + device->GL_GetProcAddress = UIKit_GL_GetProcAddress; + device->GL_LoadLibrary = UIKit_GL_LoadLibrary; #endif device->free = UIKit_DeleteDevice; #if SDL_VIDEO_VULKAN device->Vulkan_LoadLibrary = UIKit_Vulkan_LoadLibrary; device->Vulkan_UnloadLibrary = UIKit_Vulkan_UnloadLibrary; - device->Vulkan_GetInstanceExtensions - = UIKit_Vulkan_GetInstanceExtensions; + device->Vulkan_GetInstanceExtensions = UIKit_Vulkan_GetInstanceExtensions; device->Vulkan_CreateSurface = UIKit_Vulkan_CreateSurface; device->Vulkan_GetDrawableSize = UIKit_Vulkan_GetDrawableSize; #endif @@ -151,9 +149,7 @@ VideoBootStrap UIKIT_bootstrap = { UIKit_CreateDevice }; - -int -UIKit_VideoInit(_THIS) +int UIKit_VideoInit(_THIS) { _this->gl_config.driver_loaded = 1; @@ -167,8 +163,7 @@ UIKit_VideoInit(_THIS) return 0; } -void -UIKit_VideoQuit(_THIS) +void UIKit_VideoQuit(_THIS) { SDL_QuitGCKeyboard(); SDL_QuitGCMouse(); @@ -176,8 +171,7 @@ UIKit_VideoQuit(_THIS) UIKit_QuitModes(_this); } -void -UIKit_SuspendScreenSaver(_THIS) +void UIKit_SuspendScreenSaver(_THIS) { @autoreleasepool { /* Ignore ScreenSaver API calls if the idle timer hint has been set. */ @@ -200,7 +194,7 @@ UIKit_IsSystemVersionAtLeast(double version) CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen) { - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; CGRect frame = screen.bounds; /* Use the UIWindow bounds instead of the UIScreen bounds, when possible. @@ -235,14 +229,13 @@ UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen) return frame; } -void -UIKit_ForceUpdateHomeIndicator() +void UIKit_ForceUpdateHomeIndicator() { #if !TARGET_OS_TV /* Force the main SDL window to re-evaluate home indicator state */ SDL_Window *focus = SDL_GetFocusWindow(); if (focus) { - SDL_WindowData *data = (__bridge SDL_WindowData *) focus->driverdata; + SDL_WindowData *data = (__bridge SDL_WindowData *)focus->driverdata; if (data != nil) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunguarded-availability-new" diff --git a/src/video/uikit/SDL_uikitview.h b/src/video/uikit/SDL_uikitview.h index dcd63c7a5..15be61b55 100644 --- a/src/video/uikit/SDL_uikitview.h +++ b/src/video/uikit/SDL_uikitview.h @@ -37,7 +37,7 @@ #if !TARGET_OS_TV && defined(__IPHONE_13_4) - (UIPointerRegion *)pointerInteraction:(UIPointerInteraction *)interaction regionForRequest:(UIPointerRegionRequest *)request defaultRegion:(UIPointerRegion *)defaultRegion API_AVAILABLE(ios(13.4)); -- (UIPointerStyle *)pointerInteraction:(UIPointerInteraction *)interaction styleForRegion:(UIPointerRegion *)region API_AVAILABLE(ios(13.4)); +- (UIPointerStyle *)pointerInteraction:(UIPointerInteraction *)interaction styleForRegion:(UIPointerRegion *)region API_AVAILABLE(ios(13.4)); #endif - (CGPoint)touchLocation:(UITouch *)touch shouldNormalize:(BOOL)normalize; diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index 8c48cfa50..557b97140 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -1,22 +1,22 @@ - /* - Simple DirectMedia Layer - Copyright (C) 1997-2022 Sam Lantinga +/* + Simple DirectMedia Layer + Copyright (C) 1997-2022 Sam Lantinga - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" @@ -35,14 +35,15 @@ #include "SDL_uikitwindow.h" /* The maximum number of mouse buttons we support */ -#define MAX_MOUSE_BUTTONS 5 +#define MAX_MOUSE_BUTTONS 5 /* This is defined in SDL_sysjoystick.m */ #if !SDL_JOYSTICK_DISABLED extern int SDL_AppleTVRemoteOpenedAsJoystick; #endif -@implementation SDL_uikitview { +@implementation SDL_uikitview +{ SDL_Window *sdlwindow; SDL_TouchID directTouchId; @@ -103,7 +104,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; /* Remove ourself from the old window. */ if (sdlwindow) { SDL_uikitview *view = nil; - data = (__bridge SDL_WindowData *) sdlwindow->driverdata; + data = (__bridge SDL_WindowData *)sdlwindow->driverdata; [data.views removeObject:self]; @@ -122,7 +123,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; /* Add ourself to the new window. */ if (window) { - data = (__bridge SDL_WindowData *) window->driverdata; + data = (__bridge SDL_WindowData *)window->driverdata; /* Make sure the SDL window has a strong reference to this view. */ [data.views addObject:self]; @@ -149,7 +150,8 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; } #if !TARGET_OS_TV && defined(__IPHONE_13_4) -- (UIPointerRegion *)pointerInteraction:(UIPointerInteraction *)interaction regionForRequest:(UIPointerRegionRequest *)request defaultRegion:(UIPointerRegion *)defaultRegion API_AVAILABLE(ios(13.4)){ +- (UIPointerRegion *)pointerInteraction:(UIPointerInteraction *)interaction regionForRequest:(UIPointerRegionRequest *)request defaultRegion:(UIPointerRegion *)defaultRegion API_AVAILABLE(ios(13.4)) +{ if (request != nil && !SDL_GCMouseRelativeMode()) { CGPoint origin = self.bounds.origin; CGPoint point = request.location; @@ -162,7 +164,8 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; return [UIPointerRegion regionWithRect:self.bounds identifier:nil]; } -- (UIPointerStyle *)pointerInteraction:(UIPointerInteraction *)interaction styleForRegion:(UIPointerRegion *)region API_AVAILABLE(ios(13.4)){ +- (UIPointerStyle *)pointerInteraction:(UIPointerInteraction *)interaction styleForRegion:(UIPointerRegion *)region API_AVAILABLE(ios(13.4)) +{ if (SDL_ShowCursor(-1)) { return nil; } else { @@ -187,11 +190,11 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; - (SDL_TouchID)touchIdForType:(SDL_TouchDeviceType)type { switch (type) { - case SDL_TOUCH_DEVICE_DIRECT: - default: - return directTouchId; - case SDL_TOUCH_DEVICE_INDIRECT_RELATIVE: - return indirectTouchId; + case SDL_TOUCH_DEVICE_DIRECT: + default: + return directTouchId; + case SDL_TOUCH_DEVICE_INDIRECT_RELATIVE: + return indirectTouchId; } } @@ -212,7 +215,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; { #ifdef __IPHONE_9_0 if ([touch respondsToSelector:@selector(force)]) { - return (float) touch.force; + return (float)touch.force; } #endif @@ -364,7 +367,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; } #if TARGET_OS_TV || defined(__IPHONE_9_1) -- (SDL_Scancode)scancodeFromPress:(UIPress*)press +- (SDL_Scancode)scancodeFromPress:(UIPress *)press { #ifdef __IPHONE_13_4 if ([press respondsToSelector:@selector((key))]) { @@ -446,7 +449,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; #endif /* TARGET_OS_TV || defined(__IPHONE_9_1) */ #if TARGET_OS_TV --(void)swipeGesture:(UISwipeGestureRecognizer *)gesture +- (void)swipeGesture:(UISwipeGestureRecognizer *)gesture { /* Swipe gestures don't trigger begin states. */ if (gesture.state == UIGestureRecognizerStateEnded) { diff --git a/src/video/uikit/SDL_uikitviewcontroller.h b/src/video/uikit/SDL_uikitviewcontroller.h index 2e64a5279..2880ccd4a 100644 --- a/src/video/uikit/SDL_uikitviewcontroller.h +++ b/src/video/uikit/SDL_uikitviewcontroller.h @@ -39,18 +39,18 @@ @interface SDL_uikitviewcontroller : SDLRootViewController #endif -@property (nonatomic, assign) SDL_Window *window; +@property(nonatomic, assign) SDL_Window *window; - (instancetype)initWithSDLWindow:(SDL_Window *)_window; - (void)setAnimationCallback:(int)interval - callback:(void (*)(void*))callback - callbackParam:(void*)callbackParam; + callback:(void (*)(void *))callback + callbackParam:(void *)callbackParam; - (void)startAnimation; - (void)stopAnimation; -- (void)doLoop:(CADisplayLink*)sender; +- (void)doLoop:(CADisplayLink *)sender; - (void)loadView; - (void)viewDidLayoutSubviews; @@ -61,7 +61,7 @@ - (BOOL)prefersHomeIndicatorAutoHidden; - (UIRectEdge)preferredScreenEdgesDeferringSystemGestures; -@property (nonatomic, assign) int homeIndicatorHidden; +@property(nonatomic, assign) int homeIndicatorHidden; #endif #if SDL_IPHONE_KEYBOARD @@ -75,9 +75,9 @@ - (void)updateKeyboard; -@property (nonatomic, assign, getter=isKeyboardVisible) BOOL keyboardVisible; -@property (nonatomic, assign) SDL_Rect textInputRect; -@property (nonatomic, assign) int keyboardHeight; +@property(nonatomic, assign, getter=isKeyboardVisible) BOOL keyboardVisible; +@property(nonatomic, assign) SDL_Rect textInputRect; +@property(nonatomic, assign) int keyboardHeight; #endif @end diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m index ee7ee83b0..889cb8438 100644 --- a/src/video/uikit/SDL_uikitviewcontroller.m +++ b/src/video/uikit/SDL_uikitviewcontroller.m @@ -36,22 +36,20 @@ #include "SDL_uikitopengles.h" #if TARGET_OS_TV -static void SDLCALL -SDL_AppleTVControllerUIHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_AppleTVControllerUIHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { @autoreleasepool { - SDL_uikitviewcontroller *viewcontroller = (__bridge SDL_uikitviewcontroller *) userdata; + SDL_uikitviewcontroller *viewcontroller = (__bridge SDL_uikitviewcontroller *)userdata; viewcontroller.controllerUserInteractionEnabled = hint && (*hint != '0'); } } #endif #if !TARGET_OS_TV -static void SDLCALL -SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { @autoreleasepool { - SDL_uikitviewcontroller *viewcontroller = (__bridge SDL_uikitviewcontroller *) userdata; + SDL_uikitviewcontroller *viewcontroller = (__bridge SDL_uikitviewcontroller *)userdata; viewcontroller.homeIndicatorHidden = (hint && *hint) ? SDL_atoi(hint) : -1; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunguarded-availability-new" @@ -64,10 +62,11 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o } #endif -@implementation SDL_uikitviewcontroller { +@implementation SDL_uikitviewcontroller +{ CADisplayLink *displayLink; int animationInterval; - void (*animationCallback)(void*); + void (*animationCallback)(void *); void *animationCallbackParam; #if SDL_IPHONE_KEYBOARD @@ -97,13 +96,13 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o #if TARGET_OS_TV SDL_AddHintCallback(SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTS, SDL_AppleTVControllerUIHintChanged, - (__bridge void *) self); + (__bridge void *)self); #endif #if !TARGET_OS_TV SDL_AddHintCallback(SDL_HINT_IOS_HIDE_HOME_INDICATOR, SDL_HideHomeIndicatorHintChanged, - (__bridge void *) self); + (__bridge void *)self); #endif } return self; @@ -118,19 +117,19 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o #if TARGET_OS_TV SDL_DelHintCallback(SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTS, SDL_AppleTVControllerUIHintChanged, - (__bridge void *) self); + (__bridge void *)self); #endif #if !TARGET_OS_TV SDL_DelHintCallback(SDL_HINT_IOS_HIDE_HOME_INDICATOR, SDL_HideHomeIndicatorHintChanged, - (__bridge void *) self); + (__bridge void *)self); #endif } - (void)setAnimationCallback:(int)interval - callback:(void (*)(void*))callback - callbackParam:(void*)callbackParam + callback:(void (*)(void *))callback + callbackParam:(void *)callbackParam { [self stopAnimation]; @@ -148,11 +147,9 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(doLoop:)]; #ifdef __IPHONE_10_3 - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; - if ([displayLink respondsToSelector:@selector(preferredFramesPerSecond)] - && data != nil && data.uiwindow != nil - && [data.uiwindow.screen respondsToSelector:@selector(maximumFramesPerSecond)]) { + if ([displayLink respondsToSelector:@selector(preferredFramesPerSecond)] && data != nil && data.uiwindow != nil && [data.uiwindow.screen respondsToSelector:@selector(maximumFramesPerSecond)]) { displayLink.preferredFramesPerSecond = data.uiwindow.screen.maximumFramesPerSecond / animationInterval; } else #endif @@ -171,7 +168,7 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o displayLink = nil; } -- (void)doLoop:(CADisplayLink*)sender +- (void)doLoop:(CADisplayLink *)sender { /* Don't run the game loop while a messagebox is up */ if (!UIKit_ShowingMessageBox()) { @@ -192,8 +189,8 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o - (void)viewDidLayoutSubviews { const CGSize size = self.view.bounds.size; - int w = (int) size.width; - int h = (int) size.height; + int w = (int)size.width; + int h = (int)size.height; SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, w, h); } @@ -206,7 +203,7 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o - (BOOL)prefersStatusBarHidden { - BOOL hidden = (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) != 0; + BOOL hidden = (window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS)) != 0; return hidden; } @@ -230,7 +227,7 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o } /* By default, fullscreen and borderless windows get all screen gestures */ - if ((window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) != 0) { + if ((window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS)) != 0) { return UIRectEdgeAll; } else { return UIRectEdgeNone; @@ -277,10 +274,16 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; #if !TARGET_OS_TV - [center addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; + [center addObserver:self + selector:@selector(keyboardWillShow:) + name:UIKeyboardWillShowNotification + object:nil]; [center addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; #endif - [center addObserver:self selector:@selector(textFieldTextDidChange:) name:UITextFieldTextDidChangeNotification object:nil]; + [center addObserver:self + selector:@selector(textFieldTextDidChange:) + name:UITextFieldTextDidChangeNotification + object:nil]; } - (NSArray *)keyCommands @@ -331,20 +334,26 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o { [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; rotatingOrientation = YES; - [coordinator animateAlongsideTransition:^(id context) {} - completion:^(id context) { - self->rotatingOrientation = NO; - }]; + [coordinator + animateAlongsideTransition:^(id context) { + } + completion:^(id context) { + self->rotatingOrientation = NO; + }]; } - (void)deinitKeyboard { NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; #if !TARGET_OS_TV - [center removeObserver:self name:UIKeyboardWillShowNotification object:nil]; + [center removeObserver:self + name:UIKeyboardWillShowNotification + object:nil]; [center removeObserver:self name:UIKeyboardWillHideNotification object:nil]; #endif - [center removeObserver:self name:UITextFieldTextDidChangeNotification object:nil]; + [center removeObserver:self + name:UITextFieldTextDidChangeNotification + object:nil]; } /* reveal onscreen virtual keyboard */ @@ -471,12 +480,12 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o } /* Terminates the editing session */ -- (BOOL)textFieldShouldReturn:(UITextField*)_textField +- (BOOL)textFieldShouldReturn:(UITextField *)_textField { SDL_SendKeyboardKeyAutoRelease(SDL_SCANCODE_RETURN); if (keyboardVisible && SDL_GetHintBoolean(SDL_HINT_RETURN_KEY_HIDES_IME, SDL_FALSE)) { - SDL_StopTextInput(); + SDL_StopTextInput(); } return YES; } @@ -488,8 +497,7 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o /* iPhone keyboard addition functions */ #if SDL_IPHONE_KEYBOARD -static SDL_uikitviewcontroller * -GetWindowViewController(SDL_Window * window) +static SDL_uikitviewcontroller *GetWindowViewController(SDL_Window *window) { if (!window || !window->driverdata) { SDL_SetError("Invalid window"); @@ -507,8 +515,7 @@ UIKit_HasScreenKeyboardSupport(_THIS) return SDL_TRUE; } -void -UIKit_ShowScreenKeyboard(_THIS, SDL_Window *window) +void UIKit_ShowScreenKeyboard(_THIS, SDL_Window *window) { @autoreleasepool { SDL_uikitviewcontroller *vc = GetWindowViewController(window); @@ -516,8 +523,7 @@ UIKit_ShowScreenKeyboard(_THIS, SDL_Window *window) } } -void -UIKit_HideScreenKeyboard(_THIS, SDL_Window *window) +void UIKit_HideScreenKeyboard(_THIS, SDL_Window *window) { @autoreleasepool { SDL_uikitviewcontroller *vc = GetWindowViewController(window); @@ -537,8 +543,7 @@ UIKit_IsScreenKeyboardShown(_THIS, SDL_Window *window) } } -void -UIKit_SetTextInputRect(_THIS, const SDL_Rect *rect) +void UIKit_SetTextInputRect(_THIS, const SDL_Rect *rect) { if (!rect) { SDL_InvalidParamError("rect"); @@ -557,7 +562,6 @@ UIKit_SetTextInputRect(_THIS, const SDL_Rect *rect) } } - #endif /* SDL_IPHONE_KEYBOARD */ #endif /* SDL_VIDEO_DRIVER_UIKIT */ diff --git a/src/video/uikit/SDL_uikitvulkan.h b/src/video/uikit/SDL_uikitvulkan.h index cc8f777eb..3c29d6fba 100644 --- a/src/video/uikit/SDL_uikitvulkan.h +++ b/src/video/uikit/SDL_uikitvulkan.h @@ -37,13 +37,13 @@ int UIKit_Vulkan_LoadLibrary(_THIS, const char *path); void UIKit_Vulkan_UnloadLibrary(_THIS); SDL_bool UIKit_Vulkan_GetInstanceExtensions(_THIS, - SDL_Window *window, - unsigned *count, - const char **names); + SDL_Window *window, + unsigned *count, + const char **names); SDL_bool UIKit_Vulkan_CreateSurface(_THIS, - SDL_Window *window, - VkInstance instance, - VkSurfaceKHR *surface); + SDL_Window *window, + VkInstance instance, + VkSurfaceKHR *surface); void UIKit_Vulkan_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h); diff --git a/src/video/uikit/SDL_uikitvulkan.m b/src/video/uikit/SDL_uikitvulkan.m index 52a1ceddb..ae011abe5 100644 --- a/src/video/uikit/SDL_uikitvulkan.m +++ b/src/video/uikit/SDL_uikitvulkan.m @@ -38,7 +38,7 @@ #include -const char* defaultPaths[] = { +const char *defaultPaths[] = { "libvulkan.dylib", }; @@ -67,14 +67,14 @@ int UIKit_Vulkan_LoadLibrary(_THIS, const char *path) if (!path) { /* Handle the case where Vulkan Portability is linked statically. */ vkGetInstanceProcAddr = - (PFN_vkGetInstanceProcAddr)dlsym(DEFAULT_HANDLE, - "vkGetInstanceProcAddr"); + (PFN_vkGetInstanceProcAddr)dlsym(DEFAULT_HANDLE, + "vkGetInstanceProcAddr"); } if (vkGetInstanceProcAddr) { _this->vulkan_config.loader_handle = DEFAULT_HANDLE; } else { - const char** paths; + const char **paths; const char *foundPath = NULL; int numPaths; int i; @@ -101,15 +101,15 @@ int UIKit_Vulkan_LoadLibrary(_THIS, const char *path) SDL_arraysize(_this->vulkan_config.loader_path)); vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction( - _this->vulkan_config.loader_handle, - "vkGetInstanceProcAddr"); + _this->vulkan_config.loader_handle, + "vkGetInstanceProcAddr"); } if (!vkGetInstanceProcAddr) { SDL_SetError("Failed to find %s in either executable or %s: %s", "vkGetInstanceProcAddr", "linked Vulkan Portability library", - (const char *) dlerror()); + (const char *)dlerror()); goto fail; } @@ -145,13 +145,10 @@ int UIKit_Vulkan_LoadLibrary(_THIS, const char *path) SDL_free(extensions); if (!hasSurfaceExtension) { - SDL_SetError("Installed Vulkan Portability doesn't implement the " - VK_KHR_SURFACE_EXTENSION_NAME " extension"); + SDL_SetError("Installed Vulkan Portability doesn't implement the " VK_KHR_SURFACE_EXTENSION_NAME " extension"); goto fail; } else if (!hasMetalSurfaceExtension && !hasIOSSurfaceExtension) { - SDL_SetError("Installed Vulkan Portability doesn't implement the " - VK_EXT_METAL_SURFACE_EXTENSION_NAME " or " - VK_MVK_IOS_SURFACE_EXTENSION_NAME " extensions"); + SDL_SetError("Installed Vulkan Portability doesn't implement the " VK_EXT_METAL_SURFACE_EXTENSION_NAME " or " VK_MVK_IOS_SURFACE_EXTENSION_NAME " extensions"); goto fail; } @@ -173,9 +170,9 @@ void UIKit_Vulkan_UnloadLibrary(_THIS) } SDL_bool UIKit_Vulkan_GetInstanceExtensions(_THIS, - SDL_Window *window, - unsigned *count, - const char **names) + SDL_Window *window, + unsigned *count, + const char **names) { static const char *const extensionsForUIKit[] = { VK_KHR_SURFACE_EXTENSION_NAME, VK_EXT_METAL_SURFACE_EXTENSION_NAME @@ -186,25 +183,25 @@ SDL_bool UIKit_Vulkan_GetInstanceExtensions(_THIS, } return SDL_Vulkan_GetInstanceExtensions_Helper( - count, names, SDL_arraysize(extensionsForUIKit), - extensionsForUIKit); + count, names, SDL_arraysize(extensionsForUIKit), + extensionsForUIKit); } SDL_bool UIKit_Vulkan_CreateSurface(_THIS, - SDL_Window *window, - VkInstance instance, - VkSurfaceKHR *surface) + SDL_Window *window, + VkInstance instance, + VkSurfaceKHR *surface) { PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT = (PFN_vkCreateMetalSurfaceEXT)vkGetInstanceProcAddr( - (VkInstance)instance, - "vkCreateMetalSurfaceEXT"); + (VkInstance)instance, + "vkCreateMetalSurfaceEXT"); PFN_vkCreateIOSSurfaceMVK vkCreateIOSSurfaceMVK = (PFN_vkCreateIOSSurfaceMVK)vkGetInstanceProcAddr( - (VkInstance)instance, - "vkCreateIOSSurfaceMVK"); + (VkInstance)instance, + "vkCreateIOSSurfaceMVK"); VkResult result; SDL_MetalView metalview; @@ -214,9 +211,8 @@ SDL_bool UIKit_Vulkan_CreateSurface(_THIS, } if (!vkCreateMetalSurfaceEXT && !vkCreateIOSSurfaceMVK) { - SDL_SetError(VK_EXT_METAL_SURFACE_EXTENSION_NAME " or " - VK_MVK_IOS_SURFACE_EXTENSION_NAME - " extensions are not enabled in the Vulkan instance."); + SDL_SetError(VK_EXT_METAL_SURFACE_EXTENSION_NAME " or " VK_MVK_IOS_SURFACE_EXTENSION_NAME + " extensions are not enabled in the Vulkan instance."); return SDL_FALSE; } @@ -231,7 +227,7 @@ SDL_bool UIKit_Vulkan_CreateSurface(_THIS, createInfo.pNext = NULL; createInfo.flags = 0; createInfo.pLayer = (__bridge const CAMetalLayer *) - UIKit_Metal_GetLayer(_this, metalview); + UIKit_Metal_GetLayer(_this, metalview); result = vkCreateMetalSurfaceEXT(instance, &createInfo, NULL, surface); if (result != VK_SUCCESS) { UIKit_Metal_DestroyView(_this, metalview); @@ -246,7 +242,7 @@ SDL_bool UIKit_Vulkan_CreateSurface(_THIS, createInfo.flags = 0; createInfo.pView = (const void *)metalview; result = vkCreateIOSSurfaceMVK(instance, &createInfo, - NULL, surface); + NULL, surface); if (result != VK_SUCCESS) { UIKit_Metal_DestroyView(_this, metalview); SDL_SetError("vkCreateIOSSurfaceMVK failed: %s", diff --git a/src/video/uikit/SDL_uikitwindow.h b/src/video/uikit/SDL_uikitwindow.h index 7ca9b475e..7e7e7479f 100644 --- a/src/video/uikit/SDL_uikitwindow.h +++ b/src/video/uikit/SDL_uikitwindow.h @@ -40,17 +40,17 @@ extern void UIKit_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int extern SDL_bool UIKit_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo * info); -extern NSUInteger UIKit_GetSupportedOrientations(SDL_Window * window); +extern NSUInteger UIKit_GetSupportedOrientations(SDL_Window *window); @class UIWindow; @interface SDL_WindowData : NSObject -@property (nonatomic, strong) UIWindow *uiwindow; -@property (nonatomic, strong) SDL_uikitviewcontroller *viewcontroller; +@property(nonatomic, strong) UIWindow *uiwindow; +@property(nonatomic, strong) SDL_uikitviewcontroller *viewcontroller; /* Array of SDL_uikitviews owned by this window. */ -@property (nonatomic, copy) NSMutableArray *views; +@property(nonatomic, copy) NSMutableArray *views; @end diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m index 7b8dfff56..b58877b8e 100644 --- a/src/video/uikit/SDL_uikitwindow.m +++ b/src/video/uikit/SDL_uikitwindow.m @@ -83,24 +83,22 @@ @end - -static int -SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bool created) +static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bool created) { SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); - SDL_DisplayData *displaydata = (__bridge SDL_DisplayData *) display->driverdata; + SDL_DisplayData *displaydata = (__bridge SDL_DisplayData *)display->driverdata; SDL_uikitview *view; CGRect frame = UIKit_ComputeViewFrame(window, displaydata.uiscreen); - int width = (int) frame.size.width; - int height = (int) frame.size.height; + int width = (int)frame.size.width; + int height = (int)frame.size.height; SDL_WindowData *data = [[SDL_WindowData alloc] init]; if (!data) { return SDL_OutOfMemory(); } - window->driverdata = (void *) CFBridgingRetain(data); + window->driverdata = (void *)CFBridgingRetain(data); data.uiwindow = uiwindow; @@ -108,9 +106,9 @@ SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bool created) window->flags &= ~SDL_WINDOW_HIDDEN; if (displaydata.uiscreen != [UIScreen mainScreen]) { - window->flags &= ~SDL_WINDOW_RESIZABLE; /* window is NEVER resizable */ - window->flags &= ~SDL_WINDOW_INPUT_FOCUS; /* never has input focus */ - window->flags |= SDL_WINDOW_BORDERLESS; /* never has a status bar. */ + window->flags &= ~SDL_WINDOW_RESIZABLE; /* window is NEVER resizable */ + window->flags &= ~SDL_WINDOW_INPUT_FOCUS; /* never has input focus */ + window->flags |= SDL_WINDOW_BORDERLESS; /* never has a status bar. */ } #if !TARGET_OS_TV @@ -125,7 +123,7 @@ SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bool created) NSUInteger orients = UIKit_GetSupportedOrientations(window); BOOL supportsLandscape = (orients & UIInterfaceOrientationMaskLandscape) != 0; - BOOL supportsPortrait = (orients & (UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskPortraitUpsideDown)) != 0; + BOOL supportsPortrait = (orients & (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown)) != 0; /* Make sure the width/height are oriented correctly */ if ((width > height && !supportsLandscape) || (height > width && !supportsPortrait)) { @@ -158,12 +156,11 @@ SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bool created) return 0; } -int -UIKit_CreateWindow(_THIS, SDL_Window *window) +int UIKit_CreateWindow(_THIS, SDL_Window *window) { @autoreleasepool { SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); - SDL_DisplayData *data = (__bridge SDL_DisplayData *) display->driverdata; + SDL_DisplayData *data = (__bridge SDL_DisplayData *)display->driverdata; SDL_Window *other; /* We currently only handle a single window per display on iOS */ @@ -204,7 +201,7 @@ UIKit_CreateWindow(_THIS, SDL_Window *window) } if (data.uiscreen == [UIScreen mainScreen]) { - if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) { + if (window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS)) { [UIApplication sharedApplication].statusBarHidden = YES; } else { [UIApplication sharedApplication].statusBarHidden = NO; @@ -229,25 +226,23 @@ UIKit_CreateWindow(_THIS, SDL_Window *window) return 1; } -void -UIKit_SetWindowTitle(_THIS, SDL_Window * window) +void UIKit_SetWindowTitle(_THIS, SDL_Window *window) { @autoreleasepool { - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; data.viewcontroller.title = @(window->title); } } -void -UIKit_ShowWindow(_THIS, SDL_Window * window) +void UIKit_ShowWindow(_THIS, SDL_Window *window) { @autoreleasepool { - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; [data.uiwindow makeKeyAndVisible]; /* Make this window the current mouse focus for touch input */ SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); - SDL_DisplayData *displaydata = (__bridge SDL_DisplayData *) display->driverdata; + SDL_DisplayData *displaydata = (__bridge SDL_DisplayData *)display->driverdata; if (displaydata.uiscreen == [UIScreen mainScreen]) { SDL_SetMouseFocus(window); SDL_SetKeyboardFocus(window); @@ -255,17 +250,15 @@ UIKit_ShowWindow(_THIS, SDL_Window * window) } } -void -UIKit_HideWindow(_THIS, SDL_Window * window) +void UIKit_HideWindow(_THIS, SDL_Window *window) { @autoreleasepool { - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; data.uiwindow.hidden = YES; } } -void -UIKit_RaiseWindow(_THIS, SDL_Window * window) +void UIKit_RaiseWindow(_THIS, SDL_Window *window) { /* We don't currently offer a concept of "raising" the SDL window, since * we only allow one per display, in the iOS fashion. @@ -274,10 +267,9 @@ UIKit_RaiseWindow(_THIS, SDL_Window * window) _this->GL_MakeCurrent(_this, _this->current_glwin, _this->current_glctx); } -static void -UIKit_UpdateWindowBorder(_THIS, SDL_Window * window) +static void UIKit_UpdateWindowBorder(_THIS, SDL_Window *window) { - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; SDL_uikitviewcontroller *viewcontroller = data.viewcontroller; #if !TARGET_OS_TV @@ -304,35 +296,31 @@ UIKit_UpdateWindowBorder(_THIS, SDL_Window * window) [viewcontroller.view layoutIfNeeded]; } -void -UIKit_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) +void UIKit_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered) { @autoreleasepool { UIKit_UpdateWindowBorder(_this, window); } } -void -UIKit_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen) +void UIKit_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen) { @autoreleasepool { UIKit_UpdateWindowBorder(_this, window); } } -void -UIKit_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed) +void UIKit_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed) { /* There really isn't a concept of window grab or cursor confinement on iOS */ } -void -UIKit_UpdatePointerLock(_THIS, SDL_Window * window) +void UIKit_UpdatePointerLock(_THIS, SDL_Window *window) { #if !TARGET_OS_TV #if defined(__IPHONE_14_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0 @autoreleasepool { - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; SDL_uikitviewcontroller *viewcontroller = data.viewcontroller; if (@available(iOS 14.0, *)) { [viewcontroller setNeedsUpdateOfPrefersPointerLocked]; @@ -342,12 +330,11 @@ UIKit_UpdatePointerLock(_THIS, SDL_Window * window) #endif /* !TARGET_OS_TV */ } -void -UIKit_DestroyWindow(_THIS, SDL_Window * window) +void UIKit_DestroyWindow(_THIS, SDL_Window *window) { @autoreleasepool { if (window->driverdata != NULL) { - SDL_WindowData *data = (SDL_WindowData *) CFBridgingRelease(window->driverdata); + SDL_WindowData *data = (SDL_WindowData *)CFBridgingRelease(window->driverdata); NSArray *views = nil; [data.viewcontroller stopAnimation]; @@ -371,18 +358,24 @@ UIKit_DestroyWindow(_THIS, SDL_Window * window) window->driverdata = NULL; } -void -UIKit_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h) -{ @autoreleasepool +void UIKit_GetWindowSizeInPixels(_THIS, SDL_Window *window, int *w, int *h) { - SDL_WindowData *windata = (__bridge SDL_WindowData *) window->driverdata; - UIView *view = windata.viewcontroller.view; - CGSize size = view.bounds.size; - CGFloat scale = 1.0; + @autoreleasepool { + SDL_WindowData *windata = (__bridge SDL_WindowData *)window->driverdata; + UIView *view = windata.viewcontroller.view; + CGSize size = view.bounds.size; + CGFloat scale = 1.0; - if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) { - scale = windata.uiwindow.screen.nativeScale; + if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) { + scale = windata.uiwindow.screen.nativeScale; + } + + /* Integer truncation of fractional values matches SDL_uikitmetalview and + * SDL_uikitopenglview. */ + *w = size.width * scale; + *h = size.height * scale; } +} /* Integer truncation of fractional values matches SDL_uikitmetalview and * SDL_uikitopenglview. */ @@ -431,14 +424,14 @@ UIKit_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) #if !TARGET_OS_TV NSUInteger -UIKit_GetSupportedOrientations(SDL_Window * window) +UIKit_GetSupportedOrientations(SDL_Window *window) { const char *hint = SDL_GetHint(SDL_HINT_ORIENTATIONS); NSUInteger validOrientations = UIInterfaceOrientationMaskAll; NSUInteger orientationMask = 0; @autoreleasepool { - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; UIApplication *app = [UIApplication sharedApplication]; /* Get all possible valid orientations. If the app delegate doesn't tell @@ -497,8 +490,7 @@ UIKit_GetSupportedOrientations(SDL_Window * window) } #endif /* !TARGET_OS_TV */ -int -SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam) +int SDL_iPhoneSetAnimationCallback(SDL_Window *window, int interval, void (*callback)(void *), void *callbackParam) { if (!window || !window->driverdata) { return SDL_SetError("Invalid window"); diff --git a/src/video/vita/SDL_vitaframebuffer.c b/src/video/vita/SDL_vitaframebuffer.c index c14700f62..a1b0d5e1a 100644 --- a/src/video/vita/SDL_vitaframebuffer.c +++ b/src/video/vita/SDL_vitaframebuffer.c @@ -26,9 +26,9 @@ #include -#define SCREEN_W 960 -#define SCREEN_H 544 -#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) +#define SCREEN_W 960 +#define SCREEN_H 544 +#define ALIGN(x, a) (((x) + ((a)-1)) & ~((a)-1)) #define DISPLAY_PIXEL_FORMAT SCE_DISPLAY_PIXELFORMAT_A8B8G8R8 void *vita_gpu_alloc(unsigned int type, unsigned int size, SceUID *uid) @@ -36,9 +36,9 @@ void *vita_gpu_alloc(unsigned int type, unsigned int size, SceUID *uid) void *mem; if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW) { - size = ALIGN(size, 256*1024); + size = ALIGN(size, 256 * 1024); } else { - size = ALIGN(size, 4*1024); + size = ALIGN(size, 4 * 1024); } *uid = sceKernelAllocMemBlock("gpu_mem", type, size, NULL); @@ -63,9 +63,9 @@ void vita_gpu_free(SceUID uid) sceKernelFreeMemBlock(uid); } -int VITA_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch) +int VITA_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SceDisplayFrameBuf framebuf; *format = SDL_PIXELFORMAT_ABGR8888; @@ -74,19 +74,18 @@ int VITA_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, vo data->buffer = vita_gpu_alloc( SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, 4 * SCREEN_W * SCREEN_H, - &data->buffer_uid - ); + &data->buffer_uid); // SDL_memset the buffer to black - SDL_memset(data->buffer, 0x0, SCREEN_W*SCREEN_H*4); + SDL_memset(data->buffer, 0x0, SCREEN_W * SCREEN_H * 4); SDL_memset(&framebuf, 0x00, sizeof(SceDisplayFrameBuf)); - framebuf.size = sizeof(SceDisplayFrameBuf); - framebuf.base = data->buffer; - framebuf.pitch = SCREEN_W; + framebuf.size = sizeof(SceDisplayFrameBuf); + framebuf.base = data->buffer; + framebuf.pitch = SCREEN_W; framebuf.pixelformat = DISPLAY_PIXEL_FORMAT; - framebuf.width = SCREEN_W; - framebuf.height = SCREEN_H; + framebuf.width = SCREEN_W; + framebuf.height = SCREEN_H; sceDisplaySetFrameBuf(&framebuf, SCE_DISPLAY_SETBUF_NEXTFRAME); *pixels = data->buffer; @@ -94,15 +93,15 @@ int VITA_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, vo return 0; } -int VITA_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects) +int VITA_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects) { // do nothing return 0; } -void VITA_DestroyWindowFramebuffer(_THIS, SDL_Window * window) +void VITA_DestroyWindowFramebuffer(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; if (data == NULL) { /* The window wasn't fully initialized */ diff --git a/src/video/vita/SDL_vitaframebuffer.h b/src/video/vita/SDL_vitaframebuffer.h index f2d1e1b94..89634c949 100644 --- a/src/video/vita/SDL_vitaframebuffer.h +++ b/src/video/vita/SDL_vitaframebuffer.h @@ -20,8 +20,8 @@ */ #include "../../SDL_internal.h" -extern int VITA_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch); -extern int VITA_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects); -extern void VITA_DestroyWindowFramebuffer(_THIS, SDL_Window * window); +extern int VITA_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch); +extern int VITA_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects); +extern void VITA_DestroyWindowFramebuffer(_THIS, SDL_Window *window); /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/vita/SDL_vitagl_pvr.c b/src/video/vita/SDL_vitagl_pvr.c index 11b4d5db4..23daed4bc 100644 --- a/src/video/vita/SDL_vitagl_pvr.c +++ b/src/video/vita/SDL_vitagl_pvr.c @@ -45,46 +45,45 @@ void getFBSize(int *width, int *height) *height = FB_HEIGHT; } -int -VITA_GL_LoadLibrary(_THIS, const char *path) +int VITA_GL_LoadLibrary(_THIS, const char *path) { PVRSRV_PSP2_APPHINT hint; - char* override = SDL_getenv("VITA_MODULE_PATH"); - char* skip_init = SDL_getenv("VITA_PVR_SKIP_INIT"); - char* default_path = "app0:module"; + char *override = SDL_getenv("VITA_MODULE_PATH"); + char *skip_init = SDL_getenv("VITA_PVR_SKIP_INIT"); + char *default_path = "app0:module"; char target_path[MAX_PATH]; if (skip_init == NULL) // we don't care about actual value { if (override != NULL) { - default_path = override; + default_path = override; } - sceKernelLoadStartModule("vs0:sys/external/libfios2.suprx", 0, NULL, 0, NULL, NULL); - sceKernelLoadStartModule("vs0:sys/external/libc.suprx", 0, NULL, 0, NULL, NULL); + sceKernelLoadStartModule("vs0:sys/external/libfios2.suprx", 0, NULL, 0, NULL, NULL); + sceKernelLoadStartModule("vs0:sys/external/libc.suprx", 0, NULL, 0, NULL, NULL); - SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libGL.suprx"); - sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); + SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libGL.suprx"); + sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); - SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libgpu_es4_ext.suprx"); - sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); + SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libgpu_es4_ext.suprx"); + sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); - SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libIMGEGL.suprx"); - sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); + SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libIMGEGL.suprx"); + sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); - PVRSRVInitializeAppHint(&hint); + PVRSRVInitializeAppHint(&hint); - SDL_snprintf(hint.szGLES1, MAX_PATH, "%s/%s", default_path, "libGLESv1_CM.suprx"); - SDL_snprintf(hint.szGLES2, MAX_PATH, "%s/%s", default_path, "libGLESv2.suprx"); - SDL_snprintf(hint.szWindowSystem, MAX_PATH, "%s/%s", default_path, "libpvrPSP2_WSEGL.suprx"); + SDL_snprintf(hint.szGLES1, MAX_PATH, "%s/%s", default_path, "libGLESv1_CM.suprx"); + SDL_snprintf(hint.szGLES2, MAX_PATH, "%s/%s", default_path, "libGLESv2.suprx"); + SDL_snprintf(hint.szWindowSystem, MAX_PATH, "%s/%s", default_path, "libpvrPSP2_WSEGL.suprx"); - PVRSRVCreateVirtualAppHint(&hint); - } + PVRSRVCreateVirtualAppHint(&hint); +} - return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType) 0, 0); +return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)0, 0); } SDL_GLContext -VITA_GL_CreateContext(_THIS, SDL_Window * window) +VITA_GL_CreateContext(_THIS, SDL_Window *window) { char gl_version[3]; SDL_GLContext context = NULL; @@ -97,7 +96,7 @@ VITA_GL_CreateContext(_THIS, SDL_Window * window) _this->gl_config.minor_version = 0; _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; - context = SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface); + context = SDL_EGL_CreateContext(_this, ((SDL_WindowData *)window->driverdata)->egl_surface); if (context != NULL) { FB_WIDTH = window->w; diff --git a/src/video/vita/SDL_vitagl_pvr_c.h b/src/video/vita/SDL_vitagl_pvr_c.h index 2329d472b..9bbc090ce 100644 --- a/src/video/vita/SDL_vitagl_pvr_c.h +++ b/src/video/vita/SDL_vitagl_pvr_c.h @@ -24,11 +24,10 @@ #include "SDL_vitavideo.h" -extern SDL_GLContext VITA_GL_CreateContext(_THIS, SDL_Window * window); +extern SDL_GLContext VITA_GL_CreateContext(_THIS, SDL_Window *window); extern int VITA_GL_LoadLibrary(_THIS, const char *path); extern void *VITA_GL_GetProcAddress(_THIS, const char *proc); - #endif /* SDL_vitagl_pvr_c_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/vita/SDL_vitagles.c b/src/video/vita/SDL_vitagles.c index f9b6fb6d1..ba78ddeda 100644 --- a/src/video/vita/SDL_vitagles.c +++ b/src/video/vita/SDL_vitagles.c @@ -32,20 +32,19 @@ /*****************************************************************************/ /* SDL OpenGL/OpenGL ES functions */ /*****************************************************************************/ -#define EGLCHK(stmt) \ - do { \ - EGLint err; \ - \ - stmt; \ - err = eglGetError(); \ - if (err != EGL_SUCCESS) { \ - SDL_SetError("EGL error %d", err); \ - return 0; \ - } \ +#define EGLCHK(stmt) \ + do { \ + EGLint err; \ + \ + stmt; \ + err = eglGetError(); \ + if (err != EGL_SUCCESS) { \ + SDL_SetError("EGL error %d", err); \ + return 0; \ + } \ } while (0) -void -VITA_GLES_KeyboardCallback(ScePigletPreSwapData *data) +void VITA_GLES_KeyboardCallback(ScePigletPreSwapData *data) { SceCommonDialogUpdateParam commonDialogParam; SDL_zero(commonDialogParam); @@ -61,11 +60,10 @@ VITA_GLES_KeyboardCallback(ScePigletPreSwapData *data) sceCommonDialogUpdate(&commonDialogParam); } -int -VITA_GLES_LoadLibrary(_THIS, const char *path) +int VITA_GLES_LoadLibrary(_THIS, const char *path) { - pibInit(PIB_SHACCCG | PIB_GET_PROC_ADDR_CORE); - return 0; + pibInit(PIB_SHACCCG | PIB_GET_PROC_ADDR_CORE); + return 0; } void * @@ -74,8 +72,7 @@ VITA_GLES_GetProcAddress(_THIS, const char *proc) return eglGetProcAddress(proc); } -void -VITA_GLES_UnloadLibrary(_THIS) +void VITA_GLES_UnloadLibrary(_THIS) { eglTerminate(_this->gl_data->display); } @@ -84,10 +81,10 @@ static EGLint width = 960; static EGLint height = 544; SDL_GLContext -VITA_GLES_CreateContext(_THIS, SDL_Window * window) +VITA_GLES_CreateContext(_THIS, SDL_Window *window) { - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; + SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata; EGLint attribs[32]; EGLDisplay display; @@ -143,7 +140,6 @@ VITA_GLES_CreateContext(_THIS, SDL_Window * window) return 0; } - EGLCHK(surface = eglCreateWindowSurface(display, config, VITA_WINDOW_960X544, NULL)); EGLCHK(context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs)); @@ -157,25 +153,22 @@ VITA_GLES_CreateContext(_THIS, SDL_Window * window) _this->gl_data->context = context; _this->gl_data->surface = surface; - preSwapCallback = (PFNEGLPIGLETVITASETPRESWAPCALLBACKSCEPROC) eglGetProcAddress("eglPigletVitaSetPreSwapCallbackSCE"); + preSwapCallback = (PFNEGLPIGLETVITASETPRESWAPCALLBACKSCEPROC)eglGetProcAddress("eglPigletVitaSetPreSwapCallbackSCE"); preSwapCallback(VITA_GLES_KeyboardCallback); return context; } -int -VITA_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) +int VITA_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context) { - if (!eglMakeCurrent(_this->gl_data->display, _this->gl_data->surface, - _this->gl_data->surface, _this->gl_data->context)) - { - return SDL_SetError("Unable to make EGL context current"); - } + if (!eglMakeCurrent(_this->gl_data->display, _this->gl_data->surface, + _this->gl_data->surface, _this->gl_data->context)) { + return SDL_SetError("Unable to make EGL context current"); + } return 0; } -int -VITA_GLES_SetSwapInterval(_THIS, int interval) +int VITA_GLES_SetSwapInterval(_THIS, int interval) { EGLBoolean status; status = eglSwapInterval(_this->gl_data->display, interval); @@ -188,14 +181,12 @@ VITA_GLES_SetSwapInterval(_THIS, int interval) return SDL_SetError("Unable to set the EGL swap interval"); } -int -VITA_GLES_GetSwapInterval(_THIS) +int VITA_GLES_GetSwapInterval(_THIS) { return _this->gl_data->swapinterval; } -int -VITA_GLES_SwapWindow(_THIS, SDL_Window * window) +int VITA_GLES_SwapWindow(_THIS, SDL_Window *window) { if (!eglSwapBuffers(_this->gl_data->display, _this->gl_data->surface)) { return SDL_SetError("eglSwapBuffers() failed"); @@ -203,10 +194,9 @@ VITA_GLES_SwapWindow(_THIS, SDL_Window * window) return 0; } -void -VITA_GLES_DeleteContext(_THIS, SDL_GLContext context) +void VITA_GLES_DeleteContext(_THIS, SDL_GLContext context) { - SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata; EGLBoolean status; if (phdata->egl_initialized != SDL_TRUE) { diff --git a/src/video/vita/SDL_vitagles_c.h b/src/video/vita/SDL_vitagles_c.h index 10fd8533a..7f6022d04 100644 --- a/src/video/vita/SDL_vitagles_c.h +++ b/src/video/vita/SDL_vitagles_c.h @@ -22,7 +22,6 @@ #ifndef SDL_vitagles_c_h_ #define SDL_vitagles_c_h_ - #include #include #include @@ -31,27 +30,26 @@ #include "SDL_vitavideo.h" - -typedef struct SDL_GLDriverData { - EGLDisplay display; - EGLContext context; - EGLSurface surface; +typedef struct SDL_GLDriverData +{ + EGLDisplay display; + EGLContext context; + EGLSurface surface; uint32_t swapinterval; -}SDL_GLDriverData; +} SDL_GLDriverData; -extern void * VITA_GLES_GetProcAddress(_THIS, const char *proc); -extern int VITA_GLES_MakeCurrent(_THIS,SDL_Window * window, SDL_GLContext context); +extern void *VITA_GLES_GetProcAddress(_THIS, const char *proc); +extern int VITA_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); extern void VITA_GLES_SwapBuffers(_THIS); -extern int VITA_GLES_SwapWindow(_THIS, SDL_Window * window); -extern SDL_GLContext VITA_GLES_CreateContext(_THIS, SDL_Window * window); +extern int VITA_GLES_SwapWindow(_THIS, SDL_Window *window); +extern SDL_GLContext VITA_GLES_CreateContext(_THIS, SDL_Window *window); extern int VITA_GLES_LoadLibrary(_THIS, const char *path); extern void VITA_GLES_UnloadLibrary(_THIS); extern int VITA_GLES_SetSwapInterval(_THIS, int interval); extern int VITA_GLES_GetSwapInterval(_THIS); - #endif /* SDL_vitagles_c_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/vita/SDL_vitagles_pvr.c b/src/video/vita/SDL_vitagles_pvr.c index 0f1d5f56f..f10e96ecd 100644 --- a/src/video/vita/SDL_vitagles_pvr.c +++ b/src/video/vita/SDL_vitagles_pvr.c @@ -34,68 +34,64 @@ #define MAX_PATH 256 // vita limits are somehow wrong -int -VITA_GLES_LoadLibrary(_THIS, const char *path) +int VITA_GLES_LoadLibrary(_THIS, const char *path) { PVRSRV_PSP2_APPHINT hint; - char* override = SDL_getenv("VITA_MODULE_PATH"); - char* skip_init = SDL_getenv("VITA_PVR_SKIP_INIT"); - char* default_path = "app0:module"; + char *override = SDL_getenv("VITA_MODULE_PATH"); + char *skip_init = SDL_getenv("VITA_PVR_SKIP_INIT"); + char *default_path = "app0:module"; char target_path[MAX_PATH]; if (skip_init == NULL) // we don't care about actual value { if (override != NULL) { - default_path = override; + default_path = override; } - sceKernelLoadStartModule("vs0:sys/external/libfios2.suprx", 0, NULL, 0, NULL, NULL); - sceKernelLoadStartModule("vs0:sys/external/libc.suprx", 0, NULL, 0, NULL, NULL); + sceKernelLoadStartModule("vs0:sys/external/libfios2.suprx", 0, NULL, 0, NULL, NULL); + sceKernelLoadStartModule("vs0:sys/external/libc.suprx", 0, NULL, 0, NULL, NULL); - SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libgpu_es4_ext.suprx"); - sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); + SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libgpu_es4_ext.suprx"); + sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); - SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libIMGEGL.suprx"); - sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); + SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libIMGEGL.suprx"); + sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); - PVRSRVInitializeAppHint(&hint); + PVRSRVInitializeAppHint(&hint); - SDL_snprintf(hint.szGLES1, MAX_PATH, "%s/%s", default_path, "libGLESv1_CM.suprx"); - SDL_snprintf(hint.szGLES2, MAX_PATH, "%s/%s", default_path, "libGLESv2.suprx"); - SDL_snprintf(hint.szWindowSystem, MAX_PATH, "%s/%s", default_path, "libpvrPSP2_WSEGL.suprx"); + SDL_snprintf(hint.szGLES1, MAX_PATH, "%s/%s", default_path, "libGLESv1_CM.suprx"); + SDL_snprintf(hint.szGLES2, MAX_PATH, "%s/%s", default_path, "libGLESv2.suprx"); + SDL_snprintf(hint.szWindowSystem, MAX_PATH, "%s/%s", default_path, "libpvrPSP2_WSEGL.suprx"); - PVRSRVCreateVirtualAppHint(&hint); - } + PVRSRVCreateVirtualAppHint(&hint); +} - return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType) 0, 0); +return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)0, 0); } SDL_GLContext -VITA_GLES_CreateContext(_THIS, SDL_Window * window) +VITA_GLES_CreateContext(_THIS, SDL_Window *window) { - return SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface); + return SDL_EGL_CreateContext(_this, ((SDL_WindowData *)window->driverdata)->egl_surface); } -int -VITA_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) +int VITA_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context) { if (window && context) { - return SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *) window->driverdata)->egl_surface, context); + return SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *)window->driverdata)->egl_surface, context); } else { return SDL_EGL_MakeCurrent(_this, NULL, NULL); } } -int -VITA_GLES_SwapWindow(_THIS, SDL_Window * window) +int VITA_GLES_SwapWindow(_THIS, SDL_Window *window) { SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; if (videodata->ime_active) { sceImeUpdate(); } - return SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface); + return SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *)window->driverdata)->egl_surface); } - #endif /* SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_VITA_PVR */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/vita/SDL_vitagles_pvr_c.h b/src/video/vita/SDL_vitagles_pvr_c.h index c3a13c436..69371982c 100644 --- a/src/video/vita/SDL_vitagles_pvr_c.h +++ b/src/video/vita/SDL_vitagles_pvr_c.h @@ -24,12 +24,11 @@ #include "SDL_vitavideo.h" -extern int VITA_GLES_MakeCurrent(_THIS,SDL_Window * window, SDL_GLContext context); -extern int VITA_GLES_SwapWindow(_THIS, SDL_Window * window); -extern SDL_GLContext VITA_GLES_CreateContext(_THIS, SDL_Window * window); +extern int VITA_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); +extern int VITA_GLES_SwapWindow(_THIS, SDL_Window *window); +extern SDL_GLContext VITA_GLES_CreateContext(_THIS, SDL_Window *window); extern int VITA_GLES_LoadLibrary(_THIS, const char *path); - #endif /* SDL_vitagles_pvr_c_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/vita/SDL_vitakeyboard.c b/src/video/vita/SDL_vitakeyboard.c index 9e5a6387d..e331cf262 100644 --- a/src/video/vita/SDL_vitakeyboard.c +++ b/src/video/vita/SDL_vitakeyboard.c @@ -34,13 +34,12 @@ SceHidKeyboardReport k_reports[SCE_HID_MAX_REPORT]; int keyboard_hid_handle = 0; -Uint8 prev_keys[6] = {0}; +Uint8 prev_keys[6] = { 0 }; Uint8 prev_modifiers = 0; Uint8 locks = 0; Uint8 lock_key_down = 0; -void -VITA_InitKeyboard(void) +void VITA_InitKeyboard(void) { #if defined(SDL_VIDEO_VITA_PVR) sceSysmoduleLoadModule(SCE_SYSMODULE_IME); /** For PVR OSK Support **/ @@ -48,8 +47,7 @@ VITA_InitKeyboard(void) sceHidKeyboardEnumerate(&keyboard_hid_handle, 1); } -void -VITA_PollKeyboard(void) +void VITA_PollKeyboard(void) { // We skip polling keyboard if no window is created if (Vita_Window == NULL) { @@ -57,7 +55,7 @@ VITA_PollKeyboard(void) } if (keyboard_hid_handle > 0) { - int numReports = sceHidKeyboardRead(keyboard_hid_handle, (SceHidKeyboardReport**)&k_reports, SCE_HID_MAX_REPORT); + int numReports = sceHidKeyboardRead(keyboard_hid_handle, (SceHidKeyboardReport **)&k_reports, SCE_HID_MAX_REPORT); if (numReports < 0) { keyboard_hid_handle = 0; @@ -141,7 +139,7 @@ VITA_PollKeyboard(void) } else { SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RCTRL); } - } + } if (changed_modifiers & 0x20) { if (prev_modifiers & 0x20) { SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RSHIFT); diff --git a/src/video/vita/SDL_vitamessagebox.c b/src/video/vita/SDL_vitamessagebox.c index 6fe7048f4..5d9178ba6 100644 --- a/src/video/vita/SDL_vitamessagebox.c +++ b/src/video/vita/SDL_vitamessagebox.c @@ -54,7 +54,7 @@ int VITA_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) SDL_zero(msgParam); SDL_snprintf(message, sizeof(message), "%s\r\n\r\n%s", messageboxdata->title, messageboxdata->message); - msgParam.msg = (const SceChar8*)message; + msgParam.msg = (const SceChar8 *)message; SDL_zero(buttonParam); if (messageboxdata->numbuttons == 3) { diff --git a/src/video/vita/SDL_vitamouse.c b/src/video/vita/SDL_vitamouse.c index 46d3471a3..8d6390b68 100644 --- a/src/video/vita/SDL_vitamouse.c +++ b/src/video/vita/SDL_vitamouse.c @@ -37,14 +37,12 @@ SceHidMouseReport m_reports[SCE_HID_MAX_REPORT]; int mouse_hid_handle = 0; Uint8 prev_buttons = 0; -void -VITA_InitMouse(void) +void VITA_InitMouse(void) { sceHidMouseEnumerate(&mouse_hid_handle, 1); } -void -VITA_PollMouse(void) +void VITA_PollMouse(void) { // We skip polling mouse if no window is created if (Vita_Window == NULL) { @@ -52,7 +50,7 @@ VITA_PollMouse(void) } if (mouse_hid_handle > 0) { - int numReports = sceHidMouseRead(mouse_hid_handle, (SceHidMouseReport**)&m_reports, SCE_HID_MAX_REPORT); + int numReports = sceHidMouseRead(mouse_hid_handle, (SceHidMouseReport **)&m_reports, SCE_HID_MAX_REPORT); if (numReports > 0) { for (int i = 0; i <= numReports - 1; i++) { Uint8 changed_buttons = m_reports[i].buttons ^ prev_buttons; diff --git a/src/video/vita/SDL_vitatouch.c b/src/video/vita/SDL_vitatouch.c index e28dd3d3a..0cf35704b 100644 --- a/src/video/vita/SDL_vitatouch.c +++ b/src/video/vita/SDL_vitatouch.c @@ -37,16 +37,16 @@ SceTouchData touch[SCE_TOUCH_PORT_MAX_NUM]; SDL_FRect area_info[SCE_TOUCH_PORT_MAX_NUM]; -struct{ +struct +{ float min; float range; } force_info[SCE_TOUCH_PORT_MAX_NUM]; -char* disableFrontPoll = NULL; -char* disableBackPoll = NULL; +char *disableFrontPoll = NULL; +char *disableBackPoll = NULL; -void -VITA_InitTouch(void) +void VITA_InitTouch(void) { disableFrontPoll = SDL_getenv("VITA_DISABLE_TOUCH_FRONT"); disableBackPoll = SDL_getenv("VITA_DISABLE_TOUCH_BACK"); @@ -60,10 +60,10 @@ VITA_InitTouch(void) SceTouchPanelInfo panelinfo; sceTouchGetPanelInfo(port, &panelinfo); - area_info[port].x = (float)panelinfo.minAaX; - area_info[port].y = (float)panelinfo.minAaY; - area_info[port].w = (float)(panelinfo.maxAaX - panelinfo.minAaX); - area_info[port].h = (float)(panelinfo.maxAaY - panelinfo.minAaY); + area_info[port].x = (float)panelinfo.minAaX; + area_info[port].y = (float)panelinfo.minAaY; + area_info[port].w = (float)(panelinfo.maxAaX - panelinfo.minAaX); + area_info[port].h = (float)(panelinfo.maxAaY - panelinfo.minAaY); force_info[port].min = (float)panelinfo.minForce; force_info[port].range = (float)(panelinfo.maxForce - panelinfo.minForce); @@ -71,17 +71,16 @@ VITA_InitTouch(void) // Support passing both front and back touch devices in events SDL_AddTouch((SDL_TouchID)0, SDL_TOUCH_DEVICE_DIRECT, "Front"); - SDL_AddTouch((SDL_TouchID)1, SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, "Back"); + SDL_AddTouch((SDL_TouchID)1, SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, "Back"); } -void -VITA_QuitTouch(void) { +void VITA_QuitTouch(void) +{ sceTouchDisableTouchForce(SCE_TOUCH_PORT_FRONT); sceTouchDisableTouchForce(SCE_TOUCH_PORT_BACK); } -void -VITA_PollTouch(void) +void VITA_PollTouch(void) { SDL_FingerID finger_id = 0; int port; @@ -112,34 +111,34 @@ VITA_PollTouch(void) if (touch_old[port].reportNum > 0) { for (int j = 0; j < touch_old[port].reportNum; j++) { - if (touch[port].report[i].id == touch_old[port].report[j].id ) { + if (touch[port].report[i].id == touch_old[port].report[j].id) { finger_down = 1; } } } - + VITA_ConvertTouchXYToSDLXY(&x, &y, touch[port].report[i].x, touch[port].report[i].y, port); - finger_id = (SDL_FingerID) touch[port].report[i].id; + finger_id = (SDL_FingerID)touch[port].report[i].id; // Skip if finger was already previously down if (!finger_down) { // Send an initial touch SDL_SendTouch((SDL_TouchID)port, - finger_id, - Vita_Window, - SDL_TRUE, - x, - y, - force); + finger_id, + Vita_Window, + SDL_TRUE, + x, + y, + force); } // Always send the motion SDL_SendTouchMotion((SDL_TouchID)port, - finger_id, - Vita_Window, - x, - y, - force); + finger_id, + Vita_Window, + x, + y, + force); } } @@ -149,7 +148,7 @@ VITA_PollTouch(void) int finger_up = 1; if (touch[port].reportNum > 0) { for (int j = 0; j < touch[port].reportNum; j++) { - if (touch[port].report[j].id == touch_old[port].report[i].id ) { + if (touch[port].report[j].id == touch_old[port].report[i].id) { finger_up = 0; } } @@ -159,22 +158,23 @@ VITA_PollTouch(void) float y = 0; float force = (touch_old[port].report[i].force - force_info[port].min) / force_info[port].range; VITA_ConvertTouchXYToSDLXY(&x, &y, touch_old[port].report[i].x, touch_old[port].report[i].y, port); - finger_id = (SDL_FingerID) touch_old[port].report[i].id; + finger_id = (SDL_FingerID)touch_old[port].report[i].id; // Finger released from screen SDL_SendTouch((SDL_TouchID)port, - finger_id, - Vita_Window, - SDL_FALSE, - x, - y, - force); + finger_id, + Vita_Window, + SDL_FALSE, + x, + y, + force); } } } } } -void VITA_ConvertTouchXYToSDLXY(float *sdl_x, float *sdl_y, int vita_x, int vita_y, int port) { +void VITA_ConvertTouchXYToSDLXY(float *sdl_x, float *sdl_y, int vita_x, int vita_y, int port) +{ float x = (vita_x - area_info[port].x) / area_info[port].w; float y = (vita_y - area_info[port].y) / area_info[port].h; @@ -188,7 +188,6 @@ void VITA_ConvertTouchXYToSDLXY(float *sdl_x, float *sdl_y, int vita_x, int vita *sdl_y = y; } - #endif /* SDL_VIDEO_DRIVER_VITA */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/vita/SDL_vitavideo.c b/src/video/vita/SDL_vitavideo.c index 34b5c6250..100c3de3e 100644 --- a/src/video/vita/SDL_vitavideo.c +++ b/src/video/vita/SDL_vitavideo.c @@ -41,11 +41,11 @@ #include "SDL_vitaframebuffer.h" #if defined(SDL_VIDEO_VITA_PIB) - #include "SDL_vitagles_c.h" +#include "SDL_vitagles_c.h" #elif defined(SDL_VIDEO_VITA_PVR) - #include "SDL_vitagles_pvr_c.h" +#include "SDL_vitagles_pvr_c.h" #if defined(SDL_VIDEO_VITA_PVR_OGL) - #include "SDL_vitagl_pvr_c.h" +#include "SDL_vitagl_pvr_c.h" #endif #define VITA_GLES_GetProcAddress SDL_EGL_GetProcAddress #define VITA_GLES_UnloadLibrary SDL_EGL_UnloadLibrary @@ -56,20 +56,18 @@ SDL_Window *Vita_Window; -static void -VITA_Destroy(SDL_VideoDevice * device) +static void VITA_Destroy(SDL_VideoDevice *device) { -/* SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */ + /* SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */ SDL_free(device->driverdata); SDL_free(device); -// if (device->driverdata != NULL) { -// device->driverdata = NULL; -// } + // if (device->driverdata != NULL) { + // device->driverdata = NULL; + // } } -static SDL_VideoDevice * -VITA_Create() +static SDL_VideoDevice *VITA_Create() { SDL_VideoDevice *device; SDL_VideoData *phdata; @@ -77,14 +75,14 @@ VITA_Create() SDL_GLDriverData *gldata; #endif /* Initialize SDL_VideoDevice structure */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device == NULL) { SDL_OutOfMemory(); return NULL; } /* Initialize internal VITA specific data */ - phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); + phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); if (phdata == NULL) { SDL_OutOfMemory(); SDL_free(device); @@ -92,7 +90,7 @@ VITA_Create() } #if SDL_VIDEO_VITA_PIB - gldata = (SDL_GLDriverData *) SDL_calloc(1, sizeof(SDL_GLDriverData)); + gldata = (SDL_GLDriverData *)SDL_calloc(1, sizeof(SDL_GLDriverData)); if (gldata == NULL) { SDL_OutOfMemory(); SDL_free(device); @@ -134,26 +132,26 @@ VITA_Create() device->DestroyWindow = VITA_DestroyWindow; device->GetWindowWMInfo = VITA_GetWindowWMInfo; -/* - // Disabled, causes issues on high-framerate updates. SDL still emulates this. - device->CreateWindowFramebuffer = VITA_CreateWindowFramebuffer; - device->UpdateWindowFramebuffer = VITA_UpdateWindowFramebuffer; - device->DestroyWindowFramebuffer = VITA_DestroyWindowFramebuffer; -*/ + /* + // Disabled, causes issues on high-framerate updates. SDL still emulates this. + device->CreateWindowFramebuffer = VITA_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = VITA_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = VITA_DestroyWindowFramebuffer; + */ #if defined(SDL_VIDEO_VITA_PIB) || defined(SDL_VIDEO_VITA_PVR) #if defined(SDL_VIDEO_VITA_PVR_OGL) -if (SDL_getenv("VITA_PVR_OGL") != NULL) { - device->GL_LoadLibrary = VITA_GL_LoadLibrary; - device->GL_CreateContext = VITA_GL_CreateContext; - device->GL_GetProcAddress = VITA_GL_GetProcAddress; -} else { + if (SDL_getenv("VITA_PVR_OGL") != NULL) { + device->GL_LoadLibrary = VITA_GL_LoadLibrary; + device->GL_CreateContext = VITA_GL_CreateContext; + device->GL_GetProcAddress = VITA_GL_GetProcAddress; + } else { #endif - device->GL_LoadLibrary = VITA_GLES_LoadLibrary; - device->GL_CreateContext = VITA_GLES_CreateContext; - device->GL_GetProcAddress = VITA_GLES_GetProcAddress; + device->GL_LoadLibrary = VITA_GLES_LoadLibrary; + device->GL_CreateContext = VITA_GLES_CreateContext; + device->GL_GetProcAddress = VITA_GLES_GetProcAddress; #if defined(SDL_VIDEO_VITA_PVR_OGL) -} + } #endif device->GL_UnloadLibrary = VITA_GLES_UnloadLibrary; @@ -183,13 +181,12 @@ VideoBootStrap VITA_bootstrap = { /*****************************************************************************/ /* SDL Video and Display initialization/handling functions */ /*****************************************************************************/ -int -VITA_VideoInit(_THIS) +int VITA_VideoInit(_THIS) { SDL_VideoDisplay display; SDL_DisplayMode current_mode; #if defined(SDL_VIDEO_VITA_PVR) - char* res = SDL_getenv("VITA_RESOLUTION"); + char *res = SDL_getenv("VITA_RESOLUTION"); #endif SDL_zero(current_mode); @@ -234,26 +231,22 @@ VITA_VideoInit(_THIS) return 1; } -void -VITA_VideoQuit(_THIS) +void VITA_VideoQuit(_THIS) { VITA_QuitTouch(); } -void -VITA_GetDisplayModes(_THIS, SDL_VideoDisplay * display) +void VITA_GetDisplayModes(_THIS, SDL_VideoDisplay *display) { SDL_AddDisplayMode(display, &display->current_mode); } -int -VITA_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +int VITA_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) { return 0; } -int -VITA_CreateWindow(_THIS, SDL_Window * window) +int VITA_CreateWindow(_THIS, SDL_Window *window) { SDL_WindowData *wdata; #if defined(SDL_VIDEO_VITA_PVR) @@ -264,7 +257,7 @@ VITA_CreateWindow(_THIS, SDL_Window * window) #endif /* Allocate window internal data */ - wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); + wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); if (wdata == NULL) { return SDL_OutOfMemory(); } @@ -297,26 +290,26 @@ VITA_CreateWindow(_THIS, SDL_Window * window) win.windowSize = PSP2_WINDOW_960X544; } if ((window->flags & SDL_WINDOW_OPENGL) != 0) { - if (SDL_getenv("VITA_PVR_OGL") != NULL) { - /* Set version to 2.1 and PROFILE to ES */ - temp_major = _this->gl_config.major_version; - temp_minor = _this->gl_config.minor_version; - temp_profile = _this->gl_config.profile_mask; + if (SDL_getenv("VITA_PVR_OGL") != NULL) { + /* Set version to 2.1 and PROFILE to ES */ + temp_major = _this->gl_config.major_version; + temp_minor = _this->gl_config.minor_version; + temp_profile = _this->gl_config.profile_mask; - _this->gl_config.major_version = 2; - _this->gl_config.minor_version = 1; - _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; - } - wdata->egl_surface = SDL_EGL_CreateSurface(_this, &win); - if (wdata->egl_surface == EGL_NO_SURFACE) { - return SDL_SetError("Could not create GLES window surface"); - } - if (SDL_getenv("VITA_PVR_OGL") != NULL) { - /* Revert */ - _this->gl_config.major_version = temp_major; - _this->gl_config.minor_version = temp_minor; - _this->gl_config.profile_mask = temp_profile; - } + _this->gl_config.major_version = 2; + _this->gl_config.minor_version = 1; + _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; + } + wdata->egl_surface = SDL_EGL_CreateSurface(_this, &win); + if (wdata->egl_surface == EGL_NO_SURFACE) { + return SDL_SetError("Could not create GLES window surface"); + } + if (SDL_getenv("VITA_PVR_OGL") != NULL) { + /* Revert */ + _this->gl_config.major_version = temp_major; + _this->gl_config.minor_version = temp_minor; + _this->gl_config.profile_mask = temp_profile; + } } #endif @@ -327,61 +320,48 @@ VITA_CreateWindow(_THIS, SDL_Window * window) return 0; } -int -VITA_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) +int VITA_CreateWindowFrom(_THIS, SDL_Window *window, const void *data) { return -1; } -void -VITA_SetWindowTitle(_THIS, SDL_Window * window) +void VITA_SetWindowTitle(_THIS, SDL_Window *window) { } -void -VITA_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) +void VITA_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon) { } -void -VITA_SetWindowPosition(_THIS, SDL_Window * window) +void VITA_SetWindowPosition(_THIS, SDL_Window *window) { } -void -VITA_SetWindowSize(_THIS, SDL_Window * window) +void VITA_SetWindowSize(_THIS, SDL_Window *window) { } -void -VITA_ShowWindow(_THIS, SDL_Window * window) +void VITA_ShowWindow(_THIS, SDL_Window *window) { } -void -VITA_HideWindow(_THIS, SDL_Window * window) +void VITA_HideWindow(_THIS, SDL_Window *window) { } -void -VITA_RaiseWindow(_THIS, SDL_Window * window) +void VITA_RaiseWindow(_THIS, SDL_Window *window) { } -void -VITA_MaximizeWindow(_THIS, SDL_Window * window) +void VITA_MaximizeWindow(_THIS, SDL_Window *window) { } -void -VITA_MinimizeWindow(_THIS, SDL_Window * window) +void VITA_MinimizeWindow(_THIS, SDL_Window *window) { } -void -VITA_RestoreWindow(_THIS, SDL_Window * window) +void VITA_RestoreWindow(_THIS, SDL_Window *window) { } -void -VITA_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) +void VITA_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed) { } -void -VITA_DestroyWindow(_THIS, SDL_Window * window) +void VITA_DestroyWindow(_THIS, SDL_Window *window) { -// SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; + // SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; SDL_WindowData *data; data = window->driverdata; @@ -421,31 +401,32 @@ SDL_bool VITA_HasScreenKeyboardSupport(_THIS) #define SCE_IME_LANGUAGE_ENGLISH_US SCE_IME_LANGUAGE_ENGLISH #endif -static void utf16_to_utf8(const uint16_t *src, uint8_t *dst) { - int i; - for (i = 0; src[i]; i++) { - if ((src[i] & 0xFF80) == 0) { - *(dst++) = src[i] & 0xFF; - } else if ((src[i] & 0xF800) == 0) { - *(dst++) = ((src[i] >> 6) & 0xFF) | 0xC0; - *(dst++) = (src[i] & 0x3F) | 0x80; - } else if ((src[i] & 0xFC00) == 0xD800 && (src[i + 1] & 0xFC00) == 0xDC00) { - *(dst++) = (((src[i] + 64) >> 8) & 0x3) | 0xF0; - *(dst++) = (((src[i] >> 2) + 16) & 0x3F) | 0x80; - *(dst++) = ((src[i] >> 4) & 0x30) | 0x80 | ((src[i + 1] << 2) & 0xF); - *(dst++) = (src[i + 1] & 0x3F) | 0x80; - i += 1; - } else { - *(dst++) = ((src[i] >> 12) & 0xF) | 0xE0; - *(dst++) = ((src[i] >> 6) & 0x3F) | 0x80; - *(dst++) = (src[i] & 0x3F) | 0x80; +static void utf16_to_utf8(const uint16_t *src, uint8_t *dst) +{ + int i; + for (i = 0; src[i]; i++) { + if ((src[i] & 0xFF80) == 0) { + *(dst++) = src[i] & 0xFF; + } else if ((src[i] & 0xF800) == 0) { + *(dst++) = ((src[i] >> 6) & 0xFF) | 0xC0; + *(dst++) = (src[i] & 0x3F) | 0x80; + } else if ((src[i] & 0xFC00) == 0xD800 && (src[i + 1] & 0xFC00) == 0xDC00) { + *(dst++) = (((src[i] + 64) >> 8) & 0x3) | 0xF0; + *(dst++) = (((src[i] >> 2) + 16) & 0x3F) | 0x80; + *(dst++) = ((src[i] >> 4) & 0x30) | 0x80 | ((src[i + 1] << 2) & 0xF); + *(dst++) = (src[i + 1] & 0x3F) | 0x80; + i += 1; + } else { + *(dst++) = ((src[i] >> 12) & 0xF) | 0xE0; + *(dst++) = ((src[i] >> 6) & 0x3F) | 0x80; + *(dst++) = (src[i] & 0x3F) | 0x80; + } } - } - *dst = '\0'; + *dst = '\0'; } -#if defined (SDL_VIDEO_VITA_PVR) +#if defined(SDL_VIDEO_VITA_PVR) SceWChar16 libime_out[SCE_IME_MAX_PREEDIT_LENGTH + SCE_IME_MAX_TEXT_LENGTH + 1]; char libime_initval[8] = { 1 }; SceImeCaret caret_rev; @@ -466,7 +447,7 @@ void VITA_ImeEventHandler(void *arg, const SceImeEventData *e) SDL_SendKeyboardKeyAutoRelease(SDL_SCANCODE_SPACE); } else { utf16_to_utf8((SceWChar16 *)&libime_out[1], utf8_buffer); - SDL_SendKeyboardText((const char*)utf8_buffer); + SDL_SendKeyboardText((const char *)utf8_buffer); } SDL_memset(&caret_rev, 0, sizeof(SceImeCaret)); SDL_memset(libime_out, 0, ((SCE_IME_MAX_PREEDIT_LENGTH + SCE_IME_MAX_TEXT_LENGTH + 1) * sizeof(SceWChar16))); @@ -554,13 +535,13 @@ void VITA_HideScreenKeyboard(_THIS, SDL_Window *window) SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus(); switch (dialogStatus) { - default: - case SCE_COMMON_DIALOG_STATUS_NONE: - case SCE_COMMON_DIALOG_STATUS_RUNNING: - break; - case SCE_COMMON_DIALOG_STATUS_FINISHED: - sceImeDialogTerm(); - break; + default: + case SCE_COMMON_DIALOG_STATUS_NONE: + case SCE_COMMON_DIALOG_STATUS_RUNNING: + break; + case SCE_COMMON_DIALOG_STATUS_FINISHED: + sceImeDialogTerm(); + break; } videodata->ime_active = SDL_FALSE; @@ -597,7 +578,7 @@ void VITA_PumpEvents(_THIS) if (videodata->ime_active == SDL_TRUE) { // update IME status. Terminate, if finished SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus(); - if (dialogStatus == SCE_COMMON_DIALOG_STATUS_FINISHED) { + if (dialogStatus == SCE_COMMON_DIALOG_STATUS_FINISHED) { uint8_t utf8_buffer[SCE_IME_DIALOG_MAX_TEXT_LENGTH]; SceImeDialogResult result; @@ -608,7 +589,7 @@ void VITA_PumpEvents(_THIS) utf16_to_utf8(videodata->ime_buffer, utf8_buffer); // Send SDL event - SDL_SendKeyboardText((const char*)utf8_buffer); + SDL_SendKeyboardText((const char *)utf8_buffer); // Send enter key only on enter if (result.button == SCE_IME_DIALOG_BUTTON_ENTER) { @@ -619,7 +600,6 @@ void VITA_PumpEvents(_THIS) videodata->ime_active = SDL_FALSE; } - } #endif } @@ -627,4 +607,3 @@ void VITA_PumpEvents(_THIS) #endif /* SDL_VIDEO_DRIVER_VITA */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/video/vita/SDL_vitavideo.h b/src/video/vita/SDL_vitavideo.h index 9fdf7e69c..1dae0d62f 100644 --- a/src/video/vita/SDL_vitavideo.h +++ b/src/video/vita/SDL_vitavideo.h @@ -33,33 +33,30 @@ typedef struct SDL_VideoData { - SDL_bool egl_initialized; /* OpenGL device initialization status */ - uint32_t egl_refcount; /* OpenGL reference count */ + SDL_bool egl_initialized; /* OpenGL device initialization status */ + uint32_t egl_refcount; /* OpenGL reference count */ SceWChar16 ime_buffer[SCE_IME_DIALOG_MAX_TEXT_LENGTH]; SDL_bool ime_active; } SDL_VideoData; - typedef struct SDL_DisplayData { } SDL_DisplayData; - typedef struct SDL_WindowData { SDL_bool uses_gles; SceUID buffer_uid; - void* buffer; + void *buffer; #if defined(SDL_VIDEO_VITA_PVR) EGLSurface egl_surface; EGLContext egl_context; #endif } SDL_WindowData; -extern SDL_Window * Vita_Window; - +extern SDL_Window *Vita_Window; /****************************************************************************/ /* SDL_VideoDevice functions declaration */ @@ -68,22 +65,22 @@ extern SDL_Window * Vita_Window; /* Display and window functions */ int VITA_VideoInit(_THIS); void VITA_VideoQuit(_THIS); -void VITA_GetDisplayModes(_THIS, SDL_VideoDisplay * display); -int VITA_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); -int VITA_CreateWindow(_THIS, SDL_Window * window); -int VITA_CreateWindowFrom(_THIS, SDL_Window * window, const void *data); -void VITA_SetWindowTitle(_THIS, SDL_Window * window); -void VITA_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon); -void VITA_SetWindowPosition(_THIS, SDL_Window * window); -void VITA_SetWindowSize(_THIS, SDL_Window * window); -void VITA_ShowWindow(_THIS, SDL_Window * window); -void VITA_HideWindow(_THIS, SDL_Window * window); -void VITA_RaiseWindow(_THIS, SDL_Window * window); -void VITA_MaximizeWindow(_THIS, SDL_Window * window); -void VITA_MinimizeWindow(_THIS, SDL_Window * window); -void VITA_RestoreWindow(_THIS, SDL_Window * window); -void VITA_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed); -void VITA_DestroyWindow(_THIS, SDL_Window * window); +void VITA_GetDisplayModes(_THIS, SDL_VideoDisplay *display); +int VITA_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode); +int VITA_CreateWindow(_THIS, SDL_Window *window); +int VITA_CreateWindowFrom(_THIS, SDL_Window *window, const void *data); +void VITA_SetWindowTitle(_THIS, SDL_Window *window); +void VITA_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon); +void VITA_SetWindowPosition(_THIS, SDL_Window *window); +void VITA_SetWindowSize(_THIS, SDL_Window *window); +void VITA_ShowWindow(_THIS, SDL_Window *window); +void VITA_HideWindow(_THIS, SDL_Window *window); +void VITA_RaiseWindow(_THIS, SDL_Window *window); +void VITA_MaximizeWindow(_THIS, SDL_Window *window); +void VITA_MinimizeWindow(_THIS, SDL_Window *window); +void VITA_RestoreWindow(_THIS, SDL_Window *window); +void VITA_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed); +void VITA_DestroyWindow(_THIS, SDL_Window *window); /* Window manager function */ SDL_bool VITA_GetWindowWMInfo(_THIS, SDL_Window * window, @@ -93,7 +90,7 @@ SDL_bool VITA_GetWindowWMInfo(_THIS, SDL_Window * window, #if defined(SDL_VIDEO_VITA_PVR_OGL) /* OpenGL functions */ int VITA_GL_LoadLibrary(_THIS, const char *path); -SDL_GLContext VITA_GL_CreateContext(_THIS, SDL_Window * window); +SDL_GLContext VITA_GL_CreateContext(_THIS, SDL_Window *window); void *VITA_GL_GetProcAddress(_THIS, const char *proc); #endif @@ -101,11 +98,11 @@ void *VITA_GL_GetProcAddress(_THIS, const char *proc); int VITA_GLES_LoadLibrary(_THIS, const char *path); void *VITA_GLES_GetProcAddress(_THIS, const char *proc); void VITA_GLES_UnloadLibrary(_THIS); -SDL_GLContext VITA_GLES_CreateContext(_THIS, SDL_Window * window); -int VITA_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); +SDL_GLContext VITA_GLES_CreateContext(_THIS, SDL_Window *window); +int VITA_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); int VITA_GLES_SetSwapInterval(_THIS, int interval); int VITA_GLES_GetSwapInterval(_THIS); -int VITA_GLES_SwapWindow(_THIS, SDL_Window * window); +int VITA_GLES_SwapWindow(_THIS, SDL_Window *window); void VITA_GLES_DeleteContext(_THIS, SDL_GLContext context); #endif diff --git a/src/video/vivante/SDL_vivanteopengles.c b/src/video/vivante/SDL_vivanteopengles.c index 42888d6a8..77cedfeae 100644 --- a/src/video/vivante/SDL_vivanteopengles.c +++ b/src/video/vivante/SDL_vivanteopengles.c @@ -27,8 +27,7 @@ /* EGL implementation of SDL OpenGL support */ -int -VIVANTE_GLES_LoadLibrary(_THIS, const char *path) +int VIVANTE_GLES_LoadLibrary(_THIS, const char *path) { SDL_DisplayData *displaydata; @@ -38,10 +37,9 @@ VIVANTE_GLES_LoadLibrary(_THIS, const char *path) } SDL_EGL_CreateContext_impl(VIVANTE) -SDL_EGL_SwapWindow_impl(VIVANTE) -SDL_EGL_MakeCurrent_impl(VIVANTE) + SDL_EGL_SwapWindow_impl(VIVANTE) + SDL_EGL_MakeCurrent_impl(VIVANTE) #endif /* SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL */ -/* vi: set ts=4 sw=4 expandtab: */ - + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/vivante/SDL_vivanteopengles.h b/src/video/vivante/SDL_vivanteopengles.h index dce74ae6b..652ca1c66 100644 --- a/src/video/vivante/SDL_vivanteopengles.h +++ b/src/video/vivante/SDL_vivanteopengles.h @@ -34,12 +34,12 @@ #define VIVANTE_GLES_UnloadLibrary SDL_EGL_UnloadLibrary #define VIVANTE_GLES_SetSwapInterval SDL_EGL_SetSwapInterval #define VIVANTE_GLES_GetSwapInterval SDL_EGL_GetSwapInterval -#define VIVANTE_GLES_DeleteContext SDL_EGL_DeleteContext +#define VIVANTE_GLES_DeleteContext SDL_EGL_DeleteContext extern int VIVANTE_GLES_LoadLibrary(_THIS, const char *path); -extern SDL_GLContext VIVANTE_GLES_CreateContext(_THIS, SDL_Window * window); -extern int VIVANTE_GLES_SwapWindow(_THIS, SDL_Window * window); -extern int VIVANTE_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); +extern SDL_GLContext VIVANTE_GLES_CreateContext(_THIS, SDL_Window *window); +extern int VIVANTE_GLES_SwapWindow(_THIS, SDL_Window *window); +extern int VIVANTE_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); #endif /* SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL */ diff --git a/src/video/vivante/SDL_vivanteplatform.c b/src/video/vivante/SDL_vivanteplatform.c index 36d6822b4..de1fa3e35 100644 --- a/src/video/vivante/SDL_vivanteplatform.c +++ b/src/video/vivante/SDL_vivanteplatform.c @@ -26,8 +26,7 @@ #ifdef VIVANTE_PLATFORM_GENERIC -int -VIVANTE_SetupPlatform(_THIS) +int VIVANTE_SetupPlatform(_THIS) { return 0; } @@ -37,13 +36,11 @@ char *VIVANTE_GetDisplayName(_THIS) return NULL; } -void -VIVANTE_UpdateDisplayScale(_THIS) +void VIVANTE_UpdateDisplayScale(_THIS) { } -void -VIVANTE_CleanupPlatform(_THIS) +void VIVANTE_CleanupPlatform(_THIS) { } diff --git a/src/video/vivante/SDL_vivantevideo.c b/src/video/vivante/SDL_vivantevideo.c index 3b18b7db8..330c1e973 100644 --- a/src/video/vivante/SDL_vivantevideo.c +++ b/src/video/vivante/SDL_vivantevideo.c @@ -39,9 +39,7 @@ #include "SDL_vivanteopengles.h" #include "SDL_vivantevulkan.h" - -static void -VIVANTE_Destroy(SDL_VideoDevice * device) +static void VIVANTE_Destroy(SDL_VideoDevice *device) { if (device->driverdata != NULL) { SDL_free(device->driverdata); @@ -49,21 +47,20 @@ VIVANTE_Destroy(SDL_VideoDevice * device) } } -static SDL_VideoDevice * -VIVANTE_Create() +static SDL_VideoDevice *VIVANTE_Create() { SDL_VideoDevice *device; SDL_VideoData *data; /* Initialize SDL_VideoDevice structure */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device == NULL) { SDL_OutOfMemory(); return NULL; } /* Initialize internal data */ - data = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); + data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); if (data == NULL) { SDL_OutOfMemory(); SDL_free(device); @@ -126,8 +123,7 @@ VideoBootStrap VIVANTE_bootstrap = { /* SDL Video and Display initialization/handling functions */ /*****************************************************************************/ -static int -VIVANTE_AddVideoDisplays(_THIS) +static int VIVANTE_AddVideoDisplays(_THIS) { SDL_VideoData *videodata = _this->driverdata; SDL_VideoDisplay display; @@ -136,7 +132,7 @@ VIVANTE_AddVideoDisplays(_THIS) int pitch = 0, bpp = 0; unsigned long pixels = 0; - data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData)); + data = (SDL_DisplayData *)SDL_calloc(1, sizeof(SDL_DisplayData)); if (data == NULL) { return SDL_OutOfMemory(); } @@ -152,8 +148,7 @@ VIVANTE_AddVideoDisplays(_THIS) videodata->fbGetDisplayInfo(data->native_display, ¤t_mode.w, ¤t_mode.h, &pixels, &pitch, &bpp); #endif /* SDL_VIDEO_DRIVER_VIVANTE_VDK */ - switch (bpp) - { + switch (bpp) { default: /* Is another format used? */ case 32: current_mode.format = SDL_PIXELFORMAT_ARGB8888; @@ -174,8 +169,7 @@ VIVANTE_AddVideoDisplays(_THIS) return 0; } -int -VIVANTE_VideoInit(_THIS) +int VIVANTE_VideoInit(_THIS) { SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; @@ -192,9 +186,10 @@ VIVANTE_VideoInit(_THIS) return -1; } } -#define LOAD_FUNC(NAME) \ +#define LOAD_FUNC(NAME) \ videodata->NAME = SDL_LoadFunction(videodata->egl_handle, #NAME); \ - if (!videodata->NAME) return -1; + if (!videodata->NAME) \ + return -1; LOAD_FUNC(fbGetDisplay); LOAD_FUNC(fbGetDisplayByIndex); @@ -226,8 +221,7 @@ VIVANTE_VideoInit(_THIS) return 0; } -void -VIVANTE_VideoQuit(_THIS) +void VIVANTE_VideoQuit(_THIS) { SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; @@ -250,21 +244,18 @@ VIVANTE_VideoQuit(_THIS) #endif } -void -VIVANTE_GetDisplayModes(_THIS, SDL_VideoDisplay * display) +void VIVANTE_GetDisplayModes(_THIS, SDL_VideoDisplay *display) { /* Only one display mode available, the current one */ SDL_AddDisplayMode(display, &display->current_mode); } -int -VIVANTE_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +int VIVANTE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) { return 0; } -int -VIVANTE_CreateWindow(_THIS, SDL_Window * window) +int VIVANTE_CreateWindow(_THIS, SDL_Window *window) { SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; SDL_DisplayData *displaydata; @@ -273,7 +264,7 @@ VIVANTE_CreateWindow(_THIS, SDL_Window * window) displaydata = SDL_GetDisplayDriverData(0); /* Allocate window internal data */ - data = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); + data = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); if (data == NULL) { return SDL_OutOfMemory(); } @@ -305,8 +296,7 @@ VIVANTE_CreateWindow(_THIS, SDL_Window * window) return 0; } -void -VIVANTE_DestroyWindow(_THIS, SDL_Window * window) +void VIVANTE_DestroyWindow(_THIS, SDL_Window *window) { SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; SDL_WindowData *data; @@ -332,8 +322,7 @@ VIVANTE_DestroyWindow(_THIS, SDL_Window * window) window->driverdata = NULL; } -void -VIVANTE_SetWindowTitle(_THIS, SDL_Window * window) +void VIVANTE_SetWindowTitle(_THIS, SDL_Window *window) { #if SDL_VIDEO_DRIVER_VIVANTE_VDK SDL_WindowData *data = window->driverdata; @@ -341,20 +330,17 @@ VIVANTE_SetWindowTitle(_THIS, SDL_Window * window) #endif } -void -VIVANTE_SetWindowPosition(_THIS, SDL_Window * window) +void VIVANTE_SetWindowPosition(_THIS, SDL_Window *window) { /* FIXME */ } -void -VIVANTE_SetWindowSize(_THIS, SDL_Window * window) +void VIVANTE_SetWindowSize(_THIS, SDL_Window *window) { /* FIXME */ } -void -VIVANTE_ShowWindow(_THIS, SDL_Window * window) +void VIVANTE_ShowWindow(_THIS, SDL_Window *window) { #if SDL_VIDEO_DRIVER_VIVANTE_VDK SDL_WindowData *data = window->driverdata; @@ -364,8 +350,7 @@ VIVANTE_ShowWindow(_THIS, SDL_Window * window) SDL_SetKeyboardFocus(window); } -void -VIVANTE_HideWindow(_THIS, SDL_Window * window) +void VIVANTE_HideWindow(_THIS, SDL_Window *window) { #if SDL_VIDEO_DRIVER_VIVANTE_VDK SDL_WindowData *data = window->driverdata; @@ -377,9 +362,9 @@ VIVANTE_HideWindow(_THIS, SDL_Window * window) /* SDL Window Manager function */ /*****************************************************************************/ SDL_bool -VIVANTE_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) +VIVANTE_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_DisplayData *displaydata = SDL_GetDisplayDriverData(0); if (info->version.major == SDL_MAJOR_VERSION) { diff --git a/src/video/vivante/SDL_vivantevideo.h b/src/video/vivante/SDL_vivantevideo.h index ae4a8e142..97e239013 100644 --- a/src/video/vivante/SDL_vivantevideo.h +++ b/src/video/vivante/SDL_vivantevideo.h @@ -39,15 +39,15 @@ typedef struct SDL_VideoData vdkPrivate vdk_private; #else void *egl_handle; /* EGL shared library handle */ - EGLNativeDisplayType (EGLAPIENTRY *fbGetDisplay)(void *context); - EGLNativeDisplayType (EGLAPIENTRY *fbGetDisplayByIndex)(int DisplayIndex); - void (EGLAPIENTRY *fbGetDisplayGeometry)(EGLNativeDisplayType Display, int *Width, int *Height); - void (EGLAPIENTRY *fbGetDisplayInfo)(EGLNativeDisplayType Display, int *Width, int *Height, unsigned long *Physical, int *Stride, int *BitsPerPixel); - void (EGLAPIENTRY *fbDestroyDisplay)(EGLNativeDisplayType Display); - EGLNativeWindowType (EGLAPIENTRY *fbCreateWindow)(EGLNativeDisplayType Display, int X, int Y, int Width, int Height); - void (EGLAPIENTRY *fbGetWindowGeometry)(EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height); - void (EGLAPIENTRY *fbGetWindowInfo)(EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height, int *BitsPerPixel, unsigned int *Offset); - void (EGLAPIENTRY *fbDestroyWindow)(EGLNativeWindowType Window); + EGLNativeDisplayType(EGLAPIENTRY *fbGetDisplay)(void *context); + EGLNativeDisplayType(EGLAPIENTRY *fbGetDisplayByIndex)(int DisplayIndex); + void(EGLAPIENTRY *fbGetDisplayGeometry)(EGLNativeDisplayType Display, int *Width, int *Height); + void(EGLAPIENTRY *fbGetDisplayInfo)(EGLNativeDisplayType Display, int *Width, int *Height, unsigned long *Physical, int *Stride, int *BitsPerPixel); + void(EGLAPIENTRY *fbDestroyDisplay)(EGLNativeDisplayType Display); + EGLNativeWindowType(EGLAPIENTRY *fbCreateWindow)(EGLNativeDisplayType Display, int X, int Y, int Width, int Height); + void(EGLAPIENTRY *fbGetWindowGeometry)(EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height); + void(EGLAPIENTRY *fbGetWindowInfo)(EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height, int *BitsPerPixel, unsigned int *Offset); + void(EGLAPIENTRY *fbDestroyWindow)(EGLNativeWindowType Window); #endif } SDL_VideoData; @@ -69,15 +69,15 @@ typedef struct SDL_WindowData /* Display and window functions */ int VIVANTE_VideoInit(_THIS); void VIVANTE_VideoQuit(_THIS); -void VIVANTE_GetDisplayModes(_THIS, SDL_VideoDisplay * display); -int VIVANTE_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); -int VIVANTE_CreateWindow(_THIS, SDL_Window * window); -void VIVANTE_SetWindowTitle(_THIS, SDL_Window * window); -void VIVANTE_SetWindowPosition(_THIS, SDL_Window * window); -void VIVANTE_SetWindowSize(_THIS, SDL_Window * window); -void VIVANTE_ShowWindow(_THIS, SDL_Window * window); -void VIVANTE_HideWindow(_THIS, SDL_Window * window); -void VIVANTE_DestroyWindow(_THIS, SDL_Window * window); +void VIVANTE_GetDisplayModes(_THIS, SDL_VideoDisplay *display); +int VIVANTE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode); +int VIVANTE_CreateWindow(_THIS, SDL_Window *window); +void VIVANTE_SetWindowTitle(_THIS, SDL_Window *window); +void VIVANTE_SetWindowPosition(_THIS, SDL_Window *window); +void VIVANTE_SetWindowSize(_THIS, SDL_Window *window); +void VIVANTE_ShowWindow(_THIS, SDL_Window *window); +void VIVANTE_HideWindow(_THIS, SDL_Window *window); +void VIVANTE_DestroyWindow(_THIS, SDL_Window *window); /* Window manager function */ SDL_bool VIVANTE_GetWindowWMInfo(_THIS, SDL_Window * window, diff --git a/src/video/vivante/SDL_vivantevulkan.c b/src/video/vivante/SDL_vivantevulkan.c index 7935cd32a..9dcfb4284 100644 --- a/src/video/vivante/SDL_vivantevulkan.c +++ b/src/video/vivante/SDL_vivantevulkan.c @@ -87,8 +87,7 @@ int VIVANTE_Vulkan_LoadLibrary(_THIS, const char *path) if (extensions == NULL) { goto fail; } - for (i = 0; i < extensionCount; i++) - { + for (i = 0; i < extensionCount; i++) { if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { hasSurfaceExtension = SDL_TRUE; } else if (SDL_strcmp(VK_KHR_DISPLAY_EXTENSION_NAME, extensions[i].extensionName) == 0) { @@ -97,12 +96,10 @@ int VIVANTE_Vulkan_LoadLibrary(_THIS, const char *path) } SDL_free(extensions); if (!hasSurfaceExtension) { - SDL_SetError("Installed Vulkan doesn't implement the " - VK_KHR_SURFACE_EXTENSION_NAME " extension"); + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_SURFACE_EXTENSION_NAME " extension"); goto fail; } else if (!hasDisplayExtension) { - SDL_SetError("Installed Vulkan doesn't implement the " - VK_KHR_DISPLAY_EXTENSION_NAME "extension"); + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_DISPLAY_EXTENSION_NAME "extension"); goto fail; } return 0; @@ -122,9 +119,9 @@ void VIVANTE_Vulkan_UnloadLibrary(_THIS) } SDL_bool VIVANTE_Vulkan_GetInstanceExtensions(_THIS, - SDL_Window *window, - unsigned *count, - const char **names) + SDL_Window *window, + unsigned *count, + const char **names) { static const char *const extensionsForVivante[] = { VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_DISPLAY_EXTENSION_NAME @@ -134,14 +131,14 @@ SDL_bool VIVANTE_Vulkan_GetInstanceExtensions(_THIS, return SDL_FALSE; } return SDL_Vulkan_GetInstanceExtensions_Helper( - count, names, SDL_arraysize(extensionsForVivante), - extensionsForVivante); + count, names, SDL_arraysize(extensionsForVivante), + extensionsForVivante); } SDL_bool VIVANTE_Vulkan_CreateSurface(_THIS, - SDL_Window *window, - VkInstance instance, - VkSurfaceKHR *surface) + SDL_Window *window, + VkInstance instance, + VkSurfaceKHR *surface) { if (!_this->vulkan_config.loader_handle) { SDL_SetError("Vulkan is not loaded"); @@ -153,4 +150,3 @@ SDL_bool VIVANTE_Vulkan_CreateSurface(_THIS, #endif /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/video/vivante/SDL_vivantevulkan.h b/src/video/vivante/SDL_vivantevulkan.h index 0be68fae7..b514cd97a 100644 --- a/src/video/vivante/SDL_vivantevulkan.h +++ b/src/video/vivante/SDL_vivantevulkan.h @@ -32,22 +32,21 @@ #include "../SDL_vulkan_internal.h" #include "../SDL_sysvideo.h" -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_VIVANTE +#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_VIVANTE int VIVANTE_Vulkan_LoadLibrary(_THIS, const char *path); void VIVANTE_Vulkan_UnloadLibrary(_THIS); SDL_bool VIVANTE_Vulkan_GetInstanceExtensions(_THIS, - SDL_Window *window, - unsigned *count, - const char **names); + SDL_Window *window, + unsigned *count, + const char **names); SDL_bool VIVANTE_Vulkan_CreateSurface(_THIS, - SDL_Window *window, - VkInstance instance, - VkSurfaceKHR *surface); + SDL_Window *window, + VkInstance instance, + VkSurfaceKHR *surface); #endif #endif /* SDL_vivantevulkan_h_ */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/video/wayland/SDL_waylandclipboard.c b/src/video/wayland/SDL_waylandclipboard.c index ff19639f7..efdcc1701 100644 --- a/src/video/wayland/SDL_waylandclipboard.c +++ b/src/video/wayland/SDL_waylandclipboard.c @@ -26,8 +26,7 @@ #include "SDL_waylandevents_c.h" #include "SDL_waylandclipboard.h" -int -Wayland_SetClipboardText(_THIS, const char *text) +int Wayland_SetClipboardText(_THIS, const char *text) { SDL_VideoData *video_data = NULL; SDL_WaylandDataDevice *data_device = NULL; @@ -41,7 +40,7 @@ Wayland_SetClipboardText(_THIS, const char *text) if (video_data->input != NULL && video_data->input->data_device != NULL) { data_device = video_data->input->data_device; if (text[0] != '\0') { - SDL_WaylandDataSource* source = Wayland_data_source_create(_this); + SDL_WaylandDataSource *source = Wayland_data_source_create(_this); Wayland_data_source_add_data(source, TEXT_MIME, text, SDL_strlen(text)); @@ -58,8 +57,7 @@ Wayland_SetClipboardText(_THIS, const char *text) return status; } -int -Wayland_SetPrimarySelectionText(_THIS, const char *text) +int Wayland_SetPrimarySelectionText(_THIS, const char *text) { SDL_VideoData *video_data = NULL; SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL; @@ -73,7 +71,7 @@ Wayland_SetPrimarySelectionText(_THIS, const char *text) if (video_data->input != NULL && video_data->input->primary_selection_device != NULL) { primary_selection_device = video_data->input->primary_selection_device; if (text[0] != '\0') { - SDL_WaylandPrimarySelectionSource* source = Wayland_primary_selection_source_create(_this); + SDL_WaylandPrimarySelectionSource *source = Wayland_primary_selection_source_create(_this); Wayland_primary_selection_source_add_data(source, TEXT_MIME, text, SDL_strlen(text)); @@ -112,7 +110,7 @@ Wayland_GetClipboardText(_THIS) text = Wayland_data_source_get_data(data_device->selection_source, &length, TEXT_MIME, SDL_TRUE); } else if (Wayland_data_offer_has_mime( - data_device->selection_offer, TEXT_MIME)) { + data_device->selection_offer, TEXT_MIME)) { text = Wayland_data_offer_receive(data_device->selection_offer, &length, TEXT_MIME, SDL_TRUE); } @@ -147,7 +145,7 @@ Wayland_GetPrimarySelectionText(_THIS) text = Wayland_primary_selection_source_get_data(primary_selection_device->selection_source, &length, TEXT_MIME, SDL_TRUE); } else if (Wayland_primary_selection_offer_has_mime( - primary_selection_device->selection_offer, TEXT_MIME)) { + primary_selection_device->selection_offer, TEXT_MIME)) { text = Wayland_primary_selection_offer_receive(primary_selection_device->selection_offer, &length, TEXT_MIME, SDL_TRUE); } diff --git a/src/video/wayland/SDL_waylanddatamanager.c b/src/video/wayland/SDL_waylanddatamanager.c index 63e9d489c..9353caa53 100644 --- a/src/video/wayland/SDL_waylanddatamanager.c +++ b/src/video/wayland/SDL_waylanddatamanager.c @@ -41,7 +41,7 @@ #define PIPE_MS_TIMEOUT 14 static ssize_t -write_pipe(int fd, const void* buffer, size_t total_length, size_t *pos) +write_pipe(int fd, const void *buffer, size_t total_length, size_t *pos) { int ready = 0; ssize_t bytes_written = 0; @@ -49,7 +49,7 @@ write_pipe(int fd, const void* buffer, size_t total_length, size_t *pos) sigset_t sig_set; sigset_t old_sig_set; - struct timespec zerotime = {0}; + struct timespec zerotime = { 0 }; ready = SDL_IOReady(fd, SDL_IOR_WRITE, PIPE_MS_TIMEOUT); @@ -68,7 +68,7 @@ write_pipe(int fd, const void* buffer, size_t total_length, size_t *pos) bytes_written = SDL_SetError("Pipe select error"); } else { if (length > 0) { - bytes_written = write(fd, (Uint8*)buffer + *pos, SDL_min(length, PIPE_BUF)); + bytes_written = write(fd, (Uint8 *)buffer + *pos, SDL_min(length, PIPE_BUF)); } if (bytes_written > 0) { @@ -88,10 +88,10 @@ write_pipe(int fd, const void* buffer, size_t total_length, size_t *pos) } static ssize_t -read_pipe(int fd, void** buffer, size_t* total_length, SDL_bool null_terminate) +read_pipe(int fd, void **buffer, size_t *total_length, SDL_bool null_terminate) { int ready = 0; - void* output_buffer = NULL; + void *output_buffer = NULL; char temp[PIPE_BUF]; size_t new_buffer_length = 0; ssize_t bytes_read = 0; @@ -126,10 +126,10 @@ read_pipe(int fd, void** buffer, size_t* total_length, SDL_bool null_terminate) if (output_buffer == NULL) { bytes_read = SDL_OutOfMemory(); } else { - SDL_memcpy((Uint8*)output_buffer + pos, temp, bytes_read); + SDL_memcpy((Uint8 *)output_buffer + pos, temp, bytes_read); if (null_terminate == SDL_TRUE) { - SDL_memset((Uint8*)output_buffer + (new_buffer_length - 1), 0, 1); + SDL_memset((Uint8 *)output_buffer + (new_buffer_length - 1), 0, 1); } *buffer = output_buffer; @@ -141,14 +141,14 @@ read_pipe(int fd, void** buffer, size_t* total_length, SDL_bool null_terminate) #define MIME_LIST_SIZE 4 -static const char* mime_conversion_list[MIME_LIST_SIZE][2] = { - {"text/plain", TEXT_MIME}, - {"TEXT", TEXT_MIME}, - {"UTF8_STRING", TEXT_MIME}, - {"STRING", TEXT_MIME} +static const char *mime_conversion_list[MIME_LIST_SIZE][2] = { + { "text/plain", TEXT_MIME }, + { "TEXT", TEXT_MIME }, + { "UTF8_STRING", TEXT_MIME }, + { "STRING", TEXT_MIME } }; -const char* +const char * Wayland_convert_mime_type(const char *mime_type) { const char *found = mime_type; @@ -165,14 +165,13 @@ Wayland_convert_mime_type(const char *mime_type) return found; } -static SDL_MimeDataList* -mime_data_list_find(struct wl_list* list, - const char* mime_type) +static SDL_MimeDataList *mime_data_list_find(struct wl_list *list, + const char *mime_type) { SDL_MimeDataList *found = NULL; SDL_MimeDataList *mime_list = NULL; - wl_list_for_each(mime_list, list, link) { + wl_list_for_each (mime_list, list, link) { if (SDL_strcmp(mime_list->mime_type, mime_type) == 0) { found = mime_list; break; @@ -181,10 +180,9 @@ mime_data_list_find(struct wl_list* list, return found; } -static int -mime_data_list_add(struct wl_list* list, - const char* mime_type, - const void* buffer, size_t length) +static int mime_data_list_add(struct wl_list *list, + const char *mime_type, + const void *buffer, size_t length) { int status = 0; size_t mime_type_length = 0; @@ -231,13 +229,13 @@ mime_data_list_add(struct wl_list* list, return status; } -static void -mime_data_list_free(struct wl_list *list) +static void mime_data_list_free(struct wl_list *list) { SDL_MimeDataList *mime_data = NULL; SDL_MimeDataList *next = NULL; - wl_list_for_each_safe(mime_data, next, list, link) { + wl_list_for_each_safe(mime_data, next, list, link) + { if (mime_data->data != NULL) { SDL_free(mime_data->data); } @@ -259,7 +257,8 @@ Wayland_source_send(SDL_MimeDataList *mime_data, const char *mime_type, int fd) close(fd); } else { while (write_pipe(fd, mime_data->data, mime_data->length, - &written_bytes) > 0); + &written_bytes) > 0) + ; close(fd); status = written_bytes; } @@ -274,7 +273,7 @@ Wayland_data_source_send(SDL_WaylandDataSource *source, mime_type = Wayland_convert_mime_type(mime_type); mime_data = mime_data_list_find(&source->mimes, - mime_type); + mime_type); return Wayland_source_send(mime_data, mime_type, fd); } @@ -287,7 +286,7 @@ Wayland_primary_selection_source_send(SDL_WaylandPrimarySelectionSource *source, mime_type = Wayland_convert_mime_type(mime_type); mime_data = mime_data_list_find(&source->mimes, - mime_type); + mime_type); return Wayland_source_send(mime_data, mime_type, fd); } @@ -332,10 +331,9 @@ Wayland_primary_selection_source_has_mime(SDL_WaylandPrimarySelectionSource *sou return found; } -static void* -Wayland_source_get_data(SDL_MimeDataList *mime_data, - size_t *length, - SDL_bool null_terminate) +static void *Wayland_source_get_data(SDL_MimeDataList *mime_data, + size_t *length, + SDL_bool null_terminate) { void *buffer = NULL; @@ -360,9 +358,9 @@ Wayland_source_get_data(SDL_MimeDataList *mime_data, return buffer; } -void* +void * Wayland_data_source_get_data(SDL_WaylandDataSource *source, - size_t *length, const char* mime_type, + size_t *length, const char *mime_type, SDL_bool null_terminate) { SDL_MimeDataList *mime_data = NULL; @@ -379,9 +377,9 @@ Wayland_data_source_get_data(SDL_WaylandDataSource *source, return buffer; } -void* +void * Wayland_primary_selection_source_get_data(SDL_WaylandPrimarySelectionSource *source, - size_t *length, const char* mime_type, + size_t *length, const char *mime_type, SDL_bool null_terminate) { SDL_MimeDataList *mime_data = NULL; @@ -398,11 +396,10 @@ Wayland_primary_selection_source_get_data(SDL_WaylandPrimarySelectionSource *sou return buffer; } -void -Wayland_data_source_destroy(SDL_WaylandDataSource *source) +void Wayland_data_source_destroy(SDL_WaylandDataSource *source) { if (source != NULL) { - SDL_WaylandDataDevice *data_device = (SDL_WaylandDataDevice *) source->data_device; + SDL_WaylandDataDevice *data_device = (SDL_WaylandDataDevice *)source->data_device; if (data_device && (data_device->selection_source == source)) { data_device->selection_source = NULL; } @@ -412,11 +409,10 @@ Wayland_data_source_destroy(SDL_WaylandDataSource *source) } } -void -Wayland_primary_selection_source_destroy(SDL_WaylandPrimarySelectionSource *source) +void Wayland_primary_selection_source_destroy(SDL_WaylandPrimarySelectionSource *source) { if (source != NULL) { - SDL_WaylandPrimarySelectionDevice *primary_selection_device = (SDL_WaylandPrimarySelectionDevice *) source->primary_selection_device; + SDL_WaylandPrimarySelectionDevice *primary_selection_device = (SDL_WaylandPrimarySelectionDevice *)source->primary_selection_device; if (primary_selection_device && (primary_selection_device->selection_source == source)) { primary_selection_device->selection_source = NULL; } @@ -426,9 +422,9 @@ Wayland_primary_selection_source_destroy(SDL_WaylandPrimarySelectionSource *sour } } -void* +void * Wayland_data_offer_receive(SDL_WaylandDataOffer *offer, - size_t *length, const char* mime_type, + size_t *length, const char *mime_type, SDL_bool null_terminate) { SDL_WaylandDataDevice *data_device = NULL; @@ -441,7 +437,7 @@ Wayland_data_offer_receive(SDL_WaylandDataOffer *offer, SDL_SetError("Invalid data offer"); } else if ((data_device = offer->data_device) == NULL) { SDL_SetError("Data device not initialized"); - } else if (pipe2(pipefd, O_CLOEXEC|O_NONBLOCK) == -1) { + } else if (pipe2(pipefd, O_CLOEXEC | O_NONBLOCK) == -1) { SDL_SetError("Could not read pipe"); } else { wl_data_offer_receive(offer->offer, mime_type, pipefd[1]); @@ -451,15 +447,16 @@ Wayland_data_offer_receive(SDL_WaylandDataOffer *offer, close(pipefd[1]); - while (read_pipe(pipefd[0], &buffer, length, null_terminate) > 0); + while (read_pipe(pipefd[0], &buffer, length, null_terminate) > 0) + ; close(pipefd[0]); } return buffer; } -void* +void * Wayland_primary_selection_offer_receive(SDL_WaylandPrimarySelectionOffer *offer, - size_t *length, const char* mime_type, + size_t *length, const char *mime_type, SDL_bool null_terminate) { SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL; @@ -472,7 +469,7 @@ Wayland_primary_selection_offer_receive(SDL_WaylandPrimarySelectionOffer *offer, SDL_SetError("Invalid data offer"); } else if ((primary_selection_device = offer->primary_selection_device) == NULL) { SDL_SetError("Primary selection device not initialized"); - } else if (pipe2(pipefd, O_CLOEXEC|O_NONBLOCK) == -1) { + } else if (pipe2(pipefd, O_CLOEXEC | O_NONBLOCK) == -1) { SDL_SetError("Could not read pipe"); } else { zwp_primary_selection_offer_v1_receive(offer->offer, mime_type, pipefd[1]); @@ -482,22 +479,21 @@ Wayland_primary_selection_offer_receive(SDL_WaylandPrimarySelectionOffer *offer, close(pipefd[1]); - while (read_pipe(pipefd[0], &buffer, length, null_terminate) > 0); + while (read_pipe(pipefd[0], &buffer, length, null_terminate) > 0) + ; close(pipefd[0]); } return buffer; } -int -Wayland_data_offer_add_mime(SDL_WaylandDataOffer *offer, - const char* mime_type) +int Wayland_data_offer_add_mime(SDL_WaylandDataOffer *offer, + const char *mime_type) { return mime_data_list_add(&offer->mimes, mime_type, NULL, 0); } -int -Wayland_primary_selection_offer_add_mime(SDL_WaylandPrimarySelectionOffer *offer, - const char* mime_type) +int Wayland_primary_selection_offer_add_mime(SDL_WaylandPrimarySelectionOffer *offer, + const char *mime_type) { return mime_data_list_add(&offer->mimes, mime_type, NULL, 0); } @@ -526,8 +522,7 @@ Wayland_primary_selection_offer_has_mime(SDL_WaylandPrimarySelectionOffer *offer return found; } -void -Wayland_data_offer_destroy(SDL_WaylandDataOffer *offer) +void Wayland_data_offer_destroy(SDL_WaylandDataOffer *offer) { if (offer != NULL) { wl_data_offer_destroy(offer->offer); @@ -536,8 +531,7 @@ Wayland_data_offer_destroy(SDL_WaylandDataOffer *offer) } } -void -Wayland_primary_selection_offer_destroy(SDL_WaylandPrimarySelectionOffer *offer) +void Wayland_primary_selection_offer_destroy(SDL_WaylandPrimarySelectionOffer *offer) { if (offer != NULL) { zwp_primary_selection_offer_v1_destroy(offer->offer); @@ -546,8 +540,7 @@ Wayland_primary_selection_offer_destroy(SDL_WaylandPrimarySelectionOffer *offer) } } -int -Wayland_data_device_clear_selection(SDL_WaylandDataDevice *data_device) +int Wayland_data_device_clear_selection(SDL_WaylandDataDevice *data_device) { int status = 0; @@ -561,8 +554,7 @@ Wayland_data_device_clear_selection(SDL_WaylandDataDevice *data_device) return status; } -int -Wayland_primary_selection_device_clear_selection(SDL_WaylandPrimarySelectionDevice *primary_selection_device) +int Wayland_primary_selection_device_clear_selection(SDL_WaylandPrimarySelectionDevice *primary_selection_device) { int status = 0; @@ -577,9 +569,8 @@ Wayland_primary_selection_device_clear_selection(SDL_WaylandPrimarySelectionDevi return status; } -int -Wayland_data_device_set_selection(SDL_WaylandDataDevice *data_device, - SDL_WaylandDataSource *source) +int Wayland_data_device_set_selection(SDL_WaylandDataDevice *data_device, + SDL_WaylandDataSource *source) { int status = 0; size_t num_offers = 0; @@ -592,7 +583,7 @@ Wayland_data_device_set_selection(SDL_WaylandDataDevice *data_device, } else { SDL_MimeDataList *mime_data = NULL; - wl_list_for_each(mime_data, &(source->mimes), link) { + wl_list_for_each (mime_data, &(source->mimes), link) { wl_data_source_offer(source->source, mime_data->mime_type); @@ -601,7 +592,7 @@ Wayland_data_device_set_selection(SDL_WaylandDataDevice *data_device, if (SDL_strcmp(mime_conversion_list[index][1], mime_data->mime_type) == 0) { wl_data_source_offer(source->source, mime_conversion_list[index][0]); - } + } } /* */ @@ -629,9 +620,8 @@ Wayland_data_device_set_selection(SDL_WaylandDataDevice *data_device, return status; } -int -Wayland_primary_selection_device_set_selection(SDL_WaylandPrimarySelectionDevice *primary_selection_device, - SDL_WaylandPrimarySelectionSource *source) +int Wayland_primary_selection_device_set_selection(SDL_WaylandPrimarySelectionDevice *primary_selection_device, + SDL_WaylandPrimarySelectionSource *source) { int status = 0; size_t num_offers = 0; @@ -644,16 +634,16 @@ Wayland_primary_selection_device_set_selection(SDL_WaylandPrimarySelectionDevice } else { SDL_MimeDataList *mime_data = NULL; - wl_list_for_each(mime_data, &(source->mimes), link) { + wl_list_for_each (mime_data, &(source->mimes), link) { zwp_primary_selection_source_v1_offer(source->source, mime_data->mime_type); /* TODO - Improve system for multiple mime types to same data */ for (index = 0; index < MIME_LIST_SIZE; ++index) { if (SDL_strcmp(mime_conversion_list[index][1], mime_data->mime_type) == 0) { - zwp_primary_selection_source_v1_offer(source->source, - mime_conversion_list[index][0]); - } + zwp_primary_selection_source_v1_offer(source->source, + mime_conversion_list[index][0]); + } } /* */ @@ -681,17 +671,15 @@ Wayland_primary_selection_device_set_selection(SDL_WaylandPrimarySelectionDevice return status; } -int -Wayland_data_device_set_serial(SDL_WaylandDataDevice *data_device, - uint32_t serial) +int Wayland_data_device_set_serial(SDL_WaylandDataDevice *data_device, + uint32_t serial) { int status = -1; if (data_device != NULL) { status = 0; /* If there was no serial and there is a pending selection set it now. */ - if (data_device->selection_serial == 0 - && data_device->selection_source != NULL) { + if (data_device->selection_serial == 0 && data_device->selection_source != NULL) { wl_data_device_set_selection(data_device->data_device, data_device->selection_source->source, data_device->selection_serial); @@ -703,17 +691,15 @@ Wayland_data_device_set_serial(SDL_WaylandDataDevice *data_device, return status; } -int -Wayland_primary_selection_device_set_serial(SDL_WaylandPrimarySelectionDevice *primary_selection_device, - uint32_t serial) +int Wayland_primary_selection_device_set_serial(SDL_WaylandPrimarySelectionDevice *primary_selection_device, + uint32_t serial) { int status = -1; if (primary_selection_device != NULL) { status = 0; /* If there was no serial and there is a pending selection set it now. */ - if (primary_selection_device->selection_serial == 0 - && primary_selection_device->selection_source != NULL) { + if (primary_selection_device->selection_serial == 0 && primary_selection_device->selection_source != NULL) { zwp_primary_selection_device_v1_set_selection(primary_selection_device->primary_selection_device, primary_selection_device->selection_source->source, primary_selection_device->selection_serial); diff --git a/src/video/wayland/SDL_waylanddatamanager.h b/src/video/wayland/SDL_waylanddatamanager.h index 3e1aa0349..6a8cdd6b9 100644 --- a/src/video/wayland/SDL_waylanddatamanager.h +++ b/src/video/wayland/SDL_waylanddatamanager.h @@ -30,38 +30,44 @@ #define TEXT_MIME "text/plain;charset=utf-8" #define FILE_MIME "text/uri-list" -typedef struct { +typedef struct +{ char *mime_type; void *data; size_t length; struct wl_list link; } SDL_MimeDataList; -typedef struct { +typedef struct +{ struct wl_data_source *source; struct wl_list mimes; void *data_device; } SDL_WaylandDataSource; -typedef struct { +typedef struct +{ struct zwp_primary_selection_source_v1 *source; struct wl_list mimes; void *primary_selection_device; } SDL_WaylandPrimarySelectionSource; -typedef struct { +typedef struct +{ struct wl_data_offer *offer; struct wl_list mimes; void *data_device; } SDL_WaylandDataOffer; -typedef struct { +typedef struct +{ struct zwp_primary_selection_offer_v1 *offer; struct wl_list mimes; void *primary_selection_device; } SDL_WaylandPrimarySelectionOffer; -typedef struct { +typedef struct +{ struct wl_data_device *data_device; SDL_VideoData *video_data; @@ -75,7 +81,8 @@ typedef struct { SDL_WaylandDataSource *selection_source; } SDL_WaylandDataDevice; -typedef struct { +typedef struct +{ struct zwp_primary_selection_device_v1 *primary_selection_device; SDL_VideoData *video_data; @@ -84,11 +91,11 @@ typedef struct { SDL_WaylandPrimarySelectionOffer *selection_offer; } SDL_WaylandPrimarySelectionDevice; -extern const char* Wayland_convert_mime_type(const char *mime_type); +extern const char *Wayland_convert_mime_type(const char *mime_type); /* Wayland Data Source / Primary Selection Source - (Sending) */ -extern SDL_WaylandDataSource* Wayland_data_source_create(_THIS); -extern SDL_WaylandPrimarySelectionSource* Wayland_primary_selection_source_create(_THIS); +extern SDL_WaylandDataSource *Wayland_data_source_create(_THIS); +extern SDL_WaylandPrimarySelectionSource *Wayland_primary_selection_source_create(_THIS); extern ssize_t Wayland_data_source_send(SDL_WaylandDataSource *source, const char *mime_type, int fd); extern ssize_t Wayland_primary_selection_source_send(SDL_WaylandPrimarySelectionSource *source, @@ -105,11 +112,11 @@ extern SDL_bool Wayland_data_source_has_mime(SDL_WaylandDataSource *source, const char *mime_type); extern SDL_bool Wayland_primary_selection_source_has_mime(SDL_WaylandPrimarySelectionSource *source, const char *mime_type); -extern void* Wayland_data_source_get_data(SDL_WaylandDataSource *source, +extern void *Wayland_data_source_get_data(SDL_WaylandDataSource *source, size_t *length, const char *mime_type, SDL_bool null_terminate); -extern void* Wayland_primary_selection_source_get_data(SDL_WaylandPrimarySelectionSource *source, +extern void *Wayland_primary_selection_source_get_data(SDL_WaylandPrimarySelectionSource *source, size_t *length, const char *mime_type, SDL_bool null_terminate); @@ -117,11 +124,11 @@ extern void Wayland_data_source_destroy(SDL_WaylandDataSource *source); extern void Wayland_primary_selection_source_destroy(SDL_WaylandPrimarySelectionSource *source); /* Wayland Data / Primary Selection Offer - (Receiving) */ -extern void* Wayland_data_offer_receive(SDL_WaylandDataOffer *offer, +extern void *Wayland_data_offer_receive(SDL_WaylandDataOffer *offer, size_t *length, const char *mime_type, SDL_bool null_terminate); -extern void* Wayland_primary_selection_offer_receive(SDL_WaylandPrimarySelectionOffer *offer, +extern void *Wayland_primary_selection_offer_receive(SDL_WaylandPrimarySelectionOffer *offer, size_t *length, const char *mime_type, SDL_bool null_terminate); @@ -142,7 +149,7 @@ extern int Wayland_primary_selection_device_clear_selection(SDL_WaylandPrimarySe extern int Wayland_data_device_set_selection(SDL_WaylandDataDevice *device, SDL_WaylandDataSource *source); extern int Wayland_primary_selection_device_set_selection(SDL_WaylandPrimarySelectionDevice *device, - SDL_WaylandPrimarySelectionSource *source); + SDL_WaylandPrimarySelectionSource *source); extern int Wayland_data_device_set_serial(SDL_WaylandDataDevice *device, uint32_t serial); extern int Wayland_primary_selection_device_set_serial(SDL_WaylandPrimarySelectionDevice *device, @@ -150,4 +157,3 @@ extern int Wayland_primary_selection_device_set_serial(SDL_WaylandPrimarySelecti #endif /* SDL_waylanddatamanager_h_ */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/video/wayland/SDL_waylanddyn.c b/src/video/wayland/SDL_waylanddyn.c index 68ea1cf48..e4c3f193c 100644 --- a/src/video/wayland/SDL_waylanddyn.c +++ b/src/video/wayland/SDL_waylanddyn.c @@ -26,7 +26,6 @@ #include "SDL_waylanddyn.h" - #ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC #include "SDL_name.h" @@ -52,15 +51,14 @@ typedef struct #endif static waylanddynlib waylandlibs[] = { - {NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC}, - {NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL}, - {NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR}, - {NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON}, - {NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR} + { NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC }, + { NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL }, + { NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR }, + { NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON }, + { NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR } }; -static void * -WAYLAND_GetSym(const char *fnname, int *pHasModule) +static void *WAYLAND_GetSym(const char *fnname, int *pHasModule) { int i; void *fn = NULL; @@ -94,29 +92,27 @@ WAYLAND_GetSym(const char *fnname, int *pHasModule) #endif /* SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */ /* Define all the function pointers and wrappers... */ -#define SDL_WAYLAND_MODULE(modname) int SDL_WAYLAND_HAVE_##modname = 0; -#define SDL_WAYLAND_SYM(rc,fn,params) SDL_DYNWAYLANDFN_##fn WAYLAND_##fn = NULL; -#define SDL_WAYLAND_INTERFACE(iface) const struct wl_interface *WAYLAND_##iface = NULL; +#define SDL_WAYLAND_MODULE(modname) int SDL_WAYLAND_HAVE_##modname = 0; +#define SDL_WAYLAND_SYM(rc, fn, params) SDL_DYNWAYLANDFN_##fn WAYLAND_##fn = NULL; +#define SDL_WAYLAND_INTERFACE(iface) const struct wl_interface *WAYLAND_##iface = NULL; #include "SDL_waylandsym.h" static int wayland_load_refcount = 0; -void -SDL_WAYLAND_UnloadSymbols(void) +void SDL_WAYLAND_UnloadSymbols(void) { /* Don't actually unload if more than one module is using the libs... */ if (wayland_load_refcount > 0) { if (--wayland_load_refcount == 0) { -#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC int i; #endif - - /* set all the function pointers to NULL. */ -#define SDL_WAYLAND_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 0; -#define SDL_WAYLAND_SYM(rc,fn,params) WAYLAND_##fn = NULL; -#define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = NULL; -#include "SDL_waylandsym.h" + /* set all the function pointers to NULL. */ +#define SDL_WAYLAND_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 0; +#define SDL_WAYLAND_SYM(rc, fn, params) WAYLAND_##fn = NULL; +#define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = NULL; +#include "SDL_waylandsym.h" #ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC for (i = 0; i < SDL_TABLESIZE(waylandlibs); i++) { @@ -131,10 +127,9 @@ SDL_WAYLAND_UnloadSymbols(void) } /* returns non-zero if all needed symbols were loaded. */ -int -SDL_WAYLAND_LoadSymbols(void) +int SDL_WAYLAND_LoadSymbols(void) { - int rc = 1; /* always succeed if not using Dynamic WAYLAND stuff. */ + int rc = 1; /* always succeed if not using Dynamic WAYLAND stuff. */ /* deal with multiple modules (dga, wayland, etc) needing these symbols... */ if (wayland_load_refcount++ == 0) { @@ -150,9 +145,9 @@ SDL_WAYLAND_LoadSymbols(void) #define SDL_WAYLAND_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 1; /* default yes */ #include "SDL_waylandsym.h" -#define SDL_WAYLAND_MODULE(modname) thismod = &SDL_WAYLAND_HAVE_##modname; -#define SDL_WAYLAND_SYM(rc,fn,params) WAYLAND_##fn = (SDL_DYNWAYLANDFN_##fn) WAYLAND_GetSym(#fn,thismod); -#define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = (struct wl_interface *) WAYLAND_GetSym(#iface,thismod); +#define SDL_WAYLAND_MODULE(modname) thismod = &SDL_WAYLAND_HAVE_##modname; +#define SDL_WAYLAND_SYM(rc, fn, params) WAYLAND_##fn = (SDL_DYNWAYLANDFN_##fn)WAYLAND_GetSym(#fn, thismod); +#define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = (struct wl_interface *)WAYLAND_GetSym(#iface, thismod); #include "SDL_waylandsym.h" if (SDL_WAYLAND_HAVE_WAYLAND_CLIENT) { @@ -164,11 +159,11 @@ SDL_WAYLAND_LoadSymbols(void) rc = 0; } -#else /* no dynamic WAYLAND */ +#else /* no dynamic WAYLAND */ -#define SDL_WAYLAND_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 1; /* default yes */ -#define SDL_WAYLAND_SYM(rc,fn,params) WAYLAND_##fn = fn; -#define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = &iface; +#define SDL_WAYLAND_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 1; /* default yes */ +#define SDL_WAYLAND_SYM(rc, fn, params) WAYLAND_##fn = fn; +#define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = &iface; #include "SDL_waylandsym.h" #endif diff --git a/src/video/wayland/SDL_waylanddyn.h b/src/video/wayland/SDL_waylanddyn.h index 887c51d1c..1c0db6c5d 100644 --- a/src/video/wayland/SDL_waylanddyn.h +++ b/src/video/wayland/SDL_waylanddyn.h @@ -55,22 +55,21 @@ enum libdecor_window_state; /* Must be included before our #defines, see Bugzilla #4957 */ #include "wayland-client-core.h" -#define SDL_WAYLAND_CHECK_VERSION(x, y, z) \ - (WAYLAND_VERSION_MAJOR > x || \ - (WAYLAND_VERSION_MAJOR == x && WAYLAND_VERSION_MINOR > y) || \ - (WAYLAND_VERSION_MAJOR == x && WAYLAND_VERSION_MINOR == y && WAYLAND_VERSION_MICRO >= z)) +#define SDL_WAYLAND_CHECK_VERSION(x, y, z) \ + (WAYLAND_VERSION_MAJOR > x || \ + (WAYLAND_VERSION_MAJOR == x && WAYLAND_VERSION_MINOR > y) || \ + (WAYLAND_VERSION_MAJOR == x && WAYLAND_VERSION_MINOR == y && WAYLAND_VERSION_MICRO >= z)) #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif int SDL_WAYLAND_LoadSymbols(void); void SDL_WAYLAND_UnloadSymbols(void); #define SDL_WAYLAND_MODULE(modname) extern int SDL_WAYLAND_HAVE_##modname; -#define SDL_WAYLAND_SYM(rc,fn,params) \ - typedef rc (*SDL_DYNWAYLANDFN_##fn) params; \ +#define SDL_WAYLAND_SYM(rc, fn, params) \ + typedef rc(*SDL_DYNWAYLANDFN_##fn) params; \ extern SDL_DYNWAYLANDFN_##fn WAYLAND_##fn; #define SDL_WAYLAND_INTERFACE(iface) extern const struct wl_interface *WAYLAND_##iface; #include "SDL_waylandsym.h" @@ -89,35 +88,35 @@ void SDL_WAYLAND_UnloadSymbols(void); * has inline functions that require these to be defined in dynamic loading mode */ -#define wl_proxy_create (*WAYLAND_wl_proxy_create) -#define wl_proxy_destroy (*WAYLAND_wl_proxy_destroy) -#define wl_proxy_marshal (*WAYLAND_wl_proxy_marshal) -#define wl_proxy_set_user_data (*WAYLAND_wl_proxy_set_user_data) -#define wl_proxy_get_user_data (*WAYLAND_wl_proxy_get_user_data) -#define wl_proxy_get_version (*WAYLAND_wl_proxy_get_version) -#define wl_proxy_add_listener (*WAYLAND_wl_proxy_add_listener) -#define wl_proxy_marshal_constructor (*WAYLAND_wl_proxy_marshal_constructor) +#define wl_proxy_create (*WAYLAND_wl_proxy_create) +#define wl_proxy_destroy (*WAYLAND_wl_proxy_destroy) +#define wl_proxy_marshal (*WAYLAND_wl_proxy_marshal) +#define wl_proxy_set_user_data (*WAYLAND_wl_proxy_set_user_data) +#define wl_proxy_get_user_data (*WAYLAND_wl_proxy_get_user_data) +#define wl_proxy_get_version (*WAYLAND_wl_proxy_get_version) +#define wl_proxy_add_listener (*WAYLAND_wl_proxy_add_listener) +#define wl_proxy_marshal_constructor (*WAYLAND_wl_proxy_marshal_constructor) #define wl_proxy_marshal_constructor_versioned (*WAYLAND_wl_proxy_marshal_constructor_versioned) -#define wl_proxy_set_tag (*WAYLAND_wl_proxy_set_tag) -#define wl_proxy_get_tag (*WAYLAND_wl_proxy_get_tag) -#define wl_proxy_marshal_flags (*WAYLAND_wl_proxy_marshal_flags) -#define wl_proxy_marshal_array_flags (*WAYLAND_wl_proxy_marshal_array_flags) -#define wl_display_reconnect (*WAYLAND_wl_display_reconnect) +#define wl_proxy_set_tag (*WAYLAND_wl_proxy_set_tag) +#define wl_proxy_get_tag (*WAYLAND_wl_proxy_get_tag) +#define wl_proxy_marshal_flags (*WAYLAND_wl_proxy_marshal_flags) +#define wl_proxy_marshal_array_flags (*WAYLAND_wl_proxy_marshal_array_flags) +#define wl_display_reconnect (*WAYLAND_wl_display_reconnect) -#define wl_seat_interface (*WAYLAND_wl_seat_interface) -#define wl_surface_interface (*WAYLAND_wl_surface_interface) -#define wl_shm_pool_interface (*WAYLAND_wl_shm_pool_interface) -#define wl_buffer_interface (*WAYLAND_wl_buffer_interface) -#define wl_registry_interface (*WAYLAND_wl_registry_interface) -#define wl_region_interface (*WAYLAND_wl_region_interface) -#define wl_pointer_interface (*WAYLAND_wl_pointer_interface) -#define wl_keyboard_interface (*WAYLAND_wl_keyboard_interface) -#define wl_compositor_interface (*WAYLAND_wl_compositor_interface) -#define wl_output_interface (*WAYLAND_wl_output_interface) -#define wl_shm_interface (*WAYLAND_wl_shm_interface) -#define wl_data_device_interface (*WAYLAND_wl_data_device_interface) -#define wl_data_offer_interface (*WAYLAND_wl_data_offer_interface) -#define wl_data_source_interface (*WAYLAND_wl_data_source_interface) +#define wl_seat_interface (*WAYLAND_wl_seat_interface) +#define wl_surface_interface (*WAYLAND_wl_surface_interface) +#define wl_shm_pool_interface (*WAYLAND_wl_shm_pool_interface) +#define wl_buffer_interface (*WAYLAND_wl_buffer_interface) +#define wl_registry_interface (*WAYLAND_wl_registry_interface) +#define wl_region_interface (*WAYLAND_wl_region_interface) +#define wl_pointer_interface (*WAYLAND_wl_pointer_interface) +#define wl_keyboard_interface (*WAYLAND_wl_keyboard_interface) +#define wl_compositor_interface (*WAYLAND_wl_compositor_interface) +#define wl_output_interface (*WAYLAND_wl_output_interface) +#define wl_shm_interface (*WAYLAND_wl_shm_interface) +#define wl_data_device_interface (*WAYLAND_wl_data_device_interface) +#define wl_data_offer_interface (*WAYLAND_wl_data_offer_interface) +#define wl_data_source_interface (*WAYLAND_wl_data_source_interface) #define wl_data_device_manager_interface (*WAYLAND_wl_data_device_manager_interface) /* @@ -131,37 +130,37 @@ void SDL_WAYLAND_UnloadSymbols(void); /* Must be included before our defines */ #include -#define libdecor_unref (*WAYLAND_libdecor_unref) -#define libdecor_new (*WAYLAND_libdecor_new) -#define libdecor_decorate (*WAYLAND_libdecor_decorate) -#define libdecor_frame_unref (*WAYLAND_libdecor_frame_unref) -#define libdecor_frame_set_title (*WAYLAND_libdecor_frame_set_title) -#define libdecor_frame_set_app_id (*WAYLAND_libdecor_frame_set_app_id) -#define libdecor_frame_set_max_content_size (*WAYLAND_libdecor_frame_set_max_content_size) -#define libdecor_frame_set_min_content_size (*WAYLAND_libdecor_frame_set_min_content_size) -#define libdecor_frame_resize (*WAYLAND_libdecor_frame_resize) -#define libdecor_frame_move (*WAYLAND_libdecor_frame_move) -#define libdecor_frame_commit (*WAYLAND_libdecor_frame_commit) -#define libdecor_frame_set_minimized (*WAYLAND_libdecor_frame_set_minimized) -#define libdecor_frame_set_maximized (*WAYLAND_libdecor_frame_set_maximized) -#define libdecor_frame_unset_maximized (*WAYLAND_libdecor_frame_unset_maximized) -#define libdecor_frame_set_fullscreen (*WAYLAND_libdecor_frame_set_fullscreen) -#define libdecor_frame_unset_fullscreen (*WAYLAND_libdecor_frame_unset_fullscreen) -#define libdecor_frame_set_capabilities (*WAYLAND_libdecor_frame_set_capabilities) -#define libdecor_frame_unset_capabilities (*WAYLAND_libdecor_frame_unset_capabilities) -#define libdecor_frame_has_capability (*WAYLAND_libdecor_frame_has_capability) -#define libdecor_frame_set_visibility (*WAYLAND_libdecor_frame_set_visibility) -#define libdecor_frame_is_visible (*WAYLAND_libdecor_frame_is_visible) -#define libdecor_frame_is_floating (*WAYLAND_libdecor_frame_is_floating) -#define libdecor_frame_set_parent (*WAYLAND_libdecor_frame_set_parent) -#define libdecor_frame_get_xdg_surface (*WAYLAND_libdecor_frame_get_xdg_surface) -#define libdecor_frame_get_xdg_toplevel (*WAYLAND_libdecor_frame_get_xdg_toplevel) -#define libdecor_frame_map (*WAYLAND_libdecor_frame_map) -#define libdecor_state_new (*WAYLAND_libdecor_state_new) -#define libdecor_state_free (*WAYLAND_libdecor_state_free) +#define libdecor_unref (*WAYLAND_libdecor_unref) +#define libdecor_new (*WAYLAND_libdecor_new) +#define libdecor_decorate (*WAYLAND_libdecor_decorate) +#define libdecor_frame_unref (*WAYLAND_libdecor_frame_unref) +#define libdecor_frame_set_title (*WAYLAND_libdecor_frame_set_title) +#define libdecor_frame_set_app_id (*WAYLAND_libdecor_frame_set_app_id) +#define libdecor_frame_set_max_content_size (*WAYLAND_libdecor_frame_set_max_content_size) +#define libdecor_frame_set_min_content_size (*WAYLAND_libdecor_frame_set_min_content_size) +#define libdecor_frame_resize (*WAYLAND_libdecor_frame_resize) +#define libdecor_frame_move (*WAYLAND_libdecor_frame_move) +#define libdecor_frame_commit (*WAYLAND_libdecor_frame_commit) +#define libdecor_frame_set_minimized (*WAYLAND_libdecor_frame_set_minimized) +#define libdecor_frame_set_maximized (*WAYLAND_libdecor_frame_set_maximized) +#define libdecor_frame_unset_maximized (*WAYLAND_libdecor_frame_unset_maximized) +#define libdecor_frame_set_fullscreen (*WAYLAND_libdecor_frame_set_fullscreen) +#define libdecor_frame_unset_fullscreen (*WAYLAND_libdecor_frame_unset_fullscreen) +#define libdecor_frame_set_capabilities (*WAYLAND_libdecor_frame_set_capabilities) +#define libdecor_frame_unset_capabilities (*WAYLAND_libdecor_frame_unset_capabilities) +#define libdecor_frame_has_capability (*WAYLAND_libdecor_frame_has_capability) +#define libdecor_frame_set_visibility (*WAYLAND_libdecor_frame_set_visibility) +#define libdecor_frame_is_visible (*WAYLAND_libdecor_frame_is_visible) +#define libdecor_frame_is_floating (*WAYLAND_libdecor_frame_is_floating) +#define libdecor_frame_set_parent (*WAYLAND_libdecor_frame_set_parent) +#define libdecor_frame_get_xdg_surface (*WAYLAND_libdecor_frame_get_xdg_surface) +#define libdecor_frame_get_xdg_toplevel (*WAYLAND_libdecor_frame_get_xdg_toplevel) +#define libdecor_frame_map (*WAYLAND_libdecor_frame_map) +#define libdecor_state_new (*WAYLAND_libdecor_state_new) +#define libdecor_state_free (*WAYLAND_libdecor_state_free) #define libdecor_configuration_get_content_size (*WAYLAND_libdecor_configuration_get_content_size) #define libdecor_configuration_get_window_state (*WAYLAND_libdecor_configuration_get_window_state) -#define libdecor_dispatch (*WAYLAND_libdecor_dispatch) +#define libdecor_dispatch (*WAYLAND_libdecor_dispatch) #endif #else /* SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */ diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index c5863d9ff..da5116de9 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -51,11 +51,11 @@ #ifdef SDL_INPUT_LINUXEV #include #else -#define BTN_LEFT (0x110) -#define BTN_RIGHT (0x111) -#define BTN_MIDDLE (0x112) -#define BTN_SIDE (0x113) -#define BTN_EXTRA (0x114) +#define BTN_LEFT (0x110) +#define BTN_RIGHT (0x111) +#define BTN_MIDDLE (0x112) +#define BTN_SIDE (0x113) +#define BTN_EXTRA (0x114) #endif #include #include @@ -75,27 +75,28 @@ /* Weston uses a ratio of 10 units per scroll tick */ #define WAYLAND_WHEEL_AXIS_UNIT 10 -struct SDL_WaylandTouchPoint { +struct SDL_WaylandTouchPoint +{ SDL_TouchID id; float x; float y; - struct wl_surface* surface; + struct wl_surface *surface; - struct SDL_WaylandTouchPoint* prev; - struct SDL_WaylandTouchPoint* next; + struct SDL_WaylandTouchPoint *prev; + struct SDL_WaylandTouchPoint *next; }; -struct SDL_WaylandTouchPointList { - struct SDL_WaylandTouchPoint* head; - struct SDL_WaylandTouchPoint* tail; -}; - -static struct SDL_WaylandTouchPointList touch_points = {NULL, NULL}; - -static void -touch_add(SDL_TouchID id, float x, float y, struct wl_surface *surface) +struct SDL_WaylandTouchPointList { - struct SDL_WaylandTouchPoint* tp = SDL_malloc(sizeof(struct SDL_WaylandTouchPoint)); + struct SDL_WaylandTouchPoint *head; + struct SDL_WaylandTouchPoint *tail; +}; + +static struct SDL_WaylandTouchPointList touch_points = { NULL, NULL }; + +static void touch_add(SDL_TouchID id, float x, float y, struct wl_surface *surface) +{ + struct SDL_WaylandTouchPoint *tp = SDL_malloc(sizeof(struct SDL_WaylandTouchPoint)); tp->id = id; tp->x = x; @@ -114,10 +115,9 @@ touch_add(SDL_TouchID id, float x, float y, struct wl_surface *surface) tp->next = NULL; } -static void -touch_update(SDL_TouchID id, float x, float y) +static void touch_update(SDL_TouchID id, float x, float y) { - struct SDL_WaylandTouchPoint* tp = touch_points.head; + struct SDL_WaylandTouchPoint *tp = touch_points.head; while (tp) { if (tp->id == id) { @@ -129,10 +129,9 @@ touch_update(SDL_TouchID id, float x, float y) } } -static void -touch_del(SDL_TouchID id, float* x, float* y, struct wl_surface **surface) +static void touch_del(SDL_TouchID id, float *x, float *y, struct wl_surface **surface) { - struct SDL_WaylandTouchPoint* tp = touch_points.head; + struct SDL_WaylandTouchPoint *tp = touch_points.head; while (tp) { if (tp->id == id) { @@ -163,10 +162,10 @@ touch_del(SDL_TouchID id, float* x, float* y, struct wl_surface **surface) } } -static struct wl_surface* +static struct wl_surface * touch_surface(SDL_TouchID id) { - struct SDL_WaylandTouchPoint* tp = touch_points.head; + struct SDL_WaylandTouchPoint *tp = touch_points.head; while (tp) { if (tp->id == id) { @@ -180,8 +179,7 @@ touch_surface(SDL_TouchID id) } /* Returns SDL_TRUE if a key repeat event was due */ -static SDL_bool -keyboard_repeat_handle(SDL_WaylandKeyboardRepeat* repeat_info, uint32_t elapsed) +static SDL_bool keyboard_repeat_handle(SDL_WaylandKeyboardRepeat *repeat_info, uint32_t elapsed) { SDL_bool ret = SDL_FALSE; while ((elapsed - repeat_info->next_repeat_ms) < 0x80000000U) { @@ -197,17 +195,17 @@ keyboard_repeat_handle(SDL_WaylandKeyboardRepeat* repeat_info, uint32_t elapsed) return ret; } -static void -keyboard_repeat_clear(SDL_WaylandKeyboardRepeat* repeat_info) { +static void keyboard_repeat_clear(SDL_WaylandKeyboardRepeat *repeat_info) +{ if (!repeat_info->is_initialized) { return; } repeat_info->is_key_down = SDL_FALSE; } -static void -keyboard_repeat_set(SDL_WaylandKeyboardRepeat* repeat_info, uint32_t key, uint32_t wl_press_time, - uint32_t scancode, SDL_bool has_text, char text[8]) { +static void keyboard_repeat_set(SDL_WaylandKeyboardRepeat *repeat_info, uint32_t key, uint32_t wl_press_time, + uint32_t scancode, SDL_bool has_text, char text[8]) +{ if (!repeat_info->is_initialized || !repeat_info->repeat_rate) { return; } @@ -224,8 +222,7 @@ keyboard_repeat_set(SDL_WaylandKeyboardRepeat* repeat_info, uint32_t key, uint32 } } -static uint32_t -keyboard_repeat_get_key(SDL_WaylandKeyboardRepeat *repeat_info) +static uint32_t keyboard_repeat_get_key(SDL_WaylandKeyboardRepeat *repeat_info) { if (repeat_info->is_initialized && repeat_info->is_key_down) { return repeat_info->key; @@ -234,24 +231,24 @@ keyboard_repeat_get_key(SDL_WaylandKeyboardRepeat *repeat_info) return 0; } -static void -keyboard_repeat_set_text(SDL_WaylandKeyboardRepeat *repeat_info, const char text[8]) +static void keyboard_repeat_set_text(SDL_WaylandKeyboardRepeat *repeat_info, const char text[8]) { if (repeat_info->is_initialized) { SDL_memcpy(repeat_info->text, text, 8); } } -static SDL_bool keyboard_repeat_is_set(SDL_WaylandKeyboardRepeat* repeat_info) { +static SDL_bool keyboard_repeat_is_set(SDL_WaylandKeyboardRepeat *repeat_info) +{ return repeat_info->is_initialized && repeat_info->is_key_down; } -static SDL_bool keyboard_repeat_key_is_set(SDL_WaylandKeyboardRepeat* repeat_info, uint32_t key) { +static SDL_bool keyboard_repeat_key_is_set(SDL_WaylandKeyboardRepeat *repeat_info, uint32_t key) +{ return repeat_info->is_initialized && repeat_info->is_key_down && key == repeat_info->key; } -void -Wayland_SendWakeupEvent(_THIS, SDL_Window *window) +void Wayland_SendWakeupEvent(_THIS, SDL_Window *window) { SDL_VideoData *d = _this->driverdata; @@ -260,8 +257,7 @@ Wayland_SendWakeupEvent(_THIS, SDL_Window *window) WAYLAND_wl_display_flush(d->display); } -static int -dispatch_queued_events(SDL_VideoData *viddata) +static int dispatch_queued_events(SDL_VideoData *viddata) { int ret; @@ -279,8 +275,7 @@ dispatch_queued_events(SDL_VideoData *viddata) return ret >= 0 ? 1 : ret; } -int -Wayland_WaitEventTimeout(_THIS, int timeout) +int Wayland_WaitEventTimeout(_THIS, int timeout) { SDL_VideoData *d = _this->driverdata; struct SDL_WaylandInput *input = d->input; @@ -351,8 +346,7 @@ Wayland_WaitEventTimeout(_THIS, int timeout) } } -void -Wayland_PumpEvents(_THIS) +void Wayland_PumpEvents(_THIS) { SDL_VideoData *d = _this->driverdata; struct SDL_WaylandInput *input = d->input; @@ -408,9 +402,8 @@ Wayland_PumpEvents(_THIS) } } -static void -pointer_handle_motion(void *data, struct wl_pointer *pointer, - uint32_t time, wl_fixed_t sx_w, wl_fixed_t sy_w) +static void pointer_handle_motion(void *data, struct wl_pointer *pointer, + uint32_t time, wl_fixed_t sx_w, wl_fixed_t sy_w) { struct SDL_WaylandInput *input = data; SDL_WindowData *window = input->pointer_focus; @@ -419,16 +412,15 @@ pointer_handle_motion(void *data, struct wl_pointer *pointer, if (input->pointer_focus) { const float sx_f = (float)wl_fixed_to_double(sx_w); const float sy_f = (float)wl_fixed_to_double(sy_w); - const int sx = (int)SDL_floorf(sx_f * window->pointer_scale_x); - const int sy = (int)SDL_floorf(sy_f * window->pointer_scale_y); + const int sx = (int)SDL_floorf(sx_f * window->pointer_scale_x); + const int sy = (int)SDL_floorf(sy_f * window->pointer_scale_y); SDL_SendMouseMotion(window->sdlwindow, 0, 0, sx, sy); } } -static void -pointer_handle_enter(void *data, struct wl_pointer *pointer, - uint32_t serial, struct wl_surface *surface, - wl_fixed_t sx_w, wl_fixed_t sy_w) +static void pointer_handle_enter(void *data, struct wl_pointer *pointer, + uint32_t serial, struct wl_surface *surface, + wl_fixed_t sx_w, wl_fixed_t sy_w) { struct SDL_WaylandInput *input = data; SDL_WindowData *window; @@ -466,9 +458,8 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer, } } -static void -pointer_handle_leave(void *data, struct wl_pointer *pointer, - uint32_t serial, struct wl_surface *surface) +static void pointer_handle_leave(void *data, struct wl_pointer *pointer, + uint32_t serial, struct wl_surface *surface) { struct SDL_WaylandInput *input = data; @@ -482,8 +473,7 @@ pointer_handle_leave(void *data, struct wl_pointer *pointer, } } -static SDL_bool -ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial) +static SDL_bool ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial) { SDL_WindowData *window_data = input->pointer_focus; SDL_Window *window = window_data->sdlwindow; @@ -509,58 +499,58 @@ ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial) #endif switch (rc) { - case SDL_HITTEST_DRAGGABLE: + case SDL_HITTEST_DRAGGABLE: #ifdef HAVE_LIBDECOR_H - if (window_data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (window_data->shell_surface.libdecor.frame) { - libdecor_frame_move(window_data->shell_surface.libdecor.frame, input->seat, serial); - } - } else + if (window_data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { + if (window_data->shell_surface.libdecor.frame) { + libdecor_frame_move(window_data->shell_surface.libdecor.frame, input->seat, serial); + } + } else #endif if (window_data->shell_surface_type == WAYLAND_SURFACE_XDG_TOPLEVEL) { - if (window_data->shell_surface.xdg.roleobj.toplevel) { - xdg_toplevel_move(window_data->shell_surface.xdg.roleobj.toplevel, - input->seat, - serial); - } + if (window_data->shell_surface.xdg.roleobj.toplevel) { + xdg_toplevel_move(window_data->shell_surface.xdg.roleobj.toplevel, + input->seat, + serial); } - return SDL_TRUE; + } + return SDL_TRUE; - case SDL_HITTEST_RESIZE_TOPLEFT: - case SDL_HITTEST_RESIZE_TOP: - case SDL_HITTEST_RESIZE_TOPRIGHT: - case SDL_HITTEST_RESIZE_RIGHT: - case SDL_HITTEST_RESIZE_BOTTOMRIGHT: - case SDL_HITTEST_RESIZE_BOTTOM: - case SDL_HITTEST_RESIZE_BOTTOMLEFT: - case SDL_HITTEST_RESIZE_LEFT: + case SDL_HITTEST_RESIZE_TOPLEFT: + case SDL_HITTEST_RESIZE_TOP: + case SDL_HITTEST_RESIZE_TOPRIGHT: + case SDL_HITTEST_RESIZE_RIGHT: + case SDL_HITTEST_RESIZE_BOTTOMRIGHT: + case SDL_HITTEST_RESIZE_BOTTOM: + case SDL_HITTEST_RESIZE_BOTTOMLEFT: + case SDL_HITTEST_RESIZE_LEFT: #ifdef HAVE_LIBDECOR_H - if (window_data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (window_data->shell_surface.libdecor.frame) { - libdecor_frame_resize(window_data->shell_surface.libdecor.frame, input->seat, serial, directions_libdecor[rc - SDL_HITTEST_RESIZE_TOPLEFT]); - } - } else + if (window_data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { + if (window_data->shell_surface.libdecor.frame) { + libdecor_frame_resize(window_data->shell_surface.libdecor.frame, input->seat, serial, directions_libdecor[rc - SDL_HITTEST_RESIZE_TOPLEFT]); + } + } else #endif if (window_data->shell_surface_type == WAYLAND_SURFACE_XDG_TOPLEVEL) { - if (window_data->shell_surface.xdg.roleobj.toplevel) { - xdg_toplevel_resize(window_data->shell_surface.xdg.roleobj.toplevel, - input->seat, - serial, - directions[rc - SDL_HITTEST_RESIZE_TOPLEFT]); - } + if (window_data->shell_surface.xdg.roleobj.toplevel) { + xdg_toplevel_resize(window_data->shell_surface.xdg.roleobj.toplevel, + input->seat, + serial, + directions[rc - SDL_HITTEST_RESIZE_TOPLEFT]); } - return SDL_TRUE; + } + return SDL_TRUE; - default: return SDL_FALSE; + default: + return SDL_FALSE; } } return SDL_FALSE; } -static void -pointer_handle_button_common(struct SDL_WaylandInput *input, uint32_t serial, - uint32_t time, uint32_t button, uint32_t state_w) +static void pointer_handle_button_common(struct SDL_WaylandInput *input, uint32_t serial, + uint32_t time, uint32_t button, uint32_t state_w) { SDL_WindowData *window = input->pointer_focus; enum wl_pointer_button_state state = state_w; @@ -569,26 +559,26 @@ pointer_handle_button_common(struct SDL_WaylandInput *input, uint32_t serial, if (window) { SDL_VideoData *viddata = window->waylandData; switch (button) { - case BTN_LEFT: - sdl_button = SDL_BUTTON_LEFT; - if (ProcessHitTest(input, serial)) { - return; /* don't pass this event on to app. */ - } - break; - case BTN_MIDDLE: - sdl_button = SDL_BUTTON_MIDDLE; - break; - case BTN_RIGHT: - sdl_button = SDL_BUTTON_RIGHT; - break; - case BTN_SIDE: - sdl_button = SDL_BUTTON_X1; - break; - case BTN_EXTRA: - sdl_button = SDL_BUTTON_X2; - break; - default: - return; + case BTN_LEFT: + sdl_button = SDL_BUTTON_LEFT; + if (ProcessHitTest(input, serial)) { + return; /* don't pass this event on to app. */ + } + break; + case BTN_MIDDLE: + sdl_button = SDL_BUTTON_MIDDLE; + break; + case BTN_RIGHT: + sdl_button = SDL_BUTTON_RIGHT; + break; + case BTN_SIDE: + sdl_button = SDL_BUTTON_X1; + break; + case BTN_EXTRA: + sdl_button = SDL_BUTTON_X2; + break; + default: + return; } /* Wayland won't let you "capture" the mouse, but it will @@ -596,7 +586,7 @@ pointer_handle_button_common(struct SDL_WaylandInput *input, uint32_t serial, drag outside of it, until you let go of all buttons (even if you add or remove presses outside the window, as long as any button is still down, the capture remains) */ - if (state) { /* update our mask of currently-pressed buttons */ + if (state) { /* update our mask of currently-pressed buttons */ input->buttons_pressed |= SDL_BUTTON(sdl_button); } else { input->buttons_pressed &= ~(SDL_BUTTON(sdl_button)); @@ -619,18 +609,16 @@ pointer_handle_button_common(struct SDL_WaylandInput *input, uint32_t serial, } } -static void -pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial, - uint32_t time, uint32_t button, uint32_t state_w) +static void pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial, + uint32_t time, uint32_t button, uint32_t state_w) { struct SDL_WaylandInput *input = data; pointer_handle_button_common(input, serial, time, button, state_w); } -static void -pointer_handle_axis_common_v1(struct SDL_WaylandInput *input, - uint32_t time, uint32_t axis, wl_fixed_t value) +static void pointer_handle_axis_common_v1(struct SDL_WaylandInput *input, + uint32_t time, uint32_t axis, wl_fixed_t value) { SDL_WindowData *window = input->pointer_focus; enum wl_pointer_axis a = axis; @@ -638,16 +626,16 @@ pointer_handle_axis_common_v1(struct SDL_WaylandInput *input, if (input->pointer_focus) { switch (a) { - case WL_POINTER_AXIS_VERTICAL_SCROLL: - x = 0; - y = 0 - (float)wl_fixed_to_double(value); - break; - case WL_POINTER_AXIS_HORIZONTAL_SCROLL: - x = (float)wl_fixed_to_double(value); - y = 0; - break; - default: - return; + case WL_POINTER_AXIS_VERTICAL_SCROLL: + x = 0; + y = 0 - (float)wl_fixed_to_double(value); + break; + case WL_POINTER_AXIS_HORIZONTAL_SCROLL: + x = (float)wl_fixed_to_double(value); + y = 0; + break; + default: + return; } x /= WAYLAND_WHEEL_AXIS_UNIT; @@ -657,9 +645,8 @@ pointer_handle_axis_common_v1(struct SDL_WaylandInput *input, } } -static void -pointer_handle_axis_common(struct SDL_WaylandInput *input, enum SDL_WaylandAxisEvent type, - uint32_t axis, wl_fixed_t value) +static void pointer_handle_axis_common(struct SDL_WaylandInput *input, enum SDL_WaylandAxisEvent type, + uint32_t axis, wl_fixed_t value) { enum wl_pointer_axis a = axis; @@ -731,9 +718,8 @@ pointer_handle_axis_common(struct SDL_WaylandInput *input, enum SDL_WaylandAxisE } } -static void -pointer_handle_axis(void *data, struct wl_pointer *pointer, - uint32_t time, uint32_t axis, wl_fixed_t value) +static void pointer_handle_axis(void *data, struct wl_pointer *pointer, + uint32_t time, uint32_t axis, wl_fixed_t value) { struct SDL_WaylandInput *input = data; @@ -743,14 +729,13 @@ pointer_handle_axis(void *data, struct wl_pointer *pointer, pointer_handle_axis_common_v1(input, time, axis, value); } -static void -pointer_handle_frame(void *data, struct wl_pointer *pointer) +static void pointer_handle_frame(void *data, struct wl_pointer *pointer) { struct SDL_WaylandInput *input = data; SDL_WindowData *window = input->pointer_focus; float x, y; - switch(input->pointer_curr_axis_info.x_axis_type) { + switch (input->pointer_curr_axis_info.x_axis_type) { case AXIS_EVENT_CONTINUOUS: x = input->pointer_curr_axis_info.x / WAYLAND_WHEEL_AXIS_UNIT; break; @@ -765,7 +750,7 @@ pointer_handle_frame(void *data, struct wl_pointer *pointer) break; } - switch(input->pointer_curr_axis_info.y_axis_type) { + switch (input->pointer_curr_axis_info.y_axis_type) { case AXIS_EVENT_CONTINUOUS: y = input->pointer_curr_axis_info.y / WAYLAND_WHEEL_AXIS_UNIT; break; @@ -788,32 +773,28 @@ pointer_handle_frame(void *data, struct wl_pointer *pointer) } } -static void -pointer_handle_axis_source(void *data, struct wl_pointer *pointer, - uint32_t axis_source) +static void pointer_handle_axis_source(void *data, struct wl_pointer *pointer, + uint32_t axis_source) { /* unimplemented */ } -static void -pointer_handle_axis_stop(void *data, struct wl_pointer *pointer, - uint32_t time, uint32_t axis) +static void pointer_handle_axis_stop(void *data, struct wl_pointer *pointer, + uint32_t time, uint32_t axis) { /* unimplemented */ } -static void -pointer_handle_axis_discrete(void *data, struct wl_pointer *pointer, - uint32_t axis, int32_t discrete) +static void pointer_handle_axis_discrete(void *data, struct wl_pointer *pointer, + uint32_t axis, int32_t discrete) { struct SDL_WaylandInput *input = data; pointer_handle_axis_common(input, AXIS_EVENT_DISCRETE, axis, wl_fixed_from_int(discrete)); } -static void -pointer_handle_axis_value120(void *data, struct wl_pointer *pointer, - uint32_t axis, int32_t value120) +static void pointer_handle_axis_value120(void *data, struct wl_pointer *pointer, + uint32_t axis, int32_t value120) { struct SDL_WaylandInput *input = data; @@ -826,17 +807,16 @@ static const struct wl_pointer_listener pointer_listener = { pointer_handle_motion, pointer_handle_button, pointer_handle_axis, - pointer_handle_frame, /* Version 5 */ - pointer_handle_axis_source, /* Version 5 */ - pointer_handle_axis_stop, /* Version 5 */ - pointer_handle_axis_discrete, /* Version 5 */ - pointer_handle_axis_value120 /* Version 8 */ + pointer_handle_frame, /* Version 5 */ + pointer_handle_axis_source, /* Version 5 */ + pointer_handle_axis_stop, /* Version 5 */ + pointer_handle_axis_discrete, /* Version 5 */ + pointer_handle_axis_value120 /* Version 8 */ }; -static void -touch_handler_down(void *data, struct wl_touch *touch, unsigned int serial, - unsigned int timestamp, struct wl_surface *surface, - int id, wl_fixed_t fx, wl_fixed_t fy) +static void touch_handler_down(void *data, struct wl_touch *touch, unsigned int serial, + unsigned int timestamp, struct wl_surface *surface, + int id, wl_fixed_t fx, wl_fixed_t fy) { SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(surface); const double dblx = wl_fixed_to_double(fx) * window_data->pointer_scale_x; @@ -849,9 +829,8 @@ touch_handler_down(void *data, struct wl_touch *touch, unsigned int serial, SDL_SendTouch((SDL_TouchID)(intptr_t)touch, (SDL_FingerID)id, window_data->sdlwindow, SDL_TRUE, x, y, 1.0f); } -static void -touch_handler_up(void *data, struct wl_touch *touch, unsigned int serial, - unsigned int timestamp, int id) +static void touch_handler_up(void *data, struct wl_touch *touch, unsigned int serial, + unsigned int timestamp, int id) { float x = 0, y = 0; struct wl_surface *surface = NULL; @@ -867,9 +846,8 @@ touch_handler_up(void *data, struct wl_touch *touch, unsigned int serial, SDL_SendTouch((SDL_TouchID)(intptr_t)touch, (SDL_FingerID)id, window, SDL_FALSE, x, y, 0.0f); } -static void -touch_handler_motion(void *data, struct wl_touch *touch, unsigned int timestamp, - int id, wl_fixed_t fx, wl_fixed_t fy) +static void touch_handler_motion(void *data, struct wl_touch *touch, unsigned int timestamp, + int id, wl_fixed_t fx, wl_fixed_t fy) { SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(touch_surface(id)); const double dblx = wl_fixed_to_double(fx) * window_data->pointer_scale_x; @@ -881,16 +859,12 @@ touch_handler_motion(void *data, struct wl_touch *touch, unsigned int timestamp, SDL_SendTouchMotion((SDL_TouchID)(intptr_t)touch, (SDL_FingerID)id, window_data->sdlwindow, x, y, 1.0f); } -static void -touch_handler_frame(void *data, struct wl_touch *touch) +static void touch_handler_frame(void *data, struct wl_touch *touch) { - } -static void -touch_handler_cancel(void *data, struct wl_touch *touch) +static void touch_handler_cancel(void *data, struct wl_touch *touch) { - } static const struct wl_touch_listener touch_listener = { @@ -909,8 +883,7 @@ typedef struct Wayland_Keymap SDL_Keycode keymap[SDL_NUM_SCANCODES]; } Wayland_Keymap; -static void -Wayland_keymap_iter(struct xkb_keymap *keymap, xkb_keycode_t key, void *data) +static void Wayland_keymap_iter(struct xkb_keymap *keymap, xkb_keycode_t key, void *data) { const xkb_keysym_t *syms; Wayland_Keymap *sdlKeymap = (Wayland_Keymap *)data; @@ -956,9 +929,8 @@ Wayland_keymap_iter(struct xkb_keymap *keymap, xkb_keycode_t key, void *data) } } -static void -keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, - uint32_t format, int fd, uint32_t size) +static void keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, + uint32_t format, int fd, uint32_t size) { struct SDL_WaylandInput *input = data; char *map_str; @@ -1062,8 +1034,7 @@ keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, * Virtual keyboards can have arbitrary layouts, arbitrary scancodes/keycodes, etc... * Key presses from these devices must be looked up by their keysym value. */ -static SDL_Scancode -Wayland_get_scancode_from_key(struct SDL_WaylandInput *input, uint32_t key) +static SDL_Scancode Wayland_get_scancode_from_key(struct SDL_WaylandInput *input, uint32_t key) { SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN; @@ -1079,10 +1050,9 @@ Wayland_get_scancode_from_key(struct SDL_WaylandInput *input, uint32_t key) return scancode; } -static void -keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, - uint32_t serial, struct wl_surface *surface, - struct wl_array *keys) +static void keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, + uint32_t serial, struct wl_surface *surface, + struct wl_array *keys) { /* Caps Lock not included because it only makes sense to consider modifiers * that get held down, for the case where a user clicks on an unfocused @@ -1139,9 +1109,8 @@ keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, } } -static void -keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, - uint32_t serial, struct wl_surface *surface) +static void keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, + uint32_t serial, struct wl_surface *surface) { struct SDL_WaylandInput *input = data; SDL_WindowData *window; @@ -1168,8 +1137,7 @@ keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, #endif } -static SDL_bool -keyboard_input_get_text(char text[8], const struct SDL_WaylandInput *input, uint32_t key, Uint8 state, SDL_bool *handled_by_ime) +static SDL_bool keyboard_input_get_text(char text[8], const struct SDL_WaylandInput *input, uint32_t key, Uint8 state, SDL_bool *handled_by_ime) { SDL_WindowData *window = input->keyboard_focus; const xkb_keysym_t *syms; @@ -1199,31 +1167,30 @@ keyboard_input_get_text(char text[8], const struct SDL_WaylandInput *input, uint } if (input->xkb.compose_state && WAYLAND_xkb_compose_state_feed(input->xkb.compose_state, sym) == XKB_COMPOSE_FEED_ACCEPTED) { - switch(WAYLAND_xkb_compose_state_get_status(input->xkb.compose_state)) { - case XKB_COMPOSE_COMPOSING: - if (handled_by_ime) { - *handled_by_ime = SDL_TRUE; - } - return SDL_TRUE; - case XKB_COMPOSE_CANCELLED: - default: - sym = XKB_KEY_NoSymbol; - break; - case XKB_COMPOSE_NOTHING: - break; - case XKB_COMPOSE_COMPOSED: - sym = WAYLAND_xkb_compose_state_get_one_sym(input->xkb.compose_state); - break; + switch (WAYLAND_xkb_compose_state_get_status(input->xkb.compose_state)) { + case XKB_COMPOSE_COMPOSING: + if (handled_by_ime) { + *handled_by_ime = SDL_TRUE; + } + return SDL_TRUE; + case XKB_COMPOSE_CANCELLED: + default: + sym = XKB_KEY_NoSymbol; + break; + case XKB_COMPOSE_NOTHING: + break; + case XKB_COMPOSE_COMPOSED: + sym = WAYLAND_xkb_compose_state_get_one_sym(input->xkb.compose_state); + break; } } return WAYLAND_xkb_keysym_to_utf8(sym, text, 8) > 0; } -static void -keyboard_handle_key(void *data, struct wl_keyboard *keyboard, - uint32_t serial, uint32_t time, uint32_t key, - uint32_t state_w) +static void keyboard_handle_key(void *data, struct wl_keyboard *keyboard, + uint32_t serial, uint32_t time, uint32_t key, + uint32_t state_w) { struct SDL_WaylandInput *input = data; enum wl_keyboard_key_state state = state_w; @@ -1266,18 +1233,17 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard, } } -static void -keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, - uint32_t serial, uint32_t mods_depressed, - uint32_t mods_latched, uint32_t mods_locked, - uint32_t group) +static void keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, + uint32_t serial, uint32_t mods_depressed, + uint32_t mods_latched, uint32_t mods_locked, + uint32_t group) { struct SDL_WaylandInput *input = data; Wayland_Keymap keymap; const uint32_t modstate = (mods_depressed | mods_latched | mods_locked); WAYLAND_xkb_state_update_mask(input->xkb.state, mods_depressed, mods_latched, - mods_locked, 0, 0, group); + mods_locked, 0, 0, group); /* Toggle the modifier states for virtual keyboards, as they may not send key presses. */ if (input->keyboard_is_virtual) { @@ -1315,9 +1281,8 @@ keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, SDL_SetKeymap(0, keymap.keymap, SDL_NUM_SCANCODES, SDL_TRUE); } -static void -keyboard_handle_repeat_info(void *data, struct wl_keyboard *wl_keyboard, - int32_t rate, int32_t delay) +static void keyboard_handle_repeat_info(void *data, struct wl_keyboard *wl_keyboard, + int32_t rate, int32_t delay) { struct SDL_WaylandInput *input = data; input->keyboard_repeat.repeat_rate = SDL_clamp(rate, 0, 1000); @@ -1331,12 +1296,11 @@ static const struct wl_keyboard_listener keyboard_listener = { keyboard_handle_leave, keyboard_handle_key, keyboard_handle_modifiers, - keyboard_handle_repeat_info, /* Version 4 */ + keyboard_handle_repeat_info, /* Version 4 */ }; -static void -seat_handle_capabilities(void *data, struct wl_seat *seat, - enum wl_seat_capability caps) +static void seat_handle_capabilities(void *data, struct wl_seat *seat, + enum wl_seat_capability caps) { struct SDL_WaylandInput *input = data; @@ -1358,7 +1322,7 @@ seat_handle_capabilities(void *data, struct wl_seat *seat, SDL_AddTouch((SDL_TouchID)(intptr_t)input->touch, SDL_TOUCH_DEVICE_DIRECT, "wayland_touch"); wl_touch_set_user_data(input->touch, input); wl_touch_add_listener(input->touch, &touch_listener, - input); + input); } else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && input->touch) { SDL_DelTouch((SDL_TouchID)(intptr_t)input->touch); wl_touch_destroy(input->touch); @@ -1376,49 +1340,42 @@ seat_handle_capabilities(void *data, struct wl_seat *seat, } } -static void -seat_handle_name(void *data, struct wl_seat *wl_seat, const char *name) +static void seat_handle_name(void *data, struct wl_seat *wl_seat, const char *name) { /* unimplemented */ } static const struct wl_seat_listener seat_listener = { seat_handle_capabilities, - seat_handle_name, /* Version 2 */ + seat_handle_name, /* Version 2 */ }; -static void -data_source_handle_target(void *data, struct wl_data_source *wl_data_source, - const char *mime_type) +static void data_source_handle_target(void *data, struct wl_data_source *wl_data_source, + const char *mime_type) { } -static void -data_source_handle_send(void *data, struct wl_data_source *wl_data_source, - const char *mime_type, int32_t fd) +static void data_source_handle_send(void *data, struct wl_data_source *wl_data_source, + const char *mime_type, int32_t fd) { Wayland_data_source_send((SDL_WaylandDataSource *)data, mime_type, fd); } -static void -data_source_handle_cancelled(void *data, struct wl_data_source *wl_data_source) +static void data_source_handle_cancelled(void *data, struct wl_data_source *wl_data_source) { Wayland_data_source_destroy(data); } -static void -data_source_handle_dnd_drop_performed(void *data, struct wl_data_source *wl_data_source) +static void data_source_handle_dnd_drop_performed(void *data, struct wl_data_source *wl_data_source) { } -static void -data_source_handle_dnd_finished(void *data, struct wl_data_source *wl_data_source) +static void data_source_handle_dnd_finished(void *data, struct wl_data_source *wl_data_source) { } -static void -data_source_handle_action(void *data, struct wl_data_source *wl_data_source, - uint32_t dnd_action) +static void data_source_handle_action(void *data, struct wl_data_source *wl_data_source, + uint32_t dnd_action) { } @@ -1431,16 +1388,14 @@ static const struct wl_data_source_listener data_source_listener = { data_source_handle_action, /* Version 3 */ }; -static void -primary_selection_source_send(void *data, struct zwp_primary_selection_source_v1 *zwp_primary_selection_source_v1, - const char *mime_type, int32_t fd) +static void primary_selection_source_send(void *data, struct zwp_primary_selection_source_v1 *zwp_primary_selection_source_v1, + const char *mime_type, int32_t fd) { Wayland_primary_selection_source_send((SDL_WaylandPrimarySelectionSource *)data, mime_type, fd); } -static void -primary_selection_source_cancelled(void *data, struct zwp_primary_selection_source_v1 *zwp_primary_selection_source_v1) +static void primary_selection_source_cancelled(void *data, struct zwp_primary_selection_source_v1 *zwp_primary_selection_source_v1) { Wayland_primary_selection_source_destroy(data); } @@ -1450,7 +1405,7 @@ static const struct zwp_primary_selection_source_v1_listener primary_selection_s primary_selection_source_cancelled, }; -SDL_WaylandDataSource* +SDL_WaylandDataSource * Wayland_data_source_create(_THIS) { SDL_WaylandDataSource *data_source = NULL; @@ -1464,7 +1419,7 @@ Wayland_data_source_create(_THIS) if (driver_data->data_device_manager != NULL) { id = wl_data_device_manager_create_data_source( - driver_data->data_device_manager); + driver_data->data_device_manager); } if (id == NULL) { @@ -1486,7 +1441,7 @@ Wayland_data_source_create(_THIS) return data_source; } -SDL_WaylandPrimarySelectionSource* +SDL_WaylandPrimarySelectionSource * Wayland_primary_selection_source_create(_THIS) { SDL_WaylandPrimarySelectionSource *primary_selection_source = NULL; @@ -1500,7 +1455,7 @@ Wayland_primary_selection_source_create(_THIS) if (driver_data->primary_selection_device_manager != NULL) { id = zwp_primary_selection_device_manager_v1_create_source( - driver_data->primary_selection_device_manager); + driver_data->primary_selection_device_manager); } if (id == NULL) { @@ -1514,30 +1469,27 @@ Wayland_primary_selection_source_create(_THIS) WAYLAND_wl_list_init(&(primary_selection_source->mimes)); primary_selection_source->source = id; zwp_primary_selection_source_v1_add_listener(id, &primary_selection_source_listener, - primary_selection_source); + primary_selection_source); } } } return primary_selection_source; } -static void -data_offer_handle_offer(void *data, struct wl_data_offer *wl_data_offer, - const char *mime_type) +static void data_offer_handle_offer(void *data, struct wl_data_offer *wl_data_offer, + const char *mime_type) { SDL_WaylandDataOffer *offer = data; Wayland_data_offer_add_mime(offer, mime_type); } -static void -data_offer_handle_source_actions(void *data, struct wl_data_offer *wl_data_offer, - uint32_t source_actions) +static void data_offer_handle_source_actions(void *data, struct wl_data_offer *wl_data_offer, + uint32_t source_actions) { } -static void -data_offer_handle_actions(void *data, struct wl_data_offer *wl_data_offer, - uint32_t dnd_action) +static void data_offer_handle_actions(void *data, struct wl_data_offer *wl_data_offer, + uint32_t dnd_action) { } @@ -1547,9 +1499,8 @@ static const struct wl_data_offer_listener data_offer_listener = { data_offer_handle_actions, /* Version 3 */ }; -static void -primary_selection_offer_handle_offer(void *data, struct zwp_primary_selection_offer_v1 *zwp_primary_selection_offer_v1, - const char *mime_type) +static void primary_selection_offer_handle_offer(void *data, struct zwp_primary_selection_offer_v1 *zwp_primary_selection_offer_v1, + const char *mime_type) { SDL_WaylandPrimarySelectionOffer *offer = data; Wayland_primary_selection_offer_add_mime(offer, mime_type); @@ -1559,9 +1510,8 @@ static const struct zwp_primary_selection_offer_v1_listener primary_selection_of primary_selection_offer_handle_offer, }; -static void -data_device_handle_data_offer(void *data, struct wl_data_device *wl_data_device, - struct wl_data_offer *id) +static void data_device_handle_data_offer(void *data, struct wl_data_device *wl_data_device, + struct wl_data_offer *id) { SDL_WaylandDataOffer *data_offer = NULL; @@ -1577,10 +1527,9 @@ data_device_handle_data_offer(void *data, struct wl_data_device *wl_data_device, } } -static void -data_device_handle_enter(void *data, struct wl_data_device *wl_data_device, - uint32_t serial, struct wl_surface *surface, - wl_fixed_t x, wl_fixed_t y, struct wl_data_offer *id) +static void data_device_handle_enter(void *data, struct wl_data_device *wl_data_device, + uint32_t serial, struct wl_surface *surface, + wl_fixed_t x, wl_fixed_t y, struct wl_data_offer *id) { SDL_WaylandDataDevice *data_device = data; SDL_bool has_mime = SDL_FALSE; @@ -1610,8 +1559,7 @@ data_device_handle_enter(void *data, struct wl_data_device *wl_data_device, } } -static void -data_device_handle_leave(void *data, struct wl_data_device *wl_data_device) +static void data_device_handle_leave(void *data, struct wl_data_device *wl_data_device) { SDL_WaylandDataDevice *data_device = data; SDL_WaylandDataOffer *offer = NULL; @@ -1622,9 +1570,8 @@ data_device_handle_leave(void *data, struct wl_data_device *wl_data_device) } } -static void -data_device_handle_motion(void *data, struct wl_data_device *wl_data_device, - uint32_t time, wl_fixed_t x, wl_fixed_t y) +static void data_device_handle_motion(void *data, struct wl_data_device *wl_data_device, + uint32_t time, wl_fixed_t x, wl_fixed_t y) { } @@ -1643,7 +1590,8 @@ data_device_handle_motion(void *data, struct wl_data_device *wl_data_device, * * FIXME: This was shamelessly copied from SDL_x11events.c */ -static int Wayland_URIDecode(char *buf, int len) { +static int Wayland_URIDecode(char *buf, int len) +{ int ri, wi, di; char decode = '\0'; if (buf == NULL || len < 0) { @@ -1708,12 +1656,13 @@ static int Wayland_URIDecode(char *buf, int len) { * * FIXME: This was shamelessly copied from SDL_x11events.c */ -static char* Wayland_URIToLocal(char* uri) { +static char *Wayland_URIToLocal(char *uri) +{ char *file = NULL; SDL_bool local; - if (SDL_memcmp(uri,"file:/",6) == 0) { - uri += 6; /* local file? */ + if (SDL_memcmp(uri, "file:/", 6) == 0) { + uri += 6; /* local file? */ } else if (SDL_strstr(uri, ":/") != NULL) { return file; /* wrong scheme */ } @@ -1722,33 +1671,32 @@ static char* Wayland_URIToLocal(char* uri) { /* got a hostname? */ if (!local && uri[0] == '/' && uri[2] != '/') { - char* hostname_end = SDL_strchr(uri+1, '/'); - if (hostname_end != NULL) { - char hostname[ 257 ]; - if (gethostname(hostname, 255) == 0) { - hostname[ 256 ] = '\0'; - if (SDL_memcmp(uri+1, hostname, hostname_end - (uri+1)) == 0) { - uri = hostname_end + 1; - local = SDL_TRUE; + char *hostname_end = SDL_strchr(uri + 1, '/'); + if (hostname_end != NULL) { + char hostname[257]; + if (gethostname(hostname, 255) == 0) { + hostname[256] = '\0'; + if (SDL_memcmp(uri + 1, hostname, hostname_end - (uri + 1)) == 0) { + uri = hostname_end + 1; + local = SDL_TRUE; + } } - } - } + } } if (local) { - file = uri; - /* Convert URI escape sequences to real characters */ - Wayland_URIDecode(file, 0); - if (uri[1] == '/') { - file++; - } else { - file--; - } + file = uri; + /* Convert URI escape sequences to real characters */ + Wayland_URIDecode(file, 0); + if (uri[1] == '/') { + file++; + } else { + file--; + } } return file; } -static void -data_device_handle_drop(void *data, struct wl_data_device *wl_data_device) +static void data_device_handle_drop(void *data, struct wl_data_device *wl_data_device) { SDL_WaylandDataDevice *data_device = data; @@ -1759,7 +1707,7 @@ data_device_handle_drop(void *data, struct wl_data_device *wl_data_device) &length, FILE_MIME, SDL_TRUE); if (buffer) { char *saveptr = NULL; - char *token = SDL_strtokr((char *) buffer, "\r\n", &saveptr); + char *token = SDL_strtokr((char *)buffer, "\r\n", &saveptr); while (token != NULL) { char *fn = Wayland_URIToLocal(token); if (fn) { @@ -1773,9 +1721,8 @@ data_device_handle_drop(void *data, struct wl_data_device *wl_data_device) } } -static void -data_device_handle_selection(void *data, struct wl_data_device *wl_data_device, - struct wl_data_offer *id) +static void data_device_handle_selection(void *data, struct wl_data_device *wl_data_device, + struct wl_data_offer *id) { SDL_WaylandDataDevice *data_device = data; SDL_WaylandDataOffer *offer = NULL; @@ -1801,9 +1748,8 @@ static const struct wl_data_device_listener data_device_listener = { data_device_handle_selection }; -static void -primary_selection_device_handle_offer(void *data, struct zwp_primary_selection_device_v1 *zwp_primary_selection_device_v1, - struct zwp_primary_selection_offer_v1 *id) +static void primary_selection_device_handle_offer(void *data, struct zwp_primary_selection_device_v1 *zwp_primary_selection_device_v1, + struct zwp_primary_selection_offer_v1 *id) { SDL_WaylandPrimarySelectionOffer *primary_selection_offer = NULL; @@ -1819,9 +1765,8 @@ primary_selection_device_handle_offer(void *data, struct zwp_primary_selection_d } } -static void -primary_selection_device_handle_selection(void *data, struct zwp_primary_selection_device_v1 *zwp_primary_selection_device_v1, - struct zwp_primary_selection_offer_v1 *id) +static void primary_selection_device_handle_selection(void *data, struct zwp_primary_selection_device_v1 *zwp_primary_selection_device_v1, + struct zwp_primary_selection_offer_v1 *id) { SDL_WaylandPrimarySelectionDevice *primary_selection_device = data; SDL_WaylandPrimarySelectionOffer *offer = NULL; @@ -1843,28 +1788,25 @@ static const struct zwp_primary_selection_device_v1_listener primary_selection_d primary_selection_device_handle_selection }; -static void -text_input_enter(void *data, - struct zwp_text_input_v3 *zwp_text_input_v3, - struct wl_surface *surface) +static void text_input_enter(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + struct wl_surface *surface) { /* No-op */ } -static void -text_input_leave(void *data, - struct zwp_text_input_v3 *zwp_text_input_v3, - struct wl_surface *surface) +static void text_input_leave(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + struct wl_surface *surface) { /* No-op */ } -static void -text_input_preedit_string(void *data, - struct zwp_text_input_v3 *zwp_text_input_v3, - const char *text, - int32_t cursor_begin, - int32_t cursor_end) +static void text_input_preedit_string(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + const char *text, + int32_t cursor_begin, + int32_t cursor_end) { SDL_WaylandTextInput *text_input = data; char buf[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; @@ -1888,7 +1830,7 @@ text_input_preedit_string(void *data, int text_bytes = (int)SDL_strlen(text), i = 0; int cursor = 0; do { - const int sz = (int)SDL_utf8strlcpy(buf, text+i, sizeof(buf)); + const int sz = (int)SDL_utf8strlcpy(buf, text + i, sizeof(buf)); const int chars = (int)SDL_utf8strlen(buf); SDL_SendEditingText(buf, cursor, chars); @@ -1903,17 +1845,16 @@ text_input_preedit_string(void *data, } } -static void -text_input_commit_string(void *data, - struct zwp_text_input_v3 *zwp_text_input_v3, - const char *text) +static void text_input_commit_string(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + const char *text) { if (text && *text) { char buf[SDL_TEXTINPUTEVENT_TEXT_SIZE]; size_t text_bytes = SDL_strlen(text), i = 0; while (i < text_bytes) { - size_t sz = SDL_utf8strlcpy(buf, text+i, sizeof(buf)); + size_t sz = SDL_utf8strlcpy(buf, text + i, sizeof(buf)); SDL_SendKeyboardText(buf); i += sz; @@ -1921,19 +1862,17 @@ text_input_commit_string(void *data, } } -static void -text_input_delete_surrounding_text(void *data, - struct zwp_text_input_v3 *zwp_text_input_v3, - uint32_t before_length, - uint32_t after_length) +static void text_input_delete_surrounding_text(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + uint32_t before_length, + uint32_t after_length) { /* FIXME: Do we care about this event? */ } -static void -text_input_done(void *data, - struct zwp_text_input_v3 *zwp_text_input_v3, - uint32_t serial) +static void text_input_done(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + uint32_t serial) { SDL_WaylandTextInput *text_input = data; if (!text_input->has_preedit) { @@ -1951,8 +1890,7 @@ static const struct zwp_text_input_v3_listener text_input_listener = { text_input_done }; -static void -Wayland_create_data_device(SDL_VideoData *d) +static void Wayland_create_data_device(SDL_VideoData *d) { SDL_WaylandDataDevice *data_device = NULL; @@ -1962,8 +1900,7 @@ Wayland_create_data_device(SDL_VideoData *d) } data_device->data_device = wl_data_device_manager_get_data_device( - d->data_device_manager, d->input->seat - ); + d->data_device_manager, d->input->seat); data_device->video_data = d; if (data_device->data_device == NULL) { @@ -1976,8 +1913,7 @@ Wayland_create_data_device(SDL_VideoData *d) } } -static void -Wayland_create_primary_selection_device(SDL_VideoData *d) +static void Wayland_create_primary_selection_device(SDL_VideoData *d) { SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL; @@ -1987,8 +1923,7 @@ Wayland_create_primary_selection_device(SDL_VideoData *d) } primary_selection_device->primary_selection_device = zwp_primary_selection_device_manager_v1_get_device( - d->primary_selection_device_manager, d->input->seat - ); + d->primary_selection_device_manager, d->input->seat); primary_selection_device->video_data = d; if (primary_selection_device->primary_selection_device == NULL) { @@ -2002,8 +1937,7 @@ Wayland_create_primary_selection_device(SDL_VideoData *d) } } -static void -Wayland_create_text_input(SDL_VideoData *d) +static void Wayland_create_text_input(SDL_VideoData *d) { SDL_WaylandTextInput *text_input = NULL; @@ -2013,8 +1947,7 @@ Wayland_create_text_input(SDL_VideoData *d) } text_input->text_input = zwp_text_input_manager_v3_get_text_input( - d->text_input_manager, d->input->seat - ); + d->text_input_manager, d->input->seat); if (text_input->text_input == NULL) { SDL_free(text_input); @@ -2026,8 +1959,7 @@ Wayland_create_text_input(SDL_VideoData *d) } } -void -Wayland_add_data_device_manager(SDL_VideoData *d, uint32_t id, uint32_t version) +void Wayland_add_data_device_manager(SDL_VideoData *d, uint32_t id, uint32_t version) { d->data_device_manager = wl_registry_bind(d->registry, id, &wl_data_device_manager_interface, SDL_min(3, version)); @@ -2036,8 +1968,7 @@ Wayland_add_data_device_manager(SDL_VideoData *d, uint32_t id, uint32_t version) } } -void -Wayland_add_primary_selection_device_manager(SDL_VideoData *d, uint32_t id, uint32_t version) +void Wayland_add_primary_selection_device_manager(SDL_VideoData *d, uint32_t id, uint32_t version) { d->primary_selection_device_manager = wl_registry_bind(d->registry, id, &zwp_primary_selection_device_manager_v1_interface, 1); @@ -2046,8 +1977,7 @@ Wayland_add_primary_selection_device_manager(SDL_VideoData *d, uint32_t id, uint } } -void -Wayland_add_text_input_manager(SDL_VideoData *d, uint32_t id, uint32_t version) +void Wayland_add_text_input_manager(SDL_VideoData *d, uint32_t id, uint32_t version) { d->text_input_manager = wl_registry_bind(d->registry, id, &zwp_text_input_manager_v3_interface, 1); @@ -2056,47 +1986,40 @@ Wayland_add_text_input_manager(SDL_VideoData *d, uint32_t id, uint32_t version) } } -static void -tablet_tool_handle_type(void* data, struct zwp_tablet_tool_v2* tool, uint32_t type) +static void tablet_tool_handle_type(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t type) { /* unimplemented */ } -static void -tablet_tool_handle_hardware_serial(void* data, struct zwp_tablet_tool_v2* tool, uint32_t serial_hi, uint32_t serial_lo) +static void tablet_tool_handle_hardware_serial(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t serial_hi, uint32_t serial_lo) { /* unimplemented */ } -static void -tablet_tool_handle_hardware_id_wacom(void* data, struct zwp_tablet_tool_v2* tool, uint32_t id_hi, uint32_t id_lo) +static void tablet_tool_handle_hardware_id_wacom(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t id_hi, uint32_t id_lo) { /* unimplemented */ } -static void -tablet_tool_handle_capability(void* data, struct zwp_tablet_tool_v2* tool, uint32_t capability) +static void tablet_tool_handle_capability(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t capability) { /* unimplemented */ } -static void -tablet_tool_handle_done(void* data, struct zwp_tablet_tool_v2* tool) +static void tablet_tool_handle_done(void *data, struct zwp_tablet_tool_v2 *tool) { /* unimplemented */ } -static void -tablet_tool_handle_removed(void* data, struct zwp_tablet_tool_v2* tool) +static void tablet_tool_handle_removed(void *data, struct zwp_tablet_tool_v2 *tool) { /* unimplemented */ } -static void -tablet_tool_handle_proximity_in(void* data, struct zwp_tablet_tool_v2* tool, uint32_t serial, struct zwp_tablet_v2* tablet, struct wl_surface* surface) +static void tablet_tool_handle_proximity_in(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t serial, struct zwp_tablet_v2 *tablet, struct wl_surface *surface) { - struct SDL_WaylandTabletInput* input = data; - SDL_WindowData* window; + struct SDL_WaylandTabletInput *input = data; + SDL_WindowData *window; if (surface == NULL) { return; @@ -2106,7 +2029,7 @@ tablet_tool_handle_proximity_in(void* data, struct zwp_tablet_tool_v2* tool, uin return; } - window = (SDL_WindowData*)wl_surface_get_user_data(surface); + window = (SDL_WindowData *)wl_surface_get_user_data(surface); if (window) { input->tool_focus = window; @@ -2123,10 +2046,9 @@ tablet_tool_handle_proximity_in(void* data, struct zwp_tablet_tool_v2* tool, uin } } -static void -tablet_tool_handle_proximity_out(void* data, struct zwp_tablet_tool_v2* tool) +static void tablet_tool_handle_proximity_out(void *data, struct zwp_tablet_tool_v2 *tool) { - struct SDL_WaylandTabletInput* input = data; + struct SDL_WaylandTabletInput *input = data; if (input->tool_focus) { SDL_SetMouseFocus(NULL); @@ -2135,28 +2057,27 @@ tablet_tool_handle_proximity_out(void* data, struct zwp_tablet_tool_v2* tool) } uint32_t -tablet_tool_btn_to_sdl_button(struct SDL_WaylandTabletInput* input) +tablet_tool_btn_to_sdl_button(struct SDL_WaylandTabletInput *input) { unsigned int tool_btn = input->btn_stylus3 << 2 | input->btn_stylus2 << 1 | input->btn_stylus << 0; switch (tool_btn) { - case 0b000: - return SDL_BUTTON_LEFT; - case 0b001: - return SDL_BUTTON_RIGHT; - case 0b010: - return SDL_BUTTON_MIDDLE; - case 0b100: - return SDL_BUTTON_X1; - default: - return SDL_BUTTON_LEFT; + case 0b000: + return SDL_BUTTON_LEFT; + case 0b001: + return SDL_BUTTON_RIGHT; + case 0b010: + return SDL_BUTTON_MIDDLE; + case 0b100: + return SDL_BUTTON_X1; + default: + return SDL_BUTTON_LEFT; } } -static void -tablet_tool_handle_down(void* data, struct zwp_tablet_tool_v2* tool, uint32_t serial) +static void tablet_tool_handle_down(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t serial) { - struct SDL_WaylandTabletInput* input = data; - SDL_WindowData* window = input->tool_focus; + struct SDL_WaylandTabletInput *input = data; + SDL_WindowData *window = input->tool_focus; input->is_down = SDL_TRUE; if (window == NULL) { /* tablet_tool_handle_proximity_out gets called when moving over the libdecoration csd. @@ -2169,11 +2090,10 @@ tablet_tool_handle_down(void* data, struct zwp_tablet_tool_v2* tool, uint32_t se SDL_SendMouseButton(window->sdlwindow, 0, SDL_PRESSED, tablet_tool_btn_to_sdl_button(input)); } -static void -tablet_tool_handle_up(void* data, struct zwp_tablet_tool_v2* tool) +static void tablet_tool_handle_up(void *data, struct zwp_tablet_tool_v2 *tool) { - struct SDL_WaylandTabletInput* input = data; - SDL_WindowData* window = input->tool_focus; + struct SDL_WaylandTabletInput *input = data; + SDL_WindowData *window = input->tool_focus; input->is_down = SDL_FALSE; @@ -2188,45 +2108,40 @@ tablet_tool_handle_up(void* data, struct zwp_tablet_tool_v2* tool) SDL_SendMouseButton(window->sdlwindow, 0, SDL_RELEASED, tablet_tool_btn_to_sdl_button(input)); } -static void -tablet_tool_handle_motion(void* data, struct zwp_tablet_tool_v2* tool, wl_fixed_t sx_w, wl_fixed_t sy_w) +static void tablet_tool_handle_motion(void *data, struct zwp_tablet_tool_v2 *tool, wl_fixed_t sx_w, wl_fixed_t sy_w) { - struct SDL_WaylandTabletInput* input = data; - SDL_WindowData* window = input->tool_focus; + struct SDL_WaylandTabletInput *input = data; + SDL_WindowData *window = input->tool_focus; input->sx_w = sx_w; input->sy_w = sy_w; if (input->tool_focus) { const float sx_f = (float)wl_fixed_to_double(sx_w); const float sy_f = (float)wl_fixed_to_double(sy_w); - const int sx = (int)SDL_floorf(sx_f * window->pointer_scale_x); - const int sy = (int)SDL_floorf(sy_f * window->pointer_scale_y); + const int sx = (int)SDL_floorf(sx_f * window->pointer_scale_x); + const int sy = (int)SDL_floorf(sy_f * window->pointer_scale_y); SDL_SendMouseMotion(window->sdlwindow, 0, 0, sx, sy); } } -static void -tablet_tool_handle_pressure(void* data, struct zwp_tablet_tool_v2* tool, uint32_t pressure) +static void tablet_tool_handle_pressure(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t pressure) { /* unimplemented */ } -static void -tablet_tool_handle_distance(void* data, struct zwp_tablet_tool_v2* tool, uint32_t distance) +static void tablet_tool_handle_distance(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t distance) { /* unimplemented */ } -static void -tablet_tool_handle_tilt(void* data, struct zwp_tablet_tool_v2* tool, wl_fixed_t xtilt, wl_fixed_t ytilt) +static void tablet_tool_handle_tilt(void *data, struct zwp_tablet_tool_v2 *tool, wl_fixed_t xtilt, wl_fixed_t ytilt) { /* unimplemented */ } -static void -tablet_tool_handle_button(void* data, struct zwp_tablet_tool_v2* tool, uint32_t serial, uint32_t button, uint32_t state) +static void tablet_tool_handle_button(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t serial, uint32_t button, uint32_t state) { - struct SDL_WaylandTabletInput* input = data; + struct SDL_WaylandTabletInput *input = data; if (input->is_down) { tablet_tool_handle_up(data, tool); @@ -2234,16 +2149,16 @@ tablet_tool_handle_button(void* data, struct zwp_tablet_tool_v2* tool, uint32_t } switch (button) { - /* see %{_includedir}/linux/input-event-codes.h */ - case 0x14b: /* BTN_STYLUS */ - input->btn_stylus = state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED ? SDL_TRUE : SDL_FALSE; - break; - case 0x14c: /* BTN_STYLUS2 */ - input->btn_stylus2 = state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED ? SDL_TRUE : SDL_FALSE; - break; - case 0x149: /* BTN_STYLUS3 */ - input->btn_stylus3 = state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED ? SDL_TRUE : SDL_FALSE; - break; + /* see %{_includedir}/linux/input-event-codes.h */ + case 0x14b: /* BTN_STYLUS */ + input->btn_stylus = state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED ? SDL_TRUE : SDL_FALSE; + break; + case 0x14c: /* BTN_STYLUS2 */ + input->btn_stylus2 = state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED ? SDL_TRUE : SDL_FALSE; + break; + case 0x149: /* BTN_STYLUS3 */ + input->btn_stylus3 = state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED ? SDL_TRUE : SDL_FALSE; + break; } if (input->is_down) { @@ -2251,31 +2166,26 @@ tablet_tool_handle_button(void* data, struct zwp_tablet_tool_v2* tool, uint32_t } } -static void -tablet_tool_handle_rotation(void* data, struct zwp_tablet_tool_v2* tool, wl_fixed_t degrees) +static void tablet_tool_handle_rotation(void *data, struct zwp_tablet_tool_v2 *tool, wl_fixed_t degrees) { /* unimplemented */ } -static void -tablet_tool_handle_slider(void* data, struct zwp_tablet_tool_v2* tool, int32_t position) +static void tablet_tool_handle_slider(void *data, struct zwp_tablet_tool_v2 *tool, int32_t position) { /* unimplemented */ } -static void -tablet_tool_handle_wheel(void* data, struct zwp_tablet_tool_v2* tool, int32_t degrees, int32_t clicks) +static void tablet_tool_handle_wheel(void *data, struct zwp_tablet_tool_v2 *tool, int32_t degrees, int32_t clicks) { /* unimplemented */ } -static void -tablet_tool_handle_frame(void* data, struct zwp_tablet_tool_v2* tool, uint32_t time) +static void tablet_tool_handle_frame(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t time) { /* unimplemented */ } - static const struct zwp_tablet_tool_v2_listener tablet_tool_listener = { tablet_tool_handle_type, tablet_tool_handle_hardware_serial, @@ -2298,10 +2208,10 @@ static const struct zwp_tablet_tool_v2_listener tablet_tool_listener = { tablet_tool_handle_frame }; -struct SDL_WaylandTabletObjectListNode* -tablet_object_list_new_node(void* object) +struct SDL_WaylandTabletObjectListNode * +tablet_object_list_new_node(void *object) { - struct SDL_WaylandTabletObjectListNode* node; + struct SDL_WaylandTabletObjectListNode *node; node = SDL_calloc(1, sizeof *node); if (node == NULL) { @@ -2314,7 +2224,7 @@ tablet_object_list_new_node(void* object) return node; } -void tablet_object_list_append(struct SDL_WaylandTabletObjectListNode* head, void* object) +void tablet_object_list_append(struct SDL_WaylandTabletObjectListNode *head, void *object) { if (head->object == NULL) { head->object = object; @@ -2328,10 +2238,10 @@ void tablet_object_list_append(struct SDL_WaylandTabletObjectListNode* head, voi head->next = tablet_object_list_new_node(object); } -void tablet_object_list_destroy(struct SDL_WaylandTabletObjectListNode* head, void (*deleter)(void* object)) +void tablet_object_list_destroy(struct SDL_WaylandTabletObjectListNode *head, void (*deleter)(void *object)) { while (head) { - struct SDL_WaylandTabletObjectListNode* next = head->next; + struct SDL_WaylandTabletObjectListNode *next = head->next; if (head->object) { (*deleter)(head->object); } @@ -2340,19 +2250,16 @@ void tablet_object_list_destroy(struct SDL_WaylandTabletObjectListNode* head, vo } } - -static void -tablet_seat_handle_tablet_added(void* data, struct zwp_tablet_seat_v2* seat, struct zwp_tablet_v2* tablet) +static void tablet_seat_handle_tablet_added(void *data, struct zwp_tablet_seat_v2 *seat, struct zwp_tablet_v2 *tablet) { - struct SDL_WaylandTabletInput* input = data; + struct SDL_WaylandTabletInput *input = data; tablet_object_list_append(input->tablets, tablet); } -static void -tablet_seat_handle_tool_added(void* data, struct zwp_tablet_seat_v2* seat, struct zwp_tablet_tool_v2* tool) +static void tablet_seat_handle_tool_added(void *data, struct zwp_tablet_seat_v2 *seat, struct zwp_tablet_tool_v2 *tool) { - struct SDL_WaylandTabletInput* input = data; + struct SDL_WaylandTabletInput *input = data; zwp_tablet_tool_v2_add_listener(tool, &tablet_tool_listener, data); zwp_tablet_tool_v2_set_user_data(tool, data); @@ -2360,10 +2267,9 @@ tablet_seat_handle_tool_added(void* data, struct zwp_tablet_seat_v2* seat, struc tablet_object_list_append(input->tools, tool); } -static void -tablet_seat_handle_pad_added(void* data, struct zwp_tablet_seat_v2* seat, struct zwp_tablet_pad_v2* pad) +static void tablet_seat_handle_pad_added(void *data, struct zwp_tablet_seat_v2 *seat, struct zwp_tablet_pad_v2 *pad) { - struct SDL_WaylandTabletInput* input = data; + struct SDL_WaylandTabletInput *input = data; tablet_object_list_append(input->pads, pad); } @@ -2374,10 +2280,9 @@ static const struct zwp_tablet_seat_v2_listener tablet_seat_listener = { tablet_seat_handle_pad_added }; -void -Wayland_input_add_tablet(struct SDL_WaylandInput *input, struct SDL_WaylandTabletManager* tablet_manager) +void Wayland_input_add_tablet(struct SDL_WaylandInput *input, struct SDL_WaylandTabletManager *tablet_manager) { - struct SDL_WaylandTabletInput* tablet_input; + struct SDL_WaylandTabletInput *tablet_input; if (tablet_manager == NULL || input == NULL || !input->seat) { return; @@ -2390,31 +2295,29 @@ Wayland_input_add_tablet(struct SDL_WaylandInput *input, struct SDL_WaylandTable input->tablet = tablet_input; - tablet_input->seat = (struct SDL_WaylandTabletSeat*)zwp_tablet_manager_v2_get_tablet_seat((struct zwp_tablet_manager_v2*)tablet_manager, input->seat); + tablet_input->seat = (struct SDL_WaylandTabletSeat *)zwp_tablet_manager_v2_get_tablet_seat((struct zwp_tablet_manager_v2 *)tablet_manager, input->seat); tablet_input->tablets = tablet_object_list_new_node(NULL); tablet_input->tools = tablet_object_list_new_node(NULL); tablet_input->pads = tablet_object_list_new_node(NULL); - zwp_tablet_seat_v2_add_listener((struct zwp_tablet_seat_v2*)tablet_input->seat, &tablet_seat_listener, tablet_input); + zwp_tablet_seat_v2_add_listener((struct zwp_tablet_seat_v2 *)tablet_input->seat, &tablet_seat_listener, tablet_input); } -#define TABLET_OBJECT_LIST_DELETER(fun) (void (*)(void*))fun -void -Wayland_input_destroy_tablet(struct SDL_WaylandInput* input) +#define TABLET_OBJECT_LIST_DELETER(fun) (void (*)(void *)) fun +void Wayland_input_destroy_tablet(struct SDL_WaylandInput *input) { tablet_object_list_destroy(input->tablet->pads, TABLET_OBJECT_LIST_DELETER(zwp_tablet_pad_v2_destroy)); tablet_object_list_destroy(input->tablet->tools, TABLET_OBJECT_LIST_DELETER(zwp_tablet_tool_v2_destroy)); tablet_object_list_destroy(input->tablet->tablets, TABLET_OBJECT_LIST_DELETER(zwp_tablet_v2_destroy)); - zwp_tablet_seat_v2_destroy((struct zwp_tablet_seat_v2*)input->tablet->seat); + zwp_tablet_seat_v2_destroy((struct zwp_tablet_seat_v2 *)input->tablet->seat); SDL_free(input->tablet); input->tablet = NULL; } -void -Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version) +void Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version) { struct SDL_WaylandInput *input; @@ -2547,15 +2450,14 @@ void Wayland_display_destroy_pointer_constraints(SDL_VideoData *d) } } -static void -relative_pointer_handle_relative_motion(void *data, - struct zwp_relative_pointer_v1 *pointer, - uint32_t time_hi, - uint32_t time_lo, - wl_fixed_t dx_w, - wl_fixed_t dy_w, - wl_fixed_t dx_unaccel_w, - wl_fixed_t dy_unaccel_w) +static void relative_pointer_handle_relative_motion(void *data, + struct zwp_relative_pointer_v1 *pointer, + uint32_t time_hi, + uint32_t time_lo, + wl_fixed_t dx_w, + wl_fixed_t dy_w, + wl_fixed_t dx_unaccel_w, + wl_fixed_t dy_unaccel_w) { struct SDL_WaylandInput *input = data; SDL_VideoData *d = input->display; @@ -2584,15 +2486,13 @@ static const struct zwp_relative_pointer_v1_listener relative_pointer_listener = relative_pointer_handle_relative_motion, }; -static void -locked_pointer_locked(void *data, - struct zwp_locked_pointer_v1 *locked_pointer) +static void locked_pointer_locked(void *data, + struct zwp_locked_pointer_v1 *locked_pointer) { } -static void -locked_pointer_unlocked(void *data, - struct zwp_locked_pointer_v1 *locked_pointer) +static void locked_pointer_unlocked(void *data, + struct zwp_locked_pointer_v1 *locked_pointer) { } @@ -2601,9 +2501,8 @@ static const struct zwp_locked_pointer_v1_listener locked_pointer_listener = { locked_pointer_unlocked, }; -static void -lock_pointer_to_window(SDL_Window *window, - struct SDL_WaylandInput *input) +static void lock_pointer_to_window(SDL_Window *window, + struct SDL_WaylandInput *input) { SDL_WindowData *w = window->driverdata; SDL_VideoData *d = input->display; @@ -2708,15 +2607,13 @@ int Wayland_input_unlock_pointer(struct SDL_WaylandInput *input) return 0; } -static void -confined_pointer_confined(void *data, - struct zwp_confined_pointer_v1 *confined_pointer) +static void confined_pointer_confined(void *data, + struct zwp_confined_pointer_v1 *confined_pointer) { } -static void -confined_pointer_unconfined(void *data, - struct zwp_confined_pointer_v1 *confined_pointer) +static void confined_pointer_unconfined(void *data, + struct zwp_confined_pointer_v1 *confined_pointer) { } diff --git a/src/video/wayland/SDL_waylandevents_c.h b/src/video/wayland/SDL_waylandevents_c.h index aab2abf43..7e5cd8a92 100644 --- a/src/video/wayland/SDL_waylandevents_c.h +++ b/src/video/wayland/SDL_waylandevents_c.h @@ -38,17 +38,19 @@ enum SDL_WaylandAxisEvent struct SDL_WaylandTabletSeat; -struct SDL_WaylandTabletObjectListNode { - void* object; - struct SDL_WaylandTabletObjectListNode* next; +struct SDL_WaylandTabletObjectListNode +{ + void *object; + struct SDL_WaylandTabletObjectListNode *next; }; -struct SDL_WaylandTabletInput { - struct SDL_WaylandTabletSeat* seat; +struct SDL_WaylandTabletInput +{ + struct SDL_WaylandTabletSeat *seat; - struct SDL_WaylandTabletObjectListNode* tablets; - struct SDL_WaylandTabletObjectListNode* tools; - struct SDL_WaylandTabletObjectListNode* pads; + struct SDL_WaylandTabletObjectListNode *tablets; + struct SDL_WaylandTabletObjectListNode *tools; + struct SDL_WaylandTabletObjectListNode *pads; SDL_WindowData *tool_focus; uint32_t tool_prox_serial; @@ -64,7 +66,8 @@ struct SDL_WaylandTabletInput { SDL_bool btn_stylus3; }; -typedef struct { +typedef struct +{ // repeat_rate in range of [1, 1000] int32_t repeat_rate; int32_t repeat_delay; @@ -72,14 +75,15 @@ typedef struct { SDL_bool is_key_down; uint32_t key; - uint32_t wl_press_time; // Key press time as reported by the Wayland API + uint32_t wl_press_time; // Key press time as reported by the Wayland API uint32_t sdl_press_time; // Key press time expressed in SDL ticks uint32_t next_repeat_ms; uint32_t scancode; char text[8]; } SDL_WaylandKeyboardRepeat; -struct SDL_WaylandInput { +struct SDL_WaylandInput +{ SDL_VideoData *display; struct wl_seat *seat; struct wl_pointer *pointer; @@ -102,7 +106,8 @@ struct SDL_WaylandInput { double dx_frac; double dy_frac; - struct { + struct + { struct xkb_keymap *keymap; struct xkb_state *state; struct xkb_compose_table *compose_table; @@ -121,7 +126,8 @@ struct SDL_WaylandInput { } xkb; /* information about axis events on current frame */ - struct { + struct + { enum SDL_WaylandAxisEvent x_axis_type; float x; @@ -131,7 +137,7 @@ struct SDL_WaylandInput { SDL_WaylandKeyboardRepeat keyboard_repeat; - struct SDL_WaylandTabletInput* tablet; + struct SDL_WaylandTabletInput *tablet; /* are we forcing relative mouse mode? */ SDL_bool cursor_visible; @@ -166,7 +172,7 @@ extern void Wayland_display_destroy_relative_pointer_manager(SDL_VideoData *d); extern int Wayland_input_grab_keyboard(SDL_Window *window, struct SDL_WaylandInput *input); extern int Wayland_input_ungrab_keyboard(SDL_Window *window); -extern void Wayland_input_add_tablet(struct SDL_WaylandInput *input, struct SDL_WaylandTabletManager* tablet_manager); +extern void Wayland_input_add_tablet(struct SDL_WaylandInput *input, struct SDL_WaylandTabletManager *tablet_manager); extern void Wayland_input_destroy_tablet(struct SDL_WaylandInput *input); #endif /* SDL_waylandevents_h_ */ diff --git a/src/video/wayland/SDL_waylandkeyboard.c b/src/video/wayland/SDL_waylandkeyboard.c index 1f3900b01..676b536fd 100644 --- a/src/video/wayland/SDL_waylandkeyboard.c +++ b/src/video/wayland/SDL_waylandkeyboard.c @@ -27,8 +27,7 @@ #include "SDL_waylandevents_c.h" #include "text-input-unstable-v3-client-protocol.h" -int -Wayland_InitKeyboard(_THIS) +int Wayland_InitKeyboard(_THIS) { #ifdef SDL_USE_IME SDL_VideoData *driverdata = _this->driverdata; @@ -40,8 +39,7 @@ Wayland_InitKeyboard(_THIS) return 0; } -void -Wayland_QuitKeyboard(_THIS) +void Wayland_QuitKeyboard(_THIS) { #ifdef SDL_USE_IME SDL_VideoData *driverdata = _this->driverdata; @@ -51,8 +49,7 @@ Wayland_QuitKeyboard(_THIS) #endif } -void -Wayland_StartTextInput(_THIS) +void Wayland_StartTextInput(_THIS) { SDL_VideoData *driverdata = _this->driverdata; @@ -93,8 +90,7 @@ Wayland_StartTextInput(_THIS) } } -void -Wayland_StopTextInput(_THIS) +void Wayland_StopTextInput(_THIS) { SDL_VideoData *driverdata = _this->driverdata; @@ -114,8 +110,7 @@ Wayland_StopTextInput(_THIS) #endif } -void -Wayland_SetTextInputRect(_THIS, const SDL_Rect *rect) +void Wayland_SetTextInputRect(_THIS, const SDL_Rect *rect) { SDL_VideoData *driverdata = _this->driverdata; diff --git a/src/video/wayland/SDL_waylandmessagebox.c b/src/video/wayland/SDL_waylandmessagebox.c index e2a3b9bc3..b4a15473e 100644 --- a/src/video/wayland/SDL_waylandmessagebox.c +++ b/src/video/wayland/SDL_waylandmessagebox.c @@ -28,15 +28,14 @@ #include /* FILE, STDOUT_FILENO, fdopen, fclose */ #include /* pid_t, pipe, fork, close, dup2, execvp, _exit */ #include /* waitpid, WIFEXITED, WEXITSTATUS */ -#include /* strerr */ +#include /* strerr */ #include #include "SDL_waylandmessagebox.h" -#define MAX_BUTTONS 8 /* Maximum number of buttons supported */ +#define MAX_BUTTONS 8 /* Maximum number of buttons supported */ -int -Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) +int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { int fd_pipe[2]; /* fd_pipe[0]: read end of pipe, fd_pipe[1]: write end of pipe */ pid_t pid1; @@ -50,9 +49,9 @@ Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) } pid1 = fork(); - if (pid1 == 0) { /* child process */ + if (pid1 == 0) { /* child process */ int argc = 5, i; - const char* argv[5 + 2/* icon name */ + 2/* title */ + 2/* message */ + 2*MAX_BUTTONS + 1/* NULL */] = { + const char *argv[5 + 2 /* icon name */ + 2 /* title */ + 2 /* message */ + 2 * MAX_BUTTONS + 1 /* NULL */] = { "zenity", "--question", "--switch", "--no-wrap", "--no-markup" }; @@ -116,9 +115,9 @@ Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) if (WEXITSTATUS(status) < 128) { int i; size_t output_len = 1; - char* output = NULL; - char* tmp = NULL; - FILE* outputfp = NULL; + char *output = NULL; + char *tmp = NULL; + FILE *outputfp = NULL; close(fd_pipe[1]); /* no writing to pipe */ /* At this point, if no button ID is needed, we can just bail as soon as the @@ -177,7 +176,7 @@ Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) } SDL_free(output); - return 0; /* success! */ + return 0; /* success! */ } else { return SDL_SetError("zenity reported error or failed to launch: %d", WEXITSTATUS(status)); } diff --git a/src/video/wayland/SDL_waylandmouse.c b/src/video/wayland/SDL_waylandmouse.c index 2e3a60ed8..07dabd390 100644 --- a/src/video/wayland/SDL_waylandmouse.c +++ b/src/video/wayland/SDL_waylandmouse.c @@ -43,29 +43,28 @@ #include "SDL_hints.h" #include "../../SDL_hints_c.h" -static int -Wayland_SetRelativeMouseMode(SDL_bool enabled); +static int Wayland_SetRelativeMouseMode(SDL_bool enabled); -typedef struct { - struct wl_buffer *buffer; - struct wl_surface *surface; +typedef struct +{ + struct wl_buffer *buffer; + struct wl_surface *surface; - int hot_x, hot_y; - int w, h; + int hot_x, hot_y; + int w, h; /* shm_data is non-NULL for custom cursors. * When shm_data is NULL, system_cursor must be valid */ - SDL_SystemCursor system_cursor; - void *shm_data; + SDL_SystemCursor system_cursor; + void *shm_data; } Wayland_CursorData; #ifdef SDL_USE_LIBDBUS #include "../../core/linux/SDL_dbus.h" -static DBusMessage* -wayland_read_dbus_setting(SDL_DBusContext *dbus, const char *key) +static DBusMessage *wayland_read_dbus_setting(SDL_DBusContext *dbus, const char *key) { static const char *iface = "org.gnome.desktop.interface"; @@ -73,7 +72,7 @@ wayland_read_dbus_setting(SDL_DBusContext *dbus, const char *key) DBusMessage *msg = dbus->message_new_method_call("org.freedesktop.portal.Desktop", /* Node */ "/org/freedesktop/portal/desktop", /* Path */ "org.freedesktop.portal.Settings", /* Interface */ - "Read"); /* Method */ + "Read"); /* Method */ if (msg) { if (dbus->message_append_args(msg, DBUS_TYPE_STRING, &iface, DBUS_TYPE_STRING, &key, DBUS_TYPE_INVALID)) { @@ -85,8 +84,7 @@ wayland_read_dbus_setting(SDL_DBusContext *dbus, const char *key) return reply; } -static SDL_bool -wayland_parse_dbus_reply(SDL_DBusContext *dbus, DBusMessage *reply, int type, void *value) +static SDL_bool wayland_parse_dbus_reply(SDL_DBusContext *dbus, DBusMessage *reply, int type, void *value) { DBusMessageIter iter[3]; @@ -110,8 +108,7 @@ wayland_parse_dbus_reply(SDL_DBusContext *dbus, DBusMessage *reply, int type, vo return SDL_TRUE; } -static SDL_bool -wayland_dbus_read_cursor_size(int *size) +static SDL_bool wayland_dbus_read_cursor_size(int *size) { static const char *cursor_size_value = "cursor-size"; @@ -133,8 +130,7 @@ wayland_dbus_read_cursor_size(int *size) return SDL_FALSE; } -static SDL_bool -wayland_dbus_read_cursor_theme(char **theme) +static SDL_bool wayland_dbus_read_cursor_theme(char **theme) { static const char *cursor_theme_value = "cursor-theme"; @@ -160,8 +156,7 @@ wayland_dbus_read_cursor_theme(char **theme) #endif -static SDL_bool -wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorData *cdata, float *scale) +static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorData *cdata, float *scale) { struct wl_cursor_theme *theme = NULL; struct wl_cursor *cursor; @@ -236,8 +231,7 @@ wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorData *cdata, float } /* Next, find the cursor from the theme... */ - switch(cdata->system_cursor) - { + switch (cdata->system_cursor) { case SDL_SYSTEM_CURSOR_ARROW: cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "left_ptr"); break; @@ -288,8 +282,7 @@ wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorData *cdata, float return SDL_TRUE; } -static int -wayland_create_tmp_file(off_t size) +static int wayland_create_tmp_file(off_t size) { static const char template[] = "/sdl-shared-XXXXXX"; char *xdg_path; @@ -317,8 +310,7 @@ wayland_create_tmp_file(off_t size) return fd; } -static void -mouse_buffer_release(void *data, struct wl_buffer *buffer) +static void mouse_buffer_release(void *data, struct wl_buffer *buffer) { } @@ -326,14 +318,13 @@ static const struct wl_buffer_listener mouse_buffer_listener = { mouse_buffer_release }; -static int -create_buffer_from_shm(Wayland_CursorData *d, - int width, - int height, - uint32_t format) +static int create_buffer_from_shm(Wayland_CursorData *d, + int width, + int height, + uint32_t format) { SDL_VideoDevice *vd = SDL_GetVideoDevice(); - SDL_VideoData *data = (SDL_VideoData *) vd->driverdata; + SDL_VideoData *data = (SDL_VideoData *)vd->driverdata; struct wl_shm_pool *shm_pool; int stride = width * 4; @@ -354,7 +345,7 @@ create_buffer_from_shm(Wayland_CursorData *d, 0); if (d->shm_data == MAP_FAILED) { d->shm_data = NULL; - close (shm_fd); + close(shm_fd); return SDL_SetError("mmap() failed."); } @@ -371,37 +362,35 @@ create_buffer_from_shm(Wayland_CursorData *d, &mouse_buffer_listener, d); - wl_shm_pool_destroy (shm_pool); - close (shm_fd); + wl_shm_pool_destroy(shm_pool); + close(shm_fd); return 0; } -static SDL_Cursor * -Wayland_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) +static SDL_Cursor *Wayland_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) { SDL_Cursor *cursor; - cursor = SDL_calloc(1, sizeof (*cursor)); + cursor = SDL_calloc(1, sizeof(*cursor)); if (cursor) { - SDL_VideoDevice *vd = SDL_GetVideoDevice (); - SDL_VideoData *wd = (SDL_VideoData *) vd->driverdata; - Wayland_CursorData *data = SDL_calloc (1, sizeof (Wayland_CursorData)); + SDL_VideoDevice *vd = SDL_GetVideoDevice(); + SDL_VideoData *wd = (SDL_VideoData *)vd->driverdata; + Wayland_CursorData *data = SDL_calloc(1, sizeof(Wayland_CursorData)); if (data == NULL) { SDL_OutOfMemory(); SDL_free(cursor); return NULL; } - cursor->driverdata = (void *) data; + cursor->driverdata = (void *)data; /* Allocate shared memory buffer for this cursor */ - if (create_buffer_from_shm (data, - surface->w, - surface->h, - WL_SHM_FORMAT_ARGB8888) < 0) - { - SDL_free (cursor->driverdata); - SDL_free (cursor); + if (create_buffer_from_shm(data, + surface->w, + surface->h, + WL_SHM_FORMAT_ARGB8888) < 0) { + SDL_free(cursor->driverdata); + SDL_free(cursor); return NULL; } @@ -424,21 +413,20 @@ Wayland_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) return cursor; } -static SDL_Cursor * -Wayland_CreateSystemCursor(SDL_SystemCursor id) +static SDL_Cursor *Wayland_CreateSystemCursor(SDL_SystemCursor id) { SDL_VideoData *data = SDL_GetVideoDevice()->driverdata; SDL_Cursor *cursor; - cursor = SDL_calloc(1, sizeof (*cursor)); + cursor = SDL_calloc(1, sizeof(*cursor)); if (cursor) { - Wayland_CursorData *cdata = SDL_calloc (1, sizeof (Wayland_CursorData)); + Wayland_CursorData *cdata = SDL_calloc(1, sizeof(Wayland_CursorData)); if (cdata == NULL) { SDL_OutOfMemory(); SDL_free(cursor); return NULL; } - cursor->driverdata = (void *) cdata; + cursor->driverdata = (void *)cdata; cdata->surface = wl_compositor_create_surface(data->compositor); wl_surface_set_user_data(cdata->surface, NULL); @@ -454,14 +442,12 @@ Wayland_CreateSystemCursor(SDL_SystemCursor id) return cursor; } -static SDL_Cursor * -Wayland_CreateDefaultCursor() +static SDL_Cursor *Wayland_CreateDefaultCursor() { return Wayland_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); } -static void -Wayland_FreeCursorData(Wayland_CursorData *d) +static void Wayland_FreeCursorData(Wayland_CursorData *d) { if (d->buffer) { if (d->shm_data) { @@ -476,8 +462,7 @@ Wayland_FreeCursorData(Wayland_CursorData *d) } } -static void -Wayland_FreeCursor(SDL_Cursor *cursor) +static void Wayland_FreeCursor(SDL_Cursor *cursor) { if (cursor == NULL) { return; @@ -488,15 +473,14 @@ Wayland_FreeCursor(SDL_Cursor *cursor) return; } - Wayland_FreeCursorData((Wayland_CursorData *) cursor->driverdata); + Wayland_FreeCursorData((Wayland_CursorData *)cursor->driverdata); /* Not sure what's meant to happen to shm_data */ SDL_free(cursor->driverdata); SDL_free(cursor); } -static int -Wayland_ShowCursor(SDL_Cursor *cursor) +static int Wayland_ShowCursor(SDL_Cursor *cursor) { SDL_VideoDevice *vd = SDL_GetVideoDevice(); SDL_VideoData *d = vd->driverdata; @@ -534,17 +518,16 @@ Wayland_ShowCursor(SDL_Cursor *cursor) Wayland_input_unlock_pointer(input); input->relative_mode_override = SDL_FALSE; } - + } else { input->cursor_visible = SDL_FALSE; wl_pointer_set_cursor(pointer, input->pointer_enter_serial, NULL, 0, 0); } - + return 0; } -static void -Wayland_WarpMouse(SDL_Window *window, int x, int y) +static void Wayland_WarpMouse(SDL_Window *window, int x, int y) { SDL_VideoDevice *vd = SDL_GetVideoDevice(); SDL_VideoData *d = vd->driverdata; @@ -562,18 +545,15 @@ Wayland_WarpMouse(SDL_Window *window, int x, int y) } } -static int -Wayland_WarpMouseGlobal(int x, int y) +static int Wayland_WarpMouseGlobal(int x, int y) { return SDL_Unsupported(); } -static int -Wayland_SetRelativeMouseMode(SDL_bool enabled) +static int Wayland_SetRelativeMouseMode(SDL_bool enabled) { SDL_VideoDevice *vd = SDL_GetVideoDevice(); - SDL_VideoData *data = (SDL_VideoData *) vd->driverdata; - + SDL_VideoData *data = (SDL_VideoData *)vd->driverdata; if (enabled) { /* Disable mouse warp emulation if it's enabled. */ @@ -592,17 +572,15 @@ Wayland_SetRelativeMouseMode(SDL_bool enabled) } } -static void SDLCALL -Wayland_EmulateMouseWarpChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL Wayland_EmulateMouseWarpChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { struct SDL_WaylandInput *input = (struct SDL_WaylandInput *)userdata; input->warp_emulation_prohibited = !SDL_GetStringBoolean(hint, !input->warp_emulation_prohibited); } -#if 0 /* TODO RECONNECT: See waylandvideo.c for more information! */ -static void -Wayland_RecreateCursor(SDL_Cursor *cursor, SDL_VideoData *vdata) +#if 0 /* TODO RECONNECT: See waylandvideo.c for more information! */ +static void Wayland_RecreateCursor(SDL_Cursor *cursor, SDL_VideoData *vdata) { Wayland_CursorData *cdata = (Wayland_CursorData *) cursor->driverdata; @@ -658,8 +636,7 @@ Wayland_RecreateCursors(void) } #endif /* 0 */ -void -Wayland_InitMouse(void) +void Wayland_InitMouse(void) { SDL_Mouse *mouse = SDL_GetMouse(); SDL_VideoDevice *vd = SDL_GetVideoDevice(); @@ -679,12 +656,11 @@ Wayland_InitMouse(void) SDL_SetDefaultCursor(Wayland_CreateDefaultCursor()); - SDL_AddHintCallback(SDL_HINT_VIDEO_WAYLAND_EMULATE_MOUSE_WARP, + SDL_AddHintCallback(SDL_HINT_VIDEO_WAYLAND_EMULATE_MOUSE_WARP, Wayland_EmulateMouseWarpChanged, input); } -void -Wayland_FiniMouse(SDL_VideoData *data) +void Wayland_FiniMouse(SDL_VideoData *data) { struct SDL_WaylandInput *input = data->input; int i; @@ -695,10 +671,10 @@ Wayland_FiniMouse(SDL_VideoData *data) SDL_free(data->cursor_themes); data->cursor_themes = NULL; - SDL_DelHintCallback(SDL_HINT_VIDEO_WAYLAND_EMULATE_MOUSE_WARP, + SDL_DelHintCallback(SDL_HINT_VIDEO_WAYLAND_EMULATE_MOUSE_WARP, Wayland_EmulateMouseWarpChanged, input); } -#endif /* SDL_VIDEO_DRIVER_WAYLAND */ +#endif /* SDL_VIDEO_DRIVER_WAYLAND */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/wayland/SDL_waylandmouse.h b/src/video/wayland/SDL_waylandmouse.h index 00a56af43..abb1e67a0 100644 --- a/src/video/wayland/SDL_waylandmouse.h +++ b/src/video/wayland/SDL_waylandmouse.h @@ -27,7 +27,7 @@ extern void Wayland_InitMouse(void); extern void Wayland_FiniMouse(SDL_VideoData *data); -#if 0 /* TODO RECONNECT: See waylandvideo.c for more information! */ +#if 0 /* TODO RECONNECT: See waylandvideo.c for more information! */ extern void Wayland_RecreateCursors(void); #endif /* 0 */ diff --git a/src/video/wayland/SDL_waylandopengles.c b/src/video/wayland/SDL_waylandopengles.c index 4a85a4d61..677a247be 100644 --- a/src/video/wayland/SDL_waylandopengles.c +++ b/src/video/wayland/SDL_waylandopengles.c @@ -35,10 +35,10 @@ /* EGL implementation of SDL OpenGL ES support */ -int -Wayland_GLES_LoadLibrary(_THIS, const char *path) { +int Wayland_GLES_LoadLibrary(_THIS, const char *path) +{ int ret; - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; ret = SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType) data->display, 0); @@ -48,13 +48,12 @@ Wayland_GLES_LoadLibrary(_THIS, const char *path) { return ret; } - SDL_GLContext -Wayland_GLES_CreateContext(_THIS, SDL_Window * window) +Wayland_GLES_CreateContext(_THIS, SDL_Window *window) { SDL_GLContext context; - context = SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface); - WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display ); + context = SDL_EGL_CreateContext(_this, ((SDL_WindowData *)window->driverdata)->egl_surface); + WAYLAND_wl_display_flush(((SDL_VideoData *)_this->driverdata)->display); return context; } @@ -73,13 +72,12 @@ Wayland_GLES_CreateContext(_THIS, SDL_Window * window) libretro, Wayland, probably others...it feels like we're eventually going to have to give in with a future SDL API revision, since we can bend the other APIs to this style, but this style is much harder to bend the other way. :/ */ -int -Wayland_GLES_SetSwapInterval(_THIS, int interval) +int Wayland_GLES_SetSwapInterval(_THIS, int interval) { if (!_this->egl_data) { return SDL_SetError("EGL not initialized"); } - + /* technically, this is _all_ adaptive vsync (-1), because we can't actually wait for the _next_ vsync if you set 1, but things that request 1 probably won't care _that_ much. I hope. No matter what @@ -96,8 +94,7 @@ Wayland_GLES_SetSwapInterval(_THIS, int interval) return 0; } -int -Wayland_GLES_GetSwapInterval(_THIS) +int Wayland_GLES_GetSwapInterval(_THIS) { if (!_this->egl_data) { SDL_SetError("EGL not initialized"); @@ -107,10 +104,9 @@ Wayland_GLES_GetSwapInterval(_THIS) return _this->egl_data->egl_swapinterval; } -int -Wayland_GLES_SwapWindow(_THIS, SDL_Window *window) +int Wayland_GLES_SwapWindow(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; const int swap_interval = _this->egl_data->egl_swapinterval; /* For windows that we know are hidden, skip swaps entirely, if we don't do @@ -131,8 +127,7 @@ Wayland_GLES_SwapWindow(_THIS, SDL_Window *window) struct wl_display *display = videodata->display; SDL_VideoDisplay *sdldisplay = SDL_GetDisplayForWindow(window); /* ~10 frames (or 1 sec), so we'll progress even if throttled to zero. */ - const Uint32 max_wait = SDL_GetTicks() + (sdldisplay->current_mode.refresh_rate ? - (10000 / sdldisplay->current_mode.refresh_rate) : 1000); + const Uint32 max_wait = SDL_GetTicks() + (sdldisplay->current_mode.refresh_rate ? (10000 / sdldisplay->current_mode.refresh_rate) : 1000); while (SDL_AtomicGet(&data->swap_interval_ready) == 0) { Uint32 now; @@ -173,34 +168,32 @@ Wayland_GLES_SwapWindow(_THIS, SDL_Window *window) return SDL_EGL_SetError("unable to show color buffer in an OS-native window", "eglSwapBuffers"); } - WAYLAND_wl_display_flush( data->waylandData->display ); + WAYLAND_wl_display_flush(data->waylandData->display); return 0; } -int -Wayland_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) +int Wayland_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context) { int ret; if (window && context) { - ret = SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *) window->driverdata)->egl_surface, context); + ret = SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *)window->driverdata)->egl_surface, context); } else { ret = SDL_EGL_MakeCurrent(_this, NULL, NULL); } - WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display ); + WAYLAND_wl_display_flush(((SDL_VideoData *)_this->driverdata)->display); - _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, 0); /* see comments on Wayland_GLES_SetSwapInterval. */ + _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, 0); /* see comments on Wayland_GLES_SetSwapInterval. */ return ret; } -void -Wayland_GLES_DeleteContext(_THIS, SDL_GLContext context) +void Wayland_GLES_DeleteContext(_THIS, SDL_GLContext context) { SDL_EGL_DeleteContext(_this, context); - WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display ); + WAYLAND_wl_display_flush(((SDL_VideoData *)_this->driverdata)->display); } #endif /* SDL_VIDEO_DRIVER_WAYLAND && SDL_VIDEO_OPENGL_EGL */ diff --git a/src/video/wayland/SDL_waylandopengles.h b/src/video/wayland/SDL_waylandopengles.h index b9500b9f1..deef54d7b 100644 --- a/src/video/wayland/SDL_waylandopengles.h +++ b/src/video/wayland/SDL_waylandopengles.h @@ -37,11 +37,11 @@ typedef struct SDL_PrivateGLESData #define Wayland_GLES_UnloadLibrary SDL_EGL_UnloadLibrary extern int Wayland_GLES_LoadLibrary(_THIS, const char *path); -extern SDL_GLContext Wayland_GLES_CreateContext(_THIS, SDL_Window * window); +extern SDL_GLContext Wayland_GLES_CreateContext(_THIS, SDL_Window *window); extern int Wayland_GLES_SetSwapInterval(_THIS, int interval); extern int Wayland_GLES_GetSwapInterval(_THIS); -extern int Wayland_GLES_SwapWindow(_THIS, SDL_Window * window); -extern int Wayland_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); +extern int Wayland_GLES_SwapWindow(_THIS, SDL_Window *window); +extern int Wayland_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); extern void Wayland_GLES_DeleteContext(_THIS, SDL_GLContext context); #endif /* SDL_waylandopengles_h_ */ diff --git a/src/video/wayland/SDL_waylandtouch.c b/src/video/wayland/SDL_waylandtouch.c index b3879f176..3813d7a1f 100644 --- a/src/video/wayland/SDL_waylandtouch.c +++ b/src/video/wayland/SDL_waylandtouch.c @@ -30,42 +30,42 @@ #include "SDL_waylandtouch.h" #include "../../events/SDL_touch_c.h" -struct SDL_WaylandTouch { +struct SDL_WaylandTouch +{ struct qt_touch_extension *touch_extension; }; - /** * Qt TouchPointState * adapted from qtbase/src/corelib/global/qnamespace.h **/ -enum QtWaylandTouchPointState { - QtWaylandTouchPointPressed = 0x01, - QtWaylandTouchPointMoved = 0x02, +enum QtWaylandTouchPointState +{ + QtWaylandTouchPointPressed = 0x01, + QtWaylandTouchPointMoved = 0x02, /* Never sent by the server: QtWaylandTouchPointStationary = 0x04, */ - QtWaylandTouchPointReleased = 0x08, + QtWaylandTouchPointReleased = 0x08, }; -static void -touch_handle_touch(void *data, - struct qt_touch_extension *qt_touch_extension, - uint32_t time, - uint32_t id, - uint32_t state, - int32_t x, - int32_t y, - int32_t normalized_x, - int32_t normalized_y, - int32_t width, - int32_t height, - uint32_t pressure, - int32_t velocity_x, - int32_t velocity_y, - uint32_t flags, - struct wl_array *rawdata) +static void touch_handle_touch(void *data, + struct qt_touch_extension *qt_touch_extension, + uint32_t time, + uint32_t id, + uint32_t state, + int32_t x, + int32_t y, + int32_t normalized_x, + int32_t normalized_y, + int32_t width, + int32_t height, + uint32_t pressure, + int32_t velocity_x, + int32_t velocity_y, + uint32_t flags, + struct wl_array *rawdata) { /** * Event is assembled in QtWayland in TouchExtensionGlobal::postTouchEvent @@ -89,11 +89,11 @@ touch_handle_touch(void *data, uint32_t capabilities = flags >> 16; */ - SDL_Window* window = NULL; + SDL_Window *window = NULL; SDL_TouchID deviceId = 1; if (SDL_AddTouch(deviceId, SDL_TOUCH_DEVICE_DIRECT, "qt_touch_extension") < 0) { - SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__); + SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__); } /* FIXME: This should be the window the given wayland surface is associated @@ -104,29 +104,27 @@ touch_handle_touch(void *data, } switch (touchState) { - case QtWaylandTouchPointPressed: - case QtWaylandTouchPointReleased: - SDL_SendTouch(deviceId, (SDL_FingerID)id, window, - (touchState == QtWaylandTouchPointPressed) ? SDL_TRUE : SDL_FALSE, - xf, yf, pressuref); - break; - case QtWaylandTouchPointMoved: - SDL_SendTouchMotion(deviceId, (SDL_FingerID)id, window, xf, yf, pressuref); - break; - default: - /* Should not happen */ - break; + case QtWaylandTouchPointPressed: + case QtWaylandTouchPointReleased: + SDL_SendTouch(deviceId, (SDL_FingerID)id, window, + (touchState == QtWaylandTouchPointPressed) ? SDL_TRUE : SDL_FALSE, + xf, yf, pressuref); + break; + case QtWaylandTouchPointMoved: + SDL_SendTouchMotion(deviceId, (SDL_FingerID)id, window, xf, yf, pressuref); + break; + default: + /* Should not happen */ + break; } } -static void -touch_handle_configure(void *data, - struct qt_touch_extension *qt_touch_extension, - uint32_t flags) +static void touch_handle_configure(void *data, + struct qt_touch_extension *qt_touch_extension, + uint32_t flags) { } - /* wayland-qt-touch-extension.c BEGINS */ static const struct qt_touch_extension_listener touch_listener = { @@ -161,9 +159,12 @@ static const struct wl_message qt_touch_extension_events[] = { }; const struct wl_interface qt_touch_extension_interface = { - "qt_touch_extension", 1, - 1, qt_touch_extension_requests, - 2, qt_touch_extension_events, + "qt_touch_extension", + 1, + 1, + qt_touch_extension_requests, + 2, + qt_touch_extension_events, }; /* wayland-qt-touch-extension.c ENDS */ @@ -184,9 +185,12 @@ static const struct wl_message qt_windowmanager_events[] = { }; const struct wl_interface qt_windowmanager_interface = { - "qt_windowmanager", 1, - 1, qt_windowmanager_requests, - 2, qt_windowmanager_events, + "qt_windowmanager", + 1, + 1, + qt_windowmanager_requests, + 2, + qt_windowmanager_events, }; /* wayland-qt-windowmanager.c ENDS */ @@ -200,14 +204,14 @@ static const struct wl_interface *qt_surface_extension_types[] = { NULL, &qt_extended_surface_interface, #ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC - /* FIXME: Set this dynamically to (*WAYLAND_wl_surface_interface) ? - * The value comes from auto generated code and does + /* FIXME: Set this dynamically to (*WAYLAND_wl_surface_interface) ? + * The value comes from auto generated code and does * not appear to actually be used anywhere */ - NULL, + NULL, #else &wl_surface_interface, -#endif +#endif }; static const struct wl_message qt_surface_extension_requests[] = { @@ -215,9 +219,12 @@ static const struct wl_message qt_surface_extension_requests[] = { }; const struct wl_interface qt_surface_extension_interface = { - "qt_surface_extension", 1, - 1, qt_surface_extension_requests, - 0, NULL, + "qt_surface_extension", + 1, + 1, + qt_surface_extension_requests, + 0, + NULL, }; static const struct wl_message qt_extended_surface_requests[] = { @@ -233,15 +240,17 @@ static const struct wl_message qt_extended_surface_events[] = { }; const struct wl_interface qt_extended_surface_interface = { - "qt_extended_surface", 1, - 3, qt_extended_surface_requests, - 3, qt_extended_surface_events, + "qt_extended_surface", + 1, + 3, + qt_extended_surface_requests, + 3, + qt_extended_surface_events, }; /* wayland-qt-surface-extension.c ENDS */ -void -Wayland_touch_create(SDL_VideoData *data, uint32_t id) +void Wayland_touch_create(SDL_VideoData *data, uint32_t id) { struct SDL_WaylandTouch *touch; @@ -257,8 +266,7 @@ Wayland_touch_create(SDL_VideoData *data, uint32_t id) qt_touch_extension_add_listener(touch->touch_extension, &touch_listener, data); } -void -Wayland_touch_destroy(SDL_VideoData *data) +void Wayland_touch_destroy(SDL_VideoData *data) { if (data->touch) { struct SDL_WaylandTouch *touch = data->touch; diff --git a/src/video/wayland/SDL_waylandtouch.h b/src/video/wayland/SDL_waylandtouch.h index 8487adb9a..80667a126 100644 --- a/src/video/wayland/SDL_waylandtouch.h +++ b/src/video/wayland/SDL_waylandtouch.h @@ -31,7 +31,6 @@ #include #include "wayland-util.h" - void Wayland_touch_create(SDL_VideoData *data, uint32_t id); void Wayland_touch_destroy(SDL_VideoData *data); @@ -72,45 +71,42 @@ struct qt_extended_surface; extern const struct wl_interface qt_surface_extension_interface; extern const struct wl_interface qt_extended_surface_interface; -#define QT_SURFACE_EXTENSION_GET_EXTENDED_SURFACE 0 +#define QT_SURFACE_EXTENSION_GET_EXTENDED_SURFACE 0 -static inline void -qt_surface_extension_set_user_data(struct qt_surface_extension *qt_surface_extension, void *user_data) +static inline void qt_surface_extension_set_user_data(struct qt_surface_extension *qt_surface_extension, void *user_data) { - wl_proxy_set_user_data((struct wl_proxy *) qt_surface_extension, user_data); + wl_proxy_set_user_data((struct wl_proxy *)qt_surface_extension, user_data); } -static inline void * -qt_surface_extension_get_user_data(struct qt_surface_extension *qt_surface_extension) +static inline void *qt_surface_extension_get_user_data(struct qt_surface_extension *qt_surface_extension) { - return wl_proxy_get_user_data((struct wl_proxy *) qt_surface_extension); + return wl_proxy_get_user_data((struct wl_proxy *)qt_surface_extension); } -static inline void -qt_surface_extension_destroy(struct qt_surface_extension *qt_surface_extension) +static inline void qt_surface_extension_destroy(struct qt_surface_extension *qt_surface_extension) { - WAYLAND_wl_proxy_destroy((struct wl_proxy *) qt_surface_extension); + WAYLAND_wl_proxy_destroy((struct wl_proxy *)qt_surface_extension); } -static inline struct qt_extended_surface * -qt_surface_extension_get_extended_surface(struct qt_surface_extension *qt_surface_extension, struct wl_surface *surface) +static inline struct qt_extended_surface *qt_surface_extension_get_extended_surface(struct qt_surface_extension *qt_surface_extension, struct wl_surface *surface) { struct wl_proxy *id; - id = wl_proxy_create((struct wl_proxy *) qt_surface_extension, - &qt_extended_surface_interface); + id = wl_proxy_create((struct wl_proxy *)qt_surface_extension, + &qt_extended_surface_interface); if (id == NULL) return NULL; - WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_surface_extension, - QT_SURFACE_EXTENSION_GET_EXTENDED_SURFACE, id, surface); + WAYLAND_wl_proxy_marshal((struct wl_proxy *)qt_surface_extension, + QT_SURFACE_EXTENSION_GET_EXTENDED_SURFACE, id, surface); - return (struct qt_extended_surface *) id; + return (struct qt_extended_surface *)id; } #ifndef QT_EXTENDED_SURFACE_ORIENTATION_ENUM #define QT_EXTENDED_SURFACE_ORIENTATION_ENUM -enum qt_extended_surface_orientation { +enum qt_extended_surface_orientation +{ QT_EXTENDED_SURFACE_ORIENTATION_PRIMARYORIENTATION = 0, QT_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION = 1, QT_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION = 2, @@ -121,85 +117,80 @@ enum qt_extended_surface_orientation { #ifndef QT_EXTENDED_SURFACE_WINDOWFLAG_ENUM #define QT_EXTENDED_SURFACE_WINDOWFLAG_ENUM -enum qt_extended_surface_windowflag { +enum qt_extended_surface_windowflag +{ QT_EXTENDED_SURFACE_WINDOWFLAG_OVERRIDESSYSTEMGESTURES = 1, QT_EXTENDED_SURFACE_WINDOWFLAG_STAYSONTOP = 2, }; #endif /* QT_EXTENDED_SURFACE_WINDOWFLAG_ENUM */ -struct qt_extended_surface_listener { +struct qt_extended_surface_listener +{ /** * onscreen_visibility - (none) * @visible: (none) */ void (*onscreen_visibility)(void *data, - struct qt_extended_surface *qt_extended_surface, - int32_t visible); + struct qt_extended_surface *qt_extended_surface, + int32_t visible); /** * set_generic_property - (none) * @name: (none) * @value: (none) */ void (*set_generic_property)(void *data, - struct qt_extended_surface *qt_extended_surface, - const char *name, - struct wl_array *value); + struct qt_extended_surface *qt_extended_surface, + const char *name, + struct wl_array *value); /** * close - (none) */ void (*close)(void *data, - struct qt_extended_surface *qt_extended_surface); + struct qt_extended_surface *qt_extended_surface); }; -static inline int -qt_extended_surface_add_listener(struct qt_extended_surface *qt_extended_surface, - const struct qt_extended_surface_listener *listener, void *data) +static inline int qt_extended_surface_add_listener(struct qt_extended_surface *qt_extended_surface, + const struct qt_extended_surface_listener *listener, void *data) { - return wl_proxy_add_listener((struct wl_proxy *) qt_extended_surface, - (void (**)(void)) listener, data); + return wl_proxy_add_listener((struct wl_proxy *)qt_extended_surface, + (void (**)(void))listener, data); } #define QT_EXTENDED_SURFACE_UPDATE_GENERIC_PROPERTY 0 #define QT_EXTENDED_SURFACE_SET_CONTENT_ORIENTATION 1 -#define QT_EXTENDED_SURFACE_SET_WINDOW_FLAGS 2 +#define QT_EXTENDED_SURFACE_SET_WINDOW_FLAGS 2 -static inline void -qt_extended_surface_set_user_data(struct qt_extended_surface *qt_extended_surface, void *user_data) +static inline void qt_extended_surface_set_user_data(struct qt_extended_surface *qt_extended_surface, void *user_data) { - WAYLAND_wl_proxy_set_user_data((struct wl_proxy *) qt_extended_surface, user_data); + WAYLAND_wl_proxy_set_user_data((struct wl_proxy *)qt_extended_surface, user_data); } -static inline void * -qt_extended_surface_get_user_data(struct qt_extended_surface *qt_extended_surface) +static inline void *qt_extended_surface_get_user_data(struct qt_extended_surface *qt_extended_surface) { - return WAYLAND_wl_proxy_get_user_data((struct wl_proxy *) qt_extended_surface); + return WAYLAND_wl_proxy_get_user_data((struct wl_proxy *)qt_extended_surface); } -static inline void -qt_extended_surface_destroy(struct qt_extended_surface *qt_extended_surface) +static inline void qt_extended_surface_destroy(struct qt_extended_surface *qt_extended_surface) { - WAYLAND_wl_proxy_destroy((struct wl_proxy *) qt_extended_surface); + WAYLAND_wl_proxy_destroy((struct wl_proxy *)qt_extended_surface); } -static inline void -qt_extended_surface_update_generic_property(struct qt_extended_surface *qt_extended_surface, const char *name, struct wl_array *value) +static inline void qt_extended_surface_update_generic_property(struct qt_extended_surface *qt_extended_surface, const char *name, struct wl_array *value) { - WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_extended_surface, - QT_EXTENDED_SURFACE_UPDATE_GENERIC_PROPERTY, name, value); + WAYLAND_wl_proxy_marshal((struct wl_proxy *)qt_extended_surface, + QT_EXTENDED_SURFACE_UPDATE_GENERIC_PROPERTY, name, value); } -static inline void -qt_extended_surface_set_content_orientation(struct qt_extended_surface *qt_extended_surface, int32_t orientation) +static inline void qt_extended_surface_set_content_orientation(struct qt_extended_surface *qt_extended_surface, int32_t orientation) { - WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_extended_surface, - QT_EXTENDED_SURFACE_SET_CONTENT_ORIENTATION, orientation); + WAYLAND_wl_proxy_marshal((struct wl_proxy *)qt_extended_surface, + QT_EXTENDED_SURFACE_SET_CONTENT_ORIENTATION, orientation); } -static inline void -qt_extended_surface_set_window_flags(struct qt_extended_surface *qt_extended_surface, int32_t flags) +static inline void qt_extended_surface_set_window_flags(struct qt_extended_surface *qt_extended_surface, int32_t flags) { - WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_extended_surface, - QT_EXTENDED_SURFACE_SET_WINDOW_FLAGS, flags); + WAYLAND_wl_proxy_marshal((struct wl_proxy *)qt_extended_surface, + QT_EXTENDED_SURFACE_SET_WINDOW_FLAGS, flags); } /* wayland-qt-touch-extension.h */ @@ -208,12 +199,14 @@ extern const struct wl_interface qt_touch_extension_interface; #ifndef QT_TOUCH_EXTENSION_FLAGS_ENUM #define QT_TOUCH_EXTENSION_FLAGS_ENUM -enum qt_touch_extension_flags { +enum qt_touch_extension_flags +{ QT_TOUCH_EXTENSION_FLAGS_MOUSE_FROM_TOUCH = 0x1, }; #endif /* QT_TOUCH_EXTENSION_FLAGS_ENUM */ -struct qt_touch_extension_listener { +struct qt_touch_extension_listener +{ /** * touch - (none) * @time: (none) @@ -232,118 +225,108 @@ struct qt_touch_extension_listener { * @rawdata: (none) */ void (*touch)(void *data, - struct qt_touch_extension *qt_touch_extension, - uint32_t time, - uint32_t id, - uint32_t state, - int32_t x, - int32_t y, - int32_t normalized_x, - int32_t normalized_y, - int32_t width, - int32_t height, - uint32_t pressure, - int32_t velocity_x, - int32_t velocity_y, - uint32_t flags, - struct wl_array *rawdata); + struct qt_touch_extension *qt_touch_extension, + uint32_t time, + uint32_t id, + uint32_t state, + int32_t x, + int32_t y, + int32_t normalized_x, + int32_t normalized_y, + int32_t width, + int32_t height, + uint32_t pressure, + int32_t velocity_x, + int32_t velocity_y, + uint32_t flags, + struct wl_array *rawdata); /** * configure - (none) * @flags: (none) */ void (*configure)(void *data, - struct qt_touch_extension *qt_touch_extension, - uint32_t flags); + struct qt_touch_extension *qt_touch_extension, + uint32_t flags); }; -static inline int -qt_touch_extension_add_listener(struct qt_touch_extension *qt_touch_extension, - const struct qt_touch_extension_listener *listener, void *data) +static inline int qt_touch_extension_add_listener(struct qt_touch_extension *qt_touch_extension, + const struct qt_touch_extension_listener *listener, void *data) { - return wl_proxy_add_listener((struct wl_proxy *) qt_touch_extension, - (void (**)(void)) listener, data); + return wl_proxy_add_listener((struct wl_proxy *)qt_touch_extension, + (void (**)(void))listener, data); } -#define QT_TOUCH_EXTENSION_DUMMY 0 +#define QT_TOUCH_EXTENSION_DUMMY 0 -static inline void -qt_touch_extension_set_user_data(struct qt_touch_extension *qt_touch_extension, void *user_data) +static inline void qt_touch_extension_set_user_data(struct qt_touch_extension *qt_touch_extension, void *user_data) { - WAYLAND_wl_proxy_set_user_data((struct wl_proxy *) qt_touch_extension, user_data); + WAYLAND_wl_proxy_set_user_data((struct wl_proxy *)qt_touch_extension, user_data); } -static inline void * -qt_touch_extension_get_user_data(struct qt_touch_extension *qt_touch_extension) +static inline void *qt_touch_extension_get_user_data(struct qt_touch_extension *qt_touch_extension) { - return WAYLAND_wl_proxy_get_user_data((struct wl_proxy *) qt_touch_extension); + return WAYLAND_wl_proxy_get_user_data((struct wl_proxy *)qt_touch_extension); } -static inline void -qt_touch_extension_destroy(struct qt_touch_extension *qt_touch_extension) +static inline void qt_touch_extension_destroy(struct qt_touch_extension *qt_touch_extension) { - WAYLAND_wl_proxy_destroy((struct wl_proxy *) qt_touch_extension); + WAYLAND_wl_proxy_destroy((struct wl_proxy *)qt_touch_extension); } -static inline void -qt_touch_extension_dummy(struct qt_touch_extension *qt_touch_extension) +static inline void qt_touch_extension_dummy(struct qt_touch_extension *qt_touch_extension) { - WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_touch_extension, - QT_TOUCH_EXTENSION_DUMMY); + WAYLAND_wl_proxy_marshal((struct wl_proxy *)qt_touch_extension, + QT_TOUCH_EXTENSION_DUMMY); } - /* wayland-qt-windowmanager.h */ extern const struct wl_interface qt_windowmanager_interface; -struct qt_windowmanager_listener { +struct qt_windowmanager_listener +{ /** * hints - (none) * @show_is_fullscreen: (none) */ void (*hints)(void *data, - struct qt_windowmanager *qt_windowmanager, - int32_t show_is_fullscreen); + struct qt_windowmanager *qt_windowmanager, + int32_t show_is_fullscreen); /** * quit - (none) */ void (*quit)(void *data, - struct qt_windowmanager *qt_windowmanager); + struct qt_windowmanager *qt_windowmanager); }; -static inline int -qt_windowmanager_add_listener(struct qt_windowmanager *qt_windowmanager, - const struct qt_windowmanager_listener *listener, void *data) +static inline int qt_windowmanager_add_listener(struct qt_windowmanager *qt_windowmanager, + const struct qt_windowmanager_listener *listener, void *data) { - return wl_proxy_add_listener((struct wl_proxy *) qt_windowmanager, - (void (**)(void)) listener, data); + return wl_proxy_add_listener((struct wl_proxy *)qt_windowmanager, + (void (**)(void))listener, data); } -#define QT_WINDOWMANAGER_OPEN_URL 0 +#define QT_WINDOWMANAGER_OPEN_URL 0 -static inline void -qt_windowmanager_set_user_data(struct qt_windowmanager *qt_windowmanager, void *user_data) +static inline void qt_windowmanager_set_user_data(struct qt_windowmanager *qt_windowmanager, void *user_data) { - WAYLAND_wl_proxy_set_user_data((struct wl_proxy *) qt_windowmanager, user_data); + WAYLAND_wl_proxy_set_user_data((struct wl_proxy *)qt_windowmanager, user_data); } -static inline void * -qt_windowmanager_get_user_data(struct qt_windowmanager *qt_windowmanager) +static inline void *qt_windowmanager_get_user_data(struct qt_windowmanager *qt_windowmanager) { - return WAYLAND_wl_proxy_get_user_data((struct wl_proxy *) qt_windowmanager); + return WAYLAND_wl_proxy_get_user_data((struct wl_proxy *)qt_windowmanager); } -static inline void -qt_windowmanager_destroy(struct qt_windowmanager *qt_windowmanager) +static inline void qt_windowmanager_destroy(struct qt_windowmanager *qt_windowmanager) { - WAYLAND_wl_proxy_destroy((struct wl_proxy *) qt_windowmanager); + WAYLAND_wl_proxy_destroy((struct wl_proxy *)qt_windowmanager); } -static inline void -qt_windowmanager_open_url(struct qt_windowmanager *qt_windowmanager, uint32_t remaining, const char *url) +static inline void qt_windowmanager_open_url(struct qt_windowmanager *qt_windowmanager, uint32_t remaining, const char *url) { - WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_windowmanager, - QT_WINDOWMANAGER_OPEN_URL, remaining, url); + WAYLAND_wl_proxy_marshal((struct wl_proxy *)qt_windowmanager, + QT_WINDOWMANAGER_OPEN_URL, remaining, url); } #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */ diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c index 80887cb77..76c3e4d4a 100644 --- a/src/video/wayland/SDL_waylandvideo.c +++ b/src/video/wayland/SDL_waylandvideo.c @@ -64,32 +64,26 @@ #define WAYLANDVID_DRIVER_NAME "wayland" -static void -display_handle_done(void *data, struct wl_output *output); +static void display_handle_done(void *data, struct wl_output *output); /* Initialization/Query functions */ -static int -Wayland_VideoInit(_THIS); +static int Wayland_VideoInit(_THIS); -static int -Wayland_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect); +static int Wayland_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect); -static int -Wayland_GetDisplayDPI(_THIS, SDL_VideoDisplay * sdl_display, float * ddpi, float * hdpi, float * vdpi); +static int Wayland_GetDisplayDPI(_THIS, SDL_VideoDisplay *sdl_display, float *ddpi, float *hdpi, float *vdpi); -static void -Wayland_VideoQuit(_THIS); +static void Wayland_VideoQuit(_THIS); /* Find out what class name we should use * Based on src/video/x11/SDL_x11video.c */ -static char * -get_classname() +static char *get_classname() { -/* !!! FIXME: this is probably wrong, albeit harmless in many common cases. From protocol spec: - "The surface class identifies the general class of applications - to which the surface belongs. A common convention is to use the - file name (or the full path if it is a non-standard location) of - the application's .desktop file as the class." */ + /* !!! FIXME: this is probably wrong, albeit harmless in many common cases. From protocol spec: + "The surface class identifies the general class of applications + to which the surface belongs. A common convention is to use the + file name (or the full path if it is a non-standard location) of + the application's .desktop file as the class." */ char *spot; #if defined(__LINUX__) || defined(__FREEBSD__) @@ -151,16 +145,15 @@ void SDL_WAYLAND_register_output(struct wl_output *output) SDL_bool SDL_WAYLAND_own_surface(struct wl_surface *surface) { - return wl_proxy_get_tag((struct wl_proxy *) surface) == &SDL_WAYLAND_surface_tag; + return wl_proxy_get_tag((struct wl_proxy *)surface) == &SDL_WAYLAND_surface_tag; } SDL_bool SDL_WAYLAND_own_output(struct wl_output *output) { - return wl_proxy_get_tag((struct wl_proxy *) output) == &SDL_WAYLAND_output_tag; + return wl_proxy_get_tag((struct wl_proxy *)output) == &SDL_WAYLAND_output_tag; } -static void -Wayland_DeleteDevice(SDL_VideoDevice *device) +static void Wayland_DeleteDevice(SDL_VideoDevice *device) { SDL_VideoData *data = (SDL_VideoData *)device->driverdata; if (data->display) { @@ -175,8 +168,7 @@ Wayland_DeleteDevice(SDL_VideoDevice *device) SDL_WAYLAND_UnloadSymbols(); } -static SDL_VideoDevice * -Wayland_CreateDevice(void) +static SDL_VideoDevice *Wayland_CreateDevice(void) { SDL_VideoDevice *device; SDL_VideoData *data; @@ -294,22 +286,20 @@ VideoBootStrap Wayland_bootstrap = { Wayland_CreateDevice }; -static void -xdg_output_handle_logical_position(void *data, struct zxdg_output_v1 *xdg_output, - int32_t x, int32_t y) +static void xdg_output_handle_logical_position(void *data, struct zxdg_output_v1 *xdg_output, + int32_t x, int32_t y) { - SDL_WaylandOutputData* driverdata = data; + SDL_WaylandOutputData *driverdata = data; driverdata->x = x; driverdata->y = y; driverdata->has_logical_position = SDL_TRUE; } -static void -xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xdg_output, - int32_t width, int32_t height) +static void xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xdg_output, + int32_t width, int32_t height) { - SDL_WaylandOutputData* driverdata = data; + SDL_WaylandOutputData *driverdata = data; if (driverdata->width != 0 && driverdata->height != 0) { /* FIXME: GNOME has a bug where the logical size does not account for @@ -320,12 +310,11 @@ xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xdg_output, * detected otherwise), then override if necessary. * -flibit */ - const float scale = (float) driverdata->width / (float) width; + const float scale = (float)driverdata->width / (float)width; if ((scale == 1.0f) && (driverdata->scale_factor != 1.0f)) { SDL_LogWarn( SDL_LOG_CATEGORY_VIDEO, - "xdg_output scale did not match, overriding with wl_output scale" - ); + "xdg_output scale did not match, overriding with wl_output scale"); return; } } @@ -335,10 +324,9 @@ xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xdg_output, driverdata->has_logical_size = SDL_TRUE; } -static void -xdg_output_handle_done(void *data, struct zxdg_output_v1 *xdg_output) +static void xdg_output_handle_done(void *data, struct zxdg_output_v1 *xdg_output) { - SDL_WaylandOutputData* driverdata = data; + SDL_WaylandOutputData *driverdata = data; /* * xdg-output.done events are deprecated and only apply below version 3 of the protocol. @@ -349,17 +337,15 @@ xdg_output_handle_done(void *data, struct zxdg_output_v1 *xdg_output) } } -static void -xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output, - const char *name) +static void xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output, + const char *name) { } -static void -xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg_output, - const char *description) +static void xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg_output, + const char *description) { - SDL_WaylandOutputData* driverdata = data; + SDL_WaylandOutputData *driverdata = data; if (driverdata->index == -1) { /* xdg-output descriptions, if available, supersede wl-output model names. */ @@ -372,15 +358,14 @@ xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg_output, } static const struct zxdg_output_v1_listener xdg_output_listener = { - xdg_output_handle_logical_position, - xdg_output_handle_logical_size, - xdg_output_handle_done, - xdg_output_handle_name, - xdg_output_handle_description, + xdg_output_handle_logical_position, + xdg_output_handle_logical_size, + xdg_output_handle_done, + xdg_output_handle_name, + xdg_output_handle_description, }; -static void -AddEmulatedModes(SDL_VideoDisplay *dpy, SDL_bool rot_90) +static void AddEmulatedModes(SDL_VideoDisplay *dpy, SDL_bool rot_90) { struct EmulatedMode { @@ -432,7 +417,7 @@ AddEmulatedModes(SDL_VideoDisplay *dpy, SDL_bool rot_90) int i; SDL_DisplayMode mode; - const int native_width = dpy->display_modes->w; + const int native_width = dpy->display_modes->w; const int native_height = dpy->display_modes->h; for (i = 0; i < SDL_arraysize(mode_list); ++i) { @@ -455,16 +440,15 @@ AddEmulatedModes(SDL_VideoDisplay *dpy, SDL_bool rot_90) } } -static void -display_handle_geometry(void *data, - struct wl_output *output, - int x, int y, - int physical_width, - int physical_height, - int subpixel, - const char *make, - const char *model, - int transform) +static void display_handle_geometry(void *data, + struct wl_output *output, + int x, int y, + int physical_width, + int physical_height, + int subpixel, + const char *make, + const char *model, + int transform) { SDL_WaylandOutputData *driverdata = data; @@ -499,10 +483,10 @@ display_handle_geometry(void *data, } driverdata->transform = transform; - #define TF_CASE(in, out) \ - case WL_OUTPUT_TRANSFORM_##in: \ - driverdata->orientation = SDL_ORIENTATION_##out; \ - break; +#define TF_CASE(in, out) \ + case WL_OUTPUT_TRANSFORM_##in: \ + driverdata->orientation = SDL_ORIENTATION_##out; \ + break; if (driverdata->physical_width >= driverdata->physical_height) { switch (transform) { TF_CASE(NORMAL, LANDSCAPE) @@ -526,21 +510,20 @@ display_handle_geometry(void *data, TF_CASE(FLIPPED_270, LANDSCAPE) } } - #undef TF_CASE +#undef TF_CASE } -static void -display_handle_mode(void *data, - struct wl_output *output, - uint32_t flags, - int width, - int height, - int refresh) +static void display_handle_mode(void *data, + struct wl_output *output, + uint32_t flags, + int width, + int height, + int refresh) { - SDL_WaylandOutputData* driverdata = data; + SDL_WaylandOutputData *driverdata = data; if (flags & WL_OUTPUT_MODE_CURRENT) { - driverdata->native_width = width; + driverdata->native_width = width; driverdata->native_height = height; /* @@ -548,7 +531,7 @@ display_handle_mode(void *data, * handle_done and xdg-output coordinates are pre-transformed. */ if (!driverdata->has_logical_size) { - driverdata->width = width; + driverdata->width = width; driverdata->height = height; } @@ -556,12 +539,11 @@ display_handle_mode(void *data, } } -static void -display_handle_done(void *data, - struct wl_output *output) +static void display_handle_done(void *data, + struct wl_output *output) { - SDL_WaylandOutputData* driverdata = data; - SDL_VideoData* video = driverdata->videodata; + SDL_WaylandOutputData *driverdata = data; + SDL_VideoData *video = driverdata->videodata; SDL_DisplayMode native_mode, desktop_mode; SDL_VideoDisplay *dpy; const SDL_bool mode_emulation_enabled = SDL_GetHintBoolean(SDL_HINT_VIDEO_WAYLAND_MODE_EMULATION, SDL_TRUE); @@ -592,7 +574,7 @@ display_handle_done(void *data, native_mode.h = driverdata->native_height; } native_mode.refresh_rate = (int)SDL_round(driverdata->refresh / 1000.0); /* mHz to Hz */ - native_mode.driverdata = driverdata->output; + native_mode.driverdata = driverdata->output; /* The scaled desktop mode */ SDL_zero(desktop_mode); @@ -630,27 +612,19 @@ display_handle_done(void *data, /* Calculate the display DPI */ if (driverdata->transform & WL_OUTPUT_TRANSFORM_90) { - driverdata->hdpi = driverdata->physical_height ? - (((float) driverdata->height) * 25.4f / driverdata->physical_height) : - 0.0f; - driverdata->vdpi = driverdata->physical_width ? - (((float) driverdata->width) * 25.4f / driverdata->physical_width) : - 0.0f; + driverdata->hdpi = driverdata->physical_height ? (((float)driverdata->height) * 25.4f / driverdata->physical_height) : 0.0f; + driverdata->vdpi = driverdata->physical_width ? (((float)driverdata->width) * 25.4f / driverdata->physical_width) : 0.0f; driverdata->ddpi = SDL_ComputeDiagonalDPI(driverdata->height, driverdata->width, - ((float) driverdata->physical_height) / 25.4f, - ((float) driverdata->physical_width) / 25.4f); + ((float)driverdata->physical_height) / 25.4f, + ((float)driverdata->physical_width) / 25.4f); } else { - driverdata->hdpi = driverdata->physical_width ? - (((float) driverdata->width) * 25.4f / driverdata->physical_width) : - 0.0f; - driverdata->vdpi = driverdata->physical_height ? - (((float) driverdata->height) * 25.4f / driverdata->physical_height) : - 0.0f; + driverdata->hdpi = driverdata->physical_width ? (((float)driverdata->width) * 25.4f / driverdata->physical_width) : 0.0f; + driverdata->vdpi = driverdata->physical_height ? (((float)driverdata->height) * 25.4f / driverdata->physical_height) : 0.0f; driverdata->ddpi = SDL_ComputeDiagonalDPI(driverdata->width, driverdata->height, - ((float) driverdata->physical_width) / 25.4f, - ((float) driverdata->physical_height) / 25.4f); + ((float)driverdata->physical_width) / 25.4f, + ((float)driverdata->physical_height) / 25.4f); } if (driverdata->index > -1) { @@ -683,10 +657,9 @@ display_handle_done(void *data, } } -static void -display_handle_scale(void *data, - struct wl_output *output, - int32_t factor) +static void display_handle_scale(void *data, + struct wl_output *output, + int32_t factor) { SDL_WaylandOutputData *driverdata = data; driverdata->scale_factor = factor; @@ -699,8 +672,7 @@ static const struct wl_output_listener output_listener = { display_handle_scale }; -static void -Wayland_add_display(SDL_VideoData *d, uint32_t id) +static void Wayland_add_display(SDL_VideoData *d, uint32_t id) { struct wl_output *output; SDL_WaylandOutputData *data; @@ -723,15 +695,15 @@ Wayland_add_display(SDL_VideoData *d, uint32_t id) /* Keep a list of outputs for deferred xdg-output initialization. */ if (d->output_list != NULL) { - SDL_WaylandOutputData *node = (SDL_WaylandOutputData*)d->output_list; + SDL_WaylandOutputData *node = (SDL_WaylandOutputData *)d->output_list; while (node->next != NULL) { - node = (SDL_WaylandOutputData*)node->next; + node = (SDL_WaylandOutputData *)node->next; } - node->next = (struct SDL_WaylandOutputData*)data; + node->next = (struct SDL_WaylandOutputData *)data; } else { - d->output_list = (struct SDL_WaylandOutputData*)data; + d->output_list = (struct SDL_WaylandOutputData *)data; } if (data->videodata->xdg_output_manager) { @@ -740,8 +712,7 @@ Wayland_add_display(SDL_VideoData *d, uint32_t id) } } -static void -Wayland_free_display(SDL_VideoData *d, uint32_t id) +static void Wayland_free_display(SDL_VideoData *d, uint32_t id) { int num_displays = SDL_GetNumVideoDisplays(); SDL_VideoDisplay *display; @@ -750,7 +721,7 @@ Wayland_free_display(SDL_VideoData *d, uint32_t id) for (i = 0; i < num_displays; i += 1) { display = SDL_GetDisplay(i); - data = (SDL_WaylandOutputData *) display->driverdata; + data = (SDL_WaylandOutputData *)display->driverdata; if (data->registry_id == id) { if (d->output_list != NULL) { SDL_WaylandOutputData *node = d->output_list; @@ -776,7 +747,7 @@ Wayland_free_display(SDL_VideoData *d, uint32_t id) num_displays -= 1; for (; i < num_displays; i += 1) { display = SDL_GetDisplay(i); - data = (SDL_WaylandOutputData *) display->driverdata; + data = (SDL_WaylandOutputData *)display->driverdata; data->index -= 1; } @@ -785,8 +756,7 @@ Wayland_free_display(SDL_VideoData *d, uint32_t id) } } -static void -Wayland_init_xdg_output(SDL_VideoData *d) +static void Wayland_init_xdg_output(SDL_VideoData *d) { SDL_WaylandOutputData *node; for (node = d->output_list; node != NULL; node = node->next) { @@ -796,14 +766,12 @@ Wayland_init_xdg_output(SDL_VideoData *d) } #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH -static void -windowmanager_hints(void *data, struct qt_windowmanager *qt_windowmanager, - int32_t show_is_fullscreen) +static void windowmanager_hints(void *data, struct qt_windowmanager *qt_windowmanager, + int32_t show_is_fullscreen) { } -static void -windowmanager_quit(void *data, struct qt_windowmanager *qt_windowmanager) +static void windowmanager_quit(void *data, struct qt_windowmanager *qt_windowmanager) { SDL_SendQuit(); } @@ -814,8 +782,7 @@ static const struct qt_windowmanager_listener windowmanager_listener = { }; #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */ -static void -handle_ping_xdg_wm_base(void *data, struct xdg_wm_base *xdg, uint32_t serial) +static void handle_ping_xdg_wm_base(void *data, struct xdg_wm_base *xdg, uint32_t serial) { xdg_wm_base_pong(xdg, serial); } @@ -824,12 +791,10 @@ static const struct xdg_wm_base_listener shell_listener_xdg = { handle_ping_xdg_wm_base }; - #ifdef HAVE_LIBDECOR_H -static void -libdecor_error(struct libdecor *context, - enum libdecor_error error, - const char *message) +static void libdecor_error(struct libdecor *context, + enum libdecor_error error, + const char *message) { SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "libdecor error (%d): %s\n", error, message); } @@ -839,10 +804,8 @@ static struct libdecor_interface libdecor_interface = { }; #endif - -static void -display_handle_global(void *data, struct wl_registry *registry, uint32_t id, - const char *interface, uint32_t version) +static void display_handle_global(void *data, struct wl_registry *registry, uint32_t id, + const char *interface, uint32_t version) { SDL_VideoData *d = data; @@ -895,17 +858,16 @@ display_handle_global(void *data, struct wl_registry *registry, uint32_t id, Wayland_touch_create(d, id); } else if (SDL_strcmp(interface, "qt_surface_extension") == 0) { d->surface_extension = wl_registry_bind(registry, id, - &qt_surface_extension_interface, 1); + &qt_surface_extension_interface, 1); } else if (SDL_strcmp(interface, "qt_windowmanager") == 0) { d->windowmanager = wl_registry_bind(registry, id, - &qt_windowmanager_interface, 1); + &qt_windowmanager_interface, 1); qt_windowmanager_add_listener(d->windowmanager, &windowmanager_listener, d); #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */ } } -static void -display_remove_global(void *data, struct wl_registry *registry, uint32_t id) +static void display_remove_global(void *data, struct wl_registry *registry, uint32_t id) { SDL_VideoData *d = data; /* We don't get an interface, just an ID, so assume it's a wl_output :shrug: */ @@ -959,10 +921,9 @@ Wayland_LoadLibdecor(SDL_VideoData *data, SDL_bool ignore_xdg) return SDL_FALSE; } -int -Wayland_VideoInit(_THIS) +int Wayland_VideoInit(_THIS) { - SDL_VideoData *data = (SDL_VideoData*)_this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; data->xkb_context = WAYLAND_xkb_context_new(0); if (!data->xkb_context) { @@ -1000,8 +961,7 @@ Wayland_VideoInit(_THIS) return 0; } -static int -Wayland_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) +static int Wayland_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) { SDL_WaylandOutputData *driverdata = (SDL_WaylandOutputData *)display->driverdata; rect->x = driverdata->x; @@ -1011,8 +971,7 @@ Wayland_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) return 0; } -static int -Wayland_GetDisplayDPI(_THIS, SDL_VideoDisplay * sdl_display, float * ddpi, float * hdpi, float * vdpi) +static int Wayland_GetDisplayDPI(_THIS, SDL_VideoDisplay *sdl_display, float *ddpi, float *hdpi, float *vdpi) { SDL_WaylandOutputData *driverdata = (SDL_WaylandOutputData *)sdl_display->driverdata; @@ -1029,8 +988,7 @@ Wayland_GetDisplayDPI(_THIS, SDL_VideoDisplay * sdl_display, float * ddpi, float return driverdata->ddpi != 0.0f ? 0 : SDL_SetError("Couldn't get DPI"); } -static void -Wayland_VideoCleanup(_THIS) +static void Wayland_VideoCleanup(_THIS) { SDL_VideoData *data = _this->driverdata; int i, j; @@ -1041,11 +999,11 @@ Wayland_VideoCleanup(_THIS) for (i = _this->num_displays - 1; i >= 0; --i) { SDL_VideoDisplay *display = &_this->displays[i]; - if (((SDL_WaylandOutputData*)display->driverdata)->xdg_output) { - zxdg_output_v1_destroy(((SDL_WaylandOutputData*)display->driverdata)->xdg_output); + if (((SDL_WaylandOutputData *)display->driverdata)->xdg_output) { + zxdg_output_v1_destroy(((SDL_WaylandOutputData *)display->driverdata)->xdg_output); } - wl_output_destroy(((SDL_WaylandOutputData*)display->driverdata)->output); + wl_output_destroy(((SDL_WaylandOutputData *)display->driverdata)->output); SDL_free(display->driverdata); display->driverdata = NULL; @@ -1102,7 +1060,7 @@ Wayland_VideoCleanup(_THIS) #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */ if (data->tablet_manager) { - zwp_tablet_manager_v2_destroy((struct zwp_tablet_manager_v2*)data->tablet_manager); + zwp_tablet_manager_v2_destroy((struct zwp_tablet_manager_v2 *)data->tablet_manager); data->tablet_manager = NULL; } @@ -1205,8 +1163,7 @@ Wayland_VideoReconnect(_THIS) #endif /* 0 */ } -void -Wayland_VideoQuit(_THIS) +void Wayland_VideoQuit(_THIS) { SDL_VideoData *data = _this->driverdata; diff --git a/src/video/wayland/SDL_waylandvideo.h b/src/video/wayland/SDL_waylandvideo.h index 92cdd7410..d17d4c048 100644 --- a/src/video/wayland/SDL_waylandvideo.h +++ b/src/video/wayland/SDL_waylandvideo.h @@ -42,14 +42,16 @@ struct qt_surface_extension; struct qt_windowmanager; #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */ -typedef struct { +typedef struct +{ struct wl_cursor_theme *theme; int size; } SDL_WaylandCursorTheme; typedef struct SDL_WaylandOutputData SDL_WaylandOutputData; -typedef struct { +typedef struct +{ SDL_bool initializing; struct wl_display *display; int display_disconnected; @@ -59,7 +61,8 @@ typedef struct { SDL_WaylandCursorTheme *cursor_themes; int num_cursor_themes; struct wl_pointer *pointer; - struct { + struct + { struct xdg_wm_base *xdg; #ifdef HAVE_LIBDECOR_H struct libdecor *libdecor; @@ -99,7 +102,8 @@ typedef struct { SDL_bool egl_transparency_enabled; } SDL_VideoData; -struct SDL_WaylandOutputData { +struct SDL_WaylandOutputData +{ SDL_VideoData *videodata; struct wl_output *output; struct zxdg_output_v1 *xdg_output; diff --git a/src/video/wayland/SDL_waylandvulkan.c b/src/video/wayland/SDL_waylandvulkan.c index a736816e6..9c3694346 100644 --- a/src/video/wayland/SDL_waylandvulkan.c +++ b/src/video/wayland/SDL_waylandvulkan.c @@ -36,9 +36,9 @@ #include "SDL_syswm.h" #if defined(__OpenBSD__) -#define DEFAULT_VULKAN "libvulkan.so" +#define DEFAULT_VULKAN "libvulkan.so" #else -#define DEFAULT_VULKAN "libvulkan.so.1" +#define DEFAULT_VULKAN "libvulkan.so.1" #endif int Wayland_Vulkan_LoadLibrary(_THIS, const char *path) @@ -84,8 +84,7 @@ int Wayland_Vulkan_LoadLibrary(_THIS, const char *path) if (extensions == NULL) { goto fail; } - for (i = 0; i < extensionCount; i++) - { + for (i = 0; i < extensionCount; i++) { if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { hasSurfaceExtension = SDL_TRUE; } else if (SDL_strcmp(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { @@ -94,12 +93,10 @@ int Wayland_Vulkan_LoadLibrary(_THIS, const char *path) } SDL_free(extensions); if (!hasSurfaceExtension) { - SDL_SetError("Installed Vulkan doesn't implement the " - VK_KHR_SURFACE_EXTENSION_NAME " extension"); + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_SURFACE_EXTENSION_NAME " extension"); goto fail; } else if (!hasWaylandSurfaceExtension) { - SDL_SetError("Installed Vulkan doesn't implement the " - VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME "extension"); + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME "extension"); goto fail; } return 0; @@ -119,9 +116,9 @@ void Wayland_Vulkan_UnloadLibrary(_THIS) } SDL_bool Wayland_Vulkan_GetInstanceExtensions(_THIS, - SDL_Window *window, - unsigned *count, - const char **names) + SDL_Window *window, + unsigned *count, + const char **names) { static const char *const extensionsForWayland[] = { VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME @@ -131,22 +128,22 @@ SDL_bool Wayland_Vulkan_GetInstanceExtensions(_THIS, return SDL_FALSE; } return SDL_Vulkan_GetInstanceExtensions_Helper( - count, names, SDL_arraysize(extensionsForWayland), - extensionsForWayland); + count, names, SDL_arraysize(extensionsForWayland), + extensionsForWayland); } SDL_bool Wayland_Vulkan_CreateSurface(_THIS, - SDL_Window *window, - VkInstance instance, - VkSurfaceKHR *surface) + SDL_Window *window, + VkInstance instance, + VkSurfaceKHR *surface) { SDL_WindowData *windowData = (SDL_WindowData *)window->driverdata; PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR)vkGetInstanceProcAddr( - instance, - "vkCreateWaylandSurfaceKHR"); + instance, + "vkCreateWaylandSurfaceKHR"); VkWaylandSurfaceCreateInfoKHR createInfo; VkResult result; @@ -165,7 +162,7 @@ SDL_bool Wayland_Vulkan_CreateSurface(_THIS, createInfo.pNext = NULL; createInfo.flags = 0; createInfo.display = windowData->waylandData->display; - createInfo.surface = windowData->surface; + createInfo.surface = windowData->surface; result = vkCreateWaylandSurfaceKHR(instance, &createInfo, NULL, surface); if (result != VK_SUCCESS) { diff --git a/src/video/wayland/SDL_waylandvulkan.h b/src/video/wayland/SDL_waylandvulkan.h index 7ef4658bf..60e868d83 100644 --- a/src/video/wayland/SDL_waylandvulkan.h +++ b/src/video/wayland/SDL_waylandvulkan.h @@ -37,13 +37,13 @@ int Wayland_Vulkan_LoadLibrary(_THIS, const char *path); void Wayland_Vulkan_UnloadLibrary(_THIS); SDL_bool Wayland_Vulkan_GetInstanceExtensions(_THIS, - SDL_Window *window, - unsigned *count, - const char **names); + SDL_Window *window, + unsigned *count, + const char **names); SDL_bool Wayland_Vulkan_CreateSurface(_THIS, - SDL_Window *window, - VkInstance instance, - VkSurfaceKHR *surface); + SDL_Window *window, + VkInstance instance, + VkSurfaceKHR *surface); #endif diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index 1c850defc..e6defb8e1 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -51,17 +51,16 @@ SDL_FORCE_INLINE SDL_bool FloatEqual(float a, float b) { - const float diff = SDL_fabsf(a - b); + const float diff = SDL_fabsf(a - b); const float largest = SDL_max(SDL_fabsf(a), SDL_fabsf(b)); return diff <= largest * SDL_FLT_EPSILON; } -static void -GetFullScreenDimensions(SDL_Window *window, int *width, int *height, int *drawable_width, int *drawable_height) +static void GetFullScreenDimensions(SDL_Window *window, int *width, int *height, int *drawable_width, int *drawable_height) { - SDL_WindowData *wind = (SDL_WindowData *) window->driverdata; - SDL_WaylandOutputData *output = (SDL_WaylandOutputData *) SDL_GetDisplayForWindow(window)->driverdata; + SDL_WindowData *wind = (SDL_WindowData *)window->driverdata; + SDL_WaylandOutputData *output = (SDL_WaylandOutputData *)SDL_GetDisplayForWindow(window)->driverdata; int fs_width, fs_height; int buf_width, buf_height; @@ -74,15 +73,15 @@ GetFullScreenDimensions(SDL_Window *window, int *width, int *height, int *drawab * differently sized window and backbuffer spaces on its own. */ if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) { - fs_width = output_width; + fs_width = output_width; fs_height = output_height; /* If the application is DPI aware, we can expose the true backbuffer size */ if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) { - buf_width = output->native_width; + buf_width = output->native_width; buf_height = output->native_height; } else { - buf_width = fs_width; + buf_width = fs_width; buf_height = fs_height; } } else { @@ -91,17 +90,17 @@ GetFullScreenDimensions(SDL_Window *window, int *width, int *height, int *drawab * for DPI aware apps and the desktop size for legacy apps. */ if (window->fullscreen_mode.w != 0 && window->fullscreen_mode.h != 0) { - fs_width = window->fullscreen_mode.w; + fs_width = window->fullscreen_mode.w; fs_height = window->fullscreen_mode.h; } else if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) { - fs_width = output->native_width; + fs_width = output->native_width; fs_height = output->native_height; } else { - fs_width = output_width; + fs_width = output_width; fs_height = output_height; } - buf_width = fs_width; + buf_width = fs_width; buf_height = fs_height; } @@ -133,13 +132,12 @@ FullscreenModeEmulation(SDL_Window *window) ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP); } -static SDL_bool -NeedViewport(SDL_Window *window) +static SDL_bool NeedViewport(SDL_Window *window) { - SDL_WindowData *wind = window->driverdata; - SDL_VideoData *video = wind->waylandData; + SDL_WindowData *wind = window->driverdata; + SDL_VideoData *video = wind->waylandData; SDL_WaylandOutputData *output = ((SDL_WaylandOutputData *)SDL_GetDisplayForWindow(window)->driverdata); - int fs_width, fs_height; + int fs_width, fs_height; /* * A viewport is only required when scaling is enabled and: @@ -160,18 +158,17 @@ NeedViewport(SDL_Window *window) return SDL_FALSE; } -static void -GetBufferSize(SDL_Window *window, int *width, int *height) +static void GetBufferSize(SDL_Window *window, int *width, int *height) { SDL_WindowData *data = window->driverdata; - int buf_width; - int buf_height; + int buf_width; + int buf_height; if (FullscreenModeEmulation(window)) { GetFullScreenDimensions(window, NULL, NULL, &buf_width, &buf_height); } else if (NeedViewport(window)) { /* Round fractional backbuffer sizes halfway away from zero. */ - buf_width = (int)SDL_lroundf(window->w * data->scale_factor); + buf_width = (int)SDL_lroundf(window->w * data->scale_factor); buf_height = (int)SDL_lroundf(window->h * data->scale_factor); } else { /* @@ -182,7 +179,7 @@ GetBufferSize(SDL_Window *window, int *width, int *height) */ int scale_factor = (int)SDL_ceilf(data->scale_factor); - buf_width = window->w * scale_factor; + buf_width = window->w * scale_factor; buf_height = window->h * scale_factor; } @@ -194,11 +191,10 @@ GetBufferSize(SDL_Window *window, int *width, int *height) } } -static void -SetDrawSurfaceViewport(SDL_Window *window, int src_width, int src_height, int dst_width, int dst_height) +static void SetDrawSurfaceViewport(SDL_Window *window, int src_width, int src_height, int dst_width, int dst_height) { - SDL_WindowData *wind = window->driverdata; - SDL_VideoData *video = wind->waylandData; + SDL_WindowData *wind = window->driverdata; + SDL_VideoData *video = wind->waylandData; if (video->viewporter) { if (wind->draw_viewport == NULL) { @@ -210,8 +206,7 @@ SetDrawSurfaceViewport(SDL_Window *window, int src_width, int src_height, int ds } } -static void -UnsetDrawSurfaceViewport(SDL_Window *window) +static void UnsetDrawSurfaceViewport(SDL_Window *window) { SDL_WindowData *wind = window->driverdata; @@ -221,17 +216,16 @@ UnsetDrawSurfaceViewport(SDL_Window *window) } } -static void -ConfigureWindowGeometry(SDL_Window *window) +static void ConfigureWindowGeometry(SDL_Window *window) { - SDL_WindowData *data = window->driverdata; - SDL_VideoData *viddata = data->waylandData; - SDL_WaylandOutputData *output = (SDL_WaylandOutputData *)SDL_GetDisplayForWindow(window)->driverdata; - struct wl_region *region; - const int old_dw = data->drawable_width; - const int old_dh = data->drawable_height; - SDL_bool window_size_changed; - SDL_bool drawable_size_changed; + SDL_WindowData *data = window->driverdata; + SDL_VideoData *viddata = data->waylandData; + SDL_WaylandOutputData *output = (SDL_WaylandOutputData *)SDL_GetDisplayForWindow(window)->driverdata; + struct wl_region *region; + const int old_dw = data->drawable_width; + const int old_dh = data->drawable_height; + SDL_bool window_size_changed; + SDL_bool drawable_size_changed; /* Set the drawable backbuffer size. */ GetBufferSize(window, &data->drawable_width, &data->drawable_height); @@ -246,7 +240,7 @@ ConfigureWindowGeometry(SDL_Window *window) if (FullscreenModeEmulation(window) && NeedViewport(window)) { int fs_width, fs_height; - const int output_width = data->fs_output_width ? data->fs_output_width : output->width; + const int output_width = data->fs_output_width ? data->fs_output_width : output->width; const int output_height = data->fs_output_height ? data->fs_output_height : output->height; window_size_changed = data->window_width != output_width || data->window_height != output_height; @@ -259,11 +253,11 @@ ConfigureWindowGeometry(SDL_Window *window) SetDrawSurfaceViewport(window, data->drawable_width, data->drawable_height, output_width, output_height); - data->window_width = output_width; + data->window_width = output_width; data->window_height = output_height; - data->pointer_scale_x = (float) fs_width / (float) output_width; - data->pointer_scale_y = (float) fs_height / (float) output_height; + data->pointer_scale_x = (float)fs_width / (float)output_width; + data->pointer_scale_y = (float)fs_height / (float)output_height; } } else { window_size_changed = data->window_width != window->w || data->window_height != window->h; @@ -276,7 +270,7 @@ ConfigureWindowGeometry(SDL_Window *window) UnsetDrawSurfaceViewport(window); /* Round to the next integer in case of a fractional value. */ - wl_surface_set_buffer_scale(data->surface, (int32_t) SDL_ceilf(data->scale_factor)); + wl_surface_set_buffer_scale(data->surface, (int32_t)SDL_ceilf(data->scale_factor)); } data->window_width = window->w; @@ -306,11 +300,10 @@ ConfigureWindowGeometry(SDL_Window *window) } } -static void -CommitLibdecorFrame(SDL_Window *window) +static void CommitLibdecorFrame(SDL_Window *window) { #ifdef HAVE_LIBDECOR_H - SDL_WindowData *wind = (SDL_WindowData *) window->driverdata; + SDL_WindowData *wind = (SDL_WindowData *)window->driverdata; if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR && wind->shell_surface.libdecor.frame) { struct libdecor_state *state = libdecor_state_new(wind->window_width, wind->window_height); @@ -320,8 +313,7 @@ CommitLibdecorFrame(SDL_Window *window) #endif } -static void -SetMinMaxDimensions(SDL_Window *window, SDL_bool commit) +static void SetMinMaxDimensions(SDL_Window *window, SDL_bool commit) { SDL_WindowData *wind = window->driverdata; SDL_VideoData *viddata = wind->waylandData; @@ -371,7 +363,7 @@ SetMinMaxDimensions(SDL_Window *window, SDL_bool commit) } } else #endif - if (viddata->shell.xdg) { + if (viddata->shell.xdg) { if (wind->shell_surface.xdg.roleobj.toplevel == NULL) { return; /* Can't do anything yet, wait for ShowWindow */ } @@ -387,8 +379,7 @@ SetMinMaxDimensions(SDL_Window *window, SDL_bool commit) } } -static void -SetFullscreen(SDL_Window *window, struct wl_output *output) +static void SetFullscreen(SDL_Window *window, struct wl_output *output) { SDL_WindowData *wind = window->driverdata; SDL_VideoData *viddata = wind->waylandData; @@ -430,7 +421,7 @@ SetFullscreen(SDL_Window *window, struct wl_output *output) } } else #endif - if (viddata->shell.xdg) { + if (viddata->shell.xdg) { if (wind->shell_surface.xdg.roleobj.toplevel == NULL) { return; /* Can't do anything yet, wait for ShowWindow */ } @@ -445,10 +436,9 @@ SetFullscreen(SDL_Window *window, struct wl_output *output) } } -static void -UpdateWindowFullscreen(SDL_Window *window, SDL_bool fullscreen) +static void UpdateWindowFullscreen(SDL_Window *window, SDL_bool fullscreen) { - SDL_WindowData *wind = (SDL_WindowData*)window->driverdata; + SDL_WindowData *wind = (SDL_WindowData *)window->driverdata; if (fullscreen) { if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { @@ -494,8 +484,7 @@ UpdateWindowFullscreen(SDL_Window *window, SDL_bool fullscreen) static const struct wl_callback_listener surface_damage_frame_listener; -static void -surface_damage_frame_done(void *data, struct wl_callback *cb, uint32_t time) +static void surface_damage_frame_done(void *data, struct wl_callback *cb, uint32_t time) { SDL_WindowData *wind = (SDL_WindowData *)data; @@ -522,11 +511,10 @@ static const struct wl_callback_listener surface_damage_frame_listener = { static const struct wl_callback_listener gles_swap_frame_listener; -static void -gles_swap_frame_done(void *data, struct wl_callback *cb, uint32_t time) +static void gles_swap_frame_done(void *data, struct wl_callback *cb, uint32_t time) { - SDL_WindowData *wind = (SDL_WindowData *) data; - SDL_AtomicSet(&wind->swap_interval_ready, 1); /* mark window as ready to present again. */ + SDL_WindowData *wind = (SDL_WindowData *)data; + SDL_AtomicSet(&wind->swap_interval_ready, 1); /* mark window as ready to present again. */ /* reset this callback to fire again once a new frame was presented and compositor wants the next one. */ wind->gles_swap_frame_callback = wl_surface_frame(wind->gles_swap_frame_surface_wrapper); @@ -538,11 +526,9 @@ static const struct wl_callback_listener gles_swap_frame_listener = { gles_swap_frame_done }; - static void Wayland_HandleResize(SDL_Window *window, int width, int height, float scale); -static void -handle_configure_xdg_shell_surface(void *data, struct xdg_surface *xdg, uint32_t serial) +static void handle_configure_xdg_shell_surface(void *data, struct xdg_surface *xdg, uint32_t serial) { SDL_WindowData *wind = (SDL_WindowData *)data; SDL_Window *window = wind->sdlwindow; @@ -557,12 +543,11 @@ static const struct xdg_surface_listener shell_surface_listener_xdg = { handle_configure_xdg_shell_surface }; -static void -handle_configure_xdg_toplevel(void *data, - struct xdg_toplevel *xdg_toplevel, - int32_t width, - int32_t height, - struct wl_array *states) +static void handle_configure_xdg_toplevel(void *data, + struct xdg_toplevel *xdg_toplevel, + int32_t width, + int32_t height, + struct wl_array *states) { SDL_WindowData *wind = (SDL_WindowData *)data; SDL_Window *window = wind->sdlwindow; @@ -572,7 +557,7 @@ handle_configure_xdg_toplevel(void *data, SDL_bool fullscreen = SDL_FALSE; SDL_bool maximized = SDL_FALSE; SDL_bool floating = SDL_TRUE; - wl_array_for_each(state, states) { + wl_array_for_each (state, states) { switch (*state) { case XDG_TOPLEVEL_STATE_FULLSCREEN: fullscreen = SDL_TRUE; @@ -593,7 +578,7 @@ handle_configure_xdg_toplevel(void *data, } } - driverdata = (SDL_WaylandOutputData *) SDL_GetDisplayForWindow(window)->driverdata; + driverdata = (SDL_WaylandOutputData *)SDL_GetDisplayForWindow(window)->driverdata; UpdateWindowFullscreen(window, fullscreen); @@ -633,9 +618,7 @@ handle_configure_xdg_toplevel(void *data, * No, we do not get minimize events from xdg-shell. */ SDL_SendWindowEvent(window, - maximized ? - SDL_WINDOWEVENT_MAXIMIZED : - SDL_WINDOWEVENT_RESTORED, + maximized ? SDL_WINDOWEVENT_MAXIMIZED : SDL_WINDOWEVENT_RESTORED, 0, 0); /* Store current floating dimensions for restoring */ @@ -682,8 +665,7 @@ handle_configure_xdg_toplevel(void *data, } } -static void -handle_close_xdg_toplevel(void *data, struct xdg_toplevel *xdg_toplevel) +static void handle_close_xdg_toplevel(void *data, struct xdg_toplevel *xdg_toplevel) { SDL_WindowData *window = (SDL_WindowData *)data; SDL_SendWindowEvent(window->sdlwindow, SDL_WINDOWEVENT_CLOSE, 0, 0); @@ -694,28 +676,25 @@ static const struct xdg_toplevel_listener toplevel_listener_xdg = { handle_close_xdg_toplevel }; -static void -handle_configure_xdg_popup(void *data, - struct xdg_popup *xdg_popup, - int32_t x, - int32_t y, - int32_t width, - int32_t height) +static void handle_configure_xdg_popup(void *data, + struct xdg_popup *xdg_popup, + int32_t x, + int32_t y, + int32_t width, + int32_t height) { /* No-op, we don't use x/y and width/height are fixed-size */ } -static void -handle_done_xdg_popup(void *data, struct xdg_popup *xdg_popup) +static void handle_done_xdg_popup(void *data, struct xdg_popup *xdg_popup) { SDL_WindowData *window = (SDL_WindowData *)data; SDL_SendWindowEvent(window->sdlwindow, SDL_WINDOWEVENT_CLOSE, 0, 0); } -static void -handle_repositioned_xdg_popup(void *data, - struct xdg_popup *xdg_popup, - uint32_t token) +static void handle_repositioned_xdg_popup(void *data, + struct xdg_popup *xdg_popup, + uint32_t token) { /* No-op, configure does all the work we care about */ } @@ -728,11 +707,10 @@ static const struct xdg_popup_listener popup_listener_xdg = { #define TOOLTIP_CURSOR_OFFSET 8 /* FIXME: Arbitrary, eyeballed from X tooltip */ -static int -Wayland_PopupWatch(void *data, SDL_Event *event) +static int Wayland_PopupWatch(void *data, SDL_Event *event) { if (event->type == SDL_MOUSEMOTION) { - SDL_Window *window = (SDL_Window *) data; + SDL_Window *window = (SDL_Window *)data; SDL_WindowData *wind = window->driverdata; /* Coordinates might be relative to the popup, which we don't want */ @@ -748,13 +726,12 @@ Wayland_PopupWatch(void *data, SDL_Event *event) return 1; } -static void -handle_configure_zxdg_decoration(void *data, - struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, - uint32_t mode) +static void handle_configure_zxdg_decoration(void *data, + struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, + uint32_t mode) { - SDL_Window *window = (SDL_Window *) data; - SDL_WindowData *driverdata = (SDL_WindowData *) window->driverdata; + SDL_Window *window = (SDL_Window *)data; + SDL_WindowData *driverdata = (SDL_WindowData *)window->driverdata; SDL_VideoDevice *device = SDL_GetVideoDevice(); /* If the compositor tries to force CSD anyway, bail on direct XDG support @@ -787,10 +764,9 @@ static const struct zxdg_toplevel_decoration_v1_listener decoration_listener = { }; #ifdef HAVE_LIBDECOR_H -static void -decoration_frame_configure(struct libdecor_frame *frame, - struct libdecor_configuration *configuration, - void *user_data) +static void decoration_frame_configure(struct libdecor_frame *frame, + struct libdecor_configuration *configuration, + void *user_data) { SDL_WindowData *wind = (SDL_WindowData *)user_data; SDL_Window *window = wind->sdlwindow; @@ -807,10 +783,8 @@ decoration_frame_configure(struct libdecor_frame *frame, SDL_bool tiled = SDL_FALSE; SDL_bool floating; - static const enum libdecor_window_state tiled_states = ( - LIBDECOR_WINDOW_STATE_TILED_LEFT | LIBDECOR_WINDOW_STATE_TILED_RIGHT | - LIBDECOR_WINDOW_STATE_TILED_TOP | LIBDECOR_WINDOW_STATE_TILED_BOTTOM - ); + static const enum libdecor_window_state tiled_states = (LIBDECOR_WINDOW_STATE_TILED_LEFT | LIBDECOR_WINDOW_STATE_TILED_RIGHT | + LIBDECOR_WINDOW_STATE_TILED_TOP | LIBDECOR_WINDOW_STATE_TILED_BOTTOM); /* Window State */ if (libdecor_configuration_get_window_state(configuration, &window_state)) { @@ -821,7 +795,7 @@ decoration_frame_configure(struct libdecor_frame *frame, } floating = !(fullscreen || maximized || tiled); - driverdata = (SDL_WaylandOutputData *) SDL_GetDisplayForWindow(window)->driverdata; + driverdata = (SDL_WaylandOutputData *)SDL_GetDisplayForWindow(window)->driverdata; UpdateWindowFullscreen(window, fullscreen); @@ -832,17 +806,13 @@ decoration_frame_configure(struct libdecor_frame *frame, * No, we do not get minimize events from libdecor. */ SDL_SendWindowEvent(window, - maximized ? - SDL_WINDOWEVENT_MAXIMIZED : - SDL_WINDOWEVENT_RESTORED, + maximized ? SDL_WINDOWEVENT_MAXIMIZED : SDL_WINDOWEVENT_RESTORED, 0, 0); } /* Similar to maximized/restore events above, send focus events too! */ SDL_SendWindowEvent(window, - focused ? - SDL_WINDOWEVENT_FOCUS_GAINED : - SDL_WINDOWEVENT_FOCUS_LOST, + focused ? SDL_WINDOWEVENT_FOCUS_GAINED : SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); /* For fullscreen or fixed-size windows we know our size. @@ -855,7 +825,7 @@ decoration_frame_configure(struct libdecor_frame *frame, * told to do this. */ if (libdecor_configuration_get_content_size(configuration, frame, - &width, &height)) { + &width, &height)) { wind->fs_output_width = width; wind->fs_output_height = height; } else { @@ -932,14 +902,12 @@ decoration_frame_configure(struct libdecor_frame *frame, window->flags & SDL_WINDOW_RESIZABLE); } -static void -decoration_frame_close(struct libdecor_frame *frame, void *user_data) +static void decoration_frame_close(struct libdecor_frame *frame, void *user_data) { SDL_SendWindowEvent(((SDL_WindowData *)user_data)->sdlwindow, SDL_WINDOWEVENT_CLOSE, 0, 0); } -static void -decoration_frame_commit(struct libdecor_frame *frame, void *user_data) +static void decoration_frame_commit(struct libdecor_frame *frame, void *user_data) { SDL_WindowData *wind = user_data; @@ -954,21 +922,18 @@ static struct libdecor_frame_interface libdecor_frame_interface = { #endif #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH -static void -handle_onscreen_visibility(void *data, - struct qt_extended_surface *qt_extended_surface, int32_t visible) +static void handle_onscreen_visibility(void *data, + struct qt_extended_surface *qt_extended_surface, int32_t visible) { } -static void -handle_set_generic_property(void *data, - struct qt_extended_surface *qt_extended_surface, const char *name, - struct wl_array *value) +static void handle_set_generic_property(void *data, + struct qt_extended_surface *qt_extended_surface, const char *name, + struct wl_array *value) { } -static void -handle_close(void *data, struct qt_extended_surface *qt_extended_surface) +static void handle_close(void *data, struct qt_extended_surface *qt_extended_surface) { SDL_WindowData *window = (SDL_WindowData *)data; SDL_SendWindowEvent(window->sdlwindow, SDL_WINDOWEVENT_CLOSE, 0, 0); @@ -981,8 +946,7 @@ static const struct qt_extended_surface_listener extended_surface_listener = { }; #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */ -static void -update_scale_factor(SDL_WindowData *window) +static void update_scale_factor(SDL_WindowData *window) { float old_factor = window->scale_factor; float new_factor; @@ -996,7 +960,7 @@ update_scale_factor(SDL_WindowData *window) if (FULLSCREEN_VISIBLE(window->sdlwindow)) { /* For fullscreen, use the active display's scale factor */ SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window->sdlwindow); - SDL_WaylandOutputData* driverdata = display->driverdata; + SDL_WaylandOutputData *driverdata = display->driverdata; new_factor = driverdata->scale_factor; } else if (window->num_outputs == 0) { /* No monitor (somehow)? Just fall back. */ @@ -1005,7 +969,7 @@ update_scale_factor(SDL_WindowData *window) /* Check every display's factor, use the highest */ new_factor = 0.0f; for (i = 0; i < window->num_outputs; i++) { - SDL_WaylandOutputData* driverdata = window->outputs[i]; + SDL_WaylandOutputData *driverdata = window->outputs[i]; new_factor = SDL_max(new_factor, driverdata->scale_factor); } } @@ -1019,11 +983,10 @@ update_scale_factor(SDL_WindowData *window) * what monitor we're on, so let's send move events that put the window at the * center of the whatever display the wl_surface_listener events give us. */ -static void -Wayland_move_window(SDL_Window *window, - SDL_WaylandOutputData *driverdata) +static void Wayland_move_window(SDL_Window *window, + SDL_WaylandOutputData *driverdata) { - SDL_WindowData *wind = (SDL_WindowData*)window->driverdata; + SDL_WindowData *wind = (SDL_WindowData *)window->driverdata; SDL_VideoDisplay *display; SDL_bool fs_display_changed = SDL_FALSE; int i, j; @@ -1090,9 +1053,8 @@ Wayland_move_window(SDL_Window *window, } } -static void -handle_surface_enter(void *data, struct wl_surface *surface, - struct wl_output *output) +static void handle_surface_enter(void *data, struct wl_surface *surface, + struct wl_output *output) { SDL_WindowData *window = data; SDL_WaylandOutputData *driverdata = wl_output_get_user_data(output); @@ -1102,7 +1064,7 @@ handle_surface_enter(void *data, struct wl_surface *surface, } window->outputs = SDL_realloc(window->outputs, - sizeof(SDL_WaylandOutputData*) * (window->num_outputs + 1)); + sizeof(SDL_WaylandOutputData *) * (window->num_outputs + 1)); window->outputs[window->num_outputs++] = driverdata; /* Update the scale factor after the move so that fullscreen outputs are updated. */ @@ -1113,9 +1075,8 @@ handle_surface_enter(void *data, struct wl_surface *surface, } } -static void -handle_surface_leave(void *data, struct wl_surface *surface, - struct wl_output *output) +static void handle_surface_leave(void *data, struct wl_surface *surface, + struct wl_output *output) { SDL_WindowData *window = data; int i, send_move_event = 0; @@ -1126,14 +1087,14 @@ handle_surface_leave(void *data, struct wl_surface *surface, } for (i = 0; i < window->num_outputs; i++) { - if (window->outputs[i] == driverdata) { /* remove this one */ - if (i == (window->num_outputs-1)) { + if (window->outputs[i] == driverdata) { /* remove this one */ + if (i == (window->num_outputs - 1)) { window->outputs[i] = NULL; send_move_event = 1; } else { SDL_memmove(&window->outputs[i], &window->outputs[i + 1], - sizeof(SDL_WaylandOutputData*) * ((window->num_outputs - i) - 1)); + sizeof(SDL_WaylandOutputData *) * ((window->num_outputs - i) - 1)); } window->num_outputs--; i--; @@ -1248,16 +1209,14 @@ Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) return SDL_TRUE; } -int -Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled) +int Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled) { - return 0; /* just succeed, the real work is done elsewhere. */ + return 0; /* just succeed, the real work is done elsewhere. */ } -int -Wayland_SetWindowModalFor(_THIS, SDL_Window *modal_window, SDL_Window *parent_window) +int Wayland_SetWindowModalFor(_THIS, SDL_Window *modal_window, SDL_Window *parent_window) { - SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata; SDL_WindowData *modal_data = modal_window->driverdata; SDL_WindowData *parent_data = parent_window->driverdata; @@ -1277,7 +1236,7 @@ Wayland_SetWindowModalFor(_THIS, SDL_Window *modal_window, SDL_Window *parent_wi parent_data->shell_surface.libdecor.frame); } else #endif - if (viddata->shell.xdg) { + if (viddata->shell.xdg) { if (modal_data->shell_surface.xdg.roleobj.toplevel == NULL) { return SDL_SetError("Modal window was hidden"); } @@ -1337,7 +1296,7 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window) } } else #endif - if (c->shell.xdg) { + if (c->shell.xdg) { data->shell_surface.xdg.surface = xdg_wm_base_get_xdg_surface(c->shell.xdg, data->surface); xdg_surface_set_user_data(data->shell_surface.xdg.surface, data); xdg_surface_add_listener(data->shell_surface.xdg.surface, &shell_surface_listener_xdg, data); @@ -1402,7 +1361,7 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window) } } else #endif - if (c->shell.xdg) { + if (c->shell.xdg) { /* Unlike libdecor we need to call this explicitly to prevent a deadlock. * libdecor will call this as part of their configure event! * -flibit @@ -1468,8 +1427,7 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window) WAYLAND_wl_display_roundtrip(c->display); } -static void -Wayland_ReleasePopup(_THIS, SDL_Window *popup) +static void Wayland_ReleasePopup(_THIS, SDL_Window *popup) { SDL_WindowData *popupdata; @@ -1510,8 +1468,8 @@ void Wayland_HideWindow(_THIS, SDL_Window *window) SDL_WindowData *wind = window->driverdata; if (wind->server_decoration) { - zxdg_toplevel_decoration_v1_destroy(wind->server_decoration); - wind->server_decoration = NULL; + zxdg_toplevel_decoration_v1_destroy(wind->server_decoration); + wind->server_decoration = NULL; } /* Be sure to detach after this is done, otherwise ShowWindow crashes! */ @@ -1526,7 +1484,7 @@ void Wayland_HideWindow(_THIS, SDL_Window *window) } } else #endif - if (data->shell.xdg) { + if (data->shell.xdg) { if (wind->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP) { Wayland_ReleasePopup(_this, window); } else if (wind->shell_surface.xdg.roleobj.toplevel) { @@ -1546,10 +1504,9 @@ void Wayland_HideWindow(_THIS, SDL_Window *window) WAYLAND_wl_display_roundtrip(data->display); } -static void -handle_xdg_activation_done(void *data, - struct xdg_activation_token_v1 *xdg_activation_token_v1, - const char *token) +static void handle_xdg_activation_done(void *data, + struct xdg_activation_token_v1 *xdg_activation_token_v1, + const char *token) { SDL_WindowData *window = data; if (xdg_activation_token_v1 == window->activation_token) { @@ -1585,10 +1542,9 @@ static const struct xdg_activation_token_v1_listener activation_listener_xdg = { * * -flibit */ -static void -Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *wind, - struct wl_surface *surface, - uint32_t serial, struct wl_seat *seat) +static void Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *wind, + struct wl_surface *surface, + uint32_t serial, struct wl_seat *seat) { if (data->activation_manager) { if (wind->activation_token != NULL) { @@ -1618,8 +1574,7 @@ Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *wind, } } -void -Wayland_RaiseWindow(_THIS, SDL_Window *window) +void Wayland_RaiseWindow(_THIS, SDL_Window *window) { SDL_WindowData *wind = window->driverdata; @@ -1636,8 +1591,7 @@ Wayland_RaiseWindow(_THIS, SDL_Window *window) NULL); } -int -Wayland_FlashWindow(_THIS, SDL_Window *window, SDL_FlashOperation operation) +int Wayland_FlashWindow(_THIS, SDL_Window *window, SDL_FlashOperation operation) { Wayland_activate_window(_this->driverdata, window->driverdata, @@ -1648,8 +1602,8 @@ Wayland_FlashWindow(_THIS, SDL_Window *window, SDL_FlashOperation operation) } void handle_preferred_scale_changed(void *data, - struct wp_fractional_scale_v1 *wp_fractional_scale_v1, - uint preferred_scale) + struct wp_fractional_scale_v1 *wp_fractional_scale_v1, + uint preferred_scale) { SDL_WindowData *window = data; float old_factor = window->scale_factor; @@ -1669,16 +1623,15 @@ static const struct wp_fractional_scale_v1_listener fractional_scale_listener = handle_preferred_scale_changed }; - #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH -static void SDLCALL -QtExtendedSurface_OnHintChanged(void *userdata, const char *name, - const char *oldValue, const char *newValue) +static void SDLCALL QtExtendedSurface_OnHintChanged(void *userdata, const char *name, + const char *oldValue, const char *newValue) { struct qt_extended_surface *qt_extended_surface = userdata; int i; - static struct { + static struct + { const char *name; int32_t value; } orientations[] = { @@ -1754,13 +1707,12 @@ static void QtExtendedSurface_Unsubscribe(struct qt_extended_surface *surface, c } #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */ -void -Wayland_SetWindowFullscreen(_THIS, SDL_Window * window, - SDL_VideoDisplay * _display, SDL_bool fullscreen) +void Wayland_SetWindowFullscreen(_THIS, SDL_Window *window, + SDL_VideoDisplay *_display, SDL_bool fullscreen) { - SDL_WindowData *wind = (SDL_WindowData*) window->driverdata; - struct wl_output *output = ((SDL_WaylandOutputData*) _display->driverdata)->output; - SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata; + SDL_WindowData *wind = (SDL_WindowData *)window->driverdata; + struct wl_output *output = ((SDL_WaylandOutputData *)_display->driverdata)->output; + SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata; /* Called from within a configure event or the window is a popup, drop it. */ if (wind->in_fullscreen_transition || wind->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP) { @@ -1793,11 +1745,10 @@ Wayland_SetWindowFullscreen(_THIS, SDL_Window * window, } } -void -Wayland_RestoreWindow(_THIS, SDL_Window * window) +void Wayland_RestoreWindow(_THIS, SDL_Window *window) { SDL_WindowData *wind = window->driverdata; - SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata; if (wind->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP) { return; @@ -1816,22 +1767,21 @@ Wayland_RestoreWindow(_THIS, SDL_Window * window) libdecor_frame_unset_maximized(wind->shell_surface.libdecor.frame); } else #endif - /* Note that xdg-shell does NOT provide a way to unset minimize! */ - if (viddata->shell.xdg) { - if (wind->shell_surface.xdg.roleobj.toplevel == NULL) { - return; /* Can't do anything yet, wait for ShowWindow */ + /* Note that xdg-shell does NOT provide a way to unset minimize! */ + if (viddata->shell.xdg) { + if (wind->shell_surface.xdg.roleobj.toplevel == NULL) { + return; /* Can't do anything yet, wait for ShowWindow */ + } + xdg_toplevel_unset_maximized(wind->shell_surface.xdg.roleobj.toplevel); } - xdg_toplevel_unset_maximized(wind->shell_surface.xdg.roleobj.toplevel); - } - WAYLAND_wl_display_flush( viddata->display ); + WAYLAND_wl_display_flush(viddata->display); } -void -Wayland_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) +void Wayland_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered) { SDL_WindowData *wind = window->driverdata; - const SDL_VideoData *viddata = (const SDL_VideoData *) _this->driverdata; + const SDL_VideoData *viddata = (const SDL_VideoData *)_this->driverdata; if (wind->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP) { return; @@ -1844,14 +1794,13 @@ Wayland_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) } } else #endif - if ((viddata->decoration_manager) && (wind->server_decoration)) { + if ((viddata->decoration_manager) && (wind->server_decoration)) { const enum zxdg_toplevel_decoration_v1_mode mode = bordered ? ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE : ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE; zxdg_toplevel_decoration_v1_set_mode(wind->server_decoration, mode); } } -void -Wayland_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable) +void Wayland_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable) { #ifdef HAVE_LIBDECOR_H const SDL_WindowData *wind = window->driverdata; @@ -1872,11 +1821,10 @@ Wayland_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable) } } -void -Wayland_MaximizeWindow(_THIS, SDL_Window * window) +void Wayland_MaximizeWindow(_THIS, SDL_Window *window) { SDL_WindowData *wind = window->driverdata; - SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata; if (wind->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP) { return; @@ -1899,7 +1847,7 @@ Wayland_MaximizeWindow(_THIS, SDL_Window * window) libdecor_frame_set_maximized(wind->shell_surface.libdecor.frame); } else #endif - if (viddata->shell.xdg) { + if (viddata->shell.xdg) { if (wind->shell_surface.xdg.roleobj.toplevel == NULL) { return; /* Can't do anything yet, wait for ShowWindow */ } @@ -1909,11 +1857,10 @@ Wayland_MaximizeWindow(_THIS, SDL_Window * window) WAYLAND_wl_display_flush(viddata->display); } -void -Wayland_MinimizeWindow(_THIS, SDL_Window * window) +void Wayland_MinimizeWindow(_THIS, SDL_Window *window) { SDL_WindowData *wind = window->driverdata; - SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata; if (wind->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP) { return; @@ -1927,7 +1874,7 @@ Wayland_MinimizeWindow(_THIS, SDL_Window * window) libdecor_frame_set_minimized(wind->shell_surface.libdecor.frame); } else #endif - if (viddata->shell.xdg) { + if (viddata->shell.xdg) { if (wind->shell_surface.xdg.roleobj.toplevel == NULL) { return; /* Can't do anything yet, wait for ShowWindow */ } @@ -1937,10 +1884,9 @@ Wayland_MinimizeWindow(_THIS, SDL_Window * window) WAYLAND_wl_display_flush(viddata->display); } -void -Wayland_SetWindowMouseRect(_THIS, SDL_Window *window) +void Wayland_SetWindowMouseRect(_THIS, SDL_Window *window) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; /* This may look suspiciously like SetWindowGrab, despite SetMouseRect not * implicitly doing a grab. And you're right! Wayland doesn't let us mess @@ -1957,10 +1903,9 @@ Wayland_SetWindowMouseRect(_THIS, SDL_Window *window) } } -void -Wayland_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed) +void Wayland_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; if (grabbed) { Wayland_input_confine_pointer(data->input, window); @@ -1969,10 +1914,9 @@ Wayland_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed) } } -void -Wayland_SetWindowKeyboardGrab(_THIS, SDL_Window *window, SDL_bool grabbed) +void Wayland_SetWindowKeyboardGrab(_THIS, SDL_Window *window, SDL_bool grabbed) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; if (grabbed) { Wayland_input_grab_keyboard(window, data->input); @@ -2015,8 +1959,8 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window) if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) { int i; - for (i=0; i < SDL_GetVideoDevice()->num_displays; i++) { - float scale = ((SDL_WaylandOutputData*)SDL_GetVideoDevice()->displays[i].driverdata)->scale_factor; + for (i = 0; i < SDL_GetVideoDevice()->num_displays; i++) { + float scale = ((SDL_WaylandOutputData *)SDL_GetVideoDevice()->displays[i].driverdata)->scale_factor; data->scale_factor = SDL_max(data->scale_factor, scale); } } @@ -2056,7 +2000,7 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window) #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH if (c->surface_extension) { data->extended_surface = qt_surface_extension_get_extended_surface( - c->surface_extension, data->surface); + c->surface_extension, data->surface); QtExtendedSurface_Subscribe(data->extended_surface, SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION); QtExtendedSurface_Subscribe(data->extended_surface, SDL_HINT_QTWAYLAND_WINDOW_FLAGS); @@ -2068,10 +2012,10 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window) #if SDL_VIDEO_OPENGL_EGL /* Create the GLES window surface */ - data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->egl_window); + data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType)data->egl_window); if (data->egl_surface == EGL_NO_SURFACE) { - return -1; /* SDL_EGL_CreateSurface should have set error */ + return -1; /* SDL_EGL_CreateSurface should have set error */ } #endif } @@ -2091,7 +2035,7 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window) if (c->fractional_scale_manager) { data->fractional_scale = wp_fractional_scale_manager_v1_get_fractional_scale(c->fractional_scale_manager, data->surface); wp_fractional_scale_v1_add_listener(data->fractional_scale, - &fractional_scale_listener, data); + &fractional_scale_listener, data); } /* Moved this call to ShowWindow: wl_surface_commit(data->surface); */ @@ -2100,30 +2044,28 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window) /* We may need to create an idle inhibitor for this new window */ Wayland_SuspendScreenSaver(_this); - #define IS_POPUP(window) \ - (window->flags & (SDL_WINDOW_TOOLTIP | SDL_WINDOW_POPUP_MENU)) +#define IS_POPUP(window) \ + (window->flags & (SDL_WINDOW_TOOLTIP | SDL_WINDOW_POPUP_MENU)) #ifdef HAVE_LIBDECOR_H if (c->shell.libdecor && !IS_POPUP(window)) { data->shell_surface_type = WAYLAND_SURFACE_LIBDECOR; } else #endif - if (c->shell.xdg) { + if (c->shell.xdg) { if (IS_POPUP(window)) { data->shell_surface_type = WAYLAND_SURFACE_XDG_POPUP; } else { data->shell_surface_type = WAYLAND_SURFACE_XDG_TOPLEVEL; } } /* All other cases will be WAYLAND_SURFACE_UNKNOWN */ - #undef IS_POPUP +#undef IS_POPUP return 0; } - -static void -Wayland_HandleResize(SDL_Window *window, int width, int height, float scale) +static void Wayland_HandleResize(SDL_Window *window, int width, int height, float scale) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; const int old_w = window->w, old_h = window->h; const int old_drawable_width = data->drawable_width; const int old_drawable_height = data->drawable_height; @@ -2148,19 +2090,17 @@ Wayland_HandleResize(SDL_Window *window, int width, int height, float scale) } } -void -Wayland_SetWindowMinimumSize(_THIS, SDL_Window * window) +void Wayland_SetWindowMinimumSize(_THIS, SDL_Window *window) { SetMinMaxDimensions(window, SDL_TRUE); } -void -Wayland_SetWindowMaximumSize(_THIS, SDL_Window * window) +void Wayland_SetWindowMaximumSize(_THIS, SDL_Window *window) { SetMinMaxDimensions(window, SDL_TRUE); } -void Wayland_SetWindowSize(_THIS, SDL_Window * window) +void Wayland_SetWindowSize(_THIS, SDL_Window *window) { SDL_WindowData *wind = window->driverdata; @@ -2169,9 +2109,9 @@ void Wayland_SetWindowSize(_THIS, SDL_Window * window) if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR && wind->shell_surface.libdecor.frame && !libdecor_frame_is_floating(wind->shell_surface.libdecor.frame)) { - /* Commit the resize when we re-enter floating state */ - wind->floating_resize_pending = SDL_TRUE; - return; + /* Commit the resize when we re-enter floating state */ + wind->floating_resize_pending = SDL_TRUE; + return; } #endif @@ -2184,17 +2124,17 @@ void Wayland_SetWindowSize(_THIS, SDL_Window * window) wind->floating_height = window->windowed.h; } -void Wayland_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h) +void Wayland_GetWindowSizeInPixels(_THIS, SDL_Window *window, int *w, int *h) { SDL_WindowData *data; if (window->driverdata) { - data = (SDL_WindowData *) window->driverdata; + data = (SDL_WindowData *)window->driverdata; *w = data->drawable_width; *h = data->drawable_height; } } -void Wayland_SetWindowTitle(_THIS, SDL_Window * window) +void Wayland_SetWindowTitle(_THIS, SDL_Window *window) { SDL_WindowData *wind = window->driverdata; SDL_VideoData *viddata = _this->driverdata; @@ -2222,8 +2162,7 @@ void Wayland_SetWindowTitle(_THIS, SDL_Window * window) WAYLAND_wl_display_flush(viddata->display); } -void -Wayland_SuspendScreenSaver(_THIS) +void Wayland_SuspendScreenSaver(_THIS) { SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; @@ -2318,23 +2257,22 @@ void Wayland_DestroyWindow(_THIS, SDL_Window *window) window->driverdata = NULL; } -static void -EGLTransparencyChangedCallback(void *userdata, const char *name, const char *oldValue, const char *newValue) +static void EGLTransparencyChangedCallback(void *userdata, const char *name, const char *oldValue, const char *newValue) { const SDL_bool oldval = SDL_GetStringBoolean(oldValue, SDL_FALSE); const SDL_bool newval = SDL_GetStringBoolean(newValue, SDL_FALSE); if (oldval != newval) { - SDL_Window *window; - SDL_VideoData *viddata = (SDL_VideoData *) userdata; - SDL_VideoDevice *dev = SDL_GetVideoDevice(); + SDL_Window *window; + SDL_VideoData *viddata = (SDL_VideoData *)userdata; + SDL_VideoDevice *dev = SDL_GetVideoDevice(); viddata->egl_transparency_enabled = newval; /* Iterate over all windows and update the surface opaque regions */ for (window = dev->windows; window != NULL; window = window->next) { - SDL_WindowData *wind = (SDL_WindowData *) window->driverdata; - + SDL_WindowData *wind = (SDL_WindowData *)window->driverdata; + if (!newval) { struct wl_region *region = wl_compositor_create_region(wind->waylandData->compositor); wl_region_add(region, 0, 0, wind->window_width, wind->window_height); @@ -2347,15 +2285,13 @@ EGLTransparencyChangedCallback(void *userdata, const char *name, const char *old } } -void -Wayland_InitWin(SDL_VideoData *data) +void Wayland_InitWin(SDL_VideoData *data) { data->egl_transparency_enabled = SDL_GetHintBoolean(SDL_HINT_VIDEO_EGL_ALLOW_TRANSPARENCY, SDL_FALSE); SDL_AddHintCallback(SDL_HINT_VIDEO_EGL_ALLOW_TRANSPARENCY, EGLTransparencyChangedCallback, data); } -void -Wayland_QuitWin(SDL_VideoData *data) +void Wayland_QuitWin(SDL_VideoData *data) { SDL_DelHintCallback(SDL_HINT_VIDEO_EGL_ALLOW_TRANSPARENCY, EGLTransparencyChangedCallback, data); } diff --git a/src/video/wayland/SDL_waylandwindow.h b/src/video/wayland/SDL_waylandwindow.h index 76adba510..912f75d60 100644 --- a/src/video/wayland/SDL_waylandwindow.h +++ b/src/video/wayland/SDL_waylandwindow.h @@ -32,7 +32,8 @@ struct SDL_WaylandInput; -typedef struct { +typedef struct +{ SDL_Window *sdlwindow; SDL_VideoData *waylandData; struct wl_surface *surface; @@ -41,18 +42,23 @@ typedef struct { struct wl_surface *gles_swap_frame_surface_wrapper; struct wl_callback *surface_damage_frame_callback; - union { + union + { #ifdef HAVE_LIBDECOR_H - struct { + struct + { struct libdecor_frame *frame; SDL_bool initial_configure_seen; } libdecor; #endif - struct { + struct + { struct xdg_surface *surface; - union { + union + { struct xdg_toplevel *toplevel; - struct { + struct + { struct xdg_popup *popup; struct xdg_positioner *positioner; Uint32 parentID; @@ -62,7 +68,8 @@ typedef struct { SDL_bool initial_configure_seen; } xdg; } shell_surface; - enum { + enum + { WAYLAND_SURFACE_UNKNOWN = 0, WAYLAND_SURFACE_XDG_TOPLEVEL, WAYLAND_SURFACE_XDG_POPUP, @@ -112,31 +119,31 @@ typedef struct { extern void Wayland_ShowWindow(_THIS, SDL_Window *window); extern void Wayland_HideWindow(_THIS, SDL_Window *window); extern void Wayland_RaiseWindow(_THIS, SDL_Window *window); -extern void Wayland_SetWindowFullscreen(_THIS, SDL_Window * window, - SDL_VideoDisplay * _display, +extern void Wayland_SetWindowFullscreen(_THIS, SDL_Window *window, + SDL_VideoDisplay *_display, SDL_bool fullscreen); -extern void Wayland_MaximizeWindow(_THIS, SDL_Window * window); -extern void Wayland_MinimizeWindow(_THIS, SDL_Window * window); -extern void Wayland_SetWindowMouseRect(_THIS, SDL_Window * window); -extern void Wayland_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed); +extern void Wayland_MaximizeWindow(_THIS, SDL_Window *window); +extern void Wayland_MinimizeWindow(_THIS, SDL_Window *window); +extern void Wayland_SetWindowMouseRect(_THIS, SDL_Window *window); +extern void Wayland_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed); extern void Wayland_SetWindowKeyboardGrab(_THIS, SDL_Window *window, SDL_bool grabbed); -extern void Wayland_RestoreWindow(_THIS, SDL_Window * window); -extern void Wayland_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered); -extern void Wayland_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable); +extern void Wayland_RestoreWindow(_THIS, SDL_Window *window); +extern void Wayland_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered); +extern void Wayland_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable); extern int Wayland_CreateWindow(_THIS, SDL_Window *window); -extern void Wayland_SetWindowSize(_THIS, SDL_Window * window); -extern void Wayland_SetWindowMinimumSize(_THIS, SDL_Window * window); -extern void Wayland_SetWindowMaximumSize(_THIS, SDL_Window * window); -extern void Wayland_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h); -extern int Wayland_SetWindowModalFor(_THIS, SDL_Window * modal_window, SDL_Window * parent_window); -extern void Wayland_SetWindowTitle(_THIS, SDL_Window * window); +extern void Wayland_SetWindowSize(_THIS, SDL_Window *window); +extern void Wayland_SetWindowMinimumSize(_THIS, SDL_Window *window); +extern void Wayland_SetWindowMaximumSize(_THIS, SDL_Window *window); +extern void Wayland_GetWindowSizeInPixels(_THIS, SDL_Window *window, int *w, int *h); +extern int Wayland_SetWindowModalFor(_THIS, SDL_Window *modal_window, SDL_Window *parent_window); +extern void Wayland_SetWindowTitle(_THIS, SDL_Window *window); extern void Wayland_DestroyWindow(_THIS, SDL_Window *window); extern void Wayland_SuspendScreenSaver(_THIS); extern SDL_bool Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info); extern int Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled); -extern int Wayland_FlashWindow(_THIS, SDL_Window * window, SDL_FlashOperation operation); +extern int Wayland_FlashWindow(_THIS, SDL_Window *window, SDL_FlashOperation operation); extern void Wayland_InitWin(SDL_VideoData *data); extern void Wayland_QuitWin(SDL_VideoData *data); diff --git a/src/video/windows/SDL_msctf.h b/src/video/windows/SDL_msctf.h index 9fa80785d..31d42fd26 100644 --- a/src/video/windows/SDL_msctf.h +++ b/src/video/windows/SDL_msctf.h @@ -24,9 +24,11 @@ #include -#define TF_INVALID_COOKIE (0xffffffff) -#define TF_IPSINK_FLAG_ACTIVE 0x0001 -#define TF_TMAE_UIELEMENTENABLEDONLY 0x00000004 +#define TF_INVALID_COOKIE (0xffffffff) +#define TF_IPSINK_FLAG_ACTIVE 0x0001 +#define TF_TMAE_UIELEMENTENABLEDONLY 0x00000004 + +/* *INDENT-OFF* */ /* clang-format off */ typedef struct ITfThreadMgr ITfThreadMgr; typedef struct ITfDocumentMgr ITfDocumentMgr; @@ -239,4 +241,6 @@ struct ITfSource const struct ITfSourceVtbl *lpVtbl; }; +/* *INDENT-ON* */ /* clang-format on */ + #endif /* SDL_msctf_h_ */ diff --git a/src/video/windows/SDL_vkeys.h b/src/video/windows/SDL_vkeys.h index 3b0c41929..c80beac6d 100644 --- a/src/video/windows/SDL_vkeys.h +++ b/src/video/windows/SDL_vkeys.h @@ -20,57 +20,57 @@ */ #ifndef VK_0 -#define VK_0 '0' -#define VK_1 '1' -#define VK_2 '2' -#define VK_3 '3' -#define VK_4 '4' -#define VK_5 '5' -#define VK_6 '6' -#define VK_7 '7' -#define VK_8 '8' -#define VK_9 '9' -#define VK_A 'A' -#define VK_B 'B' -#define VK_C 'C' -#define VK_D 'D' -#define VK_E 'E' -#define VK_F 'F' -#define VK_G 'G' -#define VK_H 'H' -#define VK_I 'I' -#define VK_J 'J' -#define VK_K 'K' -#define VK_L 'L' -#define VK_M 'M' -#define VK_N 'N' -#define VK_O 'O' -#define VK_P 'P' -#define VK_Q 'Q' -#define VK_R 'R' -#define VK_S 'S' -#define VK_T 'T' -#define VK_U 'U' -#define VK_V 'V' -#define VK_W 'W' -#define VK_X 'X' -#define VK_Y 'Y' -#define VK_Z 'Z' +#define VK_0 '0' +#define VK_1 '1' +#define VK_2 '2' +#define VK_3 '3' +#define VK_4 '4' +#define VK_5 '5' +#define VK_6 '6' +#define VK_7 '7' +#define VK_8 '8' +#define VK_9 '9' +#define VK_A 'A' +#define VK_B 'B' +#define VK_C 'C' +#define VK_D 'D' +#define VK_E 'E' +#define VK_F 'F' +#define VK_G 'G' +#define VK_H 'H' +#define VK_I 'I' +#define VK_J 'J' +#define VK_K 'K' +#define VK_L 'L' +#define VK_M 'M' +#define VK_N 'N' +#define VK_O 'O' +#define VK_P 'P' +#define VK_Q 'Q' +#define VK_R 'R' +#define VK_S 'S' +#define VK_T 'T' +#define VK_U 'U' +#define VK_V 'V' +#define VK_W 'W' +#define VK_X 'X' +#define VK_Y 'Y' +#define VK_Z 'Z' #endif /* VK_0 */ /* These keys haven't been defined, but were experimentally determined */ -#define VK_SEMICOLON 0xBA -#define VK_EQUALS 0xBB -#define VK_COMMA 0xBC -#define VK_MINUS 0xBD -#define VK_PERIOD 0xBE -#define VK_SLASH 0xBF -#define VK_GRAVE 0xC0 -#define VK_LBRACKET 0xDB -#define VK_BACKSLASH 0xDC -#define VK_RBRACKET 0xDD -#define VK_APOSTROPHE 0xDE -#define VK_BACKTICK 0xDF -#define VK_OEM_102 0xE2 +#define VK_SEMICOLON 0xBA +#define VK_EQUALS 0xBB +#define VK_COMMA 0xBC +#define VK_MINUS 0xBD +#define VK_PERIOD 0xBE +#define VK_SLASH 0xBF +#define VK_GRAVE 0xC0 +#define VK_LBRACKET 0xDB +#define VK_BACKSLASH 0xDC +#define VK_RBRACKET 0xDD +#define VK_APOSTROPHE 0xDE +#define VK_BACKTICK 0xDF +#define VK_OEM_102 0xE2 /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/windows/SDL_windowsclipboard.c b/src/video/windows/SDL_windowsclipboard.c index 4ba650e2e..efb824593 100644 --- a/src/video/windows/SDL_windowsclipboard.c +++ b/src/video/windows/SDL_windowsclipboard.c @@ -26,31 +26,27 @@ #include "SDL_windowswindow.h" #include "../../events/SDL_clipboardevents_c.h" - #ifdef UNICODE -#define TEXT_FORMAT CF_UNICODETEXT +#define TEXT_FORMAT CF_UNICODETEXT #else -#define TEXT_FORMAT CF_TEXT +#define TEXT_FORMAT CF_TEXT #endif - /* Get any application owned window handle for clipboard association */ -static HWND -GetWindowHandle(_THIS) +static HWND GetWindowHandle(_THIS) { SDL_Window *window; window = _this->windows; if (window) { - return ((SDL_WindowData *) window->driverdata)->hwnd; + return ((SDL_WindowData *)window->driverdata)->hwnd; } return NULL; } -int -WIN_SetClipboardText(_THIS, const char *text) +int WIN_SetClipboardText(_THIS, const char *text) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; int result = 0; if (OpenClipboard(GetWindowHandle(_this))) { @@ -66,12 +62,12 @@ WIN_SetClipboardText(_THIS, const char *text) /* Find out the size of the data */ for (size = 0, i = 0; tstr[i]; ++i, ++size) { - if (tstr[i] == '\n' && (i == 0 || tstr[i-1] != '\r')) { + if (tstr[i] == '\n' && (i == 0 || tstr[i - 1] != '\r')) { /* We're going to insert a carriage return */ ++size; } } - size = (size+1)*sizeof(*tstr); + size = (size + 1) * sizeof(*tstr); /* Save the data to the clipboard */ hMem = GlobalAlloc(GMEM_MOVEABLE, size); @@ -80,7 +76,7 @@ WIN_SetClipboardText(_THIS, const char *text) if (dst) { /* Copy the text over, adding carriage returns as necessary */ for (i = 0; tstr[i]; ++i) { - if (tstr[i] == '\n' && (i == 0 || tstr[i-1] != '\r')) { + if (tstr[i] == '\n' && (i == 0 || tstr[i - 1] != '\r')) { *dst++ = '\r'; } *dst++ = tstr[i]; @@ -143,8 +139,7 @@ WIN_HasClipboardText(_THIS) return result; } -void -WIN_CheckClipboardUpdate(struct SDL_VideoData * data) +void WIN_CheckClipboardUpdate(struct SDL_VideoData *data) { const DWORD count = GetClipboardSequenceNumber(); if (count != data->clipboard_count) { diff --git a/src/video/windows/SDL_windowsclipboard.h b/src/video/windows/SDL_windowsclipboard.h index 5cdcdfcab..04ce7db6e 100644 --- a/src/video/windows/SDL_windowsclipboard.h +++ b/src/video/windows/SDL_windowsclipboard.h @@ -29,7 +29,7 @@ struct SDL_VideoData; extern int WIN_SetClipboardText(_THIS, const char *text); extern char *WIN_GetClipboardText(_THIS); extern SDL_bool WIN_HasClipboardText(_THIS); -extern void WIN_CheckClipboardUpdate(struct SDL_VideoData * data); +extern void WIN_CheckClipboardUpdate(struct SDL_VideoData *data); #endif /* SDL_windowsclipboard_h_ */ diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index f608b39b3..2cb3d4b90 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -60,10 +60,10 @@ /* #define HIGHDPI_DEBUG */ /* Masks for processing the windows KEYDOWN and KEYUP messages */ -#define REPEATED_KEYMASK (1<<30) -#define EXTENDED_KEYMASK (1<<24) +#define REPEATED_KEYMASK (1 << 30) +#define EXTENDED_KEYMASK (1 << 24) -#define VK_ENTER 10 /* Keypad Enter ... no VKEY defined? */ +#define VK_ENTER 10 /* Keypad Enter ... no VKEY defined? */ #ifndef VK_OEM_NEC_EQUAL #define VK_OEM_NEC_EQUAL 0x92 #endif @@ -101,87 +101,132 @@ #endif #ifndef IS_HIGH_SURROGATE -#define IS_HIGH_SURROGATE(x) (((x) >= 0xd800) && ((x) <= 0xdbff)) +#define IS_HIGH_SURROGATE(x) (((x) >= 0xd800) && ((x) <= 0xdbff)) #endif #ifndef IS_LOW_SURROGATE -#define IS_LOW_SURROGATE(x) (((x) >= 0xdc00) && ((x) <= 0xdfff)) +#define IS_LOW_SURROGATE(x) (((x) >= 0xdc00) && ((x) <= 0xdfff)) #endif #ifndef IS_SURROGATE_PAIR -#define IS_SURROGATE_PAIR(h,l) (IS_HIGH_SURROGATE(h) && IS_LOW_SURROGATE(l)) +#define IS_SURROGATE_PAIR(h, l) (IS_HIGH_SURROGATE(h) && IS_LOW_SURROGATE(l)) #endif -static SDL_Scancode -VKeytoScancodeFallback(WPARAM vkey) +static SDL_Scancode VKeytoScancodeFallback(WPARAM vkey) { switch (vkey) { - case VK_LEFT: return SDL_SCANCODE_LEFT; - case VK_UP: return SDL_SCANCODE_UP; - case VK_RIGHT: return SDL_SCANCODE_RIGHT; - case VK_DOWN: return SDL_SCANCODE_DOWN; + case VK_LEFT: + return SDL_SCANCODE_LEFT; + case VK_UP: + return SDL_SCANCODE_UP; + case VK_RIGHT: + return SDL_SCANCODE_RIGHT; + case VK_DOWN: + return SDL_SCANCODE_DOWN; - default: return SDL_SCANCODE_UNKNOWN; + default: + return SDL_SCANCODE_UNKNOWN; } } -static SDL_Scancode -VKeytoScancode(WPARAM vkey) +static SDL_Scancode VKeytoScancode(WPARAM vkey) { switch (vkey) { - case VK_MODECHANGE: return SDL_SCANCODE_MODE; - case VK_SELECT: return SDL_SCANCODE_SELECT; - case VK_EXECUTE: return SDL_SCANCODE_EXECUTE; - case VK_HELP: return SDL_SCANCODE_HELP; - case VK_PAUSE: return SDL_SCANCODE_PAUSE; - case VK_NUMLOCK: return SDL_SCANCODE_NUMLOCKCLEAR; + case VK_MODECHANGE: + return SDL_SCANCODE_MODE; + case VK_SELECT: + return SDL_SCANCODE_SELECT; + case VK_EXECUTE: + return SDL_SCANCODE_EXECUTE; + case VK_HELP: + return SDL_SCANCODE_HELP; + case VK_PAUSE: + return SDL_SCANCODE_PAUSE; + case VK_NUMLOCK: + return SDL_SCANCODE_NUMLOCKCLEAR; - case VK_F13: return SDL_SCANCODE_F13; - case VK_F14: return SDL_SCANCODE_F14; - case VK_F15: return SDL_SCANCODE_F15; - case VK_F16: return SDL_SCANCODE_F16; - case VK_F17: return SDL_SCANCODE_F17; - case VK_F18: return SDL_SCANCODE_F18; - case VK_F19: return SDL_SCANCODE_F19; - case VK_F20: return SDL_SCANCODE_F20; - case VK_F21: return SDL_SCANCODE_F21; - case VK_F22: return SDL_SCANCODE_F22; - case VK_F23: return SDL_SCANCODE_F23; - case VK_F24: return SDL_SCANCODE_F24; + case VK_F13: + return SDL_SCANCODE_F13; + case VK_F14: + return SDL_SCANCODE_F14; + case VK_F15: + return SDL_SCANCODE_F15; + case VK_F16: + return SDL_SCANCODE_F16; + case VK_F17: + return SDL_SCANCODE_F17; + case VK_F18: + return SDL_SCANCODE_F18; + case VK_F19: + return SDL_SCANCODE_F19; + case VK_F20: + return SDL_SCANCODE_F20; + case VK_F21: + return SDL_SCANCODE_F21; + case VK_F22: + return SDL_SCANCODE_F22; + case VK_F23: + return SDL_SCANCODE_F23; + case VK_F24: + return SDL_SCANCODE_F24; - case VK_OEM_NEC_EQUAL: return SDL_SCANCODE_KP_EQUALS; - case VK_BROWSER_BACK: return SDL_SCANCODE_AC_BACK; - case VK_BROWSER_FORWARD: return SDL_SCANCODE_AC_FORWARD; - case VK_BROWSER_REFRESH: return SDL_SCANCODE_AC_REFRESH; - case VK_BROWSER_STOP: return SDL_SCANCODE_AC_STOP; - case VK_BROWSER_SEARCH: return SDL_SCANCODE_AC_SEARCH; - case VK_BROWSER_FAVORITES: return SDL_SCANCODE_AC_BOOKMARKS; - case VK_BROWSER_HOME: return SDL_SCANCODE_AC_HOME; - case VK_VOLUME_MUTE: return SDL_SCANCODE_AUDIOMUTE; - case VK_VOLUME_DOWN: return SDL_SCANCODE_VOLUMEDOWN; - case VK_VOLUME_UP: return SDL_SCANCODE_VOLUMEUP; + case VK_OEM_NEC_EQUAL: + return SDL_SCANCODE_KP_EQUALS; + case VK_BROWSER_BACK: + return SDL_SCANCODE_AC_BACK; + case VK_BROWSER_FORWARD: + return SDL_SCANCODE_AC_FORWARD; + case VK_BROWSER_REFRESH: + return SDL_SCANCODE_AC_REFRESH; + case VK_BROWSER_STOP: + return SDL_SCANCODE_AC_STOP; + case VK_BROWSER_SEARCH: + return SDL_SCANCODE_AC_SEARCH; + case VK_BROWSER_FAVORITES: + return SDL_SCANCODE_AC_BOOKMARKS; + case VK_BROWSER_HOME: + return SDL_SCANCODE_AC_HOME; + case VK_VOLUME_MUTE: + return SDL_SCANCODE_AUDIOMUTE; + case VK_VOLUME_DOWN: + return SDL_SCANCODE_VOLUMEDOWN; + case VK_VOLUME_UP: + return SDL_SCANCODE_VOLUMEUP; - case VK_MEDIA_NEXT_TRACK: return SDL_SCANCODE_AUDIONEXT; - case VK_MEDIA_PREV_TRACK: return SDL_SCANCODE_AUDIOPREV; - case VK_MEDIA_STOP: return SDL_SCANCODE_AUDIOSTOP; - case VK_MEDIA_PLAY_PAUSE: return SDL_SCANCODE_AUDIOPLAY; - case VK_LAUNCH_MAIL: return SDL_SCANCODE_MAIL; - case VK_LAUNCH_MEDIA_SELECT: return SDL_SCANCODE_MEDIASELECT; + case VK_MEDIA_NEXT_TRACK: + return SDL_SCANCODE_AUDIONEXT; + case VK_MEDIA_PREV_TRACK: + return SDL_SCANCODE_AUDIOPREV; + case VK_MEDIA_STOP: + return SDL_SCANCODE_AUDIOSTOP; + case VK_MEDIA_PLAY_PAUSE: + return SDL_SCANCODE_AUDIOPLAY; + case VK_LAUNCH_MAIL: + return SDL_SCANCODE_MAIL; + case VK_LAUNCH_MEDIA_SELECT: + return SDL_SCANCODE_MEDIASELECT; - case VK_OEM_102: return SDL_SCANCODE_NONUSBACKSLASH; + case VK_OEM_102: + return SDL_SCANCODE_NONUSBACKSLASH; - case VK_ATTN: return SDL_SCANCODE_SYSREQ; - case VK_CRSEL: return SDL_SCANCODE_CRSEL; - case VK_EXSEL: return SDL_SCANCODE_EXSEL; - case VK_OEM_CLEAR: return SDL_SCANCODE_CLEAR; + case VK_ATTN: + return SDL_SCANCODE_SYSREQ; + case VK_CRSEL: + return SDL_SCANCODE_CRSEL; + case VK_EXSEL: + return SDL_SCANCODE_EXSEL; + case VK_OEM_CLEAR: + return SDL_SCANCODE_CLEAR; - case VK_LAUNCH_APP1: return SDL_SCANCODE_APP1; - case VK_LAUNCH_APP2: return SDL_SCANCODE_APP2; + case VK_LAUNCH_APP1: + return SDL_SCANCODE_APP1; + case VK_LAUNCH_APP2: + return SDL_SCANCODE_APP2; - default: return SDL_SCANCODE_UNKNOWN; + default: + return SDL_SCANCODE_UNKNOWN; } } -static SDL_Scancode -WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam) +static SDL_Scancode WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam) { SDL_Scancode code; int nScanCode = (lParam >> 16) & 0xFF; @@ -266,14 +311,12 @@ WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam) } #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) -static SDL_bool -WIN_ShouldIgnoreFocusClick() +static SDL_bool WIN_ShouldIgnoreFocusClick() { return !SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, SDL_FALSE); } -static void -WIN_CheckWParamMouseButton(SDL_bool bwParamMousePressed, Uint32 mouseFlags, SDL_bool bSwapButtons, SDL_WindowData *data, Uint8 button, SDL_MouseID mouseID) +static void WIN_CheckWParamMouseButton(SDL_bool bwParamMousePressed, Uint32 mouseFlags, SDL_bool bSwapButtons, SDL_WindowData *data, Uint8 button, SDL_MouseID mouseID) { if (bSwapButtons) { if (button == SDL_BUTTON_LEFT) { @@ -302,11 +345,10 @@ WIN_CheckWParamMouseButton(SDL_bool bwParamMousePressed, Uint32 mouseFlags, SDL_ } /* -* Some windows systems fail to send a WM_LBUTTONDOWN sometimes, but each mouse move contains the current button state also -* so this function reconciles our view of the world with the current buttons reported by windows -*/ -static void -WIN_CheckWParamMouseButtons(WPARAM wParam, SDL_WindowData *data, SDL_MouseID mouseID) + * Some windows systems fail to send a WM_LBUTTONDOWN sometimes, but each mouse move contains the current button state also + * so this function reconciles our view of the world with the current buttons reported by windows + */ +static void WIN_CheckWParamMouseButtons(WPARAM wParam, SDL_WindowData *data, SDL_MouseID mouseID) { if (wParam != data->mouse_button_flags) { Uint32 mouseFlags = SDL_GetMouseState(NULL, NULL); @@ -322,8 +364,7 @@ WIN_CheckWParamMouseButtons(WPARAM wParam, SDL_WindowData *data, SDL_MouseID mou } } -static void -WIN_CheckRawMouseButtons(ULONG rawButtons, SDL_WindowData *data, SDL_MouseID mouseID) +static void WIN_CheckRawMouseButtons(ULONG rawButtons, SDL_WindowData *data, SDL_MouseID mouseID) { // Add a flag to distinguish raw mouse buttons from wParam above rawButtons |= 0x8000000; @@ -365,8 +406,7 @@ WIN_CheckRawMouseButtons(ULONG rawButtons, SDL_WindowData *data, SDL_MouseID mou } } -static void -WIN_CheckAsyncMouseRelease(SDL_WindowData *data) +static void WIN_CheckAsyncMouseRelease(SDL_WindowData *data) { Uint32 mouseFlags; SHORT keyState; @@ -401,10 +441,9 @@ WIN_CheckAsyncMouseRelease(SDL_WindowData *data) data->mouse_button_flags = (WPARAM)-1; } -static void -WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus) +static void WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; HWND hwnd = data->hwnd; SDL_bool had_focus = (SDL_GetKeyboardFocus() == window) ? SDL_TRUE : SDL_FALSE; SDL_bool has_focus = (GetForegroundWindow() == hwnd) ? SDL_TRUE : SDL_FALSE; @@ -481,26 +520,25 @@ WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus) } #endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ -static BOOL -WIN_ConvertUTF32toUTF8(UINT32 codepoint, char * text) +static BOOL WIN_ConvertUTF32toUTF8(UINT32 codepoint, char *text) { if (codepoint <= 0x7F) { - text[0] = (char) codepoint; + text[0] = (char)codepoint; text[1] = '\0'; } else if (codepoint <= 0x7FF) { - text[0] = 0xC0 | (char) ((codepoint >> 6) & 0x1F); - text[1] = 0x80 | (char) (codepoint & 0x3F); + text[0] = 0xC0 | (char)((codepoint >> 6) & 0x1F); + text[1] = 0x80 | (char)(codepoint & 0x3F); text[2] = '\0'; } else if (codepoint <= 0xFFFF) { - text[0] = 0xE0 | (char) ((codepoint >> 12) & 0x0F); - text[1] = 0x80 | (char) ((codepoint >> 6) & 0x3F); - text[2] = 0x80 | (char) (codepoint & 0x3F); + text[0] = 0xE0 | (char)((codepoint >> 12) & 0x0F); + text[1] = 0x80 | (char)((codepoint >> 6) & 0x3F); + text[2] = 0x80 | (char)(codepoint & 0x3F); text[3] = '\0'; } else if (codepoint <= 0x10FFFF) { - text[0] = 0xF0 | (char) ((codepoint >> 18) & 0x0F); - text[1] = 0x80 | (char) ((codepoint >> 12) & 0x3F); - text[2] = 0x80 | (char) ((codepoint >> 6) & 0x3F); - text[3] = 0x80 | (char) (codepoint & 0x3F); + text[0] = 0xF0 | (char)((codepoint >> 18) & 0x0F); + text[1] = 0x80 | (char)((codepoint >> 12) & 0x3F); + text[2] = 0x80 | (char)((codepoint >> 6) & 0x3F); + text[3] = 0x80 | (char)(codepoint & 0x3F); text[4] = '\0'; } else { return SDL_FALSE; @@ -508,25 +546,23 @@ WIN_ConvertUTF32toUTF8(UINT32 codepoint, char * text) return SDL_TRUE; } -static BOOL -WIN_ConvertUTF16toUTF8(UINT32 high_surrogate, UINT32 low_surrogate, char * text) +static BOOL WIN_ConvertUTF16toUTF8(UINT32 high_surrogate, UINT32 low_surrogate, char *text) { const UINT32 SURROGATE_OFFSET = 0x10000 - (0xD800 << 10) - 0xDC00; const UINT32 codepoint = (high_surrogate << 10) + low_surrogate + SURROGATE_OFFSET; return WIN_ConvertUTF32toUTF8(codepoint, text); } -static SDL_bool -ShouldGenerateWindowCloseOnAltF4(void) +static SDL_bool ShouldGenerateWindowCloseOnAltF4(void) { return !SDL_GetHintBoolean(SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4, SDL_FALSE); } #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* We want to generate mouse events from mouse and pen, and touch events from touchscreens */ -#define MI_WP_SIGNATURE 0xFF515700 -#define MI_WP_SIGNATURE_MASK 0xFFFFFF00 -#define IsTouchEvent(dw) ((dw) & MI_WP_SIGNATURE_MASK) == MI_WP_SIGNATURE +#define MI_WP_SIGNATURE 0xFF515700 +#define MI_WP_SIGNATURE_MASK 0xFFFFFF00 +#define IsTouchEvent(dw) ((dw)&MI_WP_SIGNATURE_MASK) == MI_WP_SIGNATURE typedef enum { @@ -555,8 +591,7 @@ static SDL_MOUSE_EVENT_SOURCE GetMouseMessageSource() } #endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ -static SDL_WindowData * -WIN_GetWindowDataFromHWND(HWND hwnd) +static SDL_WindowData *WIN_GetWindowDataFromHWND(HWND hwnd) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); SDL_Window *window; @@ -576,8 +611,8 @@ WIN_GetWindowDataFromHWND(HWND hwnd) LRESULT CALLBACK WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) { - KBDLLHOOKSTRUCT* hookData = (KBDLLHOOKSTRUCT*)lParam; - SDL_VideoData* data = SDL_GetVideoDevice()->driverdata; + KBDLLHOOKSTRUCT *hookData = (KBDLLHOOKSTRUCT *)lParam; + SDL_VideoData *data = SDL_GetVideoDevice()->driverdata; SDL_Scancode scanCode; if (nCode < 0 || nCode != HC_ACTION) { @@ -661,7 +696,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) if (data == NULL) { /* Fallback */ - data = (SDL_WindowData *) GetProp(hwnd, TEXT("SDL_WindowData")); + data = (SDL_WindowData *)GetProp(hwnd, TEXT("SDL_WindowData")); } #endif if (data == NULL) { @@ -689,86 +724,80 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) switch (msg) { case WM_SHOWWINDOW: - { - if (wParam) { - SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0); - } else { - SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIDDEN, 0, 0); - } + { + if (wParam) { + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0); + } else { + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIDDEN, 0, 0); } - break; + } break; #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) case WM_NCACTIVATE: - { - /* Don't immediately clip the cursor in case we're clicking minimize/maximize buttons */ - data->skip_update_clipcursor = SDL_TRUE; + { + /* Don't immediately clip the cursor in case we're clicking minimize/maximize buttons */ + data->skip_update_clipcursor = SDL_TRUE; - /* Update the focus here, since it's possible to get WM_ACTIVATE and WM_SETFOCUS without - actually being the foreground window, but this appears to get called in all cases where - the global foreground window changes to and from this window. */ - WIN_UpdateFocus(data->window, !!wParam); - } - break; + /* Update the focus here, since it's possible to get WM_ACTIVATE and WM_SETFOCUS without + actually being the foreground window, but this appears to get called in all cases where + the global foreground window changes to and from this window. */ + WIN_UpdateFocus(data->window, !!wParam); + } break; case WM_ACTIVATE: - { - /* Update the focus in case we changed focus to a child window and then away from the application */ - WIN_UpdateFocus(data->window, !!LOWORD(wParam)); - } - break; + { + /* Update the focus in case we changed focus to a child window and then away from the application */ + WIN_UpdateFocus(data->window, !!LOWORD(wParam)); + } break; case WM_SETFOCUS: - { - /* Update the focus in case it's changing between top-level windows in the same application */ - WIN_UpdateFocus(data->window, SDL_TRUE); - } - break; + { + /* Update the focus in case it's changing between top-level windows in the same application */ + WIN_UpdateFocus(data->window, SDL_TRUE); + } break; case WM_KILLFOCUS: case WM_ENTERIDLE: - { - /* Update the focus in case it's changing between top-level windows in the same application */ - WIN_UpdateFocus(data->window, SDL_FALSE); - } - break; + { + /* Update the focus in case it's changing between top-level windows in the same application */ + WIN_UpdateFocus(data->window, SDL_FALSE); + } break; case WM_POINTERUPDATE: - { - data->last_pointer_update = lParam; - break; - } + { + data->last_pointer_update = lParam; + break; + } case WM_MOUSEMOVE: - { - SDL_Mouse *mouse = SDL_GetMouse(); + { + SDL_Mouse *mouse = SDL_GetMouse(); - if (!data->mouse_tracked) { - TRACKMOUSEEVENT trackMouseEvent; + if (!data->mouse_tracked) { + TRACKMOUSEEVENT trackMouseEvent; - trackMouseEvent.cbSize = sizeof(TRACKMOUSEEVENT); - trackMouseEvent.dwFlags = TME_LEAVE; - trackMouseEvent.hwndTrack = data->hwnd; + trackMouseEvent.cbSize = sizeof(TRACKMOUSEEVENT); + trackMouseEvent.dwFlags = TME_LEAVE; + trackMouseEvent.hwndTrack = data->hwnd; - if (TrackMouseEvent(&trackMouseEvent)) { - data->mouse_tracked = SDL_TRUE; - } - } - - if (!mouse->relative_mode || mouse->relative_mode_warp) { - /* Only generate mouse events for real mouse */ - if (GetMouseMessageSource() != SDL_MOUSE_EVENT_SOURCE_TOUCH && - lParam != data->last_pointer_update) { - int x = GET_X_LPARAM(lParam); - int y = GET_Y_LPARAM(lParam); - - WIN_ClientPointToSDL(data->window, &x, &y); - - SDL_SendMouseMotion(data->window, 0, 0, x, y); - } + if (TrackMouseEvent(&trackMouseEvent)) { + data->mouse_tracked = SDL_TRUE; } } - break; + + if (!mouse->relative_mode || mouse->relative_mode_warp) { + /* Only generate mouse events for real mouse */ + if (GetMouseMessageSource() != SDL_MOUSE_EVENT_SOURCE_TOUCH && + lParam != data->last_pointer_update) { + int x = GET_X_LPARAM(lParam); + int y = GET_Y_LPARAM(lParam); + + WIN_ClientPointToSDL(data->window, &x, &y); + + SDL_SendMouseMotion(data->window, 0, 0, x, y); + } + } + } break; case WM_LBUTTONUP: case WM_RBUTTONUP: @@ -782,141 +811,138 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_MBUTTONDBLCLK: case WM_XBUTTONDOWN: case WM_XBUTTONDBLCLK: - { - SDL_Mouse *mouse = SDL_GetMouse(); - if (!mouse->relative_mode || mouse->relative_mode_warp) { - if (GetMouseMessageSource() != SDL_MOUSE_EVENT_SOURCE_TOUCH && - lParam != data->last_pointer_update) { - WIN_CheckWParamMouseButtons(wParam, data, 0); - } + { + SDL_Mouse *mouse = SDL_GetMouse(); + if (!mouse->relative_mode || mouse->relative_mode_warp) { + if (GetMouseMessageSource() != SDL_MOUSE_EVENT_SOURCE_TOUCH && + lParam != data->last_pointer_update) { + WIN_CheckWParamMouseButtons(wParam, data, 0); } } - break; + } break; case WM_INPUT: - { - SDL_Mouse *mouse = SDL_GetMouse(); - HRAWINPUT hRawInput = (HRAWINPUT)lParam; - RAWINPUT inp; - UINT size = sizeof(inp); + { + SDL_Mouse *mouse = SDL_GetMouse(); + HRAWINPUT hRawInput = (HRAWINPUT)lParam; + RAWINPUT inp; + UINT size = sizeof(inp); - /* We only use raw mouse input in relative mode */ - if (!mouse->relative_mode || mouse->relative_mode_warp) { + /* We only use raw mouse input in relative mode */ + if (!mouse->relative_mode || mouse->relative_mode_warp) { + break; + } + + /* Relative mouse motion is delivered to the window with keyboard focus */ + if (data->window != SDL_GetKeyboardFocus()) { + break; + } + + GetRawInputData(hRawInput, RID_INPUT, &inp, &size, sizeof(RAWINPUTHEADER)); + + /* Mouse data (ignoring synthetic mouse events generated for touchscreens) */ + if (inp.header.dwType == RIM_TYPEMOUSE) { + SDL_MouseID mouseID; + RAWMOUSE *rawmouse; + if (SDL_GetNumTouchDevices() > 0 && + (GetMouseMessageSource() == SDL_MOUSE_EVENT_SOURCE_TOUCH || (GetMessageExtraInfo() & 0x82) == 0x82)) { break; } + /* We do all of our mouse state checking against mouse ID 0 + * We would only use the actual hDevice if we were tracking + * all mouse motion independently, and never using mouse ID 0. + */ + mouseID = 0; /* (SDL_MouseID)(uintptr_t)inp.header.hDevice; */ + rawmouse = &inp.data.mouse; - /* Relative mouse motion is delivered to the window with keyboard focus */ - if (data->window != SDL_GetKeyboardFocus()) { - break; - } + if ((rawmouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE) { + SDL_SendMouseMotion(data->window, mouseID, 1, (int)rawmouse->lLastX, (int)rawmouse->lLastY); + } else if (rawmouse->lLastX || rawmouse->lLastY) { + /* This is absolute motion, either using a tablet or mouse over RDP - GetRawInputData(hRawInput, RID_INPUT, &inp, &size, sizeof(RAWINPUTHEADER)); + Notes on how RDP appears to work, as of Windows 10 2004: + - SetCursorPos() calls are cached, with multiple calls coalesced into a single call that's sent to the RDP client. If the last call to SetCursorPos() has the same value as the last one that was sent to the client, it appears to be ignored and not sent. This means that we need to jitter the SetCursorPos() position slightly in order for the recentering to work correctly. + - User mouse motion is coalesced with SetCursorPos(), so the WM_INPUT positions we see will not necessarily match the positon we requested with SetCursorPos(). + - SetCursorPos() outside of the bounds of the focus window appears not to do anything. + - SetCursorPos() while the cursor is NULL doesn't do anything - /* Mouse data (ignoring synthetic mouse events generated for touchscreens) */ - if (inp.header.dwType == RIM_TYPEMOUSE) { - SDL_MouseID mouseID; - RAWMOUSE* rawmouse; - if (SDL_GetNumTouchDevices() > 0 && - (GetMouseMessageSource() == SDL_MOUSE_EVENT_SOURCE_TOUCH || (GetMessageExtraInfo() & 0x82) == 0x82)) { - break; - } - /* We do all of our mouse state checking against mouse ID 0 - * We would only use the actual hDevice if we were tracking - * all mouse motion independently, and never using mouse ID 0. - */ - mouseID = 0; /* (SDL_MouseID)(uintptr_t)inp.header.hDevice; */ - rawmouse = &inp.data.mouse; - - if ((rawmouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE) { - SDL_SendMouseMotion(data->window, mouseID, 1, (int)rawmouse->lLastX, (int)rawmouse->lLastY); - } else if (rawmouse->lLastX || rawmouse->lLastY) { - /* This is absolute motion, either using a tablet or mouse over RDP - - Notes on how RDP appears to work, as of Windows 10 2004: - - SetCursorPos() calls are cached, with multiple calls coalesced into a single call that's sent to the RDP client. If the last call to SetCursorPos() has the same value as the last one that was sent to the client, it appears to be ignored and not sent. This means that we need to jitter the SetCursorPos() position slightly in order for the recentering to work correctly. - - User mouse motion is coalesced with SetCursorPos(), so the WM_INPUT positions we see will not necessarily match the positon we requested with SetCursorPos(). - - SetCursorPos() outside of the bounds of the focus window appears not to do anything. - - SetCursorPos() while the cursor is NULL doesn't do anything - - We handle this by creating a safe area within the application window, and when the mouse leaves that safe area, we warp back to the opposite side. Any single motion > 50% of the safe area is assumed to be a warp and ignored. - */ - SDL_bool remote_desktop = GetSystemMetrics(SM_REMOTESESSION) ? SDL_TRUE : SDL_FALSE; - SDL_bool virtual_desktop = (rawmouse->usFlags & MOUSE_VIRTUAL_DESKTOP) ? SDL_TRUE : SDL_FALSE; - SDL_bool normalized_coordinates = ((rawmouse->usFlags & 0x40) == 0) ? SDL_TRUE : SDL_FALSE; - int w = GetSystemMetrics(virtual_desktop ? SM_CXVIRTUALSCREEN : SM_CXSCREEN); - int h = GetSystemMetrics(virtual_desktop ? SM_CYVIRTUALSCREEN : SM_CYSCREEN); - int x = normalized_coordinates ? (int)(((float)rawmouse->lLastX / 65535.0f) * w) : (int)rawmouse->lLastX; - int y = normalized_coordinates ? (int)(((float)rawmouse->lLastY / 65535.0f) * h) : (int)rawmouse->lLastY; - int relX, relY; - - /* Calculate relative motion */ - if (data->last_raw_mouse_position.x == 0 && data->last_raw_mouse_position.y == 0) { - data->last_raw_mouse_position.x = x; - data->last_raw_mouse_position.y = y; - } - relX = (int)(x - data->last_raw_mouse_position.x); - relY = (int)(y - data->last_raw_mouse_position.y); - - if (remote_desktop) { - if (!data->in_title_click && !data->focus_click_pending) { - static int wobble; - float floatX = (float)x / w; - float floatY = (float)y / h; - - /* See if the mouse is at the edge of the screen, or in the RDP title bar area */ - if (floatX <= 0.01f || floatX >= 0.99f || floatY <= 0.01f || floatY >= 0.99f || y < 32) { - /* Wobble the cursor position so it's not ignored if the last warp didn't have any effect */ - RECT rect = data->cursor_clipped_rect; - int warpX = rect.left + ((rect.right - rect.left) / 2) + wobble; - int warpY = rect.top + ((rect.bottom - rect.top) / 2); - - WIN_SetCursorPos(warpX, warpY); - - ++wobble; - if (wobble > 1) { - wobble = -1; - } - } else { - /* Send relative motion if we didn't warp last frame (had good position data) - We also sometimes get large deltas due to coalesced mouse motion and warping, - so ignore those. - */ - const int MAX_RELATIVE_MOTION = (h / 6); - if (SDL_abs(relX) < MAX_RELATIVE_MOTION && - SDL_abs(relY) < MAX_RELATIVE_MOTION) { - SDL_SendMouseMotion(data->window, mouseID, 1, relX, relY); - } - } - } - } else { - const int MAXIMUM_TABLET_RELATIVE_MOTION = 32; - if (SDL_abs(relX) > MAXIMUM_TABLET_RELATIVE_MOTION || - SDL_abs(relY) > MAXIMUM_TABLET_RELATIVE_MOTION) { - /* Ignore this motion, probably a pen lift and drop */ - } else { - SDL_SendMouseMotion(data->window, mouseID, 1, relX, relY); - } - } + We handle this by creating a safe area within the application window, and when the mouse leaves that safe area, we warp back to the opposite side. Any single motion > 50% of the safe area is assumed to be a warp and ignored. + */ + SDL_bool remote_desktop = GetSystemMetrics(SM_REMOTESESSION) ? SDL_TRUE : SDL_FALSE; + SDL_bool virtual_desktop = (rawmouse->usFlags & MOUSE_VIRTUAL_DESKTOP) ? SDL_TRUE : SDL_FALSE; + SDL_bool normalized_coordinates = ((rawmouse->usFlags & 0x40) == 0) ? SDL_TRUE : SDL_FALSE; + int w = GetSystemMetrics(virtual_desktop ? SM_CXVIRTUALSCREEN : SM_CXSCREEN); + int h = GetSystemMetrics(virtual_desktop ? SM_CYVIRTUALSCREEN : SM_CYSCREEN); + int x = normalized_coordinates ? (int)(((float)rawmouse->lLastX / 65535.0f) * w) : (int)rawmouse->lLastX; + int y = normalized_coordinates ? (int)(((float)rawmouse->lLastY / 65535.0f) * h) : (int)rawmouse->lLastY; + int relX, relY; + /* Calculate relative motion */ + if (data->last_raw_mouse_position.x == 0 && data->last_raw_mouse_position.y == 0) { data->last_raw_mouse_position.x = x; data->last_raw_mouse_position.y = y; } - WIN_CheckRawMouseButtons(rawmouse->usButtonFlags, data, mouseID); + relX = (int)(x - data->last_raw_mouse_position.x); + relY = (int)(y - data->last_raw_mouse_position.y); + + if (remote_desktop) { + if (!data->in_title_click && !data->focus_click_pending) { + static int wobble; + float floatX = (float)x / w; + float floatY = (float)y / h; + + /* See if the mouse is at the edge of the screen, or in the RDP title bar area */ + if (floatX <= 0.01f || floatX >= 0.99f || floatY <= 0.01f || floatY >= 0.99f || y < 32) { + /* Wobble the cursor position so it's not ignored if the last warp didn't have any effect */ + RECT rect = data->cursor_clipped_rect; + int warpX = rect.left + ((rect.right - rect.left) / 2) + wobble; + int warpY = rect.top + ((rect.bottom - rect.top) / 2); + + WIN_SetCursorPos(warpX, warpY); + + ++wobble; + if (wobble > 1) { + wobble = -1; + } + } else { + /* Send relative motion if we didn't warp last frame (had good position data) + We also sometimes get large deltas due to coalesced mouse motion and warping, + so ignore those. + */ + const int MAX_RELATIVE_MOTION = (h / 6); + if (SDL_abs(relX) < MAX_RELATIVE_MOTION && + SDL_abs(relY) < MAX_RELATIVE_MOTION) { + SDL_SendMouseMotion(data->window, mouseID, 1, relX, relY); + } + } + } + } else { + const int MAXIMUM_TABLET_RELATIVE_MOTION = 32; + if (SDL_abs(relX) > MAXIMUM_TABLET_RELATIVE_MOTION || + SDL_abs(relY) > MAXIMUM_TABLET_RELATIVE_MOTION) { + /* Ignore this motion, probably a pen lift and drop */ + } else { + SDL_SendMouseMotion(data->window, mouseID, 1, relX, relY); + } + } + + data->last_raw_mouse_position.x = x; + data->last_raw_mouse_position.y = y; } + WIN_CheckRawMouseButtons(rawmouse->usButtonFlags, data, mouseID); } - break; + } break; case WM_MOUSEWHEEL: case WM_MOUSEHWHEEL: - { - short amount = GET_WHEEL_DELTA_WPARAM(wParam); - float fAmount = (float) amount / WHEEL_DELTA; - if (msg == WM_MOUSEWHEEL) - SDL_SendMouseWheel(data->window, 0, 0.0f, fAmount, SDL_MOUSEWHEEL_NORMAL); - else - SDL_SendMouseWheel(data->window, 0, fAmount, 0.0f, SDL_MOUSEWHEEL_NORMAL); - } - break; + { + short amount = GET_WHEEL_DELTA_WPARAM(wParam); + float fAmount = (float)amount / WHEEL_DELTA; + if (msg == WM_MOUSEWHEEL) + SDL_SendMouseWheel(data->window, 0, 0.0f, fAmount, SDL_MOUSEWHEEL_NORMAL); + else + SDL_SendMouseWheel(data->window, 0, fAmount, 0.0f, SDL_MOUSEWHEEL_NORMAL); + } break; case WM_MOUSELEAVE: if (!(data->window->flags & SDL_WINDOW_MOUSE_CAPTURE)) { @@ -932,14 +958,14 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) mouse = SDL_GetMouse(); if (!mouse->was_touch_mouse_events) { /* we're not a touch handler causing a mouse leave? */ SDL_SendMouseMotion(data->window, 0, 0, point.x, point.y); - } else { /* touch handling? */ + } else { /* touch handling? */ mouse->was_touch_mouse_events = SDL_FALSE; /* not anymore */ - if (mouse->touch_mouse_events) { /* convert touch to mouse events */ + if (mouse->touch_mouse_events) { /* convert touch to mouse events */ SDL_SendMouseMotion(data->window, SDL_TOUCH_MOUSEID, 0, point.x, point.y); } else { /* normal handling */ SDL_SendMouseMotion(data->window, 0, 0, point.x, point.y); } - } + } } if (!SDL_GetMouse()->relative_mode) { @@ -957,40 +983,40 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_KEYDOWN: case WM_SYSKEYDOWN: - { - SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam); - const Uint8 *keyboardState = SDL_GetKeyboardState(NULL); + { + SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam); + const Uint8 *keyboardState = SDL_GetKeyboardState(NULL); - /* Detect relevant keyboard shortcuts */ - if (keyboardState[SDL_SCANCODE_LALT] == SDL_PRESSED || keyboardState[SDL_SCANCODE_RALT] == SDL_PRESSED) { - /* ALT+F4: Close window */ - if (code == SDL_SCANCODE_F4 && ShouldGenerateWindowCloseOnAltF4()) { - SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0); - } - } - - if (code != SDL_SCANCODE_UNKNOWN) { - SDL_SendKeyboardKey(SDL_PRESSED, code); + /* Detect relevant keyboard shortcuts */ + if (keyboardState[SDL_SCANCODE_LALT] == SDL_PRESSED || keyboardState[SDL_SCANCODE_RALT] == SDL_PRESSED) { + /* ALT+F4: Close window */ + if (code == SDL_SCANCODE_F4 && ShouldGenerateWindowCloseOnAltF4()) { + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0); } } + if (code != SDL_SCANCODE_UNKNOWN) { + SDL_SendKeyboardKey(SDL_PRESSED, code); + } + } + returnCode = 0; break; case WM_SYSKEYUP: case WM_KEYUP: - { - SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam); - const Uint8 *keyboardState = SDL_GetKeyboardState(NULL); + { + SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam); + const Uint8 *keyboardState = SDL_GetKeyboardState(NULL); - if (code != SDL_SCANCODE_UNKNOWN) { - if (code == SDL_SCANCODE_PRINTSCREEN && - keyboardState[code] == SDL_RELEASED) { - SDL_SendKeyboardKey(SDL_PRESSED, code); - } - SDL_SendKeyboardKey(SDL_RELEASED, code); + if (code != SDL_SCANCODE_UNKNOWN) { + if (code == SDL_SCANCODE_PRINTSCREEN && + keyboardState[code] == SDL_RELEASED) { + SDL_SendKeyboardKey(SDL_PRESSED, code); } + SDL_SendKeyboardKey(SDL_RELEASED, code); } + } returnCode = 0; break; @@ -1038,133 +1064,131 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #ifdef WM_INPUTLANGCHANGE case WM_INPUTLANGCHANGE: - { - WIN_UpdateKeymap(SDL_TRUE); - } + { + WIN_UpdateKeymap(SDL_TRUE); + } returnCode = 1; break; #endif /* WM_INPUTLANGCHANGE */ case WM_NCLBUTTONDOWN: - { - data->in_title_click = SDL_TRUE; - } - break; + { + data->in_title_click = SDL_TRUE; + } break; case WM_CAPTURECHANGED: - { - data->in_title_click = SDL_FALSE; + { + data->in_title_click = SDL_FALSE; - /* The mouse may have been released during a modal loop */ - WIN_CheckAsyncMouseRelease(data); - } - break; + /* The mouse may have been released during a modal loop */ + WIN_CheckAsyncMouseRelease(data); + } break; #ifdef WM_GETMINMAXINFO case WM_GETMINMAXINFO: - { - MINMAXINFO *info; - RECT size; - int x, y; - int w, h; - int min_w, min_h; - int max_w, max_h; - BOOL constrain_max_size; + { + MINMAXINFO *info; + RECT size; + int x, y; + int w, h; + int min_w, min_h; + int max_w, max_h; + BOOL constrain_max_size; - if (SDL_IsShapedWindow(data->window)) { - Win32_ResizeWindowShape(data->window); - } - - /* If this is an expected size change, allow it */ - if (data->expected_resize) { - break; - } - - /* Get the current position of our window */ - GetWindowRect(hwnd, &size); - x = size.left; - y = size.top; - - /* Calculate current size of our window */ - SDL_GetWindowSize(data->window, &w, &h); - SDL_GetWindowMinimumSize(data->window, &min_w, &min_h); - SDL_GetWindowMaximumSize(data->window, &max_w, &max_h); - - /* Convert w, h, min_w, min_h, max_w, max_h from dpi-scaled points to pixels, - treating them as coordinates within the client area. */ - WIN_ClientPointFromSDL(data->window, &w, &h); - WIN_ClientPointFromSDL(data->window, &min_w, &min_h); - WIN_ClientPointFromSDL(data->window, &max_w, &max_h); - - /* Store in min_w and min_h difference between current size and minimal - size so we don't need to call AdjustWindowRectEx twice */ - min_w -= w; - min_h -= h; - if (max_w && max_h) { - max_w -= w; - max_h -= h; - constrain_max_size = TRUE; - } else { - constrain_max_size = FALSE; - } - - if (!(SDL_GetWindowFlags(data->window) & SDL_WINDOW_BORDERLESS)) { - LONG style = GetWindowLong(hwnd, GWL_STYLE); - /* DJM - according to the docs for GetMenu(), the - return value is undefined if hwnd is a child window. - Apparently it's too difficult for MS to check - inside their function, so I have to do it here. - */ - BOOL menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL); - UINT dpi; - - dpi = 96; - size.top = 0; - size.left = 0; - size.bottom = h; - size.right = w; - - if (WIN_IsPerMonitorV2DPIAware(SDL_GetVideoDevice())) { - dpi = data->videodata->GetDpiForWindow(hwnd); - data->videodata->AdjustWindowRectExForDpi(&size, style, menu, 0, dpi); - } else { - AdjustWindowRectEx(&size, style, menu, 0); - } - w = size.right - size.left; - h = size.bottom - size.top; -#ifdef HIGHDPI_DEBUG - SDL_Log("WM_GETMINMAXINFO: max window size: %dx%d using dpi: %u", w, h, dpi); -#endif - } - - /* Fix our size to the current size */ - info = (MINMAXINFO *) lParam; - if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_RESIZABLE) { - if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_BORDERLESS) { - int screenW = GetSystemMetrics(SM_CXSCREEN); - int screenH = GetSystemMetrics(SM_CYSCREEN); - info->ptMaxSize.x = SDL_max(w, screenW); - info->ptMaxSize.y = SDL_max(h, screenH); - info->ptMaxPosition.x = SDL_min(0, ((screenW - w) / 2)); - info->ptMaxPosition.y = SDL_min(0, ((screenH - h) / 2)); - } - info->ptMinTrackSize.x = w + min_w; - info->ptMinTrackSize.y = h + min_h; - if (constrain_max_size) { - info->ptMaxTrackSize.x = w + max_w; - info->ptMaxTrackSize.y = h + max_h; - } - } else { - info->ptMaxSize.x = w; - info->ptMaxSize.y = h; - info->ptMaxPosition.x = x; - info->ptMaxPosition.y = y; - info->ptMinTrackSize.x = w; - info->ptMinTrackSize.y = h; - info->ptMaxTrackSize.x = w; - info->ptMaxTrackSize.y = h; - } + if (SDL_IsShapedWindow(data->window)) { + Win32_ResizeWindowShape(data->window); } + + /* If this is an expected size change, allow it */ + if (data->expected_resize) { + break; + } + + /* Get the current position of our window */ + GetWindowRect(hwnd, &size); + x = size.left; + y = size.top; + + /* Calculate current size of our window */ + SDL_GetWindowSize(data->window, &w, &h); + SDL_GetWindowMinimumSize(data->window, &min_w, &min_h); + SDL_GetWindowMaximumSize(data->window, &max_w, &max_h); + + /* Convert w, h, min_w, min_h, max_w, max_h from dpi-scaled points to pixels, + treating them as coordinates within the client area. */ + WIN_ClientPointFromSDL(data->window, &w, &h); + WIN_ClientPointFromSDL(data->window, &min_w, &min_h); + WIN_ClientPointFromSDL(data->window, &max_w, &max_h); + + /* Store in min_w and min_h difference between current size and minimal + size so we don't need to call AdjustWindowRectEx twice */ + min_w -= w; + min_h -= h; + if (max_w && max_h) { + max_w -= w; + max_h -= h; + constrain_max_size = TRUE; + } else { + constrain_max_size = FALSE; + } + + if (!(SDL_GetWindowFlags(data->window) & SDL_WINDOW_BORDERLESS)) { + LONG style = GetWindowLong(hwnd, GWL_STYLE); + /* DJM - according to the docs for GetMenu(), the + return value is undefined if hwnd is a child window. + Apparently it's too difficult for MS to check + inside their function, so I have to do it here. + */ + BOOL menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL); + UINT dpi; + + dpi = 96; + size.top = 0; + size.left = 0; + size.bottom = h; + size.right = w; + + if (WIN_IsPerMonitorV2DPIAware(SDL_GetVideoDevice())) { + dpi = data->videodata->GetDpiForWindow(hwnd); + data->videodata->AdjustWindowRectExForDpi(&size, style, menu, 0, dpi); + } else { + AdjustWindowRectEx(&size, style, menu, 0); + } + w = size.right - size.left; + h = size.bottom - size.top; +#ifdef HIGHDPI_DEBUG + SDL_Log("WM_GETMINMAXINFO: max window size: %dx%d using dpi: %u", w, h, dpi); +#endif + } + + /* Fix our size to the current size */ + info = (MINMAXINFO *)lParam; + if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_RESIZABLE) { + if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_BORDERLESS) { + int screenW = GetSystemMetrics(SM_CXSCREEN); + int screenH = GetSystemMetrics(SM_CYSCREEN); + info->ptMaxSize.x = SDL_max(w, screenW); + info->ptMaxSize.y = SDL_max(h, screenH); + info->ptMaxPosition.x = SDL_min(0, ((screenW - w) / 2)); + info->ptMaxPosition.y = SDL_min(0, ((screenH - h) / 2)); + } + info->ptMinTrackSize.x = w + min_w; + info->ptMinTrackSize.y = h + min_h; + if (constrain_max_size) { + info->ptMaxTrackSize.x = w + max_w; + info->ptMaxTrackSize.y = h + max_h; + } + } else { + info->ptMaxSize.x = w; + info->ptMaxSize.y = h; + info->ptMaxPosition.x = x; + info->ptMaxPosition.y = y; + info->ptMinTrackSize.x = w; + info->ptMinTrackSize.y = h; + info->ptMaxTrackSize.x = w; + info->ptMaxTrackSize.y = h; + } + } returnCode = 0; break; #endif /* WM_GETMINMAXINFO */ @@ -1177,105 +1201,102 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) break; case WM_WINDOWPOSCHANGED: - { - RECT rect; - int x, y; - int w, h; - int display_index = data->window->display_index; + { + RECT rect; + int x, y; + int w, h; + int display_index = data->window->display_index; - if (data->initializing || data->in_border_change) { - break; - } + if (data->initializing || data->in_border_change) { + break; + } - /* When the window is minimized it's resized to the dock icon size, ignore this */ - if (IsIconic(hwnd)) { - break; - } + /* When the window is minimized it's resized to the dock icon size, ignore this */ + if (IsIconic(hwnd)) { + break; + } - if (!GetClientRect(hwnd, &rect) || IsRectEmpty(&rect)) { - break; - } - ClientToScreen(hwnd, (LPPOINT) & rect); - ClientToScreen(hwnd, (LPPOINT) & rect + 1); + if (!GetClientRect(hwnd, &rect) || IsRectEmpty(&rect)) { + break; + } + ClientToScreen(hwnd, (LPPOINT)&rect); + ClientToScreen(hwnd, (LPPOINT)&rect + 1); - WIN_UpdateClipCursor(data->window); + WIN_UpdateClipCursor(data->window); - x = rect.left; - y = rect.top; - WIN_ScreenPointToSDL(&x, &y); + x = rect.left; + y = rect.top; + WIN_ScreenPointToSDL(&x, &y); - SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MOVED, x, y); + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MOVED, x, y); - /* Convert client area width/height from pixels to dpi-scaled points */ - w = rect.right - rect.left; - h = rect.bottom - rect.top; - WIN_ClientPointToSDL(data->window, &w, &h); + /* Convert client area width/height from pixels to dpi-scaled points */ + w = rect.right - rect.left; + h = rect.bottom - rect.top; + WIN_ClientPointToSDL(data->window, &w, &h); - SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESIZED, w, h); + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESIZED, w, h); #ifdef HIGHDPI_DEBUG - SDL_Log("WM_WINDOWPOSCHANGED: Windows client rect (pixels): (%d, %d) (%d x %d)\tSDL client rect (points): (%d, %d) (%d x %d) cached dpi %d, windows reported dpi %d", + SDL_Log("WM_WINDOWPOSCHANGED: Windows client rect (pixels): (%d, %d) (%d x %d)\tSDL client rect (points): (%d, %d) (%d x %d) cached dpi %d, windows reported dpi %d", rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, x, y, w, h, data->scaling_dpi, data->videodata->GetDpiForWindow ? data->videodata->GetDpiForWindow(data->hwnd) : 0); #endif - /* Forces a WM_PAINT event */ - InvalidateRect(hwnd, NULL, FALSE); + /* Forces a WM_PAINT event */ + InvalidateRect(hwnd, NULL, FALSE); - if (data->window->display_index != display_index) { - /* Display changed, check ICC profile */ - WIN_UpdateWindowICCProfile(data->window, SDL_TRUE); - } + if (data->window->display_index != display_index) { + /* Display changed, check ICC profile */ + WIN_UpdateWindowICCProfile(data->window, SDL_TRUE); } - break; + } break; case WM_SIZE: - { - switch (wParam) { - case SIZE_MAXIMIZED: - SDL_SendWindowEvent(data->window, - SDL_WINDOWEVENT_RESTORED, 0, 0); - SDL_SendWindowEvent(data->window, - SDL_WINDOWEVENT_MAXIMIZED, 0, 0); - break; - case SIZE_MINIMIZED: - SDL_SendWindowEvent(data->window, - SDL_WINDOWEVENT_MINIMIZED, 0, 0); - break; - case SIZE_RESTORED: - SDL_SendWindowEvent(data->window, - SDL_WINDOWEVENT_RESTORED, 0, 0); - break; - default: - break; - } + { + switch (wParam) { + case SIZE_MAXIMIZED: + SDL_SendWindowEvent(data->window, + SDL_WINDOWEVENT_RESTORED, 0, 0); + SDL_SendWindowEvent(data->window, + SDL_WINDOWEVENT_MAXIMIZED, 0, 0); + break; + case SIZE_MINIMIZED: + SDL_SendWindowEvent(data->window, + SDL_WINDOWEVENT_MINIMIZED, 0, 0); + break; + case SIZE_RESTORED: + SDL_SendWindowEvent(data->window, + SDL_WINDOWEVENT_RESTORED, 0, 0); + break; + default: + break; } - break; + } break; case WM_SETCURSOR: - { - Uint16 hittest; + { + Uint16 hittest; - hittest = LOWORD(lParam); - if (hittest == HTCLIENT) { - SetCursor(SDL_cursor); - returnCode = TRUE; - } else if (!g_WindowFrameUsableWhileCursorHidden && !SDL_cursor) { - SetCursor(NULL); - returnCode = TRUE; - } + hittest = LOWORD(lParam); + if (hittest == HTCLIENT) { + SetCursor(SDL_cursor); + returnCode = TRUE; + } else if (!g_WindowFrameUsableWhileCursorHidden && !SDL_cursor) { + SetCursor(NULL); + returnCode = TRUE; } - break; + } break; /* We were occluded, refresh our display */ case WM_PAINT: - { - RECT rect; - if (GetUpdateRect(hwnd, &rect, FALSE)) { - ValidateRect(hwnd, NULL); - SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_EXPOSED, 0, 0); - } + { + RECT rect; + if (GetUpdateRect(hwnd, &rect, FALSE)) { + ValidateRect(hwnd, NULL); + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_EXPOSED, 0, 0); } + } returnCode = 0; break; @@ -1293,27 +1314,26 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return 1; case WM_SYSCOMMAND: - { - if ((wParam & 0xFFF0) == SC_KEYMENU) { - return 0; - } + { + if ((wParam & 0xFFF0) == SC_KEYMENU) { + return 0; + } #if defined(SC_SCREENSAVE) || defined(SC_MONITORPOWER) - /* Don't start the screensaver or blank the monitor in fullscreen apps */ - if ((wParam & 0xFFF0) == SC_SCREENSAVE || - (wParam & 0xFFF0) == SC_MONITORPOWER) { - if (SDL_GetVideoDevice()->suspend_screensaver) { - return 0; - } + /* Don't start the screensaver or blank the monitor in fullscreen apps */ + if ((wParam & 0xFFF0) == SC_SCREENSAVE || + (wParam & 0xFFF0) == SC_MONITORPOWER) { + if (SDL_GetVideoDevice()->suspend_screensaver) { + return 0; } -#endif /* System has screensaver support */ } - break; +#endif /* System has screensaver support */ + } break; case WM_CLOSE: - { - SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0); - } + { + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0); + } returnCode = 0; break; @@ -1333,8 +1353,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } break; } - ClientToScreen(hwnd, (LPPOINT) & rect); - ClientToScreen(hwnd, (LPPOINT) & rect + 1); + ClientToScreen(hwnd, (LPPOINT)&rect); + ClientToScreen(hwnd, (LPPOINT)&rect + 1); rect.top *= 100; rect.left *= 100; rect.bottom *= 100; @@ -1353,8 +1373,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } /* Get the normalized coordinates for the window */ - x = (float)(input->x - rect.left)/(rect.right - rect.left); - y = (float)(input->y - rect.top)/(rect.bottom - rect.top); + x = (float)(input->x - rect.left) / (rect.right - rect.left); + y = (float)(input->y - rect.top) / (rect.bottom - rect.top); if (input->dwFlags & TOUCHEVENTF_DOWN) { SDL_SendTouch(touchId, input->dwID, data->window, SDL_TRUE, x, y, 1.0f); @@ -1381,101 +1401,111 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) * If we're handling our own touches, we don't want any gestures. * Not all of these settings are documented. * The use of the undocumented ones was suggested by https://github.com/bjarkeck/GCGJ/blob/master/Monogame/Windows/WinFormsGameForm.cs . */ - return TABLET_DISABLE_PRESSANDHOLD | TABLET_DISABLE_PENTAPFEEDBACK | TABLET_DISABLE_PENBARRELFEEDBACK | TABLET_DISABLE_TOUCHUIFORCEON | TABLET_DISABLE_TOUCHUIFORCEOFF | TABLET_DISABLE_TOUCHSWITCH | TABLET_DISABLE_FLICKS | TABLET_DISABLE_SMOOTHSCROLLING | TABLET_DISABLE_FLICKFALLBACKKEYS; /* disables press and hold (right-click) gesture */ - /* disables UI feedback on pen up (waves) */ - /* disables UI feedback on pen button down (circle) */ - /* disables pen flicks (back, forward, drag down, drag up) */ + return TABLET_DISABLE_PRESSANDHOLD | TABLET_DISABLE_PENTAPFEEDBACK | TABLET_DISABLE_PENBARRELFEEDBACK | TABLET_DISABLE_TOUCHUIFORCEON | TABLET_DISABLE_TOUCHUIFORCEOFF | TABLET_DISABLE_TOUCHSWITCH | TABLET_DISABLE_FLICKS | TABLET_DISABLE_SMOOTHSCROLLING | TABLET_DISABLE_FLICKFALLBACKKEYS; /* disables press and hold (right-click) gesture */ + /* disables UI feedback on pen up (waves) */ + /* disables UI feedback on pen button down (circle) */ + /* disables pen flicks (back, forward, drag down, drag up) */ #endif /* HAVE_TPCSHRD_H */ case WM_DROPFILES: - { - UINT i; - HDROP drop = (HDROP) wParam; - UINT count = DragQueryFile(drop, 0xFFFFFFFF, NULL, 0); - for (i = 0; i < count; ++i) { - SDL_bool isstack; - UINT size = DragQueryFile(drop, i, NULL, 0) + 1; - LPTSTR buffer = SDL_small_alloc(TCHAR, size, &isstack); - if (buffer) { - if (DragQueryFile(drop, i, buffer, size)) { - char *file = WIN_StringToUTF8(buffer); - SDL_SendDropFile(data->window, file); - SDL_free(file); - } - SDL_small_free(buffer, isstack); + { + UINT i; + HDROP drop = (HDROP)wParam; + UINT count = DragQueryFile(drop, 0xFFFFFFFF, NULL, 0); + for (i = 0; i < count; ++i) { + SDL_bool isstack; + UINT size = DragQueryFile(drop, i, NULL, 0) + 1; + LPTSTR buffer = SDL_small_alloc(TCHAR, size, &isstack); + if (buffer) { + if (DragQueryFile(drop, i, buffer, size)) { + char *file = WIN_StringToUTF8(buffer); + SDL_SendDropFile(data->window, file); + SDL_free(file); } + SDL_small_free(buffer, isstack); } - SDL_SendDropComplete(data->window); - DragFinish(drop); - return 0; } - break; + SDL_SendDropComplete(data->window); + DragFinish(drop); + return 0; + } break; case WM_DISPLAYCHANGE: - { - // Reacquire displays if any were added or removed - WIN_RefreshDisplays(SDL_GetVideoDevice()); - } - break; + { + // Reacquire displays if any were added or removed + WIN_RefreshDisplays(SDL_GetVideoDevice()); + } break; case WM_NCCALCSIZE: - { - Uint32 window_flags = SDL_GetWindowFlags(data->window); - if (wParam == TRUE && (window_flags & SDL_WINDOW_BORDERLESS) && !(window_flags & SDL_WINDOW_FULLSCREEN)) { - /* When borderless, need to tell windows that the size of the non-client area is 0 */ - if (!(window_flags & SDL_WINDOW_RESIZABLE)) { - int w, h; - NCCALCSIZE_PARAMS *params = (NCCALCSIZE_PARAMS *)lParam; - w = data->window->windowed.w; - h = data->window->windowed.h; - WIN_ClientPointFromSDL(data->window, &w, &h); - params->rgrc[0].right = params->rgrc[0].left + w; - params->rgrc[0].bottom = params->rgrc[0].top + h; - } - return 0; + { + Uint32 window_flags = SDL_GetWindowFlags(data->window); + if (wParam == TRUE && (window_flags & SDL_WINDOW_BORDERLESS) && !(window_flags & SDL_WINDOW_FULLSCREEN)) { + /* When borderless, need to tell windows that the size of the non-client area is 0 */ + if (!(window_flags & SDL_WINDOW_RESIZABLE)) { + int w, h; + NCCALCSIZE_PARAMS *params = (NCCALCSIZE_PARAMS *)lParam; + w = data->window->windowed.w; + h = data->window->windowed.h; + WIN_ClientPointFromSDL(data->window, &w, &h); + params->rgrc[0].right = params->rgrc[0].left + w; + params->rgrc[0].bottom = params->rgrc[0].top + h; } + return 0; } - break; + } break; case WM_NCHITTEST: - { - SDL_Window *window = data->window; - if (window->hit_test) { - POINT winpoint; - winpoint.x = GET_X_LPARAM(lParam); - winpoint.y = GET_Y_LPARAM(lParam); - if (ScreenToClient(hwnd, &winpoint)) { - SDL_Point point; - SDL_HitTestResult rc; - point.x = winpoint.x; - point.y = winpoint.y; - WIN_ClientPointToSDL(data->window, &point.x, &point.y); - rc = window->hit_test(window, &point, window->hit_test_data); - switch (rc) { - #define POST_HIT_TEST(ret) { SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIT_TEST, 0, 0); return ret; } - case SDL_HITTEST_DRAGGABLE: POST_HIT_TEST(HTCAPTION); - case SDL_HITTEST_RESIZE_TOPLEFT: POST_HIT_TEST(HTTOPLEFT); - case SDL_HITTEST_RESIZE_TOP: POST_HIT_TEST(HTTOP); - case SDL_HITTEST_RESIZE_TOPRIGHT: POST_HIT_TEST(HTTOPRIGHT); - case SDL_HITTEST_RESIZE_RIGHT: POST_HIT_TEST(HTRIGHT); - case SDL_HITTEST_RESIZE_BOTTOMRIGHT: POST_HIT_TEST(HTBOTTOMRIGHT); - case SDL_HITTEST_RESIZE_BOTTOM: POST_HIT_TEST(HTBOTTOM); - case SDL_HITTEST_RESIZE_BOTTOMLEFT: POST_HIT_TEST(HTBOTTOMLEFT); - case SDL_HITTEST_RESIZE_LEFT: POST_HIT_TEST(HTLEFT); - #undef POST_HIT_TEST - case SDL_HITTEST_NORMAL: return HTCLIENT; - } + { + SDL_Window *window = data->window; + if (window->hit_test) { + POINT winpoint; + winpoint.x = GET_X_LPARAM(lParam); + winpoint.y = GET_Y_LPARAM(lParam); + if (ScreenToClient(hwnd, &winpoint)) { + SDL_Point point; + SDL_HitTestResult rc; + point.x = winpoint.x; + point.y = winpoint.y; + WIN_ClientPointToSDL(data->window, &point.x, &point.y); + rc = window->hit_test(window, &point, window->hit_test_data); + switch (rc) { +#define POST_HIT_TEST(ret) \ + { \ + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIT_TEST, 0, 0); \ + return ret; \ + } + case SDL_HITTEST_DRAGGABLE: + POST_HIT_TEST(HTCAPTION); + case SDL_HITTEST_RESIZE_TOPLEFT: + POST_HIT_TEST(HTTOPLEFT); + case SDL_HITTEST_RESIZE_TOP: + POST_HIT_TEST(HTTOP); + case SDL_HITTEST_RESIZE_TOPRIGHT: + POST_HIT_TEST(HTTOPRIGHT); + case SDL_HITTEST_RESIZE_RIGHT: + POST_HIT_TEST(HTRIGHT); + case SDL_HITTEST_RESIZE_BOTTOMRIGHT: + POST_HIT_TEST(HTBOTTOMRIGHT); + case SDL_HITTEST_RESIZE_BOTTOM: + POST_HIT_TEST(HTBOTTOM); + case SDL_HITTEST_RESIZE_BOTTOMLEFT: + POST_HIT_TEST(HTBOTTOMLEFT); + case SDL_HITTEST_RESIZE_LEFT: + POST_HIT_TEST(HTLEFT); +#undef POST_HIT_TEST + case SDL_HITTEST_NORMAL: + return HTCLIENT; } - /* If we didn't return, this will call DefWindowProc below. */ } + /* If we didn't return, this will call DefWindowProc below. */ } - break; + } break; case WM_GETDPISCALEDSIZE: /* Windows 10 Creators Update+ */ /* Documented as only being sent to windows that are per-monitor V2 DPI aware. - + Experimentation shows it's only sent during interactive dragging, not in response to SetWindowPos. */ if (data->videodata->GetDpiForWindow && data->videodata->AdjustWindowRectExForDpi) { @@ -1489,7 +1519,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) because Windows doesn't scale the non-client area (titlebar etc.) linearly. So, we need to handle this message to request custom scaling. */ - + const int nextDPI = (int)wParam; const int prevDPI = (int)data->videodata->GetDpiForWindow(hwnd); SIZE *sizeInOut = (SIZE *)lParam; @@ -1507,7 +1537,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) /* Subtract the window frame size that would have been used at prevDPI */ { - RECT rect = {0}; + RECT rect = { 0 }; if (!(data->window->flags & SDL_WINDOW_BORDERLESS)) { data->videodata->AdjustWindowRectExForDpi(&rect, style, menu, 0, prevDPI); @@ -1520,7 +1550,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) query_client_h_win = sizeInOut->cy - frame_h; } - /* Convert to new dpi if we are using scaling. + /* Convert to new dpi if we are using scaling. * Otherwise leave as pixels. */ if (data->videodata->dpi_scaling_enabled) { @@ -1530,7 +1560,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) /* Add the window frame size that would be used at nextDPI */ { - RECT rect = {0}; + RECT rect = { 0 }; rect.right = query_client_w_win; rect.bottom = query_client_h_win; @@ -1554,12 +1584,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) /* Windows 8.1+ */ { const int newDPI = HIWORD(wParam); - RECT* const suggestedRect = (RECT*)lParam; + RECT *const suggestedRect = (RECT *)lParam; int w, h; #ifdef HIGHDPI_DEBUG SDL_Log("WM_DPICHANGED: to %d\tsuggested rect: (%d, %d), (%dx%d)\n", newDPI, - suggestedRect->left, suggestedRect->top, suggestedRect->right - suggestedRect->left, suggestedRect->bottom - suggestedRect->top); + suggestedRect->left, suggestedRect->top, suggestedRect->right - suggestedRect->left, suggestedRect->bottom - suggestedRect->top); #endif if (data->expected_resize) { @@ -1606,7 +1636,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) const DWORD style = GetWindowLong(hwnd, GWL_STYLE); const BOOL menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL); - RECT rect = {0}; + RECT rect = { 0 }; rect.right = data->window->w; rect.bottom = data->window->h; @@ -1623,21 +1653,21 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) w = rect.right - rect.left; h = rect.bottom - rect.top; } - + #ifdef HIGHDPI_DEBUG SDL_Log("WM_DPICHANGED: current SDL window size: (%dx%d)\tcalling SetWindowPos: (%d, %d), (%dx%d)\n", - data->window->w, data->window->h, - suggestedRect->left, suggestedRect->top, w, h); + data->window->w, data->window->h, + suggestedRect->left, suggestedRect->top, w, h); #endif data->expected_resize = SDL_TRUE; SetWindowPos(hwnd, - NULL, - suggestedRect->left, - suggestedRect->top, - w, - h, - SWP_NOZORDER | SWP_NOACTIVATE); + NULL, + suggestedRect->left, + suggestedRect->top, + w, + h, + SWP_NOZORDER | SWP_NOACTIVATE); data->expected_resize = SDL_FALSE; if (data->videodata->dpi_scaling_enabled) { @@ -1697,10 +1727,10 @@ static void WIN_UpdateClipCursorForWindows() static void WIN_UpdateMouseCapture() { - SDL_Window* focusWindow = SDL_GetKeyboardFocus(); + SDL_Window *focusWindow = SDL_GetKeyboardFocus(); if (focusWindow && (focusWindow->flags & SDL_WINDOW_MOUSE_CAPTURE)) { - SDL_WindowData *data = (SDL_WindowData *) focusWindow->driverdata; + SDL_WindowData *data = (SDL_WindowData *)focusWindow->driverdata; if (!data->mouse_tracked) { POINT cursorPos; @@ -1735,8 +1765,7 @@ void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata) g_WindowsMessageHookData = userdata; } -int -WIN_WaitEventTimeout(_THIS, int timeout) +int WIN_WaitEventTimeout(_THIS, int timeout) { MSG msg; if (g_WindowsEnableMessageLoop) { @@ -1771,15 +1800,13 @@ WIN_WaitEventTimeout(_THIS, int timeout) } } -void -WIN_SendWakeupEvent(_THIS, SDL_Window *window) +void WIN_SendWakeupEvent(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; PostMessage(data->hwnd, data->videodata->_SDL_WAKEUP, 0, 0); } -void -WIN_PumpEvents(_THIS) +void WIN_PumpEvents(_THIS) { MSG msg; DWORD end_ticks = GetTickCount() + 1; @@ -1864,7 +1891,6 @@ WIN_PumpEvents(_THIS) #endif } - static int app_registered = 0; LPTSTR SDL_Appname = NULL; Uint32 SDL_Appstyle = 0; @@ -1885,8 +1911,7 @@ static void WIN_CleanRegisterApp(WNDCLASSEX wcex) } /* Register the class for this application */ -int -SDL_RegisterApp(const char *name, Uint32 style, void *hInst) +int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) { WNDCLASSEX wcex; #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) @@ -1911,18 +1936,18 @@ SDL_RegisterApp(const char *name, Uint32 style, void *hInst) SDL_Instance = hInst ? hInst : GetModuleHandle(NULL); /* Register the application class */ - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.hCursor = NULL; - wcex.hIcon = NULL; - wcex.hIconSm = NULL; - wcex.lpszMenuName = NULL; - wcex.lpszClassName = SDL_Appname; - wcex.style = SDL_Appstyle; - wcex.hbrBackground = NULL; - wcex.lpfnWndProc = WIN_WindowProc; - wcex.hInstance = SDL_Instance; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; + wcex.cbSize = sizeof(WNDCLASSEX); + wcex.hCursor = NULL; + wcex.hIcon = NULL; + wcex.hIconSm = NULL; + wcex.lpszMenuName = NULL; + wcex.lpszClassName = SDL_Appname; + wcex.style = SDL_Appstyle; + wcex.hbrBackground = NULL; + wcex.lpfnWndProc = WIN_WindowProc; + wcex.hInstance = SDL_Instance; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) hint = SDL_GetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON); @@ -1950,8 +1975,7 @@ SDL_RegisterApp(const char *name, Uint32 style, void *hInst) } /* Unregisters the windowclass registered in SDL_RegisterApp above. */ -void -SDL_UnregisterApp() +void SDL_UnregisterApp() { WNDCLASSEX wcex; diff --git a/src/video/windows/SDL_windowsevents.h b/src/video/windows/SDL_windowsevents.h index be7f21ff2..de0db922a 100644 --- a/src/video/windows/SDL_windowsevents.h +++ b/src/video/windows/SDL_windowsevents.h @@ -32,7 +32,7 @@ extern LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); extern void WIN_PumpEvents(_THIS); extern void WIN_SendWakeupEvent(_THIS, SDL_Window *window); -extern int WIN_WaitEventTimeout(_THIS, int timeout); +extern int WIN_WaitEventTimeout(_THIS, int timeout); #endif /* SDL_windowsevents_h_ */ diff --git a/src/video/windows/SDL_windowsframebuffer.c b/src/video/windows/SDL_windowsframebuffer.c index 389cf94f8..5b792ecac 100644 --- a/src/video/windows/SDL_windowsframebuffer.c +++ b/src/video/windows/SDL_windowsframebuffer.c @@ -24,9 +24,9 @@ #include "SDL_windowsvideo.h" -int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch) +int WIN_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_bool isstack; size_t size; LPBITMAPINFO info; @@ -41,7 +41,7 @@ int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, voi } /* Find out the format of the screen */ - size = sizeof(BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD); + size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD); info = (LPBITMAPINFO)SDL_small_alloc(Uint8, size, &isstack); if (!info) { return SDL_OutOfMemory(); @@ -62,7 +62,7 @@ int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, voi Uint32 *masks; bpp = info->bmiHeader.biPlanes * info->bmiHeader.biBitCount; - masks = (Uint32*)((Uint8*)info + info->bmiHeader.biSize); + masks = (Uint32 *)((Uint8 *)info + info->bmiHeader.biSize); *format = SDL_MasksToPixelFormatEnum(bpp, masks[0], masks[1], masks[2], 0); } if (*format == SDL_PIXELFORMAT_UNKNOWN) { @@ -80,7 +80,7 @@ int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, voi /* Fill in the size information */ *pitch = (((window->w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3); info->bmiHeader.biWidth = window->w; - info->bmiHeader.biHeight = -window->h; /* negative for topdown bitmap */ + info->bmiHeader.biHeight = -window->h; /* negative for topdown bitmap */ info->bmiHeader.biSizeImage = window->h * (*pitch); data->mdc = CreateCompatibleDC(data->hdc); @@ -95,9 +95,9 @@ int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, voi return 0; } -int WIN_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects) +int WIN_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; int i; for (i = 0; i < numrects; ++i) { @@ -107,9 +107,9 @@ int WIN_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rec return 0; } -void WIN_DestroyWindowFramebuffer(_THIS, SDL_Window * window) +void WIN_DestroyWindowFramebuffer(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; if (data == NULL) { /* The window wasn't fully initialized */ diff --git a/src/video/windows/SDL_windowsframebuffer.h b/src/video/windows/SDL_windowsframebuffer.h index 04fc3d130..79839478c 100644 --- a/src/video/windows/SDL_windowsframebuffer.h +++ b/src/video/windows/SDL_windowsframebuffer.h @@ -20,8 +20,8 @@ */ #include "../../SDL_internal.h" -extern int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch); -extern int WIN_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects); -extern void WIN_DestroyWindowFramebuffer(_THIS, SDL_Window * window); +extern int WIN_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch); +extern int WIN_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects); +extern void WIN_DestroyWindowFramebuffer(_THIS, SDL_Window *window); /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c index 68ec749e2..425d6c546 100644 --- a/src/video/windows/SDL_windowskeyboard.c +++ b/src/video/windows/SDL_windowskeyboard.c @@ -37,25 +37,24 @@ static void IME_Enable(SDL_VideoData *videodata, HWND hwnd); static void IME_Disable(SDL_VideoData *videodata, HWND hwnd); static void IME_Quit(SDL_VideoData *videodata); static void IME_ClearComposition(SDL_VideoData *videodata); -static SDL_bool IME_IsTextInputShown(SDL_VideoData* videodata); +static SDL_bool IME_IsTextInputShown(SDL_VideoData *videodata); #endif /* !SDL_DISABLE_WINDOWS_IME */ #ifndef MAPVK_VK_TO_VSC -#define MAPVK_VK_TO_VSC 0 +#define MAPVK_VK_TO_VSC 0 #endif #ifndef MAPVK_VSC_TO_VK -#define MAPVK_VSC_TO_VK 1 +#define MAPVK_VSC_TO_VK 1 #endif #ifndef MAPVK_VK_TO_CHAR -#define MAPVK_VK_TO_CHAR 2 +#define MAPVK_VK_TO_CHAR 2 #endif /* Alphabetic scancodes for PC keyboards */ -void -WIN_InitKeyboard(_THIS) +void WIN_InitKeyboard(_THIS) { #ifndef SDL_DISABLE_WINDOWS_IME - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; data->ime_com_initialized = SDL_FALSE; data->ime_threadmgr = 0; @@ -66,7 +65,7 @@ WIN_InitKeyboard(_THIS) data->ime_hwnd_current = 0; data->ime_himc = 0; data->ime_composition_length = 32 * sizeof(WCHAR); - data->ime_composition = (WCHAR*)SDL_malloc(data->ime_composition_length + sizeof(WCHAR)); + data->ime_composition = (WCHAR *)SDL_malloc(data->ime_composition_length + sizeof(WCHAR)); data->ime_composition[0] = 0; data->ime_readingstring[0] = 0; data->ime_cursor = 0; @@ -116,8 +115,7 @@ WIN_InitKeyboard(_THIS) SDL_ToggleModState(KMOD_SCROLL, (GetKeyState(VK_SCROLL) & 0x0001) != 0); } -void -WIN_UpdateKeymap(SDL_bool send_event) +void WIN_UpdateKeymap(SDL_bool send_event) { int i; SDL_Scancode scancode; @@ -129,7 +127,7 @@ WIN_UpdateKeymap(SDL_bool send_event) int vk; /* Make sure this scancode is a valid character scancode */ scancode = windows_scancode_table[i]; - if (scancode == SDL_SCANCODE_UNKNOWN ) { + if (scancode == SDL_SCANCODE_UNKNOWN) { continue; } @@ -137,16 +135,16 @@ WIN_UpdateKeymap(SDL_bool send_event) /* Not mapping numbers fixes the French layout, giving numeric keycodes for the number keys, which is the expected behavior */ if ((keymap[scancode] & SDLK_SCANCODE_MASK) || /* scancode == SDL_SCANCODE_GRAVE || */ /* Uncomment this line to re-enable the behavior of not mapping the "`"(grave) key to the users actual keyboard layout */ - (scancode >= SDL_SCANCODE_1 && scancode <= SDL_SCANCODE_0) ) { + (scancode >= SDL_SCANCODE_1 && scancode <= SDL_SCANCODE_0)) { continue; } - vk = MapVirtualKey(i, MAPVK_VSC_TO_VK); - if ( vk ) { - int ch = (MapVirtualKey( vk, MAPVK_VK_TO_CHAR ) & 0x7FFF); - if ( ch ) { - if ( ch >= 'A' && ch <= 'Z' ) { - keymap[scancode] = SDLK_a + ( ch - 'A' ); + vk = MapVirtualKey(i, MAPVK_VSC_TO_VK); + if (vk) { + int ch = (MapVirtualKey(vk, MAPVK_VK_TO_CHAR) & 0x7FFF); + if (ch) { + if (ch >= 'A' && ch <= 'Z') { + keymap[scancode] = SDLK_a + (ch - 'A'); } else { keymap[scancode] = ch; } @@ -157,10 +155,9 @@ WIN_UpdateKeymap(SDL_bool send_event) SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES, send_event); } -void -WIN_QuitKeyboard(_THIS) +void WIN_QuitKeyboard(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; #ifndef SDL_DISABLE_WINDOWS_IME IME_Quit(data); @@ -172,11 +169,10 @@ WIN_QuitKeyboard(_THIS) #endif /* !SDL_DISABLE_WINDOWS_IME */ } -void -WIN_ResetDeadKeys() +void WIN_ResetDeadKeys() { /* - if a deadkey has been typed, but not the next character (which the deadkey might modify), + if a deadkey has been typed, but not the next character (which the deadkey might modify), this tries to undo the effect pressing the deadkey. see: http://archives.miloush.net/michkap/archive/2006/09/10/748775.html */ @@ -202,8 +198,7 @@ WIN_ResetDeadKeys() } } -void -WIN_StartTextInput(_THIS) +void WIN_StartTextInput(_THIS) { #ifndef SDL_DISABLE_WINDOWS_IME SDL_Window *window; @@ -214,7 +209,7 @@ WIN_StartTextInput(_THIS) #ifndef SDL_DISABLE_WINDOWS_IME window = SDL_GetKeyboardFocus(); if (window) { - HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; + HWND hwnd = ((SDL_WindowData *)window->driverdata)->hwnd; SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; SDL_GetWindowSize(window, &videodata->ime_winwidth, &videodata->ime_winheight); IME_Init(videodata, hwnd); @@ -223,8 +218,7 @@ WIN_StartTextInput(_THIS) #endif /* !SDL_DISABLE_WINDOWS_IME */ } -void -WIN_StopTextInput(_THIS) +void WIN_StopTextInput(_THIS) { #ifndef SDL_DISABLE_WINDOWS_IME SDL_Window *window; @@ -235,7 +229,7 @@ WIN_StopTextInput(_THIS) #ifndef SDL_DISABLE_WINDOWS_IME window = SDL_GetKeyboardFocus(); if (window) { - HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; + HWND hwnd = ((SDL_WindowData *)window->driverdata)->hwnd; SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; IME_Init(videodata, hwnd); IME_Disable(videodata, hwnd); @@ -243,8 +237,7 @@ WIN_StopTextInput(_THIS) #endif /* !SDL_DISABLE_WINDOWS_IME */ } -void -WIN_SetTextInputRect(_THIS, const SDL_Rect *rect) +void WIN_SetTextInputRect(_THIS, const SDL_Rect *rect) { SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; HIMC himc = 0; @@ -286,7 +279,6 @@ WIN_SetTextInputRect(_THIS, const SDL_Rect *rect) #endif /* !SDL_DISABLE_WINDOWS_IME */ } - #ifdef SDL_DISABLE_WINDOWS_IME void WIN_ClearComposition(_THIS) @@ -317,58 +309,58 @@ void IME_Present(SDL_VideoData *videodata) #endif #ifdef USE_INIT_GUID #undef DEFINE_GUID -#define DEFINE_GUID(n,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) static const GUID n = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}} -DEFINE_GUID(IID_ITfInputProcessorProfileActivationSink, 0x71C6E74E,0x0F28,0x11D8,0xA8,0x2A,0x00,0x06,0x5B,0x84,0x43,0x5C); -DEFINE_GUID(IID_ITfUIElementSink, 0xEA1EA136,0x19DF,0x11D7,0xA6,0xD2,0x00,0x06,0x5B,0x84,0x43,0x5C); -DEFINE_GUID(GUID_TFCAT_TIP_KEYBOARD, 0x34745C63,0xB2F0,0x4784,0x8B,0x67,0x5E,0x12,0xC8,0x70,0x1A,0x31); -DEFINE_GUID(IID_ITfSource, 0x4EA48A35,0x60AE,0x446F,0x8F,0xD6,0xE6,0xA8,0xD8,0x24,0x59,0xF7); -DEFINE_GUID(IID_ITfUIElementMgr, 0xEA1EA135,0x19DF,0x11D7,0xA6,0xD2,0x00,0x06,0x5B,0x84,0x43,0x5C); -DEFINE_GUID(IID_ITfCandidateListUIElement, 0xEA1EA138,0x19DF,0x11D7,0xA6,0xD2,0x00,0x06,0x5B,0x84,0x43,0x5C); -DEFINE_GUID(IID_ITfReadingInformationUIElement, 0xEA1EA139,0x19DF,0x11D7,0xA6,0xD2,0x00,0x06,0x5B,0x84,0x43,0x5C); -DEFINE_GUID(IID_ITfThreadMgr, 0xAA80E801,0x2021,0x11D2,0x93,0xE0,0x00,0x60,0xB0,0x67,0xB8,0x6E); -DEFINE_GUID(CLSID_TF_ThreadMgr, 0x529A9E6B,0x6587,0x4F23,0xAB,0x9E,0x9C,0x7D,0x68,0x3E,0x3C,0x50); -DEFINE_GUID(IID_ITfThreadMgrEx, 0x3E90ADE3,0x7594,0x4CB0,0xBB,0x58,0x69,0x62,0x8F,0x5F,0x45,0x8C); +#define DEFINE_GUID(n, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) static const GUID n = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } +DEFINE_GUID(IID_ITfInputProcessorProfileActivationSink, 0x71C6E74E, 0x0F28, 0x11D8, 0xA8, 0x2A, 0x00, 0x06, 0x5B, 0x84, 0x43, 0x5C); +DEFINE_GUID(IID_ITfUIElementSink, 0xEA1EA136, 0x19DF, 0x11D7, 0xA6, 0xD2, 0x00, 0x06, 0x5B, 0x84, 0x43, 0x5C); +DEFINE_GUID(GUID_TFCAT_TIP_KEYBOARD, 0x34745C63, 0xB2F0, 0x4784, 0x8B, 0x67, 0x5E, 0x12, 0xC8, 0x70, 0x1A, 0x31); +DEFINE_GUID(IID_ITfSource, 0x4EA48A35, 0x60AE, 0x446F, 0x8F, 0xD6, 0xE6, 0xA8, 0xD8, 0x24, 0x59, 0xF7); +DEFINE_GUID(IID_ITfUIElementMgr, 0xEA1EA135, 0x19DF, 0x11D7, 0xA6, 0xD2, 0x00, 0x06, 0x5B, 0x84, 0x43, 0x5C); +DEFINE_GUID(IID_ITfCandidateListUIElement, 0xEA1EA138, 0x19DF, 0x11D7, 0xA6, 0xD2, 0x00, 0x06, 0x5B, 0x84, 0x43, 0x5C); +DEFINE_GUID(IID_ITfReadingInformationUIElement, 0xEA1EA139, 0x19DF, 0x11D7, 0xA6, 0xD2, 0x00, 0x06, 0x5B, 0x84, 0x43, 0x5C); +DEFINE_GUID(IID_ITfThreadMgr, 0xAA80E801, 0x2021, 0x11D2, 0x93, 0xE0, 0x00, 0x60, 0xB0, 0x67, 0xB8, 0x6E); +DEFINE_GUID(CLSID_TF_ThreadMgr, 0x529A9E6B, 0x6587, 0x4F23, 0xAB, 0x9E, 0x9C, 0x7D, 0x68, 0x3E, 0x3C, 0x50); +DEFINE_GUID(IID_ITfThreadMgrEx, 0x3E90ADE3, 0x7594, 0x4CB0, 0xBB, 0x58, 0x69, 0x62, 0x8F, 0x5F, 0x45, 0x8C); #endif #define LANG_CHT MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL) #define LANG_CHS MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED) -#define MAKEIMEVERSION(major,minor) ((DWORD) (((BYTE)(major) << 24) | ((BYTE)(minor) << 16) )) -#define IMEID_VER(id) ((id) & 0xffff0000) -#define IMEID_LANG(id) ((id) & 0x0000ffff) +#define MAKEIMEVERSION(major, minor) ((DWORD)(((BYTE)(major) << 24) | ((BYTE)(minor) << 16))) +#define IMEID_VER(id) ((id)&0xffff0000) +#define IMEID_LANG(id) ((id)&0x0000ffff) -#define CHT_HKL_DAYI ((HKL)(UINT_PTR)0xE0060404) -#define CHT_HKL_NEW_PHONETIC ((HKL)(UINT_PTR)0xE0080404) -#define CHT_HKL_NEW_CHANG_JIE ((HKL)(UINT_PTR)0xE0090404) -#define CHT_HKL_NEW_QUICK ((HKL)(UINT_PTR)0xE00A0404) -#define CHT_HKL_HK_CANTONESE ((HKL)(UINT_PTR)0xE00B0404) -#define CHT_IMEFILENAME1 "TINTLGNT.IME" -#define CHT_IMEFILENAME2 "CINTLGNT.IME" -#define CHT_IMEFILENAME3 "MSTCIPHA.IME" -#define IMEID_CHT_VER42 (LANG_CHT | MAKEIMEVERSION(4, 2)) -#define IMEID_CHT_VER43 (LANG_CHT | MAKEIMEVERSION(4, 3)) -#define IMEID_CHT_VER44 (LANG_CHT | MAKEIMEVERSION(4, 4)) -#define IMEID_CHT_VER50 (LANG_CHT | MAKEIMEVERSION(5, 0)) -#define IMEID_CHT_VER51 (LANG_CHT | MAKEIMEVERSION(5, 1)) -#define IMEID_CHT_VER52 (LANG_CHT | MAKEIMEVERSION(5, 2)) -#define IMEID_CHT_VER60 (LANG_CHT | MAKEIMEVERSION(6, 0)) -#define IMEID_CHT_VER_VISTA (LANG_CHT | MAKEIMEVERSION(7, 0)) +#define CHT_HKL_DAYI ((HKL)(UINT_PTR)0xE0060404) +#define CHT_HKL_NEW_PHONETIC ((HKL)(UINT_PTR)0xE0080404) +#define CHT_HKL_NEW_CHANG_JIE ((HKL)(UINT_PTR)0xE0090404) +#define CHT_HKL_NEW_QUICK ((HKL)(UINT_PTR)0xE00A0404) +#define CHT_HKL_HK_CANTONESE ((HKL)(UINT_PTR)0xE00B0404) +#define CHT_IMEFILENAME1 "TINTLGNT.IME" +#define CHT_IMEFILENAME2 "CINTLGNT.IME" +#define CHT_IMEFILENAME3 "MSTCIPHA.IME" +#define IMEID_CHT_VER42 (LANG_CHT | MAKEIMEVERSION(4, 2)) +#define IMEID_CHT_VER43 (LANG_CHT | MAKEIMEVERSION(4, 3)) +#define IMEID_CHT_VER44 (LANG_CHT | MAKEIMEVERSION(4, 4)) +#define IMEID_CHT_VER50 (LANG_CHT | MAKEIMEVERSION(5, 0)) +#define IMEID_CHT_VER51 (LANG_CHT | MAKEIMEVERSION(5, 1)) +#define IMEID_CHT_VER52 (LANG_CHT | MAKEIMEVERSION(5, 2)) +#define IMEID_CHT_VER60 (LANG_CHT | MAKEIMEVERSION(6, 0)) +#define IMEID_CHT_VER_VISTA (LANG_CHT | MAKEIMEVERSION(7, 0)) -#define CHS_HKL ((HKL)(UINT_PTR)0xE00E0804) -#define CHS_IMEFILENAME1 "PINTLGNT.IME" -#define CHS_IMEFILENAME2 "MSSCIPYA.IME" -#define IMEID_CHS_VER41 (LANG_CHS | MAKEIMEVERSION(4, 1)) -#define IMEID_CHS_VER42 (LANG_CHS | MAKEIMEVERSION(4, 2)) -#define IMEID_CHS_VER53 (LANG_CHS | MAKEIMEVERSION(5, 3)) +#define CHS_HKL ((HKL)(UINT_PTR)0xE00E0804) +#define CHS_IMEFILENAME1 "PINTLGNT.IME" +#define CHS_IMEFILENAME2 "MSSCIPYA.IME" +#define IMEID_CHS_VER41 (LANG_CHS | MAKEIMEVERSION(4, 1)) +#define IMEID_CHS_VER42 (LANG_CHS | MAKEIMEVERSION(4, 2)) +#define IMEID_CHS_VER53 (LANG_CHS | MAKEIMEVERSION(5, 3)) -#define LANG() LOWORD((videodata->ime_hkl)) -#define PRIMLANG() ((WORD)PRIMARYLANGID(LANG())) -#define SUBLANG() SUBLANGID(LANG()) +#define LANG() LOWORD((videodata->ime_hkl)) +#define PRIMLANG() ((WORD)PRIMARYLANGID(LANG())) +#define SUBLANG() SUBLANGID(LANG()) static void IME_UpdateInputLocale(SDL_VideoData *videodata); static int IME_ShowCandidateList(SDL_VideoData *videodata); static void IME_ClearComposition(SDL_VideoData *videodata); -static void IME_SetWindow(SDL_VideoData* videodata, HWND hwnd); +static void IME_SetWindow(SDL_VideoData *videodata, HWND hwnd); static void IME_SetupAPI(SDL_VideoData *videodata); static DWORD IME_GetId(SDL_VideoData *videodata, UINT uIndex); static void IME_SendEditingEvent(SDL_VideoData *videodata); @@ -379,14 +371,12 @@ static void UILess_ReleaseSinks(SDL_VideoData *videodata); static void UILess_EnableUIUpdates(SDL_VideoData *videodata); static void UILess_DisableUIUpdates(SDL_VideoData *videodata); -static SDL_bool -WIN_ShouldShowNativeUI() +static SDL_bool WIN_ShouldShowNativeUI() { return SDL_GetHintBoolean(SDL_HINT_IME_SHOW_UI, SDL_FALSE); } -static void -IME_Init(SDL_VideoData *videodata, HWND hwnd) +static void IME_Init(SDL_VideoData *videodata, HWND hwnd) { HRESULT hResult = S_OK; @@ -410,10 +400,12 @@ IME_Init(SDL_VideoData *videodata, HWND hwnd) SDL_ClearError(); return; } + /* *INDENT-OFF* */ /* clang-format off */ videodata->ImmLockIMC = (LPINPUTCONTEXT2 (WINAPI *)(HIMC))SDL_LoadFunction(videodata->ime_himm32, "ImmLockIMC"); videodata->ImmUnlockIMC = (BOOL (WINAPI *)(HIMC))SDL_LoadFunction(videodata->ime_himm32, "ImmUnlockIMC"); videodata->ImmLockIMCC = (LPVOID (WINAPI *)(HIMCC))SDL_LoadFunction(videodata->ime_himm32, "ImmLockIMCC"); videodata->ImmUnlockIMCC = (BOOL (WINAPI *)(HIMCC))SDL_LoadFunction(videodata->ime_himm32, "ImmUnlockIMCC"); + /* *INDENT-ON* */ /* clang-format on */ IME_SetWindow(videodata, hwnd); videodata->ime_himc = ImmGetContext(hwnd); @@ -434,8 +426,7 @@ IME_Init(SDL_VideoData *videodata, HWND hwnd) IME_Disable(videodata, hwnd); } -static void -IME_Enable(SDL_VideoData *videodata, HWND hwnd) +static void IME_Enable(SDL_VideoData *videodata, HWND hwnd) { if (!videodata->ime_initialized || !videodata->ime_hwnd_current) { return; @@ -454,8 +445,7 @@ IME_Enable(SDL_VideoData *videodata, HWND hwnd) UILess_EnableUIUpdates(videodata); } -static void -IME_Disable(SDL_VideoData *videodata, HWND hwnd) +static void IME_Disable(SDL_VideoData *videodata, HWND hwnd) { if (!videodata->ime_initialized || !videodata->ime_hwnd_current) { return; @@ -470,8 +460,7 @@ IME_Disable(SDL_VideoData *videodata, HWND hwnd) UILess_DisableUIUpdates(videodata); } -static void -IME_Quit(SDL_VideoData *videodata) +static void IME_Quit(SDL_VideoData *videodata) { if (!videodata->ime_initialized) { return; @@ -500,8 +489,7 @@ IME_Quit(SDL_VideoData *videodata) videodata->ime_initialized = SDL_FALSE; } -static void -IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd) +static void IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd) { DWORD id = 0; HIMC himc = 0; @@ -517,7 +505,7 @@ IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd) } videodata->ime_readingstring[0] = 0; - + id = IME_GetId(videodata, 0); if (!id) { return; @@ -542,8 +530,7 @@ IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd) LPINPUTCONTEXT2 lpimc = videodata->ImmLockIMC(himc); LPBYTE p = 0; s = 0; - switch (id) - { + switch (id) { case IMEID_CHT_VER42: case IMEID_CHT_VER43: case IMEID_CHT_VER44: @@ -552,7 +539,7 @@ IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd) break; } - len = *(DWORD *)(p + 7*4 + 32*4); + len = *(DWORD *)(p + 7 * 4 + 32 * 4); s = (WCHAR *)(p + 56); break; case IMEID_CHT_VER51: @@ -563,34 +550,33 @@ IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd) break; } - p = *(LPBYTE *)((LPBYTE)p + 1*4 + 5*4); + p = *(LPBYTE *)((LPBYTE)p + 1 * 4 + 5 * 4); if (!p) { break; } - len = *(DWORD *)(p + 1*4 + (16*2+2*4) + 5*4 + 16*2); - s = (WCHAR *)(p + 1*4 + (16*2+2*4) + 5*4); + len = *(DWORD *)(p + 1 * 4 + (16 * 2 + 2 * 4) + 5 * 4 + 16 * 2); + s = (WCHAR *)(p + 1 * 4 + (16 * 2 + 2 * 4) + 5 * 4); break; case IMEID_CHS_VER41: - { - int offset = (IME_GetId(videodata, 1) >= 0x00000002) ? 8 : 7; - p = *(LPBYTE *)((LPBYTE)videodata->ImmLockIMCC(lpimc->hPrivate) + offset * 4); - if (!p) { - break; - } - - len = *(DWORD *)(p + 7*4 + 16*2*4); - s = (WCHAR *)(p + 6*4 + 16*2*1); - } - break; - case IMEID_CHS_VER42: - p = *(LPBYTE *)((LPBYTE)videodata->ImmLockIMCC(lpimc->hPrivate) + 1*4 + 1*4 + 6*4); + { + int offset = (IME_GetId(videodata, 1) >= 0x00000002) ? 8 : 7; + p = *(LPBYTE *)((LPBYTE)videodata->ImmLockIMCC(lpimc->hPrivate) + offset * 4); if (!p) { break; } - len = *(DWORD *)(p + 1*4 + (16*2+2*4) + 5*4 + 16*2); - s = (WCHAR *)(p + 1*4 + (16*2+2*4) + 5*4); + len = *(DWORD *)(p + 7 * 4 + 16 * 2 * 4); + s = (WCHAR *)(p + 6 * 4 + 16 * 2 * 1); + } break; + case IMEID_CHS_VER42: + p = *(LPBYTE *)((LPBYTE)videodata->ImmLockIMCC(lpimc->hPrivate) + 1 * 4 + 1 * 4 + 6 * 4); + if (!p) { + break; + } + + len = *(DWORD *)(p + 1 * 4 + (16 * 2 + 2 * 4) + 5 * 4 + 16 * 2); + s = (WCHAR *)(p + 1 * 4 + (16 * 2 + 2 * 4) + 5 * 4); break; } if (s) { @@ -605,8 +591,7 @@ IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd) IME_SendEditingEvent(videodata); } -static void -IME_InputLangChanged(SDL_VideoData *videodata) +static void IME_InputLangChanged(SDL_VideoData *videodata) { UINT lang = PRIMLANG(); IME_UpdateInputLocale(videodata); @@ -620,11 +605,10 @@ IME_InputLangChanged(SDL_VideoData *videodata) } } -static DWORD -IME_GetId(SDL_VideoData *videodata, UINT uIndex) +static DWORD IME_GetId(SDL_VideoData *videodata, UINT uIndex) { static HKL hklprev = 0; - static DWORD dwRet[2] = {0}; + static DWORD dwRet[2] = { 0 }; DWORD dwVerSize = 0; DWORD dwVerHandle = 0; LPVOID lpVerBuffer = 0; @@ -648,11 +632,7 @@ IME_GetId(SDL_VideoData *videodata, UINT uIndex) dwRet[1] = 0; return dwRet[0]; } - if (hkl != CHT_HKL_NEW_PHONETIC - && hkl != CHT_HKL_NEW_CHANG_JIE - && hkl != CHT_HKL_NEW_QUICK - && hkl != CHT_HKL_HK_CANTONESE - && hkl != CHS_HKL) { + if (hkl != CHT_HKL_NEW_PHONETIC && hkl != CHT_HKL_NEW_CHANG_JIE && hkl != CHT_HKL_NEW_QUICK && hkl != CHT_HKL_HK_CANTONESE && hkl != CHS_HKL) { dwRet[0] = dwRet[1] = 0; return dwRet[0]; } @@ -661,45 +641,38 @@ IME_GetId(SDL_VideoData *videodata, UINT uIndex) return dwRet[0]; } if (!videodata->GetReadingString) { - #define LCID_INVARIANT MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) - if (CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME1, -1) != 2 - && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME2, -1) != 2 - && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME3, -1) != 2 - && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHS_IMEFILENAME1, -1) != 2 - && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHS_IMEFILENAME2, -1) != 2) { +#define LCID_INVARIANT MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) + if (CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME1, -1) != 2 && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME2, -1) != 2 && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME3, -1) != 2 && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHS_IMEFILENAME1, -1) != 2 && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHS_IMEFILENAME2, -1) != 2) { dwRet[0] = dwRet[1] = 0; return dwRet[0]; } - #undef LCID_INVARIANT +#undef LCID_INVARIANT dwVerSize = GetFileVersionInfoSizeA(szTemp, &dwVerHandle); if (dwVerSize) { lpVerBuffer = SDL_malloc(dwVerSize); if (lpVerBuffer) { if (GetFileVersionInfoA(szTemp, dwVerHandle, dwVerSize, lpVerBuffer)) { if (VerQueryValueA(lpVerBuffer, "\\", &lpVerData, &cbVerData)) { - #define pVerFixedInfo ((VS_FIXEDFILEINFO FAR*)lpVerData) +#define pVerFixedInfo ((VS_FIXEDFILEINFO FAR *)lpVerData) DWORD dwVer = pVerFixedInfo->dwFileVersionMS; dwVer = (dwVer & 0x00ff0000) << 8 | (dwVer & 0x000000ff) << 16; if ((videodata->GetReadingString) || - ((dwLang == LANG_CHT) && ( - dwVer == MAKEIMEVERSION(4, 2) || - dwVer == MAKEIMEVERSION(4, 3) || - dwVer == MAKEIMEVERSION(4, 4) || - dwVer == MAKEIMEVERSION(5, 0) || - dwVer == MAKEIMEVERSION(5, 1) || - dwVer == MAKEIMEVERSION(5, 2) || - dwVer == MAKEIMEVERSION(6, 0))) - || - ((dwLang == LANG_CHS) && ( - dwVer == MAKEIMEVERSION(4, 1) || - dwVer == MAKEIMEVERSION(4, 2) || - dwVer == MAKEIMEVERSION(5, 3)))) { + ((dwLang == LANG_CHT) && (dwVer == MAKEIMEVERSION(4, 2) || + dwVer == MAKEIMEVERSION(4, 3) || + dwVer == MAKEIMEVERSION(4, 4) || + dwVer == MAKEIMEVERSION(5, 0) || + dwVer == MAKEIMEVERSION(5, 1) || + dwVer == MAKEIMEVERSION(5, 2) || + dwVer == MAKEIMEVERSION(6, 0))) || + ((dwLang == LANG_CHS) && (dwVer == MAKEIMEVERSION(4, 1) || + dwVer == MAKEIMEVERSION(4, 2) || + dwVer == MAKEIMEVERSION(5, 3)))) { dwRet[0] = dwVer | dwLang; dwRet[1] = pVerFixedInfo->dwFileVersionLS; SDL_free(lpVerBuffer); return dwRet[0]; } - #undef pVerFixedInfo +#undef pVerFixedInfo } } } @@ -710,11 +683,10 @@ IME_GetId(SDL_VideoData *videodata, UINT uIndex) return dwRet[0]; } -static void -IME_SetupAPI(SDL_VideoData *videodata) +static void IME_SetupAPI(SDL_VideoData *videodata) { char ime_file[MAX_PATH + 1]; - void* hime = 0; + void *hime = 0; HKL hkl = 0; videodata->GetReadingString = 0; videodata->ShowReadingWindow = 0; @@ -732,10 +704,12 @@ IME_SetupAPI(SDL_VideoData *videodata) return; } + /* *INDENT-OFF* */ /* clang-format off */ videodata->GetReadingString = (UINT (WINAPI *)(HIMC, UINT, LPWSTR, PINT, BOOL*, PUINT)) SDL_LoadFunction(hime, "GetReadingString"); videodata->ShowReadingWindow = (BOOL (WINAPI *)(HIMC, BOOL)) SDL_LoadFunction(hime, "ShowReadingWindow"); + /* *INDENT-ON* */ /* clang-format on */ if (videodata->ShowReadingWindow) { HIMC himc = ImmGetContext(videodata->ime_hwnd_current); @@ -746,8 +720,7 @@ IME_SetupAPI(SDL_VideoData *videodata) } } -static void -IME_SetWindow(SDL_VideoData* videodata, HWND hwnd) +static void IME_SetWindow(SDL_VideoData *videodata, HWND hwnd) { videodata->ime_hwnd_current = hwnd; if (videodata->ime_threadmgr) { @@ -760,8 +733,7 @@ IME_SetWindow(SDL_VideoData* videodata, HWND hwnd) } } -static void -IME_UpdateInputLocale(SDL_VideoData *videodata) +static void IME_UpdateInputLocale(SDL_VideoData *videodata) { HKL hklnext = GetKeyboardLayout(0); @@ -773,8 +745,7 @@ IME_UpdateInputLocale(SDL_VideoData *videodata) videodata->ime_candvertical = (PRIMLANG() == LANG_KOREAN || LANG() == LANG_CHS) ? SDL_FALSE : SDL_TRUE; } -static void -IME_ClearComposition(SDL_VideoData *videodata) +static void IME_ClearComposition(SDL_VideoData *videodata) { HIMC himc = 0; if (!videodata->ime_initialized) { @@ -796,8 +767,7 @@ IME_ClearComposition(SDL_VideoData *videodata) SDL_SendEditingText("", 0, 0); } -static SDL_bool -IME_IsTextInputShown(SDL_VideoData* videodata) +static SDL_bool IME_IsTextInputShown(SDL_VideoData *videodata) { if (!videodata->ime_initialized || !videodata->ime_available || !videodata->ime_enabled) { return SDL_FALSE; @@ -806,8 +776,7 @@ IME_IsTextInputShown(SDL_VideoData* videodata) return videodata->ime_uicontext != 0 ? SDL_TRUE : SDL_FALSE; } -static void -IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD string) +static void IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD string) { LONG length; DWORD dwLang = ((DWORD_PTR)videodata->ime_hkl & 0xffff); @@ -818,7 +787,7 @@ IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD string) SDL_free(videodata->ime_composition); } - videodata->ime_composition = (WCHAR*)SDL_malloc(length + sizeof(WCHAR)); + videodata->ime_composition = (WCHAR *)SDL_malloc(length + sizeof(WCHAR)); videodata->ime_composition_length = length; } @@ -826,8 +795,7 @@ IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD string) himc, string, videodata->ime_composition, - videodata->ime_composition_length - ); + videodata->ime_composition_length); if (length < 0) { length = 0; @@ -858,7 +826,7 @@ IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD string) length = ImmGetCompositionStringW(himc, GCS_COMPATTR, NULL, 0); if (length > 0) { - Uint8* attributes = (Uint8*)SDL_malloc(length + sizeof(WCHAR)); + Uint8 *attributes = (Uint8 *)SDL_malloc(length + sizeof(WCHAR)); ImmGetCompositionString(himc, GCS_COMPATTR, attributes, length); for (start = 0; start < length; ++start) { @@ -885,8 +853,7 @@ IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD string) } } -static void -IME_SendInputEvent(SDL_VideoData *videodata) +static void IME_SendInputEvent(SDL_VideoData *videodata) { char *s = 0; s = WIN_StringToUTF8W(videodata->ime_composition); @@ -898,8 +865,7 @@ IME_SendInputEvent(SDL_VideoData *videodata) videodata->ime_cursor = 0; } -static void -IME_SendEditingEvent(SDL_VideoData *videodata) +static void IME_SendEditingEvent(SDL_VideoData *videodata) { char *s = NULL; WCHAR *buffer = NULL; @@ -908,14 +874,14 @@ IME_SendEditingEvent(SDL_VideoData *videodata) size_t len = SDL_min(SDL_wcslen(videodata->ime_composition), (size_t)videodata->ime_cursor); size += sizeof(videodata->ime_readingstring); - buffer = (WCHAR*)SDL_malloc(size + sizeof(WCHAR)); + buffer = (WCHAR *)SDL_malloc(size + sizeof(WCHAR)); buffer[0] = 0; SDL_wcslcpy(buffer, videodata->ime_composition, len + 1); SDL_wcslcat(buffer, videodata->ime_readingstring, size); SDL_wcslcat(buffer, &videodata->ime_composition[len], size); } else { - buffer = (WCHAR*)SDL_malloc(size + sizeof(WCHAR)); + buffer = (WCHAR *)SDL_malloc(size + sizeof(WCHAR)); buffer[0] = 0; SDL_wcslcpy(buffer, videodata->ime_composition, size); } @@ -926,8 +892,7 @@ IME_SendEditingEvent(SDL_VideoData *videodata) SDL_free(buffer); } -static void -IME_AddCandidate(SDL_VideoData *videodata, UINT i, LPCWSTR candidate) +static void IME_AddCandidate(SDL_VideoData *videodata, UINT i, LPCWSTR candidate) { LPWSTR dst = &videodata->ime_candidates[i * MAX_CANDLENGTH]; LPWSTR end = &dst[MAX_CANDLENGTH - 1]; @@ -944,8 +909,7 @@ IME_AddCandidate(SDL_VideoData *videodata, UINT i, LPCWSTR candidate) *dst = (WCHAR)'\0'; } -static void -IME_GetCandidateList(HWND hwnd, SDL_VideoData *videodata) +static void IME_GetCandidateList(HWND hwnd, SDL_VideoData *videodata) { HIMC himc; DWORD size; @@ -996,9 +960,8 @@ IME_GetCandidateList(HWND hwnd, SDL_VideoData *videodata) IME_AddCandidate(videodata, j, candidate); } // TODO: why was this necessary? check ime_candvertical instead? PRIMLANG() never equals LANG_CHT ! - //if (PRIMLANG() == LANG_KOREAN || (PRIMLANG() == LANG_CHT && !IME_GetId(videodata, 0))) + // if (PRIMLANG() == LANG_KOREAN || (PRIMLANG() == LANG_CHT && !IME_GetId(videodata, 0))) // videodata->ime_candsel = -1; - } SDL_free(cand_list); } @@ -1006,8 +969,7 @@ IME_GetCandidateList(HWND hwnd, SDL_VideoData *videodata) ImmReleaseContext(hwnd, himc); } -static int -IME_ShowCandidateList(SDL_VideoData *videodata) +static int IME_ShowCandidateList(SDL_VideoData *videodata) { void *candidates; @@ -1030,8 +992,7 @@ IME_ShowCandidateList(SDL_VideoData *videodata) return 0; } -static void -IME_HideCandidateList(SDL_VideoData *videodata) +static void IME_HideCandidateList(SDL_VideoData *videodata) { videodata->ime_dirty = SDL_FALSE; videodata->ime_candlist = SDL_FALSE; @@ -1064,7 +1025,7 @@ IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoD *lParam = 0; } break; - case WM_IME_STARTCOMPOSITION: + case WM_IME_STARTCOMPOSITION: videodata->ime_suppress_endcomposition_event = SDL_FALSE; trap = SDL_TRUE; break; @@ -1119,33 +1080,31 @@ IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoD IME_HideCandidateList(videodata); break; case IMN_PRIVATE: - { - DWORD dwId = IME_GetId(videodata, 0); - IME_GetReadingString(videodata, hwnd); - switch (dwId) - { - case IMEID_CHT_VER42: - case IMEID_CHT_VER43: - case IMEID_CHT_VER44: - case IMEID_CHS_VER41: - case IMEID_CHS_VER42: - if (*lParam == 1 || *lParam == 2) { - trap = SDL_TRUE; - } - - break; - case IMEID_CHT_VER50: - case IMEID_CHT_VER51: - case IMEID_CHT_VER52: - case IMEID_CHT_VER60: - case IMEID_CHS_VER53: - if (*lParam == 16 || *lParam == 17 || *lParam == 26 || *lParam == 27 || *lParam == 28) { - trap = SDL_TRUE; - } - break; + { + DWORD dwId = IME_GetId(videodata, 0); + IME_GetReadingString(videodata, hwnd); + switch (dwId) { + case IMEID_CHT_VER42: + case IMEID_CHT_VER43: + case IMEID_CHT_VER44: + case IMEID_CHS_VER41: + case IMEID_CHS_VER42: + if (*lParam == 1 || *lParam == 2) { + trap = SDL_TRUE; } + + break; + case IMEID_CHT_VER50: + case IMEID_CHT_VER51: + case IMEID_CHT_VER52: + case IMEID_CHT_VER60: + case IMEID_CHS_VER53: + if (*lParam == 16 || *lParam == 17 || *lParam == 26 || *lParam == 27 || *lParam == 28) { + trap = SDL_TRUE; + } + break; } - break; + } break; default: trap = SDL_TRUE; break; @@ -1155,8 +1114,7 @@ IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoD return trap; } -static void -IME_CloseCandidateList(SDL_VideoData *videodata) +static void IME_CloseCandidateList(SDL_VideoData *videodata) { IME_HideCandidateList(videodata); videodata->ime_candcount = 0; @@ -1164,8 +1122,7 @@ IME_CloseCandidateList(SDL_VideoData *videodata) videodata->ime_candidates = NULL; } -static void -UILess_GetCandidateList(SDL_VideoData *videodata, ITfCandidateListUIElement *pcandlist) +static void UILess_GetCandidateList(SDL_VideoData *videodata, ITfCandidateListUIElement *pcandlist) { UINT selection = 0; UINT count = 0; @@ -1212,16 +1169,18 @@ UILess_GetCandidateList(SDL_VideoData *videodata, ITfCandidateListUIElement *pca } } // TODO: why was this necessary? check ime_candvertical instead? - //if (PRIMLANG() == LANG_KOREAN) + // if (PRIMLANG() == LANG_KOREAN) // videodata->ime_candsel = -1; } -STDMETHODIMP_(ULONG) TSFSink_AddRef(TSFSink *sink) +STDMETHODIMP_(ULONG) +TSFSink_AddRef(TSFSink *sink) { return ++sink->refcount; } -STDMETHODIMP_(ULONG) TSFSink_Release(TSFSink *sink) +STDMETHODIMP_(ULONG) +TSFSink_Release(TSFSink *sink) { --sink->refcount; if (sink->refcount == 0) { @@ -1390,8 +1349,7 @@ static void *vtIPPASink[] = { (void *)(IPPASink_OnActivated) }; -static void -UILess_EnableUIUpdates(SDL_VideoData *videodata) +static void UILess_EnableUIUpdates(SDL_VideoData *videodata) { ITfSource *source = 0; if (!videodata->ime_threadmgrex || videodata->ime_uielemsinkcookie != TF_INVALID_COOKIE) { @@ -1404,8 +1362,7 @@ UILess_EnableUIUpdates(SDL_VideoData *videodata) } } -static void -UILess_DisableUIUpdates(SDL_VideoData *videodata) +static void UILess_DisableUIUpdates(SDL_VideoData *videodata) { ITfSource *source = 0; if (!videodata->ime_threadmgrex || videodata->ime_uielemsinkcookie == TF_INVALID_COOKIE) { @@ -1419,8 +1376,7 @@ UILess_DisableUIUpdates(SDL_VideoData *videodata) } } -static SDL_bool -UILess_SetupSinks(SDL_VideoData *videodata) +static SDL_bool UILess_SetupSinks(SDL_VideoData *videodata) { TfClientId clientid = 0; SDL_bool result = SDL_FALSE; @@ -1455,16 +1411,15 @@ UILess_SetupSinks(SDL_VideoData *videodata) return result; } -#define SAFE_RELEASE(p) \ -{ \ - if (p) { \ - (p)->lpVtbl->Release((p)); \ - (p) = 0; \ - } \ -} +#define SAFE_RELEASE(p) \ + { \ + if (p) { \ + (p)->lpVtbl->Release((p)); \ + (p) = 0; \ + } \ + } -static void -UILess_ReleaseSinks(SDL_VideoData *videodata) +static void UILess_ReleaseSinks(SDL_VideoData *videodata) { ITfSource *source = 0; if (videodata->ime_threadmgrex && SUCCEEDED(videodata->ime_threadmgrex->lpVtbl->QueryInterface(videodata->ime_threadmgrex, &IID_ITfSource, (LPVOID *)&source))) { @@ -1480,8 +1435,7 @@ UILess_ReleaseSinks(SDL_VideoData *videodata) } } -static void * -StartDrawToBitmap(HDC hdc, HBITMAP *hhbm, int width, int height) +static void *StartDrawToBitmap(HDC hdc, HBITMAP *hhbm, int width, int height) { BITMAPINFO info; BITMAPINFOHEADER *infoHeader = &info.bmiHeader; @@ -1502,8 +1456,7 @@ StartDrawToBitmap(HDC hdc, HBITMAP *hhbm, int width, int height) return bits; } -static void -StopDrawToBitmap(HDC hdc, HBITMAP *hhbm) +static void StopDrawToBitmap(HDC hdc, HBITMAP *hhbm) { if (hhbm && *hhbm) { DeleteObject(*hhbm); @@ -1512,8 +1465,7 @@ StopDrawToBitmap(HDC hdc, HBITMAP *hhbm) } /* This draws only within the specified area and fills the entire region. */ -static void -DrawRect(HDC hdc, int left, int top, int right, int bottom, int pensize) +static void DrawRect(HDC hdc, int left, int top, int right, int bottom, int pensize) { /* The case of no pen (PenSize = 0) is automatically taken care of. */ const int penadjust = (int)SDL_floor(pensize / 2.0f - 0.5f); @@ -1524,19 +1476,18 @@ DrawRect(HDC hdc, int left, int top, int right, int bottom, int pensize) Rectangle(hdc, left, top, right, bottom); } -static void -IME_DestroyTextures(SDL_VideoData *videodata) +static void IME_DestroyTextures(SDL_VideoData *videodata) { } -#define SDL_swap(a,b) { \ - int c = (a); \ - (a) = (b); \ - (b) = c; \ +#define SDL_swap(a, b) \ + { \ + int c = (a); \ + (a) = (b); \ + (b) = c; \ } -static void -IME_PositionCandidateList(SDL_VideoData *videodata, SIZE size) +static void IME_PositionCandidateList(SDL_VideoData *videodata, SIZE size) { int left, top, right, bottom; SDL_bool ok = SDL_FALSE; @@ -1607,13 +1558,12 @@ IME_PositionCandidateList(SDL_VideoData *videodata, SIZE size) videodata->ime_candlistrect.h = bottom - top; } -static void -IME_RenderCandidateList(SDL_VideoData *videodata, HDC hdc) +static void IME_RenderCandidateList(SDL_VideoData *videodata, HDC hdc) { int i, j; - SIZE size = {0}; + SIZE size = { 0 }; SIZE candsizes[MAX_CANDLIST]; - SIZE maxcandsize = {0}; + SIZE maxcandsize = { 0 }; HBITMAP hbm = NULL; int candcount = SDL_min(SDL_min(MAX_CANDLIST, videodata->ime_candcount), videodata->ime_candpgsize); SDL_bool vertical = videodata->ime_candvertical; @@ -1655,7 +1605,6 @@ IME_RenderCandidateList(SDL_VideoData *videodata, HDC hdc) GetTextExtentPoint32W(hdc, s, (int)SDL_wcslen(s), &candsizes[i]); maxcandsize.cx = SDL_max(maxcandsize.cx, candsizes[i].cx); maxcandsize.cy = SDL_max(maxcandsize.cy, candsizes[i].cy); - } if (vertical) { size.cx = @@ -1664,16 +1613,14 @@ IME_RenderCandidateList(SDL_VideoData *videodata, HDC hdc) (candmargin * 2) + (candborder * 2) + (candpadding * 2) + - (maxcandsize.cx) - ; + (maxcandsize.cx); size.cy = (listborder * 2) + (listpadding * 2) + ((candcount + 1) * candmargin) + (candcount * candborder * 2) + (candcount * candpadding * 2) + - (candcount * maxcandsize.cy) - ; + (candcount * maxcandsize.cy); } else { size.cx = (listborder * 2) + @@ -1693,8 +1640,7 @@ IME_RenderCandidateList(SDL_VideoData *videodata, HDC hdc) (candmargin * 2) + (candborder * 2) + (candpadding * 2) + - (maxcandsize.cy) - ; + (maxcandsize.cy); } StartDrawToBitmap(hdc, &hbm, size.cx, size.cy); @@ -1755,8 +1701,7 @@ IME_RenderCandidateList(SDL_VideoData *videodata, HDC hdc) IME_PositionCandidateList(videodata, size); } -static void -IME_Render(SDL_VideoData *videodata) +static void IME_Render(SDL_VideoData *videodata) { HDC hdc = CreateCompatibleDC(NULL); @@ -1780,7 +1725,7 @@ void IME_Present(SDL_VideoData *videodata) SDL_bool WIN_IsTextInputShown(_THIS) { - SDL_VideoData* videodata = (SDL_VideoData*)_this->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; return IME_IsTextInputShown(videodata); } diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c index bfbf3c3bb..09528f619 100644 --- a/src/video/windows/SDL_windowsmessagebox.c +++ b/src/video/windows/SDL_windowsmessagebox.c @@ -34,7 +34,7 @@ #include "SDL_windowsvideo.h" #ifndef SS_EDITCONTROL -#define SS_EDITCONTROL 0x2000 +#define SS_EDITCONTROL 0x2000 #endif #ifndef IDOK @@ -46,11 +46,11 @@ #endif /* Custom dialog return codes */ -#define IDCLOSED 20 -#define IDINVALPTRINIT 50 -#define IDINVALPTRCOMMAND 51 +#define IDCLOSED 20 +#define IDINVALPTRINIT 50 +#define IDINVALPTRCOMMAND 51 #define IDINVALPTRSETFOCUS 52 -#define IDINVALPTRDLGITEM 53 +#define IDINVALPTRDLGITEM 53 /* First button ID */ #define IDBUTTONINDEX0 100 @@ -64,7 +64,6 @@ */ #define MAX_BUTTONS (0xffff - 100) - /* Display a Windows message box */ typedef HRESULT(CALLBACK *PFTASKDIALOGCALLBACK)(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LONG_PTR lpRefData); @@ -90,42 +89,42 @@ enum _TASKDIALOG_FLAGS //#if (NTDDI_VERSION >= NTDDI_WIN8) TDF_NO_SET_FOREGROUND = 0x00010000, // Don't call SetForegroundWindow() when activating the dialog //#endif // (NTDDI_VERSION >= NTDDI_WIN8) - TDF_SIZE_TO_CONTENT = 0x01000000 // used by ShellMessageBox to emulate MessageBox sizing behavior + TDF_SIZE_TO_CONTENT = 0x01000000 // used by ShellMessageBox to emulate MessageBox sizing behavior }; -typedef int TASKDIALOG_FLAGS; // Note: _TASKDIALOG_FLAGS is an int +typedef int TASKDIALOG_FLAGS; // Note: _TASKDIALOG_FLAGS is an int typedef enum _TASKDIALOG_MESSAGES { TDM_NAVIGATE_PAGE = WM_USER + 101, - TDM_CLICK_BUTTON = WM_USER + 102, // wParam = Button ID - TDM_SET_MARQUEE_PROGRESS_BAR = WM_USER + 103, // wParam = 0 (nonMarque) wParam != 0 (Marquee) - TDM_SET_PROGRESS_BAR_STATE = WM_USER + 104, // wParam = new progress state - TDM_SET_PROGRESS_BAR_RANGE = WM_USER + 105, // lParam = MAKELPARAM(nMinRange, nMaxRange) - TDM_SET_PROGRESS_BAR_POS = WM_USER + 106, // wParam = new position - TDM_SET_PROGRESS_BAR_MARQUEE = WM_USER + 107, // wParam = 0 (stop marquee), wParam != 0 (start marquee), lparam = speed (milliseconds between repaints) - TDM_SET_ELEMENT_TEXT = WM_USER + 108, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR) - TDM_CLICK_RADIO_BUTTON = WM_USER + 110, // wParam = Radio Button ID - TDM_ENABLE_BUTTON = WM_USER + 111, // lParam = 0 (disable), lParam != 0 (enable), wParam = Button ID - TDM_ENABLE_RADIO_BUTTON = WM_USER + 112, // lParam = 0 (disable), lParam != 0 (enable), wParam = Radio Button ID - TDM_CLICK_VERIFICATION = WM_USER + 113, // wParam = 0 (unchecked), 1 (checked), lParam = 1 (set key focus) - TDM_UPDATE_ELEMENT_TEXT = WM_USER + 114, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR) + TDM_CLICK_BUTTON = WM_USER + 102, // wParam = Button ID + TDM_SET_MARQUEE_PROGRESS_BAR = WM_USER + 103, // wParam = 0 (nonMarque) wParam != 0 (Marquee) + TDM_SET_PROGRESS_BAR_STATE = WM_USER + 104, // wParam = new progress state + TDM_SET_PROGRESS_BAR_RANGE = WM_USER + 105, // lParam = MAKELPARAM(nMinRange, nMaxRange) + TDM_SET_PROGRESS_BAR_POS = WM_USER + 106, // wParam = new position + TDM_SET_PROGRESS_BAR_MARQUEE = WM_USER + 107, // wParam = 0 (stop marquee), wParam != 0 (start marquee), lparam = speed (milliseconds between repaints) + TDM_SET_ELEMENT_TEXT = WM_USER + 108, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR) + TDM_CLICK_RADIO_BUTTON = WM_USER + 110, // wParam = Radio Button ID + TDM_ENABLE_BUTTON = WM_USER + 111, // lParam = 0 (disable), lParam != 0 (enable), wParam = Button ID + TDM_ENABLE_RADIO_BUTTON = WM_USER + 112, // lParam = 0 (disable), lParam != 0 (enable), wParam = Radio Button ID + TDM_CLICK_VERIFICATION = WM_USER + 113, // wParam = 0 (unchecked), 1 (checked), lParam = 1 (set key focus) + TDM_UPDATE_ELEMENT_TEXT = WM_USER + 114, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR) TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = WM_USER + 115, // wParam = Button ID, lParam = 0 (elevation not required), lParam != 0 (elevation required) - TDM_UPDATE_ICON = WM_USER + 116 // wParam = icon element (TASKDIALOG_ICON_ELEMENTS), lParam = new icon (hIcon if TDF_USE_HICON_* was set, PCWSTR otherwise) + TDM_UPDATE_ICON = WM_USER + 116 // wParam = icon element (TASKDIALOG_ICON_ELEMENTS), lParam = new icon (hIcon if TDF_USE_HICON_* was set, PCWSTR otherwise) } TASKDIALOG_MESSAGES; typedef enum _TASKDIALOG_NOTIFICATIONS { TDN_CREATED = 0, TDN_NAVIGATED = 1, - TDN_BUTTON_CLICKED = 2, // wParam = Button ID - TDN_HYPERLINK_CLICKED = 3, // lParam = (LPCWSTR)pszHREF - TDN_TIMER = 4, // wParam = Milliseconds since dialog created or timer reset + TDN_BUTTON_CLICKED = 2, // wParam = Button ID + TDN_HYPERLINK_CLICKED = 3, // lParam = (LPCWSTR)pszHREF + TDN_TIMER = 4, // wParam = Milliseconds since dialog created or timer reset TDN_DESTROYED = 5, - TDN_RADIO_BUTTON_CLICKED = 6, // wParam = Radio Button ID + TDN_RADIO_BUTTON_CLICKED = 6, // wParam = Radio Button ID TDN_DIALOG_CONSTRUCTED = 7, - TDN_VERIFICATION_CLICKED = 8, // wParam = 1 if checkbox checked, 0 if not, lParam is unused and always 0 + TDN_VERIFICATION_CLICKED = 8, // wParam = 1 if checkbox checked, 0 if not, lParam is unused and always 0 TDN_HELP = 9, - TDN_EXPANDO_BUTTON_CLICKED = 10 // wParam = 0 (dialog is now collapsed), wParam != 0 (dialog is now expanded) + TDN_EXPANDO_BUTTON_CLICKED = 10 // wParam = 0 (dialog is now collapsed), wParam != 0 (dialog is now expanded) } TASKDIALOG_NOTIFICATIONS; typedef enum _TASKDIALOG_ELEMENTS @@ -142,64 +141,64 @@ typedef enum _TASKDIALOG_ICON_ELEMENTS TDIE_ICON_FOOTER } TASKDIALOG_ICON_ELEMENTS; -#define TD_WARNING_ICON MAKEINTRESOURCEW(-1) -#define TD_ERROR_ICON MAKEINTRESOURCEW(-2) -#define TD_INFORMATION_ICON MAKEINTRESOURCEW(-3) -#define TD_SHIELD_ICON MAKEINTRESOURCEW(-4) +#define TD_WARNING_ICON MAKEINTRESOURCEW(-1) +#define TD_ERROR_ICON MAKEINTRESOURCEW(-2) +#define TD_INFORMATION_ICON MAKEINTRESOURCEW(-3) +#define TD_SHIELD_ICON MAKEINTRESOURCEW(-4) enum _TASKDIALOG_COMMON_BUTTON_FLAGS { - TDCBF_OK_BUTTON = 0x0001, // selected control return value IDOK - TDCBF_YES_BUTTON = 0x0002, // selected control return value IDYES - TDCBF_NO_BUTTON = 0x0004, // selected control return value IDNO + TDCBF_OK_BUTTON = 0x0001, // selected control return value IDOK + TDCBF_YES_BUTTON = 0x0002, // selected control return value IDYES + TDCBF_NO_BUTTON = 0x0004, // selected control return value IDNO TDCBF_CANCEL_BUTTON = 0x0008, // selected control return value IDCANCEL - TDCBF_RETRY_BUTTON = 0x0010, // selected control return value IDRETRY - TDCBF_CLOSE_BUTTON = 0x0020 // selected control return value IDCLOSE + TDCBF_RETRY_BUTTON = 0x0010, // selected control return value IDRETRY + TDCBF_CLOSE_BUTTON = 0x0020 // selected control return value IDCLOSE }; -typedef int TASKDIALOG_COMMON_BUTTON_FLAGS; // Note: _TASKDIALOG_COMMON_BUTTON_FLAGS is an int +typedef int TASKDIALOG_COMMON_BUTTON_FLAGS; // Note: _TASKDIALOG_COMMON_BUTTON_FLAGS is an int #pragma pack(push, 1) typedef struct _TASKDIALOG_BUTTON { - int nButtonID; - PCWSTR pszButtonText; + int nButtonID; + PCWSTR pszButtonText; } TASKDIALOG_BUTTON; typedef struct _TASKDIALOGCONFIG { - UINT cbSize; - HWND hwndParent; // incorrectly named, this is the owner window, not a parent. - HINSTANCE hInstance; // used for MAKEINTRESOURCE() strings - TASKDIALOG_FLAGS dwFlags; // TASKDIALOG_FLAGS (TDF_XXX) flags - TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons; // TASKDIALOG_COMMON_BUTTON (TDCBF_XXX) flags - PCWSTR pszWindowTitle; // string or MAKEINTRESOURCE() + UINT cbSize; + HWND hwndParent; // incorrectly named, this is the owner window, not a parent. + HINSTANCE hInstance; // used for MAKEINTRESOURCE() strings + TASKDIALOG_FLAGS dwFlags; // TASKDIALOG_FLAGS (TDF_XXX) flags + TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons; // TASKDIALOG_COMMON_BUTTON (TDCBF_XXX) flags + PCWSTR pszWindowTitle; // string or MAKEINTRESOURCE() union { - HICON hMainIcon; - PCWSTR pszMainIcon; + HICON hMainIcon; + PCWSTR pszMainIcon; } /*DUMMYUNIONNAME*/; - PCWSTR pszMainInstruction; - PCWSTR pszContent; - UINT cButtons; - const TASKDIALOG_BUTTON *pButtons; - int nDefaultButton; - UINT cRadioButtons; - const TASKDIALOG_BUTTON *pRadioButtons; - int nDefaultRadioButton; - PCWSTR pszVerificationText; - PCWSTR pszExpandedInformation; - PCWSTR pszExpandedControlText; - PCWSTR pszCollapsedControlText; + PCWSTR pszMainInstruction; + PCWSTR pszContent; + UINT cButtons; + const TASKDIALOG_BUTTON *pButtons; + int nDefaultButton; + UINT cRadioButtons; + const TASKDIALOG_BUTTON *pRadioButtons; + int nDefaultRadioButton; + PCWSTR pszVerificationText; + PCWSTR pszExpandedInformation; + PCWSTR pszExpandedControlText; + PCWSTR pszCollapsedControlText; union { - HICON hFooterIcon; - PCWSTR pszFooterIcon; + HICON hFooterIcon; + PCWSTR pszFooterIcon; } /*DUMMYUNIONNAME2*/; - PCWSTR pszFooter; + PCWSTR pszFooter; PFTASKDIALOGCALLBACK pfCallback; - LONG_PTR lpCallbackData; - UINT cxWidth; // width of the Task Dialog's client area in DLU's. If 0, Task Dialog will calculate the ideal width. + LONG_PTR lpCallbackData; + UINT cxWidth; // width of the Task Dialog's client area in DLU's. If 0, Task Dialog will calculate the ideal width. } TASKDIALOGCONFIG; typedef struct @@ -232,7 +231,7 @@ typedef struct typedef struct { - DLGTEMPLATEEX* lpDialog; + DLGTEMPLATEEX *lpDialog; Uint8 *data; size_t size; size_t used; @@ -254,7 +253,7 @@ static INT_PTR CALLBACK MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wP const SDL_MessageBoxData *messageboxdata; size_t buttonindex; - switch ( iMessage ) { + switch (iMessage) { case WM_INITDIALOG: if (lParam == 0) { EndDialog(hDlg, IDINVALPTRINIT); @@ -351,7 +350,7 @@ static SDL_bool ExpandDialogSpace(WIN_DialogData *dialog, size_t space) } dialog->data = data; dialog->size = size; - dialog->lpDialog = (DLGTEMPLATEEX*)dialog->data; + dialog->lpDialog = (DLGTEMPLATEEX *)dialog->data; } return SDL_TRUE; } @@ -375,7 +374,7 @@ static SDL_bool AddDialogData(WIN_DialogData *dialog, const void *data, size_t s return SDL_FALSE; } - SDL_memcpy(dialog->data+dialog->used, data, size); + SDL_memcpy(dialog->data + dialog->used, data, size); dialog->used += size; return SDL_TRUE; @@ -404,7 +403,7 @@ static SDL_bool AddDialogString(WIN_DialogData *dialog, const char *string) } ++count; - status = AddDialogData(dialog, wstring, count*sizeof(WCHAR)); + status = AddDialogData(dialog, wstring, count * sizeof(WCHAR)); SDL_free(wstring); return status; } @@ -419,7 +418,6 @@ static void Vec2ToDLU(short *x, short *y) *y = MulDiv(*y, 8, s_BaseUnitsY); } - static SDL_bool AddDialogControl(WIN_DialogData *dialog, WORD type, DWORD style, DWORD exStyle, int x, int y, int w, int h, int id, const char *caption, WORD ordinal) { DLGITEMTEMPLATEEX item; @@ -674,15 +672,14 @@ static const char *EscapeAmpersands(char **dst, size_t *dstlen, const char *src) } /* This function is called if a Task Dialog is unsupported. */ -static int -WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) +static int WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { WIN_DialogData *dialog; int i, x, y, retval; HFONT DialogFont; SIZE Size; RECT TextSize; - wchar_t* wmessage; + wchar_t *wmessage; TEXTMETRIC TM; HDC FontDC; INT_PTR result; @@ -824,7 +821,7 @@ WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) return -1; } - if (icon && ! AddDialogStaticIcon(dialog, IconMargin, IconMargin, IconWidth, IconHeight, icon)) { + if (icon && !AddDialogStaticIcon(dialog, IconMargin, IconMargin, IconWidth, IconHeight, icon)) { FreeDialogData(dialog); return -1; } @@ -874,10 +871,10 @@ WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) /* If we have a parent window, get the Instance and HWND for them * so that our little dialog gets exclusive focus at all times. */ if (messageboxdata->window) { - ParentWindow = ((SDL_WindowData*)messageboxdata->window->driverdata)->hwnd; + ParentWindow = ((SDL_WindowData *)messageboxdata->window->driverdata)->hwnd; } - result = DialogBoxIndirectParam(NULL, (DLGTEMPLATE*)dialog->lpDialog, ParentWindow, MessageBoxDialogProc, (LPARAM)messageboxdata); + result = DialogBoxIndirectParam(NULL, (DLGTEMPLATE *)dialog->lpDialog, ParentWindow, MessageBoxDialogProc, (LPARAM)messageboxdata); if (result >= IDBUTTONINDEX0 && result - IDBUTTONINDEX0 < messageboxdata->numbuttons) { *buttonid = messageboxdata->buttons[result - IDBUTTONINDEX0].buttonid; retval = 0; @@ -908,10 +905,11 @@ WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) /* TaskDialogIndirect procedure * This is because SDL targets Windows XP (0x501), so this is not defined in the platform SDK. */ -typedef HRESULT(FAR WINAPI *TASKDIALOGINDIRECTPROC)(const TASKDIALOGCONFIG *pTaskConfig, int *pnButton, int *pnRadioButton, BOOL *pfVerificationFlagChecked); +/* *INDENT-OFF* */ /* clang-format off */ +typedef HRESULT (FAR WINAPI *TASKDIALOGINDIRECTPROC)(const TASKDIALOGCONFIG *pTaskConfig, int *pnButton, int *pnRadioButton, BOOL *pfVerificationFlagChecked); +/* *INDENT-ON* */ /* clang-format on */ -int -WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) +int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { HWND ParentWindow = NULL; wchar_t *wmessage; @@ -945,7 +943,7 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) If you don't want to bother with manifests, put this #pragma in your app's source code somewhere: pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") */ - pfnTaskDialogIndirect = (TASKDIALOGINDIRECTPROC) GetProcAddress(hComctl32, "TaskDialogIndirect"); + pfnTaskDialogIndirect = (TASKDIALOGINDIRECTPROC)GetProcAddress(hComctl32, "TaskDialogIndirect"); if (pfnTaskDialogIndirect == NULL) { FreeLibrary(hComctl32); return WIN_ShowOldMessageBox(messageboxdata, buttonid); @@ -954,14 +952,14 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) /* If we have a parent window, get the Instance and HWND for them so that our little dialog gets exclusive focus at all times. */ if (messageboxdata->window) { - ParentWindow = ((SDL_WindowData *) messageboxdata->window->driverdata)->hwnd; + ParentWindow = ((SDL_WindowData *)messageboxdata->window->driverdata)->hwnd; } wmessage = WIN_UTF8ToStringW(messageboxdata->message); wtitle = WIN_UTF8ToStringW(messageboxdata->title); SDL_zero(TaskConfig); - TaskConfig.cbSize = sizeof (TASKDIALOGCONFIG); + TaskConfig.cbSize = sizeof(TASKDIALOGCONFIG); TaskConfig.hwndParent = ParentWindow; TaskConfig.dwFlags = TDF_SIZE_TO_CONTENT; TaskConfig.pszWindowTitle = wtitle; @@ -977,7 +975,7 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) TaskConfig.pszContent = wmessage; TaskConfig.cButtons = messageboxdata->numbuttons; - pButtons = SDL_malloc(sizeof (TASKDIALOG_BUTTON) * messageboxdata->numbuttons); + pButtons = SDL_malloc(sizeof(TASKDIALOG_BUTTON) * messageboxdata->numbuttons); TaskConfig.nDefaultButton = 0; nCancelButton = 0; for (i = 0; i < messageboxdata->numbuttons; i++) { @@ -1001,7 +999,7 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) SDL_free(wmessage); SDL_free(wtitle); for (j = 0; j < i; j++) { - SDL_free((wchar_t *) pButtons[j].pszButtonText); + SDL_free((wchar_t *)pButtons[j].pszButtonText); } SDL_free(pButtons); return -1; @@ -1022,7 +1020,7 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) SDL_free(wmessage); SDL_free(wtitle); for (i = 0; i < messageboxdata->numbuttons; i++) { - SDL_free((wchar_t *) pButtons[i].pszButtonText); + SDL_free((wchar_t *)pButtons[i].pszButtonText); } SDL_free(pButtons); diff --git a/src/video/windows/SDL_windowsmodes.c b/src/video/windows/SDL_windowsmodes.c index 78af47917..0e087fa7d 100644 --- a/src/video/windows/SDL_windowsmodes.c +++ b/src/video/windows/SDL_windowsmodes.c @@ -33,23 +33,21 @@ /* #define DEBUG_MODES */ /* #define HIGHDPI_DEBUG_VERBOSE */ -static void -WIN_UpdateDisplayMode(_THIS, LPCWSTR deviceName, DWORD index, SDL_DisplayMode * mode) +static void WIN_UpdateDisplayMode(_THIS, LPCWSTR deviceName, DWORD index, SDL_DisplayMode *mode) { - SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata; + SDL_DisplayModeData *data = (SDL_DisplayModeData *)mode->driverdata; HDC hdc; data->DeviceMode.dmFields = (DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY | DM_DISPLAYFLAGS); - if (index == ENUM_CURRENT_SETTINGS - && (hdc = CreateDC(deviceName, NULL, NULL, NULL)) != NULL) { + if (index == ENUM_CURRENT_SETTINGS && (hdc = CreateDC(deviceName, NULL, NULL, NULL)) != NULL) { char bmi_data[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)]; LPBITMAPINFO bmi; HBITMAP hbm; - int logical_width = GetDeviceCaps( hdc, HORZRES ); - int logical_height = GetDeviceCaps( hdc, VERTRES ); + int logical_width = GetDeviceCaps(hdc, HORZRES); + int logical_height = GetDeviceCaps(hdc, VERTRES); /* High-DPI notes: @@ -62,9 +60,9 @@ WIN_UpdateDisplayMode(_THIS, LPCWSTR deviceName, DWORD index, SDL_DisplayMode * - GetDeviceCaps( hdc, HORZRES ) will return pixels, same as DeviceMode.dmPelsWidth */ mode->w = logical_width; mode->h = logical_height; - + SDL_zeroa(bmi_data); - bmi = (LPBITMAPINFO) bmi_data; + bmi = (LPBITMAPINFO)bmi_data; bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); hbm = CreateCompatibleBitmap(hdc, 1, 1); @@ -73,7 +71,7 @@ WIN_UpdateDisplayMode(_THIS, LPCWSTR deviceName, DWORD index, SDL_DisplayMode * DeleteObject(hbm); DeleteDC(hdc); if (bmi->bmiHeader.biCompression == BI_BITFIELDS) { - switch (*(Uint32 *) bmi->bmiColors) { + switch (*(Uint32 *)bmi->bmiColors) { case 0x00FF0000: mode->format = SDL_PIXELFORMAT_RGB888; break; @@ -119,8 +117,7 @@ WIN_UpdateDisplayMode(_THIS, LPCWSTR deviceName, DWORD index, SDL_DisplayMode * } } -static SDL_DisplayOrientation -WIN_GetDisplayOrientation(DEVMODE *mode) +static SDL_DisplayOrientation WIN_GetDisplayOrientation(DEVMODE *mode) { int width = mode->dmPelsWidth; int height = mode->dmPelsHeight; @@ -161,8 +158,7 @@ WIN_GetDisplayOrientation(DEVMODE *mode) } } -static SDL_bool -WIN_GetDisplayMode(_THIS, LPCWSTR deviceName, DWORD index, SDL_DisplayMode * mode, SDL_DisplayOrientation *orientation) +static SDL_bool WIN_GetDisplayMode(_THIS, LPCWSTR deviceName, DWORD index, SDL_DisplayMode *mode, SDL_DisplayOrientation *orientation) { SDL_DisplayModeData *data; DEVMODE devmode; @@ -173,7 +169,7 @@ WIN_GetDisplayMode(_THIS, LPCWSTR deviceName, DWORD index, SDL_DisplayMode * mod return SDL_FALSE; } - data = (SDL_DisplayModeData *) SDL_malloc(sizeof(*data)); + data = (SDL_DisplayModeData *)SDL_malloc(sizeof(*data)); if (data == NULL) { return SDL_FALSE; } @@ -197,12 +193,13 @@ WIN_GetDisplayMode(_THIS, LPCWSTR deviceName, DWORD index, SDL_DisplayMode * mod } /* The win32 API calls in this function require Windows Vista or later. */ +/* *INDENT-OFF* */ /* clang-format off */ typedef LONG (WINAPI *SDL_WIN32PROC_GetDisplayConfigBufferSizes)(UINT32 flags, UINT32* numPathArrayElements, UINT32* numModeInfoArrayElements); typedef LONG (WINAPI *SDL_WIN32PROC_QueryDisplayConfig)(UINT32 flags, UINT32* numPathArrayElements, DISPLAYCONFIG_PATH_INFO* pathArray, UINT32* numModeInfoArrayElements, DISPLAYCONFIG_MODE_INFO* modeInfoArray, DISPLAYCONFIG_TOPOLOGY_ID* currentTopologyId); typedef LONG (WINAPI *SDL_WIN32PROC_DisplayConfigGetDeviceInfo)(DISPLAYCONFIG_DEVICE_INFO_HEADER* requestPacket); +/* *INDENT-ON* */ /* clang-format on */ -static char * -WIN_GetDisplayNameVista(const WCHAR *deviceName) +static char *WIN_GetDisplayNameVista(const WCHAR *deviceName) { void *dll; SDL_WIN32PROC_GetDisplayConfigBufferSizes pGetDisplayConfigBufferSizes; @@ -221,9 +218,9 @@ WIN_GetDisplayNameVista(const WCHAR *deviceName) return NULL; } - pGetDisplayConfigBufferSizes = (SDL_WIN32PROC_GetDisplayConfigBufferSizes) SDL_LoadFunction(dll, "GetDisplayConfigBufferSizes"); - pQueryDisplayConfig = (SDL_WIN32PROC_QueryDisplayConfig) SDL_LoadFunction(dll, "QueryDisplayConfig"); - pDisplayConfigGetDeviceInfo = (SDL_WIN32PROC_DisplayConfigGetDeviceInfo) SDL_LoadFunction(dll, "DisplayConfigGetDeviceInfo"); + pGetDisplayConfigBufferSizes = (SDL_WIN32PROC_GetDisplayConfigBufferSizes)SDL_LoadFunction(dll, "GetDisplayConfigBufferSizes"); + pQueryDisplayConfig = (SDL_WIN32PROC_QueryDisplayConfig)SDL_LoadFunction(dll, "QueryDisplayConfig"); + pDisplayConfigGetDeviceInfo = (SDL_WIN32PROC_DisplayConfigGetDeviceInfo)SDL_LoadFunction(dll, "DisplayConfigGetDeviceInfo"); if (pGetDisplayConfigBufferSizes == NULL || pQueryDisplayConfig == NULL || pDisplayConfigGetDeviceInfo == NULL) { goto WIN_GetDisplayNameVista_failed; @@ -238,8 +235,8 @@ WIN_GetDisplayNameVista(const WCHAR *deviceName) SDL_free(paths); SDL_free(modes); - paths = (DISPLAYCONFIG_PATH_INFO *) SDL_malloc(sizeof (DISPLAYCONFIG_PATH_INFO) * pathCount); - modes = (DISPLAYCONFIG_MODE_INFO *) SDL_malloc(sizeof (DISPLAYCONFIG_MODE_INFO) * modeCount); + paths = (DISPLAYCONFIG_PATH_INFO *)SDL_malloc(sizeof(DISPLAYCONFIG_PATH_INFO) * pathCount); + modes = (DISPLAYCONFIG_MODE_INFO *)SDL_malloc(sizeof(DISPLAYCONFIG_MODE_INFO) * modeCount); if ((paths == NULL) || (modes == NULL)) { goto WIN_GetDisplayNameVista_failed; } @@ -255,7 +252,7 @@ WIN_GetDisplayNameVista(const WCHAR *deviceName) SDL_zero(sourceName); sourceName.header.adapterId = paths[i].targetInfo.adapterId; sourceName.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME; - sourceName.header.size = sizeof (sourceName); + sourceName.header.size = sizeof(sourceName); sourceName.header.id = paths[i].sourceInfo.id; rc = pDisplayConfigGetDeviceInfo(&sourceName.header); if (rc != ERROR_SUCCESS) { @@ -268,7 +265,7 @@ WIN_GetDisplayNameVista(const WCHAR *deviceName) targetName.header.adapterId = paths[i].targetInfo.adapterId; targetName.header.id = paths[i].targetInfo.id; targetName.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME; - targetName.header.size = sizeof (targetName); + targetName.header.size = sizeof(targetName); rc = pDisplayConfigGetDeviceInfo(&targetName.header); if (rc == ERROR_SUCCESS) { retval = WIN_StringToUTF8W(targetName.monitorFriendlyDeviceName); @@ -296,8 +293,7 @@ WIN_GetDisplayNameVista_failed: return NULL; } -static SDL_bool -WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info, SDL_bool send_event) +static SDL_bool WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info, SDL_bool send_event) { int i; SDL_VideoDisplay display; @@ -332,7 +328,7 @@ WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info, SDL_bool se } } - displaydata = (SDL_DisplayData *) SDL_calloc(1, sizeof(*displaydata)); + displaydata = (SDL_DisplayData *)SDL_calloc(1, sizeof(*displaydata)); if (displaydata == NULL) { return SDL_FALSE; } @@ -345,7 +341,7 @@ WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info, SDL_bool se if (display.name == NULL) { DISPLAY_DEVICEW device; SDL_zero(device); - device.cb = sizeof (device); + device.cb = sizeof(device); if (EnumDisplayDevicesW(info->szDevice, 0, &device, 0)) { display.name = WIN_StringToUTF8W(device.DeviceString); } @@ -360,19 +356,19 @@ WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info, SDL_bool se return SDL_TRUE; } -typedef struct _WIN_AddDisplaysData { +typedef struct _WIN_AddDisplaysData +{ SDL_VideoDevice *video_device; SDL_bool send_event; SDL_bool want_primary; } WIN_AddDisplaysData; -static BOOL CALLBACK -WIN_AddDisplaysCallback(HMONITOR hMonitor, - HDC hdcMonitor, - LPRECT lprcMonitor, - LPARAM dwData) +static BOOL CALLBACK WIN_AddDisplaysCallback(HMONITOR hMonitor, + HDC hdcMonitor, + LPRECT lprcMonitor, + LPARAM dwData) { - WIN_AddDisplaysData *data = (WIN_AddDisplaysData*)dwData; + WIN_AddDisplaysData *data = (WIN_AddDisplaysData *)dwData; MONITORINFOEXW info; SDL_zero(info); @@ -390,8 +386,7 @@ WIN_AddDisplaysCallback(HMONITOR hMonitor, return TRUE; } -static void -WIN_AddDisplays(_THIS, SDL_bool send_event) +static void WIN_AddDisplays(_THIS, SDL_bool send_event) { WIN_AddDisplaysData callback_data; callback_data.video_device = _this; @@ -404,8 +399,7 @@ WIN_AddDisplays(_THIS, SDL_bool send_event) EnumDisplayMonitors(NULL, NULL, WIN_AddDisplaysCallback, (LPARAM)&callback_data); } -int -WIN_InitModes(_THIS) +int WIN_InitModes(_THIS) { WIN_AddDisplays(_this, SDL_FALSE); @@ -416,13 +410,12 @@ WIN_InitModes(_THIS) } /** - * Convert the monitor rect and work rect from pixels to the SDL coordinate system (monitor origins are in pixels, + * Convert the monitor rect and work rect from pixels to the SDL coordinate system (monitor origins are in pixels, * monitor size in DPI-scaled points). - * + * * No-op if DPI scaling is not enabled. */ -static void -WIN_MonitorInfoToSDL(const SDL_VideoData *videodata, HMONITOR monitor, MONITORINFO *info) +static void WIN_MonitorInfoToSDL(const SDL_VideoData *videodata, HMONITOR monitor, MONITORINFO *info) { UINT xdpi, ydpi; @@ -444,14 +437,13 @@ WIN_MonitorInfoToSDL(const SDL_VideoData *videodata, HMONITOR monitor, MONITORIN info->rcMonitor.bottom = info->rcMonitor.top + MulDiv(info->rcMonitor.bottom - info->rcMonitor.top, 96, ydpi); /* Convert monitor work rect to points */ - info->rcWork.left = info->rcMonitor.left + MulDiv(info->rcWork.left - info->rcMonitor.left, 96, xdpi); - info->rcWork.right = info->rcMonitor.left + MulDiv(info->rcWork.right - info->rcMonitor.left, 96, xdpi); - info->rcWork.top = info->rcMonitor.top + MulDiv(info->rcWork.top - info->rcMonitor.top, 96, ydpi); - info->rcWork.bottom = info->rcMonitor.top + MulDiv(info->rcWork.bottom - info->rcMonitor.top, 96, ydpi); + info->rcWork.left = info->rcMonitor.left + MulDiv(info->rcWork.left - info->rcMonitor.left, 96, xdpi); + info->rcWork.right = info->rcMonitor.left + MulDiv(info->rcWork.right - info->rcMonitor.left, 96, xdpi); + info->rcWork.top = info->rcMonitor.top + MulDiv(info->rcWork.top - info->rcMonitor.top, 96, ydpi); + info->rcWork.bottom = info->rcMonitor.top + MulDiv(info->rcWork.bottom - info->rcMonitor.top, 96, ydpi); } -int -WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect) +int WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) { const SDL_DisplayData *data = (const SDL_DisplayData *)display->driverdata; const SDL_VideoData *videodata = (SDL_VideoData *)display->device->driverdata; @@ -475,13 +467,12 @@ WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect) return 0; } -int -WIN_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi_out, float * hdpi_out, float * vdpi_out) +int WIN_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi_out, float *hdpi_out, float *vdpi_out) { const SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata; const SDL_VideoData *videodata = (SDL_VideoData *)display->device->driverdata; float hdpi = 0, vdpi = 0, ddpi = 0; - + if (videodata->GetDpiForMonitor) { UINT hdpi_uint, vdpi_uint; // Windows 8.1+ codepath @@ -534,8 +525,7 @@ WIN_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi_out, float * h return ddpi != 0.0f ? 0 : SDL_SetError("Couldn't get DPI"); } -int -WIN_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect) +int WIN_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) { const SDL_DisplayData *data = (const SDL_DisplayData *)display->driverdata; const SDL_VideoData *videodata = (SDL_VideoData *)display->device->driverdata; @@ -560,11 +550,11 @@ WIN_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect) } /** - * Convert a point from the SDL coordinate system (monitor origins are in pixels, + * Convert a point from the SDL coordinate system (monitor origins are in pixels, * offset within a monitor in DPI-scaled points) to Windows virtual screen coordinates (pixels). - * + * * No-op if DPI scaling is not enabled (returns 96 dpi). - * + * * Returns the DPI of the monitor that was closest to x, y and used for the conversion. */ void WIN_ScreenPointFromSDL(int *x, int *y, int *dpiOut) @@ -576,8 +566,8 @@ void WIN_ScreenPointFromSDL(int *x, int *y, int *dpiOut) float ddpi, hdpi, vdpi; int x_sdl, y_sdl; SDL_Point point; - point.x = *x; - point.y = *y; + point.x = *x; + point.y = *y; if (dpiOut) { *dpiOut = 96; @@ -599,13 +589,12 @@ void WIN_ScreenPointFromSDL(int *x, int *y, int *dpiOut) return; } - if (SDL_GetDisplayBounds(displayIndex, &bounds) < 0 - || SDL_GetDisplayDPI(displayIndex, &ddpi, &hdpi, &vdpi) < 0) { + if (SDL_GetDisplayBounds(displayIndex, &bounds) < 0 || SDL_GetDisplayDPI(displayIndex, &ddpi, &hdpi, &vdpi) < 0) { return; } if (dpiOut) { - *dpiOut = (int) ddpi; + *dpiOut = (int)ddpi; } /* Undo the DPI-scaling within the monitor bounds to convert back to pixels */ @@ -616,7 +605,7 @@ void WIN_ScreenPointFromSDL(int *x, int *y, int *dpiOut) #ifdef HIGHDPI_DEBUG_VERBOSE SDL_Log("WIN_ScreenPointFromSDL: (%d, %d) points -> (%d x %d) pixels, using %d DPI monitor", - x_sdl, y_sdl, *x, *y, (int)ddpi); + x_sdl, y_sdl, *x, *y, (int)ddpi); #endif } @@ -645,7 +634,7 @@ void WIN_ScreenPointToSDL(int *x, int *y) if (!videodata->dpi_scaling_enabled) { return; } - + point.x = *x; point.y = *y; monitor = MonitorFromPoint(point, MONITOR_DEFAULTTONEAREST); @@ -663,8 +652,7 @@ void WIN_ScreenPointToSDL(int *x, int *y) } /* Get SDL display properties */ - if (SDL_GetDisplayBounds(displayIndex, &bounds) < 0 - || SDL_GetDisplayDPI(displayIndex, &ddpi, &hdpi, &vdpi) < 0) { + if (SDL_GetDisplayBounds(displayIndex, &bounds) < 0 || SDL_GetDisplayDPI(displayIndex, &ddpi, &hdpi, &vdpi) < 0) { return; } @@ -676,18 +664,17 @@ void WIN_ScreenPointToSDL(int *x, int *y) #ifdef HIGHDPI_DEBUG_VERBOSE SDL_Log("WIN_ScreenPointToSDL: (%d, %d) pixels -> (%d x %d) points, using %d DPI monitor", - x_pixels, y_pixels, *x, *y, (int)ddpi); + x_pixels, y_pixels, *x, *y, (int)ddpi); #endif } -void -WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display) +void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay *display) { - SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata; + SDL_DisplayData *data = (SDL_DisplayData *)display->driverdata; DWORD i; SDL_DisplayMode mode; - for (i = 0; ; ++i) { + for (i = 0;; ++i) { if (!WIN_GetDisplayMode(_this, data->DeviceName, i, &mode, NULL)) { break; } @@ -707,8 +694,7 @@ WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display) } #ifdef DEBUG_MODES -static void -WIN_LogMonitor(_THIS, HMONITOR mon) +static void WIN_LogMonitor(_THIS, HMONITOR mon) { const SDL_VideoData *vid_data = (const SDL_VideoData *)_this->driverdata; MONITORINFOEX minfo; @@ -726,22 +712,21 @@ WIN_LogMonitor(_THIS, HMONITOR mon) name_utf8 = WIN_StringToUTF8(minfo.szDevice); SDL_Log("WIN_LogMonitor: monitor \"%s\": dpi: %d windows screen coordinates: %d, %d, %dx%d", - name_utf8, - xdpi, - minfo.rcMonitor.left, - minfo.rcMonitor.top, - minfo.rcMonitor.right - minfo.rcMonitor.left, - minfo.rcMonitor.bottom - minfo.rcMonitor.top); + name_utf8, + xdpi, + minfo.rcMonitor.left, + minfo.rcMonitor.top, + minfo.rcMonitor.right - minfo.rcMonitor.left, + minfo.rcMonitor.bottom - minfo.rcMonitor.top); SDL_free(name_utf8); } #endif -int -WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +int WIN_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) { - SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata; - SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata; + SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata; + SDL_DisplayModeData *data = (SDL_DisplayModeData *)mode->driverdata; LONG status; #ifdef DEBUG_MODES @@ -799,8 +784,7 @@ WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) return 0; } -void -WIN_RefreshDisplays(_THIS) +void WIN_RefreshDisplays(_THIS) { int i; @@ -825,8 +809,7 @@ WIN_RefreshDisplays(_THIS) } } -void -WIN_QuitModes(_THIS) +void WIN_QuitModes(_THIS) { /* All fullscreen windows should have restored modes by now */ } diff --git a/src/video/windows/SDL_windowsmodes.h b/src/video/windows/SDL_windowsmodes.h index 6bf62e586..fd586ed81 100644 --- a/src/video/windows/SDL_windowsmodes.h +++ b/src/video/windows/SDL_windowsmodes.h @@ -36,13 +36,13 @@ typedef struct } SDL_DisplayModeData; extern int WIN_InitModes(_THIS); -extern int WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect); -extern int WIN_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect); +extern int WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect); +extern int WIN_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect); extern void WIN_ScreenPointFromSDL(int *x, int *y, int *dpiOut); extern void WIN_ScreenPointToSDL(int *x, int *y); -extern int WIN_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi); -extern void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display); -extern int WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); +extern int WIN_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi); +extern void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay *display); +extern int WIN_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode); extern void WIN_RefreshDisplays(_THIS); extern void WIN_QuitModes(_THIS); diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c index 31d8f608e..45997148b 100644 --- a/src/video/windows/SDL_windowsmouse.c +++ b/src/video/windows/SDL_windowsmouse.c @@ -26,30 +26,28 @@ #include "../../events/SDL_mouse_c.h" - DWORD SDL_last_warp_time = 0; HCURSOR SDL_cursor = NULL; static SDL_Cursor *SDL_blank_cursor = NULL; static int rawInputEnableCount = 0; -static int -ToggleRawInput(SDL_bool enabled) +static int ToggleRawInput(SDL_bool enabled) { RAWINPUTDEVICE rawMouse = { 0x01, 0x02, 0, NULL }; /* Mouse: UsagePage = 1, Usage = 2 */ if (enabled) { rawInputEnableCount++; if (rawInputEnableCount > 1) { - return 0; /* already done. */ + return 0; /* already done. */ } } else { if (rawInputEnableCount == 0) { - return 0; /* already done. */ + return 0; /* already done. */ } rawInputEnableCount--; if (rawInputEnableCount > 0) { - return 0; /* not time to disable yet */ + return 0; /* not time to disable yet */ } } @@ -72,9 +70,7 @@ ToggleRawInput(SDL_bool enabled) return 0; } - -static SDL_Cursor * -WIN_CreateDefaultCursor() +static SDL_Cursor *WIN_CreateDefaultCursor() { SDL_Cursor *cursor; @@ -88,12 +84,11 @@ WIN_CreateDefaultCursor() return cursor; } -static SDL_Cursor * -WIN_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) +static SDL_Cursor *WIN_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) { /* msdn says cursor mask has to be padded out to word alignment. Not sure if that means machine word or WORD, but this handles either case. */ - const size_t pad = (sizeof (size_t) * 8); /* 32 or 64, or whatever. */ + const size_t pad = (sizeof(size_t) * 8); /* 32 or 64, or whatever. */ SDL_Cursor *cursor; HICON hicon; HICON hcursor; @@ -113,9 +108,9 @@ WIN_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) bmh.bV4BitCount = 32; bmh.bV4V4Compression = BI_BITFIELDS; bmh.bV4AlphaMask = 0xFF000000; - bmh.bV4RedMask = 0x00FF0000; + bmh.bV4RedMask = 0x00FF0000; bmh.bV4GreenMask = 0x0000FF00; - bmh.bV4BlueMask = 0x000000FF; + bmh.bV4BlueMask = 0x000000FF; maskbitslen = ((surface->w + (pad - (surface->w % pad))) / 8) * surface->h; maskbits = SDL_small_alloc(Uint8, maskbitslen, &isstack); @@ -132,7 +127,7 @@ WIN_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) ii.fIcon = FALSE; ii.xHotspot = (DWORD)hot_x; ii.yHotspot = (DWORD)hot_y; - ii.hbmColor = CreateDIBSection(hdc, (BITMAPINFO*)&bmh, DIB_RGB_COLORS, &pixels, NULL, 0); + ii.hbmColor = CreateDIBSection(hdc, (BITMAPINFO *)&bmh, DIB_RGB_COLORS, &pixels, NULL, 0); ii.hbmMask = CreateBitmap(surface->w, surface->h, 1, 1, maskbits); ReleaseDC(NULL, hdc); SDL_small_free(maskbits, isstack); @@ -172,8 +167,7 @@ WIN_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) return cursor; } -static SDL_Cursor * -WIN_CreateBlankCursor() +static SDL_Cursor *WIN_CreateBlankCursor() { SDL_Cursor *cursor = NULL; SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormat(0, 32, 32, 32, SDL_PIXELFORMAT_ARGB8888); @@ -184,29 +178,51 @@ WIN_CreateBlankCursor() return cursor; } -static SDL_Cursor * -WIN_CreateSystemCursor(SDL_SystemCursor id) +static SDL_Cursor *WIN_CreateSystemCursor(SDL_SystemCursor id) { SDL_Cursor *cursor; LPCTSTR name; - switch(id) - { + switch (id) { default: SDL_assert(0); return NULL; - case SDL_SYSTEM_CURSOR_ARROW: name = IDC_ARROW; break; - case SDL_SYSTEM_CURSOR_IBEAM: name = IDC_IBEAM; break; - case SDL_SYSTEM_CURSOR_WAIT: name = IDC_WAIT; break; - case SDL_SYSTEM_CURSOR_CROSSHAIR: name = IDC_CROSS; break; - case SDL_SYSTEM_CURSOR_WAITARROW: name = IDC_WAIT; break; - case SDL_SYSTEM_CURSOR_SIZENWSE: name = IDC_SIZENWSE; break; - case SDL_SYSTEM_CURSOR_SIZENESW: name = IDC_SIZENESW; break; - case SDL_SYSTEM_CURSOR_SIZEWE: name = IDC_SIZEWE; break; - case SDL_SYSTEM_CURSOR_SIZENS: name = IDC_SIZENS; break; - case SDL_SYSTEM_CURSOR_SIZEALL: name = IDC_SIZEALL; break; - case SDL_SYSTEM_CURSOR_NO: name = IDC_NO; break; - case SDL_SYSTEM_CURSOR_HAND: name = IDC_HAND; break; + case SDL_SYSTEM_CURSOR_ARROW: + name = IDC_ARROW; + break; + case SDL_SYSTEM_CURSOR_IBEAM: + name = IDC_IBEAM; + break; + case SDL_SYSTEM_CURSOR_WAIT: + name = IDC_WAIT; + break; + case SDL_SYSTEM_CURSOR_CROSSHAIR: + name = IDC_CROSS; + break; + case SDL_SYSTEM_CURSOR_WAITARROW: + name = IDC_WAIT; + break; + case SDL_SYSTEM_CURSOR_SIZENWSE: + name = IDC_SIZENWSE; + break; + case SDL_SYSTEM_CURSOR_SIZENESW: + name = IDC_SIZENESW; + break; + case SDL_SYSTEM_CURSOR_SIZEWE: + name = IDC_SIZEWE; + break; + case SDL_SYSTEM_CURSOR_SIZENS: + name = IDC_SIZENS; + break; + case SDL_SYSTEM_CURSOR_SIZEALL: + name = IDC_SIZEALL; + break; + case SDL_SYSTEM_CURSOR_NO: + name = IDC_NO; + break; + case SDL_SYSTEM_CURSOR_HAND: + name = IDC_HAND; + break; } cursor = SDL_calloc(1, sizeof(*cursor)); @@ -223,8 +239,7 @@ WIN_CreateSystemCursor(SDL_SystemCursor id) return cursor; } -static void -WIN_FreeCursor(SDL_Cursor * cursor) +static void WIN_FreeCursor(SDL_Cursor *cursor) { HICON hicon = (HICON)cursor->driverdata; @@ -232,8 +247,7 @@ WIN_FreeCursor(SDL_Cursor * cursor) SDL_free(cursor); } -static int -WIN_ShowCursor(SDL_Cursor * cursor) +static int WIN_ShowCursor(SDL_Cursor *cursor) { if (cursor == NULL) { cursor = SDL_blank_cursor; @@ -249,12 +263,11 @@ WIN_ShowCursor(SDL_Cursor * cursor) return 0; } -void -WIN_SetCursorPos(int x, int y) +void WIN_SetCursorPos(int x, int y) { /* We need to jitter the value because otherwise Windows will occasionally inexplicably ignore the SetCursorPos() or SendInput() */ SetCursorPos(x, y); - SetCursorPos(x+1, y); + SetCursorPos(x + 1, y); SetCursorPos(x, y); /* Flush any mouse motion prior to or associated with this warp */ @@ -264,8 +277,7 @@ WIN_SetCursorPos(int x, int y) } } -static void -WIN_WarpMouse(SDL_Window * window, int x, int y) +static void WIN_WarpMouse(SDL_Window *window, int x, int y) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; HWND hwnd = data->hwnd; @@ -285,8 +297,7 @@ WIN_WarpMouse(SDL_Window * window, int x, int y) SDL_SendMouseMotion(window, SDL_GetMouse()->mouseID, 0, x, y); } -static int -WIN_WarpMouseGlobal(int x, int y) +static int WIN_WarpMouseGlobal(int x, int y) { POINT pt; @@ -297,21 +308,19 @@ WIN_WarpMouseGlobal(int x, int y) return 0; } -static int -WIN_SetRelativeMouseMode(SDL_bool enabled) +static int WIN_SetRelativeMouseMode(SDL_bool enabled) { return ToggleRawInput(enabled); } -static int -WIN_CaptureMouse(SDL_Window *window) +static int WIN_CaptureMouse(SDL_Window *window) { if (window) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SetCapture(data->hwnd); } else { SDL_Window *focus_window = SDL_GetMouseFocus(); - + if (focus_window) { SDL_WindowData *data = (SDL_WindowData *)focus_window->driverdata; if (!data->mouse_tracked) { @@ -324,16 +333,15 @@ WIN_CaptureMouse(SDL_Window *window) return 0; } -static Uint32 -WIN_GetGlobalMouseState(int *x, int *y) +static Uint32 WIN_GetGlobalMouseState(int *x, int *y) { Uint32 retval = 0; POINT pt = { 0, 0 }; SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0; GetCursorPos(&pt); - *x = (int) pt.x; - *y = (int) pt.y; + *x = (int)pt.x; + *y = (int)pt.y; WIN_ScreenPointToSDL(x, y); retval |= GetAsyncKeyState(!swapButtons ? VK_LBUTTON : VK_RBUTTON) & 0x8000 ? SDL_BUTTON_LMASK : 0; @@ -345,8 +353,7 @@ WIN_GetGlobalMouseState(int *x, int *y) return retval; } -void -WIN_InitMouse(_THIS) +void WIN_InitMouse(_THIS) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -367,10 +374,9 @@ WIN_InitMouse(_THIS) WIN_UpdateMouseSystemScale(); } -void -WIN_QuitMouse(_THIS) +void WIN_QuitMouse(_THIS) { - if (rawInputEnableCount) { /* force RAWINPUT off here. */ + if (rawInputEnableCount) { /* force RAWINPUT off here. */ rawInputEnableCount = 1; ToggleRawInput(SDL_FALSE); } @@ -385,13 +391,12 @@ WIN_QuitMouse(_THIS) * https://superuser.com/questions/278362/windows-mouse-acceleration-curve-smoothmousexcurve-and-smoothmouseycurve * http://www.esreality.com/?a=post&id=1846538/ */ -static SDL_bool -LoadFiveFixedPointFloats(BYTE *bytes, float *values) +static SDL_bool LoadFiveFixedPointFloats(BYTE *bytes, float *values) { int i; for (i = 0; i < 5; ++i) { - float fraction = (float)((Uint16) bytes[1] << 8 | bytes[0]) / 65535.0f; + float fraction = (float)((Uint16)bytes[1] << 8 | bytes[0]) / 65535.0f; float value = (float)(((Uint16)bytes[3] << 8) | bytes[2]) + fraction; *values++ = value; bytes += 8; @@ -399,10 +404,9 @@ LoadFiveFixedPointFloats(BYTE *bytes, float *values) return SDL_TRUE; } -static void -WIN_SetEnhancedMouseScale(int mouse_speed) +static void WIN_SetEnhancedMouseScale(int mouse_speed) { - float scale = (float) mouse_speed / 10.0f; + float scale = (float)mouse_speed / 10.0f; HKEY hKey; DWORD dwType = REG_BINARY; BYTE value[40]; @@ -414,7 +418,7 @@ WIN_SetEnhancedMouseScale(int mouse_speed) const int dpi = 96; // FIXME, how do we handle different monitors with different DPI? const float display_factor = 3.5f * (150.0f / dpi); - if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Control Panel\\Mouse", 0, KEY_READ, &hKey) == ERROR_SUCCESS) { + if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Control Panel\\Mouse", 0, KEY_READ, &hKey) == ERROR_SUCCESS) { if (RegQueryValueExW(hKey, L"SmoothMouseXCurve", 0, &dwType, value, &length) == ERROR_SUCCESS && LoadFiveFixedPointFloats(value, xpoints) && RegQueryValueExW(hKey, L"SmoothMouseYCurve", 0, &dwType, value, &length) == ERROR_SUCCESS && @@ -428,7 +432,7 @@ WIN_SetEnhancedMouseScale(int mouse_speed) } scale_points[i * 2] = xpoints[i]; scale_points[i * 2 + 1] = gain / display_factor; - //SDL_Log("Point %d = %f,%f\n", i, scale_points[i * 2], scale_points[i * 2 + 1]); + // SDL_Log("Point %d = %f,%f\n", i, scale_points[i * 2], scale_points[i * 2 + 1]); } SDL_SetMouseSystemScale(SDL_arraysize(scale_points), scale_points); } @@ -436,8 +440,7 @@ WIN_SetEnhancedMouseScale(int mouse_speed) } } -static void -WIN_SetLinearMouseScale(int mouse_speed) +static void WIN_SetLinearMouseScale(int mouse_speed) { static float mouse_speed_scale[] = { 0.0f, @@ -468,8 +471,7 @@ WIN_SetLinearMouseScale(int mouse_speed) } } -void -WIN_UpdateMouseSystemScale() +void WIN_UpdateMouseSystemScale() { int mouse_speed; int params[3] = { 0, 0, 0 }; diff --git a/src/video/windows/SDL_windowsopengl.c b/src/video/windows/SDL_windowsopengl.c index 53f27d5f8..dfed3755c 100644 --- a/src/video/windows/SDL_windowsopengl.c +++ b/src/video/windows/SDL_windowsopengl.c @@ -36,12 +36,12 @@ #ifndef WGL_ARB_create_context #define WGL_ARB_create_context -#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 -#define WGL_CONTEXT_FLAGS_ARB 0x2094 -#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 -#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 #ifndef WGL_ARB_create_context_profile #define WGL_ARB_create_context_profile @@ -52,53 +52,52 @@ #ifndef WGL_ARB_create_context_robustness #define WGL_ARB_create_context_robustness -#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 -#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 +#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 #endif #endif #ifndef WGL_EXT_create_context_es2_profile #define WGL_EXT_create_context_es2_profile -#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 +#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 #endif #ifndef WGL_EXT_create_context_es_profile #define WGL_EXT_create_context_es_profile -#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 +#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 #endif #ifndef WGL_ARB_framebuffer_sRGB #define WGL_ARB_framebuffer_sRGB -#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 #endif #ifndef WGL_ARB_pixel_format_float #define WGL_ARB_pixel_format_float -#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 #endif #ifndef WGL_ARB_context_flush_control #define WGL_ARB_context_flush_control -#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 -#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0x0000 -#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0x0000 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 #endif #ifndef WGL_ARB_create_context_no_error #define WGL_ARB_create_context_no_error -#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3 +#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3 #endif -typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, - HGLRC - hShareContext, - const int - *attribList); +typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC hDC, + HGLRC + hShareContext, + const int + *attribList); -int -WIN_GL_LoadLibrary(_THIS, const char *path) +int WIN_GL_LoadLibrary(_THIS, const char *path) { void *handle; @@ -116,23 +115,25 @@ WIN_GL_LoadLibrary(_THIS, const char *path) SDL_arraysize(_this->gl_config.driver_path)); /* Allocate OpenGL memory */ - _this->gl_data = (struct SDL_GLDriverData *) SDL_calloc(1, sizeof(struct SDL_GLDriverData)); + _this->gl_data = (struct SDL_GLDriverData *)SDL_calloc(1, sizeof(struct SDL_GLDriverData)); if (!_this->gl_data) { return SDL_OutOfMemory(); } /* Load function pointers */ handle = _this->gl_config.dll_handle; - _this->gl_data->wglGetProcAddress = (void *(WINAPI *) (const char *)) + /* *INDENT-OFF* */ /* clang-format off */ + _this->gl_data->wglGetProcAddress = (void *(WINAPI *)(const char *)) SDL_LoadFunction(handle, "wglGetProcAddress"); - _this->gl_data->wglCreateContext = (HGLRC(WINAPI *) (HDC)) + _this->gl_data->wglCreateContext = (HGLRC (WINAPI *)(HDC)) SDL_LoadFunction(handle, "wglCreateContext"); - _this->gl_data->wglDeleteContext = (BOOL(WINAPI *) (HGLRC)) + _this->gl_data->wglDeleteContext = (BOOL (WINAPI *)(HGLRC)) SDL_LoadFunction(handle, "wglDeleteContext"); - _this->gl_data->wglMakeCurrent = (BOOL(WINAPI *) (HDC, HGLRC)) + _this->gl_data->wglMakeCurrent = (BOOL (WINAPI *)(HDC, HGLRC)) SDL_LoadFunction(handle, "wglMakeCurrent"); - _this->gl_data->wglShareLists = (BOOL(WINAPI *) (HGLRC, HGLRC)) + _this->gl_data->wglShareLists = (BOOL (WINAPI *)(HGLRC, HGLRC)) SDL_LoadFunction(handle, "wglShareLists"); + /* *INDENT-ON* */ /* clang-format on */ if (!_this->gl_data->wglGetProcAddress || !_this->gl_data->wglCreateContext || @@ -196,8 +197,7 @@ WIN_GL_GetProcAddress(_THIS, const char *proc) return func; } -void -WIN_GL_UnloadLibrary(_THIS) +void WIN_GL_UnloadLibrary(_THIS) { SDL_UnloadObject(_this->gl_config.dll_handle); _this->gl_config.dll_handle = NULL; @@ -207,8 +207,7 @@ WIN_GL_UnloadLibrary(_THIS) _this->gl_data = NULL; } -static void -WIN_GL_SetupPixelFormat(_THIS, PIXELFORMATDESCRIPTOR * pfd) +static void WIN_GL_SetupPixelFormat(_THIS, PIXELFORMATDESCRIPTOR *pfd) { SDL_zerop(pfd); pfd->nSize = sizeof(*pfd); @@ -246,8 +245,7 @@ WIN_GL_SetupPixelFormat(_THIS, PIXELFORMATDESCRIPTOR * pfd) /* Choose the closest pixel format that meets or exceeds the target. FIXME: Should we weight any particular attribute over any other? */ -static int -WIN_GL_ChoosePixelFormat(HDC hdc, PIXELFORMATDESCRIPTOR * target) +static int WIN_GL_ChoosePixelFormat(HDC hdc, PIXELFORMATDESCRIPTOR *target) { PIXELFORMATDESCRIPTOR pfd; int count, index, best = 0; @@ -344,8 +342,7 @@ WIN_GL_ChoosePixelFormat(HDC hdc, PIXELFORMATDESCRIPTOR * target) return best; } -static SDL_bool -HasExtension(const char *extension, const char *extensions) +static SDL_bool HasExtension(const char *extension, const char *extensions) { const char *start; const char *where, *terminator; @@ -384,10 +381,11 @@ HasExtension(const char *extension, const char *extensions) return SDL_FALSE; } -void -WIN_GL_InitExtensions(_THIS) +void WIN_GL_InitExtensions(_THIS) { - const char *(WINAPI * wglGetExtensionsStringARB) (HDC) = 0; + /* *INDENT-OFF* */ /* clang-format off */ + const char *(WINAPI * wglGetExtensionsStringARB)(HDC) = 0; + /* *INDENT-ON* */ /* clang-format on */ const char *extensions; HWND hwnd; HDC hdc; @@ -400,7 +398,7 @@ WIN_GL_InitExtensions(_THIS) hwnd = CreateWindow(SDL_Appname, SDL_Appname, (WS_POPUP | WS_DISABLED), 0, 0, - 10, 10, NULL, NULL, SDL_Instance, NULL); + 10, 10, NULL, NULL, SDL_Instance, NULL); if (!hwnd) { return; } @@ -418,8 +416,10 @@ WIN_GL_InitExtensions(_THIS) } _this->gl_data->wglMakeCurrent(hdc, hglrc); - wglGetExtensionsStringARB = (const char *(WINAPI *) (HDC)) + /* *INDENT-OFF* */ /* clang-format off */ + wglGetExtensionsStringARB = (const char *(WINAPI *)(HDC)) _this->gl_data->wglGetProcAddress("wglGetExtensionsStringARB"); + /* *INDENT-ON* */ /* clang-format on */ if (wglGetExtensionsStringARB) { extensions = wglGetExtensionsStringARB(hdc); } else { @@ -429,14 +429,14 @@ WIN_GL_InitExtensions(_THIS) /* Check for WGL_ARB_pixel_format */ _this->gl_data->HAS_WGL_ARB_pixel_format = SDL_FALSE; if (HasExtension("WGL_ARB_pixel_format", extensions)) { - _this->gl_data->wglChoosePixelFormatARB = (BOOL(WINAPI *) - (HDC, const int *, - const FLOAT *, UINT, - int *, UINT *)) + /* *INDENT-OFF* */ /* clang-format off */ + _this->gl_data->wglChoosePixelFormatARB = + (BOOL (WINAPI *)(HDC, const int *, const FLOAT *, UINT, int *, UINT *)) WIN_GL_GetProcAddress(_this, "wglChoosePixelFormatARB"); _this->gl_data->wglGetPixelFormatAttribivARB = - (BOOL(WINAPI *) (HDC, int, int, UINT, const int *, int *)) + (BOOL (WINAPI *)(HDC, int, int, UINT, const int *, int *)) WIN_GL_GetProcAddress(_this, "wglGetPixelFormatAttribivARB"); + /* *INDENT-ON* */ /* clang-format on */ if ((_this->gl_data->wglChoosePixelFormatARB != NULL) && (_this->gl_data->wglGetPixelFormatAttribivARB != NULL)) { @@ -463,8 +463,7 @@ WIN_GL_InitExtensions(_THIS) if (HasExtension("WGL_EXT_create_context_es2_profile", extensions)) { SDL_GL_DeduceMaxSupportedESProfile( &_this->gl_data->es_profile_max_supported_version.major, - &_this->gl_data->es_profile_max_supported_version.minor - ); + &_this->gl_data->es_profile_max_supported_version.minor); } /* Check for WGL_ARB_context_flush_control */ @@ -489,8 +488,7 @@ WIN_GL_InitExtensions(_THIS) WIN_PumpEvents(_this); } -static int -WIN_GL_ChoosePixelFormatARB(_THIS, int *iAttribs, float *fAttribs) +static int WIN_GL_ChoosePixelFormatARB(_THIS, int *iAttribs, float *fAttribs) { HWND hwnd; HDC hdc; @@ -531,10 +529,9 @@ WIN_GL_ChoosePixelFormatARB(_THIS, int *iAttribs, float *fAttribs) } /* actual work of WIN_GL_SetupWindow() happens here. */ -static int -WIN_GL_SetupWindowInternal(_THIS, SDL_Window * window) +static int WIN_GL_SetupWindowInternal(_THIS, SDL_Window *window) { - HDC hdc = ((SDL_WindowData *) window->driverdata)->hdc; + HDC hdc = ((SDL_WindowData *)window->driverdata)->hdc; PIXELFORMATDESCRIPTOR pfd; int pixel_format = 0; int iAttribs[64]; @@ -634,10 +631,10 @@ WIN_GL_SetupWindowInternal(_THIS, SDL_Window * window) pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs); /* App said "don't care about accel" and FULL accel failed. Try NO. */ - if ( ( !pixel_format ) && ( _this->gl_config.accelerated < 0 ) ) { + if ((!pixel_format) && (_this->gl_config.accelerated < 0)) { *iAccelAttr = WGL_NO_ACCELERATION_ARB; pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs); - *iAccelAttr = WGL_FULL_ACCELERATION_ARB; /* if we try again. */ + *iAccelAttr = WGL_FULL_ACCELERATION_ARB; /* if we try again. */ } if (!pixel_format) { pixel_format = WIN_GL_ChoosePixelFormat(hdc, &pfd); @@ -651,8 +648,7 @@ WIN_GL_SetupWindowInternal(_THIS, SDL_Window * window) return 0; } -int -WIN_GL_SetupWindow(_THIS, SDL_Window * window) +int WIN_GL_SetupWindow(_THIS, SDL_Window *window) { /* The current context is lost in here; save it and reset it. */ SDL_Window *current_win = SDL_GL_GetCurrentWindow(); @@ -672,13 +668,13 @@ WIN_GL_UseEGL(_THIS) } SDL_GLContext -WIN_GL_CreateContext(_THIS, SDL_Window * window) +WIN_GL_CreateContext(_THIS, SDL_Window *window) { - HDC hdc = ((SDL_WindowData *) window->driverdata)->hdc; + HDC hdc = ((SDL_WindowData *)window->driverdata)->hdc; HGLRC context, share_context; if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES && WIN_GL_UseEGL(_this)) { -#if SDL_VIDEO_OPENGL_EGL +#if SDL_VIDEO_OPENGL_EGL /* Switch to EGL based functions */ WIN_GL_UnloadLibrary(_this); _this->GL_LoadLibrary = WIN_GLES_LoadLibrary; @@ -694,7 +690,7 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window) if (WIN_GLES_LoadLibrary(_this, NULL) != 0) { return NULL; } - + return WIN_GLES_CreateContext(_this, window); #else SDL_SetError("SDL not configured with EGL support"); @@ -713,7 +709,7 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window) _this->gl_config.flags == 0) { /* Create legacy context */ context = _this->gl_data->wglCreateContext(hdc); - if ( share_context != 0 ) { + if (share_context != 0) { _this->gl_data->wglShareLists(share_context, context); } } else { @@ -731,13 +727,12 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window) } wglCreateContextAttribsARB = - (PFNWGLCREATECONTEXTATTRIBSARBPROC) _this->gl_data-> - wglGetProcAddress("wglCreateContextAttribsARB"); + (PFNWGLCREATECONTEXTATTRIBSARBPROC)_this->gl_data->wglGetProcAddress("wglCreateContextAttribsARB"); if (!wglCreateContextAttribsARB) { SDL_SetError("GL 3.x is not supported"); context = temp_context; } else { - int attribs[15]; /* max 14 attributes plus terminator */ + int attribs[15]; /* max 14 attributes plus terminator */ int iattr = 0; attribs[iattr++] = WGL_CONTEXT_MAJOR_VERSION_ARB; @@ -760,17 +755,13 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window) /* only set if wgl extension is available */ if (_this->gl_data->HAS_WGL_ARB_context_flush_control) { attribs[iattr++] = WGL_CONTEXT_RELEASE_BEHAVIOR_ARB; - attribs[iattr++] = _this->gl_config.release_behavior ? - WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB : - WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB; + attribs[iattr++] = _this->gl_config.release_behavior ? WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB : WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB; } /* only set if wgl extension is available */ if (_this->gl_data->HAS_WGL_ARB_create_context_robustness) { attribs[iattr++] = WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB; - attribs[iattr++] = _this->gl_config.reset_notification ? - WGL_LOSE_CONTEXT_ON_RESET_ARB : - WGL_NO_RESET_NOTIFICATION_ARB; + attribs[iattr++] = _this->gl_config.reset_notification ? WGL_LOSE_CONTEXT_ON_RESET_ARB : WGL_NO_RESET_NOTIFICATION_ARB; } /* only set if wgl extension is available */ @@ -801,8 +792,7 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window) return context; } -int -WIN_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) +int WIN_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context) { HDC hdc; @@ -821,19 +811,18 @@ WIN_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) window = SDL_GL_GetCurrentWindow(); if (window == NULL) { SDL_assert(SDL_GL_GetCurrentContext() == NULL); - return 0; /* already done. */ + return 0; /* already done. */ } } - hdc = ((SDL_WindowData *) window->driverdata)->hdc; - if (!_this->gl_data->wglMakeCurrent(hdc, (HGLRC) context)) { + hdc = ((SDL_WindowData *)window->driverdata)->hdc; + if (!_this->gl_data->wglMakeCurrent(hdc, (HGLRC)context)) { return WIN_SetError("wglMakeCurrent()"); } return 0; } -int -WIN_GL_SetSwapInterval(_THIS, int interval) +int WIN_GL_SetSwapInterval(_THIS, int interval) { if ((interval < 0) && (!_this->gl_data->HAS_WGL_EXT_swap_control_tear)) { return SDL_SetError("Negative swap interval unsupported in this GL"); @@ -847,8 +836,7 @@ WIN_GL_SetSwapInterval(_THIS, int interval) return 0; } -int -WIN_GL_GetSwapInterval(_THIS) +int WIN_GL_GetSwapInterval(_THIS) { int retval = 0; if (_this->gl_data->wglGetSwapIntervalEXT) { @@ -857,10 +845,9 @@ WIN_GL_GetSwapInterval(_THIS) return retval; } -int -WIN_GL_SwapWindow(_THIS, SDL_Window * window) +int WIN_GL_SwapWindow(_THIS, SDL_Window *window) { - HDC hdc = ((SDL_WindowData *) window->driverdata)->hdc; + HDC hdc = ((SDL_WindowData *)window->driverdata)->hdc; if (!SwapBuffers(hdc)) { return WIN_SetError("SwapBuffers()"); @@ -868,21 +855,19 @@ WIN_GL_SwapWindow(_THIS, SDL_Window * window) return 0; } -void -WIN_GL_DeleteContext(_THIS, SDL_GLContext context) +void WIN_GL_DeleteContext(_THIS, SDL_GLContext context) { if (!_this->gl_data) { return; } - _this->gl_data->wglDeleteContext((HGLRC) context); + _this->gl_data->wglDeleteContext((HGLRC)context); } - SDL_bool -WIN_GL_SetPixelFormatFrom(_THIS, SDL_Window * fromWindow, SDL_Window * toWindow) +WIN_GL_SetPixelFormatFrom(_THIS, SDL_Window *fromWindow, SDL_Window *toWindow) { - HDC hfromdc = ((SDL_WindowData *) fromWindow->driverdata)->hdc; - HDC htodc = ((SDL_WindowData *) toWindow->driverdata)->hdc; + HDC hfromdc = ((SDL_WindowData *)fromWindow->driverdata)->hdc; + HDC htodc = ((SDL_WindowData *)toWindow->driverdata)->hdc; BOOL result; /* get the pixel format of the fromWindow */ diff --git a/src/video/windows/SDL_windowsopengl.h b/src/video/windows/SDL_windowsopengl.h index 2dec0023a..ca1d62f04 100644 --- a/src/video/windows/SDL_windowsopengl.h +++ b/src/video/windows/SDL_windowsopengl.h @@ -37,29 +37,23 @@ struct SDL_GLDriverData implementation supports WGL_EXT_create_context_es2_profile. major = minor = 0 when unsupported. */ - struct { + struct + { int major; int minor; } es_profile_max_supported_version; - void *(WINAPI * wglGetProcAddress) (const char *proc); - HGLRC(WINAPI * wglCreateContext) (HDC hdc); - BOOL(WINAPI * wglDeleteContext) (HGLRC hglrc); - BOOL(WINAPI * wglMakeCurrent) (HDC hdc, HGLRC hglrc); - BOOL(WINAPI * wglShareLists) (HGLRC hglrc1, HGLRC hglrc2); - BOOL(WINAPI * wglChoosePixelFormatARB) (HDC hdc, - const int *piAttribIList, - const FLOAT * pfAttribFList, - UINT nMaxFormats, - int *piFormats, - UINT * nNumFormats); - BOOL(WINAPI * wglGetPixelFormatAttribivARB) (HDC hdc, int iPixelFormat, - int iLayerPlane, - UINT nAttributes, - const int *piAttributes, - int *piValues); - BOOL (WINAPI * wglSwapIntervalEXT) (int interval); - int (WINAPI * wglGetSwapIntervalEXT) (void); + /* *INDENT-OFF* */ /* clang-format off */ + void *(WINAPI *wglGetProcAddress)(const char *proc); + HGLRC (WINAPI *wglCreateContext)(HDC hdc); + BOOL (WINAPI *wglDeleteContext)(HGLRC hglrc); + BOOL (WINAPI *wglMakeCurrent)(HDC hdc, HGLRC hglrc); + BOOL (WINAPI *wglShareLists)(HGLRC hglrc1, HGLRC hglrc2); + BOOL (WINAPI *wglChoosePixelFormatARB)(HDC hdc, const int *piAttribIList, const FLOAT * pfAttribFList, UINT nMaxFormats, int *piFormats, UINT * nNumFormats); + BOOL (WINAPI *wglGetPixelFormatAttribivARB)(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); + BOOL (WINAPI *wglSwapIntervalEXT)(int interval); + int (WINAPI *wglGetSwapIntervalEXT)(void); + /* *INDENT-ON* */ /* clang-format on */ }; /* OpenGL functions */ @@ -67,72 +61,72 @@ extern int WIN_GL_LoadLibrary(_THIS, const char *path); extern void *WIN_GL_GetProcAddress(_THIS, const char *proc); extern void WIN_GL_UnloadLibrary(_THIS); extern SDL_bool WIN_GL_UseEGL(_THIS); -extern int WIN_GL_SetupWindow(_THIS, SDL_Window * window); -extern SDL_GLContext WIN_GL_CreateContext(_THIS, SDL_Window * window); -extern int WIN_GL_MakeCurrent(_THIS, SDL_Window * window, +extern int WIN_GL_SetupWindow(_THIS, SDL_Window *window); +extern SDL_GLContext WIN_GL_CreateContext(_THIS, SDL_Window *window); +extern int WIN_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); extern int WIN_GL_SetSwapInterval(_THIS, int interval); extern int WIN_GL_GetSwapInterval(_THIS); -extern int WIN_GL_SwapWindow(_THIS, SDL_Window * window); +extern int WIN_GL_SwapWindow(_THIS, SDL_Window *window); extern void WIN_GL_DeleteContext(_THIS, SDL_GLContext context); extern void WIN_GL_InitExtensions(_THIS); -extern SDL_bool WIN_GL_SetPixelFormatFrom(_THIS, SDL_Window * fromWindow, SDL_Window * toWindow); +extern SDL_bool WIN_GL_SetPixelFormatFrom(_THIS, SDL_Window *fromWindow, SDL_Window *toWindow); #ifndef WGL_ARB_pixel_format -#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 -#define WGL_DRAW_TO_WINDOW_ARB 0x2001 -#define WGL_DRAW_TO_BITMAP_ARB 0x2002 -#define WGL_ACCELERATION_ARB 0x2003 -#define WGL_NEED_PALETTE_ARB 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 -#define WGL_SWAP_METHOD_ARB 0x2007 -#define WGL_NUMBER_OVERLAYS_ARB 0x2008 -#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 -#define WGL_TRANSPARENT_ARB 0x200A -#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NEED_PALETTE_ARB 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#define WGL_SWAP_METHOD_ARB 0x2007 +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#define WGL_TRANSPARENT_ARB 0x200A +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 #define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 -#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 #define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A #define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B -#define WGL_SHARE_DEPTH_ARB 0x200C -#define WGL_SHARE_STENCIL_ARB 0x200D -#define WGL_SHARE_ACCUM_ARB 0x200E -#define WGL_SUPPORT_GDI_ARB 0x200F -#define WGL_SUPPORT_OPENGL_ARB 0x2010 -#define WGL_DOUBLE_BUFFER_ARB 0x2011 -#define WGL_STEREO_ARB 0x2012 -#define WGL_PIXEL_TYPE_ARB 0x2013 -#define WGL_COLOR_BITS_ARB 0x2014 -#define WGL_RED_BITS_ARB 0x2015 -#define WGL_RED_SHIFT_ARB 0x2016 -#define WGL_GREEN_BITS_ARB 0x2017 -#define WGL_GREEN_SHIFT_ARB 0x2018 -#define WGL_BLUE_BITS_ARB 0x2019 -#define WGL_BLUE_SHIFT_ARB 0x201A -#define WGL_ALPHA_BITS_ARB 0x201B -#define WGL_ALPHA_SHIFT_ARB 0x201C -#define WGL_ACCUM_BITS_ARB 0x201D -#define WGL_ACCUM_RED_BITS_ARB 0x201E -#define WGL_ACCUM_GREEN_BITS_ARB 0x201F -#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 -#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 -#define WGL_DEPTH_BITS_ARB 0x2022 -#define WGL_STENCIL_BITS_ARB 0x2023 -#define WGL_AUX_BUFFERS_ARB 0x2024 -#define WGL_NO_ACCELERATION_ARB 0x2025 -#define WGL_GENERIC_ACCELERATION_ARB 0x2026 -#define WGL_FULL_ACCELERATION_ARB 0x2027 -#define WGL_SWAP_EXCHANGE_ARB 0x2028 -#define WGL_SWAP_COPY_ARB 0x2029 -#define WGL_SWAP_UNDEFINED_ARB 0x202A -#define WGL_TYPE_RGBA_ARB 0x202B -#define WGL_TYPE_COLORINDEX_ARB 0x202C +#define WGL_SHARE_DEPTH_ARB 0x200C +#define WGL_SHARE_STENCIL_ARB 0x200D +#define WGL_SHARE_ACCUM_ARB 0x200E +#define WGL_SUPPORT_GDI_ARB 0x200F +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_STEREO_ARB 0x2012 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_COLOR_BITS_ARB 0x2014 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201A +#define WGL_ALPHA_BITS_ARB 0x201B +#define WGL_ALPHA_SHIFT_ARB 0x201C +#define WGL_ACCUM_BITS_ARB 0x201D +#define WGL_ACCUM_RED_BITS_ARB 0x201E +#define WGL_ACCUM_GREEN_BITS_ARB 0x201F +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_GENERIC_ACCELERATION_ARB 0x2026 +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#define WGL_SWAP_EXCHANGE_ARB 0x2028 +#define WGL_SWAP_COPY_ARB 0x2029 +#define WGL_SWAP_UNDEFINED_ARB 0x202A +#define WGL_TYPE_RGBA_ARB 0x202B +#define WGL_TYPE_COLORINDEX_ARB 0x202C #endif #ifndef WGL_ARB_multisample -#define WGL_SAMPLE_BUFFERS_ARB 0x2041 -#define WGL_SAMPLES_ARB 0x2042 +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 #endif #endif /* SDL_VIDEO_OPENGL_WGL */ diff --git a/src/video/windows/SDL_windowsopengles.c b/src/video/windows/SDL_windowsopengles.c index 1e2a4f620..4d5d86d80 100644 --- a/src/video/windows/SDL_windowsopengles.c +++ b/src/video/windows/SDL_windowsopengles.c @@ -29,8 +29,8 @@ /* EGL implementation of SDL OpenGL support */ -int -WIN_GLES_LoadLibrary(_THIS, const char *path) { +int WIN_GLES_LoadLibrary(_THIS, const char *path) +{ /* If the profile requested is not GL ES, switch over to WIN_GL functions */ if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) { @@ -50,7 +50,7 @@ WIN_GLES_LoadLibrary(_THIS, const char *path) { return SDL_SetError("SDL not configured with OpenGL/WGL support"); #endif } - + if (_this->egl_data == NULL) { return SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, 0); } @@ -59,7 +59,7 @@ WIN_GLES_LoadLibrary(_THIS, const char *path) { } SDL_GLContext -WIN_GLES_CreateContext(_THIS, SDL_Window * window) +WIN_GLES_CreateContext(_THIS, SDL_Window *window) { SDL_GLContext context; SDL_WindowData *data = (SDL_WindowData *)window->driverdata; @@ -90,27 +90,25 @@ WIN_GLES_CreateContext(_THIS, SDL_Window * window) return context; } -void -WIN_GLES_DeleteContext(_THIS, SDL_GLContext context) +void WIN_GLES_DeleteContext(_THIS, SDL_GLContext context) { SDL_EGL_DeleteContext(_this, context); WIN_GLES_UnloadLibrary(_this); } SDL_EGL_SwapWindow_impl(WIN) -SDL_EGL_MakeCurrent_impl(WIN) + SDL_EGL_MakeCurrent_impl(WIN) -int -WIN_GLES_SetupWindow(_THIS, SDL_Window * window) + int WIN_GLES_SetupWindow(_THIS, SDL_Window *window) { /* The current context is lost in here; save it and reset it. */ - SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata; + SDL_WindowData *windowdata = (SDL_WindowData *)window->driverdata; SDL_Window *current_win = SDL_GL_GetCurrentWindow(); SDL_GLContext current_ctx = SDL_GL_GetCurrentContext(); if (_this->egl_data == NULL) { - /* !!! FIXME: commenting out this assertion is (I think) incorrect; figure out why driver_loaded is wrong for ANGLE instead. --ryan. */ - #if 0 /* When hint SDL_HINT_OPENGL_ES_DRIVER is set to "1" (e.g. for ANGLE support), _this->gl_config.driver_loaded can be 1, while the below lines function. */ +/* !!! FIXME: commenting out this assertion is (I think) incorrect; figure out why driver_loaded is wrong for ANGLE instead. --ryan. */ +#if 0 /* When hint SDL_HINT_OPENGL_ES_DRIVER is set to "1" (e.g. for ANGLE support), _this->gl_config.driver_loaded can be 1, while the below lines function. */ SDL_assert(!_this->gl_config.driver_loaded); #endif if (SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, 0) < 0) { @@ -119,7 +117,7 @@ WIN_GLES_SetupWindow(_THIS, SDL_Window * window) } _this->gl_config.driver_loaded = 1; } - + /* Create the GLES window surface */ windowdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType)windowdata->hwnd); @@ -127,7 +125,7 @@ WIN_GLES_SetupWindow(_THIS, SDL_Window * window) return SDL_SetError("Could not create GLES window surface"); } - return WIN_GLES_MakeCurrent(_this, current_win, current_ctx); + return WIN_GLES_MakeCurrent(_this, current_win, current_ctx); } #endif /* SDL_VIDEO_DRIVER_WINDOWS && SDL_VIDEO_OPENGL_EGL */ diff --git a/src/video/windows/SDL_windowsopengles.h b/src/video/windows/SDL_windowsopengles.h index b21c56f4f..78b7ea097 100644 --- a/src/video/windows/SDL_windowsopengles.h +++ b/src/video/windows/SDL_windowsopengles.h @@ -36,9 +36,9 @@ #define WIN_GLES_SetSwapInterval SDL_EGL_SetSwapInterval extern int WIN_GLES_LoadLibrary(_THIS, const char *path); -extern SDL_GLContext WIN_GLES_CreateContext(_THIS, SDL_Window * window); -extern int WIN_GLES_SwapWindow(_THIS, SDL_Window * window); -extern int WIN_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); +extern SDL_GLContext WIN_GLES_CreateContext(_THIS, SDL_Window *window); +extern int WIN_GLES_SwapWindow(_THIS, SDL_Window *window); +extern int WIN_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); extern void WIN_GLES_DeleteContext(_THIS, SDL_GLContext context); extern int WIN_GLES_SetupWindow(_THIS, SDL_Window * window); diff --git a/src/video/windows/SDL_windowsshape.c b/src/video/windows/SDL_windowsshape.c index 64af5a691..5a51664a0 100644 --- a/src/video/windows/SDL_windowsshape.c +++ b/src/video/windows/SDL_windowsshape.c @@ -25,10 +25,11 @@ #include "SDL_windowsshape.h" #include "SDL_windowsvideo.h" -SDL_WindowShaper* -Win32_CreateShaper(SDL_Window * window) { +SDL_WindowShaper * +Win32_CreateShaper(SDL_Window *window) +{ int resized_properly; - SDL_WindowShaper* result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper)); + SDL_WindowShaper *result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper)); if (result == NULL) { SDL_OutOfMemory(); return NULL; @@ -38,7 +39,7 @@ Win32_CreateShaper(SDL_Window * window) { result->mode.parameters.binarizationCutoff = 1; result->userx = result->usery = 0; result->hasshape = SDL_FALSE; - result->driverdata = (SDL_ShapeData*)SDL_calloc(1, sizeof(SDL_ShapeData)); + result->driverdata = (SDL_ShapeData *)SDL_calloc(1, sizeof(SDL_ShapeData)); if (!result->driverdata) { SDL_free(result); SDL_OutOfMemory(); @@ -57,40 +58,40 @@ Win32_CreateShaper(SDL_Window * window) { return result; } -static void -CombineRectRegions(SDL_ShapeTree* node,void* closure) { - HRGN mask_region = *((HRGN*)closure),temp_region = NULL; +static void CombineRectRegions(SDL_ShapeTree *node, void *closure) +{ + HRGN mask_region = *((HRGN *)closure), temp_region = NULL; if (node->kind == OpaqueShape) { /* Win32 API regions exclude their outline, so we widen the region by one pixel in each direction to include the real outline. */ - temp_region = CreateRectRgn(node->data.shape.x,node->data.shape.y,node->data.shape.x + node->data.shape.w + 1,node->data.shape.y + node->data.shape.h + 1); + temp_region = CreateRectRgn(node->data.shape.x, node->data.shape.y, node->data.shape.x + node->data.shape.w + 1, node->data.shape.y + node->data.shape.h + 1); if (mask_region != NULL) { - CombineRgn(mask_region,mask_region,temp_region,RGN_OR); + CombineRgn(mask_region, mask_region, temp_region, RGN_OR); DeleteObject(temp_region); } else - *((HRGN*)closure) = temp_region; + *((HRGN *)closure) = temp_region; } } -int -Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) { +int Win32_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode) +{ SDL_ShapeData *data; HRGN mask_region = NULL; - if ( (shaper == NULL) || + if ((shaper == NULL) || (shape == NULL) || ((shape->format->Amask == 0) && (shape_mode->mode != ShapeModeColorKey)) || (shape->w != shaper->window->w) || - (shape->h != shaper->window->h) ) { + (shape->h != shaper->window->h)) { return SDL_INVALID_SHAPE_ARGUMENT; } - data = (SDL_ShapeData*)shaper->driverdata; + data = (SDL_ShapeData *)shaper->driverdata; if (data->mask_tree != NULL) { SDL_FreeShapeTree(&data->mask_tree); } - data->mask_tree = SDL_CalculateShapeTree(*shape_mode,shape); + data->mask_tree = SDL_CalculateShapeTree(*shape_mode, shape); - SDL_TraverseShapeTree(data->mask_tree,&CombineRectRegions,&mask_region); + SDL_TraverseShapeTree(data->mask_tree, &CombineRectRegions, &mask_region); SDL_assert(mask_region != NULL); SetWindowRgn(((SDL_WindowData *)(shaper->window->driverdata))->hwnd, mask_region, TRUE); @@ -98,9 +99,9 @@ Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShape return 0; } -int -Win32_ResizeWindowShape(SDL_Window *window) { - SDL_ShapeData* data; +int Win32_ResizeWindowShape(SDL_Window *window) +{ + SDL_ShapeData *data; if (window == NULL) { return -1; @@ -116,7 +117,7 @@ Win32_ResizeWindowShape(SDL_Window *window) { if (window->shaper->hasshape == SDL_TRUE) { window->shaper->userx = window->x; window->shaper->usery = window->y; - SDL_SetWindowPosition(window,-1000,-1000); + SDL_SetWindowPosition(window, -1000, -1000); } return 0; diff --git a/src/video/windows/SDL_windowsshape.h b/src/video/windows/SDL_windowsshape.h index 982807357..18e89fff2 100644 --- a/src/video/windows/SDL_windowsshape.h +++ b/src/video/windows/SDL_windowsshape.h @@ -29,12 +29,13 @@ #include "../SDL_sysvideo.h" #include "../SDL_shape_internals.h" -typedef struct { +typedef struct +{ SDL_ShapeTree *mask_tree; } SDL_ShapeData; -extern SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window); -extern int Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode); +extern SDL_WindowShaper *Win32_CreateShaper(SDL_Window *window); +extern int Win32_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode); extern int Win32_ResizeWindowShape(SDL_Window *window); #endif /* SDL_windowsshape_h_ */ diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index 54cdd72cf..5c8ef429d 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -45,8 +45,7 @@ static void WIN_VideoQuit(_THIS); SDL_bool g_WindowsEnableMessageLoop = SDL_TRUE; SDL_bool g_WindowFrameUsableWhileCursorHidden = SDL_TRUE; -static void SDLCALL -UpdateWindowsEnableMessageLoop(void *userdata, const char *name, const char *oldValue, const char *newValue) +static void SDLCALL UpdateWindowsEnableMessageLoop(void *userdata, const char *name, const char *oldValue, const char *newValue) { if (newValue && *newValue == '0') { g_WindowsEnableMessageLoop = SDL_FALSE; @@ -55,8 +54,7 @@ UpdateWindowsEnableMessageLoop(void *userdata, const char *name, const char *old } } -static void SDLCALL -UpdateWindowFrameUsableWhileCursorHidden(void *userdata, const char *name, const char *oldValue, const char *newValue) +static void SDLCALL UpdateWindowFrameUsableWhileCursorHidden(void *userdata, const char *name, const char *oldValue, const char *newValue) { if (newValue && *newValue == '0') { g_WindowFrameUsableWhileCursorHidden = SDL_FALSE; @@ -80,13 +78,11 @@ static void WIN_SuspendScreenSaver(_THIS) extern void D3D12_XBOX_GetResolution(Uint32 *width, Uint32 *height); #endif - /* Windows driver bootstrap functions */ -static void -WIN_DeleteDevice(SDL_VideoDevice * device) +static void WIN_DeleteDevice(SDL_VideoDevice *device) { - SDL_VideoData *data = (SDL_VideoData *) device->driverdata; + SDL_VideoData *data = (SDL_VideoData *)device->driverdata; SDL_UnregisterApp(); #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) @@ -104,8 +100,7 @@ WIN_DeleteDevice(SDL_VideoDevice * device) SDL_free(device); } -static SDL_VideoDevice * -WIN_CreateDevice(void) +static SDL_VideoDevice *WIN_CreateDevice(void) { SDL_VideoDevice *device; SDL_VideoData *data; @@ -113,9 +108,9 @@ WIN_CreateDevice(void) SDL_RegisterApp(NULL, 0, NULL); /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device) { - data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); + data = (struct SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); } else { data = NULL; } @@ -130,27 +125,31 @@ WIN_CreateDevice(void) #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) data->userDLL = SDL_LoadObject("USER32.DLL"); if (data->userDLL) { - data->CloseTouchInputHandle = (BOOL (WINAPI *)(HTOUCHINPUT)) SDL_LoadFunction(data->userDLL, "CloseTouchInputHandle"); + /* *INDENT-OFF* */ /* clang-format off */ + data->CloseTouchInputHandle = (BOOL (WINAPI *)(HTOUCHINPUT))SDL_LoadFunction(data->userDLL, "CloseTouchInputHandle"); data->GetTouchInputInfo = (BOOL (WINAPI *)(HTOUCHINPUT, UINT, PTOUCHINPUT, int)) SDL_LoadFunction(data->userDLL, "GetTouchInputInfo"); - data->RegisterTouchWindow = (BOOL (WINAPI *)(HWND, ULONG)) SDL_LoadFunction(data->userDLL, "RegisterTouchWindow"); - data->SetProcessDPIAware = (BOOL (WINAPI *)(void)) SDL_LoadFunction(data->userDLL, "SetProcessDPIAware"); - data->SetProcessDpiAwarenessContext = (BOOL (WINAPI *)(DPI_AWARENESS_CONTEXT)) SDL_LoadFunction(data->userDLL, "SetProcessDpiAwarenessContext"); - data->SetThreadDpiAwarenessContext = (DPI_AWARENESS_CONTEXT (WINAPI *)(DPI_AWARENESS_CONTEXT)) SDL_LoadFunction(data->userDLL, "SetThreadDpiAwarenessContext"); - data->GetThreadDpiAwarenessContext = (DPI_AWARENESS_CONTEXT (WINAPI *)(void)) SDL_LoadFunction(data->userDLL, "GetThreadDpiAwarenessContext"); - data->GetAwarenessFromDpiAwarenessContext = (DPI_AWARENESS (WINAPI *)(DPI_AWARENESS_CONTEXT)) SDL_LoadFunction(data->userDLL, "GetAwarenessFromDpiAwarenessContext"); - data->EnableNonClientDpiScaling = (BOOL (WINAPI *)(HWND)) SDL_LoadFunction(data->userDLL, "EnableNonClientDpiScaling"); - data->AdjustWindowRectExForDpi = (BOOL (WINAPI *)(LPRECT, DWORD, BOOL, DWORD, UINT)) SDL_LoadFunction(data->userDLL, "AdjustWindowRectExForDpi"); - data->GetDpiForWindow = (UINT (WINAPI *)(HWND)) SDL_LoadFunction(data->userDLL, "GetDpiForWindow"); - data->AreDpiAwarenessContextsEqual = (BOOL (WINAPI *)(DPI_AWARENESS_CONTEXT, DPI_AWARENESS_CONTEXT)) SDL_LoadFunction(data->userDLL, "AreDpiAwarenessContextsEqual"); - data->IsValidDpiAwarenessContext = (BOOL (WINAPI *)(DPI_AWARENESS_CONTEXT)) SDL_LoadFunction(data->userDLL, "IsValidDpiAwarenessContext"); + data->RegisterTouchWindow = (BOOL (WINAPI *)(HWND, ULONG))SDL_LoadFunction(data->userDLL, "RegisterTouchWindow"); + data->SetProcessDPIAware = (BOOL (WINAPI *)(void))SDL_LoadFunction(data->userDLL, "SetProcessDPIAware"); + data->SetProcessDpiAwarenessContext = (BOOL (WINAPI *)(DPI_AWARENESS_CONTEXT))SDL_LoadFunction(data->userDLL, "SetProcessDpiAwarenessContext"); + data->SetThreadDpiAwarenessContext = (DPI_AWARENESS_CONTEXT (WINAPI *)(DPI_AWARENESS_CONTEXT))SDL_LoadFunction(data->userDLL, "SetThreadDpiAwarenessContext"); + data->GetThreadDpiAwarenessContext = (DPI_AWARENESS_CONTEXT (WINAPI *)(void))SDL_LoadFunction(data->userDLL, "GetThreadDpiAwarenessContext"); + data->GetAwarenessFromDpiAwarenessContext = (DPI_AWARENESS (WINAPI *)(DPI_AWARENESS_CONTEXT))SDL_LoadFunction(data->userDLL, "GetAwarenessFromDpiAwarenessContext"); + data->EnableNonClientDpiScaling = (BOOL (WINAPI *)(HWND))SDL_LoadFunction(data->userDLL, "EnableNonClientDpiScaling"); + data->AdjustWindowRectExForDpi = (BOOL (WINAPI *)(LPRECT, DWORD, BOOL, DWORD, UINT))SDL_LoadFunction(data->userDLL, "AdjustWindowRectExForDpi"); + data->GetDpiForWindow = (UINT (WINAPI *)(HWND))SDL_LoadFunction(data->userDLL, "GetDpiForWindow"); + data->AreDpiAwarenessContextsEqual = (BOOL (WINAPI *)(DPI_AWARENESS_CONTEXT, DPI_AWARENESS_CONTEXT))SDL_LoadFunction(data->userDLL, "AreDpiAwarenessContextsEqual"); + data->IsValidDpiAwarenessContext = (BOOL (WINAPI *)(DPI_AWARENESS_CONTEXT))SDL_LoadFunction(data->userDLL, "IsValidDpiAwarenessContext"); + /* *INDENT-ON* */ /* clang-format on */ } else { SDL_ClearError(); } data->shcoreDLL = SDL_LoadObject("SHCORE.DLL"); if (data->shcoreDLL) { - data->GetDpiForMonitor = (HRESULT (WINAPI *)(HMONITOR, MONITOR_DPI_TYPE, UINT *, UINT *)) SDL_LoadFunction(data->shcoreDLL, "GetDpiForMonitor"); - data->SetProcessDpiAwareness = (HRESULT (WINAPI *)(PROCESS_DPI_AWARENESS)) SDL_LoadFunction(data->shcoreDLL, "SetProcessDpiAwareness"); + /* *INDENT-OFF* */ /* clang-format off */ + data->GetDpiForMonitor = (HRESULT (WINAPI *)(HMONITOR, MONITOR_DPI_TYPE, UINT *, UINT *))SDL_LoadFunction(data->shcoreDLL, "GetDpiForMonitor"); + data->SetProcessDpiAwareness = (HRESULT (WINAPI *)(PROCESS_DPI_AWARENESS))SDL_LoadFunction(data->shcoreDLL, "SetProcessDpiAwareness"); + /* *INDENT-ON* */ /* clang-format on */ } else { SDL_ClearError(); } @@ -262,16 +261,14 @@ WIN_CreateDevice(void) return device; } - VideoBootStrap WINDOWS_bootstrap = { "windows", "SDL Windows video driver", WIN_CreateDevice }; -static BOOL -WIN_DeclareDPIAwareUnaware(_THIS) +static BOOL WIN_DeclareDPIAwareUnaware(_THIS) { #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) - SDL_VideoData* data = (SDL_VideoData*)_this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; if (data->SetProcessDpiAwarenessContext) { return data->SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE); @@ -283,11 +280,10 @@ WIN_DeclareDPIAwareUnaware(_THIS) return FALSE; } -static BOOL -WIN_DeclareDPIAwareSystem(_THIS) +static BOOL WIN_DeclareDPIAwareSystem(_THIS) { #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) - SDL_VideoData* data = (SDL_VideoData*)_this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; if (data->SetProcessDpiAwarenessContext) { /* Windows 10, version 1607 */ @@ -303,11 +299,10 @@ WIN_DeclareDPIAwareSystem(_THIS) return FALSE; } -static BOOL -WIN_DeclareDPIAwarePerMonitor(_THIS) +static BOOL WIN_DeclareDPIAwarePerMonitor(_THIS) { #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; if (data->SetProcessDpiAwarenessContext) { /* Windows 10, version 1607 */ @@ -323,13 +318,12 @@ WIN_DeclareDPIAwarePerMonitor(_THIS) return FALSE; } -static BOOL -WIN_DeclareDPIAwarePerMonitorV2(_THIS) +static BOOL WIN_DeclareDPIAwarePerMonitorV2(_THIS) { #if defined(__XBOXONE__) || defined(__XBOXSERIES__) return FALSE; #else - SDL_VideoData* data = (SDL_VideoData*)_this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; /* Declare DPI aware (may have been done in external code or a manifest, as well) */ if (data->SetProcessDpiAwarenessContext) { @@ -339,7 +333,7 @@ WIN_DeclareDPIAwarePerMonitorV2(_THIS) end up still getting OS scaled. (tested on Windows 10 21H1 19043.1348, NVIDIA 496.49) NOTE: Enabling DPI awareness through Windows Explorer - (right click .exe -> Properties -> Compatibility -> High DPI Settings -> + (right click .exe -> Properties -> Compatibility -> High DPI Settings -> check "Override high DPI Scaling behaviour", select Application) gives a DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE context (at least on Windows 10 21H1), and setting DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 will fail. @@ -363,10 +357,9 @@ WIN_DeclareDPIAwarePerMonitorV2(_THIS) } #ifdef HIGHDPI_DEBUG -static const char* -WIN_GetDPIAwareness(_THIS) +static const char *WIN_GetDPIAwareness(_THIS) { - SDL_VideoData* data = (SDL_VideoData*)_this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; if (data->GetThreadDpiAwarenessContext && data->AreDpiAwarenessContextsEqual) { DPI_AWARENESS_CONTEXT context = data->GetThreadDpiAwarenessContext(); @@ -388,10 +381,9 @@ WIN_GetDPIAwareness(_THIS) } #endif -static void -WIN_InitDPIAwareness(_THIS) +static void WIN_InitDPIAwareness(_THIS) { - const char* hint = SDL_GetHint(SDL_HINT_WINDOWS_DPI_AWARENESS); + const char *hint = SDL_GetHint(SDL_HINT_WINDOWS_DPI_AWARENESS); if (hint != NULL) { if (SDL_strcmp(hint, "permonitorv2") == 0) { @@ -406,10 +398,9 @@ WIN_InitDPIAwareness(_THIS) } } -static void -WIN_InitDPIScaling(_THIS) +static void WIN_InitDPIScaling(_THIS) { - SDL_VideoData* data = (SDL_VideoData*)_this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; if (SDL_GetHintBoolean(SDL_HINT_WINDOWS_DPI_SCALING, SDL_FALSE)) { WIN_DeclareDPIAwarePerMonitorV2(_this); @@ -418,10 +409,9 @@ WIN_InitDPIScaling(_THIS) } } -int -WIN_VideoInit(_THIS) +int WIN_VideoInit(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; WIN_InitDPIAwareness(_this); WIN_InitDPIScaling(_this); @@ -444,7 +434,7 @@ WIN_VideoInit(_THIS) SDL_zero(display); display.desktop_mode = current_mode; display.current_mode = current_mode; - + SDL_AddVideoDisplay(&display, SDL_FALSE); } #else /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ @@ -466,8 +456,7 @@ WIN_VideoInit(_THIS) return 0; } -void -WIN_VideoQuit(_THIS) +void WIN_VideoQuit(_THIS) { #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) WIN_QuitModes(_this); @@ -476,7 +465,6 @@ WIN_VideoQuit(_THIS) #endif } - #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #define D3D_DEBUG_INFO #include @@ -502,20 +490,22 @@ D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface) { *pD3DDLL = SDL_LoadObject("D3D9.DLL"); if (*pD3DDLL) { - typedef IDirect3D9 *(WINAPI *Direct3DCreate9_t) (UINT SDKVersion); + /* *INDENT-OFF* */ /* clang-format off */ + typedef IDirect3D9 *(WINAPI *Direct3DCreate9_t)(UINT SDKVersion); + typedef HRESULT (WINAPI* Direct3DCreate9Ex_t)(UINT SDKVersion, IDirect3D9Ex** ppD3D); + /* *INDENT-ON* */ /* clang-format on */ Direct3DCreate9_t Direct3DCreate9Func; if (SDL_GetHintBoolean(SDL_HINT_WINDOWS_USE_D3D9EX, SDL_FALSE)) { - typedef HRESULT(WINAPI* Direct3DCreate9Ex_t)(UINT SDKVersion, IDirect3D9Ex** ppD3D); Direct3DCreate9Ex_t Direct3DCreate9ExFunc; Direct3DCreate9ExFunc = (Direct3DCreate9Ex_t)SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9Ex"); if (Direct3DCreate9ExFunc) { - IDirect3D9Ex* pDirect3D9ExInterface; + IDirect3D9Ex *pDirect3D9ExInterface; HRESULT hr = Direct3DCreate9ExFunc(D3D_SDK_VERSION, &pDirect3D9ExInterface); if (SUCCEEDED(hr)) { const GUID IDirect3D9_GUID = { 0x81bdcbca, 0x64d4, 0x426d, { 0xae, 0x8d, 0xad, 0x1, 0x47, 0xf4, 0x27, 0x5c } }; - hr = IDirect3D9Ex_QueryInterface(pDirect3D9ExInterface, &IDirect3D9_GUID, (void**)pDirect3D9Interface); + hr = IDirect3D9Ex_QueryInterface(pDirect3D9ExInterface, &IDirect3D9_GUID, (void **)pDirect3D9Interface); IDirect3D9Ex_Release(pDirect3D9ExInterface); if (SUCCEEDED(hr)) { return SDL_TRUE; @@ -539,9 +529,7 @@ D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface) return SDL_FALSE; } - -int -SDL_Direct3D9GetAdapterIndex(int displayIndex) +int SDL_Direct3D9GetAdapterIndex(int displayIndex) { void *pD3DDLL; IDirect3D9 *pD3D; @@ -559,7 +547,7 @@ SDL_Direct3D9GetAdapterIndex(int displayIndex) char *displayName = WIN_StringToUTF8W(pData->DeviceName); unsigned int count = IDirect3D9_GetAdapterCount(pD3D); unsigned int i; - for (i=0; i -static SDL_bool -DXGI_LoadDLL(void **pDXGIDLL, IDXGIFactory **pDXGIFactory) +static SDL_bool DXGI_LoadDLL(void **pDXGIDLL, IDXGIFactory **pDXGIFactory) { *pDXGIDLL = SDL_LoadObject("DXGI.DLL"); if (*pDXGIDLL) { - HRESULT (WINAPI *CreateDXGI)(REFIID riid, void **ppFactory); + /* *INDENT-OFF* */ /* clang-format off */ + typedef HRESULT (WINAPI *CreateDXGI_t)(REFIID riid, void **ppFactory); + /* *INDENT-ON* */ /* clang-format on */ + CreateDXGI_t CreateDXGI; - CreateDXGI = - (HRESULT (WINAPI *) (REFIID, void**)) SDL_LoadFunction(*pDXGIDLL, - "CreateDXGIFactory"); + CreateDXGI = (CreateDXGI_t)SDL_LoadFunction(*pDXGIDLL, "CreateDXGIFactory"); if (CreateDXGI) { - GUID dxgiGUID = {0x7b7166ec,0x21c7,0x44ae,{0xb2,0x1a,0xc9,0xae,0x32,0x1a,0xe3,0x69}}; - if (!SUCCEEDED(CreateDXGI(&dxgiGUID, (void**)pDXGIFactory))) { + GUID dxgiGUID = { 0x7b7166ec, 0x21c7, 0x44ae, { 0xb2, 0x1a, 0xc9, 0xae, 0x32, 0x1a, 0xe3, 0x69 } }; + if (!SUCCEEDED(CreateDXGI(&dxgiGUID, (void **)pDXGIFactory))) { *pDXGIFactory = NULL; } } @@ -615,7 +603,6 @@ DXGI_LoadDLL(void **pDXGIDLL, IDXGIFactory **pDXGIFactory) } #endif - SDL_bool SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputIndex) { @@ -635,7 +622,7 @@ SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputIndex) int nAdapter, nOutput; IDXGIFactory *pDXGIFactory = NULL; IDXGIAdapter *pDXGIAdapter; - IDXGIOutput* pDXGIOutput; + IDXGIOutput *pDXGIOutput; if (adapterIndex == NULL) { SDL_InvalidParamError("adapterIndex"); @@ -698,8 +685,8 @@ SDL_bool WIN_IsPerMonitorV2DPIAware(_THIS) { #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) - SDL_VideoData* data = (SDL_VideoData*) _this->driverdata; - + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; + if (data->AreDpiAwarenessContextsEqual && data->GetThreadDpiAwarenessContext) { /* Windows 10, version 1607 */ return (SDL_bool)data->AreDpiAwarenessContextsEqual(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2, diff --git a/src/video/windows/SDL_windowsvideo.h b/src/video/windows/SDL_windowsvideo.h index cdebb4cfa..c49b0bb62 100644 --- a/src/video/windows/SDL_windowsvideo.h +++ b/src/video/windows/SDL_windowsvideo.h @@ -35,9 +35,9 @@ #include -#define MAX_CANDLIST 10 -#define MAX_CANDLENGTH 256 -#define MAX_CANDSIZE (sizeof(WCHAR) * MAX_CANDLIST * MAX_CANDLENGTH) +#define MAX_CANDLIST 10 +#define MAX_CANDLENGTH 256 +#define MAX_CANDSIZE (sizeof(WCHAR) * MAX_CANDLIST * MAX_CANDLENGTH) #include "SDL_windowsclipboard.h" #include "SDL_windowsevents.h" @@ -54,11 +54,10 @@ #include "SDL_events.h" #include "SDL_loadso.h" - #if WINVER < 0x0601 /* Touch input definitions */ -#define TWF_FINETOUCH 1 -#define TWF_WANTPALM 2 +#define TWF_FINETOUCH 1 +#define TWF_WANTPALM 2 #define TOUCHEVENTF_MOVE 0x0001 #define TOUCHEVENTF_DOWN 0x0002 @@ -66,78 +65,78 @@ DECLARE_HANDLE(HTOUCHINPUT); -typedef struct _TOUCHINPUT { - LONG x; - LONG y; - HANDLE hSource; - DWORD dwID; - DWORD dwFlags; - DWORD dwMask; - DWORD dwTime; +typedef struct _TOUCHINPUT +{ + LONG x; + LONG y; + HANDLE hSource; + DWORD dwID; + DWORD dwFlags; + DWORD dwMask; + DWORD dwTime; ULONG_PTR dwExtraInfo; - DWORD cxContact; - DWORD cyContact; + DWORD cxContact; + DWORD cyContact; } TOUCHINPUT, *PTOUCHINPUT; - /* More-robust display information in Vista... */ /* This is a huge amount of data to be stuffing into three API calls. :( */ typedef struct DISPLAYCONFIG_PATH_SOURCE_INFO { - LUID adapterId; - UINT32 id; + LUID adapterId; + UINT32 id; union { UINT32 modeInfoIdx; struct { - UINT32 cloneGroupId : 16; - UINT32 sourceModeInfoIdx : 16; + UINT32 cloneGroupId : 16; + UINT32 sourceModeInfoIdx : 16; } DUMMYSTRUCTNAME; } DUMMYUNIONNAME; - UINT32 statusFlags; + UINT32 statusFlags; } DISPLAYCONFIG_PATH_SOURCE_INFO; typedef struct DISPLAYCONFIG_RATIONAL { - UINT32 Numerator; - UINT32 Denominator; + UINT32 Numerator; + UINT32 Denominator; } DISPLAYCONFIG_RATIONAL; typedef struct DISPLAYCONFIG_PATH_TARGET_INFO { - LUID adapterId; - UINT32 id; + LUID adapterId; + UINT32 id; union { - UINT32 modeInfoIdx; + UINT32 modeInfoIdx; struct { UINT32 desktopModeInfoIdx : 16; - UINT32 targetModeInfoIdx : 16; + UINT32 targetModeInfoIdx : 16; } DUMMYSTRUCTNAME; } DUMMYUNIONNAME; - UINT32 /*DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY*/ outputTechnology; - UINT32 /*DISPLAYCONFIG_ROTATION*/ rotation; - UINT32 /*DISPLAYCONFIG_SCALING*/ scaling; - DISPLAYCONFIG_RATIONAL refreshRate; - UINT32 /*DISPLAYCONFIG_SCANLINE_ORDERING*/ scanLineOrdering; - BOOL targetAvailable; - UINT32 statusFlags; + UINT32 /*DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY*/ outputTechnology; + UINT32 /*DISPLAYCONFIG_ROTATION*/ rotation; + UINT32 /*DISPLAYCONFIG_SCALING*/ scaling; + DISPLAYCONFIG_RATIONAL refreshRate; + UINT32 /*DISPLAYCONFIG_SCANLINE_ORDERING*/ scanLineOrdering; + BOOL targetAvailable; + UINT32 statusFlags; } DISPLAYCONFIG_PATH_TARGET_INFO; typedef struct DISPLAYCONFIG_PATH_INFO { - DISPLAYCONFIG_PATH_SOURCE_INFO sourceInfo; - DISPLAYCONFIG_PATH_TARGET_INFO targetInfo; - UINT32 flags; + DISPLAYCONFIG_PATH_SOURCE_INFO sourceInfo; + DISPLAYCONFIG_PATH_TARGET_INFO targetInfo; + UINT32 flags; } DISPLAYCONFIG_PATH_INFO; typedef enum { - DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE = 1, - DISPLAYCONFIG_MODE_INFO_TYPE_TARGET = 2, + DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE = 1, + DISPLAYCONFIG_MODE_INFO_TYPE_TARGET = 2, DISPLAYCONFIG_MODE_INFO_TYPE_DESKTOP_IMAGE = 3, DISPLAYCONFIG_MODE_INFO_TYPE_FORCE_UINT32 = 0xFFFFFFFF } DISPLAYCONFIG_MODE_INFO_TYPE; @@ -150,11 +149,11 @@ typedef struct DISPLAYCONFIG_2DREGION typedef struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO { - UINT64 pixelRate; - DISPLAYCONFIG_RATIONAL hSyncFreq; - DISPLAYCONFIG_RATIONAL vSyncFreq; - DISPLAYCONFIG_2DREGION activeSize; - DISPLAYCONFIG_2DREGION totalSize; + UINT64 pixelRate; + DISPLAYCONFIG_RATIONAL hSyncFreq; + DISPLAYCONFIG_RATIONAL vSyncFreq; + DISPLAYCONFIG_2DREGION activeSize; + DISPLAYCONFIG_2DREGION totalSize; union { @@ -177,15 +176,15 @@ typedef struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO typedef struct DISPLAYCONFIG_SOURCE_MODE { - UINT32 width; - UINT32 height; - UINT32 /*DISPLAYCONFIG_PIXELFORMAT*/ pixelFormat; - POINTL position; + UINT32 width; + UINT32 height; + UINT32 /*DISPLAYCONFIG_PIXELFORMAT*/ pixelFormat; + POINTL position; } DISPLAYCONFIG_SOURCE_MODE; typedef struct DISPLAYCONFIG_TARGET_MODE { - DISPLAYCONFIG_VIDEO_SIGNAL_INFO targetVideoSignalInfo; + DISPLAYCONFIG_VIDEO_SIGNAL_INFO targetVideoSignalInfo; } DISPLAYCONFIG_TARGET_MODE; typedef struct DISPLAYCONFIG_DESKTOP_IMAGE_INFO @@ -197,54 +196,54 @@ typedef struct DISPLAYCONFIG_DESKTOP_IMAGE_INFO typedef struct DISPLAYCONFIG_MODE_INFO { - DISPLAYCONFIG_MODE_INFO_TYPE infoType; - UINT32 id; - LUID adapterId; + DISPLAYCONFIG_MODE_INFO_TYPE infoType; + UINT32 id; + LUID adapterId; union { - DISPLAYCONFIG_TARGET_MODE targetMode; - DISPLAYCONFIG_SOURCE_MODE sourceMode; - DISPLAYCONFIG_DESKTOP_IMAGE_INFO desktopImageInfo; + DISPLAYCONFIG_TARGET_MODE targetMode; + DISPLAYCONFIG_SOURCE_MODE sourceMode; + DISPLAYCONFIG_DESKTOP_IMAGE_INFO desktopImageInfo; } DUMMYUNIONNAME; } DISPLAYCONFIG_MODE_INFO; typedef enum DISPLAYCONFIG_TOPOLOGY_ID { - DISPLAYCONFIG_TOPOLOGY_INTERNAL = 0x00000001, - DISPLAYCONFIG_TOPOLOGY_CLONE = 0x00000002, - DISPLAYCONFIG_TOPOLOGY_EXTEND = 0x00000004, - DISPLAYCONFIG_TOPOLOGY_EXTERNAL = 0x00000008, - DISPLAYCONFIG_TOPOLOGY_FORCE_UINT32 = 0xFFFFFFFF + DISPLAYCONFIG_TOPOLOGY_INTERNAL = 0x00000001, + DISPLAYCONFIG_TOPOLOGY_CLONE = 0x00000002, + DISPLAYCONFIG_TOPOLOGY_EXTEND = 0x00000004, + DISPLAYCONFIG_TOPOLOGY_EXTERNAL = 0x00000008, + DISPLAYCONFIG_TOPOLOGY_FORCE_UINT32 = 0xFFFFFFFF } DISPLAYCONFIG_TOPOLOGY_ID; typedef enum { - DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME = 1, - DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME = 2, - DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_PREFERRED_MODE = 3, - DISPLAYCONFIG_DEVICE_INFO_GET_ADAPTER_NAME = 4, - DISPLAYCONFIG_DEVICE_INFO_SET_TARGET_PERSISTENCE = 5, - DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_BASE_TYPE = 6, - DISPLAYCONFIG_DEVICE_INFO_GET_SUPPORT_VIRTUAL_RESOLUTION = 7, - DISPLAYCONFIG_DEVICE_INFO_SET_SUPPORT_VIRTUAL_RESOLUTION = 8, - DISPLAYCONFIG_DEVICE_INFO_GET_ADVANCED_COLOR_INFO = 9, - DISPLAYCONFIG_DEVICE_INFO_SET_ADVANCED_COLOR_STATE = 10, - DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL = 11, - DISPLAYCONFIG_DEVICE_INFO_FORCE_UINT32 = 0xFFFFFFFF + DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME = 1, + DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME = 2, + DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_PREFERRED_MODE = 3, + DISPLAYCONFIG_DEVICE_INFO_GET_ADAPTER_NAME = 4, + DISPLAYCONFIG_DEVICE_INFO_SET_TARGET_PERSISTENCE = 5, + DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_BASE_TYPE = 6, + DISPLAYCONFIG_DEVICE_INFO_GET_SUPPORT_VIRTUAL_RESOLUTION = 7, + DISPLAYCONFIG_DEVICE_INFO_SET_SUPPORT_VIRTUAL_RESOLUTION = 8, + DISPLAYCONFIG_DEVICE_INFO_GET_ADVANCED_COLOR_INFO = 9, + DISPLAYCONFIG_DEVICE_INFO_SET_ADVANCED_COLOR_STATE = 10, + DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL = 11, + DISPLAYCONFIG_DEVICE_INFO_FORCE_UINT32 = 0xFFFFFFFF } DISPLAYCONFIG_DEVICE_INFO_TYPE; typedef struct DISPLAYCONFIG_DEVICE_INFO_HEADER { - DISPLAYCONFIG_DEVICE_INFO_TYPE type; - UINT32 size; - LUID adapterId; - UINT32 id; + DISPLAYCONFIG_DEVICE_INFO_TYPE type; + UINT32 size; + LUID adapterId; + UINT32 id; } DISPLAYCONFIG_DEVICE_INFO_HEADER; typedef struct DISPLAYCONFIG_SOURCE_DEVICE_NAME { - DISPLAYCONFIG_DEVICE_INFO_HEADER header; - WCHAR viewGdiDeviceName[CCHDEVICENAME]; + DISPLAYCONFIG_DEVICE_INFO_HEADER header; + WCHAR viewGdiDeviceName[CCHDEVICENAME]; } DISPLAYCONFIG_SOURCE_DEVICE_NAME; typedef struct DISPLAYCONFIG_TARGET_DEVICE_NAME_FLAGS @@ -253,41 +252,43 @@ typedef struct DISPLAYCONFIG_TARGET_DEVICE_NAME_FLAGS { struct { - UINT32 friendlyNameFromEdid : 1; - UINT32 friendlyNameForced : 1; - UINT32 edidIdsValid : 1; - UINT32 reserved : 29; + UINT32 friendlyNameFromEdid : 1; + UINT32 friendlyNameForced : 1; + UINT32 edidIdsValid : 1; + UINT32 reserved : 29; } DUMMYSTRUCTNAME; - UINT32 value; + UINT32 value; } DUMMYUNIONNAME; } DISPLAYCONFIG_TARGET_DEVICE_NAME_FLAGS; typedef struct DISPLAYCONFIG_TARGET_DEVICE_NAME { - DISPLAYCONFIG_DEVICE_INFO_HEADER header; - DISPLAYCONFIG_TARGET_DEVICE_NAME_FLAGS flags; - UINT32 /*DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY*/ outputTechnology; - UINT16 edidManufactureId; - UINT16 edidProductCodeId; - UINT32 connectorInstance; - WCHAR monitorFriendlyDeviceName[64]; - WCHAR monitorDevicePath[128]; + DISPLAYCONFIG_DEVICE_INFO_HEADER header; + DISPLAYCONFIG_TARGET_DEVICE_NAME_FLAGS flags; + UINT32 /*DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY*/ outputTechnology; + UINT16 edidManufactureId; + UINT16 edidProductCodeId; + UINT32 connectorInstance; + WCHAR monitorFriendlyDeviceName[64]; + WCHAR monitorDevicePath[128]; } DISPLAYCONFIG_TARGET_DEVICE_NAME; -#define QDC_ONLY_ACTIVE_PATHS 0x00000002 +#define QDC_ONLY_ACTIVE_PATHS 0x00000002 #endif /* WINVER < 0x0601 */ #ifndef HAVE_SHELLSCALINGAPI_H -typedef enum MONITOR_DPI_TYPE { +typedef enum MONITOR_DPI_TYPE +{ MDT_EFFECTIVE_DPI = 0, MDT_ANGULAR_DPI = 1, MDT_RAW_DPI = 2, MDT_DEFAULT = MDT_EFFECTIVE_DPI } MONITOR_DPI_TYPE; -typedef enum PROCESS_DPI_AWARENESS { +typedef enum PROCESS_DPI_AWARENESS +{ PROCESS_DPI_UNAWARE = 0, PROCESS_SYSTEM_DPI_AWARE = 1, PROCESS_PER_MONITOR_DPI_AWARE = 2 @@ -299,7 +300,8 @@ typedef enum PROCESS_DPI_AWARENESS { #ifndef _DPI_AWARENESS_CONTEXTS_ -typedef enum DPI_AWARENESS { +typedef enum DPI_AWARENESS +{ DPI_AWARENESS_INVALID = -1, DPI_AWARENESS_UNAWARE = 0, DPI_AWARENESS_SYSTEM_AWARE = 1, @@ -324,8 +326,8 @@ DECLARE_HANDLE(DPI_AWARENESS_CONTEXT); #define DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED ((DPI_AWARENESS_CONTEXT)-5) #endif /* NTDDI_VERSION < 0x0A000006 */ -typedef BOOL (*PFNSHFullScreen)(HWND, DWORD); -typedef void (*PFCoordTransform)(SDL_Window*, POINT*); +typedef BOOL (*PFNSHFullScreen)(HWND, DWORD); +typedef void (*PFCoordTransform)(SDL_Window *, POINT *); typedef struct { @@ -336,14 +338,16 @@ typedef struct #ifndef SDL_DISABLE_WINDOWS_IME /* Definition from Win98DDK version of IMM.H */ -typedef struct tagINPUTCONTEXT2 { +typedef struct tagINPUTCONTEXT2 +{ HWND hWnd; BOOL fOpen; POINT ptStatusWndPos; POINT ptSoftKbdPos; DWORD fdwConversion; DWORD fdwSentence; - union { + union + { LOGFONTA A; LOGFONTW W; } lfFont; @@ -370,7 +374,8 @@ typedef struct SDL_VideoData #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* Xbox doesn't support user32/shcore*/ /* Touch input functions */ - void* userDLL; + void *userDLL; + /* *INDENT-OFF* */ /* clang-format off */ BOOL (WINAPI *CloseTouchInputHandle)( HTOUCHINPUT ); BOOL (WINAPI *GetTouchInputInfo)( HTOUCHINPUT, UINT, PTOUCHINPUT, int ); BOOL (WINAPI *RegisterTouchWindow)( HWND, ULONG ); @@ -384,19 +389,22 @@ typedef struct SDL_VideoData UINT (WINAPI *GetDpiForWindow)( HWND ); BOOL (WINAPI *AreDpiAwarenessContextsEqual)(DPI_AWARENESS_CONTEXT, DPI_AWARENESS_CONTEXT); BOOL (WINAPI *IsValidDpiAwarenessContext)(DPI_AWARENESS_CONTEXT); + /* *INDENT-ON* */ /* clang-format on */ - void* shcoreDLL; + void *shcoreDLL; + /* *INDENT-OFF* */ /* clang-format off */ HRESULT (WINAPI *GetDpiForMonitor)( HMONITOR hmonitor, MONITOR_DPI_TYPE dpiType, UINT *dpiX, UINT *dpiY ); HRESULT (WINAPI *SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS dpiAwareness); -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ + /* *INDENT-ON* */ /* clang-format on */ +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ SDL_bool dpi_scaling_enabled; SDL_bool cleared; - #ifndef SDL_DISABLE_WINDOWS_IME +#ifndef SDL_DISABLE_WINDOWS_IME SDL_bool ime_com_initialized; struct ITfThreadMgr *ime_threadmgr; SDL_bool ime_initialized; @@ -407,13 +415,13 @@ typedef struct SDL_VideoData SDL_bool ime_suppress_endcomposition_event; HIMC ime_himc; - WCHAR* ime_composition; + WCHAR *ime_composition; int ime_composition_length; WCHAR ime_readingstring[16]; int ime_cursor; SDL_bool ime_candlist; - WCHAR* ime_candidates; + WCHAR *ime_candidates; DWORD ime_candcount; DWORD ime_candref; DWORD ime_candsel; @@ -428,13 +436,15 @@ typedef struct SDL_VideoData int ime_winheight; HKL ime_hkl; - void* ime_himm32; + void *ime_himm32; + /* *INDENT-OFF* */ /* clang-format off */ UINT (WINAPI *GetReadingString)(HIMC himc, UINT uReadingBufLen, LPWSTR lpwReadingBuf, PINT pnErrorIndex, BOOL *pfIsVertical, PUINT puMaxReadingLen); BOOL (WINAPI *ShowReadingWindow)(HIMC himc, BOOL bShow); LPINPUTCONTEXT2 (WINAPI *ImmLockIMC)(HIMC himc); BOOL (WINAPI *ImmUnlockIMC)(HIMC himc); LPVOID (WINAPI *ImmLockIMCC)(HIMCC himcc); BOOL (WINAPI *ImmUnlockIMCC)(HIMCC himcc); + /* *INDENT-ON* */ /* clang-format on */ SDL_bool ime_uiless; struct ITfThreadMgrEx *ime_threadmgrex; @@ -455,7 +465,7 @@ extern SDL_bool g_WindowsEnableMessageLoop; extern SDL_bool g_WindowFrameUsableWhileCursorHidden; typedef struct IDirect3D9 IDirect3D9; -extern SDL_bool D3D_LoadDLL( void **pD3DDLL, IDirect3D9 **pDirect3D9Interface ); +extern SDL_bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface); extern SDL_bool WIN_IsPerMonitorV2DPIAware(_THIS); diff --git a/src/video/windows/SDL_windowsvulkan.c b/src/video/windows/SDL_windowsvulkan.c index 36af273cc..bc013835a 100644 --- a/src/video/windows/SDL_windowsvulkan.c +++ b/src/video/windows/SDL_windowsvulkan.c @@ -79,8 +79,7 @@ int WIN_Vulkan_LoadLibrary(_THIS, const char *path) if (extensions == NULL) { goto fail; } - for (i = 0; i < extensionCount; i++) - { + for (i = 0; i < extensionCount; i++) { if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { hasSurfaceExtension = SDL_TRUE; } else if (SDL_strcmp(VK_KHR_WIN32_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { @@ -89,12 +88,10 @@ int WIN_Vulkan_LoadLibrary(_THIS, const char *path) } SDL_free(extensions); if (!hasSurfaceExtension) { - SDL_SetError("Installed Vulkan doesn't implement the " - VK_KHR_SURFACE_EXTENSION_NAME " extension"); + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_SURFACE_EXTENSION_NAME " extension"); goto fail; } else if (!hasWin32SurfaceExtension) { - SDL_SetError("Installed Vulkan doesn't implement the " - VK_KHR_WIN32_SURFACE_EXTENSION_NAME "extension"); + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_WIN32_SURFACE_EXTENSION_NAME "extension"); goto fail; } return 0; @@ -126,8 +123,8 @@ SDL_bool WIN_Vulkan_GetInstanceExtensions(_THIS, return SDL_FALSE; } return SDL_Vulkan_GetInstanceExtensions_Helper( - count, names, SDL_arraysize(extensionsForWin32), - extensionsForWin32); + count, names, SDL_arraysize(extensionsForWin32), + extensionsForWin32); } SDL_bool WIN_Vulkan_CreateSurface(_THIS, @@ -140,8 +137,8 @@ SDL_bool WIN_Vulkan_CreateSurface(_THIS, (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)vkGetInstanceProcAddr( - (VkInstance)instance, - "vkCreateWin32SurfaceKHR"); + (VkInstance)instance, + "vkCreateWin32SurfaceKHR"); VkWin32SurfaceCreateInfoKHR createInfo; VkResult result; @@ -161,7 +158,7 @@ SDL_bool WIN_Vulkan_CreateSurface(_THIS, createInfo.hinstance = windowData->hinstance; createInfo.hwnd = windowData->hwnd; result = vkCreateWin32SurfaceKHR(instance, &createInfo, - NULL, surface); + NULL, surface); if (result != VK_SUCCESS) { SDL_SetError("vkCreateWin32SurfaceKHR failed: %s", SDL_Vulkan_GetResultString(result)); diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 151c369ef..d574040e2 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -65,16 +65,15 @@ static ATOM SDL_HelperWindowClass = 0; This will also cause the task bar to overlap the window and other windowed behaviors, so only use this for windows that shouldn't appear to be fullscreen */ -#define STYLE_BASIC (WS_CLIPSIBLINGS | WS_CLIPCHILDREN) -#define STYLE_FULLSCREEN (WS_POPUP | WS_MINIMIZEBOX) -#define STYLE_BORDERLESS (WS_POPUP | WS_MINIMIZEBOX) +#define STYLE_BASIC (WS_CLIPSIBLINGS | WS_CLIPCHILDREN) +#define STYLE_FULLSCREEN (WS_POPUP | WS_MINIMIZEBOX) +#define STYLE_BORDERLESS (WS_POPUP | WS_MINIMIZEBOX) #define STYLE_BORDERLESS_WINDOWED (WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX) -#define STYLE_NORMAL (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX) -#define STYLE_RESIZABLE (WS_THICKFRAME | WS_MAXIMIZEBOX) -#define STYLE_MASK (STYLE_FULLSCREEN | STYLE_BORDERLESS | STYLE_NORMAL | STYLE_RESIZABLE) +#define STYLE_NORMAL (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX) +#define STYLE_RESIZABLE (WS_THICKFRAME | WS_MAXIMIZEBOX) +#define STYLE_MASK (STYLE_FULLSCREEN | STYLE_BORDERLESS | STYLE_NORMAL | STYLE_RESIZABLE) -static DWORD -GetWindowStyle(SDL_Window * window) +static DWORD GetWindowStyle(SDL_Window *window) { DWORD style = 0; @@ -122,10 +121,9 @@ GetWindowStyle(SDL_Window * window) * Returns arguments to pass to SetWindowPos - the window rect, including frame, in Windows coordinates. * Can be called before we have a HWND. */ -static void -WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, BOOL menu, int *x, int *y, int *width, int *height, SDL_bool use_current) +static void WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, BOOL menu, int *x, int *y, int *width, int *height, SDL_bool use_current) { - SDL_VideoData* videodata = SDL_GetVideoDevice() ? SDL_GetVideoDevice()->driverdata : NULL; + SDL_VideoData *videodata = SDL_GetVideoDevice() ? SDL_GetVideoDevice()->driverdata : NULL; RECT rect; int dpi = 96; #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) @@ -168,7 +166,7 @@ WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, BOOL menu, int *x AdjustWindowRectEx(&rect, style, menu, 0); #else if (WIN_IsPerMonitorV2DPIAware(SDL_GetVideoDevice())) { - /* With per-monitor v2, the window border/titlebar size depend on the DPI, so we need to call AdjustWindowRectExForDpi instead of + /* With per-monitor v2, the window border/titlebar size depend on the DPI, so we need to call AdjustWindowRectExForDpi instead of AdjustWindowRectEx. */ UINT unused; RECT screen_rect; @@ -177,7 +175,7 @@ WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, BOOL menu, int *x screen_rect.left = *x; screen_rect.top = *y; screen_rect.right = *x + *width; - screen_rect.bottom = *y + *height; + screen_rect.bottom = *y + *height; mon = MonitorFromRect(&screen_rect, MONITOR_DEFAULTTONEAREST); @@ -189,7 +187,7 @@ WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, BOOL menu, int *x videodata->AdjustWindowRectExForDpi(&rect, style, menu, 0, frame_dpi); } else { AdjustWindowRectEx(&rect, style, menu, 0); - } + } #endif } @@ -200,17 +198,16 @@ WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, BOOL menu, int *x *height = (rect.bottom - rect.top); #ifdef HIGHDPI_DEBUG - SDL_Log("WIN_AdjustWindowRectWithStyle: in: %d, %d, %dx%d, returning: %d, %d, %dx%d, used dpi %d for frame calculation", - (use_current ? window->x : window->windowed.x), - (use_current ? window->y : window->windowed.y), - (use_current ? window->w : window->windowed.w), - (use_current ? window->h : window->windowed.h), - *x, *y, *width, *height, frame_dpi); + SDL_Log("WIN_AdjustWindowRectWithStyle: in: %d, %d, %dx%d, returning: %d, %d, %dx%d, used dpi %d for frame calculation", + (use_current ? window->x : window->windowed.x), + (use_current ? window->y : window->windowed.y), + (use_current ? window->w : window->windowed.w), + (use_current ? window->h : window->windowed.h), + *x, *y, *width, *height, frame_dpi); #endif } -static void -WIN_AdjustWindowRect(SDL_Window *window, int *x, int *y, int *width, int *height, SDL_bool use_current) +static void WIN_AdjustWindowRect(SDL_Window *window, int *x, int *y, int *width, int *height, SDL_bool use_current) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; HWND hwnd = data->hwnd; @@ -226,8 +223,7 @@ WIN_AdjustWindowRect(SDL_Window *window, int *x, int *y, int *width, int *height WIN_AdjustWindowRectWithStyle(window, style, menu, x, y, width, height, use_current); } -static void -WIN_SetWindowPositionInternal(_THIS, SDL_Window * window, UINT flags) +static void WIN_SetWindowPositionInternal(_THIS, SDL_Window *window, UINT flags) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; HWND hwnd = data->hwnd; @@ -249,15 +245,13 @@ WIN_SetWindowPositionInternal(_THIS, SDL_Window * window, UINT flags) data->expected_resize = SDL_FALSE; } -static void SDLCALL -WIN_MouseRelativeModeCenterChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +static void SDLCALL WIN_MouseRelativeModeCenterChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_WindowData *data = (SDL_WindowData *)userdata; data->mouse_relative_mode_center = SDL_GetStringBoolean(hint, SDL_TRUE); } -static int -WIN_GetScalingDPIForHWND(const SDL_VideoData *videodata, HWND hwnd) +static int WIN_GetScalingDPIForHWND(const SDL_VideoData *videodata, HWND hwnd) { #if defined(__XBOXONE__) || defined(__XBOXSERIES__) return 96; @@ -297,24 +291,23 @@ WIN_GetScalingDPIForHWND(const SDL_VideoData *videodata, HWND hwnd) #endif } -static int -SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, HWND parent, SDL_bool created) +static int SetupWindowData(_THIS, SDL_Window *window, HWND hwnd, HWND parent, SDL_bool created) { - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; SDL_WindowData *data; /* Allocate the window data */ - data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data)); + data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data)); if (data == NULL) { return SDL_OutOfMemory(); } data->window = window; data->hwnd = hwnd; data->parent = parent; -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) data->hdc = GetDC(hwnd); #endif - data->hinstance = (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE); + data->hinstance = (HINSTANCE)GetWindowLongPtr(hwnd, GWLP_HINSTANCE); data->created = created; data->high_surrogate = 0; data->mouse_button_flags = (WPARAM)-1; @@ -331,7 +324,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, HWND parent, SDL_bool cre window->driverdata = data; -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* Associate the data with the window */ if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) { ReleaseDC(hwnd, data->hdc); @@ -342,18 +335,18 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, HWND parent, SDL_bool cre /* Set up the window proc function */ #ifdef GWLP_WNDPROC - data->wndproc = (WNDPROC) GetWindowLongPtr(hwnd, GWLP_WNDPROC); + data->wndproc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_WNDPROC); if (data->wndproc == WIN_WindowProc) { data->wndproc = NULL; } else { - SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) WIN_WindowProc); + SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)WIN_WindowProc); } #else - data->wndproc = (WNDPROC) GetWindowLong(hwnd, GWL_WNDPROC); + data->wndproc = (WNDPROC)GetWindowLong(hwnd, GWL_WNDPROC); if (data->wndproc == WIN_WindowProc) { data->wndproc = NULL; } else { - SetWindowLong(hwnd, GWL_WNDPROC, (LONG_PTR) WIN_WindowProc); + SetWindowLong(hwnd, GWL_WNDPROC, (LONG_PTR)WIN_WindowProc); } #endif @@ -379,7 +372,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, HWND parent, SDL_bool cre } } } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) { POINT point; point.x = 0; @@ -441,7 +434,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, HWND parent, SDL_bool cre #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* Enable multi-touch */ if (videodata->RegisterTouchWindow) { - videodata->RegisterTouchWindow(hwnd, (TWF_FINETOUCH|TWF_WANTPALM)); + videodata->RegisterTouchWindow(hwnd, (TWF_FINETOUCH | TWF_WANTPALM)); } #endif @@ -456,9 +449,9 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, HWND parent, SDL_bool cre return 0; } -static void CleanupWindowData(_THIS, SDL_Window * window) +static void CleanupWindowData(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; if (data) { SDL_DelHintCallback(SDL_HINT_MOUSE_RELATIVE_MODE_CENTER, WIN_MouseRelativeModeCenterChanged, data); @@ -483,10 +476,10 @@ static void CleanupWindowData(_THIS, SDL_Window * window) if (data->wndproc != NULL) { #ifdef GWLP_WNDPROC SetWindowLongPtr(data->hwnd, GWLP_WNDPROC, - (LONG_PTR) data->wndproc); + (LONG_PTR)data->wndproc); #else SetWindowLong(data->hwnd, GWL_WNDPROC, - (LONG_PTR) data->wndproc); + (LONG_PTR)data->wndproc); #endif } } @@ -495,8 +488,7 @@ static void CleanupWindowData(_THIS, SDL_Window * window) window->driverdata = NULL; } -int -WIN_CreateWindow(_THIS, SDL_Window * window) +int WIN_CreateWindow(_THIS, SDL_Window *window) { HWND hwnd, parent = NULL; DWORD style = STYLE_BASIC; @@ -571,13 +563,12 @@ WIN_CreateWindow(_THIS, SDL_Window * window) return 0; } -int -WIN_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) +int WIN_CreateWindowFrom(_THIS, SDL_Window *window, const void *data) { #if defined(__XBOXONE__) || defined(__XBOXSERIES__) return -1; #else - HWND hwnd = (HWND) data; + HWND hwnd = (HWND)data; LPTSTR title; int titleLen; SDL_bool isstack; @@ -609,7 +600,7 @@ WIN_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) the window to share a pixel format with */ SDL_Window *otherWindow = NULL; - SDL_sscanf(hint, "%p", (void**)&otherWindow); + SDL_sscanf(hint, "%p", (void **)&otherWindow); /* Do some error checking on the pointer */ if (otherWindow != NULL && otherWindow->magic == &_this->window_magic) { @@ -631,22 +622,20 @@ WIN_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) #endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ } -void -WIN_SetWindowTitle(_THIS, SDL_Window * window) +void WIN_SetWindowTitle(_THIS, SDL_Window *window) { #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) - HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; + HWND hwnd = ((SDL_WindowData *)window->driverdata)->hwnd; LPTSTR title = WIN_UTF8ToString(window->title); SetWindowText(hwnd, title); SDL_free(title); #endif } -void -WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) +void WIN_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon) { #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) - HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; + HWND hwnd = ((SDL_WindowData *)window->driverdata)->hwnd; HICON hicon = NULL; BYTE *icon_bmp; int icon_len, mask_len, row_len, y; @@ -656,7 +645,7 @@ WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) /* Create temporary buffer for ICONIMAGE structure */ SDL_COMPILE_TIME_ASSERT(WIN_SetWindowIcon_uses_BITMAPINFOHEADER_to_prepare_an_ICONIMAGE, sizeof(BITMAPINFOHEADER) == 40); - mask_len = (icon->h * (icon->w + 7)/8); + mask_len = (icon->h * (icon->w + 7) / 8); icon_len = sizeof(BITMAPINFOHEADER) + icon->h * icon->w * sizeof(Uint32) + mask_len; icon_bmp = SDL_small_alloc(BYTE, icon_len, &isstack); @@ -680,7 +669,7 @@ WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) row_len = icon->w * sizeof(Uint32); y = icon->h; while (y--) { - Uint8 *src = (Uint8 *) icon->pixels + y * icon->pitch; + Uint8 *src = (Uint8 *)icon->pixels + y * icon->pitch; SDL_memcpy(dst, src, row_len); dst += row_len; } @@ -693,15 +682,14 @@ WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) SDL_small_free(icon_bmp, isstack); /* Set the icon for the window */ - SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM) hicon); + SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hicon); /* Set the icon in the task manager (should we do this?) */ - SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM) hicon); + SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hicon); #endif } -void -WIN_SetWindowPosition(_THIS, SDL_Window * window) +void WIN_SetWindowPosition(_THIS, SDL_Window *window) { /* HighDPI support: removed SWP_NOSIZE. If the move results in a DPI change, we need to allow * the window to resize (e.g. AdjustWindowRectExForDpi frame sizes are different). @@ -709,17 +697,15 @@ WIN_SetWindowPosition(_THIS, SDL_Window * window) WIN_SetWindowPositionInternal(_this, window, SWP_NOCOPYBITS | SWP_NOACTIVATE); } -void -WIN_SetWindowSize(_THIS, SDL_Window * window) +void WIN_SetWindowSize(_THIS, SDL_Window *window) { WIN_SetWindowPositionInternal(_this, window, SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOACTIVATE); } -int -WIN_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *bottom, int *right) +int WIN_GetWindowBordersSize(_THIS, SDL_Window *window, int *top, int *left, int *bottom, int *right) { #if defined(__XBOXONE__) || defined(__XBOXSERIES__) - HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; + HWND hwnd = ((SDL_WindowData *)window->driverdata)->hwnd; RECT rcClient; /* rcClient stores the size of the inner window, while rcWindow stores the outer size relative to the top-left @@ -732,8 +718,8 @@ WIN_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *b *right = rcClient.right; return 0; -#else /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ - HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; +#else /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ + HWND hwnd = ((SDL_WindowData *)window->driverdata)->hwnd; RECT rcClient, rcWindow; POINT ptDiff; @@ -756,7 +742,7 @@ WIN_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *b return SDL_SetError("ScreenToClient() failed, error %08X", (unsigned int)GetLastError()); } - rcWindow.top = ptDiff.y; + rcWindow.top = ptDiff.y; rcWindow.left = ptDiff.x; /* convert the bottom/right values to make them relative to the window, @@ -769,7 +755,7 @@ WIN_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *b } rcWindow.bottom = ptDiff.y; - rcWindow.right = ptDiff.x; + rcWindow.right = ptDiff.x; /* Now that both the inner and outer rects use the same coordinate system we can substract them to get the border size. * Keep in mind that the top/left coordinates of rcWindow are negative because the border lies slightly before {0,0}, @@ -777,14 +763,13 @@ WIN_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *b *top = rcClient.top - rcWindow.top; *left = rcClient.left - rcWindow.left; *bottom = rcWindow.bottom - rcClient.bottom; - *right = rcWindow.right - rcClient.right; + *right = rcWindow.right - rcClient.right; return 0; #endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ } -void -WIN_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h) +void WIN_GetWindowSizeInPixels(_THIS, SDL_Window *window, int *w, int *h) { const SDL_WindowData *data = ((SDL_WindowData *)window->driverdata); HWND hwnd = data->hwnd; @@ -799,8 +784,7 @@ WIN_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h) } } -void -WIN_ShowWindow(_THIS, SDL_Window * window) +void WIN_ShowWindow(_THIS, SDL_Window *window) { DWORD style; HWND hwnd; @@ -815,15 +799,13 @@ WIN_ShowWindow(_THIS, SDL_Window * window) ShowWindow(hwnd, nCmdShow); } -void -WIN_HideWindow(_THIS, SDL_Window * window) +void WIN_HideWindow(_THIS, SDL_Window *window) { - HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; + HWND hwnd = ((SDL_WindowData *)window->driverdata)->hwnd; ShowWindow(hwnd, SW_HIDE); } -void -WIN_RaiseWindow(_THIS, SDL_Window * window) +void WIN_RaiseWindow(_THIS, SDL_Window *window) { #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* If desired, raise the window more forcefully. @@ -840,7 +822,7 @@ WIN_RaiseWindow(_THIS, SDL_Window * window) DWORD dwMyID = 0u; DWORD dwCurID = 0u; - HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; + HWND hwnd = ((SDL_WindowData *)window->driverdata)->hwnd; if (bForce) { hCurWnd = GetForegroundWindow(); dwMyID = GetCurrentThreadId(); @@ -859,8 +841,7 @@ WIN_RaiseWindow(_THIS, SDL_Window * window) #endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ } -void -WIN_MaximizeWindow(_THIS, SDL_Window * window) +void WIN_MaximizeWindow(_THIS, SDL_Window *window) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; HWND hwnd = data->hwnd; @@ -869,15 +850,13 @@ WIN_MaximizeWindow(_THIS, SDL_Window * window) data->expected_resize = SDL_FALSE; } -void -WIN_MinimizeWindow(_THIS, SDL_Window * window) +void WIN_MinimizeWindow(_THIS, SDL_Window *window) { - HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; + HWND hwnd = ((SDL_WindowData *)window->driverdata)->hwnd; ShowWindow(hwnd, SW_MINIMIZE); } -void -WIN_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) +void WIN_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; HWND hwnd = data->hwnd; @@ -893,8 +872,7 @@ WIN_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) data->in_border_change = SDL_FALSE; } -void -WIN_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable) +void WIN_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; HWND hwnd = data->hwnd; @@ -907,8 +885,7 @@ WIN_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable) SetWindowLong(hwnd, GWL_STYLE, style); } -void -WIN_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top) +void WIN_SetWindowAlwaysOnTop(_THIS, SDL_Window *window, SDL_bool on_top) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; HWND hwnd = data->hwnd; @@ -919,8 +896,7 @@ WIN_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top) } } -void -WIN_RestoreWindow(_THIS, SDL_Window * window) +void WIN_RestoreWindow(_THIS, SDL_Window *window) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; HWND hwnd = data->hwnd; @@ -932,12 +908,11 @@ WIN_RestoreWindow(_THIS, SDL_Window * window) /** * Reconfigures the window to fill the given display, if fullscreen is true, otherwise restores the window. */ -void -WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen) +void WIN_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen) { -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) - SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata; - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) + SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; HWND hwnd = data->hwnd; MONITORINFO minfo; DWORD style; @@ -945,7 +920,7 @@ WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, int x, y; int w, h; - if (!fullscreen && (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_FULLSCREEN_DESKTOP)) != 0) { + if (!fullscreen && (window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP)) != 0) { /* Resizing the window on hide causes problems restoring it in Wine, and it's unnecessary. * Also, Windows would preview the minimized window with the wrong size. */ @@ -1040,9 +1015,9 @@ WIN_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) void WIN_UpdateWindowICCProfile(SDL_Window * window, SDL_bool send_event) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); - SDL_DisplayData *displaydata = display ? (SDL_DisplayData*)display->driverdata : NULL; + SDL_DisplayData *displaydata = display ? (SDL_DisplayData *)display->driverdata : NULL; if (displaydata) { HDC hdc = CreateDCW(displaydata->DeviceName, NULL, NULL, NULL); @@ -1068,9 +1043,9 @@ WIN_UpdateWindowICCProfile(SDL_Window * window, SDL_bool send_event) } void * -WIN_GetWindowICCProfile(_THIS, SDL_Window * window, size_t * size) +WIN_GetWindowICCProfile(_THIS, SDL_Window *window, size_t *size) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; char *filename_utf8; void *iccProfileData = NULL; @@ -1150,20 +1125,17 @@ void WIN_UngrabKeyboard(SDL_Window *window) } } -void -WIN_SetWindowMouseRect(_THIS, SDL_Window * window) +void WIN_SetWindowMouseRect(_THIS, SDL_Window *window) { WIN_UpdateClipCursor(window); } -void -WIN_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed) +void WIN_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed) { WIN_UpdateClipCursor(window); } -void -WIN_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed) +void WIN_SetWindowKeyboardGrab(_THIS, SDL_Window *window, SDL_bool grabbed) { if (grabbed) { WIN_GrabKeyboard(window); @@ -1173,11 +1145,10 @@ WIN_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed) } #endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ -void -WIN_DestroyWindow(_THIS, SDL_Window * window) +void WIN_DestroyWindow(_THIS, SDL_Window *window) { if (window->shaper) { - SDL_ShapeData *shapedata = (SDL_ShapeData *) window->shaper->driverdata; + SDL_ShapeData *shapedata = (SDL_ShapeData *)window->shaper->driverdata; if (shapedata) { if (shapedata->mask_tree) { SDL_FreeShapeTree(&shapedata->mask_tree); @@ -1220,8 +1191,7 @@ WIN_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) /* * Creates a HelperWindow used for DirectInput. */ -int -SDL_HelperWindowCreate(void) +int SDL_HelperWindowCreate(void) { HINSTANCE hInstance = GetModuleHandle(NULL); WNDCLASS wce; @@ -1258,12 +1228,10 @@ SDL_HelperWindowCreate(void) return 0; } - /* * Destroys the HelperWindow previously created with SDL_HelperWindowCreate. */ -void -SDL_HelperWindowDestroy(void) +void SDL_HelperWindowDestroy(void) { HINSTANCE hInstance = GetModuleHandle(NULL); @@ -1287,9 +1255,9 @@ SDL_HelperWindowDestroy(void) } #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) -void WIN_OnWindowEnter(_THIS, SDL_Window * window) +void WIN_OnWindowEnter(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; if (data == NULL || !data->hwnd) { /* The window wasn't fully initialized */ @@ -1301,10 +1269,9 @@ void WIN_OnWindowEnter(_THIS, SDL_Window * window) } } -void -WIN_UpdateClipCursor(SDL_Window *window) +void WIN_UpdateClipCursor(SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_Mouse *mouse = SDL_GetMouse(); RECT rect, clipped_rect; @@ -1342,8 +1309,8 @@ WIN_UpdateClipCursor(SDL_Window *window) } } else { if (GetClientRect(data->hwnd, &rect)) { - ClientToScreen(data->hwnd, (LPPOINT) & rect); - ClientToScreen(data->hwnd, (LPPOINT) & rect + 1); + ClientToScreen(data->hwnd, (LPPOINT)&rect); + ClientToScreen(data->hwnd, (LPPOINT)&rect + 1); if (window->mouse_rect.w > 0 && window->mouse_rect.h > 0) { SDL_Rect mouse_rect_win_client; RECT mouse_rect, intersection; @@ -1394,20 +1361,18 @@ WIN_UpdateClipCursor(SDL_Window *window) data->last_updated_clipcursor = SDL_GetTicks(); } -int -WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled) +int WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled) { - return 0; /* just succeed, the real work is done elsewhere. */ + return 0; /* just succeed, the real work is done elsewhere. */ } #endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ -int -WIN_SetWindowOpacity(_THIS, SDL_Window * window, float opacity) +int WIN_SetWindowOpacity(_THIS, SDL_Window *window, float opacity) { #if defined(__XBOXONE__) || defined(__XBOXSERIES__) return -1; #else - const SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + const SDL_WindowData *data = (SDL_WindowData *)window->driverdata; const HWND hwnd = data->hwnd; const LONG style = GetWindowLong(hwnd, GWL_EXSTYLE); @@ -1421,7 +1386,7 @@ WIN_SetWindowOpacity(_THIS, SDL_Window * window, float opacity) } } } else { - const BYTE alpha = (BYTE) ((int) (opacity * 255.0f)); + const BYTE alpha = (BYTE)((int)(opacity * 255.0f)); /* want it transparent, mark it layered if necessary. */ if ((style & WS_EX_LAYERED) == 0) { if (SetWindowLong(hwnd, GWL_EXSTYLE, style | WS_EX_LAYERED) == 0) { @@ -1440,11 +1405,10 @@ WIN_SetWindowOpacity(_THIS, SDL_Window * window, float opacity) /** * Convert a point in the client area from pixels to DPI-scaled points. - * + * * No-op if DPI scaling is not enabled. */ -void -WIN_ClientPointToSDL(const SDL_Window *window, int *x, int *y) +void WIN_ClientPointToSDL(const SDL_Window *window, int *x, int *y) { const SDL_WindowData *data = ((SDL_WindowData *)window->driverdata); const SDL_VideoData *videodata = data->videodata; @@ -1459,11 +1423,10 @@ WIN_ClientPointToSDL(const SDL_Window *window, int *x, int *y) /** * Convert a point in the client area from DPI-scaled points to pixels. - * + * * No-op if DPI scaling is not enabled. */ -void -WIN_ClientPointFromSDL(const SDL_Window *window, int *x, int *y) +void WIN_ClientPointFromSDL(const SDL_Window *window, int *x, int *y) { const SDL_WindowData *data = ((SDL_WindowData *)window->driverdata); const SDL_VideoData *videodata = data->videodata; @@ -1471,27 +1434,25 @@ WIN_ClientPointFromSDL(const SDL_Window *window, int *x, int *y) if (!videodata->dpi_scaling_enabled) { return; } - + *x = MulDiv(*x, data->scaling_dpi, 96); *y = MulDiv(*y, data->scaling_dpi, 96); } #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) -void -WIN_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept) +void WIN_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept) { - const SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + const SDL_WindowData *data = (SDL_WindowData *)window->driverdata; DragAcceptFiles(data->hwnd, accept ? TRUE : FALSE); } -int -WIN_FlashWindow(_THIS, SDL_Window * window, SDL_FlashOperation operation) +int WIN_FlashWindow(_THIS, SDL_Window *window, SDL_FlashOperation operation) { FLASHWINFO desc; SDL_zero(desc); desc.cbSize = sizeof(desc); - desc.hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; + desc.hwnd = ((SDL_WindowData *)window->driverdata)->hwnd; switch (operation) { case SDL_FLASH_CANCEL: desc.dwFlags = FLASHW_STOP; diff --git a/src/video/windows/SDL_windowswindow.h b/src/video/windows/SDL_windowswindow.h index 6477530b9..d4488c627 100644 --- a/src/video/windows/SDL_windowswindow.h +++ b/src/video/windows/SDL_windowswindow.h @@ -23,7 +23,7 @@ #ifndef SDL_windowswindow_h_ #define SDL_windowswindow_h_ -#if SDL_VIDEO_OPENGL_EGL +#if SDL_VIDEO_OPENGL_EGL #include "../SDL_egl_c.h" #else #include "../SDL_sysvideo.h" @@ -64,7 +64,7 @@ typedef struct SDL_bool mouse_tracked; WCHAR *ICMFileName; struct SDL_VideoData *videodata; -#if SDL_VIDEO_OPENGL_EGL +#if SDL_VIDEO_OPENGL_EGL EGLSurface egl_surface; #endif /** @@ -108,8 +108,8 @@ extern void WIN_UpdateClipCursor(SDL_Window *window); extern int WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled); extern void WIN_ClientPointToSDL(const SDL_Window *window, int *w, int *h); extern void WIN_ClientPointFromSDL(const SDL_Window *window, int *w, int *h); -extern void WIN_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept); -extern int WIN_FlashWindow(_THIS, SDL_Window * window, SDL_FlashOperation operation); +extern void WIN_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept); +extern int WIN_FlashWindow(_THIS, SDL_Window *window, SDL_FlashOperation operation); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/src/video/windows/wmmsg.h b/src/video/windows/wmmsg.h index 86cae1df9..bd748d2da 100644 --- a/src/video/windows/wmmsg.h +++ b/src/video/windows/wmmsg.h @@ -19,7 +19,7 @@ 3. This notice may not be removed or altered from any source distribution. */ -#define MAX_WMMSG (sizeof(wmtab)/sizeof(wmtab[0])) +#define MAX_WMMSG (sizeof(wmtab) / sizeof(wmtab[0])) const char *wmtab[] = { "WM_NULL", diff --git a/src/video/winrt/SDL_winrtevents.cpp b/src/video/winrt/SDL_winrtevents.cpp index 646bde773..0febbb118 100644 --- a/src/video/winrt/SDL_winrtevents.cpp +++ b/src/video/winrt/SDL_winrtevents.cpp @@ -44,15 +44,12 @@ extern "C" { #include "../../events/SDL_events_c.h" } - /* Forward declarations */ static void WINRT_YieldXAMLThread(); - /* Global event management */ -void -WINRT_PumpEvents(_THIS) +void WINRT_PumpEvents(_THIS) { if (SDL_WinRTGlobalApp) { SDL_WinRTGlobalApp->PumpEvents(); @@ -61,7 +58,6 @@ WINRT_PumpEvents(_THIS) } } - /* XAML Thread management */ enum SDL_XAMLAppThreadState @@ -72,12 +68,11 @@ enum SDL_XAMLAppThreadState }; static SDL_XAMLAppThreadState _threadState = ThreadState_NotLaunched; -static SDL_Thread * _XAMLThread = nullptr; -static SDL_mutex * _mutex = nullptr; -static SDL_cond * _cond = nullptr; +static SDL_Thread *_XAMLThread = nullptr; +static SDL_mutex *_mutex = nullptr; +static SDL_cond *_cond = nullptr; -static void -WINRT_YieldXAMLThread() +static void WINRT_YieldXAMLThread() { SDL_LockMutex(_mutex); SDL_assert(_threadState == ThreadState_Running); @@ -93,8 +88,7 @@ WINRT_YieldXAMLThread() SDL_UnlockMutex(_mutex); } -static int -WINRT_XAMLThreadMain(void * userdata) +static int WINRT_XAMLThreadMain(void *userdata) { // TODO, WinRT: pass the C-style main() a reasonably realistic // representation of command line arguments. @@ -103,48 +97,47 @@ WINRT_XAMLThreadMain(void * userdata) return WINRT_SDLAppEntryPoint(argc, argv); } -void -WINRT_CycleXAMLThread(void) +void WINRT_CycleXAMLThread(void) { switch (_threadState) { - case ThreadState_NotLaunched: - { - _cond = SDL_CreateCond(); + case ThreadState_NotLaunched: + { + _cond = SDL_CreateCond(); - _mutex = SDL_CreateMutex(); - _threadState = ThreadState_Running; - _XAMLThread = SDL_CreateThreadInternal(WINRT_XAMLThreadMain, "SDL/XAML App Thread", 0, nullptr); + _mutex = SDL_CreateMutex(); + _threadState = ThreadState_Running; + _XAMLThread = SDL_CreateThreadInternal(WINRT_XAMLThreadMain, "SDL/XAML App Thread", 0, nullptr); - SDL_LockMutex(_mutex); - while (_threadState != ThreadState_Yielding) { - SDL_CondWait(_cond, _mutex); - } - SDL_UnlockMutex(_mutex); - - break; + SDL_LockMutex(_mutex); + while (_threadState != ThreadState_Yielding) { + SDL_CondWait(_cond, _mutex); } + SDL_UnlockMutex(_mutex); - case ThreadState_Running: - { - SDL_assert(false); - break; - } - - case ThreadState_Yielding: - { - SDL_LockMutex(_mutex); - SDL_assert(_threadState == ThreadState_Yielding); - _threadState = ThreadState_Running; - SDL_UnlockMutex(_mutex); - - SDL_CondSignal(_cond); - - SDL_LockMutex(_mutex); - while (_threadState != ThreadState_Yielding) { - SDL_CondWait(_cond, _mutex); - } - SDL_UnlockMutex(_mutex); + break; + } + + case ThreadState_Running: + { + SDL_assert(false); + break; + } + + case ThreadState_Yielding: + { + SDL_LockMutex(_mutex); + SDL_assert(_threadState == ThreadState_Yielding); + _threadState = ThreadState_Running; + SDL_UnlockMutex(_mutex); + + SDL_CondSignal(_cond); + + SDL_LockMutex(_mutex); + while (_threadState != ThreadState_Yielding) { + SDL_CondWait(_cond, _mutex); } + SDL_UnlockMutex(_mutex); + } } } diff --git a/src/video/winrt/SDL_winrtevents_c.h b/src/video/winrt/SDL_winrtevents_c.h index 67c18b865..b98b89204 100644 --- a/src/video/winrt/SDL_winrtevents_c.h +++ b/src/video/winrt/SDL_winrtevents_c.h @@ -39,33 +39,33 @@ extern void WINRT_PumpEvents(_THIS); } #endif - /* * Internal-use, C++/CX functions: */ #ifdef __cplusplus_winrt /* Pointers (Mice, Touch, etc.) */ -typedef enum { +typedef enum +{ NormalizeZeroToOne, TransformToSDLWindowSize } WINRT_CursorNormalizationType; -extern Windows::Foundation::Point WINRT_TransformCursorPosition(SDL_Window * window, +extern Windows::Foundation::Point WINRT_TransformCursorPosition(SDL_Window *window, Windows::Foundation::Point rawPosition, WINRT_CursorNormalizationType normalization); -extern SDL_bool WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt, Uint8 *button, Uint8 *pressed); -extern void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint); -extern void WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint); -extern void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint); -extern void WINRT_ProcessPointerEnteredEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint); -extern void WINRT_ProcessPointerExitedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint); -extern void WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint); -extern void WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::MouseEventArgs ^args); +extern SDL_bool WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^ pt, Uint8 *button, Uint8 *pressed); +extern void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint); +extern void WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint); +extern void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint); +extern void WINRT_ProcessPointerEnteredEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint); +extern void WINRT_ProcessPointerExitedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint); +extern void WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint); +extern void WINRT_ProcessMouseMovedEvent(SDL_Window *window, Windows::Devices::Input::MouseEventArgs ^ args); /* Keyboard */ -extern void WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^args); -extern void WINRT_ProcessKeyUpEvent(Windows::UI::Core::KeyEventArgs ^args); -extern void WINRT_ProcessCharacterReceivedEvent(Windows::UI::Core::CharacterReceivedEventArgs ^args); +extern void WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^ args); +extern void WINRT_ProcessKeyUpEvent(Windows::UI::Core::KeyEventArgs ^ args); +extern void WINRT_ProcessCharacterReceivedEvent(Windows::UI::Core::CharacterReceivedEventArgs ^ args); #if NTDDI_VERSION >= NTDDI_WIN10 extern void WINTRT_InitialiseInputPaneEvents(_THIS); @@ -73,7 +73,7 @@ extern SDL_bool WINRT_HasScreenKeyboardSupport(_THIS); extern void WINRT_ShowScreenKeyboard(_THIS, SDL_Window *window); extern void WINRT_HideScreenKeyboard(_THIS, SDL_Window *window); extern SDL_bool WINRT_IsScreenKeyboardShown(_THIS, SDL_Window *window); -#endif // NTDDI_VERSION >= ... +#endif // NTDDI_VERSION >= ... /* XAML Thread Management */ extern void WINRT_CycleXAMLThread(void); diff --git a/src/video/winrt/SDL_winrtgamebar.cpp b/src/video/winrt/SDL_winrtgamebar.cpp index ae16092ff..717d178b2 100644 --- a/src/video/winrt/SDL_winrtgamebar.cpp +++ b/src/video/winrt/SDL_winrtgamebar.cpp @@ -27,7 +27,6 @@ #include #include - /* SDL includes */ extern "C" { #include "SDL_mouse.h" @@ -35,13 +34,11 @@ extern "C" { } #include "SDL_winrtvideo_cpp.h" - /* Game Bar events can come in off the main thread. Use the following WinRT CoreDispatcher to deal with them on SDL's thread. */ static Platform::WeakReference WINRT_MainThreadDispatcher; - /* Win10's initial SDK (the 10.0.10240.0 release) does not include references to Game Bar APIs, as the Game Bar was released via Win10 10.0.10586.0. @@ -51,26 +48,26 @@ static Platform::WeakReference WINRT_MainThreadDispatcher; MIDL_INTERFACE("1DB9A292-CC78-4173-BE45-B61E67283EA7") IGameBarStatics_ : public IInspectable { -public: - virtual HRESULT STDMETHODCALLTYPE add_VisibilityChanged( - __FIEventHandler_1_IInspectable *handler, - Windows::Foundation::EventRegistrationToken *token) = 0; - - virtual HRESULT STDMETHODCALLTYPE remove_VisibilityChanged( + public: + virtual HRESULT STDMETHODCALLTYPE add_VisibilityChanged( + __FIEventHandler_1_IInspectable * handler, + Windows::Foundation::EventRegistrationToken * token) = 0; + + virtual HRESULT STDMETHODCALLTYPE remove_VisibilityChanged( Windows::Foundation::EventRegistrationToken token) = 0; - - virtual HRESULT STDMETHODCALLTYPE add_IsInputRedirectedChanged( - __FIEventHandler_1_IInspectable *handler, - Windows::Foundation::EventRegistrationToken *token) = 0; - - virtual HRESULT STDMETHODCALLTYPE remove_IsInputRedirectedChanged( + + virtual HRESULT STDMETHODCALLTYPE add_IsInputRedirectedChanged( + __FIEventHandler_1_IInspectable * handler, + Windows::Foundation::EventRegistrationToken * token) = 0; + + virtual HRESULT STDMETHODCALLTYPE remove_IsInputRedirectedChanged( Windows::Foundation::EventRegistrationToken token) = 0; - - virtual HRESULT STDMETHODCALLTYPE get_Visible( - boolean *value) = 0; - - virtual HRESULT STDMETHODCALLTYPE get_IsInputRedirected( - boolean *value) = 0; + + virtual HRESULT STDMETHODCALLTYPE get_Visible( + boolean * value) = 0; + + virtual HRESULT STDMETHODCALLTYPE get_IsInputRedirected( + boolean * value) = 0; }; /* Declare the game bar's COM GUID */ @@ -80,8 +77,7 @@ static GUID IID_IGameBarStatics_ = { MAKELONG(0xA292, 0x1DB9), 0xCC78, 0x4173, { If a pointer is returned, it's ->Release() method must be called after the caller has finished using it. */ -static IGameBarStatics_ * -WINRT_GetGameBar() +static IGameBarStatics_ *WINRT_GetGameBar() { wchar_t *wClassName = L"Windows.Gaming.UI.GameBar"; HSTRING hClassName; @@ -99,7 +95,7 @@ WINRT_GetGameBar() goto done; } - pActivationFactory->QueryInterface(IID_IGameBarStatics_, (void **) &pGameBar); + pActivationFactory->QueryInterface(IID_IGameBarStatics_, (void **)&pGameBar); done: if (pActivationFactory) { @@ -111,8 +107,7 @@ done: return pGameBar; } -static void -WINRT_HandleGameBarIsInputRedirected_MainThread() +static void WINRT_HandleGameBarIsInputRedirected_MainThread() { IGameBarStatics_ *gameBar; boolean isInputRedirected = 0; @@ -126,7 +121,7 @@ WINRT_HandleGameBarIsInputRedirected_MainThread() return; } if (SUCCEEDED(gameBar->get_IsInputRedirected(&isInputRedirected))) { - if ( ! isInputRedirected) { + if (!isInputRedirected) { /* Input-control is now back to the SDL app. Restore the cursor, in case Windows does not (it does not in either Win10 10.0.10240.0 or 10.0.10586.0, maybe later version(s) too. @@ -138,10 +133,9 @@ WINRT_HandleGameBarIsInputRedirected_MainThread() gameBar->Release(); } -static void -WINRT_HandleGameBarIsInputRedirected_NonMainThread(Platform::Object ^ o1, Platform::Object ^o2) +static void WINRT_HandleGameBarIsInputRedirected_NonMainThread(Platform::Object ^ o1, Platform::Object ^ o2) { - Windows::UI::Core::CoreDispatcher ^dispatcher = WINRT_MainThreadDispatcher.Resolve(); + Windows::UI::Core::CoreDispatcher ^ dispatcher = WINRT_MainThreadDispatcher.Resolve(); if (dispatcher) { dispatcher->RunAsync( Windows::UI::Core::CoreDispatcherPriority::Normal, @@ -149,8 +143,7 @@ WINRT_HandleGameBarIsInputRedirected_NonMainThread(Platform::Object ^ o1, Platfo } } -void -WINRT_InitGameBar(_THIS) +void WINRT_InitGameBar(_THIS) { SDL_VideoData *driverdata = (SDL_VideoData *)_this->driverdata; IGameBarStatics_ *gameBar = WINRT_GetGameBar(); @@ -162,16 +155,15 @@ WINRT_InitGameBar(_THIS) SDL thread. */ WINRT_MainThreadDispatcher = Windows::UI::Core::CoreWindow::GetForCurrentThread()->Dispatcher; - Windows::Foundation::EventHandler ^handler = \ + Windows::Foundation::EventHandler ^ handler = ref new Windows::Foundation::EventHandler(&WINRT_HandleGameBarIsInputRedirected_NonMainThread); - __FIEventHandler_1_IInspectable * pHandler = reinterpret_cast<__FIEventHandler_1_IInspectable *>(handler); + __FIEventHandler_1_IInspectable *pHandler = reinterpret_cast<__FIEventHandler_1_IInspectable *>(handler); gameBar->add_IsInputRedirectedChanged(pHandler, &driverdata->gameBarIsInputRedirectedToken); gameBar->Release(); } } -void -WINRT_QuitGameBar(_THIS) +void WINRT_QuitGameBar(_THIS) { SDL_VideoData *driverdata; IGameBarStatics_ *gameBar; diff --git a/src/video/winrt/SDL_winrtkeyboard.cpp b/src/video/winrt/SDL_winrtkeyboard.cpp index f6ff0a409..2a21e1b72 100644 --- a/src/video/winrt/SDL_winrtkeyboard.cpp +++ b/src/video/winrt/SDL_winrtkeyboard.cpp @@ -26,7 +26,6 @@ #include #include - /* SDL-specific includes */ #include "SDL.h" #include "SDL_winrtevents_c.h" @@ -36,223 +35,241 @@ extern "C" { #include "../../events/SDL_keyboard_c.h" } - static SDL_Scancode WinRT_Official_Keycodes[] = { - SDL_SCANCODE_UNKNOWN, /* VirtualKey.None -- 0 */ - SDL_SCANCODE_UNKNOWN, /* VirtualKey.LeftButton -- 1 */ - SDL_SCANCODE_UNKNOWN, /* VirtualKey.RightButton -- 2 */ - SDL_SCANCODE_CANCEL, /* VirtualKey.Cancel -- 3 */ - SDL_SCANCODE_UNKNOWN, /* VirtualKey.MiddleButton -- 4 */ - SDL_SCANCODE_UNKNOWN, /* VirtualKey.XButton1 -- 5 */ - SDL_SCANCODE_UNKNOWN, /* VirtualKey.XButton2 -- 6 */ - SDL_SCANCODE_UNKNOWN, /* -- 7 */ - SDL_SCANCODE_BACKSPACE, /* VirtualKey.Back -- 8 */ - SDL_SCANCODE_TAB, /* VirtualKey.Tab -- 9 */ - SDL_SCANCODE_UNKNOWN, /* -- 10 */ - SDL_SCANCODE_UNKNOWN, /* -- 11 */ - SDL_SCANCODE_CLEAR, /* VirtualKey.Clear -- 12 */ - SDL_SCANCODE_RETURN, /* VirtualKey.Enter -- 13 */ - SDL_SCANCODE_UNKNOWN, /* -- 14 */ - SDL_SCANCODE_UNKNOWN, /* -- 15 */ - SDL_SCANCODE_LSHIFT, /* VirtualKey.Shift -- 16 */ - SDL_SCANCODE_LCTRL, /* VirtualKey.Control -- 17 */ - SDL_SCANCODE_MENU, /* VirtualKey.Menu -- 18 */ - SDL_SCANCODE_PAUSE, /* VirtualKey.Pause -- 19 */ - SDL_SCANCODE_CAPSLOCK, /* VirtualKey.CapitalLock -- 20 */ - SDL_SCANCODE_UNKNOWN, /* VirtualKey.Kana or VirtualKey.Hangul -- 21 */ - SDL_SCANCODE_UNKNOWN, /* -- 22 */ - SDL_SCANCODE_UNKNOWN, /* VirtualKey.Junja -- 23 */ - SDL_SCANCODE_UNKNOWN, /* VirtualKey.Final -- 24 */ - SDL_SCANCODE_UNKNOWN, /* VirtualKey.Hanja or VirtualKey.Kanji -- 25 */ - SDL_SCANCODE_UNKNOWN, /* -- 26 */ - SDL_SCANCODE_ESCAPE, /* VirtualKey.Escape -- 27 */ - SDL_SCANCODE_UNKNOWN, /* VirtualKey.Convert -- 28 */ - SDL_SCANCODE_UNKNOWN, /* VirtualKey.NonConvert -- 29 */ - SDL_SCANCODE_UNKNOWN, /* VirtualKey.Accept -- 30 */ - SDL_SCANCODE_UNKNOWN, /* VirtualKey.ModeChange -- 31 (maybe SDL_SCANCODE_MODE ?) */ - SDL_SCANCODE_SPACE, /* VirtualKey.Space -- 32 */ - SDL_SCANCODE_PAGEUP, /* VirtualKey.PageUp -- 33 */ - SDL_SCANCODE_PAGEDOWN, /* VirtualKey.PageDown -- 34 */ - SDL_SCANCODE_END, /* VirtualKey.End -- 35 */ - SDL_SCANCODE_HOME, /* VirtualKey.Home -- 36 */ - SDL_SCANCODE_LEFT, /* VirtualKey.Left -- 37 */ - SDL_SCANCODE_UP, /* VirtualKey.Up -- 38 */ - SDL_SCANCODE_RIGHT, /* VirtualKey.Right -- 39 */ - SDL_SCANCODE_DOWN, /* VirtualKey.Down -- 40 */ - SDL_SCANCODE_SELECT, /* VirtualKey.Select -- 41 */ - SDL_SCANCODE_UNKNOWN, /* VirtualKey.Print -- 42 (maybe SDL_SCANCODE_PRINTSCREEN ?) */ - SDL_SCANCODE_EXECUTE, /* VirtualKey.Execute -- 43 */ - SDL_SCANCODE_UNKNOWN, /* VirtualKey.Snapshot -- 44 */ - SDL_SCANCODE_INSERT, /* VirtualKey.Insert -- 45 */ - SDL_SCANCODE_DELETE, /* VirtualKey.Delete -- 46 */ - SDL_SCANCODE_HELP, /* VirtualKey.Help -- 47 */ - SDL_SCANCODE_0, /* VirtualKey.Number0 -- 48 */ - SDL_SCANCODE_1, /* VirtualKey.Number1 -- 49 */ - SDL_SCANCODE_2, /* VirtualKey.Number2 -- 50 */ - SDL_SCANCODE_3, /* VirtualKey.Number3 -- 51 */ - SDL_SCANCODE_4, /* VirtualKey.Number4 -- 52 */ - SDL_SCANCODE_5, /* VirtualKey.Number5 -- 53 */ - SDL_SCANCODE_6, /* VirtualKey.Number6 -- 54 */ - SDL_SCANCODE_7, /* VirtualKey.Number7 -- 55 */ - SDL_SCANCODE_8, /* VirtualKey.Number8 -- 56 */ - SDL_SCANCODE_9, /* VirtualKey.Number9 -- 57 */ - SDL_SCANCODE_UNKNOWN, /* -- 58 */ - SDL_SCANCODE_UNKNOWN, /* -- 59 */ - SDL_SCANCODE_UNKNOWN, /* -- 60 */ - SDL_SCANCODE_UNKNOWN, /* -- 61 */ - SDL_SCANCODE_UNKNOWN, /* -- 62 */ - SDL_SCANCODE_UNKNOWN, /* -- 63 */ - SDL_SCANCODE_UNKNOWN, /* -- 64 */ - SDL_SCANCODE_A, /* VirtualKey.A -- 65 */ - SDL_SCANCODE_B, /* VirtualKey.B -- 66 */ - SDL_SCANCODE_C, /* VirtualKey.C -- 67 */ - SDL_SCANCODE_D, /* VirtualKey.D -- 68 */ - SDL_SCANCODE_E, /* VirtualKey.E -- 69 */ - SDL_SCANCODE_F, /* VirtualKey.F -- 70 */ - SDL_SCANCODE_G, /* VirtualKey.G -- 71 */ - SDL_SCANCODE_H, /* VirtualKey.H -- 72 */ - SDL_SCANCODE_I, /* VirtualKey.I -- 73 */ - SDL_SCANCODE_J, /* VirtualKey.J -- 74 */ - SDL_SCANCODE_K, /* VirtualKey.K -- 75 */ - SDL_SCANCODE_L, /* VirtualKey.L -- 76 */ - SDL_SCANCODE_M, /* VirtualKey.M -- 77 */ - SDL_SCANCODE_N, /* VirtualKey.N -- 78 */ - SDL_SCANCODE_O, /* VirtualKey.O -- 79 */ - SDL_SCANCODE_P, /* VirtualKey.P -- 80 */ - SDL_SCANCODE_Q, /* VirtualKey.Q -- 81 */ - SDL_SCANCODE_R, /* VirtualKey.R -- 82 */ - SDL_SCANCODE_S, /* VirtualKey.S -- 83 */ - SDL_SCANCODE_T, /* VirtualKey.T -- 84 */ - SDL_SCANCODE_U, /* VirtualKey.U -- 85 */ - SDL_SCANCODE_V, /* VirtualKey.V -- 86 */ - SDL_SCANCODE_W, /* VirtualKey.W -- 87 */ - SDL_SCANCODE_X, /* VirtualKey.X -- 88 */ - SDL_SCANCODE_Y, /* VirtualKey.Y -- 89 */ - SDL_SCANCODE_Z, /* VirtualKey.Z -- 90 */ - SDL_SCANCODE_UNKNOWN, /* VirtualKey.LeftWindows -- 91 (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_LGUI ?) */ - SDL_SCANCODE_UNKNOWN, /* VirtualKey.RightWindows -- 92 (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_RGUI ?) */ - SDL_SCANCODE_APPLICATION, /* VirtualKey.Application -- 93 */ - SDL_SCANCODE_UNKNOWN, /* -- 94 */ - SDL_SCANCODE_SLEEP, /* VirtualKey.Sleep -- 95 */ - SDL_SCANCODE_KP_0, /* VirtualKey.NumberPad0 -- 96 */ - SDL_SCANCODE_KP_1, /* VirtualKey.NumberPad1 -- 97 */ - SDL_SCANCODE_KP_2, /* VirtualKey.NumberPad2 -- 98 */ - SDL_SCANCODE_KP_3, /* VirtualKey.NumberPad3 -- 99 */ - SDL_SCANCODE_KP_4, /* VirtualKey.NumberPad4 -- 100 */ - SDL_SCANCODE_KP_5, /* VirtualKey.NumberPad5 -- 101 */ - SDL_SCANCODE_KP_6, /* VirtualKey.NumberPad6 -- 102 */ - SDL_SCANCODE_KP_7, /* VirtualKey.NumberPad7 -- 103 */ - SDL_SCANCODE_KP_8, /* VirtualKey.NumberPad8 -- 104 */ - SDL_SCANCODE_KP_9, /* VirtualKey.NumberPad9 -- 105 */ - SDL_SCANCODE_KP_MULTIPLY, /* VirtualKey.Multiply -- 106 */ - SDL_SCANCODE_KP_PLUS, /* VirtualKey.Add -- 107 */ - SDL_SCANCODE_UNKNOWN, /* VirtualKey.Separator -- 108 */ - SDL_SCANCODE_KP_MINUS, /* VirtualKey.Subtract -- 109 */ - SDL_SCANCODE_UNKNOWN, /* VirtualKey.Decimal -- 110 (maybe SDL_SCANCODE_DECIMALSEPARATOR, SDL_SCANCODE_KP_DECIMAL, or SDL_SCANCODE_KP_PERIOD ?) */ - SDL_SCANCODE_KP_DIVIDE, /* VirtualKey.Divide -- 111 */ - SDL_SCANCODE_F1, /* VirtualKey.F1 -- 112 */ - SDL_SCANCODE_F2, /* VirtualKey.F2 -- 113 */ - SDL_SCANCODE_F3, /* VirtualKey.F3 -- 114 */ - SDL_SCANCODE_F4, /* VirtualKey.F4 -- 115 */ - SDL_SCANCODE_F5, /* VirtualKey.F5 -- 116 */ - SDL_SCANCODE_F6, /* VirtualKey.F6 -- 117 */ - SDL_SCANCODE_F7, /* VirtualKey.F7 -- 118 */ - SDL_SCANCODE_F8, /* VirtualKey.F8 -- 119 */ - SDL_SCANCODE_F9, /* VirtualKey.F9 -- 120 */ - SDL_SCANCODE_F10, /* VirtualKey.F10 -- 121 */ - SDL_SCANCODE_F11, /* VirtualKey.F11 -- 122 */ - SDL_SCANCODE_F12, /* VirtualKey.F12 -- 123 */ - SDL_SCANCODE_F13, /* VirtualKey.F13 -- 124 */ - SDL_SCANCODE_F14, /* VirtualKey.F14 -- 125 */ - SDL_SCANCODE_F15, /* VirtualKey.F15 -- 126 */ - SDL_SCANCODE_F16, /* VirtualKey.F16 -- 127 */ - SDL_SCANCODE_F17, /* VirtualKey.F17 -- 128 */ - SDL_SCANCODE_F18, /* VirtualKey.F18 -- 129 */ - SDL_SCANCODE_F19, /* VirtualKey.F19 -- 130 */ - SDL_SCANCODE_F20, /* VirtualKey.F20 -- 131 */ - SDL_SCANCODE_F21, /* VirtualKey.F21 -- 132 */ - SDL_SCANCODE_F22, /* VirtualKey.F22 -- 133 */ - SDL_SCANCODE_F23, /* VirtualKey.F23 -- 134 */ - SDL_SCANCODE_F24, /* VirtualKey.F24 -- 135 */ - SDL_SCANCODE_UNKNOWN, /* -- 136 */ - SDL_SCANCODE_UNKNOWN, /* -- 137 */ - SDL_SCANCODE_UNKNOWN, /* -- 138 */ - SDL_SCANCODE_UNKNOWN, /* -- 139 */ - SDL_SCANCODE_UNKNOWN, /* -- 140 */ - SDL_SCANCODE_UNKNOWN, /* -- 141 */ - SDL_SCANCODE_UNKNOWN, /* -- 142 */ - SDL_SCANCODE_UNKNOWN, /* -- 143 */ - SDL_SCANCODE_NUMLOCKCLEAR, /* VirtualKey.NumberKeyLock -- 144 */ - SDL_SCANCODE_SCROLLLOCK, /* VirtualKey.Scroll -- 145 */ - SDL_SCANCODE_UNKNOWN, /* -- 146 */ - SDL_SCANCODE_UNKNOWN, /* -- 147 */ - SDL_SCANCODE_UNKNOWN, /* -- 148 */ - SDL_SCANCODE_UNKNOWN, /* -- 149 */ - SDL_SCANCODE_UNKNOWN, /* -- 150 */ - SDL_SCANCODE_UNKNOWN, /* -- 151 */ - SDL_SCANCODE_UNKNOWN, /* -- 152 */ - SDL_SCANCODE_UNKNOWN, /* -- 153 */ - SDL_SCANCODE_UNKNOWN, /* -- 154 */ - SDL_SCANCODE_UNKNOWN, /* -- 155 */ - SDL_SCANCODE_UNKNOWN, /* -- 156 */ - SDL_SCANCODE_UNKNOWN, /* -- 157 */ - SDL_SCANCODE_UNKNOWN, /* -- 158 */ - SDL_SCANCODE_UNKNOWN, /* -- 159 */ - SDL_SCANCODE_LSHIFT, /* VirtualKey.LeftShift -- 160 */ - SDL_SCANCODE_RSHIFT, /* VirtualKey.RightShift -- 161 */ - SDL_SCANCODE_LCTRL, /* VirtualKey.LeftControl -- 162 */ - SDL_SCANCODE_RCTRL, /* VirtualKey.RightControl -- 163 */ - SDL_SCANCODE_MENU, /* VirtualKey.LeftMenu -- 164 */ - SDL_SCANCODE_MENU, /* VirtualKey.RightMenu -- 165 */ - SDL_SCANCODE_AC_BACK, /* VirtualKey.GoBack -- 166 : The go back key. */ - SDL_SCANCODE_AC_FORWARD, /* VirtualKey.GoForward -- 167 : The go forward key. */ - SDL_SCANCODE_AC_REFRESH, /* VirtualKey.Refresh -- 168 : The refresh key. */ - SDL_SCANCODE_AC_STOP, /* VirtualKey.Stop -- 169 : The stop key. */ - SDL_SCANCODE_AC_SEARCH, /* VirtualKey.Search -- 170 : The search key. */ - SDL_SCANCODE_AC_BOOKMARKS, /* VirtualKey.Favorites -- 171 : The favorites key. */ - SDL_SCANCODE_AC_HOME /* VirtualKey.GoHome -- 172 : The go home key. */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.None -- 0 */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.LeftButton -- 1 */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.RightButton -- 2 */ + SDL_SCANCODE_CANCEL, /* VirtualKey.Cancel -- 3 */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.MiddleButton -- 4 */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.XButton1 -- 5 */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.XButton2 -- 6 */ + SDL_SCANCODE_UNKNOWN, /* -- 7 */ + SDL_SCANCODE_BACKSPACE, /* VirtualKey.Back -- 8 */ + SDL_SCANCODE_TAB, /* VirtualKey.Tab -- 9 */ + SDL_SCANCODE_UNKNOWN, /* -- 10 */ + SDL_SCANCODE_UNKNOWN, /* -- 11 */ + SDL_SCANCODE_CLEAR, /* VirtualKey.Clear -- 12 */ + SDL_SCANCODE_RETURN, /* VirtualKey.Enter -- 13 */ + SDL_SCANCODE_UNKNOWN, /* -- 14 */ + SDL_SCANCODE_UNKNOWN, /* -- 15 */ + SDL_SCANCODE_LSHIFT, /* VirtualKey.Shift -- 16 */ + SDL_SCANCODE_LCTRL, /* VirtualKey.Control -- 17 */ + SDL_SCANCODE_MENU, /* VirtualKey.Menu -- 18 */ + SDL_SCANCODE_PAUSE, /* VirtualKey.Pause -- 19 */ + SDL_SCANCODE_CAPSLOCK, /* VirtualKey.CapitalLock -- 20 */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.Kana or VirtualKey.Hangul -- 21 */ + SDL_SCANCODE_UNKNOWN, /* -- 22 */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.Junja -- 23 */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.Final -- 24 */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.Hanja or VirtualKey.Kanji -- 25 */ + SDL_SCANCODE_UNKNOWN, /* -- 26 */ + SDL_SCANCODE_ESCAPE, /* VirtualKey.Escape -- 27 */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.Convert -- 28 */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.NonConvert -- 29 */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.Accept -- 30 */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.ModeChange -- 31 (maybe SDL_SCANCODE_MODE ?) */ + SDL_SCANCODE_SPACE, /* VirtualKey.Space -- 32 */ + SDL_SCANCODE_PAGEUP, /* VirtualKey.PageUp -- 33 */ + SDL_SCANCODE_PAGEDOWN, /* VirtualKey.PageDown -- 34 */ + SDL_SCANCODE_END, /* VirtualKey.End -- 35 */ + SDL_SCANCODE_HOME, /* VirtualKey.Home -- 36 */ + SDL_SCANCODE_LEFT, /* VirtualKey.Left -- 37 */ + SDL_SCANCODE_UP, /* VirtualKey.Up -- 38 */ + SDL_SCANCODE_RIGHT, /* VirtualKey.Right -- 39 */ + SDL_SCANCODE_DOWN, /* VirtualKey.Down -- 40 */ + SDL_SCANCODE_SELECT, /* VirtualKey.Select -- 41 */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.Print -- 42 (maybe SDL_SCANCODE_PRINTSCREEN ?) */ + SDL_SCANCODE_EXECUTE, /* VirtualKey.Execute -- 43 */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.Snapshot -- 44 */ + SDL_SCANCODE_INSERT, /* VirtualKey.Insert -- 45 */ + SDL_SCANCODE_DELETE, /* VirtualKey.Delete -- 46 */ + SDL_SCANCODE_HELP, /* VirtualKey.Help -- 47 */ + SDL_SCANCODE_0, /* VirtualKey.Number0 -- 48 */ + SDL_SCANCODE_1, /* VirtualKey.Number1 -- 49 */ + SDL_SCANCODE_2, /* VirtualKey.Number2 -- 50 */ + SDL_SCANCODE_3, /* VirtualKey.Number3 -- 51 */ + SDL_SCANCODE_4, /* VirtualKey.Number4 -- 52 */ + SDL_SCANCODE_5, /* VirtualKey.Number5 -- 53 */ + SDL_SCANCODE_6, /* VirtualKey.Number6 -- 54 */ + SDL_SCANCODE_7, /* VirtualKey.Number7 -- 55 */ + SDL_SCANCODE_8, /* VirtualKey.Number8 -- 56 */ + SDL_SCANCODE_9, /* VirtualKey.Number9 -- 57 */ + SDL_SCANCODE_UNKNOWN, /* -- 58 */ + SDL_SCANCODE_UNKNOWN, /* -- 59 */ + SDL_SCANCODE_UNKNOWN, /* -- 60 */ + SDL_SCANCODE_UNKNOWN, /* -- 61 */ + SDL_SCANCODE_UNKNOWN, /* -- 62 */ + SDL_SCANCODE_UNKNOWN, /* -- 63 */ + SDL_SCANCODE_UNKNOWN, /* -- 64 */ + SDL_SCANCODE_A, /* VirtualKey.A -- 65 */ + SDL_SCANCODE_B, /* VirtualKey.B -- 66 */ + SDL_SCANCODE_C, /* VirtualKey.C -- 67 */ + SDL_SCANCODE_D, /* VirtualKey.D -- 68 */ + SDL_SCANCODE_E, /* VirtualKey.E -- 69 */ + SDL_SCANCODE_F, /* VirtualKey.F -- 70 */ + SDL_SCANCODE_G, /* VirtualKey.G -- 71 */ + SDL_SCANCODE_H, /* VirtualKey.H -- 72 */ + SDL_SCANCODE_I, /* VirtualKey.I -- 73 */ + SDL_SCANCODE_J, /* VirtualKey.J -- 74 */ + SDL_SCANCODE_K, /* VirtualKey.K -- 75 */ + SDL_SCANCODE_L, /* VirtualKey.L -- 76 */ + SDL_SCANCODE_M, /* VirtualKey.M -- 77 */ + SDL_SCANCODE_N, /* VirtualKey.N -- 78 */ + SDL_SCANCODE_O, /* VirtualKey.O -- 79 */ + SDL_SCANCODE_P, /* VirtualKey.P -- 80 */ + SDL_SCANCODE_Q, /* VirtualKey.Q -- 81 */ + SDL_SCANCODE_R, /* VirtualKey.R -- 82 */ + SDL_SCANCODE_S, /* VirtualKey.S -- 83 */ + SDL_SCANCODE_T, /* VirtualKey.T -- 84 */ + SDL_SCANCODE_U, /* VirtualKey.U -- 85 */ + SDL_SCANCODE_V, /* VirtualKey.V -- 86 */ + SDL_SCANCODE_W, /* VirtualKey.W -- 87 */ + SDL_SCANCODE_X, /* VirtualKey.X -- 88 */ + SDL_SCANCODE_Y, /* VirtualKey.Y -- 89 */ + SDL_SCANCODE_Z, /* VirtualKey.Z -- 90 */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.LeftWindows -- 91 (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_LGUI ?) */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.RightWindows -- 92 (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_RGUI ?) */ + SDL_SCANCODE_APPLICATION, /* VirtualKey.Application -- 93 */ + SDL_SCANCODE_UNKNOWN, /* -- 94 */ + SDL_SCANCODE_SLEEP, /* VirtualKey.Sleep -- 95 */ + SDL_SCANCODE_KP_0, /* VirtualKey.NumberPad0 -- 96 */ + SDL_SCANCODE_KP_1, /* VirtualKey.NumberPad1 -- 97 */ + SDL_SCANCODE_KP_2, /* VirtualKey.NumberPad2 -- 98 */ + SDL_SCANCODE_KP_3, /* VirtualKey.NumberPad3 -- 99 */ + SDL_SCANCODE_KP_4, /* VirtualKey.NumberPad4 -- 100 */ + SDL_SCANCODE_KP_5, /* VirtualKey.NumberPad5 -- 101 */ + SDL_SCANCODE_KP_6, /* VirtualKey.NumberPad6 -- 102 */ + SDL_SCANCODE_KP_7, /* VirtualKey.NumberPad7 -- 103 */ + SDL_SCANCODE_KP_8, /* VirtualKey.NumberPad8 -- 104 */ + SDL_SCANCODE_KP_9, /* VirtualKey.NumberPad9 -- 105 */ + SDL_SCANCODE_KP_MULTIPLY, /* VirtualKey.Multiply -- 106 */ + SDL_SCANCODE_KP_PLUS, /* VirtualKey.Add -- 107 */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.Separator -- 108 */ + SDL_SCANCODE_KP_MINUS, /* VirtualKey.Subtract -- 109 */ + SDL_SCANCODE_UNKNOWN, /* VirtualKey.Decimal -- 110 (maybe SDL_SCANCODE_DECIMALSEPARATOR, SDL_SCANCODE_KP_DECIMAL, or SDL_SCANCODE_KP_PERIOD ?) */ + SDL_SCANCODE_KP_DIVIDE, /* VirtualKey.Divide -- 111 */ + SDL_SCANCODE_F1, /* VirtualKey.F1 -- 112 */ + SDL_SCANCODE_F2, /* VirtualKey.F2 -- 113 */ + SDL_SCANCODE_F3, /* VirtualKey.F3 -- 114 */ + SDL_SCANCODE_F4, /* VirtualKey.F4 -- 115 */ + SDL_SCANCODE_F5, /* VirtualKey.F5 -- 116 */ + SDL_SCANCODE_F6, /* VirtualKey.F6 -- 117 */ + SDL_SCANCODE_F7, /* VirtualKey.F7 -- 118 */ + SDL_SCANCODE_F8, /* VirtualKey.F8 -- 119 */ + SDL_SCANCODE_F9, /* VirtualKey.F9 -- 120 */ + SDL_SCANCODE_F10, /* VirtualKey.F10 -- 121 */ + SDL_SCANCODE_F11, /* VirtualKey.F11 -- 122 */ + SDL_SCANCODE_F12, /* VirtualKey.F12 -- 123 */ + SDL_SCANCODE_F13, /* VirtualKey.F13 -- 124 */ + SDL_SCANCODE_F14, /* VirtualKey.F14 -- 125 */ + SDL_SCANCODE_F15, /* VirtualKey.F15 -- 126 */ + SDL_SCANCODE_F16, /* VirtualKey.F16 -- 127 */ + SDL_SCANCODE_F17, /* VirtualKey.F17 -- 128 */ + SDL_SCANCODE_F18, /* VirtualKey.F18 -- 129 */ + SDL_SCANCODE_F19, /* VirtualKey.F19 -- 130 */ + SDL_SCANCODE_F20, /* VirtualKey.F20 -- 131 */ + SDL_SCANCODE_F21, /* VirtualKey.F21 -- 132 */ + SDL_SCANCODE_F22, /* VirtualKey.F22 -- 133 */ + SDL_SCANCODE_F23, /* VirtualKey.F23 -- 134 */ + SDL_SCANCODE_F24, /* VirtualKey.F24 -- 135 */ + SDL_SCANCODE_UNKNOWN, /* -- 136 */ + SDL_SCANCODE_UNKNOWN, /* -- 137 */ + SDL_SCANCODE_UNKNOWN, /* -- 138 */ + SDL_SCANCODE_UNKNOWN, /* -- 139 */ + SDL_SCANCODE_UNKNOWN, /* -- 140 */ + SDL_SCANCODE_UNKNOWN, /* -- 141 */ + SDL_SCANCODE_UNKNOWN, /* -- 142 */ + SDL_SCANCODE_UNKNOWN, /* -- 143 */ + SDL_SCANCODE_NUMLOCKCLEAR, /* VirtualKey.NumberKeyLock -- 144 */ + SDL_SCANCODE_SCROLLLOCK, /* VirtualKey.Scroll -- 145 */ + SDL_SCANCODE_UNKNOWN, /* -- 146 */ + SDL_SCANCODE_UNKNOWN, /* -- 147 */ + SDL_SCANCODE_UNKNOWN, /* -- 148 */ + SDL_SCANCODE_UNKNOWN, /* -- 149 */ + SDL_SCANCODE_UNKNOWN, /* -- 150 */ + SDL_SCANCODE_UNKNOWN, /* -- 151 */ + SDL_SCANCODE_UNKNOWN, /* -- 152 */ + SDL_SCANCODE_UNKNOWN, /* -- 153 */ + SDL_SCANCODE_UNKNOWN, /* -- 154 */ + SDL_SCANCODE_UNKNOWN, /* -- 155 */ + SDL_SCANCODE_UNKNOWN, /* -- 156 */ + SDL_SCANCODE_UNKNOWN, /* -- 157 */ + SDL_SCANCODE_UNKNOWN, /* -- 158 */ + SDL_SCANCODE_UNKNOWN, /* -- 159 */ + SDL_SCANCODE_LSHIFT, /* VirtualKey.LeftShift -- 160 */ + SDL_SCANCODE_RSHIFT, /* VirtualKey.RightShift -- 161 */ + SDL_SCANCODE_LCTRL, /* VirtualKey.LeftControl -- 162 */ + SDL_SCANCODE_RCTRL, /* VirtualKey.RightControl -- 163 */ + SDL_SCANCODE_MENU, /* VirtualKey.LeftMenu -- 164 */ + SDL_SCANCODE_MENU, /* VirtualKey.RightMenu -- 165 */ + SDL_SCANCODE_AC_BACK, /* VirtualKey.GoBack -- 166 : The go back key. */ + SDL_SCANCODE_AC_FORWARD, /* VirtualKey.GoForward -- 167 : The go forward key. */ + SDL_SCANCODE_AC_REFRESH, /* VirtualKey.Refresh -- 168 : The refresh key. */ + SDL_SCANCODE_AC_STOP, /* VirtualKey.Stop -- 169 : The stop key. */ + SDL_SCANCODE_AC_SEARCH, /* VirtualKey.Search -- 170 : The search key. */ + SDL_SCANCODE_AC_BOOKMARKS, /* VirtualKey.Favorites -- 171 : The favorites key. */ + SDL_SCANCODE_AC_HOME /* VirtualKey.GoHome -- 172 : The go home key. */ }; /* Attempt to translate a keycode that isn't listed in WinRT's VirtualKey enum. */ -static SDL_Scancode -WINRT_TranslateUnofficialKeycode(int keycode) +static SDL_Scancode WINRT_TranslateUnofficialKeycode(int keycode) { switch (keycode) { - case 173: return SDL_SCANCODE_MUTE; /* VK_VOLUME_MUTE */ - case 174: return SDL_SCANCODE_VOLUMEDOWN; /* VK_VOLUME_DOWN */ - case 175: return SDL_SCANCODE_VOLUMEUP; /* VK_VOLUME_UP */ - case 176: return SDL_SCANCODE_AUDIONEXT; /* VK_MEDIA_NEXT_TRACK */ - case 177: return SDL_SCANCODE_AUDIOPREV; /* VK_MEDIA_PREV_TRACK */ - // case 178: return ; /* VK_MEDIA_STOP */ - case 179: return SDL_SCANCODE_AUDIOPLAY; /* VK_MEDIA_PLAY_PAUSE */ - case 180: return SDL_SCANCODE_MAIL; /* VK_LAUNCH_MAIL */ - case 181: return SDL_SCANCODE_MEDIASELECT; /* VK_LAUNCH_MEDIA_SELECT */ - // case 182: return ; /* VK_LAUNCH_APP1 */ - case 183: return SDL_SCANCODE_CALCULATOR; /* VK_LAUNCH_APP2 */ - // case 184: return ; /* ... reserved ... */ - // case 185: return ; /* ... reserved ... */ - case 186: return SDL_SCANCODE_SEMICOLON; /* VK_OEM_1, ';:' key on US standard keyboards */ - case 187: return SDL_SCANCODE_EQUALS; /* VK_OEM_PLUS */ - case 188: return SDL_SCANCODE_COMMA; /* VK_OEM_COMMA */ - case 189: return SDL_SCANCODE_MINUS; /* VK_OEM_MINUS */ - case 190: return SDL_SCANCODE_PERIOD; /* VK_OEM_PERIOD */ - case 191: return SDL_SCANCODE_SLASH; /* VK_OEM_2, '/?' key on US standard keyboards */ - case 192: return SDL_SCANCODE_GRAVE; /* VK_OEM_3, '`~' key on US standard keyboards */ - // ? - // ... reserved or unassigned ... - // ? - case 219: return SDL_SCANCODE_LEFTBRACKET; /* VK_OEM_4, '[{' key on US standard keyboards */ - case 220: return SDL_SCANCODE_BACKSLASH; /* VK_OEM_5, '\|' key on US standard keyboards */ - case 221: return SDL_SCANCODE_RIGHTBRACKET; /* VK_OEM_6, ']}' key on US standard keyboards */ - case 222: return SDL_SCANCODE_APOSTROPHE; /* VK_OEM_7, 'single/double quote' on US standard keyboards */ - default: break; + case 173: + return SDL_SCANCODE_MUTE; /* VK_VOLUME_MUTE */ + case 174: + return SDL_SCANCODE_VOLUMEDOWN; /* VK_VOLUME_DOWN */ + case 175: + return SDL_SCANCODE_VOLUMEUP; /* VK_VOLUME_UP */ + case 176: + return SDL_SCANCODE_AUDIONEXT; /* VK_MEDIA_NEXT_TRACK */ + case 177: + return SDL_SCANCODE_AUDIOPREV; /* VK_MEDIA_PREV_TRACK */ + // case 178: return ; /* VK_MEDIA_STOP */ + case 179: + return SDL_SCANCODE_AUDIOPLAY; /* VK_MEDIA_PLAY_PAUSE */ + case 180: + return SDL_SCANCODE_MAIL; /* VK_LAUNCH_MAIL */ + case 181: + return SDL_SCANCODE_MEDIASELECT; /* VK_LAUNCH_MEDIA_SELECT */ + // case 182: return ; /* VK_LAUNCH_APP1 */ + case 183: + return SDL_SCANCODE_CALCULATOR; /* VK_LAUNCH_APP2 */ + // case 184: return ; /* ... reserved ... */ + // case 185: return ; /* ... reserved ... */ + case 186: + return SDL_SCANCODE_SEMICOLON; /* VK_OEM_1, ';:' key on US standard keyboards */ + case 187: + return SDL_SCANCODE_EQUALS; /* VK_OEM_PLUS */ + case 188: + return SDL_SCANCODE_COMMA; /* VK_OEM_COMMA */ + case 189: + return SDL_SCANCODE_MINUS; /* VK_OEM_MINUS */ + case 190: + return SDL_SCANCODE_PERIOD; /* VK_OEM_PERIOD */ + case 191: + return SDL_SCANCODE_SLASH; /* VK_OEM_2, '/?' key on US standard keyboards */ + case 192: + return SDL_SCANCODE_GRAVE; /* VK_OEM_3, '`~' key on US standard keyboards */ + // ? + // ... reserved or unassigned ... + // ? + case 219: + return SDL_SCANCODE_LEFTBRACKET; /* VK_OEM_4, '[{' key on US standard keyboards */ + case 220: + return SDL_SCANCODE_BACKSLASH; /* VK_OEM_5, '\|' key on US standard keyboards */ + case 221: + return SDL_SCANCODE_RIGHTBRACKET; /* VK_OEM_6, ']}' key on US standard keyboards */ + case 222: + return SDL_SCANCODE_APOSTROPHE; /* VK_OEM_7, 'single/double quote' on US standard keyboards */ + default: + break; } return SDL_SCANCODE_UNKNOWN; } -static SDL_Scancode -WINRT_TranslateKeycode(int keycode, unsigned int nativeScancode) +static SDL_Scancode WINRT_TranslateKeycode(int keycode, unsigned int nativeScancode) { // TODO, WinRT: try filling out the WinRT keycode table as much as possible, using the Win32 table for interpretation hints @@ -271,21 +288,21 @@ WINRT_TranslateKeycode(int keycode, unsigned int nativeScancode) */ if (nativeScancode < SDL_arraysize(windows_scancode_table)) { switch (keycode) { - case 16: // VirtualKey.Shift - switch (windows_scancode_table[nativeScancode]) { - case SDL_SCANCODE_LSHIFT: - case SDL_SCANCODE_RSHIFT: - return windows_scancode_table[nativeScancode]; - } - break; - + case 16: // VirtualKey.Shift + switch (windows_scancode_table[nativeScancode]) { + case SDL_SCANCODE_LSHIFT: + case SDL_SCANCODE_RSHIFT: + return windows_scancode_table[nativeScancode]; + } + break; + // Add others, as necessary. // // Unfortunately, this hack doesn't seem to work in determining // handedness with Control keys. - default: - break; + default: + break; } } @@ -313,8 +330,7 @@ WINRT_TranslateKeycode(int keycode, unsigned int nativeScancode) return scancode; } -void -WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^args) +void WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^ args) { SDL_Scancode sdlScancode = WINRT_TranslateKeycode((int)args->VirtualKey, args->KeyStatus.ScanCode); #if 0 @@ -339,8 +355,7 @@ WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^args) SDL_SendKeyboardKey(SDL_PRESSED, sdlScancode); } -void -WINRT_ProcessKeyUpEvent(Windows::UI::Core::KeyEventArgs ^args) +void WINRT_ProcessKeyUpEvent(Windows::UI::Core::KeyEventArgs ^ args) { SDL_Scancode sdlScancode = WINRT_TranslateKeycode((int)args->VirtualKey, args->KeyStatus.ScanCode); #if 0 @@ -365,8 +380,7 @@ WINRT_ProcessKeyUpEvent(Windows::UI::Core::KeyEventArgs ^args) SDL_SendKeyboardKey(SDL_RELEASED, sdlScancode); } -void -WINRT_ProcessCharacterReceivedEvent(Windows::UI::Core::CharacterReceivedEventArgs ^args) +void WINRT_ProcessCharacterReceivedEvent(Windows::UI::Core::CharacterReceivedEventArgs ^ args) { wchar_t src_ucs2[2]; char dest_utf8[16]; @@ -383,7 +397,6 @@ WINRT_ProcessCharacterReceivedEvent(Windows::UI::Core::CharacterReceivedEventArg } } - #if NTDDI_VERSION >= NTDDI_WIN10 static bool WINRT_InputPaneVisible = false; @@ -403,10 +416,10 @@ void WINTRT_InitialiseInputPaneEvents(_THIS) using namespace Windows::UI::ViewManagement; InputPane ^ inputPane = InputPane::GetForCurrentView(); if (inputPane) { - inputPane->Showing += ref new Windows::Foundation::TypedEventHandler(&WINTRT_OnInputPaneShowing); - inputPane->Hiding += ref new Windows::Foundation::TypedEventHandler(&WINTRT_OnInputPaneHiding); + inputPane->Showing += ref new Windows::Foundation::TypedEventHandler(&WINTRT_OnInputPaneShowing); + inputPane->Hiding += ref new Windows::Foundation::TypedEventHandler(&WINTRT_OnInputPaneHiding); } } @@ -440,17 +453,17 @@ SDL_bool WINRT_IsScreenKeyboardShown(_THIS, SDL_Window *window) if (inputPane) { switch (SDL_WinRTGetDeviceFamily()) { case SDL_WINRT_DEVICEFAMILY_XBOX: - //Documentation recommends using inputPane->Visible - //https://learn.microsoft.com/en-us/uwp/api/windows.ui.viewmanagement.inputpane.visible?view=winrt-22621 - //This does not seem to work on latest UWP/Xbox. - //Workaround: Listen to Showing/Hiding events + // Documentation recommends using inputPane->Visible + // https://learn.microsoft.com/en-us/uwp/api/windows.ui.viewmanagement.inputpane.visible?view=winrt-22621 + // This does not seem to work on latest UWP/Xbox. + // Workaround: Listen to Showing/Hiding events if (WINRT_InputPaneVisible) { return SDL_TRUE; } break; default: - //OccludedRect is recommend on universal apps per docs - //https://learn.microsoft.com/en-us/uwp/api/windows.ui.viewmanagement.inputpane.visible?view=winrt-22621 + // OccludedRect is recommend on universal apps per docs + // https://learn.microsoft.com/en-us/uwp/api/windows.ui.viewmanagement.inputpane.visible?view=winrt-22621 Windows::Foundation::Rect rect = inputPane->OccludedRect; if (rect.Width > 0 && rect.Height > 0) { return SDL_TRUE; @@ -461,6 +474,6 @@ SDL_bool WINRT_IsScreenKeyboardShown(_THIS, SDL_Window *window) return SDL_FALSE; } -#endif // NTDDI_VERSION >= ... +#endif // NTDDI_VERSION >= ... -#endif // SDL_VIDEO_DRIVER_WINRT \ No newline at end of file +#endif // SDL_VIDEO_DRIVER_WINRT diff --git a/src/video/winrt/SDL_winrtmessagebox.cpp b/src/video/winrt/SDL_winrtmessagebox.cpp index f74a7f483..014039862 100644 --- a/src/video/winrt/SDL_winrtmessagebox.cpp +++ b/src/video/winrt/SDL_winrtmessagebox.cpp @@ -34,23 +34,20 @@ using namespace Platform; using namespace Windows::Foundation; using namespace Windows::UI::Popups; -static String ^ -WINRT_UTF8ToPlatformString(const char * str) -{ - wchar_t * wstr = WIN_UTF8ToString(str); +static String ^ WINRT_UTF8ToPlatformString(const char *str) { + wchar_t *wstr = WIN_UTF8ToString(str); String ^ rtstr = ref new String(wstr); SDL_free(wstr); return rtstr; } -extern "C" int -WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) + extern "C" int WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { #if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) && (NTDDI_VERSION == NTDDI_WIN8) /* Sadly, Windows Phone 8 doesn't include the MessageDialog class that * Windows 8.x/RT does, even though MSDN's reference documentation for * Windows Phone 8 mentions it. - * + * * The .NET runtime on Windows Phone 8 does, however, include a * MessageBox class. Perhaps this could be called, somehow? */ @@ -60,15 +57,15 @@ WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP const int maxbuttons = 2; - const char * platform = "Windows Phone 8.1+"; + const char *platform = "Windows Phone 8.1+"; #else const int maxbuttons = 3; - const char * platform = "Windows 8.x"; + const char *platform = "Windows 8.x"; #endif if (messageboxdata->numbuttons > maxbuttons) { return SDL_SetError("WinRT's MessageDialog only supports %d buttons, at most, on %s. %d were requested.", - maxbuttons, platform, messageboxdata->numbuttons); + maxbuttons, platform, messageboxdata->numbuttons); } /* Build a MessageDialog object and its buttons */ @@ -115,4 +112,3 @@ WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) #endif /* SDL_VIDEO_DRIVER_WINRT */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/video/winrt/SDL_winrtmouse.cpp b/src/video/winrt/SDL_winrtmouse.cpp index 8c32e5fcf..7e5974776 100644 --- a/src/video/winrt/SDL_winrtmouse.cpp +++ b/src/video/winrt/SDL_winrtmouse.cpp @@ -44,45 +44,65 @@ extern "C" { #include "SDL_winrtvideo_cpp.h" #include "SDL_winrtmouse_c.h" - extern "C" SDL_bool WINRT_UsingRelativeMouseMode = SDL_FALSE; - -static SDL_Cursor * -WINRT_CreateSystemCursor(SDL_SystemCursor id) +static SDL_Cursor *WINRT_CreateSystemCursor(SDL_SystemCursor id) { SDL_Cursor *cursor; CoreCursorType cursorType = CoreCursorType::Arrow; - switch(id) - { + switch (id) { default: SDL_assert(0); return NULL; - case SDL_SYSTEM_CURSOR_ARROW: cursorType = CoreCursorType::Arrow; break; - case SDL_SYSTEM_CURSOR_IBEAM: cursorType = CoreCursorType::IBeam; break; - case SDL_SYSTEM_CURSOR_WAIT: cursorType = CoreCursorType::Wait; break; - case SDL_SYSTEM_CURSOR_CROSSHAIR: cursorType = CoreCursorType::Cross; break; - case SDL_SYSTEM_CURSOR_WAITARROW: cursorType = CoreCursorType::Wait; break; - case SDL_SYSTEM_CURSOR_SIZENWSE: cursorType = CoreCursorType::SizeNorthwestSoutheast; break; - case SDL_SYSTEM_CURSOR_SIZENESW: cursorType = CoreCursorType::SizeNortheastSouthwest; break; - case SDL_SYSTEM_CURSOR_SIZEWE: cursorType = CoreCursorType::SizeWestEast; break; - case SDL_SYSTEM_CURSOR_SIZENS: cursorType = CoreCursorType::SizeNorthSouth; break; - case SDL_SYSTEM_CURSOR_SIZEALL: cursorType = CoreCursorType::SizeAll; break; - case SDL_SYSTEM_CURSOR_NO: cursorType = CoreCursorType::UniversalNo; break; - case SDL_SYSTEM_CURSOR_HAND: cursorType = CoreCursorType::Hand; break; + case SDL_SYSTEM_CURSOR_ARROW: + cursorType = CoreCursorType::Arrow; + break; + case SDL_SYSTEM_CURSOR_IBEAM: + cursorType = CoreCursorType::IBeam; + break; + case SDL_SYSTEM_CURSOR_WAIT: + cursorType = CoreCursorType::Wait; + break; + case SDL_SYSTEM_CURSOR_CROSSHAIR: + cursorType = CoreCursorType::Cross; + break; + case SDL_SYSTEM_CURSOR_WAITARROW: + cursorType = CoreCursorType::Wait; + break; + case SDL_SYSTEM_CURSOR_SIZENWSE: + cursorType = CoreCursorType::SizeNorthwestSoutheast; + break; + case SDL_SYSTEM_CURSOR_SIZENESW: + cursorType = CoreCursorType::SizeNortheastSouthwest; + break; + case SDL_SYSTEM_CURSOR_SIZEWE: + cursorType = CoreCursorType::SizeWestEast; + break; + case SDL_SYSTEM_CURSOR_SIZENS: + cursorType = CoreCursorType::SizeNorthSouth; + break; + case SDL_SYSTEM_CURSOR_SIZEALL: + cursorType = CoreCursorType::SizeAll; + break; + case SDL_SYSTEM_CURSOR_NO: + cursorType = CoreCursorType::UniversalNo; + break; + case SDL_SYSTEM_CURSOR_HAND: + cursorType = CoreCursorType::Hand; + break; } - cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor)); + cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor)); if (cursor) { /* Create a pointer to a COM reference to a cursor. The extra pointer is used (on top of the COM reference) to allow the cursor to be referenced by the SDL_cursor's driverdata field, which is a void pointer. */ - CoreCursor ^* theCursor = new CoreCursor^(nullptr); + CoreCursor ^ *theCursor = new CoreCursor ^ (nullptr); *theCursor = ref new CoreCursor(cursorType, 0); - cursor->driverdata = (void *) theCursor; + cursor->driverdata = (void *)theCursor; } else { SDL_OutOfMemory(); } @@ -90,34 +110,31 @@ WINRT_CreateSystemCursor(SDL_SystemCursor id) return cursor; } -static SDL_Cursor * -WINRT_CreateDefaultCursor() +static SDL_Cursor *WINRT_CreateDefaultCursor() { return WINRT_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); } -static void -WINRT_FreeCursor(SDL_Cursor * cursor) +static void WINRT_FreeCursor(SDL_Cursor *cursor) { if (cursor->driverdata) { - CoreCursor ^* theCursor = (CoreCursor ^*) cursor->driverdata; - *theCursor = nullptr; // Release the COM reference to the CoreCursor - delete theCursor; // Delete the pointer to the COM reference + CoreCursor ^ *theCursor = (CoreCursor ^ *)cursor->driverdata; + *theCursor = nullptr; // Release the COM reference to the CoreCursor + delete theCursor; // Delete the pointer to the COM reference } SDL_free(cursor); } -static int -WINRT_ShowCursor(SDL_Cursor * cursor) +static int WINRT_ShowCursor(SDL_Cursor *cursor) { // TODO, WinRT, XAML: make WINRT_ShowCursor work when XAML support is enabled. - if ( ! CoreWindow::GetForCurrentThread()) { + if (!CoreWindow::GetForCurrentThread()) { return 0; } CoreWindow ^ coreWindow = CoreWindow::GetForCurrentThread(); if (cursor) { - CoreCursor ^* theCursor = (CoreCursor ^*) cursor->driverdata; + CoreCursor ^ *theCursor = (CoreCursor ^ *)cursor->driverdata; coreWindow->PointerCursor = *theCursor; } else { // HACK ALERT: TL;DR - Hiding the cursor in WinRT/UWP apps is weird, and @@ -164,13 +181,13 @@ WINRT_ShowCursor(SDL_Cursor * cursor) // - src/main/winrt/SDL2-WinRTResources.rc -- declares the cursor resource, and its ID (of 5000) // - const unsigned int win32CursorResourceID = 5000; + const unsigned int win32CursorResourceID = 5000; CoreCursor ^ blankCursor = ref new CoreCursor(CoreCursorType::Custom, win32CursorResourceID); // Set 'PointerCursor' to 'blankCursor' in a way that shouldn't throw // an exception if the app hasn't loaded that resource. - ABI::Windows::UI::Core::ICoreCursor * iblankCursor = reinterpret_cast(blankCursor); - ABI::Windows::UI::Core::ICoreWindow * icoreWindow = reinterpret_cast(coreWindow); + ABI::Windows::UI::Core::ICoreCursor *iblankCursor = reinterpret_cast(blankCursor); + ABI::Windows::UI::Core::ICoreWindow *icoreWindow = reinterpret_cast(coreWindow); HRESULT hr = icoreWindow->put_PointerCursor(iblankCursor); if (FAILED(hr)) { // The app doesn't contain the cursor resource, or some other error @@ -182,15 +199,13 @@ WINRT_ShowCursor(SDL_Cursor * cursor) return 0; } -static int -WINRT_SetRelativeMouseMode(SDL_bool enabled) +static int WINRT_SetRelativeMouseMode(SDL_bool enabled) { WINRT_UsingRelativeMouseMode = enabled; return 0; } -void -WINRT_InitMouse(_THIS) +void WINRT_InitMouse(_THIS) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -201,19 +216,18 @@ WINRT_InitMouse(_THIS) */ #if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP - //mouse->CreateCursor = WINRT_CreateCursor; + // mouse->CreateCursor = WINRT_CreateCursor; mouse->CreateSystemCursor = WINRT_CreateSystemCursor; mouse->ShowCursor = WINRT_ShowCursor; mouse->FreeCursor = WINRT_FreeCursor; - //mouse->WarpMouse = WINRT_WarpMouse; + // mouse->WarpMouse = WINRT_WarpMouse; mouse->SetRelativeMouseMode = WINRT_SetRelativeMouseMode; SDL_SetDefaultCursor(WINRT_CreateDefaultCursor()); #endif } -void -WINRT_QuitMouse(_THIS) +void WINRT_QuitMouse(_THIS) { } diff --git a/src/video/winrt/SDL_winrtopengles.cpp b/src/video/winrt/SDL_winrtopengles.cpp index d5301006e..9dccce63b 100644 --- a/src/video/winrt/SDL_winrtopengles.cpp +++ b/src/video/winrt/SDL_winrtopengles.cpp @@ -37,17 +37,16 @@ using namespace Windows::UI::Core; /* ANGLE/WinRT constants */ static const int ANGLE_D3D_FEATURE_LEVEL_ANY = 0; -#define EGL_PLATFORM_ANGLE_ANGLE 0x3202 -#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203 -#define EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE 0x3204 -#define EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE 0x3205 -#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208 -#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE 0x3209 -#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE 0x320B -#define EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE 0x320F - -#define EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER 0x320B +#define EGL_PLATFORM_ANGLE_ANGLE 0x3202 +#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203 +#define EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE 0x3204 +#define EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE 0x3205 +#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208 +#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE 0x3209 +#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE 0x320B +#define EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE 0x320F +#define EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER 0x320B /* * SDL/EGL top-level implementation @@ -63,7 +62,7 @@ WINRT_GLES_LoadLibrary(_THIS, const char *path) } /* Load ANGLE/WinRT-specific functions */ - CreateWinrtEglWindow_Old_Function CreateWinrtEglWindow = (CreateWinrtEglWindow_Old_Function) SDL_LoadFunction(_this->egl_data->opengl_dll_handle, "CreateWinrtEglWindow"); + CreateWinrtEglWindow_Old_Function CreateWinrtEglWindow = (CreateWinrtEglWindow_Old_Function)SDL_LoadFunction(_this->egl_data->opengl_dll_handle, "CreateWinrtEglWindow"); if (CreateWinrtEglWindow) { /* 'CreateWinrtEglWindow' was found, which means that an an older * version of ANGLE/WinRT is being used. Continue setting up EGL, @@ -98,30 +97,39 @@ WINRT_GLES_LoadLibrary(_THIS, const char *path) /* Declare some ANGLE/EGL initialization property-sets, as suggested by * MSOpenTech's ANGLE-for-WinRT template apps: */ - const EGLint defaultDisplayAttributes[] = - { - EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, - EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, - EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE, + const EGLint defaultDisplayAttributes[] = { + EGL_PLATFORM_ANGLE_TYPE_ANGLE, + EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, + EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, + EGL_TRUE, + EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, + EGL_TRUE, EGL_NONE, }; - const EGLint fl9_3DisplayAttributes[] = - { - EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, - EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9, - EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, 3, - EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, - EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE, + const EGLint fl9_3DisplayAttributes[] = { + EGL_PLATFORM_ANGLE_TYPE_ANGLE, + EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, + EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, + 9, + EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, + 3, + EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, + EGL_TRUE, + EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, + EGL_TRUE, EGL_NONE, }; - const EGLint warpDisplayAttributes[] = - { - EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, - EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE, - EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, - EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE, + const EGLint warpDisplayAttributes[] = { + EGL_PLATFORM_ANGLE_TYPE_ANGLE, + EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, + EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE, + EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE, + EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, + EGL_TRUE, + EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, + EGL_TRUE, EGL_NONE, }; @@ -193,11 +201,10 @@ WINRT_GLES_UnloadLibrary(_THIS) extern "C" { SDL_EGL_CreateContext_impl(WINRT) -SDL_EGL_SwapWindow_impl(WINRT) -SDL_EGL_MakeCurrent_impl(WINRT) + SDL_EGL_SwapWindow_impl(WINRT) + SDL_EGL_MakeCurrent_impl(WINRT) } #endif /* SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/video/winrt/SDL_winrtopengles.h b/src/video/winrt/SDL_winrtopengles.h index c702c8b69..e9a765e72 100644 --- a/src/video/winrt/SDL_winrtopengles.h +++ b/src/video/winrt/SDL_winrtopengles.h @@ -33,14 +33,13 @@ #define WINRT_GLES_GetProcAddress SDL_EGL_GetProcAddress #define WINRT_GLES_SetSwapInterval SDL_EGL_SetSwapInterval #define WINRT_GLES_GetSwapInterval SDL_EGL_GetSwapInterval -#define WINRT_GLES_DeleteContext SDL_EGL_DeleteContext +#define WINRT_GLES_DeleteContext SDL_EGL_DeleteContext extern int WINRT_GLES_LoadLibrary(_THIS, const char *path); extern void WINRT_GLES_UnloadLibrary(_THIS); -extern SDL_GLContext WINRT_GLES_CreateContext(_THIS, SDL_Window * window); -extern int WINRT_GLES_SwapWindow(_THIS, SDL_Window * window); -extern int WINRT_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); - +extern SDL_GLContext WINRT_GLES_CreateContext(_THIS, SDL_Window *window); +extern int WINRT_GLES_SwapWindow(_THIS, SDL_Window *window); +extern int WINRT_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); #ifdef __cplusplus @@ -52,16 +51,16 @@ typedef Microsoft::WRL::ComPtr WINRT_EGLNativeWindowType_Old; /* Function pointer typedefs for 'old' ANGLE/WinRT's functions, which may * require that C++ objects be passed in: */ -typedef EGLDisplay (EGLAPIENTRY *eglGetDisplay_Old_Function)(WINRT_EGLNativeWindowType_Old); -typedef EGLSurface (EGLAPIENTRY *eglCreateWindowSurface_Old_Function)(EGLDisplay, EGLConfig, WINRT_EGLNativeWindowType_Old, const EGLint *); -typedef HRESULT (EGLAPIENTRY *CreateWinrtEglWindow_Old_Function)(Microsoft::WRL::ComPtr, int, IUnknown ** result); +typedef EGLDisplay(EGLAPIENTRY *eglGetDisplay_Old_Function)(WINRT_EGLNativeWindowType_Old); +typedef EGLSurface(EGLAPIENTRY *eglCreateWindowSurface_Old_Function)(EGLDisplay, EGLConfig, WINRT_EGLNativeWindowType_Old, const EGLint *); +typedef HRESULT(EGLAPIENTRY *CreateWinrtEglWindow_Old_Function)(Microsoft::WRL::ComPtr, int, IUnknown **result); #endif /* __cplusplus */ /* Function pointer typedefs for 'new' ANGLE/WinRT functions, which, unlike * the old functions, do not require C++ support and work with plain C. */ -typedef EGLDisplay (EGLAPIENTRY *eglGetPlatformDisplayEXT_Function)(EGLenum, void *, const EGLint *); +typedef EGLDisplay(EGLAPIENTRY *eglGetPlatformDisplayEXT_Function)(EGLenum, void *, const EGLint *); #endif /* SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL */ diff --git a/src/video/winrt/SDL_winrtpointerinput.cpp b/src/video/winrt/SDL_winrtpointerinput.cpp index 51cc93727..756dbf60f 100644 --- a/src/video/winrt/SDL_winrtpointerinput.cpp +++ b/src/video/winrt/SDL_winrtpointerinput.cpp @@ -38,19 +38,16 @@ extern "C" { /* File-specific globals: */ static SDL_TouchID WINRT_TouchID = 1; - -void -WINRT_InitTouch(_THIS) +void WINRT_InitTouch(_THIS) { SDL_AddTouch(WINRT_TouchID, SDL_TOUCH_DEVICE_DIRECT, ""); } - // // Applies necessary geometric transformations to raw cursor positions: // Windows::Foundation::Point -WINRT_TransformCursorPosition(SDL_Window * window, +WINRT_TransformCursorPosition(SDL_Window *window, Windows::Foundation::Point rawPosition, WINRT_CursorNormalizationType normalization) { @@ -61,7 +58,7 @@ WINRT_TransformCursorPosition(SDL_Window * window, return rawPosition; } - SDL_WindowData * windowData = (SDL_WindowData *) window->driverdata; + SDL_WindowData *windowData = (SDL_WindowData *)window->driverdata; if (windowData->coreWindow == nullptr) { // For some reason, the window isn't associated with a CoreWindow. // This might end up being the case as XAML support is extended. @@ -85,39 +82,38 @@ WINRT_TransformCursorPosition(SDL_Window * window, outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width; outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height; #else - switch (WINRT_DISPLAY_PROPERTY(CurrentOrientation)) - { - case DisplayOrientations::Portrait: - outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width; - outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height; - break; - case DisplayOrientations::PortraitFlipped: - outputPosition.X = 1.0f - (rawPosition.X / nativeWindow->Bounds.Width); - outputPosition.Y = 1.0f - (rawPosition.Y / nativeWindow->Bounds.Height); - break; - case DisplayOrientations::Landscape: - outputPosition.X = rawPosition.Y / nativeWindow->Bounds.Height; - outputPosition.Y = 1.0f - (rawPosition.X / nativeWindow->Bounds.Width); - break; - case DisplayOrientations::LandscapeFlipped: - outputPosition.X = 1.0f - (rawPosition.Y / nativeWindow->Bounds.Height); - outputPosition.Y = rawPosition.X / nativeWindow->Bounds.Width; - break; - default: - break; + switch (WINRT_DISPLAY_PROPERTY(CurrentOrientation)) { + case DisplayOrientations::Portrait: + outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width; + outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height; + break; + case DisplayOrientations::PortraitFlipped: + outputPosition.X = 1.0f - (rawPosition.X / nativeWindow->Bounds.Width); + outputPosition.Y = 1.0f - (rawPosition.Y / nativeWindow->Bounds.Height); + break; + case DisplayOrientations::Landscape: + outputPosition.X = rawPosition.Y / nativeWindow->Bounds.Height; + outputPosition.Y = 1.0f - (rawPosition.X / nativeWindow->Bounds.Width); + break; + case DisplayOrientations::LandscapeFlipped: + outputPosition.X = 1.0f - (rawPosition.Y / nativeWindow->Bounds.Height); + outputPosition.Y = rawPosition.X / nativeWindow->Bounds.Width; + break; + default: + break; } #endif if (normalization == TransformToSDLWindowSize) { - outputPosition.X *= ((float32) window->w); - outputPosition.Y *= ((float32) window->h); + outputPosition.X *= ((float32)window->w); + outputPosition.Y *= ((float32)window->h); } return outputPosition; } SDL_bool -WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt, Uint8 *button, Uint8 *pressed) +WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^ pt, Uint8 *button, Uint8 *pressed) { using namespace Windows::UI::Input; @@ -125,40 +121,39 @@ WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt, Uint8 *b *button = SDL_BUTTON_LEFT; return SDL_TRUE; #else - switch (pt->Properties->PointerUpdateKind) - { - case PointerUpdateKind::LeftButtonPressed: - case PointerUpdateKind::LeftButtonReleased: - *button = SDL_BUTTON_LEFT; - *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::LeftButtonPressed); - return SDL_TRUE; + switch (pt->Properties->PointerUpdateKind) { + case PointerUpdateKind::LeftButtonPressed: + case PointerUpdateKind::LeftButtonReleased: + *button = SDL_BUTTON_LEFT; + *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::LeftButtonPressed); + return SDL_TRUE; - case PointerUpdateKind::RightButtonPressed: - case PointerUpdateKind::RightButtonReleased: - *button = SDL_BUTTON_RIGHT; - *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::RightButtonPressed); - return SDL_TRUE; + case PointerUpdateKind::RightButtonPressed: + case PointerUpdateKind::RightButtonReleased: + *button = SDL_BUTTON_RIGHT; + *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::RightButtonPressed); + return SDL_TRUE; - case PointerUpdateKind::MiddleButtonPressed: - case PointerUpdateKind::MiddleButtonReleased: - *button = SDL_BUTTON_MIDDLE; - *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::MiddleButtonPressed); - return SDL_TRUE; + case PointerUpdateKind::MiddleButtonPressed: + case PointerUpdateKind::MiddleButtonReleased: + *button = SDL_BUTTON_MIDDLE; + *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::MiddleButtonPressed); + return SDL_TRUE; - case PointerUpdateKind::XButton1Pressed: - case PointerUpdateKind::XButton1Released: - *button = SDL_BUTTON_X1; - *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::XButton1Pressed); - return SDL_TRUE; + case PointerUpdateKind::XButton1Pressed: + case PointerUpdateKind::XButton1Released: + *button = SDL_BUTTON_X1; + *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::XButton1Pressed); + return SDL_TRUE; - case PointerUpdateKind::XButton2Pressed: - case PointerUpdateKind::XButton2Released: - *button = SDL_BUTTON_X2; - *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::XButton2Pressed); - return SDL_TRUE; + case PointerUpdateKind::XButton2Pressed: + case PointerUpdateKind::XButton2Released: + *button = SDL_BUTTON_X2; + *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::XButton2Pressed); + return SDL_TRUE; - default: - break; + default: + break; } #endif @@ -167,64 +162,63 @@ WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt, Uint8 *b return SDL_FALSE; } -//const char * -//WINRT_ConvertPointerUpdateKindToString(Windows::UI::Input::PointerUpdateKind kind) +// const char * +// WINRT_ConvertPointerUpdateKindToString(Windows::UI::Input::PointerUpdateKind kind) //{ -// using namespace Windows::UI::Input; +// using namespace Windows::UI::Input; // -// switch (kind) -// { -// case PointerUpdateKind::Other: -// return "Other"; -// case PointerUpdateKind::LeftButtonPressed: -// return "LeftButtonPressed"; -// case PointerUpdateKind::LeftButtonReleased: -// return "LeftButtonReleased"; -// case PointerUpdateKind::RightButtonPressed: -// return "RightButtonPressed"; -// case PointerUpdateKind::RightButtonReleased: -// return "RightButtonReleased"; -// case PointerUpdateKind::MiddleButtonPressed: -// return "MiddleButtonPressed"; -// case PointerUpdateKind::MiddleButtonReleased: -// return "MiddleButtonReleased"; -// case PointerUpdateKind::XButton1Pressed: -// return "XButton1Pressed"; -// case PointerUpdateKind::XButton1Released: -// return "XButton1Released"; -// case PointerUpdateKind::XButton2Pressed: -// return "XButton2Pressed"; -// case PointerUpdateKind::XButton2Released: -// return "XButton2Released"; -// } +// switch (kind) +// { +// case PointerUpdateKind::Other: +// return "Other"; +// case PointerUpdateKind::LeftButtonPressed: +// return "LeftButtonPressed"; +// case PointerUpdateKind::LeftButtonReleased: +// return "LeftButtonReleased"; +// case PointerUpdateKind::RightButtonPressed: +// return "RightButtonPressed"; +// case PointerUpdateKind::RightButtonReleased: +// return "RightButtonReleased"; +// case PointerUpdateKind::MiddleButtonPressed: +// return "MiddleButtonPressed"; +// case PointerUpdateKind::MiddleButtonReleased: +// return "MiddleButtonReleased"; +// case PointerUpdateKind::XButton1Pressed: +// return "XButton1Pressed"; +// case PointerUpdateKind::XButton1Released: +// return "XButton1Released"; +// case PointerUpdateKind::XButton2Pressed: +// return "XButton2Pressed"; +// case PointerUpdateKind::XButton2Released: +// return "XButton2Released"; +// } // -// return ""; -//} +// return ""; +// } -static bool -WINRT_IsTouchEvent(Windows::UI::Input::PointerPoint ^pointerPoint) +static bool WINRT_IsTouchEvent(Windows::UI::Input::PointerPoint ^ pointerPoint) { #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP return true; #else using namespace Windows::Devices::Input; switch (pointerPoint->PointerDevice->PointerDeviceType) { - case PointerDeviceType::Touch: - case PointerDeviceType::Pen: - return true; - default: - return false; + case PointerDeviceType::Touch: + case PointerDeviceType::Pen: + return true; + default: + return false; } #endif } -void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint) +void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint) { if (!window) { return; } - if ( ! WINRT_IsTouchEvent(pointerPoint)) { + if (!WINRT_IsTouchEvent(pointerPoint)) { Uint8 button, pressed; WINRT_GetSDLButtonForPointerPoint(pointerPoint, &button, &pressed); SDL_assert(pressed == 1); @@ -235,7 +229,7 @@ void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::Po SDL_SendTouch( WINRT_TouchID, - (SDL_FingerID) pointerPoint->PointerId, + (SDL_FingerID)pointerPoint->PointerId, window, SDL_TRUE, normalizedPoint.X, @@ -244,8 +238,7 @@ void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::Po } } -void -WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint) +void WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint) { if (!window || WINRT_UsingRelativeMouseMode) { return; @@ -254,7 +247,7 @@ WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPo Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne); Windows::Foundation::Point windowPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, TransformToSDLWindowSize); - if ( ! WINRT_IsTouchEvent(pointerPoint)) { + if (!WINRT_IsTouchEvent(pointerPoint)) { /* For some odd reason Moved events are used for multiple mouse buttons */ Uint8 button, pressed; if (WINRT_GetSDLButtonForPointerPoint(pointerPoint, &button, &pressed)) { @@ -265,7 +258,7 @@ WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPo } else { SDL_SendTouchMotion( WINRT_TouchID, - (SDL_FingerID) pointerPoint->PointerId, + (SDL_FingerID)pointerPoint->PointerId, window, normalizedPoint.X, normalizedPoint.Y, @@ -273,7 +266,7 @@ WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPo } } -void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint) +void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint) { if (!window) { return; @@ -289,7 +282,7 @@ void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::P SDL_SendTouch( WINRT_TouchID, - (SDL_FingerID) pointerPoint->PointerId, + (SDL_FingerID)pointerPoint->PointerId, window, SDL_FALSE, normalizedPoint.X, @@ -298,7 +291,7 @@ void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::P } } -void WINRT_ProcessPointerEnteredEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint) +void WINRT_ProcessPointerEnteredEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint) { if (!window) { return; @@ -309,7 +302,7 @@ void WINRT_ProcessPointerEnteredEvent(SDL_Window *window, Windows::UI::Input::Po } } -void WINRT_ProcessPointerExitedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint) +void WINRT_ProcessPointerExitedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint) { if (!window) { return; @@ -320,19 +313,17 @@ void WINRT_ProcessPointerExitedEvent(SDL_Window *window, Windows::UI::Input::Poi } } -void -WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint) +void WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint) { if (!window) { return; } - float motion = (float) pointerPoint->Properties->MouseWheelDelta / WHEEL_DELTA; - SDL_SendMouseWheel(window, 0, 0, (float) motion, SDL_MOUSEWHEEL_NORMAL); + float motion = (float)pointerPoint->Properties->MouseWheelDelta / WHEEL_DELTA; + SDL_SendMouseWheel(window, 0, 0, (float)motion, SDL_MOUSEWHEEL_NORMAL); } -void -WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::MouseEventArgs ^args) +void WINRT_ProcessMouseMovedEvent(SDL_Window *window, Windows::Devices::Input::MouseEventArgs ^ args) { if (!window || !WINRT_UsingRelativeMouseMode) { return; diff --git a/src/video/winrt/SDL_winrtvideo.cpp b/src/video/winrt/SDL_winrtvideo.cpp index aae34b998..64df57b87 100644 --- a/src/video/winrt/SDL_winrtvideo.cpp +++ b/src/video/winrt/SDL_winrtvideo.cpp @@ -46,11 +46,9 @@ using namespace Windows::Graphics::Display; using namespace Windows::UI::Core; using namespace Windows::UI::ViewManagement; - /* [re]declare Windows GUIDs locally, to limit the amount of external lib(s) SDL has to link to */ -static const GUID SDL_IID_IDisplayRequest = { 0xe5732044, 0xf49f, 0x4b60, { 0x8d, 0xd4, 0x5e, 0x7e, 0x3a, 0x63, 0x2a, 0xc0 } }; -static const GUID SDL_IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } }; - +static const GUID SDL_IID_IDisplayRequest = { 0xe5732044, 0xf49f, 0x4b60, { 0x8d, 0xd4, 0x5e, 0x7e, 0x3a, 0x63, 0x2a, 0xc0 } }; +static const GUID SDL_IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } }; /* SDL includes */ extern "C" { @@ -75,14 +73,12 @@ extern "C" { #include "SDL_system.h" #include "SDL_hints.h" - /* Initialization/Query functions */ static int WINRT_VideoInit(_THIS); static int WINRT_InitModes(_THIS); -static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); +static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode); static void WINRT_VideoQuit(_THIS); - /* Window functions */ static int WINRT_CreateWindow(_THIS, SDL_Window * window); static void WINRT_SetWindowSize(_THIS, SDL_Window * window); @@ -92,21 +88,18 @@ static SDL_bool WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo /* Misc functions */ -static ABI::Windows::System::Display::IDisplayRequest * WINRT_CreateDisplayRequest(_THIS); +static ABI::Windows::System::Display::IDisplayRequest *WINRT_CreateDisplayRequest(_THIS); extern void WINRT_SuspendScreenSaver(_THIS); - /* SDL-internal globals: */ -SDL_Window * WINRT_GlobalSDLWindow = NULL; - +SDL_Window *WINRT_GlobalSDLWindow = NULL; /* WinRT driver bootstrap functions */ -static void -WINRT_DeleteDevice(SDL_VideoDevice * device) +static void WINRT_DeleteDevice(SDL_VideoDevice *device) { if (device->driverdata) { - SDL_VideoData * video_data = (SDL_VideoData *)device->driverdata; + SDL_VideoData *video_data = (SDL_VideoData *)device->driverdata; if (video_data->winrtEglWindow) { video_data->winrtEglWindow->Release(); } @@ -116,20 +109,19 @@ WINRT_DeleteDevice(SDL_VideoDevice * device) SDL_free(device); } -static SDL_VideoDevice * -WINRT_CreateDevice(void) +static SDL_VideoDevice *WINRT_CreateDevice(void) { SDL_VideoDevice *device; SDL_VideoData *data; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device == NULL) { SDL_OutOfMemory(); return 0; } - data = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); + data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); if (data == NULL) { SDL_OutOfMemory(); SDL_free(device); @@ -180,8 +172,7 @@ VideoBootStrap WINRT_bootstrap = { WINRT_CreateDevice }; -static void SDLCALL -WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const char *oldValue, const char *newValue) +static void SDLCALL WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const char *oldValue, const char *newValue) { SDL_assert(SDL_strcmp(name, SDL_HINT_ORIENTATIONS) == 0); @@ -204,13 +195,13 @@ WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const c std::string orientationName; std::getline(tokenizer, orientationName, ' '); if (orientationName == "LandscapeLeft") { - orientationFlags |= (unsigned int) DisplayOrientations::LandscapeFlipped; + orientationFlags |= (unsigned int)DisplayOrientations::LandscapeFlipped; } else if (orientationName == "LandscapeRight") { - orientationFlags |= (unsigned int) DisplayOrientations::Landscape; + orientationFlags |= (unsigned int)DisplayOrientations::Landscape; } else if (orientationName == "Portrait") { - orientationFlags |= (unsigned int) DisplayOrientations::Portrait; + orientationFlags |= (unsigned int)DisplayOrientations::Portrait; } else if (orientationName == "PortraitUpsideDown") { - orientationFlags |= (unsigned int) DisplayOrientations::PortraitFlipped; + orientationFlags |= (unsigned int)DisplayOrientations::PortraitFlipped; } } } @@ -218,11 +209,10 @@ WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const c // If no valid orientation flags were specified, use a reasonable set of defaults: if (!orientationFlags) { // TODO, WinRT: consider seeing if an app's default orientation flags can be found out via some API call(s). - orientationFlags = (unsigned int) ( \ - DisplayOrientations::Landscape | - DisplayOrientations::LandscapeFlipped | - DisplayOrientations::Portrait | - DisplayOrientations::PortraitFlipped); + orientationFlags = (unsigned int)(DisplayOrientations::Landscape | + DisplayOrientations::LandscapeFlipped | + DisplayOrientations::Portrait | + DisplayOrientations::PortraitFlipped); } // Set the orientation/rotation preferences. Please note that this does @@ -239,13 +229,12 @@ WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const c // for details. Microsoft's "Display orientation sample" also gives an // outline of how Windows treats device rotation // (http://code.msdn.microsoft.com/Display-Orientation-Sample-19a58e93). - WINRT_DISPLAY_PROPERTY(AutoRotationPreferences) = (DisplayOrientations) orientationFlags; + WINRT_DISPLAY_PROPERTY(AutoRotationPreferences) = (DisplayOrientations)orientationFlags; } -int -WINRT_VideoInit(_THIS) +int WINRT_VideoInit(_THIS) { - SDL_VideoData * driverdata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *driverdata = (SDL_VideoData *)_this->driverdata; if (WINRT_InitModes(_this) < 0) { return -1; } @@ -264,11 +253,9 @@ WINRT_VideoInit(_THIS) return 0; } -extern "C" -Uint32 D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat); +extern "C" Uint32 D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat); -static void -WINRT_DXGIModeToSDLDisplayMode(const DXGI_MODE_DESC * dxgiMode, SDL_DisplayMode * sdlMode) +static void WINRT_DXGIModeToSDLDisplayMode(const DXGI_MODE_DESC *dxgiMode, SDL_DisplayMode *sdlMode) { SDL_zerop(sdlMode); sdlMode->w = dxgiMode->Width; @@ -277,17 +264,16 @@ WINRT_DXGIModeToSDLDisplayMode(const DXGI_MODE_DESC * dxgiMode, SDL_DisplayMode sdlMode->format = D3D11_DXGIFormatToSDLPixelFormat(dxgiMode->Format); } -static int -WINRT_AddDisplaysForOutput (_THIS, IDXGIAdapter1 * dxgiAdapter1, int outputIndex) +static int WINRT_AddDisplaysForOutput(_THIS, IDXGIAdapter1 *dxgiAdapter1, int outputIndex) { HRESULT hr; - IDXGIOutput * dxgiOutput = NULL; + IDXGIOutput *dxgiOutput = NULL; DXGI_OUTPUT_DESC dxgiOutputDesc; SDL_VideoDisplay display; - char * displayName = NULL; + char *displayName = NULL; UINT numModes; - DXGI_MODE_DESC * dxgiModes = NULL; - int functionResult = -1; /* -1 for failure, 0 for success */ + DXGI_MODE_DESC *dxgiModes = NULL; + int functionResult = -1; /* -1 for failure, 0 for success */ DXGI_MODE_DESC modeToMatch, closestMatch; SDL_zero(display); @@ -326,10 +312,10 @@ WINRT_AddDisplaysForOutput (_THIS, IDXGIAdapter1 * dxgiAdapter1, int outputIndex mode.w = (dxgiOutputDesc.DesktopCoordinates.right - dxgiOutputDesc.DesktopCoordinates.left); mode.h = (dxgiOutputDesc.DesktopCoordinates.bottom - dxgiOutputDesc.DesktopCoordinates.top); mode.format = DXGI_FORMAT_B8G8R8A8_UNORM; - mode.refresh_rate = 0; /* Display mode is unknown, so just fill in zero, as specified by SDL's header files */ + mode.refresh_rate = 0; /* Display mode is unknown, so just fill in zero, as specified by SDL's header files */ display.desktop_mode = mode; display.current_mode = mode; - if ( ! SDL_AddDisplayMode(&display, &mode)) { + if (!SDL_AddDisplayMode(&display, &mode)) { goto done; } } else if (FAILED(hr)) { @@ -373,7 +359,7 @@ WINRT_AddDisplaysForOutput (_THIS, IDXGIAdapter1 * dxgiAdapter1, int outputIndex goto done; } - functionResult = 0; /* 0 for Success! */ + functionResult = 0; /* 0 for Success! */ done: if (dxgiModes) { SDL_free(dxgiModes); @@ -387,11 +373,10 @@ done: return functionResult; } -static int -WINRT_AddDisplaysForAdapter (_THIS, IDXGIFactory2 * dxgiFactory2, int adapterIndex) +static int WINRT_AddDisplaysForAdapter(_THIS, IDXGIFactory2 *dxgiFactory2, int adapterIndex) { HRESULT hr; - IDXGIAdapter1 * dxgiAdapter1; + IDXGIAdapter1 *dxgiAdapter1; hr = dxgiFactory2->EnumAdapters1(adapterIndex, &dxgiAdapter1); if (FAILED(hr)) { @@ -401,7 +386,7 @@ WINRT_AddDisplaysForAdapter (_THIS, IDXGIFactory2 * dxgiFactory2, int adapterInd return -1; } - for (int outputIndex = 0; ; ++outputIndex) { + for (int outputIndex = 0;; ++outputIndex) { if (WINRT_AddDisplaysForOutput(_this, dxgiAdapter1, outputIndex) < 0) { /* HACK: The Windows App Certification Kit 10.0 can fail, when running the Store Apps' test, "Direct3D Feature Test". The @@ -448,12 +433,11 @@ WINRT_AddDisplaysForAdapter (_THIS, IDXGIFactory2 * dxgiFactory2, int adapterInd #endif mode.format = DXGI_FORMAT_B8G8R8A8_UNORM; - mode.refresh_rate = 0; /* Display mode is unknown, so just fill in zero, as specified by SDL's header files */ + mode.refresh_rate = 0; /* Display mode is unknown, so just fill in zero, as specified by SDL's header files */ display.desktop_mode = mode; display.current_mode = mode; if ((SDL_AddDisplayMode(&display, &mode) < 0) || - (SDL_AddVideoDisplay(&display, SDL_FALSE) < 0)) - { + (SDL_AddVideoDisplay(&display, SDL_FALSE) < 0)) { return SDL_SetError("Failed to apply DXGI Display-detection workaround"); } } @@ -466,8 +450,7 @@ WINRT_AddDisplaysForAdapter (_THIS, IDXGIFactory2 * dxgiFactory2, int adapterInd return 0; } -int -WINRT_InitModes(_THIS) +int WINRT_InitModes(_THIS) { /* HACK: Initialize a single display, for whatever screen the app's CoreApplicationView is on. @@ -476,14 +459,14 @@ WINRT_InitModes(_THIS) */ HRESULT hr; - IDXGIFactory2 * dxgiFactory2 = NULL; + IDXGIFactory2 *dxgiFactory2 = NULL; hr = CreateDXGIFactory1(SDL_IID_IDXGIFactory2, (void **)&dxgiFactory2); if (FAILED(hr)) { return WIN_SetErrorFromHRESULT(__FUNCTION__ ", CreateDXGIFactory1() failed", hr); } - for (int adapterIndex = 0; ; ++adapterIndex) { + for (int adapterIndex = 0;; ++adapterIndex) { if (WINRT_AddDisplaysForAdapter(_this, dxgiFactory2, adapterIndex) < 0) { break; } @@ -492,16 +475,14 @@ WINRT_InitModes(_THIS) return 0; } -static int -WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) { return 0; } -void -WINRT_VideoQuit(_THIS) +void WINRT_VideoQuit(_THIS) { - SDL_VideoData * driverdata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *driverdata = (SDL_VideoData *)_this->driverdata; if (driverdata && driverdata->displayRequest) { driverdata->displayRequest->Release(); driverdata->displayRequest = NULL; @@ -510,18 +491,13 @@ WINRT_VideoQuit(_THIS) WINRT_QuitMouse(_this); } -static const Uint32 WINRT_DetectableFlags = - SDL_WINDOW_MAXIMIZED | - SDL_WINDOW_FULLSCREEN_DESKTOP | - SDL_WINDOW_SHOWN | - SDL_WINDOW_HIDDEN | - SDL_WINDOW_MOUSE_FOCUS; +static const Uint32 WINRT_DetectableFlags = SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_SHOWN | SDL_WINDOW_HIDDEN | SDL_WINDOW_MOUSE_FOCUS; extern "C" Uint32 -WINRT_DetectWindowFlags(SDL_Window * window) +WINRT_DetectWindowFlags(SDL_Window *window) { Uint32 latestFlags = 0; - SDL_WindowData * data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; bool is_fullscreen = false; #if SDL_WINRT_USE_APPLICATIONVIEW @@ -534,7 +510,7 @@ WINRT_DetectWindowFlags(SDL_Window * window) if (data->coreWindow.Get()) { if (is_fullscreen) { - SDL_VideoDisplay * display = SDL_GetDisplayForWindow(window); + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); int w = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Width); int h = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Height); @@ -545,17 +521,17 @@ WINRT_DetectWindowFlags(SDL_Window * window) const DisplayOrientations currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation); switch (currentOrientation) { #if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) - case DisplayOrientations::Landscape: - case DisplayOrientations::LandscapeFlipped: + case DisplayOrientations::Landscape: + case DisplayOrientations::LandscapeFlipped: #else - case DisplayOrientations::Portrait: - case DisplayOrientations::PortraitFlipped: + case DisplayOrientations::Portrait: + case DisplayOrientations::PortraitFlipped: #endif - { - int tmp = w; - w = h; - h = tmp; - } break; + { + int tmp = w; + w = h; + h = tmp; + } break; } #endif @@ -586,47 +562,44 @@ WINRT_DetectWindowFlags(SDL_Window * window) } // TODO, WinRT: consider removing WINRT_UpdateWindowFlags, and just calling WINRT_DetectWindowFlags as-appropriate (with appropriate calls to SDL_SendWindowEvent) -void -WINRT_UpdateWindowFlags(SDL_Window * window, Uint32 mask) +void WINRT_UpdateWindowFlags(SDL_Window *window, Uint32 mask) { mask &= WINRT_DetectableFlags; if (window) { Uint32 apply = WINRT_DetectWindowFlags(window); if ((apply & mask) & SDL_WINDOW_FULLSCREEN) { - window->last_fullscreen_flags = window->flags; // seems necessary to programmatically un-fullscreen, via SDL APIs + window->last_fullscreen_flags = window->flags; // seems necessary to programmatically un-fullscreen, via SDL APIs } window->flags = (window->flags & ~mask) | (apply & mask); } } -static bool -WINRT_IsCoreWindowActive(CoreWindow ^ coreWindow) +static bool WINRT_IsCoreWindowActive(CoreWindow ^ coreWindow) { /* WinRT does not appear to offer API(s) to determine window-activation state, at least not that I am aware of in Win8 - Win10. As such, SDL tracks this itself, via window-activation events. - + If there *is* an API to track this, it should probably get used instead of the following hack (that uses "SDLHelperWindowActivationState"). -- DavidL. */ if (coreWindow->CustomProperties->HasKey("SDLHelperWindowActivationState")) { - CoreWindowActivationState activationState = \ + CoreWindowActivationState activationState = safe_cast(coreWindow->CustomProperties->Lookup("SDLHelperWindowActivationState")); return activationState != CoreWindowActivationState::Deactivated; } /* Assume that non-SDL tracked windows are active, although this should probably be avoided, if possible. - + This might not even be possible, in normal SDL use, at least as of this writing (Dec 22, 2015; via latest hg.libsdl.org/SDL clone) -- DavidL */ return true; } -int -WINRT_CreateWindow(_THIS, SDL_Window * window) +int WINRT_CreateWindow(_THIS, SDL_Window *window) { // Make sure that only one window gets created, at least until multimonitor // support is added. @@ -634,7 +607,7 @@ WINRT_CreateWindow(_THIS, SDL_Window * window) return SDL_SetError("WinRT only supports one window"); } - SDL_WindowData *data = new SDL_WindowData; /* use 'new' here as SDL_WindowData may use WinRT/C++ types */ + SDL_WindowData *data = new SDL_WindowData; /* use 'new' here as SDL_WindowData may use WinRT/C++ types */ if (!data) { return SDL_OutOfMemory(); } @@ -664,7 +637,7 @@ WINRT_CreateWindow(_THIS, SDL_Window * window) data->egl_surface = EGL_NO_SURFACE; } else { /* OpenGL ES 2 was reuqested. Set up an EGL surface. */ - SDL_VideoData * video_data = (SDL_VideoData *)_this->driverdata; + SDL_VideoData *video_data = (SDL_VideoData *)_this->driverdata; /* Call SDL_EGL_ChooseConfig and eglCreateWindowSurface directly, * rather than via SDL_EGL_CreateSurface, as older versions of @@ -673,10 +646,10 @@ WINRT_CreateWindow(_THIS, SDL_Window * window) */ if (SDL_EGL_ChooseConfig(_this) != 0) { /* SDL_EGL_ChooseConfig failed, SDL_GetError() should have info */ - return -1; + return -1; } - if (video_data->winrtEglWindow) { /* ... is the 'old' version of ANGLE/WinRT being used? */ + if (video_data->winrtEglWindow) { /* ... is the 'old' version of ANGLE/WinRT being used? */ /* Attempt to create a window surface using older versions of * ANGLE/WinRT: */ @@ -692,7 +665,7 @@ WINRT_CreateWindow(_THIS, SDL_Window * window) /* Attempt to create a window surface using newer versions of * ANGLE/WinRT: */ - IInspectable * coreWindowAsIInspectable = reinterpret_cast(data->coreWindow.Get()); + IInspectable *coreWindowAsIInspectable = reinterpret_cast(data->coreWindow.Get()); data->egl_surface = _this->egl_data->eglCreateWindowSurface( _this->egl_data->egl_display, _this->egl_data->egl_config, @@ -723,8 +696,8 @@ WINRT_CreateWindow(_THIS, SDL_Window * window) window->x = 0; window->y = 0; window->flags |= SDL_WINDOW_SHOWN; - SDL_SetMouseFocus(NULL); // TODO: detect this - SDL_SetKeyboardFocus(NULL); // TODO: detect this + SDL_SetMouseFocus(NULL); // TODO: detect this + SDL_SetKeyboardFocus(NULL); // TODO: detect this } else { /* WinRT 8.x apps seem to live in an environment where the OS controls the app's window size, with some apps being fullscreen, depending on @@ -758,7 +731,7 @@ WINRT_CreateWindow(_THIS, SDL_Window * window) WINRT_UpdateWindowFlags( window, - 0xffffffff /* Update any window flag(s) that WINRT_UpdateWindow can handle */ + 0xffffffff /* Update any window flag(s) that WINRT_UpdateWindow can handle */ ); /* Try detecting if the window is active */ @@ -767,7 +740,7 @@ WINRT_CreateWindow(_THIS, SDL_Window * window) SDL_SetKeyboardFocus(window); } } - + /* Make sure the WinRT app's IFramworkView can post events on behalf of SDL: */ @@ -777,27 +750,25 @@ WINRT_CreateWindow(_THIS, SDL_Window * window) return 0; } -void -WINRT_SetWindowSize(_THIS, SDL_Window * window) +void WINRT_SetWindowSize(_THIS, SDL_Window *window) { #if NTDDI_VERSION >= NTDDI_WIN10 - SDL_WindowData * data = (SDL_WindowData *)window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; const Windows::Foundation::Size size(WINRT_PHYSICAL_PIXELS_TO_DIPS(window->w), WINRT_PHYSICAL_PIXELS_TO_DIPS(window->h)); data->appView->TryResizeView(size); // TODO, WinRT: return failure (to caller?) from TryResizeView() #endif } -void -WINRT_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen) +void WINRT_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen) { #if NTDDI_VERSION >= NTDDI_WIN10 - SDL_WindowData * data = (SDL_WindowData *)window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; bool isWindowActive = WINRT_IsCoreWindowActive(data->coreWindow.Get()); if (isWindowActive) { if (fullscreen) { if (!data->appView->IsFullScreenMode) { - data->appView->TryEnterFullScreenMode(); // TODO, WinRT: return failure (to caller?) from TryEnterFullScreenMode() + data->appView->TryEnterFullScreenMode(); // TODO, WinRT: return failure (to caller?) from TryEnterFullScreenMode() } } else { if (data->appView->IsFullScreenMode) { @@ -808,11 +779,9 @@ WINRT_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display #endif } - -void -WINRT_DestroyWindow(_THIS, SDL_Window * window) +void WINRT_DestroyWindow(_THIS, SDL_Window *window) { - SDL_WindowData * data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; if (WINRT_GlobalSDLWindow == window) { WINRT_GlobalSDLWindow = NULL; @@ -843,15 +812,14 @@ WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) return SDL_FALSE; } -static ABI::Windows::System::Display::IDisplayRequest * -WINRT_CreateDisplayRequest(_THIS) +static ABI::Windows::System::Display::IDisplayRequest *WINRT_CreateDisplayRequest(_THIS) { /* Setup a WinRT DisplayRequest object, usable for enabling/disabling screensaver requests */ wchar_t *wClassName = L"Windows.System.Display.DisplayRequest"; HSTRING hClassName; IActivationFactory *pActivationFactory = NULL; - IInspectable * pDisplayRequestRaw = nullptr; - ABI::Windows::System::Display::IDisplayRequest * pDisplayRequest = nullptr; + IInspectable *pDisplayRequestRaw = nullptr; + ABI::Windows::System::Display::IDisplayRequest *pDisplayRequest = nullptr; HRESULT hr; hr = ::WindowsCreateString(wClassName, (UINT32)SDL_wcslen(wClassName), &hClassName); @@ -869,7 +837,7 @@ WINRT_CreateDisplayRequest(_THIS) goto done; } - hr = pDisplayRequestRaw->QueryInterface(SDL_IID_IDisplayRequest, (void **) &pDisplayRequest); + hr = pDisplayRequestRaw->QueryInterface(SDL_IID_IDisplayRequest, (void **)&pDisplayRequest); if (FAILED(hr)) { goto done; } @@ -888,12 +856,11 @@ done: return pDisplayRequest; } -void -WINRT_SuspendScreenSaver(_THIS) +void WINRT_SuspendScreenSaver(_THIS) { SDL_VideoData *driverdata = (SDL_VideoData *)_this->driverdata; if (driverdata && driverdata->displayRequest) { - ABI::Windows::System::Display::IDisplayRequest * displayRequest = (ABI::Windows::System::Display::IDisplayRequest *) driverdata->displayRequest; + ABI::Windows::System::Display::IDisplayRequest *displayRequest = (ABI::Windows::System::Display::IDisplayRequest *)driverdata->displayRequest; if (_this->suspend_screensaver) { displayRequest->RequestActive(); } else { diff --git a/src/video/winrt/SDL_winrtvideo_cpp.h b/src/video/winrt/SDL_winrtvideo_cpp.h index 8e6d63bdc..fcb6d3d1e 100644 --- a/src/video/winrt/SDL_winrtvideo_cpp.h +++ b/src/video/winrt/SDL_winrtvideo_cpp.h @@ -29,9 +29,9 @@ #include "SDL_video.h" #include "SDL_events.h" -#if NTDDI_VERSION >= NTDDI_WINBLUE /* ApplicationView's functionality only becomes - useful for SDL in Win[Phone] 8.1 and up. - Plus, it is not available at all in WinPhone 8.0. */ +#if NTDDI_VERSION >= NTDDI_WINBLUE /* ApplicationView's functionality only becomes \ + useful for SDL in Win[Phone] 8.1 and up. \ + Plus, it is not available at all in WinPhone 8.0. */ #define SDL_WINRT_USE_APPLICATIONVIEW 1 #endif @@ -41,7 +41,8 @@ extern "C" { } /* Private display data */ -typedef struct SDL_VideoData { +typedef struct SDL_VideoData +{ /* An object created by ANGLE/WinRT (OpenGL ES 2 for WinRT) that gets * passed to eglGetDisplay and eglCreateWindowSurface: */ @@ -55,7 +56,7 @@ typedef struct SDL_VideoData { /* A WinRT DisplayRequest, used for implementing SDL_*ScreenSaver() functions. * This is really a pointer to a 'ABI::Windows::System::Display::IDisplayRequest *', * It's casted to 'IUnknown *', to help with building SDL. - */ + */ IUnknown *displayRequest; } SDL_VideoData; @@ -63,19 +64,19 @@ typedef struct SDL_VideoData { For now, SDL/WinRT only supports one window (due to platform limitations of WinRT. */ -extern SDL_Window * WINRT_GlobalSDLWindow; +extern SDL_Window *WINRT_GlobalSDLWindow; /* Updates one or more SDL_Window flags, by querying the OS' native windowing APIs. SDL_Window flags that can be updated should be specified in 'mask'. */ -extern void WINRT_UpdateWindowFlags(SDL_Window * window, Uint32 mask); -extern "C" Uint32 WINRT_DetectWindowFlags(SDL_Window * window); /* detects flags w/o applying them */ +extern void WINRT_UpdateWindowFlags(SDL_Window *window, Uint32 mask); +extern "C" Uint32 WINRT_DetectWindowFlags(SDL_Window *window); /* detects flags w/o applying them */ /* Display mode internals */ -//typedef struct +// typedef struct //{ -// Windows::Graphics::Display::DisplayOrientations currentOrientation; -//} SDL_DisplayModeData; +// Windows::Graphics::Display::DisplayOrientations currentOrientation; +// } SDL_DisplayModeData; #ifdef __cplusplus_winrt @@ -87,8 +88,8 @@ extern "C" Uint32 WINRT_DetectWindowFlags(SDL_Window * window); /* detects flag #endif /* Converts DIPS to/from physical pixels */ -#define WINRT_DIPS_TO_PHYSICAL_PIXELS(DIPS) ((int)(0.5f + (((float)(DIPS) * (float)WINRT_DISPLAY_PROPERTY(LogicalDpi)) / 96.f))) -#define WINRT_PHYSICAL_PIXELS_TO_DIPS(PHYSPIX) (((float)(PHYSPIX) * 96.f)/WINRT_DISPLAY_PROPERTY(LogicalDpi)) +#define WINRT_DIPS_TO_PHYSICAL_PIXELS(DIPS) ((int)(0.5f + (((float)(DIPS) * (float)WINRT_DISPLAY_PROPERTY(LogicalDpi)) / 96.f))) +#define WINRT_PHYSICAL_PIXELS_TO_DIPS(PHYSPIX) (((float)(PHYSPIX)*96.f) / WINRT_DISPLAY_PROPERTY(LogicalDpi)) /* Internal window data */ struct SDL_WindowData diff --git a/src/video/x11/SDL_x11clipboard.c b/src/video/x11/SDL_x11clipboard.c index 6bb6ef03a..3c1162acd 100644 --- a/src/video/x11/SDL_x11clipboard.c +++ b/src/video/x11/SDL_x11clipboard.c @@ -30,10 +30,9 @@ #include "SDL_x11clipboard.h" /* Get any application owned window handle for clipboard association */ -static Window -GetWindow(_THIS) +static Window GetWindow(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; /* We create an unmapped window that exists just to manage the clipboard, since X11 selection data is tied to a specific window and dies with it. @@ -54,76 +53,71 @@ GetWindow(_THIS) /* We use our own cut-buffer for intermediate storage instead of XA_CUT_BUFFER0 because their use isn't really defined for holding UTF8. */ -Atom -X11_GetSDLCutBufferClipboardType(Display *display, enum ESDLX11ClipboardMimeType mime_type, - Atom selection_type) +Atom X11_GetSDLCutBufferClipboardType(Display *display, enum ESDLX11ClipboardMimeType mime_type, + Atom selection_type) { switch (mime_type) { - case SDL_X11_CLIPBOARD_MIME_TYPE_STRING: - case SDL_X11_CLIPBOARD_MIME_TYPE_TEXT_PLAIN: - #ifdef X_HAVE_UTF8_STRING - case SDL_X11_CLIPBOARD_MIME_TYPE_TEXT_PLAIN_UTF8: - #endif - case SDL_X11_CLIPBOARD_MIME_TYPE_TEXT: - return X11_XInternAtom(display, selection_type == XA_PRIMARY ? - "SDL_CUTBUFFER_PRIMARY_SELECTION" : "SDL_CUTBUFFER", - False); - default: - SDL_SetError("Can't find mime_type."); - return XA_STRING; + case SDL_X11_CLIPBOARD_MIME_TYPE_STRING: + case SDL_X11_CLIPBOARD_MIME_TYPE_TEXT_PLAIN: +#ifdef X_HAVE_UTF8_STRING + case SDL_X11_CLIPBOARD_MIME_TYPE_TEXT_PLAIN_UTF8: +#endif + case SDL_X11_CLIPBOARD_MIME_TYPE_TEXT: + return X11_XInternAtom(display, selection_type == XA_PRIMARY ? "SDL_CUTBUFFER_PRIMARY_SELECTION" : "SDL_CUTBUFFER", + False); + default: + SDL_SetError("Can't find mime_type."); + return XA_STRING; } } -Atom -X11_GetSDLCutBufferClipboardExternalFormat(Display *display, enum ESDLX11ClipboardMimeType mime_type) +Atom X11_GetSDLCutBufferClipboardExternalFormat(Display *display, enum ESDLX11ClipboardMimeType mime_type) { switch (mime_type) { - case SDL_X11_CLIPBOARD_MIME_TYPE_STRING: - /* If you don't support UTF-8, you might use XA_STRING here */ - #ifdef X_HAVE_UTF8_STRING - return X11_XInternAtom(display, "UTF8_STRING", False); - #else - return XA_STRING; - #endif - case SDL_X11_CLIPBOARD_MIME_TYPE_TEXT_PLAIN: - return X11_XInternAtom(display, "text/plain", False); - #ifdef X_HAVE_UTF8_STRING - case SDL_X11_CLIPBOARD_MIME_TYPE_TEXT_PLAIN_UTF8: - return X11_XInternAtom(display, "text/plain;charset=utf-8", False); - #endif - case SDL_X11_CLIPBOARD_MIME_TYPE_TEXT: - return X11_XInternAtom(display, "TEXT", False); - default: - SDL_SetError("Can't find mime_type."); - return XA_STRING; + case SDL_X11_CLIPBOARD_MIME_TYPE_STRING: +/* If you don't support UTF-8, you might use XA_STRING here */ +#ifdef X_HAVE_UTF8_STRING + return X11_XInternAtom(display, "UTF8_STRING", False); +#else + return XA_STRING; +#endif + case SDL_X11_CLIPBOARD_MIME_TYPE_TEXT_PLAIN: + return X11_XInternAtom(display, "text/plain", False); +#ifdef X_HAVE_UTF8_STRING + case SDL_X11_CLIPBOARD_MIME_TYPE_TEXT_PLAIN_UTF8: + return X11_XInternAtom(display, "text/plain;charset=utf-8", False); +#endif + case SDL_X11_CLIPBOARD_MIME_TYPE_TEXT: + return X11_XInternAtom(display, "TEXT", False); + default: + SDL_SetError("Can't find mime_type."); + return XA_STRING; } } -Atom -X11_GetSDLCutBufferClipboardInternalFormat(Display *display, enum ESDLX11ClipboardMimeType mime_type) +Atom X11_GetSDLCutBufferClipboardInternalFormat(Display *display, enum ESDLX11ClipboardMimeType mime_type) { switch (mime_type) { - case SDL_X11_CLIPBOARD_MIME_TYPE_STRING: - case SDL_X11_CLIPBOARD_MIME_TYPE_TEXT_PLAIN: - #ifdef X_HAVE_UTF8_STRING - case SDL_X11_CLIPBOARD_MIME_TYPE_TEXT_PLAIN_UTF8: - #endif - case SDL_X11_CLIPBOARD_MIME_TYPE_TEXT: - /* If you don't support UTF-8, you might use XA_STRING here */ - #ifdef X_HAVE_UTF8_STRING - return X11_XInternAtom(display, "UTF8_STRING", False); - #else - return XA_STRING; - #endif - default: - SDL_SetError("Can't find mime_type."); - return XA_STRING; + case SDL_X11_CLIPBOARD_MIME_TYPE_STRING: + case SDL_X11_CLIPBOARD_MIME_TYPE_TEXT_PLAIN: +#ifdef X_HAVE_UTF8_STRING + case SDL_X11_CLIPBOARD_MIME_TYPE_TEXT_PLAIN_UTF8: +#endif + case SDL_X11_CLIPBOARD_MIME_TYPE_TEXT: +/* If you don't support UTF-8, you might use XA_STRING here */ +#ifdef X_HAVE_UTF8_STRING + return X11_XInternAtom(display, "UTF8_STRING", False); +#else + return XA_STRING; +#endif + default: + SDL_SetError("Can't find mime_type."); + return XA_STRING; } } -static int -SetSelectionText(_THIS, const char *text, Atom selection_type) +static int SetSelectionText(_THIS, const char *text, Atom selection_type) { - Display *display = ((SDL_VideoData *) _this->driverdata)->display; + Display *display = ((SDL_VideoData *)_this->driverdata)->display; Window window; /* Get the SDL window that will own the selection */ @@ -134,9 +128,9 @@ SetSelectionText(_THIS, const char *text, Atom selection_type) /* Save the selection on the root window */ X11_XChangeProperty(display, DefaultRootWindow(display), - X11_GetSDLCutBufferClipboardType(display, SDL_X11_CLIPBOARD_MIME_TYPE_STRING, selection_type), - X11_GetSDLCutBufferClipboardInternalFormat(display, SDL_X11_CLIPBOARD_MIME_TYPE_STRING), 8, PropModeReplace, - (const unsigned char *)text, SDL_strlen(text)); + X11_GetSDLCutBufferClipboardType(display, SDL_X11_CLIPBOARD_MIME_TYPE_STRING, selection_type), + X11_GetSDLCutBufferClipboardInternalFormat(display, SDL_X11_CLIPBOARD_MIME_TYPE_STRING), 8, PropModeReplace, + (const unsigned char *)text, SDL_strlen(text)); if (X11_XGetSelectionOwner(display, selection_type) != window) { X11_XSetSelectionOwner(display, selection_type, window, CurrentTime); @@ -145,10 +139,9 @@ SetSelectionText(_THIS, const char *text, Atom selection_type) return 0; } -static char * -GetSlectionText(_THIS, Atom selection_type) +static char *GetSlectionText(_THIS, Atom selection_type) { - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; Display *display = videodata->display; Atom format; Window window; @@ -182,7 +175,7 @@ GetSlectionText(_THIS, Atom selection_type) owner = window; selection = X11_XInternAtom(display, "SDL_SELECTION", False); X11_XConvertSelection(display, selection_type, format, selection, owner, - CurrentTime); + CurrentTime); /* When using synergy on Linux and when data has been put in the clipboard on the remote (Windows anyway) machine then selection_waiting may never @@ -204,11 +197,10 @@ GetSlectionText(_THIS, Atom selection_type) } } - if (X11_XGetWindowProperty(display, owner, selection, 0, INT_MAX/4, False, - format, &seln_type, &seln_format, &nbytes, &overflow, &src) - == Success) { + if (X11_XGetWindowProperty(display, owner, selection, 0, INT_MAX / 4, False, + format, &seln_type, &seln_format, &nbytes, &overflow, &src) == Success) { if (seln_type == format) { - text = (char *)SDL_malloc(nbytes+1); + text = (char *)SDL_malloc(nbytes + 1); if (text) { SDL_memcpy(text, src, nbytes); text[nbytes] = '\0'; @@ -224,10 +216,9 @@ GetSlectionText(_THIS, Atom selection_type) return text; } -int -X11_SetClipboardText(_THIS, const char *text) +int X11_SetClipboardText(_THIS, const char *text) { - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; Atom XA_CLIPBOARD = X11_XInternAtom(videodata->display, "CLIPBOARD", 0); if (XA_CLIPBOARD == None) { return SDL_SetError("Couldn't access X clipboard"); @@ -235,8 +226,7 @@ X11_SetClipboardText(_THIS, const char *text) return SetSelectionText(_this, text, XA_CLIPBOARD); } -int -X11_SetPrimarySelectionText(_THIS, const char *text) +int X11_SetPrimarySelectionText(_THIS, const char *text) { return SetSelectionText(_this, text, XA_PRIMARY); } @@ -244,7 +234,7 @@ X11_SetPrimarySelectionText(_THIS, const char *text) char * X11_GetClipboardText(_THIS) { - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; Atom XA_CLIPBOARD = X11_XInternAtom(videodata->display, "CLIPBOARD", 0); if (XA_CLIPBOARD == None) { SDL_SetError("Couldn't access X clipboard"); diff --git a/src/video/x11/SDL_x11clipboard.h b/src/video/x11/SDL_x11clipboard.h index ddeb016e8..7c113f22a 100644 --- a/src/video/x11/SDL_x11clipboard.h +++ b/src/video/x11/SDL_x11clipboard.h @@ -23,12 +23,13 @@ #ifndef SDL_x11clipboard_h_ #define SDL_x11clipboard_h_ -enum ESDLX11ClipboardMimeType { +enum ESDLX11ClipboardMimeType +{ SDL_X11_CLIPBOARD_MIME_TYPE_STRING, SDL_X11_CLIPBOARD_MIME_TYPE_TEXT_PLAIN, - #ifdef X_HAVE_UTF8_STRING +#ifdef X_HAVE_UTF8_STRING SDL_X11_CLIPBOARD_MIME_TYPE_TEXT_PLAIN_UTF8, - #endif +#endif SDL_X11_CLIPBOARD_MIME_TYPE_TEXT, SDL_X11_CLIPBOARD_MIME_TYPE_MAX }; diff --git a/src/video/x11/SDL_x11dyn.c b/src/video/x11/SDL_x11dyn.c index 93747a537..13a230adf 100644 --- a/src/video/x11/SDL_x11dyn.c +++ b/src/video/x11/SDL_x11dyn.c @@ -61,17 +61,16 @@ typedef struct #endif static x11dynlib x11libs[] = { - {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC}, - {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT}, - {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR}, - {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2}, - {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES}, - {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR}, - {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS} + { NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC }, + { NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT }, + { NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR }, + { NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 }, + { NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES }, + { NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR }, + { NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS } }; -static void * -X11_GetSym(const char *fnname, int *pHasModule) +static void *X11_GetSym(const char *fnname, int *pHasModule) { int i; void *fn = NULL; @@ -101,7 +100,7 @@ X11_GetSym(const char *fnname, int *pHasModule) #endif /* SDL_VIDEO_DRIVER_X11_DYNAMIC */ /* Define all the function pointers and wrappers... */ -#define SDL_X11_SYM(rc,fn,params,args,ret) SDL_DYNX11FN_##fn X11_##fn = NULL; +#define SDL_X11_SYM(rc, fn, params, args, ret) SDL_DYNX11FN_##fn X11_##fn = NULL; #include "SDL_x11sym.h" /* Annoying varargs entry point... */ @@ -116,8 +115,7 @@ SDL_DYNX11FN_XGetICValues X11_XGetICValues = NULL; static int x11_load_refcount = 0; -void -SDL_X11_UnloadSymbols(void) +void SDL_X11_UnloadSymbols(void) { /* Don't actually unload if more than one module is using the libs... */ if (x11_load_refcount > 0) { @@ -127,8 +125,8 @@ SDL_X11_UnloadSymbols(void) #endif /* set all the function pointers to NULL. */ -#define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 0; -#define SDL_X11_SYM(rc,fn,params,args,ret) X11_##fn = NULL; +#define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 0; +#define SDL_X11_SYM(rc, fn, params, args, ret) X11_##fn = NULL; #include "SDL_x11sym.h" #ifdef X_HAVE_UTF8_STRING @@ -149,10 +147,9 @@ SDL_X11_UnloadSymbols(void) } /* returns non-zero if all needed symbols were loaded. */ -int -SDL_X11_LoadSymbols(void) +int SDL_X11_LoadSymbols(void) { - int rc = 1; /* always succeed if not using Dynamic X11 stuff. */ + int rc = 1; /* always succeed if not using Dynamic X11 stuff. */ /* deal with multiple modules (dga, x11, etc) needing these symbols... */ if (x11_load_refcount++ == 0) { @@ -168,15 +165,15 @@ SDL_X11_LoadSymbols(void) #define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1; /* default yes */ #include "SDL_x11sym.h" -#define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname; -#define SDL_X11_SYM(a,fn,x,y,z) X11_##fn = (SDL_DYNX11FN_##fn) X11_GetSym(#fn,thismod); +#define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname; +#define SDL_X11_SYM(a, fn, x, y, z) X11_##fn = (SDL_DYNX11FN_##fn)X11_GetSym(#fn, thismod); #include "SDL_x11sym.h" #ifdef X_HAVE_UTF8_STRING X11_XCreateIC = (SDL_DYNX11FN_XCreateIC) - X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8); + X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8); X11_XGetICValues = (SDL_DYNX11FN_XGetICValues) - X11_GetSym("XGetICValues", &SDL_X11_HAVE_UTF8); + X11_GetSym("XGetICValues", &SDL_X11_HAVE_UTF8); #endif if (SDL_X11_HAVE_BASEXLIB) { @@ -188,10 +185,10 @@ SDL_X11_LoadSymbols(void) rc = 0; } -#else /* no dynamic X11 */ +#else /* no dynamic X11 */ -#define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1; /* default yes */ -#define SDL_X11_SYM(a,fn,x,y,z) X11_##fn = (SDL_DYNX11FN_##fn) fn; +#define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1; /* default yes */ +#define SDL_X11_SYM(a, fn, x, y, z) X11_##fn = (SDL_DYNX11FN_##fn)fn; #include "SDL_x11sym.h" #ifdef X_HAVE_UTF8_STRING diff --git a/src/video/x11/SDL_x11dyn.h b/src/video/x11/SDL_x11dyn.h index feac35fa9..710d18278 100644 --- a/src/video/x11/SDL_x11dyn.h +++ b/src/video/x11/SDL_x11dyn.h @@ -69,28 +69,27 @@ #endif #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif /* evil function signatures... */ -typedef Bool(*SDL_X11_XESetWireToEventRetType) (Display *, XEvent *, xEvent *); -typedef int (*SDL_X11_XSynchronizeRetType) (Display *); -typedef Status(*SDL_X11_XESetEventToWireRetType) (Display *, XEvent *, xEvent *); +typedef Bool (*SDL_X11_XESetWireToEventRetType)(Display *, XEvent *, xEvent *); +typedef int (*SDL_X11_XSynchronizeRetType)(Display *); +typedef Status (*SDL_X11_XESetEventToWireRetType)(Display *, XEvent *, xEvent *); int SDL_X11_LoadSymbols(void); void SDL_X11_UnloadSymbols(void); /* Declare all the function pointers and wrappers... */ -#define SDL_X11_SYM(rc,fn,params,args,ret) \ - typedef rc (*SDL_DYNX11FN_##fn) params; \ +#define SDL_X11_SYM(rc, fn, params, args, ret) \ + typedef rc(*SDL_DYNX11FN_##fn) params; \ extern SDL_DYNX11FN_##fn X11_##fn; #include "SDL_x11sym.h" /* Annoying varargs entry point... */ #ifdef X_HAVE_UTF8_STRING -typedef XIC(*SDL_DYNX11FN_XCreateIC) (XIM,...); -typedef char *(*SDL_DYNX11FN_XGetICValues) (XIC, ...); +typedef XIC (*SDL_DYNX11FN_XCreateIC)(XIM, ...); +typedef char *(*SDL_DYNX11FN_XGetICValues)(XIC, ...); extern SDL_DYNX11FN_XCreateIC X11_XCreateIC; extern SDL_DYNX11FN_XGetICValues X11_XGetICValues; #endif @@ -103,5 +102,5 @@ extern SDL_DYNX11FN_XGetICValues X11_XGetICValues; } #endif -#endif /* !defined SDL_x11dyn_h_ */ +#endif /* !defined SDL_x11dyn_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 13188240f..99650e06e 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -46,42 +46,43 @@ /*#define DEBUG_XEVENTS*/ #ifndef _NET_WM_MOVERESIZE_SIZE_TOPLEFT -#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0 +#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0 #endif #ifndef _NET_WM_MOVERESIZE_SIZE_TOP -#define _NET_WM_MOVERESIZE_SIZE_TOP 1 +#define _NET_WM_MOVERESIZE_SIZE_TOP 1 #endif #ifndef _NET_WM_MOVERESIZE_SIZE_TOPRIGHT -#define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2 +#define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2 #endif #ifndef _NET_WM_MOVERESIZE_SIZE_RIGHT -#define _NET_WM_MOVERESIZE_SIZE_RIGHT 3 +#define _NET_WM_MOVERESIZE_SIZE_RIGHT 3 #endif #ifndef _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT -#define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4 +#define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4 #endif #ifndef _NET_WM_MOVERESIZE_SIZE_BOTTOM -#define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5 +#define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5 #endif #ifndef _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT -#define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6 +#define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6 #endif #ifndef _NET_WM_MOVERESIZE_SIZE_LEFT -#define _NET_WM_MOVERESIZE_SIZE_LEFT 7 +#define _NET_WM_MOVERESIZE_SIZE_LEFT 7 #endif #ifndef _NET_WM_MOVERESIZE_MOVE -#define _NET_WM_MOVERESIZE_MOVE 8 +#define _NET_WM_MOVERESIZE_MOVE 8 #endif -typedef struct { +typedef struct +{ unsigned char *data; int format, count; Atom type; @@ -92,7 +93,7 @@ typedef struct { */ static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) { - unsigned char *ret=NULL; + unsigned char *ret = NULL; Atom type; int fmt; unsigned long count; @@ -107,10 +108,10 @@ static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) bytes_fetch += bytes_left; } while (bytes_left != 0); - p->data=ret; - p->format=fmt; - p->count=count; - p->type=type; + p->data = ret; + p->format = fmt; + p->count = count; + p->type = type; } /* Find text-uri-list in a list of targets and return it's atom @@ -120,10 +121,10 @@ static Atom X11_PickTarget(Display *disp, Atom list[], int list_count) Atom request = None; char *name; int i; - for (i=0; i < list_count && request == None; i++) { + for (i = 0; i < list_count && request == None; i++) { name = X11_XGetAtomName(disp, list[i]); if ((SDL_strcmp("text/uri-list", name) == 0) || (SDL_strcmp("text/plain", name) == 0)) { - request = list[i]; + request = list[i]; } X11_XFree(name); } @@ -134,7 +135,7 @@ static Atom X11_PickTarget(Display *disp, Atom list[], int list_count) case in the Xdnd protocol */ static Atom X11_PickTargetFromAtoms(Display *disp, Atom a0, Atom a1, Atom a2) { - int count=0; + int count = 0; Atom atom[3]; if (a0 != None) { atom[count++] = a0; @@ -155,9 +156,9 @@ struct KeyRepeatCheckData }; static Bool X11_KeyRepeatCheckIfEvent(Display *display, XEvent *chkev, - XPointer arg) + XPointer arg) { - struct KeyRepeatCheckData *d = (struct KeyRepeatCheckData *) arg; + struct KeyRepeatCheckData *d = (struct KeyRepeatCheckData *)arg; if (chkev->type == KeyPress && chkev->xkey.keycode == d->event->xkey.keycode && chkev->xkey.time - d->event->xkey.time < 2) { d->found = SDL_TRUE; } @@ -179,8 +180,7 @@ static SDL_bool X11_KeyRepeat(Display *display, XEvent *event) return d.found; } -static SDL_bool -X11_IsWheelEvent(Display * display,XEvent * event,int * xticks,int * yticks) +static SDL_bool X11_IsWheelEvent(Display *display, XEvent *event, int *xticks, int *yticks) { /* according to the xlib docs, no specific mouse wheel events exist. However, the defacto standard is that the vertical wheel is X buttons @@ -188,11 +188,20 @@ X11_IsWheelEvent(Display * display,XEvent * event,int * xticks,int * yticks) /* Xlib defines "Button1" through 5, so we just use literals here. */ switch (event->xbutton.button) { - case 4: *yticks = 1; return SDL_TRUE; - case 5: *yticks = -1; return SDL_TRUE; - case 6: *xticks = 1; return SDL_TRUE; - case 7: *xticks = -1; return SDL_TRUE; - default: break; + case 4: + *yticks = 1; + return SDL_TRUE; + case 5: + *yticks = -1; + return SDL_TRUE; + case 6: + *xticks = 1; + return SDL_TRUE; + case 7: + *xticks = -1; + return SDL_TRUE; + default: + break; } return SDL_FALSE; } @@ -210,7 +219,8 @@ X11_IsWheelEvent(Display * display,XEvent * event,int * xticks,int * yticks) On error, -1 is returned. */ -static int X11_URIDecode(char *buf, int len) { +static int X11_URIDecode(char *buf, int len) +{ int ri, wi, di; char decode = '\0'; if (buf == NULL || len < 0) { @@ -273,12 +283,13 @@ static int X11_URIDecode(char *buf, int len) { /* Convert URI to local filename return filename if possible, else NULL */ -static char* X11_URIToLocal(char* uri) { +static char *X11_URIToLocal(char *uri) +{ char *file = NULL; SDL_bool local; - if (SDL_memcmp(uri,"file:/",6) == 0) { - uri += 6; /* local file? */ + if (SDL_memcmp(uri, "file:/", 6) == 0) { + uri += 6; /* local file? */ } else if (SDL_strstr(uri, ":/") != NULL) { return file; /* wrong scheme */ } @@ -287,27 +298,27 @@ static char* X11_URIToLocal(char* uri) { /* got a hostname? */ if (!local && uri[0] == '/' && uri[2] != '/') { - char* hostname_end = SDL_strchr(uri+1, '/'); - if (hostname_end != NULL) { - char hostname[ 257 ]; - if (gethostname(hostname, 255) == 0) { - hostname[ 256 ] = '\0'; - if (SDL_memcmp(uri+1, hostname, hostname_end - (uri+1)) == 0) { - uri = hostname_end + 1; - local = SDL_TRUE; + char *hostname_end = SDL_strchr(uri + 1, '/'); + if (hostname_end != NULL) { + char hostname[257]; + if (gethostname(hostname, 255) == 0) { + hostname[256] = '\0'; + if (SDL_memcmp(uri + 1, hostname, hostname_end - (uri + 1)) == 0) { + uri = hostname_end + 1; + local = SDL_TRUE; + } } - } - } + } } if (local) { - file = uri; - /* Convert URI escape sequences to real characters */ - X11_URIDecode(file, 0); - if (uri[1] == '/') { - file++; - } else { - file--; - } + file = uri; + /* Convert URI escape sequences to real characters */ + X11_URIDecode(file, 0); + if (uri[1] == '/') { + file++; + } else { + file--; + } } return file; } @@ -338,10 +349,9 @@ static void X11_HandleGenericEvent(SDL_VideoData *videodata, XEvent *xev) } #endif /* SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS */ -static unsigned -X11_GetNumLockModifierMask(_THIS) +static unsigned X11_GetNumLockModifierMask(_THIS) { - SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata; Display *display = viddata->display; unsigned num_mask = 0; int i, j; @@ -364,10 +374,9 @@ X11_GetNumLockModifierMask(_THIS) return num_mask; } -static unsigned -X11_GetScrollLockModifierMask(_THIS) +static unsigned X11_GetScrollLockModifierMask(_THIS) { - SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata; Display *display = viddata->display; unsigned num_mask = 0; int i, j; @@ -390,10 +399,9 @@ X11_GetScrollLockModifierMask(_THIS) return num_mask; } -void -X11_ReconcileKeyboardState(_THIS) +void X11_ReconcileKeyboardState(_THIS) { - SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata; Display *display = viddata->display; char keys[32]; int keycode; @@ -440,9 +448,7 @@ X11_ReconcileKeyboardState(_THIS) } } - -static void -X11_DispatchFocusIn(_THIS, SDL_WindowData *data) +static void X11_DispatchFocusIn(_THIS, SDL_WindowData *data) { #ifdef DEBUG_XEVENTS printf("window %p: Dispatching FocusIn\n", data); @@ -462,8 +468,7 @@ X11_DispatchFocusIn(_THIS, SDL_WindowData *data) } } -static void -X11_DispatchFocusOut(_THIS, SDL_WindowData *data) +static void X11_DispatchFocusOut(_THIS, SDL_WindowData *data) { #ifdef DEBUG_XEVENTS printf("window %p: Dispatching FocusOut\n", data); @@ -485,8 +490,7 @@ X11_DispatchFocusOut(_THIS, SDL_WindowData *data) #endif } -static void -X11_DispatchMapNotify(SDL_WindowData *data) +static void X11_DispatchMapNotify(SDL_WindowData *data) { SDL_Window *window = data->window; SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0); @@ -496,18 +500,16 @@ X11_DispatchMapNotify(SDL_WindowData *data) } } -static void -X11_DispatchUnmapNotify(SDL_WindowData *data) +static void X11_DispatchUnmapNotify(SDL_WindowData *data) { SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIDDEN, 0, 0); SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); } -static void -InitiateWindowMove(_THIS, const SDL_WindowData *data, const SDL_Point *point) +static void InitiateWindowMove(_THIS, const SDL_WindowData *data, const SDL_Point *point) { - SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata; - SDL_Window* window = data->window; + SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata; + SDL_Window *window = data->window; Display *display = viddata->display; XEvent evt; @@ -529,11 +531,10 @@ InitiateWindowMove(_THIS, const SDL_WindowData *data, const SDL_Point *point) X11_XSync(display, 0); } -static void -InitiateWindowResize(_THIS, const SDL_WindowData *data, const SDL_Point *point, int direction) +static void InitiateWindowResize(_THIS, const SDL_WindowData *data, const SDL_Point *point, int direction) { - SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata; - SDL_Window* window = data->window; + SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata; + SDL_Window *window = data->window; Display *display = viddata->display; XEvent evt; @@ -559,8 +560,7 @@ InitiateWindowResize(_THIS, const SDL_WindowData *data, const SDL_Point *point, X11_XSync(display, 0); } -static SDL_bool -ProcessHitTest(_THIS, const SDL_WindowData *data, const XEvent *xev) +static SDL_bool ProcessHitTest(_THIS, const SDL_WindowData *data, const XEvent *xev) { SDL_Window *window = data->window; @@ -575,37 +575,37 @@ ProcessHitTest(_THIS, const SDL_WindowData *data, const XEvent *xev) }; switch (rc) { - case SDL_HITTEST_DRAGGABLE: - InitiateWindowMove(_this, data, &point); - return SDL_TRUE; + case SDL_HITTEST_DRAGGABLE: + InitiateWindowMove(_this, data, &point); + return SDL_TRUE; - case SDL_HITTEST_RESIZE_TOPLEFT: - case SDL_HITTEST_RESIZE_TOP: - case SDL_HITTEST_RESIZE_TOPRIGHT: - case SDL_HITTEST_RESIZE_RIGHT: - case SDL_HITTEST_RESIZE_BOTTOMRIGHT: - case SDL_HITTEST_RESIZE_BOTTOM: - case SDL_HITTEST_RESIZE_BOTTOMLEFT: - case SDL_HITTEST_RESIZE_LEFT: - InitiateWindowResize(_this, data, &point, directions[rc - SDL_HITTEST_RESIZE_TOPLEFT]); - return SDL_TRUE; + case SDL_HITTEST_RESIZE_TOPLEFT: + case SDL_HITTEST_RESIZE_TOP: + case SDL_HITTEST_RESIZE_TOPRIGHT: + case SDL_HITTEST_RESIZE_RIGHT: + case SDL_HITTEST_RESIZE_BOTTOMRIGHT: + case SDL_HITTEST_RESIZE_BOTTOM: + case SDL_HITTEST_RESIZE_BOTTOMLEFT: + case SDL_HITTEST_RESIZE_LEFT: + InitiateWindowResize(_this, data, &point, directions[rc - SDL_HITTEST_RESIZE_TOPLEFT]); + return SDL_TRUE; - default: return SDL_FALSE; + default: + return SDL_FALSE; } } return SDL_FALSE; } -static void -X11_UpdateUserTime(SDL_WindowData *data, const unsigned long latest) +static void X11_UpdateUserTime(SDL_WindowData *data, const unsigned long latest) { if (latest && (latest != data->user_time)) { SDL_VideoData *videodata = data->videodata; Display *display = videodata->display; X11_XChangeProperty(display, data->xwindow, videodata->_NET_WM_USER_TIME, XA_CARDINAL, 32, PropModeReplace, - (const unsigned char *) &latest, 1); + (const unsigned char *)&latest, 1); #ifdef DEBUG_XEVENTS printf("window %p: updating _NET_WM_USER_TIME to %lu\n", data, latest); #endif @@ -613,137 +613,133 @@ X11_UpdateUserTime(SDL_WindowData *data, const unsigned long latest) } } -static void -X11_HandleClipboardEvent(_THIS, const XEvent *xevent) +static void X11_HandleClipboardEvent(_THIS, const XEvent *xevent) { int i; - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; Display *display = videodata->display; SDL_assert(videodata->clipboard_window != None); SDL_assert(xevent->xany.window == videodata->clipboard_window); switch (xevent->type) { - /* Copy the selection from our own CUTBUFFER to the requested property */ - case SelectionRequest: { - const XSelectionRequestEvent *req = &xevent->xselectionrequest; - XEvent sevent; - int seln_format, mime_formats; - unsigned long nbytes; - unsigned long overflow; - unsigned char *seln_data; - Atom supportedFormats[SDL_X11_CLIPBOARD_MIME_TYPE_MAX+1]; - Atom XA_TARGETS = X11_XInternAtom(display, "TARGETS", 0); + /* Copy the selection from our own CUTBUFFER to the requested property */ + case SelectionRequest: + { + const XSelectionRequestEvent *req = &xevent->xselectionrequest; + XEvent sevent; + int seln_format, mime_formats; + unsigned long nbytes; + unsigned long overflow; + unsigned char *seln_data; + Atom supportedFormats[SDL_X11_CLIPBOARD_MIME_TYPE_MAX + 1]; + Atom XA_TARGETS = X11_XInternAtom(display, "TARGETS", 0); #ifdef DEBUG_XEVENTS - printf("window CLIPBOARD: SelectionRequest (requestor = %ld, target = %ld)\n", - req->requestor, req->target); + printf("window CLIPBOARD: SelectionRequest (requestor = %ld, target = %ld)\n", + req->requestor, req->target); #endif - SDL_zero(sevent); - sevent.xany.type = SelectionNotify; - sevent.xselection.selection = req->selection; - sevent.xselection.target = None; - sevent.xselection.property = None; /* tell them no by default */ - sevent.xselection.requestor = req->requestor; - sevent.xselection.time = req->time; + SDL_zero(sevent); + sevent.xany.type = SelectionNotify; + sevent.xselection.selection = req->selection; + sevent.xselection.target = None; + sevent.xselection.property = None; /* tell them no by default */ + sevent.xselection.requestor = req->requestor; + sevent.xselection.time = req->time; - /* !!! FIXME: We were probably storing this on the root window - because an SDL window might go away...? but we don't have to do - this now (or ever, really). */ + /* !!! FIXME: We were probably storing this on the root window + because an SDL window might go away...? but we don't have to do + this now (or ever, really). */ - if (req->target == XA_TARGETS) { - supportedFormats[0] = XA_TARGETS; - mime_formats = 1; - for (i = 0; i < SDL_X11_CLIPBOARD_MIME_TYPE_MAX; ++i) { - supportedFormats[mime_formats++] = X11_GetSDLCutBufferClipboardExternalFormat(display, i); + if (req->target == XA_TARGETS) { + supportedFormats[0] = XA_TARGETS; + mime_formats = 1; + for (i = 0; i < SDL_X11_CLIPBOARD_MIME_TYPE_MAX; ++i) { + supportedFormats[mime_formats++] = X11_GetSDLCutBufferClipboardExternalFormat(display, i); + } + X11_XChangeProperty(display, req->requestor, req->property, + XA_ATOM, 32, PropModeReplace, + (unsigned char *)supportedFormats, + mime_formats); + sevent.xselection.property = req->property; + sevent.xselection.target = XA_TARGETS; + } else { + for (i = 0; i < SDL_X11_CLIPBOARD_MIME_TYPE_MAX; ++i) { + if (X11_GetSDLCutBufferClipboardExternalFormat(display, i) != req->target) { + continue; } - X11_XChangeProperty(display, req->requestor, req->property, - XA_ATOM, 32, PropModeReplace, - (unsigned char*)supportedFormats, - mime_formats); - sevent.xselection.property = req->property; - sevent.xselection.target = XA_TARGETS; - } else { - for (i = 0; i < SDL_X11_CLIPBOARD_MIME_TYPE_MAX; ++i) { - if (X11_GetSDLCutBufferClipboardExternalFormat(display, i) != req->target) { - continue; - } - if (X11_XGetWindowProperty(display, DefaultRootWindow(display), - X11_GetSDLCutBufferClipboardType(display, i, req->selection), 0, INT_MAX/4, False, X11_GetSDLCutBufferClipboardInternalFormat(display, i), - &sevent.xselection.target, &seln_format, &nbytes, - &overflow, &seln_data) == Success) { - if (seln_format != None) { - X11_XChangeProperty(display, req->requestor, req->property, - sevent.xselection.target, seln_format, PropModeReplace, - seln_data, nbytes); - sevent.xselection.property = req->property; - X11_XFree(seln_data); - break; - } else { - X11_XFree(seln_data); - } + if (X11_XGetWindowProperty(display, DefaultRootWindow(display), + X11_GetSDLCutBufferClipboardType(display, i, req->selection), 0, INT_MAX / 4, False, X11_GetSDLCutBufferClipboardInternalFormat(display, i), + &sevent.xselection.target, &seln_format, &nbytes, + &overflow, &seln_data) == Success) { + if (seln_format != None) { + X11_XChangeProperty(display, req->requestor, req->property, + sevent.xselection.target, seln_format, PropModeReplace, + seln_data, nbytes); + sevent.xselection.property = req->property; + X11_XFree(seln_data); + break; + } else { + X11_XFree(seln_data); } } } - X11_XSendEvent(display, req->requestor, False, 0, &sevent); - X11_XSync(display, False); } - break; + X11_XSendEvent(display, req->requestor, False, 0, &sevent); + X11_XSync(display, False); + } break; - case SelectionNotify: { + case SelectionNotify: + { #ifdef DEBUG_XEVENTS - printf("window CLIPBOARD: SelectionNotify (requestor = %ld, target = %ld)\n", - xevent->xselection.requestor, xevent->xselection.target); + printf("window CLIPBOARD: SelectionNotify (requestor = %ld, target = %ld)\n", + xevent->xselection.requestor, xevent->xselection.target); #endif - videodata->selection_waiting = SDL_FALSE; - } - break; + videodata->selection_waiting = SDL_FALSE; + } break; - case SelectionClear: { - /* !!! FIXME: cache atoms */ - Atom XA_CLIPBOARD = X11_XInternAtom(display, "CLIPBOARD", 0); + case SelectionClear: + { + /* !!! FIXME: cache atoms */ + Atom XA_CLIPBOARD = X11_XInternAtom(display, "CLIPBOARD", 0); #ifdef DEBUG_XEVENTS - printf("window CLIPBOARD: SelectionClear (requestor = %ld, target = %ld)\n", - xevent->xselection.requestor, xevent->xselection.target); + printf("window CLIPBOARD: SelectionClear (requestor = %ld, target = %ld)\n", + xevent->xselection.requestor, xevent->xselection.target); #endif - if (xevent->xselectionclear.selection == XA_PRIMARY || - (XA_CLIPBOARD != None && xevent->xselectionclear.selection == XA_CLIPBOARD)) { - SDL_SendClipboardUpdate(); - } + if (xevent->xselectionclear.selection == XA_PRIMARY || + (XA_CLIPBOARD != None && xevent->xselectionclear.selection == XA_CLIPBOARD)) { + SDL_SendClipboardUpdate(); } - break; + } break; } } -static Bool -isMapNotify(Display *display, XEvent *ev, XPointer arg) +static Bool isMapNotify(Display *display, XEvent *ev, XPointer arg) { XUnmapEvent *unmap; - unmap = (XUnmapEvent*) arg; + unmap = (XUnmapEvent *)arg; return ev->type == MapNotify && - ev->xmap.window == unmap->window && - ev->xmap.serial == unmap->serial; + ev->xmap.window == unmap->window && + ev->xmap.serial == unmap->serial; } -static Bool -isReparentNotify(Display *display, XEvent *ev, XPointer arg) +static Bool isReparentNotify(Display *display, XEvent *ev, XPointer arg) { XUnmapEvent *unmap; - unmap = (XUnmapEvent*) arg; + unmap = (XUnmapEvent *)arg; return ev->type == ReparentNotify && - ev->xreparent.window == unmap->window && - ev->xreparent.serial == unmap->serial; + ev->xreparent.window == unmap->window && + ev->xreparent.serial == unmap->serial; } -static int -XLookupStringAsUTF8(XKeyEvent *event_struct, char *buffer_return, int bytes_buffer, KeySym *keysym_return, XComposeStatus *status_in_out) +static int XLookupStringAsUTF8(XKeyEvent *event_struct, char *buffer_return, int bytes_buffer, KeySym *keysym_return, XComposeStatus *status_in_out) { int result = X11_XLookupString(event_struct, buffer_return, bytes_buffer, keysym_return, status_in_out); if (result > 0) { @@ -759,10 +755,9 @@ XLookupStringAsUTF8(XKeyEvent *event_struct, char *buffer_return, int bytes_buff return result; } -static void -X11_DispatchEvent(_THIS, XEvent *xevent) +static void X11_DispatchEvent(_THIS, XEvent *xevent) { - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; Display *display; SDL_WindowData *data; int orig_event_type; @@ -874,7 +869,7 @@ X11_DispatchEvent(_THIS, XEvent *xevent) X11_UpdateKeymap(_this, SDL_TRUE); } else if (xevent->type == PropertyNotify && videodata && videodata->windowlist) { - char* name_of_atom = X11_XGetAtomName(display, xevent->xproperty.atom); + char *name_of_atom = X11_XGetAtomName(display, xevent->xproperty.atom); if (SDL_strncmp(name_of_atom, "_ICC_PROFILE", sizeof("_ICC_PROFILE") - 1) == 0) { XWindowAttributes attrib; @@ -907,678 +902,676 @@ X11_DispatchEvent(_THIS, XEvent *xevent) switch (xevent->type) { /* Gaining mouse coverage? */ - case EnterNotify:{ - SDL_Mouse *mouse = SDL_GetMouse(); + case EnterNotify: + { + SDL_Mouse *mouse = SDL_GetMouse(); #ifdef DEBUG_XEVENTS - printf("window %p: EnterNotify! (%d,%d,%d)\n", data, - xevent->xcrossing.x, - xevent->xcrossing.y, - xevent->xcrossing.mode); - if (xevent->xcrossing.mode == NotifyGrab) { - printf("Mode: NotifyGrab\n"); - } - if (xevent->xcrossing.mode == NotifyUngrab) { - printf("Mode: NotifyUngrab\n"); - } + printf("window %p: EnterNotify! (%d,%d,%d)\n", data, + xevent->xcrossing.x, + xevent->xcrossing.y, + xevent->xcrossing.mode); + if (xevent->xcrossing.mode == NotifyGrab) { + printf("Mode: NotifyGrab\n"); + } + if (xevent->xcrossing.mode == NotifyUngrab) { + printf("Mode: NotifyUngrab\n"); + } #endif - SDL_SetMouseFocus(data->window); + SDL_SetMouseFocus(data->window); - mouse->last_x = xevent->xcrossing.x; - mouse->last_y = xevent->xcrossing.y; + mouse->last_x = xevent->xcrossing.x; + mouse->last_y = xevent->xcrossing.y; #if SDL_VIDEO_DRIVER_X11_XFIXES - { - /* Only create the barriers if we have input focus */ - SDL_WindowData* windowdata = (SDL_WindowData *) data->window->driverdata; - if ((data->pointer_barrier_active == SDL_TRUE) && windowdata->window->flags & SDL_WINDOW_INPUT_FOCUS) { - X11_ConfineCursorWithFlags(_this, windowdata->window, &windowdata->barrier_rect, X11_BARRIER_HANDLED_BY_EVENT); - } + { + /* Only create the barriers if we have input focus */ + SDL_WindowData *windowdata = (SDL_WindowData *)data->window->driverdata; + if ((data->pointer_barrier_active == SDL_TRUE) && windowdata->window->flags & SDL_WINDOW_INPUT_FOCUS) { + X11_ConfineCursorWithFlags(_this, windowdata->window, &windowdata->barrier_rect, X11_BARRIER_HANDLED_BY_EVENT); } + } #endif - if (!mouse->relative_mode) { - SDL_SendMouseMotion(data->window, 0, 0, xevent->xcrossing.x, xevent->xcrossing.y); - } - - /* We ungrab in LeaveNotify, so we may need to grab again here */ - SDL_UpdateWindowGrab(data->window); + if (!mouse->relative_mode) { + SDL_SendMouseMotion(data->window, 0, 0, xevent->xcrossing.x, xevent->xcrossing.y); } - break; + + /* We ungrab in LeaveNotify, so we may need to grab again here */ + SDL_UpdateWindowGrab(data->window); + } break; /* Losing mouse coverage? */ - case LeaveNotify:{ + case LeaveNotify: + { #ifdef DEBUG_XEVENTS - printf("window %p: LeaveNotify! (%d,%d,%d)\n", data, - xevent->xcrossing.x, - xevent->xcrossing.y, - xevent->xcrossing.mode); - if (xevent->xcrossing.mode == NotifyGrab) { - printf("Mode: NotifyGrab\n"); - } - if (xevent->xcrossing.mode == NotifyUngrab) { - printf("Mode: NotifyUngrab\n"); - } -#endif - if (!SDL_GetMouse()->relative_mode) { - SDL_SendMouseMotion(data->window, 0, 0, xevent->xcrossing.x, xevent->xcrossing.y); - } - - if (xevent->xcrossing.mode != NotifyGrab && - xevent->xcrossing.mode != NotifyUngrab && - xevent->xcrossing.detail != NotifyInferior) { - - /* In order for interaction with the window decorations and menu to work properly - on Mutter, we need to ungrab the keyboard when the the mouse leaves. */ - if (!(data->window->flags & SDL_WINDOW_FULLSCREEN)) { - X11_SetWindowKeyboardGrab(_this, data->window, SDL_FALSE); - } - - SDL_SetMouseFocus(NULL); - } + printf("window %p: LeaveNotify! (%d,%d,%d)\n", data, + xevent->xcrossing.x, + xevent->xcrossing.y, + xevent->xcrossing.mode); + if (xevent->xcrossing.mode == NotifyGrab) { + printf("Mode: NotifyGrab\n"); } - break; + if (xevent->xcrossing.mode == NotifyUngrab) { + printf("Mode: NotifyUngrab\n"); + } +#endif + if (!SDL_GetMouse()->relative_mode) { + SDL_SendMouseMotion(data->window, 0, 0, xevent->xcrossing.x, xevent->xcrossing.y); + } + + if (xevent->xcrossing.mode != NotifyGrab && + xevent->xcrossing.mode != NotifyUngrab && + xevent->xcrossing.detail != NotifyInferior) { + + /* In order for interaction with the window decorations and menu to work properly + on Mutter, we need to ungrab the keyboard when the the mouse leaves. */ + if (!(data->window->flags & SDL_WINDOW_FULLSCREEN)) { + X11_SetWindowKeyboardGrab(_this, data->window, SDL_FALSE); + } + + SDL_SetMouseFocus(NULL); + } + } break; /* Gaining input focus? */ - case FocusIn:{ - if (xevent->xfocus.mode == NotifyGrab || xevent->xfocus.mode == NotifyUngrab) { - /* Someone is handling a global hotkey, ignore it */ + case FocusIn: + { + if (xevent->xfocus.mode == NotifyGrab || xevent->xfocus.mode == NotifyUngrab) { + /* Someone is handling a global hotkey, ignore it */ #ifdef DEBUG_XEVENTS - printf("window %p: FocusIn (NotifyGrab/NotifyUngrab, ignoring)\n", data); + printf("window %p: FocusIn (NotifyGrab/NotifyUngrab, ignoring)\n", data); #endif - break; - } - - if (xevent->xfocus.detail == NotifyInferior || xevent->xfocus.detail == NotifyPointer) { -#ifdef DEBUG_XEVENTS - printf("window %p: FocusIn (NotifyInferior/NotifyPointer, ignoring)\n", data); -#endif - break; - } -#ifdef DEBUG_XEVENTS - printf("window %p: FocusIn!\n", data); -#endif - if (!videodata->last_mode_change_deadline) /* no recent mode changes */ { - data->pending_focus = PENDING_FOCUS_NONE; - data->pending_focus_time = 0; - X11_DispatchFocusIn(_this, data); - } else { - data->pending_focus = PENDING_FOCUS_IN; - data->pending_focus_time = SDL_GetTicks() + PENDING_FOCUS_TIME; - } - data->last_focus_event_time = SDL_GetTicks(); + break; } - break; + + if (xevent->xfocus.detail == NotifyInferior || xevent->xfocus.detail == NotifyPointer) { +#ifdef DEBUG_XEVENTS + printf("window %p: FocusIn (NotifyInferior/NotifyPointer, ignoring)\n", data); +#endif + break; + } +#ifdef DEBUG_XEVENTS + printf("window %p: FocusIn!\n", data); +#endif + if (!videodata->last_mode_change_deadline) /* no recent mode changes */ { + data->pending_focus = PENDING_FOCUS_NONE; + data->pending_focus_time = 0; + X11_DispatchFocusIn(_this, data); + } else { + data->pending_focus = PENDING_FOCUS_IN; + data->pending_focus_time = SDL_GetTicks() + PENDING_FOCUS_TIME; + } + data->last_focus_event_time = SDL_GetTicks(); + } break; /* Losing input focus? */ - case FocusOut:{ - if (xevent->xfocus.mode == NotifyGrab || xevent->xfocus.mode == NotifyUngrab) { - /* Someone is handling a global hotkey, ignore it */ + case FocusOut: + { + if (xevent->xfocus.mode == NotifyGrab || xevent->xfocus.mode == NotifyUngrab) { + /* Someone is handling a global hotkey, ignore it */ #ifdef DEBUG_XEVENTS - printf("window %p: FocusOut (NotifyGrab/NotifyUngrab, ignoring)\n", data); + printf("window %p: FocusOut (NotifyGrab/NotifyUngrab, ignoring)\n", data); #endif - break; - } - if (xevent->xfocus.detail == NotifyInferior || xevent->xfocus.detail == NotifyPointer) { - /* We still have focus if a child gets focus. We also don't - care about the position of the pointer when the keyboard - focus changed. */ + break; + } + if (xevent->xfocus.detail == NotifyInferior || xevent->xfocus.detail == NotifyPointer) { + /* We still have focus if a child gets focus. We also don't + care about the position of the pointer when the keyboard + focus changed. */ #ifdef DEBUG_XEVENTS - printf("window %p: FocusOut (NotifyInferior/NotifyPointer, ignoring)\n", data); + printf("window %p: FocusOut (NotifyInferior/NotifyPointer, ignoring)\n", data); #endif - break; - } + break; + } #ifdef DEBUG_XEVENTS - printf("window %p: FocusOut!\n", data); + printf("window %p: FocusOut!\n", data); #endif - if (!videodata->last_mode_change_deadline) /* no recent mode changes */ { - data->pending_focus = PENDING_FOCUS_NONE; - data->pending_focus_time = 0; - X11_DispatchFocusOut(_this, data); - } else { - data->pending_focus = PENDING_FOCUS_OUT; - data->pending_focus_time = SDL_GetTicks() + PENDING_FOCUS_TIME; - } + if (!videodata->last_mode_change_deadline) /* no recent mode changes */ { + data->pending_focus = PENDING_FOCUS_NONE; + data->pending_focus_time = 0; + X11_DispatchFocusOut(_this, data); + } else { + data->pending_focus = PENDING_FOCUS_OUT; + data->pending_focus_time = SDL_GetTicks() + PENDING_FOCUS_TIME; + } #if SDL_VIDEO_DRIVER_X11_XFIXES - /* Disable confinement if it is activated. */ - if (data->pointer_barrier_active == SDL_TRUE) { - X11_ConfineCursorWithFlags(_this, data->window, NULL, X11_BARRIER_HANDLED_BY_EVENT); - } -#endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ + /* Disable confinement if it is activated. */ + if (data->pointer_barrier_active == SDL_TRUE) { + X11_ConfineCursorWithFlags(_this, data->window, NULL, X11_BARRIER_HANDLED_BY_EVENT); } - break; +#endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ + } break; /* Key press/release? */ case KeyPress: - case KeyRelease: { - KeyCode keycode = xevent->xkey.keycode; - KeySym keysym = NoSymbol; - char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; - Status status = 0; - SDL_bool handled_by_ime = SDL_FALSE; + case KeyRelease: + { + KeyCode keycode = xevent->xkey.keycode; + KeySym keysym = NoSymbol; + char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; + Status status = 0; + SDL_bool handled_by_ime = SDL_FALSE; #ifdef DEBUG_XEVENTS - printf("window %p: %s (X11 keycode = 0x%X)\n", data, (xevent->type == KeyPress ? "KeyPress" : "KeyRelease"), xevent->xkey.keycode); + printf("window %p: %s (X11 keycode = 0x%X)\n", data, (xevent->type == KeyPress ? "KeyPress" : "KeyRelease"), xevent->xkey.keycode); #endif #ifdef DEBUG_SCANCODES - if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN && keycode) { - int min_keycode, max_keycode; - X11_XDisplayKeycodes(display, &min_keycode, &max_keycode); - keysym = X11_KeyCodeToSym(_this, keycode, xevent->xkey.state >> 13); - SDL_Log("The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL forums/mailing list X11 KeyCode %d (%d), X11 KeySym 0x%lX (%s).\n", - keycode, keycode - min_keycode, keysym, - X11_XKeysymToString(keysym)); - } + if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN && keycode) { + int min_keycode, max_keycode; + X11_XDisplayKeycodes(display, &min_keycode, &max_keycode); + keysym = X11_KeyCodeToSym(_this, keycode, xevent->xkey.state >> 13); + SDL_Log("The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL forums/mailing list X11 KeyCode %d (%d), X11 KeySym 0x%lX (%s).\n", + keycode, keycode - min_keycode, keysym, + X11_XKeysymToString(keysym)); + } #endif /* DEBUG SCANCODES */ - SDL_zeroa(text); + SDL_zeroa(text); #ifdef X_HAVE_UTF8_STRING - if (data->ic && xevent->type == KeyPress) { - X11_Xutf8LookupString(data->ic, &xevent->xkey, text, sizeof(text), + if (data->ic && xevent->type == KeyPress) { + X11_Xutf8LookupString(data->ic, &xevent->xkey, text, sizeof(text), &keysym, &status); - } else { - XLookupStringAsUTF8(&xevent->xkey, text, sizeof(text), &keysym, NULL); - } -#else + } else { XLookupStringAsUTF8(&xevent->xkey, text, sizeof(text), &keysym, NULL); + } +#else + XLookupStringAsUTF8(&xevent->xkey, text, sizeof(text), &keysym, NULL); #endif #ifdef SDL_USE_IME - if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { - handled_by_ime = SDL_IME_ProcessKeyEvent(keysym, keycode, (xevent->type == KeyPress ? SDL_PRESSED : SDL_RELEASED)); - } + if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { + handled_by_ime = SDL_IME_ProcessKeyEvent(keysym, keycode, (xevent->type == KeyPress ? SDL_PRESSED : SDL_RELEASED)); + } #endif - if (!handled_by_ime) { - if (xevent->type == KeyPress) { - /* Don't send the key if it looks like a duplicate of a filtered key sent by an IME */ - if (xevent->xkey.keycode != videodata->filter_code || xevent->xkey.time != videodata->filter_time) { - SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]); - } - if (*text) { - SDL_SendKeyboardText(text); - } - } else { - if (X11_KeyRepeat(display, xevent)) { - /* We're about to get a repeated key down, ignore the key up */ - break; - } - SDL_SendKeyboardKey(SDL_RELEASED, videodata->key_layout[keycode]); - } - } - + if (!handled_by_ime) { if (xevent->type == KeyPress) { - X11_UpdateUserTime(data, xevent->xkey.time); + /* Don't send the key if it looks like a duplicate of a filtered key sent by an IME */ + if (xevent->xkey.keycode != videodata->filter_code || xevent->xkey.time != videodata->filter_time) { + SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]); + } + if (*text) { + SDL_SendKeyboardText(text); + } + } else { + if (X11_KeyRepeat(display, xevent)) { + /* We're about to get a repeated key down, ignore the key up */ + break; + } + SDL_SendKeyboardKey(SDL_RELEASED, videodata->key_layout[keycode]); } } - break; + + if (xevent->type == KeyPress) { + X11_UpdateUserTime(data, xevent->xkey.time); + } + } break; /* Have we been iconified? */ - case UnmapNotify:{ - XEvent ev; + case UnmapNotify: + { + XEvent ev; #ifdef DEBUG_XEVENTS - printf("window %p: UnmapNotify!\n", data); + printf("window %p: UnmapNotify!\n", data); #endif - if (X11_XCheckIfEvent(display, &ev, &isReparentNotify, (XPointer)&xevent->xunmap)) { - X11_XCheckIfEvent(display, &ev, &isMapNotify, (XPointer)&xevent->xunmap); - } else { - X11_DispatchUnmapNotify(data); - } + if (X11_XCheckIfEvent(display, &ev, &isReparentNotify, (XPointer)&xevent->xunmap)) { + X11_XCheckIfEvent(display, &ev, &isMapNotify, (XPointer)&xevent->xunmap); + } else { + X11_DispatchUnmapNotify(data); + } #if SDL_VIDEO_DRIVER_X11_XFIXES - /* Disable confinement if the window gets hidden. */ - if (data->pointer_barrier_active == SDL_TRUE) { - X11_ConfineCursorWithFlags(_this, data->window, NULL, X11_BARRIER_HANDLED_BY_EVENT); - } -#endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ + /* Disable confinement if the window gets hidden. */ + if (data->pointer_barrier_active == SDL_TRUE) { + X11_ConfineCursorWithFlags(_this, data->window, NULL, X11_BARRIER_HANDLED_BY_EVENT); } - break; +#endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ + } break; /* Have we been restored? */ - case MapNotify:{ + case MapNotify: + { #ifdef DEBUG_XEVENTS - printf("window %p: MapNotify!\n", data); + printf("window %p: MapNotify!\n", data); #endif - X11_DispatchMapNotify(data); + X11_DispatchMapNotify(data); #if SDL_VIDEO_DRIVER_X11_XFIXES - /* Enable confinement if it was activated. */ - if (data->pointer_barrier_active == SDL_TRUE) { - X11_ConfineCursorWithFlags(_this, data->window, &data->barrier_rect, X11_BARRIER_HANDLED_BY_EVENT); - } -#endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ + /* Enable confinement if it was activated. */ + if (data->pointer_barrier_active == SDL_TRUE) { + X11_ConfineCursorWithFlags(_this, data->window, &data->barrier_rect, X11_BARRIER_HANDLED_BY_EVENT); } - break; +#endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ + } break; /* Have we been resized or moved? */ - case ConfigureNotify:{ + case ConfigureNotify: + { #ifdef DEBUG_XEVENTS - printf("window %p: ConfigureNotify! (position: %d,%d, size: %dx%d)\n", data, - xevent->xconfigure.x, xevent->xconfigure.y, - xevent->xconfigure.width, xevent->xconfigure.height); + printf("window %p: ConfigureNotify! (position: %d,%d, size: %dx%d)\n", data, + xevent->xconfigure.x, xevent->xconfigure.y, + xevent->xconfigure.width, xevent->xconfigure.height); #endif - /* Real configure notify events are relative to the parent, synthetic events are absolute. */ - if (!xevent->xconfigure.send_event) { - unsigned int NumChildren; - Window ChildReturn, Root, Parent; - Window * Children; - /* Translate these coodinates back to relative to root */ - X11_XQueryTree(data->videodata->display, xevent->xconfigure.window, &Root, &Parent, &Children, &NumChildren); - X11_XTranslateCoordinates(xevent->xconfigure.display, - Parent, DefaultRootWindow(xevent->xconfigure.display), - xevent->xconfigure.x, xevent->xconfigure.y, - &xevent->xconfigure.x, &xevent->xconfigure.y, - &ChildReturn); - } - - if (xevent->xconfigure.x != data->last_xconfigure.x || - xevent->xconfigure.y != data->last_xconfigure.y) { - SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MOVED, - xevent->xconfigure.x, xevent->xconfigure.y); -#ifdef SDL_USE_IME - if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { - /* Update IME candidate list position */ - SDL_IME_UpdateTextRect(NULL); - } -#endif - } - if (xevent->xconfigure.width != data->last_xconfigure.width || - xevent->xconfigure.height != data->last_xconfigure.height) { - SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESIZED, - xevent->xconfigure.width, - xevent->xconfigure.height); - } - data->last_xconfigure = xevent->xconfigure; + /* Real configure notify events are relative to the parent, synthetic events are absolute. */ + if (!xevent->xconfigure.send_event) { + unsigned int NumChildren; + Window ChildReturn, Root, Parent; + Window *Children; + /* Translate these coodinates back to relative to root */ + X11_XQueryTree(data->videodata->display, xevent->xconfigure.window, &Root, &Parent, &Children, &NumChildren); + X11_XTranslateCoordinates(xevent->xconfigure.display, + Parent, DefaultRootWindow(xevent->xconfigure.display), + xevent->xconfigure.x, xevent->xconfigure.y, + &xevent->xconfigure.x, &xevent->xconfigure.y, + &ChildReturn); } - break; + + if (xevent->xconfigure.x != data->last_xconfigure.x || + xevent->xconfigure.y != data->last_xconfigure.y) { + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MOVED, + xevent->xconfigure.x, xevent->xconfigure.y); +#ifdef SDL_USE_IME + if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { + /* Update IME candidate list position */ + SDL_IME_UpdateTextRect(NULL); + } +#endif + } + if (xevent->xconfigure.width != data->last_xconfigure.width || + xevent->xconfigure.height != data->last_xconfigure.height) { + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESIZED, + xevent->xconfigure.width, + xevent->xconfigure.height); + } + data->last_xconfigure = xevent->xconfigure; + } break; /* Have we been requested to quit (or another client message?) */ - case ClientMessage:{ + case ClientMessage: + { - static int xdnd_version=0; + static int xdnd_version = 0; - if (xevent->xclient.message_type == videodata->XdndEnter) { + if (xevent->xclient.message_type == videodata->XdndEnter) { - SDL_bool use_list = xevent->xclient.data.l[1] & 1; - data->xdnd_source = xevent->xclient.data.l[0]; - xdnd_version = (xevent->xclient.data.l[1] >> 24); + SDL_bool use_list = xevent->xclient.data.l[1] & 1; + data->xdnd_source = xevent->xclient.data.l[0]; + xdnd_version = (xevent->xclient.data.l[1] >> 24); #ifdef DEBUG_XEVENTS - printf("XID of source window : %ld\n", data->xdnd_source); - printf("Protocol version to use : %d\n", xdnd_version); - printf("More then 3 data types : %d\n", (int) use_list); + printf("XID of source window : %ld\n", data->xdnd_source); + printf("Protocol version to use : %d\n", xdnd_version); + printf("More then 3 data types : %d\n", (int)use_list); #endif - if (use_list) { - /* fetch conversion targets */ - SDL_x11Prop p; - X11_ReadProperty(&p, display, data->xdnd_source, videodata->XdndTypeList); - /* pick one */ - data->xdnd_req = X11_PickTarget(display, (Atom*)p.data, p.count); - X11_XFree(p.data); - } else { - /* pick from list of three */ - data->xdnd_req = X11_PickTargetFromAtoms(display, xevent->xclient.data.l[2], xevent->xclient.data.l[3], xevent->xclient.data.l[4]); - } - } else if (xevent->xclient.message_type == videodata->XdndPosition) { + if (use_list) { + /* fetch conversion targets */ + SDL_x11Prop p; + X11_ReadProperty(&p, display, data->xdnd_source, videodata->XdndTypeList); + /* pick one */ + data->xdnd_req = X11_PickTarget(display, (Atom *)p.data, p.count); + X11_XFree(p.data); + } else { + /* pick from list of three */ + data->xdnd_req = X11_PickTargetFromAtoms(display, xevent->xclient.data.l[2], xevent->xclient.data.l[3], xevent->xclient.data.l[4]); + } + } else if (xevent->xclient.message_type == videodata->XdndPosition) { #ifdef DEBUG_XEVENTS - Atom act= videodata->XdndActionCopy; - if (xdnd_version >= 2) { - act = xevent->xclient.data.l[4]; - } - printf("Action requested by user is : %s\n", X11_XGetAtomName(display , act)); + Atom act = videodata->XdndActionCopy; + if (xdnd_version >= 2) { + act = xevent->xclient.data.l[4]; + } + printf("Action requested by user is : %s\n", X11_XGetAtomName(display, act)); #endif + /* reply with status */ + SDL_memset(&m, 0, sizeof(XClientMessageEvent)); + m.type = ClientMessage; + m.display = xevent->xclient.display; + m.window = xevent->xclient.data.l[0]; + m.message_type = videodata->XdndStatus; + m.format = 32; + m.data.l[0] = data->xwindow; + m.data.l[1] = (data->xdnd_req != None); + m.data.l[2] = 0; /* specify an empty rectangle */ + m.data.l[3] = 0; + m.data.l[4] = videodata->XdndActionCopy; /* we only accept copying anyway */ - /* reply with status */ + X11_XSendEvent(display, xevent->xclient.data.l[0], False, NoEventMask, (XEvent *)&m); + X11_XFlush(display); + } else if (xevent->xclient.message_type == videodata->XdndDrop) { + if (data->xdnd_req == None) { + /* say again - not interested! */ SDL_memset(&m, 0, sizeof(XClientMessageEvent)); m.type = ClientMessage; m.display = xevent->xclient.display; m.window = xevent->xclient.data.l[0]; - m.message_type = videodata->XdndStatus; - m.format=32; + m.message_type = videodata->XdndFinished; + m.format = 32; m.data.l[0] = data->xwindow; - m.data.l[1] = (data->xdnd_req != None); - m.data.l[2] = 0; /* specify an empty rectangle */ - m.data.l[3] = 0; - m.data.l[4] = videodata->XdndActionCopy; /* we only accept copying anyway */ - - X11_XSendEvent(display, xevent->xclient.data.l[0], False, NoEventMask, (XEvent*)&m); - X11_XFlush(display); - } else if (xevent->xclient.message_type == videodata->XdndDrop) { - if (data->xdnd_req == None) { - /* say again - not interested! */ - SDL_memset(&m, 0, sizeof(XClientMessageEvent)); - m.type = ClientMessage; - m.display = xevent->xclient.display; - m.window = xevent->xclient.data.l[0]; - m.message_type = videodata->XdndFinished; - m.format=32; - m.data.l[0] = data->xwindow; - m.data.l[1] = 0; - m.data.l[2] = None; /* fail! */ - X11_XSendEvent(display, xevent->xclient.data.l[0], False, NoEventMask, (XEvent*)&m); + m.data.l[1] = 0; + m.data.l[2] = None; /* fail! */ + X11_XSendEvent(display, xevent->xclient.data.l[0], False, NoEventMask, (XEvent *)&m); + } else { + /* convert */ + if (xdnd_version >= 1) { + X11_XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, xevent->xclient.data.l[2]); } else { - /* convert */ - if (xdnd_version >= 1) { - X11_XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, xevent->xclient.data.l[2]); - } else { - X11_XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, CurrentTime); - } + X11_XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, CurrentTime); } - } else if ((xevent->xclient.message_type == videodata->WM_PROTOCOLS) && - (xevent->xclient.format == 32) && - (xevent->xclient.data.l[0] == videodata->_NET_WM_PING)) { - Window root = DefaultRootWindow(display); - -#ifdef DEBUG_XEVENTS - printf("window %p: _NET_WM_PING\n", data); -#endif - xevent->xclient.window = root; - X11_XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, xevent); - break; } - - else if ((xevent->xclient.message_type == videodata->WM_PROTOCOLS) && - (xevent->xclient.format == 32) && - (xevent->xclient.data.l[0] == videodata->WM_DELETE_WINDOW)) { + } else if ((xevent->xclient.message_type == videodata->WM_PROTOCOLS) && + (xevent->xclient.format == 32) && + (xevent->xclient.data.l[0] == videodata->_NET_WM_PING)) { + Window root = DefaultRootWindow(display); #ifdef DEBUG_XEVENTS - printf("window %p: WM_DELETE_WINDOW\n", data); + printf("window %p: _NET_WM_PING\n", data); #endif - SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0); - break; - } else if ((xevent->xclient.message_type == videodata->WM_PROTOCOLS) && - (xevent->xclient.format == 32) && - (xevent->xclient.data.l[0] == videodata->WM_TAKE_FOCUS)) { - -#ifdef DEBUG_XEVENTS - printf("window %p: WM_TAKE_FOCUS\n", data); -#endif - SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_TAKE_FOCUS, 0, 0); - break; - } + xevent->xclient.window = root; + X11_XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, xevent); + break; } - break; + + else if ((xevent->xclient.message_type == videodata->WM_PROTOCOLS) && + (xevent->xclient.format == 32) && + (xevent->xclient.data.l[0] == videodata->WM_DELETE_WINDOW)) { + +#ifdef DEBUG_XEVENTS + printf("window %p: WM_DELETE_WINDOW\n", data); +#endif + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0); + break; + } else if ((xevent->xclient.message_type == videodata->WM_PROTOCOLS) && + (xevent->xclient.format == 32) && + (xevent->xclient.data.l[0] == videodata->WM_TAKE_FOCUS)) { + +#ifdef DEBUG_XEVENTS + printf("window %p: WM_TAKE_FOCUS\n", data); +#endif + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_TAKE_FOCUS, 0, 0); + break; + } + } break; /* Do we need to refresh ourselves? */ - case Expose:{ + case Expose: + { #ifdef DEBUG_XEVENTS - printf("window %p: Expose (count = %d)\n", data, xevent->xexpose.count); + printf("window %p: Expose (count = %d)\n", data, xevent->xexpose.count); #endif - SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_EXPOSED, 0, 0); - } - break; + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_EXPOSED, 0, 0); + } break; - case MotionNotify:{ - SDL_Mouse *mouse = SDL_GetMouse(); - if (!mouse->relative_mode || mouse->relative_mode_warp) { + case MotionNotify: + { + SDL_Mouse *mouse = SDL_GetMouse(); + if (!mouse->relative_mode || mouse->relative_mode_warp) { #ifdef DEBUG_MOTION - printf("window %p: X11 motion: %d,%d\n", data, xevent->xmotion.x, xevent->xmotion.y); + printf("window %p: X11 motion: %d,%d\n", data, xevent->xmotion.x, xevent->xmotion.y); #endif - SDL_SendMouseMotion(data->window, 0, 0, xevent->xmotion.x, xevent->xmotion.y); - } + SDL_SendMouseMotion(data->window, 0, 0, xevent->xmotion.x, xevent->xmotion.y); } - break; + } break; - case ButtonPress:{ - int xticks = 0, yticks = 0; + case ButtonPress: + { + int xticks = 0, yticks = 0; #ifdef DEBUG_XEVENTS - printf("window %p: ButtonPress (X11 button = %d)\n", data, xevent->xbutton.button); + printf("window %p: ButtonPress (X11 button = %d)\n", data, xevent->xbutton.button); #endif - if (X11_IsWheelEvent(display,xevent,&xticks, &yticks)) { - SDL_SendMouseWheel(data->window, 0, (float) -xticks, (float) yticks, SDL_MOUSEWHEEL_NORMAL); - } else { - SDL_bool ignore_click = SDL_FALSE; - int button = xevent->xbutton.button; - if (button == Button1) { - if (ProcessHitTest(_this, data, xevent)) { - SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIT_TEST, 0, 0); - break; /* don't pass this event on to app. */ - } - } else if (button > 7) { - /* X button values 4-7 are used for scrolling, so X1 is 8, X2 is 9, ... - => subtract (8-SDL_BUTTON_X1) to get value SDL expects */ - button -= (8-SDL_BUTTON_X1); - } - if (data->last_focus_event_time) { - const int X11_FOCUS_CLICK_TIMEOUT = 10; - if (!SDL_TICKS_PASSED(SDL_GetTicks(), data->last_focus_event_time + X11_FOCUS_CLICK_TIMEOUT)) { - ignore_click = !SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, SDL_FALSE); - } - data->last_focus_event_time = 0; - } - if (!ignore_click) { - SDL_SendMouseButton(data->window, 0, SDL_PRESSED, button); - } - } - X11_UpdateUserTime(data, xevent->xbutton.time); - } - break; - - case ButtonRelease:{ + if (X11_IsWheelEvent(display, xevent, &xticks, &yticks)) { + SDL_SendMouseWheel(data->window, 0, (float)-xticks, (float)yticks, SDL_MOUSEWHEEL_NORMAL); + } else { + SDL_bool ignore_click = SDL_FALSE; int button = xevent->xbutton.button; - /* The X server sends a Release event for each Press for wheels. Ignore them. */ - int xticks = 0, yticks = 0; -#ifdef DEBUG_XEVENTS - printf("window %p: ButtonRelease (X11 button = %d)\n", data, xevent->xbutton.button); -#endif - if (!X11_IsWheelEvent(display, xevent, &xticks, &yticks)) { - if (button > 7) { - /* see explanation at case ButtonPress */ - button -= (8-SDL_BUTTON_X1); + if (button == Button1) { + if (ProcessHitTest(_this, data, xevent)) { + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIT_TEST, 0, 0); + break; /* don't pass this event on to app. */ } - SDL_SendMouseButton(data->window, 0, SDL_RELEASED, button); + } else if (button > 7) { + /* X button values 4-7 are used for scrolling, so X1 is 8, X2 is 9, ... + => subtract (8-SDL_BUTTON_X1) to get value SDL expects */ + button -= (8 - SDL_BUTTON_X1); + } + if (data->last_focus_event_time) { + const int X11_FOCUS_CLICK_TIMEOUT = 10; + if (!SDL_TICKS_PASSED(SDL_GetTicks(), data->last_focus_event_time + X11_FOCUS_CLICK_TIMEOUT)) { + ignore_click = !SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, SDL_FALSE); + } + data->last_focus_event_time = 0; + } + if (!ignore_click) { + SDL_SendMouseButton(data->window, 0, SDL_PRESSED, button); } } - break; + X11_UpdateUserTime(data, xevent->xbutton.time); + } break; - case PropertyNotify:{ + case ButtonRelease: + { + int button = xevent->xbutton.button; + /* The X server sends a Release event for each Press for wheels. Ignore them. */ + int xticks = 0, yticks = 0; #ifdef DEBUG_XEVENTS - unsigned char *propdata; - int status, real_format; - Atom real_type; - unsigned long items_read, items_left; - - char *name = X11_XGetAtomName(display, xevent->xproperty.atom); - if (name) { - printf("window %p: PropertyNotify: %s %s time=%lu\n", data, name, (xevent->xproperty.state == PropertyDelete) ? "deleted" : "changed", xevent->xproperty.time); - X11_XFree(name); + printf("window %p: ButtonRelease (X11 button = %d)\n", data, xevent->xbutton.button); +#endif + if (!X11_IsWheelEvent(display, xevent, &xticks, &yticks)) { + if (button > 7) { + /* see explanation at case ButtonPress */ + button -= (8 - SDL_BUTTON_X1); } + SDL_SendMouseButton(data->window, 0, SDL_RELEASED, button); + } + } break; - status = X11_XGetWindowProperty(display, data->xwindow, xevent->xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata); - if (status == Success && items_read > 0) { - if (real_type == XA_INTEGER) { - int *values = (int *)propdata; + case PropertyNotify: + { +#ifdef DEBUG_XEVENTS + unsigned char *propdata; + int status, real_format; + Atom real_type; + unsigned long items_read, items_left; + + char *name = X11_XGetAtomName(display, xevent->xproperty.atom); + if (name) { + printf("window %p: PropertyNotify: %s %s time=%lu\n", data, name, (xevent->xproperty.state == PropertyDelete) ? "deleted" : "changed", xevent->xproperty.time); + X11_XFree(name); + } + + status = X11_XGetWindowProperty(display, data->xwindow, xevent->xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata); + if (status == Success && items_read > 0) { + if (real_type == XA_INTEGER) { + int *values = (int *)propdata; + + printf("{"); + for (i = 0; i < items_read; i++) { + printf(" %d", values[i]); + } + printf(" }\n"); + } else if (real_type == XA_CARDINAL) { + if (real_format == 32) { + Uint32 *values = (Uint32 *)propdata; printf("{"); for (i = 0; i < items_read; i++) { printf(" %d", values[i]); } printf(" }\n"); - } else if (real_type == XA_CARDINAL) { - if (real_format == 32) { - Uint32 *values = (Uint32 *)propdata; - - printf("{"); - for (i = 0; i < items_read; i++) { - printf(" %d", values[i]); - } - printf(" }\n"); - } else if (real_format == 16) { - Uint16 *values = (Uint16 *)propdata; - - printf("{"); - for (i = 0; i < items_read; i++) { - printf(" %d", values[i]); - } - printf(" }\n"); - } else if (real_format == 8) { - Uint8 *values = (Uint8 *)propdata; - - printf("{"); - for (i = 0; i < items_read; i++) { - printf(" %d", values[i]); - } - printf(" }\n"); - } - } else if (real_type == XA_STRING || - real_type == videodata->UTF8_STRING) { - printf("{ \"%s\" }\n", propdata); - } else if (real_type == XA_ATOM) { - Atom *atoms = (Atom *)propdata; + } else if (real_format == 16) { + Uint16 *values = (Uint16 *)propdata; printf("{"); for (i = 0; i < items_read; i++) { - char *atomname = X11_XGetAtomName(display, atoms[i]); - if (atomname) { - printf(" %s", atomname); - X11_XFree(atomname); - } + printf(" %d", values[i]); } printf(" }\n"); - } else { - char *atomname = X11_XGetAtomName(display, real_type); - printf("Unknown type: %ld (%s)\n", real_type, atomname ? atomname : "UNKNOWN"); + } else if (real_format == 8) { + Uint8 *values = (Uint8 *)propdata; + + printf("{"); + for (i = 0; i < items_read; i++) { + printf(" %d", values[i]); + } + printf(" }\n"); + } + } else if (real_type == XA_STRING || + real_type == videodata->UTF8_STRING) { + printf("{ \"%s\" }\n", propdata); + } else if (real_type == XA_ATOM) { + Atom *atoms = (Atom *)propdata; + + printf("{"); + for (i = 0; i < items_read; i++) { + char *atomname = X11_XGetAtomName(display, atoms[i]); if (atomname) { + printf(" %s", atomname); X11_XFree(atomname); } } + printf(" }\n"); + } else { + char *atomname = X11_XGetAtomName(display, real_type); + printf("Unknown type: %ld (%s)\n", real_type, atomname ? atomname : "UNKNOWN"); + if (atomname) { + X11_XFree(atomname); + } } - if (status == Success) { - X11_XFree(propdata); - } + } + if (status == Success) { + X11_XFree(propdata); + } #endif /* DEBUG_XEVENTS */ - /* Take advantage of this moment to make sure user_time has a - valid timestamp from the X server, so if we later try to - raise/restore this window, _NET_ACTIVE_WINDOW can have a - non-zero timestamp, even if there's never been a mouse or - key press to this window so far. Note that we don't try to - set _NET_WM_USER_TIME here, though. That's only for legit - user interaction with the window. */ - if (!data->user_time) { - data->user_time = xevent->xproperty.time; + /* Take advantage of this moment to make sure user_time has a + valid timestamp from the X server, so if we later try to + raise/restore this window, _NET_ACTIVE_WINDOW can have a + non-zero timestamp, even if there's never been a mouse or + key press to this window so far. Note that we don't try to + set _NET_WM_USER_TIME here, though. That's only for legit + user interaction with the window. */ + if (!data->user_time) { + data->user_time = xevent->xproperty.time; + } + + if (xevent->xproperty.atom == data->videodata->_NET_WM_STATE) { + /* Get the new state from the window manager. + Compositing window managers can alter visibility of windows + without ever mapping / unmapping them, so we handle that here, + because they use the NETWM protocol to notify us of changes. + */ + const Uint32 flags = X11_GetNetWMState(_this, data->window, xevent->xproperty.window); + const Uint32 changed = flags ^ data->window->flags; + + if ((changed & SDL_WINDOW_HIDDEN) || (changed & SDL_WINDOW_FULLSCREEN)) { + if (flags & SDL_WINDOW_HIDDEN) { + X11_DispatchUnmapNotify(data); + } else { + X11_DispatchMapNotify(data); + } } - if (xevent->xproperty.atom == data->videodata->_NET_WM_STATE) { - /* Get the new state from the window manager. - Compositing window managers can alter visibility of windows - without ever mapping / unmapping them, so we handle that here, - because they use the NETWM protocol to notify us of changes. - */ - const Uint32 flags = X11_GetNetWMState(_this, data->window, xevent->xproperty.window); - const Uint32 changed = flags ^ data->window->flags; - - if ((changed & SDL_WINDOW_HIDDEN) || (changed & SDL_WINDOW_FULLSCREEN)) { - if (flags & SDL_WINDOW_HIDDEN) { - X11_DispatchUnmapNotify(data); - } else { - X11_DispatchMapNotify(data); - } + if (changed & SDL_WINDOW_MAXIMIZED) { + if (flags & SDL_WINDOW_MAXIMIZED) { + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MAXIMIZED, 0, 0); + } else { + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESTORED, 0, 0); } - - if (changed & SDL_WINDOW_MAXIMIZED) { - if (flags & SDL_WINDOW_MAXIMIZED) { - SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MAXIMIZED, 0, 0); - } else { - SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESTORED, 0, 0); - } + } + } else if (xevent->xproperty.atom == videodata->XKLAVIER_STATE) { + /* Hack for Ubuntu 12.04 (etc) that doesn't send MappingNotify + events when the keyboard layout changes (for example, + changing from English to French on the menubar's keyboard + icon). Since it changes the XKLAVIER_STATE property, we + notice and reinit our keymap here. This might not be the + right approach, but it seems to work. */ + X11_UpdateKeymap(_this, SDL_TRUE); + } else if (xevent->xproperty.atom == videodata->_NET_FRAME_EXTENTS) { + Atom type; + int format; + unsigned long nitems, bytes_after; + unsigned char *property; + if (X11_XGetWindowProperty(display, data->xwindow, videodata->_NET_FRAME_EXTENTS, 0, 16, 0, XA_CARDINAL, &type, &format, &nitems, &bytes_after, &property) == Success) { + if (type != None && nitems == 4) { + data->border_left = (int)((long *)property)[0]; + data->border_right = (int)((long *)property)[1]; + data->border_top = (int)((long *)property)[2]; + data->border_bottom = (int)((long *)property)[3]; } - } else if (xevent->xproperty.atom == videodata->XKLAVIER_STATE) { - /* Hack for Ubuntu 12.04 (etc) that doesn't send MappingNotify - events when the keyboard layout changes (for example, - changing from English to French on the menubar's keyboard - icon). Since it changes the XKLAVIER_STATE property, we - notice and reinit our keymap here. This might not be the - right approach, but it seems to work. */ - X11_UpdateKeymap(_this, SDL_TRUE); - } else if (xevent->xproperty.atom == videodata->_NET_FRAME_EXTENTS) { - Atom type; - int format; - unsigned long nitems, bytes_after; - unsigned char *property; - if (X11_XGetWindowProperty(display, data->xwindow, videodata->_NET_FRAME_EXTENTS, 0, 16, 0, XA_CARDINAL, &type, &format, &nitems, &bytes_after, &property) == Success) { - if (type != None && nitems == 4) { - data->border_left = (int) ((long*)property)[0]; - data->border_right = (int) ((long*)property)[1]; - data->border_top = (int) ((long*)property)[2]; - data->border_bottom = (int) ((long*)property)[3]; - } - X11_XFree(property); + X11_XFree(property); - #ifdef DEBUG_XEVENTS - printf("New _NET_FRAME_EXTENTS: left=%d right=%d, top=%d, bottom=%d\n", data->border_left, data->border_right, data->border_top, data->border_bottom); - #endif - } +#ifdef DEBUG_XEVENTS + printf("New _NET_FRAME_EXTENTS: left=%d right=%d, top=%d, bottom=%d\n", data->border_left, data->border_right, data->border_top, data->border_bottom); +#endif } } - break; + } break; - case SelectionNotify: { - Atom target = xevent->xselection.target; + case SelectionNotify: + { + Atom target = xevent->xselection.target; #ifdef DEBUG_XEVENTS - printf("window %p: SelectionNotify (requestor = %ld, target = %ld)\n", data, - xevent->xselection.requestor, xevent->xselection.target); + printf("window %p: SelectionNotify (requestor = %ld, target = %ld)\n", data, + xevent->xselection.requestor, xevent->xselection.target); #endif - if (target == data->xdnd_req) { - /* read data */ - SDL_x11Prop p; - X11_ReadProperty(&p, display, data->xwindow, videodata->PRIMARY); + if (target == data->xdnd_req) { + /* read data */ + SDL_x11Prop p; + X11_ReadProperty(&p, display, data->xwindow, videodata->PRIMARY); - if (p.format == 8) { - char *saveptr = NULL; - char *name = X11_XGetAtomName(display, target); - if (name) { - char *token = SDL_strtokr((char *) p.data, "\r\n", &saveptr); - while (token != NULL) { - if (SDL_strcmp("text/plain", name) == 0) { - SDL_SendDropText(data->window, token); - } else if (SDL_strcmp("text/uri-list", name) == 0) { - char *fn = X11_URIToLocal(token); - if (fn) { - SDL_SendDropFile(data->window, fn); - } + if (p.format == 8) { + char *saveptr = NULL; + char *name = X11_XGetAtomName(display, target); + if (name) { + char *token = SDL_strtokr((char *)p.data, "\r\n", &saveptr); + while (token != NULL) { + if (SDL_strcmp("text/plain", name) == 0) { + SDL_SendDropText(data->window, token); + } else if (SDL_strcmp("text/uri-list", name) == 0) { + char *fn = X11_URIToLocal(token); + if (fn) { + SDL_SendDropFile(data->window, fn); } - token = SDL_strtokr(NULL, "\r\n", &saveptr); } - X11_XFree(name); + token = SDL_strtokr(NULL, "\r\n", &saveptr); } - SDL_SendDropComplete(data->window); + X11_XFree(name); } - X11_XFree(p.data); - - /* send reply */ - SDL_memset(&m, 0, sizeof(XClientMessageEvent)); - m.type = ClientMessage; - m.display = display; - m.window = data->xdnd_source; - m.message_type = videodata->XdndFinished; - m.format = 32; - m.data.l[0] = data->xwindow; - m.data.l[1] = 1; - m.data.l[2] = videodata->XdndActionCopy; - X11_XSendEvent(display, data->xdnd_source, False, NoEventMask, (XEvent*)&m); - - X11_XSync(display, False); + SDL_SendDropComplete(data->window); } - } - break; + X11_XFree(p.data); - default:{ -#ifdef DEBUG_XEVENTS - printf("window %p: Unhandled event %d\n", data, xevent->type); -#endif + /* send reply */ + SDL_memset(&m, 0, sizeof(XClientMessageEvent)); + m.type = ClientMessage; + m.display = display; + m.window = data->xdnd_source; + m.message_type = videodata->XdndFinished; + m.format = 32; + m.data.l[0] = data->xwindow; + m.data.l[1] = 1; + m.data.l[2] = videodata->XdndActionCopy; + X11_XSendEvent(display, data->xdnd_source, False, NoEventMask, (XEvent *)&m); + + X11_XSync(display, False); } - break; + } break; + + default: + { +#ifdef DEBUG_XEVENTS + printf("window %p: Unhandled event %d\n", data, xevent->type); +#endif + } break; } } -static void -X11_HandleFocusChanges(_THIS) +static void X11_HandleFocusChanges(_THIS) { - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; int i; if (videodata && videodata->windowlist) { @@ -1599,14 +1592,12 @@ X11_HandleFocusChanges(_THIS) } } -static Bool -isAnyEvent(Display *display, XEvent *ev, XPointer arg) +static Bool isAnyEvent(Display *display, XEvent *ev, XPointer arg) { return True; } -static SDL_bool -X11_PollEvent(Display *display, XEvent *event) +static SDL_bool X11_PollEvent(Display *display, XEvent *event) { if (!X11_XCheckIfEvent(display, event, isAnyEvent, NULL)) { return SDL_FALSE; @@ -1615,12 +1606,11 @@ X11_PollEvent(Display *display, XEvent *event) return SDL_TRUE; } -void -X11_SendWakeupEvent(_THIS, SDL_Window *window) +void X11_SendWakeupEvent(_THIS, SDL_Window *window) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; Display *req_display = data->request_display; - Window xwindow = ((SDL_WindowData *) window->driverdata)->xwindow; + Window xwindow = ((SDL_WindowData *)window->driverdata)->xwindow; XClientMessageEvent event; SDL_memset(&event, 0, sizeof(XClientMessageEvent)); @@ -1630,16 +1620,15 @@ X11_SendWakeupEvent(_THIS, SDL_Window *window) event.message_type = data->_SDL_WAKEUP; event.format = 8; - X11_XSendEvent(req_display, xwindow, False, NoEventMask, (XEvent *) &event); + X11_XSendEvent(req_display, xwindow, False, NoEventMask, (XEvent *)&event); /* XSendEvent returns a status and it could be BadValue or BadWindow. If an error happens it is an SDL's internal error and there is nothing we can do here. */ X11_XFlush(req_display); } -int -X11_WaitEventTimeout(_THIS, int timeout) +int X11_WaitEventTimeout(_THIS, int timeout) { - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; Display *display; XEvent xevent; display = videodata->display; @@ -1687,16 +1676,15 @@ X11_WaitEventTimeout(_THIS, int timeout) return 1; } -void -X11_PumpEvents(_THIS) +void X11_PumpEvents(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; XEvent xevent; int i; if (data->last_mode_change_deadline) { if (SDL_TICKS_PASSED(SDL_GetTicks(), data->last_mode_change_deadline)) { - data->last_mode_change_deadline = 0; /* assume we're done. */ + data->last_mode_change_deadline = 0; /* assume we're done. */ } } @@ -1741,12 +1729,10 @@ X11_PumpEvents(_THIS) } } - -void -X11_SuspendScreenSaver(_THIS) +void X11_SuspendScreenSaver(_THIS) { #if SDL_VIDEO_DRIVER_X11_XSCRNSAVER - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; int dummy; int major_version, minor_version; #endif /* SDL_VIDEO_DRIVER_X11_XSCRNSAVER */ @@ -1766,7 +1752,7 @@ X11_SuspendScreenSaver(_THIS) /* X11_XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */ if (!X11_XScreenSaverQueryExtension(data->display, &dummy, &dummy) || !X11_XScreenSaverQueryVersion(data->display, - &major_version, &minor_version) || + &major_version, &minor_version) || major_version < 1 || (major_version == 1 && minor_version < 1)) { return; } diff --git a/src/video/x11/SDL_x11events.h b/src/video/x11/SDL_x11events.h index de89110d0..b5d5370df 100644 --- a/src/video/x11/SDL_x11events.h +++ b/src/video/x11/SDL_x11events.h @@ -24,7 +24,7 @@ #define SDL_x11events_h_ extern void X11_PumpEvents(_THIS); -extern int X11_WaitEventTimeout(_THIS, int timeout); +extern int X11_WaitEventTimeout(_THIS, int timeout); extern void X11_SendWakeupEvent(_THIS, SDL_Window *window); extern void X11_SuspendScreenSaver(_THIS); extern void X11_ReconcileKeyboardState(_THIS); diff --git a/src/video/x11/SDL_x11framebuffer.c b/src/video/x11/SDL_x11framebuffer.c index b98d27e93..e6e05f644 100644 --- a/src/video/x11/SDL_x11framebuffer.c +++ b/src/video/x11/SDL_x11framebuffer.c @@ -25,7 +25,6 @@ #include "SDL_x11video.h" #include "SDL_x11framebuffer.h" - #ifndef NO_SHARED_MEMORY /* Shared memory error handler routine */ @@ -33,10 +32,10 @@ static int shm_error; static int (*X_handler)(Display *, XErrorEvent *) = NULL; static int shm_errhandler(Display *d, XErrorEvent *e) { - if ( e->error_code == BadAccess ) { - shm_error = True; - return 0; - } else + if (e->error_code == BadAccess) { + shm_error = True; + return 0; + } else return X_handler(d, e); } @@ -48,11 +47,10 @@ static SDL_bool have_mitshm(Display *dpy) #endif /* !NO_SHARED_MEMORY */ -int -X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, - void ** pixels, int *pitch) +int X11_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, + void **pixels, int *pitch) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; XGCValues gcv; XVisualInfo vinfo; @@ -85,11 +83,11 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, if (have_mitshm(display)) { XShmSegmentInfo *shminfo = &data->shminfo; - shminfo->shmid = shmget(IPC_PRIVATE, window->h*(*pitch), IPC_CREAT | 0777); - if ( shminfo->shmid >= 0 ) { + shminfo->shmid = shmget(IPC_PRIVATE, window->h * (*pitch), IPC_CREAT | 0777); + if (shminfo->shmid >= 0) { shminfo->shmaddr = (char *)shmat(shminfo->shmid, 0, 0); shminfo->readOnly = False; - if ( shminfo->shmaddr != (char *)-1 ) { + if (shminfo->shmaddr != (char *)-1) { shm_error = False; X_handler = X11_XSetErrorHandler(shm_errhandler); X11_XShmAttach(display, shminfo); @@ -107,9 +105,9 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, } if (!shm_error) { data->ximage = X11_XShmCreateImage(display, data->visual, - vinfo.depth, ZPixmap, - shminfo->shmaddr, shminfo, - window->w, window->h); + vinfo.depth, ZPixmap, + shminfo->shmaddr, shminfo, + window->w, window->h); if (!data->ximage) { X11_XShmDetach(display, shminfo); X11_XSync(display, False); @@ -125,14 +123,14 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, } #endif /* not NO_SHARED_MEMORY */ - *pixels = SDL_malloc(window->h*(*pitch)); + *pixels = SDL_malloc(window->h * (*pitch)); if (*pixels == NULL) { return SDL_OutOfMemory(); } data->ximage = X11_XCreateImage(display, data->visual, - vinfo.depth, ZPixmap, 0, (char *)(*pixels), - window->w, window->h, 32, 0); + vinfo.depth, ZPixmap, 0, (char *)(*pixels), + window->w, window->h, 32, 0); if (!data->ximage) { SDL_free(*pixels); return SDL_SetError("Couldn't create XImage"); @@ -141,14 +139,13 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, return 0; } -int -X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, - int numrects) +int X11_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, + int numrects) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; int i; - int x, y, w ,h; + int x, y, w, h; #ifndef NO_SHARED_MEMORY if (data->use_mitshm) { for (i = 0; i < numrects; ++i) { @@ -177,7 +174,7 @@ X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, } X11_XShmPutImage(display, data->xwindow, data->gc, data->ximage, - x, y, x, y, w, h, False); + x, y, x, y, w, h, False); } } else #endif /* !NO_SHARED_MEMORY */ @@ -208,7 +205,7 @@ X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, } X11_XPutImage(display, data->xwindow, data->gc, data->ximage, - x, y, x, y, w, h); + x, y, x, y, w, h); } } @@ -217,10 +214,9 @@ X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, return 0; } -void -X11_DestroyWindowFramebuffer(_THIS, SDL_Window * window) +void X11_DestroyWindowFramebuffer(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display; if (data == NULL) { diff --git a/src/video/x11/SDL_x11framebuffer.h b/src/video/x11/SDL_x11framebuffer.h index 63e73604a..f9feed0d0 100644 --- a/src/video/x11/SDL_x11framebuffer.h +++ b/src/video/x11/SDL_x11framebuffer.h @@ -24,13 +24,12 @@ #include "../../SDL_internal.h" - -extern int X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, - Uint32 * format, - void ** pixels, int *pitch); -extern int X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window, - const SDL_Rect * rects, int numrects); -extern void X11_DestroyWindowFramebuffer(_THIS, SDL_Window * window); +extern int X11_CreateWindowFramebuffer(_THIS, SDL_Window *window, + Uint32 *format, + void **pixels, int *pitch); +extern int X11_UpdateWindowFramebuffer(_THIS, SDL_Window *window, + const SDL_Rect *rects, int numrects); +extern void X11_DestroyWindowFramebuffer(_THIS, SDL_Window *window); #endif /* SDL_x11framebuffer_h_ */ diff --git a/src/video/x11/SDL_x11keyboard.c b/src/video/x11/SDL_x11keyboard.c index edc0147e5..25dadff12 100644 --- a/src/video/x11/SDL_x11keyboard.c +++ b/src/video/x11/SDL_x11keyboard.c @@ -47,8 +47,7 @@ static SDL_ScancodeTable scancode_set[] = { }; /* This function only correctly maps letters and numbers for keyboards in US QWERTY layout */ -static SDL_Scancode -X11_KeyCodeToSDLScancode(_THIS, KeyCode keycode) +static SDL_Scancode X11_KeyCodeToSDLScancode(_THIS, KeyCode keycode) { const KeySym keysym = X11_KeyCodeToSym(_this, keycode, 0); @@ -59,8 +58,7 @@ X11_KeyCodeToSDLScancode(_THIS, KeyCode keycode) return SDL_GetScancodeFromKeySym(keysym, keycode); } -static Uint32 -X11_KeyCodeToUcs4(_THIS, KeyCode keycode, unsigned char group) +static Uint32 X11_KeyCodeToUcs4(_THIS, KeyCode keycode, unsigned char group) { KeySym keysym = X11_KeyCodeToSym(_this, keycode, group); @@ -74,18 +72,18 @@ X11_KeyCodeToUcs4(_THIS, KeyCode keycode, unsigned char group) KeySym X11_KeyCodeToSym(_THIS, KeyCode keycode, unsigned char group) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; KeySym keysym; #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM if (data->xkb) { - int num_groups = XkbKeyNumGroups(data->xkb, keycode); + int num_groups = XkbKeyNumGroups(data->xkb, keycode); unsigned char info = XkbKeyGroupInfo(data->xkb, keycode); - + if (num_groups && group >= num_groups) { - + int action = XkbOutOfRangeGroupAction(info); - + if (action == XkbRedirectIntoRange) { if ((group = XkbOutOfRangeGroupNumber(info)) >= num_groups) { group = 0; @@ -107,14 +105,14 @@ X11_KeyCodeToSym(_THIS, KeyCode keycode, unsigned char group) return keysym; } -int -X11_InitKeyboard(_THIS) +int X11_InitKeyboard(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; int i = 0; int j = 0; int min_keycode, max_keycode; - struct { + struct + { SDL_Scancode scancode; KeySym keysym; int value; @@ -144,14 +142,14 @@ X11_InitKeyboard(_THIS) X11_XkbSetDetectableAutoRepeat(data->display, True, &xkb_repeat); } #endif - + /* Open a connection to the X input manager */ #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { - /* Set the locale, and call XSetLocaleModifiers before XOpenIM so that + /* Set the locale, and call XSetLocaleModifiers before XOpenIM so that Compose keys will work correctly. */ char *prev_locale = setlocale(LC_ALL, NULL); - char *prev_xmods = X11_XSetLocaleModifiers(NULL); + char *prev_xmods = X11_XSetLocaleModifiers(NULL); const char *new_xmods = ""; const char *env_xmods = SDL_getenv("XMODIFIERS"); SDL_bool has_dbus_ime_support = SDL_FALSE; @@ -166,7 +164,7 @@ X11_InitKeyboard(_THIS) /* IBus resends some key events that were filtered by XFilterEvents when it is used via XIM which causes issues. Prevent this by forcing - @im=none if XMODIFIERS contains @im=ibus. IBus can still be used via + @im=none if XMODIFIERS contains @im=ibus. IBus can still be used via the DBus implementation, which also has support for pre-editing. */ if (env_xmods && SDL_strstr(env_xmods, "@im=ibus") != NULL) { has_dbus_ime_support = SDL_TRUE; @@ -261,7 +259,7 @@ X11_InitKeyboard(_THIS) KeySym sym; sym = X11_KeyCodeToSym(_this, (KeyCode)i, 0); SDL_Log("code = %d, sym = 0x%X (%s) ", i - min_keycode, - (unsigned int)sym, sym == NoSymbol ? "NoSymbol" : X11_XKeysymToString(sym)); + (unsigned int)sym, sym == NoSymbol ? "NoSymbol" : X11_XKeysymToString(sym)); } #endif if (scancode == data->key_layout[i]) { @@ -288,7 +286,7 @@ X11_InitKeyboard(_THIS) KeySym sym; sym = X11_KeyCodeToSym(_this, (KeyCode)i, 0); SDL_Log("code = %d, sym = 0x%X (%s) ", i - min_keycode, - (unsigned int)sym, sym == NoSymbol ? "NoSymbol" : X11_XKeysymToString(sym)); + (unsigned int)sym, sym == NoSymbol ? "NoSymbol" : X11_XKeysymToString(sym)); } if (scancode == SDL_SCANCODE_UNKNOWN) { SDL_Log("scancode not found\n"); @@ -313,10 +311,9 @@ X11_InitKeyboard(_THIS) return 0; } -void -X11_UpdateKeymap(_THIS, SDL_bool send_event) +void X11_UpdateKeymap(_THIS, SDL_bool send_event) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; int i; SDL_Scancode scancode; SDL_Keycode keymap[SDL_NUM_SCANCODES]; @@ -335,7 +332,6 @@ X11_UpdateKeymap(_THIS, SDL_bool send_event) } #endif - for (i = 0; i < SDL_arraysize(data->key_layout); i++) { Uint32 key; @@ -353,34 +349,33 @@ X11_UpdateKeymap(_THIS, SDL_bool send_event) SDL_Scancode keyScancode = X11_KeyCodeToSDLScancode(_this, (KeyCode)i); switch (keyScancode) { - case SDL_SCANCODE_RETURN: - keymap[scancode] = SDLK_RETURN; - break; - case SDL_SCANCODE_ESCAPE: - keymap[scancode] = SDLK_ESCAPE; - break; - case SDL_SCANCODE_BACKSPACE: - keymap[scancode] = SDLK_BACKSPACE; - break; - case SDL_SCANCODE_TAB: - keymap[scancode] = SDLK_TAB; - break; - case SDL_SCANCODE_DELETE: - keymap[scancode] = SDLK_DELETE; - break; - default: - keymap[scancode] = SDL_SCANCODE_TO_KEYCODE(keyScancode); - break; + case SDL_SCANCODE_RETURN: + keymap[scancode] = SDLK_RETURN; + break; + case SDL_SCANCODE_ESCAPE: + keymap[scancode] = SDLK_ESCAPE; + break; + case SDL_SCANCODE_BACKSPACE: + keymap[scancode] = SDLK_BACKSPACE; + break; + case SDL_SCANCODE_TAB: + keymap[scancode] = SDLK_TAB; + break; + case SDL_SCANCODE_DELETE: + keymap[scancode] = SDLK_DELETE; + break; + default: + keymap[scancode] = SDL_SCANCODE_TO_KEYCODE(keyScancode); + break; } } } SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES, send_event); } -void -X11_QuitKeyboard(_THIS) +void X11_QuitKeyboard(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM if (data->xkb) { @@ -394,11 +389,10 @@ X11_QuitKeyboard(_THIS) #endif } -static void -X11_ResetXIM(_THIS) +static void X11_ResetXIM(_THIS) { #ifdef X_HAVE_UTF8_STRING - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; int i; if (videodata && videodata->windowlist) { @@ -416,14 +410,12 @@ X11_ResetXIM(_THIS) #endif } -void -X11_StartTextInput(_THIS) +void X11_StartTextInput(_THIS) { X11_ResetXIM(_this); } -void -X11_StopTextInput(_THIS) +void X11_StopTextInput(_THIS) { X11_ResetXIM(_this); #ifdef SDL_USE_IME @@ -431,14 +423,13 @@ X11_StopTextInput(_THIS) #endif } -void -X11_SetTextInputRect(_THIS, const SDL_Rect *rect) +void X11_SetTextInputRect(_THIS, const SDL_Rect *rect) { if (rect == NULL) { SDL_InvalidParamError("rect"); return; } - + #ifdef SDL_USE_IME SDL_IME_UpdateTextRect(rect); #endif @@ -447,14 +438,13 @@ X11_SetTextInputRect(_THIS, const SDL_Rect *rect) SDL_bool X11_HasScreenKeyboardSupport(_THIS) { - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; return videodata->is_steam_deck; } -void -X11_ShowScreenKeyboard(_THIS, SDL_Window *window) +void X11_ShowScreenKeyboard(_THIS, SDL_Window *window) { - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; if (videodata->is_steam_deck) { /* For more documentation of the URL parameters, see: @@ -469,10 +459,9 @@ X11_ShowScreenKeyboard(_THIS, SDL_Window *window) } } -void -X11_HideScreenKeyboard(_THIS, SDL_Window *window) +void X11_HideScreenKeyboard(_THIS, SDL_Window *window) { - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; if (videodata->is_steam_deck) { SDL_OpenURL("steam://close/keyboard"); @@ -483,7 +472,7 @@ X11_HideScreenKeyboard(_THIS, SDL_Window *window) SDL_bool X11_IsScreenKeyboardShown(_THIS, SDL_Window *window) { - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; return videodata->steam_keyboard_open; } diff --git a/src/video/x11/SDL_x11messagebox.c b/src/video/x11/SDL_x11messagebox.c index f7e917059..649bb7cbe 100644 --- a/src/video/x11/SDL_x11messagebox.c +++ b/src/video/x11/SDL_x11messagebox.c @@ -31,7 +31,6 @@ #include #include - #define SDL_FORK_MESSAGEBOX 1 #define SDL_SET_LOCALE 1 @@ -42,40 +41,42 @@ #include #endif -#define MAX_BUTTONS 8 /* Maximum number of buttons supported */ -#define MIN_BUTTON_WIDTH 64 /* Minimum button width */ -#define MIN_DIALOG_WIDTH 200 /* Minimum dialog width */ -#define MIN_DIALOG_HEIGHT 100 /* Minimum dialog height */ +#define MAX_BUTTONS 8 /* Maximum number of buttons supported */ +#define MIN_BUTTON_WIDTH 64 /* Minimum button width */ +#define MIN_DIALOG_WIDTH 200 /* Minimum dialog width */ +#define MIN_DIALOG_HEIGHT 100 /* Minimum dialog height */ static const char g_MessageBoxFontLatin1[] = "-*-*-medium-r-normal--0-120-*-*-p-0-iso8859-1"; static const char g_MessageBoxFont[] = "-*-*-medium-r-normal--*-120-*-*-*-*-*-*"; -static const SDL_MessageBoxColor g_default_colors[ SDL_MESSAGEBOX_COLOR_MAX ] = { - { 56, 54, 53 }, /* SDL_MESSAGEBOX_COLOR_BACKGROUND, */ +static const SDL_MessageBoxColor g_default_colors[SDL_MESSAGEBOX_COLOR_MAX] = { + { 56, 54, 53 }, /* SDL_MESSAGEBOX_COLOR_BACKGROUND, */ { 209, 207, 205 }, /* SDL_MESSAGEBOX_COLOR_TEXT, */ { 140, 135, 129 }, /* SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, */ - { 105, 102, 99 }, /* SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, */ - { 205, 202, 53 }, /* SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, */ + { 105, 102, 99 }, /* SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, */ + { 205, 202, 53 }, /* SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, */ }; -#define SDL_MAKE_RGB( _r, _g, _b ) ( ( ( Uint32 )( _r ) << 16 ) | \ - ( ( Uint32 )( _g ) << 8 ) | \ - ( ( Uint32 )( _b ) ) ) +#define SDL_MAKE_RGB(_r, _g, _b) (((Uint32)(_r) << 16) | \ + ((Uint32)(_g) << 8) | \ + ((Uint32)(_b))) -typedef struct SDL_MessageBoxButtonDataX11 { - int x, y; /* Text position */ - int length; /* Text length */ - int text_width; /* Text width */ +typedef struct SDL_MessageBoxButtonDataX11 +{ + int x, y; /* Text position */ + int length; /* Text length */ + int text_width; /* Text width */ - SDL_Rect rect; /* Rectangle for entire button */ + SDL_Rect rect; /* Rectangle for entire button */ - const SDL_MessageBoxButtonData *buttondata; /* Button data from caller */ + const SDL_MessageBoxButtonData *buttondata; /* Button data from caller */ } SDL_MessageBoxButtonDataX11; -typedef struct TextLineData { - int width; /* Width of this text line */ - int length; /* String length of this text line */ - const char *text; /* Text for this line */ +typedef struct TextLineData +{ + int width; /* Width of this text line */ + int length; /* String length of this text line */ + const char *text; /* Text for this line */ } TextLineData; typedef struct SDL_MessageBoxDataX11 @@ -85,46 +86,44 @@ typedef struct SDL_MessageBoxDataX11 Window window; #if SDL_VIDEO_DRIVER_X11_XDBE XdbeBackBuffer buf; - SDL_bool xdbe; /* Whether Xdbe is present or not */ + SDL_bool xdbe; /* Whether Xdbe is present or not */ #endif long event_mask; Atom wm_protocols; Atom wm_delete_message; - int dialog_width; /* Dialog box width. */ - int dialog_height; /* Dialog box height. */ + int dialog_width; /* Dialog box width. */ + int dialog_height; /* Dialog box height. */ - XFontSet font_set; /* for UTF-8 systems */ - XFontStruct *font_struct; /* Latin1 (ASCII) fallback. */ - int xtext, ytext; /* Text position to start drawing at. */ - int numlines; /* Count of Text lines. */ - int text_height; /* Height for text lines. */ + XFontSet font_set; /* for UTF-8 systems */ + XFontStruct *font_struct; /* Latin1 (ASCII) fallback. */ + int xtext, ytext; /* Text position to start drawing at. */ + int numlines; /* Count of Text lines. */ + int text_height; /* Height for text lines. */ TextLineData *linedata; - int *pbuttonid; /* Pointer to user return buttonid value. */ + int *pbuttonid; /* Pointer to user return buttonid value. */ - int button_press_index; /* Index into buttondata/buttonpos for button which is pressed (or -1). */ - int mouse_over_index; /* Index into buttondata/buttonpos for button mouse is over (or -1). */ + int button_press_index; /* Index into buttondata/buttonpos for button which is pressed (or -1). */ + int mouse_over_index; /* Index into buttondata/buttonpos for button mouse is over (or -1). */ - int numbuttons; /* Count of buttons. */ + int numbuttons; /* Count of buttons. */ const SDL_MessageBoxButtonData *buttondata; - SDL_MessageBoxButtonDataX11 buttonpos[ MAX_BUTTONS ]; + SDL_MessageBoxButtonDataX11 buttonpos[MAX_BUTTONS]; - Uint32 color[ SDL_MESSAGEBOX_COLOR_MAX ]; + Uint32 color[SDL_MESSAGEBOX_COLOR_MAX]; const SDL_MessageBoxData *messageboxdata; } SDL_MessageBoxDataX11; /* Maximum helper for ints. */ -static SDL_INLINE int -IntMax( int a, int b ) +static SDL_INLINE int IntMax(int a, int b) { - return ( a > b ) ? a : b; + return (a > b) ? a : b; } /* Return width and height for a string. */ -static void -GetTextWidthHeight( SDL_MessageBoxDataX11 *data, const char *str, int nbytes, int *pwidth, int *pheight ) +static void GetTextWidthHeight(SDL_MessageBoxDataX11 *data, const char *str, int nbytes, int *pwidth, int *pheight) { if (SDL_X11_HAVE_UTF8) { XRectangle overall_ink, overall_logical; @@ -134,29 +133,28 @@ GetTextWidthHeight( SDL_MessageBoxDataX11 *data, const char *str, int nbytes, in } else { XCharStruct text_structure; int font_direction, font_ascent, font_descent; - X11_XTextExtents( data->font_struct, str, nbytes, - &font_direction, &font_ascent, &font_descent, - &text_structure ); + X11_XTextExtents(data->font_struct, str, nbytes, + &font_direction, &font_ascent, &font_descent, + &text_structure); *pwidth = text_structure.width; *pheight = text_structure.ascent + text_structure.descent; } } /* Return index of button if position x,y is contained therein. */ -static int -GetHitButtonIndex( SDL_MessageBoxDataX11 *data, int x, int y ) +static int GetHitButtonIndex(SDL_MessageBoxDataX11 *data, int x, int y) { int i; int numbuttons = data->numbuttons; SDL_MessageBoxButtonDataX11 *buttonpos = data->buttonpos; - for ( i = 0; i < numbuttons; i++ ) { - SDL_Rect *rect = &buttonpos[ i ].rect; + for (i = 0; i < numbuttons; i++) { + SDL_Rect *rect = &buttonpos[i].rect; - if ( ( x >= rect->x ) && - ( x <= ( rect->x + rect->w ) ) && - ( y >= rect->y ) && - ( y <= ( rect->y + rect->h ) ) ) { + if ((x >= rect->x) && + (x <= (rect->x + rect->w)) && + (y >= rect->y) && + (y <= (rect->y + rect->h))) { return i; } } @@ -165,15 +163,14 @@ GetHitButtonIndex( SDL_MessageBoxDataX11 *data, int x, int y ) } /* Initialize SDL_MessageBoxData structure and Display, etc. */ -static int -X11_MessageBoxInit( SDL_MessageBoxDataX11 *data, const SDL_MessageBoxData * messageboxdata, int * pbuttonid ) +static int X11_MessageBoxInit(SDL_MessageBoxDataX11 *data, const SDL_MessageBoxData *messageboxdata, int *pbuttonid) { int i; int numbuttons = messageboxdata->numbuttons; const SDL_MessageBoxButtonData *buttondata = messageboxdata->buttons; const SDL_MessageBoxColor *colorhints; - if ( numbuttons > MAX_BUTTONS ) { + if (numbuttons > MAX_BUTTONS) { return SDL_SetError("Too many buttons (%d max allowed)", MAX_BUTTONS); } @@ -184,8 +181,8 @@ X11_MessageBoxInit( SDL_MessageBoxDataX11 *data, const SDL_MessageBoxData * mess data->numbuttons = numbuttons; data->pbuttonid = pbuttonid; - data->display = X11_XOpenDisplay( NULL ); - if ( !data->display ) { + data->display = X11_XOpenDisplay(NULL); + if (!data->display) { return SDL_SetError("Couldn't open X11 display"); } @@ -193,49 +190,47 @@ X11_MessageBoxInit( SDL_MessageBoxDataX11 *data, const SDL_MessageBoxData * mess char **missing = NULL; int num_missing = 0; data->font_set = X11_XCreateFontSet(data->display, g_MessageBoxFont, - &missing, &num_missing, NULL); - if ( missing != NULL ) { + &missing, &num_missing, NULL); + if (missing != NULL) { X11_XFreeStringList(missing); } - if ( data->font_set == NULL ) { + if (data->font_set == NULL) { return SDL_SetError("Couldn't load font %s", g_MessageBoxFont); } } else { - data->font_struct = X11_XLoadQueryFont( data->display, g_MessageBoxFontLatin1 ); - if ( data->font_struct == NULL ) { + data->font_struct = X11_XLoadQueryFont(data->display, g_MessageBoxFontLatin1); + if (data->font_struct == NULL) { return SDL_SetError("Couldn't load font %s", g_MessageBoxFontLatin1); } } - if ( messageboxdata->colorScheme ) { + if (messageboxdata->colorScheme) { colorhints = messageboxdata->colorScheme->colors; } else { colorhints = g_default_colors; } /* Convert our SDL_MessageBoxColor r,g,b values to packed RGB format. */ - for ( i = 0; i < SDL_MESSAGEBOX_COLOR_MAX; i++ ) { - data->color[ i ] = SDL_MAKE_RGB( colorhints[ i ].r, colorhints[ i ].g, colorhints[ i ].b ); + for (i = 0; i < SDL_MESSAGEBOX_COLOR_MAX; i++) { + data->color[i] = SDL_MAKE_RGB(colorhints[i].r, colorhints[i].g, colorhints[i].b); } return 0; } -static int -CountLinesOfText(const char *text) +static int CountLinesOfText(const char *text) { int retval = 0; while (text && *text) { const char *lf = SDL_strchr(text, '\n'); - retval++; /* even without an endline, this counts as a line. */ + retval++; /* even without an endline, this counts as a line. */ text = lf ? lf + 1 : NULL; } return retval; } /* Calculate and initialize text and button locations. */ -static int -X11_MessageBoxInitPositions( SDL_MessageBoxDataX11 *data ) +static int X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data) { int i; int ybuttons; @@ -245,10 +240,10 @@ X11_MessageBoxInitPositions( SDL_MessageBoxDataX11 *data ) const SDL_MessageBoxData *messageboxdata = data->messageboxdata; /* Go over text and break linefeeds into separate lines. */ - if ( messageboxdata->message[0] ) { + if (messageboxdata->message[0]) { const char *text = messageboxdata->message; const int linecount = CountLinesOfText(text); - TextLineData *plinedata = (TextLineData *) SDL_malloc(sizeof (TextLineData) * linecount); + TextLineData *plinedata = (TextLineData *)SDL_malloc(sizeof(TextLineData) * linecount); if (plinedata == NULL) { return SDL_OutOfMemory(); @@ -257,18 +252,18 @@ X11_MessageBoxInitPositions( SDL_MessageBoxDataX11 *data ) data->linedata = plinedata; data->numlines = linecount; - for ( i = 0; i < linecount; i++, plinedata++ ) { - const char *lf = SDL_strchr( text, '\n' ); - const int length = lf ? ( lf - text ) : SDL_strlen( text ); + for (i = 0; i < linecount; i++, plinedata++) { + const char *lf = SDL_strchr(text, '\n'); + const int length = lf ? (lf - text) : SDL_strlen(text); int height; plinedata->text = text; - GetTextWidthHeight( data, text, length, &plinedata->width, &height ); + GetTextWidthHeight(data, text, length, &plinedata->width, &height); /* Text and widths are the largest we've ever seen. */ - data->text_height = IntMax( data->text_height, height ); - text_width_max = IntMax( text_width_max, plinedata->width ); + data->text_height = IntMax(data->text_height, height); + text_width_max = IntMax(text_width_max, plinedata->width); plinedata->length = length; if (lf && (lf > text) && (lf[-1] == '\r')) { @@ -288,36 +283,36 @@ X11_MessageBoxInitPositions( SDL_MessageBoxDataX11 *data ) } /* Loop through all buttons and calculate the button widths and height. */ - for ( i = 0; i < data->numbuttons; i++ ) { + for (i = 0; i < data->numbuttons; i++) { int height; - data->buttonpos[ i ].buttondata = &data->buttondata[ i ]; - data->buttonpos[ i ].length = SDL_strlen( data->buttondata[ i ].text ); + data->buttonpos[i].buttondata = &data->buttondata[i]; + data->buttonpos[i].length = SDL_strlen(data->buttondata[i].text); - GetTextWidthHeight( data, data->buttondata[ i ].text, SDL_strlen( data->buttondata[ i ].text ), - &data->buttonpos[ i ].text_width, &height ); + GetTextWidthHeight(data, data->buttondata[i].text, SDL_strlen(data->buttondata[i].text), + &data->buttonpos[i].text_width, &height); - button_width = IntMax( button_width, data->buttonpos[ i ].text_width ); - button_text_height = IntMax( button_text_height, height ); + button_width = IntMax(button_width, data->buttonpos[i].text_width); + button_text_height = IntMax(button_text_height, height); } - if ( data->numlines ) { + if (data->numlines) { /* x,y for this line of text. */ data->xtext = data->text_height; data->ytext = data->text_height + data->text_height; /* Bump button y down to bottom of text. */ - ybuttons = 3 * data->ytext / 2 + ( data->numlines - 1 ) * data->text_height; + ybuttons = 3 * data->ytext / 2 + (data->numlines - 1) * data->text_height; /* Bump the dialog box width and height up if needed. */ - data->dialog_width = IntMax( data->dialog_width, 2 * data->xtext + text_width_max ); - data->dialog_height = IntMax( data->dialog_height, ybuttons ); + data->dialog_width = IntMax(data->dialog_width, 2 * data->xtext + text_width_max); + data->dialog_height = IntMax(data->dialog_height, ybuttons); } else { /* Button y starts at height of button text. */ ybuttons = button_text_height; } - if ( data->numbuttons ) { + if (data->numbuttons) { int x, y; int width_of_buttons; int button_spacing = button_text_height; @@ -327,33 +322,33 @@ X11_MessageBoxInitPositions( SDL_MessageBoxDataX11 *data ) button_width += button_text_height; /* Get width of all buttons lined up. */ - width_of_buttons = data->numbuttons * button_width + ( data->numbuttons - 1 ) * button_spacing; + width_of_buttons = data->numbuttons * button_width + (data->numbuttons - 1) * button_spacing; /* Bump up dialog width and height if buttons are wider than text. */ - data->dialog_width = IntMax( data->dialog_width, width_of_buttons + 2 * button_spacing ); - data->dialog_height = IntMax( data->dialog_height, ybuttons + 2 * button_height ); + data->dialog_width = IntMax(data->dialog_width, width_of_buttons + 2 * button_spacing); + data->dialog_height = IntMax(data->dialog_height, ybuttons + 2 * button_height); /* Location for first button. */ - if ( messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT ) { - x = data->dialog_width - ( data->dialog_width - width_of_buttons ) / 2 - ( button_width + button_spacing ); + if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT) { + x = data->dialog_width - (data->dialog_width - width_of_buttons) / 2 - (button_width + button_spacing); } else { - x = ( data->dialog_width - width_of_buttons ) / 2; + x = (data->dialog_width - width_of_buttons) / 2; } - y = ybuttons + ( data->dialog_height - ybuttons - button_height ) / 2; + y = ybuttons + (data->dialog_height - ybuttons - button_height) / 2; - for ( i = 0; i < data->numbuttons; i++ ) { + for (i = 0; i < data->numbuttons; i++) { /* Button coordinates. */ - data->buttonpos[ i ].rect.x = x; - data->buttonpos[ i ].rect.y = y; - data->buttonpos[ i ].rect.w = button_width; - data->buttonpos[ i ].rect.h = button_height; + data->buttonpos[i].rect.x = x; + data->buttonpos[i].rect.y = y; + data->buttonpos[i].rect.w = button_width; + data->buttonpos[i].rect.h = button_height; /* Button text coordinates. */ - data->buttonpos[ i ].x = x + ( button_width - data->buttonpos[ i ].text_width ) / 2; - data->buttonpos[ i ].y = y + ( button_height - button_text_height - 1 ) / 2 + button_text_height; + data->buttonpos[i].x = x + (button_width - data->buttonpos[i].text_width) / 2; + data->buttonpos[i].y = y + (button_height - button_text_height - 1) / 2 + button_text_height; /* Scoot over for next button. */ - if ( messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT ) { + if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT) { x -= button_width + button_spacing; } else { x += button_width + button_spacing; @@ -365,33 +360,32 @@ X11_MessageBoxInitPositions( SDL_MessageBoxDataX11 *data ) } /* Free SDL_MessageBoxData data. */ -static void -X11_MessageBoxShutdown( SDL_MessageBoxDataX11 *data ) +static void X11_MessageBoxShutdown(SDL_MessageBoxDataX11 *data) { - if ( data->font_set != NULL ) { - X11_XFreeFontSet( data->display, data->font_set ); + if (data->font_set != NULL) { + X11_XFreeFontSet(data->display, data->font_set); data->font_set = NULL; } - if ( data->font_struct != NULL ) { - X11_XFreeFont( data->display, data->font_struct ); + if (data->font_struct != NULL) { + X11_XFreeFont(data->display, data->font_struct); data->font_struct = NULL; } #if SDL_VIDEO_DRIVER_X11_XDBE - if ( SDL_X11_HAVE_XDBE && data->xdbe ) { + if (SDL_X11_HAVE_XDBE && data->xdbe) { X11_XdbeDeallocateBackBufferName(data->display, data->buf); } #endif - if ( data->display ) { - if ( data->window != None ) { - X11_XWithdrawWindow( data->display, data->window, data->screen ); - X11_XDestroyWindow( data->display, data->window ); + if (data->display) { + if (data->window != None) { + X11_XWithdrawWindow(data->display, data->window, data->screen); + X11_XDestroyWindow(data->display, data->window); data->window = None; } - X11_XCloseDisplay( data->display ); + X11_XCloseDisplay(data->display); data->display = NULL; } @@ -399,8 +393,7 @@ X11_MessageBoxShutdown( SDL_MessageBoxDataX11 *data ) } /* Create and set up our X11 dialog box indow. */ -static int -X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data ) +static int X11_MessageBoxCreateWindow(SDL_MessageBoxDataX11 *data) { int x, y; XSizeHints *sizehints; @@ -410,13 +403,13 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data ) SDL_WindowData *windowdata = NULL; const SDL_MessageBoxData *messageboxdata = data->messageboxdata; - if ( messageboxdata->window ) { + if (messageboxdata->window) { SDL_DisplayData *displaydata = - (SDL_DisplayData *) SDL_GetDisplayForWindow(messageboxdata->window)->driverdata; + (SDL_DisplayData *)SDL_GetDisplayForWindow(messageboxdata->window)->driverdata; windowdata = (SDL_WindowData *)messageboxdata->window->driverdata; data->screen = displaydata->screen; } else { - data->screen = DefaultScreen( display ); + data->screen = DefaultScreen(display); } data->event_mask = ExposureMask | @@ -425,16 +418,16 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data ) wnd_attr.event_mask = data->event_mask; data->window = X11_XCreateWindow( - display, RootWindow(display, data->screen), - 0, 0, - data->dialog_width, data->dialog_height, - 0, CopyFromParent, InputOutput, CopyFromParent, - CWEventMask, &wnd_attr ); - if ( data->window == None ) { + display, RootWindow(display, data->screen), + 0, 0, + data->dialog_width, data->dialog_height, + 0, CopyFromParent, InputOutput, CopyFromParent, + CWEventMask, &wnd_attr); + if (data->window == None) { return SDL_SetError("Couldn't create X window"); } - if ( windowdata ) { + if (windowdata) { Atom _NET_WM_STATE = X11_XInternAtom(display, "_NET_WM_STATE", False); Atom stateatoms[16]; size_t statecount = 0; @@ -449,47 +442,47 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data ) PropModeReplace, (unsigned char *)stateatoms, statecount); /* http://tronche.com/gui/x/icccm/sec-4.html#WM_TRANSIENT_FOR */ - X11_XSetTransientForHint( display, data->window, windowdata->xwindow ); + X11_XSetTransientForHint(display, data->window, windowdata->xwindow); } - SDL_X11_SetWindowTitle(display, data->window, (char*)messageboxdata->title); + SDL_X11_SetWindowTitle(display, data->window, (char *)messageboxdata->title); /* Let the window manager know this is a dialog box */ _NET_WM_WINDOW_TYPE = X11_XInternAtom(display, "_NET_WM_WINDOW_TYPE", False); _NET_WM_WINDOW_TYPE_DIALOG = X11_XInternAtom(display, "_NET_WM_WINDOW_TYPE_DIALOG", False); X11_XChangeProperty(display, data->window, _NET_WM_WINDOW_TYPE, XA_ATOM, 32, - PropModeReplace, - (unsigned char *)&_NET_WM_WINDOW_TYPE_DIALOG, 1); + PropModeReplace, + (unsigned char *)&_NET_WM_WINDOW_TYPE_DIALOG, 1); /* Allow the window to be deleted by the window manager */ - data->wm_protocols = X11_XInternAtom( display, "WM_PROTOCOLS", False ); - data->wm_delete_message = X11_XInternAtom( display, "WM_DELETE_WINDOW", False ); - X11_XSetWMProtocols( display, data->window, &data->wm_delete_message, 1 ); + data->wm_protocols = X11_XInternAtom(display, "WM_PROTOCOLS", False); + data->wm_delete_message = X11_XInternAtom(display, "WM_DELETE_WINDOW", False); + X11_XSetWMProtocols(display, data->window, &data->wm_delete_message, 1); - if ( windowdata ) { + if (windowdata) { XWindowAttributes attrib; Window dummy; X11_XGetWindowAttributes(display, windowdata->xwindow, &attrib); - x = attrib.x + ( attrib.width - data->dialog_width ) / 2; - y = attrib.y + ( attrib.height - data->dialog_height ) / 3 ; + x = attrib.x + (attrib.width - data->dialog_width) / 2; + y = attrib.y + (attrib.height - data->dialog_height) / 3; X11_XTranslateCoordinates(display, windowdata->xwindow, RootWindow(display, data->screen), x, y, &x, &y, &dummy); } else { const SDL_VideoDevice *dev = SDL_GetVideoDevice(); if ((dev) && (dev->displays) && (dev->num_displays > 0)) { const SDL_VideoDisplay *dpy = &dev->displays[0]; - const SDL_DisplayData *dpydata = (SDL_DisplayData *) dpy->driverdata; - x = dpydata->x + (( dpy->current_mode.w - data->dialog_width ) / 2); - y = dpydata->y + (( dpy->current_mode.h - data->dialog_height ) / 3); - } else { /* oh well. This will misposition on a multi-head setup. Init first next time. */ - x = ( DisplayWidth( display, data->screen ) - data->dialog_width ) / 2; - y = ( DisplayHeight( display, data->screen ) - data->dialog_height ) / 3 ; + const SDL_DisplayData *dpydata = (SDL_DisplayData *)dpy->driverdata; + x = dpydata->x + ((dpy->current_mode.w - data->dialog_width) / 2); + y = dpydata->y + ((dpy->current_mode.h - data->dialog_height) / 3); + } else { /* oh well. This will misposition on a multi-head setup. Init first next time. */ + x = (DisplayWidth(display, data->screen) - data->dialog_width) / 2; + y = (DisplayHeight(display, data->screen) - data->dialog_height) / 3; } } - X11_XMoveWindow( display, data->window, x, y ); + X11_XMoveWindow(display, data->window, x, y); sizehints = X11_XAllocSizeHints(); - if ( sizehints ) { + if (sizehints) { sizehints->flags = USPosition | USSize | PMaxSize | PMinSize; sizehints->x = x; sizehints->y = y; @@ -499,12 +492,12 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data ) sizehints->min_width = sizehints->max_width = data->dialog_width; sizehints->min_height = sizehints->max_height = data->dialog_height; - X11_XSetWMNormalHints( display, data->window, sizehints ); + X11_XSetWMNormalHints(display, data->window, sizehints); - X11_XFree( sizehints ); + X11_XFree(sizehints); } - X11_XMapRaised( display, data->window ); + X11_XMapRaised(display, data->window); #if SDL_VIDEO_DRIVER_X11_XDBE /* Initialise a back buffer for double buffering */ @@ -523,8 +516,7 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data ) } /* Draw our message box. */ -static void -X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx ) +static void X11_MessageBoxDraw(SDL_MessageBoxDataX11 *data, GC ctx) { int i; Drawable window = data->window; @@ -537,53 +529,51 @@ X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx ) } #endif - X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ] ); - X11_XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height ); + X11_XSetForeground(display, ctx, data->color[SDL_MESSAGEBOX_COLOR_BACKGROUND]); + X11_XFillRectangle(display, window, ctx, 0, 0, data->dialog_width, data->dialog_height); - X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] ); - for ( i = 0; i < data->numlines; i++ ) { - TextLineData *plinedata = &data->linedata[ i ]; + X11_XSetForeground(display, ctx, data->color[SDL_MESSAGEBOX_COLOR_TEXT]); + for (i = 0; i < data->numlines; i++) { + TextLineData *plinedata = &data->linedata[i]; if (SDL_X11_HAVE_UTF8) { - X11_Xutf8DrawString( display, window, data->font_set, ctx, - data->xtext, data->ytext + i * data->text_height, - plinedata->text, plinedata->length ); + X11_Xutf8DrawString(display, window, data->font_set, ctx, + data->xtext, data->ytext + i * data->text_height, + plinedata->text, plinedata->length); } else { - X11_XDrawString( display, window, ctx, - data->xtext, data->ytext + i * data->text_height, - plinedata->text, plinedata->length ); + X11_XDrawString(display, window, ctx, + data->xtext, data->ytext + i * data->text_height, + plinedata->text, plinedata->length); } } - for ( i = 0; i < data->numbuttons; i++ ) { - SDL_MessageBoxButtonDataX11 *buttondatax11 = &data->buttonpos[ i ]; + for (i = 0; i < data->numbuttons; i++) { + SDL_MessageBoxButtonDataX11 *buttondatax11 = &data->buttonpos[i]; const SDL_MessageBoxButtonData *buttondata = buttondatax11->buttondata; - int border = ( buttondata->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT ) ? 2 : 0; - int offset = ( ( data->mouse_over_index == i ) && ( data->button_press_index == data->mouse_over_index ) ) ? 1 : 0; + int border = (buttondata->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) ? 2 : 0; + int offset = ((data->mouse_over_index == i) && (data->button_press_index == data->mouse_over_index)) ? 1 : 0; - X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND ] ); - X11_XFillRectangle( display, window, ctx, - buttondatax11->rect.x - border, buttondatax11->rect.y - border, - buttondatax11->rect.w + 2 * border, buttondatax11->rect.h + 2 * border ); + X11_XSetForeground(display, ctx, data->color[SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND]); + X11_XFillRectangle(display, window, ctx, + buttondatax11->rect.x - border, buttondatax11->rect.y - border, + buttondatax11->rect.w + 2 * border, buttondatax11->rect.h + 2 * border); - X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BORDER ] ); - X11_XDrawRectangle( display, window, ctx, - buttondatax11->rect.x, buttondatax11->rect.y, - buttondatax11->rect.w, buttondatax11->rect.h ); + X11_XSetForeground(display, ctx, data->color[SDL_MESSAGEBOX_COLOR_BUTTON_BORDER]); + X11_XDrawRectangle(display, window, ctx, + buttondatax11->rect.x, buttondatax11->rect.y, + buttondatax11->rect.w, buttondatax11->rect.h); - X11_XSetForeground( display, ctx, ( data->mouse_over_index == i ) ? - data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED ] : - data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] ); + X11_XSetForeground(display, ctx, (data->mouse_over_index == i) ? data->color[SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED] : data->color[SDL_MESSAGEBOX_COLOR_TEXT]); if (SDL_X11_HAVE_UTF8) { - X11_Xutf8DrawString( display, window, data->font_set, ctx, - buttondatax11->x + offset, - buttondatax11->y + offset, - buttondata->text, buttondatax11->length ); + X11_Xutf8DrawString(display, window, data->font_set, ctx, + buttondatax11->x + offset, + buttondatax11->y + offset, + buttondata->text, buttondatax11->length); } else { - X11_XDrawString( display, window, ctx, - buttondatax11->x + offset, buttondatax11->y + offset, - buttondata->text, buttondatax11->length ); + X11_XDrawString(display, window, ctx, + buttondatax11->x + offset, buttondatax11->y + offset, + buttondata->text, buttondatax11->length); } } @@ -598,16 +588,14 @@ X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx ) #endif } -static Bool -X11_MessageBoxEventTest(Display *display, XEvent *event, XPointer arg) +static Bool X11_MessageBoxEventTest(Display *display, XEvent *event, XPointer arg) { - const SDL_MessageBoxDataX11 *data = (const SDL_MessageBoxDataX11 *) arg; + const SDL_MessageBoxDataX11 *data = (const SDL_MessageBoxDataX11 *)arg; return ((event->xany.display == data->display) && (event->xany.window == data->window)) ? True : False; } /* Loop and handle message box event messages until something kills it. */ -static int -X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) +static int X11_MessageBoxLoop(SDL_MessageBoxDataX11 *data) { GC ctx; XGCValues ctx_vals; @@ -617,29 +605,29 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) unsigned long gcflags = GCForeground | GCBackground; SDL_zero(ctx_vals); - ctx_vals.foreground = data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ]; - ctx_vals.background = data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ]; + ctx_vals.foreground = data->color[SDL_MESSAGEBOX_COLOR_BACKGROUND]; + ctx_vals.background = data->color[SDL_MESSAGEBOX_COLOR_BACKGROUND]; if (!SDL_X11_HAVE_UTF8) { gcflags |= GCFont; ctx_vals.font = data->font_struct->fid; } - ctx = X11_XCreateGC( data->display, data->window, gcflags, &ctx_vals ); - if ( ctx == None ) { + ctx = X11_XCreateGC(data->display, data->window, gcflags, &ctx_vals); + if (ctx == None) { return SDL_SetError("Couldn't create graphics context"); } - data->button_press_index = -1; /* Reset what button is currently depressed. */ - data->mouse_over_index = -1; /* Reset what button the mouse is over. */ + data->button_press_index = -1; /* Reset what button is currently depressed. */ + data->mouse_over_index = -1; /* Reset what button the mouse is over. */ - while ( !close_dialog ) { + while (!close_dialog) { XEvent e; SDL_bool draw = SDL_TRUE; /* can't use XWindowEvent() because it can't handle ClientMessage events. */ /* can't use XNextEvent() because we only want events for this window. */ - X11_XIfEvent( data->display, &e, X11_MessageBoxEventTest, (XPointer) data ); + X11_XIfEvent(data->display, &e, X11_MessageBoxEventTest, (XPointer)data); /* If X11_XFilterEvent returns True, then some input method has filtered the event, and the client should discard the event. */ @@ -647,9 +635,9 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) continue; } - switch( e.type ) { + switch (e.type) { case Expose: - if ( e.xexpose.count > 0 ) { + if (e.xexpose.count > 0) { draw = SDL_FALSE; } break; @@ -667,10 +655,10 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) break; case MotionNotify: - if ( has_focus ) { + if (has_focus) { /* Mouse moved... */ const int previndex = data->mouse_over_index; - data->mouse_over_index = GetHitButtonIndex( data, e.xbutton.x, e.xbutton.y ); + data->mouse_over_index = GetHitButtonIndex(data, e.xbutton.x, e.xbutton.y); if (data->mouse_over_index == previndex) { draw = SDL_FALSE; } @@ -678,41 +666,42 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) break; case ClientMessage: - if ( e.xclient.message_type == data->wm_protocols && - e.xclient.format == 32 && - e.xclient.data.l[ 0 ] == data->wm_delete_message ) { + if (e.xclient.message_type == data->wm_protocols && + e.xclient.format == 32 && + e.xclient.data.l[0] == data->wm_delete_message) { close_dialog = SDL_TRUE; } break; case KeyPress: /* Store key press - we make sure in key release that we got both. */ - last_key_pressed = X11_XLookupKeysym( &e.xkey, 0 ); + last_key_pressed = X11_XLookupKeysym(&e.xkey, 0); break; - case KeyRelease: { + case KeyRelease: + { Uint32 mask = 0; - KeySym key = X11_XLookupKeysym( &e.xkey, 0 ); + KeySym key = X11_XLookupKeysym(&e.xkey, 0); /* If this is a key release for something we didn't get the key down for, then bail. */ if (key != last_key_pressed) { break; } - if ( key == XK_Escape ) { + if (key == XK_Escape) { mask = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT; } else if ((key == XK_Return) || (key == XK_KP_Enter)) { mask = SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT; } - if ( mask ) { + if (mask) { int i; /* Look for first button with this mask set, and return it if found. */ - for ( i = 0; i < data->numbuttons; i++ ) { - SDL_MessageBoxButtonDataX11 *buttondatax11 = &data->buttonpos[ i ]; + for (i = 0; i < data->numbuttons; i++) { + SDL_MessageBoxButtonDataX11 *buttondatax11 = &data->buttonpos[i]; - if ( buttondatax11->buttondata->flags & mask ) { + if (buttondatax11->buttondata->flags & mask) { *data->pbuttonid = buttondatax11->buttondata->buttonid; close_dialog = SDL_TRUE; break; @@ -724,19 +713,19 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) case ButtonPress: data->button_press_index = -1; - if ( e.xbutton.button == Button1 ) { + if (e.xbutton.button == Button1) { /* Find index of button they clicked on. */ - data->button_press_index = GetHitButtonIndex( data, e.xbutton.x, e.xbutton.y ); + data->button_press_index = GetHitButtonIndex(data, e.xbutton.x, e.xbutton.y); } break; case ButtonRelease: /* If button is released over the same button that was clicked down on, then return it. */ - if ( ( e.xbutton.button == Button1 ) && ( data->button_press_index >= 0 ) ) { - int button = GetHitButtonIndex( data, e.xbutton.x, e.xbutton.y ); + if ((e.xbutton.button == Button1) && (data->button_press_index >= 0)) { + int button = GetHitButtonIndex(data, e.xbutton.x, e.xbutton.y); - if ( data->button_press_index == button ) { - SDL_MessageBoxButtonDataX11 *buttondatax11 = &data->buttonpos[ button ]; + if (data->button_press_index == button) { + SDL_MessageBoxButtonDataX11 *buttondatax11 = &data->buttonpos[button]; *data->pbuttonid = buttondatax11->buttondata->buttonid; close_dialog = SDL_TRUE; @@ -746,18 +735,17 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) break; } - if ( draw ) { + if (draw) { /* Draw our dialog box. */ - X11_MessageBoxDraw( data, ctx ); + X11_MessageBoxDraw(data, ctx); } } - X11_XFreeGC( data->display, ctx ); + X11_XFreeGC(data->display, ctx); return 0; } -static int -X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid) +static int X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid) { int ret; SDL_MessageBoxDataX11 data; @@ -789,18 +777,18 @@ X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid) *buttonid = -1; /* Init and display the message box. */ - ret = X11_MessageBoxInit( &data, messageboxdata, buttonid ); - if ( ret != -1 ) { - ret = X11_MessageBoxInitPositions( &data ); - if ( ret != -1 ) { - ret = X11_MessageBoxCreateWindow( &data ); - if ( ret != -1 ) { - ret = X11_MessageBoxLoop( &data ); + ret = X11_MessageBoxInit(&data, messageboxdata, buttonid); + if (ret != -1) { + ret = X11_MessageBoxInitPositions(&data); + if (ret != -1) { + ret = X11_MessageBoxCreateWindow(&data); + if (ret != -1) { + ret = X11_MessageBoxLoop(&data); } } } - X11_MessageBoxShutdown( &data ); + X11_MessageBoxShutdown(&data); #if SDL_SET_LOCALE if (origlocale) { @@ -813,8 +801,7 @@ X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid) } /* Display an x11 message box. */ -int -X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) +int X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { #if SDL_FORK_MESSAGEBOX /* Use a child process to protect against setlocale(). Annoying. */ @@ -827,34 +814,34 @@ X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) } pid = fork(); - if (pid == -1) { /* failed */ + if (pid == -1) { /* failed */ close(fds[0]); close(fds[1]); return X11_ShowMessageBoxImpl(messageboxdata, buttonid); /* oh well. */ - } else if (pid == 0) { /* we're the child */ + } else if (pid == 0) { /* we're the child */ int exitcode = 0; close(fds[0]); status = X11_ShowMessageBoxImpl(messageboxdata, buttonid); - if (write(fds[1], &status, sizeof (int)) != sizeof (int)) { + if (write(fds[1], &status, sizeof(int)) != sizeof(int)) { exitcode = 1; - } else if (write(fds[1], buttonid, sizeof (int)) != sizeof (int)) { + } else if (write(fds[1], buttonid, sizeof(int)) != sizeof(int)) { exitcode = 1; } close(fds[1]); - _exit(exitcode); /* don't run atexit() stuff, static destructors, etc. */ - } else { /* we're the parent */ + _exit(exitcode); /* don't run atexit() stuff, static destructors, etc. */ + } else { /* we're the parent */ pid_t rc; close(fds[1]); do { rc = waitpid(pid, &status, 0); } while ((rc == -1) && (errno == EINTR)); - SDL_assert(rc == pid); /* not sure what to do if this fails. */ + SDL_assert(rc == pid); /* not sure what to do if this fails. */ if ((rc == -1) || (!WIFEXITED(status)) || (WEXITSTATUS(status) != 0)) { status = SDL_SetError("msgbox child process failed"); - } else if ( (read(fds[0], &status, sizeof (int)) != sizeof (int)) || - (read(fds[0], buttonid, sizeof (int)) != sizeof (int)) ) { + } else if ((read(fds[0], &status, sizeof(int)) != sizeof(int)) || + (read(fds[0], buttonid, sizeof(int)) != sizeof(int))) { status = SDL_SetError("read from msgbox child process failed"); *buttonid = 0; } diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index ce7c21897..36fa07ff9 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -38,12 +38,10 @@ * fullscreen state hint but be decorated and windowed. * * However, many people swear by it, so let them swear at it. :) -*/ + */ /* #define XRANDR_DISABLED_BY_DEFAULT */ - -static int -get_visualinfo(Display * display, int screen, XVisualInfo * vinfo) +static int get_visualinfo(Display *display, int screen, XVisualInfo *vinfo) { const char *visual_id = SDL_getenv("SDL_VIDEO_X11_VISUALID"); int depth; @@ -74,8 +72,7 @@ get_visualinfo(Display * display, int screen, XVisualInfo * vinfo) return -1; } -int -X11_GetVisualInfoFromVisual(Display * display, Visual * visual, XVisualInfo * vinfo) +int X11_GetVisualInfoFromVisual(Display *display, Visual *visual, XVisualInfo *vinfo) { XVisualInfo *vi; int nvis; @@ -91,7 +88,7 @@ X11_GetVisualInfoFromVisual(Display * display, Visual * visual, XVisualInfo * vi } Uint32 -X11_GetPixelFormatFromVisualInfo(Display * display, XVisualInfo * vinfo) +X11_GetPixelFormatFromVisualInfo(Display *display, XVisualInfo *vinfo) { if (vinfo->class == DirectColor || vinfo->class == TrueColor) { int bpp; @@ -149,8 +146,7 @@ X11_GetPixelFormatFromVisualInfo(Display * display, XVisualInfo * vinfo) } #if SDL_VIDEO_DRIVER_X11_XRANDR -static SDL_bool -CheckXRandR(Display * display, int *major, int *minor) +static SDL_bool CheckXRandR(Display *display, int *major, int *minor) { /* Default the extension not available */ *major = *minor = 0; @@ -180,7 +176,8 @@ CheckXRandR(Display * display, int *major, int *minor) } /* Query the extension version */ - *major = 1; *minor = 3; /* we want 1.3 */ + *major = 1; + *minor = 3; /* we want 1.3 */ if (!X11_XRRQueryVersion(display, major, minor)) { #ifdef X11MODES_DEBUG printf("XRandR not active on the display\n"); @@ -194,19 +191,16 @@ CheckXRandR(Display * display, int *major, int *minor) return SDL_TRUE; } -#define XRANDR_ROTATION_LEFT (1 << 1) -#define XRANDR_ROTATION_RIGHT (1 << 3) +#define XRANDR_ROTATION_LEFT (1 << 1) +#define XRANDR_ROTATION_RIGHT (1 << 3) -static int -CalculateXRandRRefreshRate(const XRRModeInfo *info) +static int CalculateXRandRRefreshRate(const XRRModeInfo *info) { - return (info->hTotal && info->vTotal) ? - SDL_round(((double)info->dotClock / (double)(info->hTotal * info->vTotal))) : 0; + return (info->hTotal && info->vTotal) ? SDL_round(((double)info->dotClock / (double)(info->hTotal * info->vTotal))) : 0; } -static SDL_bool -SetXRandRModeInfo(Display *display, XRRScreenResources *res, RRCrtc crtc, - RRMode modeID, SDL_DisplayMode *mode) +static SDL_bool SetXRandRModeInfo(Display *display, XRRScreenResources *res, RRCrtc crtc, + RRMode modeID, SDL_DisplayMode *mode) { int i; for (i = 0; i < res->nmode; ++i) { @@ -221,7 +215,7 @@ SetXRandRModeInfo(Display *display, XRRScreenResources *res, RRCrtc crtc, X11_XRRFreeCrtcInfo(crtcinfo); } - if (rotation & (XRANDR_ROTATION_LEFT|XRANDR_ROTATION_RIGHT)) { + if (rotation & (XRANDR_ROTATION_LEFT | XRANDR_ROTATION_RIGHT)) { mode->w = info->height; mode->h = info->width; } else { @@ -229,9 +223,9 @@ SetXRandRModeInfo(Display *display, XRRScreenResources *res, RRCrtc crtc, mode->h = info->height; } mode->refresh_rate = CalculateXRandRRefreshRate(info); - ((SDL_DisplayModeData*)mode->driverdata)->xrandr_mode = modeID; + ((SDL_DisplayModeData *)mode->driverdata)->xrandr_mode = modeID; #ifdef X11MODES_DEBUG - printf("XRandR mode %d: %dx%d@%dHz\n", (int) modeID, mode->w, mode->h, mode->refresh_rate); + printf("XRandR mode %d: %dx%d@%dHz\n", (int)modeID, mode->w, mode->h, mode->refresh_rate); #endif return SDL_TRUE; } @@ -239,8 +233,7 @@ SetXRandRModeInfo(Display *display, XRRScreenResources *res, RRCrtc crtc, return SDL_FALSE; } -static void -SetXRandRDisplayName(Display *dpy, Atom EDID, char *name, const size_t namelen, RROutput output, const unsigned long widthmm, const unsigned long heightmm) +static void SetXRandRDisplayName(Display *dpy, Atom EDID, char *name, const size_t namelen, RROutput output, const unsigned long widthmm, const unsigned long heightmm) { /* See if we can get the EDID data for the real monitor name */ int inches; @@ -281,7 +274,7 @@ SetXRandRDisplayName(Display *dpy, Atom EDID, char *name, const size_t namelen, inches = (int)((SDL_sqrtf(widthmm * widthmm + heightmm * heightmm) / 25.4f) + 0.5f); if (*name && inches) { const size_t len = SDL_strlen(name); - SDL_snprintf(&name[len], namelen-len, " %d\"", inches); + SDL_snprintf(&name[len], namelen - len, " %d\"", inches); } #ifdef X11MODES_DEBUG @@ -289,9 +282,7 @@ SetXRandRDisplayName(Display *dpy, Atom EDID, char *name, const size_t namelen, #endif } - -static int -X11_AddXRandRDisplay(_THIS, Display *dpy, int screen, RROutput outputid, XRRScreenResources *res, SDL_bool send_event) +static int X11_AddXRandRDisplay(_THIS, Display *dpy, int screen, RROutput outputid, XRRScreenResources *res, SDL_bool send_event) { Atom EDID = X11_XInternAtom(dpy, "EDID", False); XRROutputInfo *output_info; @@ -312,12 +303,12 @@ X11_AddXRandRDisplay(_THIS, Display *dpy, int screen, RROutput outputid, XRRScre int i, n; if (get_visualinfo(dpy, screen, &vinfo) < 0) { - return 0; /* uh, skip this screen? */ + return 0; /* uh, skip this screen? */ } pixelformat = X11_GetPixelFormatFromVisualInfo(dpy, &vinfo); if (SDL_ISPIXELFORMAT_INDEXED(pixelformat)) { - return 0; /* Palettized video modes are no longer supported, ignore this one. */ + return 0; /* Palettized video modes are no longer supported, ignore this one. */ } scanline_pad = SDL_BYTESPERPIXEL(pixelformat) * 8; @@ -335,7 +326,7 @@ X11_AddXRandRDisplay(_THIS, Display *dpy, int screen, RROutput outputid, XRRScre output_info = X11_XRRGetOutputInfo(dpy, res, outputid); if (output_info == NULL || !output_info->crtc || output_info->connection == RR_Disconnected) { X11_XRRFreeOutputInfo(output_info); - return 0; /* ignore this one. */ + return 0; /* ignore this one. */ } SDL_strlcpy(display_name, output_info->name, sizeof(display_name)); @@ -346,7 +337,7 @@ X11_AddXRandRDisplay(_THIS, Display *dpy, int screen, RROutput outputid, XRRScre crtc = X11_XRRGetCrtcInfo(dpy, res, output_crtc); if (crtc == NULL) { - return 0; /* oh well, ignore it. */ + return 0; /* oh well, ignore it. */ } SDL_zero(mode); @@ -360,12 +351,12 @@ X11_AddXRandRDisplay(_THIS, Display *dpy, int screen, RROutput outputid, XRRScre X11_XRRFreeCrtcInfo(crtc); - displaydata = (SDL_DisplayData *) SDL_calloc(1, sizeof(*displaydata)); + displaydata = (SDL_DisplayData *)SDL_calloc(1, sizeof(*displaydata)); if (displaydata == NULL) { return SDL_OutOfMemory(); } - modedata = (SDL_DisplayModeData *) SDL_calloc(1, sizeof(SDL_DisplayModeData)); + modedata = (SDL_DisplayModeData *)SDL_calloc(1, sizeof(SDL_DisplayModeData)); if (modedata == NULL) { SDL_free(displaydata); return SDL_OutOfMemory(); @@ -377,9 +368,9 @@ X11_AddXRandRDisplay(_THIS, Display *dpy, int screen, RROutput outputid, XRRScre displaydata->screen = screen; displaydata->visual = vinfo.visual; displaydata->depth = vinfo.depth; - displaydata->hdpi = display_mm_width ? (((float) mode.w) * 25.4f / display_mm_width) : 0.0f; - displaydata->vdpi = display_mm_height ? (((float) mode.h) * 25.4f / display_mm_height) : 0.0f; - displaydata->ddpi = SDL_ComputeDiagonalDPI(mode.w, mode.h, ((float) display_mm_width) / 25.4f,((float) display_mm_height) / 25.4f); + displaydata->hdpi = display_mm_width ? (((float)mode.w) * 25.4f / display_mm_width) : 0.0f; + displaydata->vdpi = display_mm_height ? (((float)mode.h) * 25.4f / display_mm_height) : 0.0f; + displaydata->ddpi = SDL_ComputeDiagonalDPI(mode.w, mode.h, ((float)display_mm_width) / 25.4f, ((float)display_mm_height) / 25.4f); displaydata->scanline_pad = scanline_pad; displaydata->x = display_x; displaydata->y = display_y; @@ -387,7 +378,7 @@ X11_AddXRandRDisplay(_THIS, Display *dpy, int screen, RROutput outputid, XRRScre displaydata->xrandr_output = outputid; SetXRandRModeInfo(dpy, res, output_crtc, modeID, &mode); - SetXRandRDisplayName(dpy, EDID, display_name, sizeof (display_name), outputid, display_mm_width, display_mm_height); + SetXRandRDisplayName(dpy, EDID, display_name, sizeof(display_name), outputid, display_mm_width, display_mm_height); SDL_zero(display); if (*display_name) { @@ -399,21 +390,20 @@ X11_AddXRandRDisplay(_THIS, Display *dpy, int screen, RROutput outputid, XRRScre return SDL_AddVideoDisplay(&display, send_event); } -static void -X11_HandleXRandROutputChange(_THIS, const XRROutputChangeNotifyEvent *ev) +static void X11_HandleXRandROutputChange(_THIS, const XRROutputChangeNotifyEvent *ev) { const int num_displays = SDL_GetNumVideoDisplays(); SDL_VideoDisplay *display = NULL; int displayidx = -1; int i; - #if 0 +#if 0 printf("XRROutputChangeNotifyEvent! [output=%u, crtc=%u, mode=%u, rotation=%u, connection=%u]", (unsigned int) ev->output, (unsigned int) ev->crtc, (unsigned int) ev->mode, (unsigned int) ev->rotation, (unsigned int) ev->connection); - #endif +#endif for (i = 0; i < num_displays; i++) { SDL_VideoDisplay *thisdisplay = SDL_GetDisplay(i); - const SDL_DisplayData *displaydata = (const SDL_DisplayData *) thisdisplay->driverdata; + const SDL_DisplayData *displaydata = (const SDL_DisplayData *)thisdisplay->driverdata; if (displaydata->xrandr_output == ev->output) { display = thisdisplay; displayidx = i; @@ -423,11 +413,11 @@ X11_HandleXRandROutputChange(_THIS, const XRROutputChangeNotifyEvent *ev) SDL_assert((displayidx == -1) == (display == NULL)); - if (ev->connection == RR_Disconnected) { /* output is going away */ + if (ev->connection == RR_Disconnected) { /* output is going away */ if (display != NULL) { SDL_DelVideoDisplay(displayidx); } - } else if (ev->connection == RR_Connected) { /* output is coming online */ + } else if (ev->connection == RR_Connected) { /* output is coming online */ if (display != NULL) { /* !!! FIXME: update rotation or current mode of existing display? */ } else { @@ -452,26 +442,23 @@ X11_HandleXRandROutputChange(_THIS, const XRROutputChangeNotifyEvent *ev) } } -void -X11_HandleXRandREvent(_THIS, const XEvent *xevent) +void X11_HandleXRandREvent(_THIS, const XEvent *xevent) { - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; SDL_assert(xevent->type == (videodata->xrandr_event_base + RRNotify)); - switch (((const XRRNotifyEvent *) xevent)->subtype) { - case RRNotify_OutputChange: - X11_HandleXRandROutputChange(_this, (const XRROutputChangeNotifyEvent *) xevent); - break; - default: - break; + switch (((const XRRNotifyEvent *)xevent)->subtype) { + case RRNotify_OutputChange: + X11_HandleXRandROutputChange(_this, (const XRROutputChangeNotifyEvent *)xevent); + break; + default: + break; } } - -static int -X11_InitModes_XRandR(_THIS) +static int X11_InitModes_XRandR(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; Display *dpy = data->display; const int screencount = ScreenCount(dpy); const int default_screen = DefaultScreen(dpy); @@ -532,10 +519,9 @@ X11_InitModes_XRandR(_THIS) } #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ -static int -GetXftDPI(Display* dpy) +static int GetXftDPI(Display *dpy) { - char* xdefault_resource; + char *xdefault_resource; int xft_dpi, err; xdefault_resource = X11_XGetDefault(dpy, "Xft", "dpi"); @@ -562,7 +548,7 @@ GetXftDPI(Display* dpy) static int X11_InitModes_StdXlib(_THIS) { /* !!! FIXME: a lot of copy/paste from X11_InitModes_XRandR in this function. */ - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; Display *dpy = data->display; const int default_screen = DefaultScreen(dpy); Screen *screen = ScreenOfDisplay(dpy, default_screen); @@ -590,14 +576,14 @@ static int X11_InitModes_StdXlib(_THIS) mode.w = WidthOfScreen(screen); mode.h = HeightOfScreen(screen); mode.format = pixelformat; - mode.refresh_rate = 0; /* don't know it, sorry. */ + mode.refresh_rate = 0; /* don't know it, sorry. */ - displaydata = (SDL_DisplayData *) SDL_calloc(1, sizeof(*displaydata)); + displaydata = (SDL_DisplayData *)SDL_calloc(1, sizeof(*displaydata)); if (displaydata == NULL) { return SDL_OutOfMemory(); } - modedata = (SDL_DisplayModeData *) SDL_calloc(1, sizeof(SDL_DisplayModeData)); + modedata = (SDL_DisplayModeData *)SDL_calloc(1, sizeof(SDL_DisplayModeData)); if (modedata == NULL) { SDL_free(displaydata); return SDL_OutOfMemory(); @@ -610,9 +596,9 @@ static int X11_InitModes_StdXlib(_THIS) displaydata->screen = default_screen; displaydata->visual = vinfo.visual; displaydata->depth = vinfo.depth; - displaydata->hdpi = display_mm_width ? (((float) mode.w) * 25.4f / display_mm_width) : 0.0f; - displaydata->vdpi = display_mm_height ? (((float) mode.h) * 25.4f / display_mm_height) : 0.0f; - displaydata->ddpi = SDL_ComputeDiagonalDPI(mode.w, mode.h, ((float) display_mm_width) / 25.4f,((float) display_mm_height) / 25.4f); + displaydata->hdpi = display_mm_width ? (((float)mode.w) * 25.4f / display_mm_width) : 0.0f; + displaydata->vdpi = display_mm_height ? (((float)mode.h) * 25.4f / display_mm_height) : 0.0f; + displaydata->ddpi = SDL_ComputeDiagonalDPI(mode.w, mode.h, ((float)display_mm_width) / 25.4f, ((float)display_mm_height) / 25.4f); xft_dpi = GetXftDPI(dpy); if (xft_dpi > 0) { @@ -638,7 +624,7 @@ static int X11_InitModes_StdXlib(_THIS) displaydata->use_xrandr = SDL_FALSE; SDL_zero(display); - display.name = (char *) "Generic X11 Display"; /* this is just copied and thrown away, it's safe to cast to char* here. */ + display.name = (char *)"Generic X11 Display"; /* this is just copied and thrown away, it's safe to cast to char* here. */ display.desktop_mode = mode; display.current_mode = mode; display.driverdata = displaydata; @@ -647,16 +633,14 @@ static int X11_InitModes_StdXlib(_THIS) return 0; } - -int -X11_InitModes(_THIS) +int X11_InitModes(_THIS) { /* XRandR is the One True Modern Way to do this on X11. If this fails, we just won't report any display modes except the current desktop size. */ #if SDL_VIDEO_DRIVER_X11_XRANDR { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; int xrandr_major, xrandr_minor; /* require at least XRandR v1.3 */ if (CheckXRandR(data->display, &xrandr_major, &xrandr_minor) && @@ -670,10 +654,9 @@ X11_InitModes(_THIS) return X11_InitModes_StdXlib(_this); } -void -X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) +void X11_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display) { - SDL_DisplayData *data = (SDL_DisplayData *) sdl_display->driverdata; + SDL_DisplayData *data = (SDL_DisplayData *)sdl_display->driverdata; SDL_DisplayMode mode; /* Unfortunately X11 requires the window to be created with the correct @@ -687,10 +670,10 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) #if SDL_VIDEO_DRIVER_X11_XRANDR if (data->use_xrandr) { - Display *display = ((SDL_VideoData *) _this->driverdata)->display; + Display *display = ((SDL_VideoData *)_this->driverdata)->display; XRRScreenResources *res; - res = X11_XRRGetScreenResources (display, RootWindow(display, data->screen)); + res = X11_XRRGetScreenResources(display, RootWindow(display, data->screen)); if (res) { SDL_DisplayModeData *modedata; XRROutputInfo *output_info; @@ -699,7 +682,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) output_info = X11_XRRGetOutputInfo(display, res, data->xrandr_output); if (output_info && output_info->connection != RR_Disconnected) { for (i = 0; i < output_info->nmode; ++i) { - modedata = (SDL_DisplayModeData *) SDL_calloc(1, sizeof(SDL_DisplayModeData)); + modedata = (SDL_DisplayModeData *)SDL_calloc(1, sizeof(SDL_DisplayModeData)); if (modedata == NULL) { continue; } @@ -722,7 +705,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) SDL_DisplayModeData *modedata; /* Add the desktop mode */ mode = sdl_display->desktop_mode; - modedata = (SDL_DisplayModeData *) SDL_calloc(1, sizeof(SDL_DisplayModeData)); + modedata = (SDL_DisplayModeData *)SDL_calloc(1, sizeof(SDL_DisplayModeData)); if (modedata) { *modedata = *(SDL_DisplayModeData *)sdl_display->desktop_mode.driverdata; } @@ -737,8 +720,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) /* This catches an error from XRRSetScreenSize, as a workaround for now. */ /* !!! FIXME: remove this later when we have a better solution. */ static int (*PreXRRSetScreenSizeErrorHandler)(Display *, XErrorEvent *) = NULL; -static int -SDL_XRRSetScreenSizeErrHandler(Display *d, XErrorEvent *e) +static int SDL_XRRSetScreenSizeErrHandler(Display *d, XErrorEvent *e) { /* BadMatch: https://github.com/libsdl-org/SDL/issues/4561 */ /* BadValue: https://github.com/libsdl-org/SDL/issues/4840 */ @@ -750,11 +732,10 @@ SDL_XRRSetScreenSizeErrHandler(Display *d, XErrorEvent *e) } #endif -int -X11_SetDisplayMode(_THIS, SDL_VideoDisplay * sdl_display, SDL_DisplayMode * mode) +int X11_SetDisplayMode(_THIS, SDL_VideoDisplay *sdl_display, SDL_DisplayMode *mode) { - SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata; - SDL_DisplayData *data = (SDL_DisplayData *) sdl_display->driverdata; + SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata; + SDL_DisplayData *data = (SDL_DisplayData *)sdl_display->driverdata; viddata->last_mode_change_deadline = SDL_GetTicks() + (PENDING_FOCUS_TIME * 2); @@ -768,7 +749,7 @@ X11_SetDisplayMode(_THIS, SDL_VideoDisplay * sdl_display, SDL_DisplayMode * mode XRRCrtcInfo *crtc; Status status; - res = X11_XRRGetScreenResources (display, RootWindow(display, data->screen)); + res = X11_XRRGetScreenResources(display, RootWindow(display, data->screen)); if (res == NULL) { return SDL_SetError("Couldn't get XRandR screen resources"); } @@ -797,7 +778,7 @@ X11_SetDisplayMode(_THIS, SDL_VideoDisplay * sdl_display, SDL_DisplayMode * mode X11_XGrabServer(display); status = X11_XRRSetCrtcConfig(display, res, output_info->crtc, CurrentTime, - 0, 0, None, crtc->rotation, NULL, 0); + 0, 0, None, crtc->rotation, NULL, 0); if (status != Success) { goto ungrabServer; } @@ -818,13 +799,13 @@ X11_SetDisplayMode(_THIS, SDL_VideoDisplay * sdl_display, SDL_DisplayMode * mode X11_XSync(display, False); X11_XSetErrorHandler(PreXRRSetScreenSizeErrorHandler); - status = X11_XRRSetCrtcConfig (display, res, output_info->crtc, CurrentTime, - crtc->x, crtc->y, modedata->xrandr_mode, crtc->rotation, - &data->xrandr_output, 1); + status = X11_XRRSetCrtcConfig(display, res, output_info->crtc, CurrentTime, + crtc->x, crtc->y, modedata->xrandr_mode, crtc->rotation, + &data->xrandr_output, 1); -ungrabServer: + ungrabServer: X11_XUngrabServer(display); -freeInfo: + freeInfo: X11_XRRFreeCrtcInfo(crtc); X11_XRRFreeOutputInfo(output_info); X11_XRRFreeScreenResources(res); @@ -840,15 +821,13 @@ freeInfo: return 0; } -void -X11_QuitModes(_THIS) +void X11_QuitModes(_THIS) { } -int -X11_GetDisplayBounds(_THIS, SDL_VideoDisplay * sdl_display, SDL_Rect * rect) +int X11_GetDisplayBounds(_THIS, SDL_VideoDisplay *sdl_display, SDL_Rect *rect) { - SDL_DisplayData *data = (SDL_DisplayData *) sdl_display->driverdata; + SDL_DisplayData *data = (SDL_DisplayData *)sdl_display->driverdata; rect->x = data->x; rect->y = data->y; @@ -858,10 +837,9 @@ X11_GetDisplayBounds(_THIS, SDL_VideoDisplay * sdl_display, SDL_Rect * rect) return 0; } -int -X11_GetDisplayDPI(_THIS, SDL_VideoDisplay * sdl_display, float * ddpi, float * hdpi, float * vdpi) +int X11_GetDisplayDPI(_THIS, SDL_VideoDisplay *sdl_display, float *ddpi, float *hdpi, float *vdpi) { - SDL_DisplayData *data = (SDL_DisplayData *) sdl_display->driverdata; + SDL_DisplayData *data = (SDL_DisplayData *)sdl_display->driverdata; if (ddpi) { *ddpi = data->ddpi; @@ -876,10 +854,9 @@ X11_GetDisplayDPI(_THIS, SDL_VideoDisplay * sdl_display, float * ddpi, float * h return data->ddpi != 0.0f ? 0 : SDL_SetError("Couldn't get DPI"); } -int -X11_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * sdl_display, SDL_Rect * rect) +int X11_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *sdl_display, SDL_Rect *rect) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; Display *display = data->display; Atom _NET_WORKAREA; int status, real_format; @@ -898,7 +875,7 @@ X11_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * sdl_display, SDL_Rect * rec &real_type, &real_format, &items_read, &items_left, &propdata); if ((status == Success) && (items_read >= 4)) { - const long *p = (long*) propdata; + const long *p = (long *)propdata; const SDL_Rect usable = { (int)p[0], (int)p[1], (int)p[2], (int)p[3] }; retval = 0; if (!SDL_IntersectRect(rect, &usable, rect)) { diff --git a/src/video/x11/SDL_x11modes.h b/src/video/x11/SDL_x11modes.h index 9a4257e43..a56b24f99 100644 --- a/src/video/x11/SDL_x11modes.h +++ b/src/video/x11/SDL_x11modes.h @@ -47,23 +47,23 @@ typedef struct #if SDL_VIDEO_DRIVER_X11_XRANDR RRMode xrandr_mode; #else - int unused; /* just so struct isn't empty. */ + int unused; /* just so struct isn't empty. */ #endif } SDL_DisplayModeData; extern int X11_InitModes(_THIS); -extern void X11_GetDisplayModes(_THIS, SDL_VideoDisplay * display); -extern int X11_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); +extern void X11_GetDisplayModes(_THIS, SDL_VideoDisplay *display); +extern int X11_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode); extern void X11_QuitModes(_THIS); /* Some utility functions for working with visuals */ -extern int X11_GetVisualInfoFromVisual(Display * display, Visual * visual, - XVisualInfo * vinfo); -extern Uint32 X11_GetPixelFormatFromVisualInfo(Display * display, - XVisualInfo * vinfo); -extern int X11_GetDisplayBounds(_THIS, SDL_VideoDisplay * sdl_display, SDL_Rect * rect); -extern int X11_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * sdl_display, SDL_Rect * rect); -extern int X11_GetDisplayDPI(_THIS, SDL_VideoDisplay * sdl_display, float * ddpi, float * hdpi, float * vdpi); +extern int X11_GetVisualInfoFromVisual(Display *display, Visual *visual, + XVisualInfo *vinfo); +extern Uint32 X11_GetPixelFormatFromVisualInfo(Display *display, + XVisualInfo *vinfo); +extern int X11_GetDisplayBounds(_THIS, SDL_VideoDisplay *sdl_display, SDL_Rect *rect); +extern int X11_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *sdl_display, SDL_Rect *rect); +extern int X11_GetDisplayDPI(_THIS, SDL_VideoDisplay *sdl_display, float *ddpi, float *hdpi, float *vdpi); #if SDL_VIDEO_DRIVER_X11_XRANDR extern void X11_HandleXRandREvent(_THIS, const XEvent *xevent); diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index 2e6dd07f7..c383e13b5 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -28,18 +28,15 @@ #include "SDL_x11xinput2.h" #include "../../events/SDL_mouse_c.h" - /* FIXME: Find a better place to put this... */ static Cursor x11_empty_cursor = None; -static Display * -GetDisplay(void) +static Display *GetDisplay(void) { return ((SDL_VideoData *)SDL_GetVideoDevice()->driverdata)->display; } -static Cursor -X11_CreateEmptyCursor() +static Cursor X11_CreateEmptyCursor() { if (x11_empty_cursor == None) { Display *display = GetDisplay(); @@ -50,18 +47,17 @@ X11_CreateEmptyCursor() SDL_zeroa(data); color.red = color.green = color.blue = 0; pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display), - data, 1, 1); + data, 1, 1); if (pixmap) { x11_empty_cursor = X11_XCreatePixmapCursor(display, pixmap, pixmap, - &color, &color, 0, 0); + &color, &color, 0, 0); X11_XFreePixmap(display, pixmap); } } return x11_empty_cursor; } -static void -X11_DestroyEmptyCursor(void) +static void X11_DestroyEmptyCursor(void) { if (x11_empty_cursor != None) { X11_XFreeCursor(GetDisplay(), x11_empty_cursor); @@ -69,15 +65,14 @@ X11_DestroyEmptyCursor(void) } } -static SDL_Cursor * -X11_CreateDefaultCursor() +static SDL_Cursor *X11_CreateDefaultCursor() { SDL_Cursor *cursor; cursor = SDL_calloc(1, sizeof(*cursor)); if (cursor) { /* None is used to indicate the default cursor */ - cursor->driverdata = (void*)(uintptr_t)None; + cursor->driverdata = (void *)(uintptr_t)None; } else { SDL_OutOfMemory(); } @@ -86,8 +81,7 @@ X11_CreateDefaultCursor() } #if SDL_VIDEO_DRIVER_X11_XCURSOR -static Cursor -X11_CreateXCursorCursor(SDL_Surface * surface, int hot_x, int hot_y) +static Cursor X11_CreateXCursorCursor(SDL_Surface *surface, int hot_x, int hot_y) { Display *display = GetDisplay(); Cursor cursor = None; @@ -114,8 +108,7 @@ X11_CreateXCursorCursor(SDL_Surface * surface, int hot_x, int hot_y) } #endif /* SDL_VIDEO_DRIVER_X11_XCURSOR */ -static Cursor -X11_CreatePixmapCursor(SDL_Surface * surface, int hot_x, int hot_y) +static Cursor X11_CreatePixmapCursor(SDL_Surface *surface, int hot_x, int hot_y) { Display *display = GetDisplay(); XColor fg, bg; @@ -148,9 +141,9 @@ X11_CreatePixmapCursor(SDL_Surface * surface, int hot_x, int hot_y) ptr = (Uint32 *)((Uint8 *)surface->pixels + y * surface->pitch); for (x = 0; x < surface->w; ++x) { int alpha = (*ptr >> 24) & 0xff; - int red = (*ptr >> 16) & 0xff; + int red = (*ptr >> 16) & 0xff; int green = (*ptr >> 8) & 0xff; - int blue = (*ptr >> 0) & 0xff; + int blue = (*ptr >> 0) & 0xff; if (alpha > 25) { mask_bits[y * width_bytes + x / 8] |= (0x01 << (x % 8)); @@ -172,25 +165,27 @@ X11_CreatePixmapCursor(SDL_Surface * surface, int hot_x, int hot_y) } if (fgBits) { - fg.red = rfg * 257 / fgBits; + fg.red = rfg * 257 / fgBits; fg.green = gfg * 257 / fgBits; - fg.blue = bfg * 257 / fgBits; - } else fg.red = fg.green = fg.blue = 0; + fg.blue = bfg * 257 / fgBits; + } else + fg.red = fg.green = fg.blue = 0; if (bgBits) { - bg.red = rbg * 257 / bgBits; + bg.red = rbg * 257 / bgBits; bg.green = gbg * 257 / bgBits; - bg.blue = bbg * 257 / bgBits; - } else bg.red = bg.green = bg.blue = 0; + bg.blue = bbg * 257 / bgBits; + } else + bg.red = bg.green = bg.blue = 0; data_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display), - (char*)data_bits, - surface->w, surface->h); + (char *)data_bits, + surface->w, surface->h); mask_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display), - (char*)mask_bits, - surface->w, surface->h); + (char *)mask_bits, + surface->w, surface->h); cursor = X11_XCreatePixmapCursor(display, data_pixmap, mask_pixmap, - &fg, &bg, hot_x, hot_y); + &fg, &bg, hot_x, hot_y); X11_XFreePixmap(display, data_pixmap); X11_XFreePixmap(display, mask_pixmap); SDL_free(data_bits); @@ -199,8 +194,7 @@ X11_CreatePixmapCursor(SDL_Surface * surface, int hot_x, int hot_y) return cursor; } -static SDL_Cursor * -X11_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) +static SDL_Cursor *X11_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) { SDL_Cursor *cursor; @@ -216,7 +210,7 @@ X11_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) if (x11_cursor == None) { x11_cursor = X11_CreatePixmapCursor(surface, hot_x, hot_y); } - cursor->driverdata = (void*)(uintptr_t)x11_cursor; + cursor->driverdata = (void *)(uintptr_t)x11_cursor; } else { SDL_OutOfMemory(); } @@ -224,31 +218,53 @@ X11_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) return cursor; } -static SDL_Cursor * -X11_CreateSystemCursor(SDL_SystemCursor id) +static SDL_Cursor *X11_CreateSystemCursor(SDL_SystemCursor id) { SDL_Cursor *cursor; unsigned int shape; - switch(id) - { + switch (id) { default: SDL_assert(0); return NULL; /* X Font Cursors reference: */ /* http://tronche.com/gui/x/xlib/appendix/b/ */ - case SDL_SYSTEM_CURSOR_ARROW: shape = XC_left_ptr; break; - case SDL_SYSTEM_CURSOR_IBEAM: shape = XC_xterm; break; - case SDL_SYSTEM_CURSOR_WAIT: shape = XC_watch; break; - case SDL_SYSTEM_CURSOR_CROSSHAIR: shape = XC_tcross; break; - case SDL_SYSTEM_CURSOR_WAITARROW: shape = XC_watch; break; - case SDL_SYSTEM_CURSOR_SIZENWSE: shape = XC_top_left_corner; break; - case SDL_SYSTEM_CURSOR_SIZENESW: shape = XC_top_right_corner; break; - case SDL_SYSTEM_CURSOR_SIZEWE: shape = XC_sb_h_double_arrow; break; - case SDL_SYSTEM_CURSOR_SIZENS: shape = XC_sb_v_double_arrow; break; - case SDL_SYSTEM_CURSOR_SIZEALL: shape = XC_fleur; break; - case SDL_SYSTEM_CURSOR_NO: shape = XC_pirate; break; - case SDL_SYSTEM_CURSOR_HAND: shape = XC_hand2; break; + case SDL_SYSTEM_CURSOR_ARROW: + shape = XC_left_ptr; + break; + case SDL_SYSTEM_CURSOR_IBEAM: + shape = XC_xterm; + break; + case SDL_SYSTEM_CURSOR_WAIT: + shape = XC_watch; + break; + case SDL_SYSTEM_CURSOR_CROSSHAIR: + shape = XC_tcross; + break; + case SDL_SYSTEM_CURSOR_WAITARROW: + shape = XC_watch; + break; + case SDL_SYSTEM_CURSOR_SIZENWSE: + shape = XC_top_left_corner; + break; + case SDL_SYSTEM_CURSOR_SIZENESW: + shape = XC_top_right_corner; + break; + case SDL_SYSTEM_CURSOR_SIZEWE: + shape = XC_sb_h_double_arrow; + break; + case SDL_SYSTEM_CURSOR_SIZENS: + shape = XC_sb_v_double_arrow; + break; + case SDL_SYSTEM_CURSOR_SIZEALL: + shape = XC_fleur; + break; + case SDL_SYSTEM_CURSOR_NO: + shape = XC_pirate; + break; + case SDL_SYSTEM_CURSOR_HAND: + shape = XC_hand2; + break; } cursor = SDL_calloc(1, sizeof(*cursor)); @@ -257,7 +273,7 @@ X11_CreateSystemCursor(SDL_SystemCursor id) x11_cursor = X11_XCreateFontCursor(GetDisplay(), shape); - cursor->driverdata = (void*)(uintptr_t)x11_cursor; + cursor->driverdata = (void *)(uintptr_t)x11_cursor; } else { SDL_OutOfMemory(); } @@ -265,8 +281,7 @@ X11_CreateSystemCursor(SDL_SystemCursor id) return cursor; } -static void -X11_FreeCursor(SDL_Cursor * cursor) +static void X11_FreeCursor(SDL_Cursor *cursor) { Cursor x11_cursor = (Cursor)cursor->driverdata; @@ -276,8 +291,7 @@ X11_FreeCursor(SDL_Cursor * cursor) SDL_free(cursor); } -static int -X11_ShowCursor(SDL_Cursor * cursor) +static int X11_ShowCursor(SDL_Cursor *cursor) { Cursor x11_cursor = 0; @@ -308,10 +322,9 @@ X11_ShowCursor(SDL_Cursor * cursor) return 0; } -static void -WarpMouseInternal(Window xwindow, const int x, const int y) +static void WarpMouseInternal(Window xwindow, const int x, const int y) { - SDL_VideoData *videodata = (SDL_VideoData *) SDL_GetVideoDevice()->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)SDL_GetVideoDevice()->driverdata; Display *display = videodata->display; #if SDL_VIDEO_DRIVER_X11_XINPUT2 int deviceid = 0; @@ -332,10 +345,9 @@ WarpMouseInternal(Window xwindow, const int x, const int y) videodata->global_mouse_changed = SDL_TRUE; } -static void -X11_WarpMouse(SDL_Window * window, int x, int y) +static void X11_WarpMouse(SDL_Window *window, int x, int y) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; #if SDL_VIDEO_DRIVER_X11_XFIXES /* If we have no barrier, we need to warp */ @@ -347,15 +359,13 @@ X11_WarpMouse(SDL_Window * window, int x, int y) #endif } -static int -X11_WarpMouseGlobal(int x, int y) +static int X11_WarpMouseGlobal(int x, int y) { WarpMouseInternal(DefaultRootWindow(GetDisplay()), x, y); return 0; } -static int -X11_SetRelativeMouseMode(SDL_bool enabled) +static int X11_SetRelativeMouseMode(SDL_bool enabled) { #if SDL_VIDEO_DRIVER_X11_XINPUT2 if (X11_Xinput2IsInitialized()) { @@ -367,14 +377,13 @@ X11_SetRelativeMouseMode(SDL_bool enabled) return -1; } -static int -X11_CaptureMouse(SDL_Window *window) +static int X11_CaptureMouse(SDL_Window *window) { Display *display = GetDisplay(); SDL_Window *mouse_focus = SDL_GetMouseFocus(); if (window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; const unsigned int mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask; Window confined = (data->mouse_grabbed ? data->xwindow : None); const int rc = X11_XGrabPointer(display, data->xwindow, False, @@ -394,10 +403,9 @@ X11_CaptureMouse(SDL_Window *window) return 0; } -static Uint32 -X11_GetGlobalMouseState(int *x, int *y) +static Uint32 X11_GetGlobalMouseState(int *x, int *y) { - SDL_VideoData *videodata = (SDL_VideoData *) SDL_GetVideoDevice()->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)SDL_GetVideoDevice()->driverdata; Display *display = GetDisplay(); const int num_screens = SDL_GetNumVideoDisplays(); int i; @@ -412,7 +420,7 @@ X11_GetGlobalMouseState(int *x, int *y) /* !!! FIXME: can we just calculate this from XInput's events? */ if (videodata->global_mouse_changed) { for (i = 0; i < num_screens; i++) { - SDL_DisplayData *data = (SDL_DisplayData *) SDL_GetDisplayDriverData(i); + SDL_DisplayData *data = (SDL_DisplayData *)SDL_GetDisplayDriverData(i); if (data != NULL) { Window root, child; int rootx, rooty, winx, winy; @@ -424,7 +432,7 @@ X11_GetGlobalMouseState(int *x, int *y) buttons |= (mask & Button2Mask) ? SDL_BUTTON_MMASK : 0; buttons |= (mask & Button3Mask) ? SDL_BUTTON_RMASK : 0; /* Use the SDL state for the extended buttons - it's better than nothing */ - buttons |= (SDL_GetMouseState(NULL, NULL) & (SDL_BUTTON_X1MASK|SDL_BUTTON_X2MASK)); + buttons |= (SDL_GetMouseState(NULL, NULL) & (SDL_BUTTON_X1MASK | SDL_BUTTON_X2MASK)); /* SDL_DisplayData->x,y point to screen origin, and adding them to mouse coordinates relative to root window doesn't do the right thing * (observed on dual monitor setup with primary display being the rightmost one - mouse was offset to the right). * @@ -440,16 +448,14 @@ X11_GetGlobalMouseState(int *x, int *y) } } - SDL_assert(!videodata->global_mouse_changed); /* The pointer wasn't on any X11 screen?! */ + SDL_assert(!videodata->global_mouse_changed); /* The pointer wasn't on any X11 screen?! */ *x = videodata->global_mouse_position.x; *y = videodata->global_mouse_position.y; return videodata->global_mouse_buttons; } - -void -X11_InitMouse(_THIS) +void X11_InitMouse(_THIS) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -466,10 +472,9 @@ X11_InitMouse(_THIS) SDL_SetDefaultCursor(X11_CreateDefaultCursor()); } -void -X11_QuitMouse(_THIS) +void X11_QuitMouse(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; SDL_XInput2DeviceInfo *i; SDL_XInput2DeviceInfo *next; diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index aafaa2fb4..748bcb744 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -44,100 +44,100 @@ #elif defined(__QNXNTO__) #define DEFAULT_OPENGL "libGL.so.3" #else -#define DEFAULT_OPENGL "libGL.so.1" +#define DEFAULT_OPENGL "libGL.so.1" #endif #ifndef GLX_NONE_EXT -#define GLX_NONE_EXT 0x8000 +#define GLX_NONE_EXT 0x8000 #endif #ifndef GLX_ARB_multisample #define GLX_ARB_multisample -#define GLX_SAMPLE_BUFFERS_ARB 100000 -#define GLX_SAMPLES_ARB 100001 +#define GLX_SAMPLE_BUFFERS_ARB 100000 +#define GLX_SAMPLES_ARB 100001 #endif #ifndef GLX_EXT_visual_rating #define GLX_EXT_visual_rating -#define GLX_VISUAL_CAVEAT_EXT 0x20 -#define GLX_NONE_EXT 0x8000 -#define GLX_SLOW_VISUAL_EXT 0x8001 -#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D +#define GLX_VISUAL_CAVEAT_EXT 0x20 +#define GLX_NONE_EXT 0x8000 +#define GLX_SLOW_VISUAL_EXT 0x8001 +#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D #endif #ifndef GLX_EXT_visual_info #define GLX_EXT_visual_info -#define GLX_X_VISUAL_TYPE_EXT 0x22 -#define GLX_DIRECT_COLOR_EXT 0x8003 +#define GLX_X_VISUAL_TYPE_EXT 0x22 +#define GLX_DIRECT_COLOR_EXT 0x8003 #endif #ifndef GLX_ARB_create_context #define GLX_ARB_create_context -#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define GLX_CONTEXT_FLAGS_ARB 0x2094 -#define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001 +#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define GLX_CONTEXT_FLAGS_ARB 0x2094 +#define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001 #define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 /* Typedef for the GL 3.0 context creation function */ -typedef GLXContext(*PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display * dpy, +typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display *dpy, GLXFBConfig config, GLXContext - share_context, + share_context, Bool direct, const int - *attrib_list); + *attrib_list); #endif #ifndef GLX_ARB_create_context_profile #define GLX_ARB_create_context_profile -#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 -#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 +#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 #define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 #endif #ifndef GLX_ARB_create_context_robustness #define GLX_ARB_create_context_robustness -#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261 -#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261 +#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 #endif #ifndef GLX_EXT_create_context_es2_profile #define GLX_EXT_create_context_es2_profile #ifndef GLX_CONTEXT_ES2_PROFILE_BIT_EXT -#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000002 +#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000002 #endif #endif #ifndef GLX_ARB_framebuffer_sRGB #define GLX_ARB_framebuffer_sRGB #ifndef GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB -#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2 +#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2 #endif #endif #ifndef GLX_ARB_fbconfig_float #define GLX_ARB_fbconfig_float #ifndef GLX_RGBA_FLOAT_TYPE_ARB -#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9 +#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9 #endif #ifndef GLX_RGBA_FLOAT_BIT_ARB -#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004 +#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004 #endif #endif #ifndef GLX_ARB_create_context_no_error #define GLX_ARB_create_context_no_error #ifndef GLX_CONTEXT_OPENGL_NO_ERROR_ARB -#define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3 +#define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3 #endif #endif #ifndef GLX_EXT_swap_control -#define GLX_SWAP_INTERVAL_EXT 0x20F1 -#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2 +#define GLX_SWAP_INTERVAL_EXT 0x20F1 +#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2 #endif #ifndef GLX_EXT_swap_control_tear @@ -146,17 +146,17 @@ typedef GLXContext(*PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display * dpy, #ifndef GLX_ARB_context_flush_control #define GLX_ARB_context_flush_control -#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 -#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0x0000 -#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 +#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 +#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0x0000 +#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 #endif #define OPENGL_REQUIRES_DLOPEN #if defined(OPENGL_REQUIRES_DLOPEN) && defined(HAVE_DLOPEN) #include -#define GL_LoadObject(X) dlopen(X, (RTLD_NOW|RTLD_GLOBAL)) -#define GL_LoadFunction dlsym -#define GL_UnloadObject dlclose +#define GL_LoadObject(X) dlopen(X, (RTLD_NOW | RTLD_GLOBAL)) +#define GL_LoadFunction dlsym +#define GL_UnloadObject dlclose #else #define GL_LoadObject SDL_LoadObject #define GL_LoadFunction SDL_LoadFunction @@ -165,8 +165,7 @@ typedef GLXContext(*PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display * dpy, static void X11_GL_InitExtensions(_THIS); -int -X11_GL_LoadLibrary(_THIS, const char *path) +int X11_GL_LoadLibrary(_THIS, const char *path) { Display *display; void *handle; @@ -194,9 +193,9 @@ X11_GL_LoadLibrary(_THIS, const char *path) /* Allocate OpenGL memory */ _this->gl_data = - (struct SDL_GLDriverData *) SDL_calloc(1, - sizeof(struct - SDL_GLDriverData)); + (struct SDL_GLDriverData *)SDL_calloc(1, + sizeof(struct + SDL_GLDriverData)); if (!_this->gl_data) { return SDL_OutOfMemory(); } @@ -204,7 +203,7 @@ X11_GL_LoadLibrary(_THIS, const char *path) /* Load function pointers */ handle = _this->gl_config.dll_handle; _this->gl_data->glXQueryExtension = - (Bool (*)(Display *, int *, int *)) + (Bool(*)(Display *, int *, int *)) GL_LoadFunction(handle, "glXQueryExtension"); _this->gl_data->glXGetProcAddress = (void *(*)(const GLubyte *)) @@ -225,7 +224,7 @@ X11_GL_LoadLibrary(_THIS, const char *path) (void (*)(Display *, GLXDrawable)) X11_GL_GetProcAddress(_this, "glXSwapBuffers"); _this->gl_data->glXQueryDrawable = - (void (*)(Display*,GLXDrawable,int,unsigned int*)) + (void (*)(Display *, GLXDrawable, int, unsigned int *)) X11_GL_GetProcAddress(_this, "glXQueryDrawable"); if (!_this->gl_data->glXQueryExtension || @@ -237,20 +236,20 @@ X11_GL_LoadLibrary(_THIS, const char *path) return SDL_SetError("Could not retrieve OpenGL functions"); } - display = ((SDL_VideoData *) _this->driverdata)->display; + display = ((SDL_VideoData *)_this->driverdata)->display; if (!_this->gl_data->glXQueryExtension(display, &_this->gl_data->errorBase, &_this->gl_data->eventBase)) { return SDL_SetError("GLX is not supported"); } /* Initialize extensions */ - /* See lengthy comment about the inc/dec in + /* See lengthy comment about the inc/dec in ../windows/SDL_windowsopengl.c. */ ++_this->gl_config.driver_loaded; X11_GL_InitExtensions(_this); --_this->gl_config.driver_loaded; - - /* If we need a GL ES context and there's no - * GLX_EXT_create_context_es2_profile extension, switch over to X11_GLES functions + + /* If we need a GL ES context and there's no + * GLX_EXT_create_context_es2_profile extension, switch over to X11_GLES functions */ if (((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) || SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE)) && @@ -279,13 +278,12 @@ void * X11_GL_GetProcAddress(_THIS, const char *proc) { if (_this->gl_data->glXGetProcAddress) { - return _this->gl_data->glXGetProcAddress((const GLubyte *) proc); + return _this->gl_data->glXGetProcAddress((const GLubyte *)proc); } return GL_LoadFunction(_this->gl_config.dll_handle, proc); } -void -X11_GL_UnloadLibrary(_THIS) +void X11_GL_UnloadLibrary(_THIS) { /* Don't actually unload the library, since it may have registered * X11 shutdown hooks, per the notes at: @@ -301,8 +299,7 @@ X11_GL_UnloadLibrary(_THIS) _this->gl_data = NULL; } -static SDL_bool -HasExtension(const char *extension, const char *extensions) +static SDL_bool HasExtension(const char *extension, const char *extensions) { const char *start; const char *where, *terminator; @@ -341,26 +338,25 @@ HasExtension(const char *extension, const char *extensions) return SDL_FALSE; } -static void -X11_GL_InitExtensions(_THIS) +static void X11_GL_InitExtensions(_THIS) { - Display *display = ((SDL_VideoData *) _this->driverdata)->display; + Display *display = ((SDL_VideoData *)_this->driverdata)->display; const int screen = DefaultScreen(display); XVisualInfo *vinfo = NULL; Window w = 0; GLXContext prev_ctx = 0; GLXDrawable prev_drawable = 0; GLXContext context = 0; - const char *(*glXQueryExtensionsStringFunc) (Display *, int); + const char *(*glXQueryExtensionsStringFunc)(Display *, int); const char *extensions; vinfo = X11_GL_GetVisual(_this, display, screen); if (vinfo) { - GLXContext (*glXGetCurrentContextFunc) (void) = + GLXContext (*glXGetCurrentContextFunc)(void) = (GLXContext(*)(void)) X11_GL_GetProcAddress(_this, "glXGetCurrentContext"); - GLXDrawable (*glXGetCurrentDrawableFunc) (void) = + GLXDrawable (*glXGetCurrentDrawableFunc)(void) = (GLXDrawable(*)(void)) X11_GL_GetProcAddress(_this, "glXGetCurrentDrawable"); @@ -375,11 +371,11 @@ X11_GL_InitExtensions(_THIS) X11_XCreateColormap(display, RootWindow(display, screen), vinfo->visual, AllocNone); w = X11_XCreateWindow(display, RootWindow(display, screen), 0, 0, - 32, 32, 0, vinfo->depth, InputOutput, vinfo->visual, - (CWBackPixel | CWBorderPixel | CWColormap), &xattr); + 32, 32, 0, vinfo->depth, InputOutput, vinfo->visual, + (CWBackPixel | CWBorderPixel | CWColormap), &xattr); context = _this->gl_data->glXCreateContext(display, vinfo, - NULL, True); + NULL, True); if (context) { _this->gl_data->glXMakeCurrent(display, w, context); } @@ -389,8 +385,8 @@ X11_GL_InitExtensions(_THIS) } glXQueryExtensionsStringFunc = - (const char *(*)(Display *, int)) X11_GL_GetProcAddress(_this, - "glXQueryExtensionsString"); + (const char *(*)(Display *, int))X11_GL_GetProcAddress(_this, + "glXQueryExtensionsString"); if (glXQueryExtensionsStringFunc) { extensions = glXQueryExtensionsStringFunc(display, screen); } else { @@ -401,7 +397,7 @@ X11_GL_InitExtensions(_THIS) _this->gl_data->HAS_GLX_EXT_swap_control_tear = SDL_FALSE; if (HasExtension("GLX_EXT_swap_control", extensions)) { _this->gl_data->glXSwapIntervalEXT = - (void (*)(Display*,GLXDrawable,int)) + (void (*)(Display *, GLXDrawable, int)) X11_GL_GetProcAddress(_this, "glXSwapIntervalEXT"); if (HasExtension("GLX_EXT_swap_control_tear", extensions)) { _this->gl_data->HAS_GLX_EXT_swap_control_tear = SDL_TRUE; @@ -411,28 +407,28 @@ X11_GL_InitExtensions(_THIS) /* Check for GLX_MESA_swap_control */ if (HasExtension("GLX_MESA_swap_control", extensions)) { _this->gl_data->glXSwapIntervalMESA = - (int(*)(int)) X11_GL_GetProcAddress(_this, "glXSwapIntervalMESA"); + (int (*)(int))X11_GL_GetProcAddress(_this, "glXSwapIntervalMESA"); _this->gl_data->glXGetSwapIntervalMESA = - (int(*)(void)) X11_GL_GetProcAddress(_this, - "glXGetSwapIntervalMESA"); + (int (*)(void))X11_GL_GetProcAddress(_this, + "glXGetSwapIntervalMESA"); } /* Check for GLX_SGI_swap_control */ if (HasExtension("GLX_SGI_swap_control", extensions)) { _this->gl_data->glXSwapIntervalSGI = - (int (*)(int)) X11_GL_GetProcAddress(_this, "glXSwapIntervalSGI"); + (int (*)(int))X11_GL_GetProcAddress(_this, "glXSwapIntervalSGI"); } /* Check for GLX_ARB_create_context */ if (HasExtension("GLX_ARB_create_context", extensions)) { _this->gl_data->glXCreateContextAttribsARB = - (GLXContext (*)(Display*,GLXFBConfig,GLXContext,Bool,const int *)) + (GLXContext(*)(Display *, GLXFBConfig, GLXContext, Bool, const int *)) X11_GL_GetProcAddress(_this, "glXCreateContextAttribsARB"); _this->gl_data->glXChooseFBConfig = - (GLXFBConfig *(*)(Display *, int, const int *, int *)) + (GLXFBConfig * (*)(Display *, int, const int *, int *)) X11_GL_GetProcAddress(_this, "glXChooseFBConfig"); _this->gl_data->glXGetVisualFromFBConfig = - (XVisualInfo *(*)(Display *, GLXFBConfig)) + (XVisualInfo * (*)(Display *, GLXFBConfig)) X11_GL_GetProcAddress(_this, "glXGetVisualFromFBConfig"); } @@ -445,7 +441,7 @@ X11_GL_InitExtensions(_THIS) if (HasExtension("GLX_EXT_visual_info", extensions)) { _this->gl_data->HAS_GLX_EXT_visual_info = SDL_TRUE; } - + /* Check for GLX_EXT_create_context_es2_profile */ if (HasExtension("GLX_EXT_create_context_es2_profile", extensions)) { /* this wants to call glGetString(), so it needs a context. */ @@ -453,8 +449,7 @@ X11_GL_InitExtensions(_THIS) if (context) { SDL_GL_DeduceMaxSupportedESProfile( &_this->gl_data->es_profile_max_supported_version.major, - &_this->gl_data->es_profile_max_supported_version.minor - ); + &_this->gl_data->es_profile_max_supported_version.minor); } } @@ -494,8 +489,7 @@ X11_GL_InitExtensions(_THIS) * In case of failure, if that pointer is not NULL, set that pointer to None * and try again. */ -static int -X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int size, Bool for_FBConfig, int **_pvistypeattr) +static int X11_GL_GetAttributes(_THIS, Display *display, int screen, int *attribs, int size, Bool for_FBConfig, int **_pvistypeattr) { int i = 0; const int MAX_ATTRIBUTES = 64; @@ -505,7 +499,7 @@ X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int si SDL_assert(size >= MAX_ATTRIBUTES); /* Setup our GLX attributes according to the gl_config. */ - if ( for_FBConfig ) { + if (for_FBConfig) { attribs[i++] = GLX_RENDER_TYPE; if (_this->gl_config.floatbuffers) { attribs[i++] = GLX_RGBA_FLOAT_BIT_ARB; @@ -529,7 +523,7 @@ X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int si if (_this->gl_config.double_buffer) { attribs[i++] = GLX_DOUBLEBUFFER; - if ( for_FBConfig ) { + if (for_FBConfig) { attribs[i++] = True; } } @@ -564,7 +558,7 @@ X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int si if (_this->gl_config.stereo) { attribs[i++] = GLX_STEREO; - if ( for_FBConfig ) { + if (for_FBConfig) { attribs[i++] = True; } } @@ -585,14 +579,13 @@ X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int si if (_this->gl_config.framebuffer_srgb_capable) { attribs[i++] = GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB; - attribs[i++] = True; /* always needed, for_FBConfig or not! */ + attribs[i++] = True; /* always needed, for_FBConfig or not! */ } if (_this->gl_config.accelerated >= 0 && _this->gl_data->HAS_GLX_EXT_visual_rating) { attribs[i++] = GLX_VISUAL_CAVEAT_EXT; - attribs[i++] = _this->gl_config.accelerated ? GLX_NONE_EXT : - GLX_SLOW_VISUAL_EXT; + attribs[i++] = _this->gl_config.accelerated ? GLX_NONE_EXT : GLX_SLOW_VISUAL_EXT; } /* If we're supposed to use DirectColor visuals, and we've got the @@ -616,7 +609,7 @@ X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int si } XVisualInfo * -X11_GL_GetVisual(_THIS, Display * display, int screen) +X11_GL_GetVisual(_THIS, Display *display, int screen) { /* 64 seems nice. */ int attribs[64]; @@ -663,19 +656,18 @@ X11_GL_GetVisual(_THIS, Display * display, int screen) return vinfo; } -static int (*handler) (Display *, XErrorEvent *) = NULL; +static int (*handler)(Display *, XErrorEvent *) = NULL; static const char *errorHandlerOperation = NULL; static int errorBase = 0; static int errorCode = 0; -static int -X11_GL_ErrorHandler(Display * d, XErrorEvent * e) +static int X11_GL_ErrorHandler(Display *d, XErrorEvent *e) { char *x11_error = NULL; char x11_error_locale[256]; errorCode = e->error_code; if (X11_XGetErrorText(d, errorCode, x11_error_locale, sizeof(x11_error_locale)) == Success) { - x11_error = SDL_iconv_string("UTF-8", "", x11_error_locale, SDL_strlen(x11_error_locale)+1); + x11_error = SDL_iconv_string("UTF-8", "", x11_error_locale, SDL_strlen(x11_error_locale) + 1); } if (x11_error) { @@ -699,20 +691,17 @@ X11_GL_UseEGL(_THIS) } SDL_assert(_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES); - return (SDL_GetHintBoolean(SDL_HINT_OPENGL_ES_DRIVER, SDL_FALSE) - || _this->gl_config.major_version == 1 /* No GLX extension for OpenGL ES 1.x profiles. */ - || _this->gl_config.major_version > _this->gl_data->es_profile_max_supported_version.major - || (_this->gl_config.major_version == _this->gl_data->es_profile_max_supported_version.major - && _this->gl_config.minor_version > _this->gl_data->es_profile_max_supported_version.minor)); + return (SDL_GetHintBoolean(SDL_HINT_OPENGL_ES_DRIVER, SDL_FALSE) || _this->gl_config.major_version == 1 /* No GLX extension for OpenGL ES 1.x profiles. */ + || _this->gl_config.major_version > _this->gl_data->es_profile_max_supported_version.major || (_this->gl_config.major_version == _this->gl_data->es_profile_max_supported_version.major && _this->gl_config.minor_version > _this->gl_data->es_profile_max_supported_version.minor)); } SDL_GLContext -X11_GL_CreateContext(_THIS, SDL_Window * window) +X11_GL_CreateContext(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; int screen = - ((SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata)->screen; + ((SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata)->screen; XWindowAttributes xattr; XVisualInfo v, *vinfo; int n; @@ -753,37 +742,33 @@ X11_GL_CreateContext(_THIS, SDL_Window * window) int iattr = 4; /* SDL profile bits match GLX profile bits */ - if ( _this->gl_config.profile_mask != 0 ) { + if (_this->gl_config.profile_mask != 0) { attribs[iattr++] = GLX_CONTEXT_PROFILE_MASK_ARB; attribs[iattr++] = _this->gl_config.profile_mask; } /* SDL flags match GLX flags */ - if ( _this->gl_config.flags != 0 ) { + if (_this->gl_config.flags != 0) { attribs[iattr++] = GLX_CONTEXT_FLAGS_ARB; attribs[iattr++] = _this->gl_config.flags; } /* only set if glx extension is available */ - if ( _this->gl_data->HAS_GLX_ARB_context_flush_control ) { + if (_this->gl_data->HAS_GLX_ARB_context_flush_control) { attribs[iattr++] = GLX_CONTEXT_RELEASE_BEHAVIOR_ARB; - attribs[iattr++] = - _this->gl_config.release_behavior ? - GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB : - GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB; + attribs[iattr++] = + _this->gl_config.release_behavior ? GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB : GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB; } /* only set if glx extension is available */ - if ( _this->gl_data->HAS_GLX_ARB_create_context_robustness ) { + if (_this->gl_data->HAS_GLX_ARB_create_context_robustness) { attribs[iattr++] = GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB; attribs[iattr++] = - _this->gl_config.reset_notification ? - GLX_LOSE_CONTEXT_ON_RESET_ARB : - GLX_NO_RESET_NOTIFICATION_ARB; + _this->gl_config.reset_notification ? GLX_LOSE_CONTEXT_ON_RESET_ARB : GLX_NO_RESET_NOTIFICATION_ARB; } /* only set if glx extension is available */ - if ( _this->gl_data->HAS_GLX_ARB_create_context_no_error ) { + if (_this->gl_data->HAS_GLX_ARB_create_context_no_error) { attribs[iattr++] = GLX_CONTEXT_OPENGL_NO_ERROR_ARB; attribs[iattr++] = _this->gl_config.no_error; } @@ -801,24 +786,24 @@ X11_GL_CreateContext(_THIS, SDL_Window * window) int fbcount = 0; int *pvistypeattr = NULL; - X11_GL_GetAttributes(_this,display,screen,glxAttribs,64,SDL_TRUE,&pvistypeattr); + X11_GL_GetAttributes(_this, display, screen, glxAttribs, 64, SDL_TRUE, &pvistypeattr); if (_this->gl_data->glXChooseFBConfig) { framebuffer_config = _this->gl_data->glXChooseFBConfig(display, - DefaultScreen(display), glxAttribs, - &fbcount); + DefaultScreen(display), glxAttribs, + &fbcount); if (!framebuffer_config && (pvistypeattr != NULL)) { *pvistypeattr = None; framebuffer_config = _this->gl_data->glXChooseFBConfig(display, - DefaultScreen(display), glxAttribs, - &fbcount); + DefaultScreen(display), glxAttribs, + &fbcount); } - + if (framebuffer_config) { context = _this->gl_data->glXCreateContextAttribsARB(display, - framebuffer_config[0], - share_context, True, attribs); + framebuffer_config[0], + share_context, True, attribs); X11_XFree(framebuffer_config); } } @@ -844,13 +829,12 @@ X11_GL_CreateContext(_THIS, SDL_Window * window) return context; } -int -X11_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) +int X11_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context) { - Display *display = ((SDL_VideoData *) _this->driverdata)->display; + Display *display = ((SDL_VideoData *)_this->driverdata)->display; Window drawable = - (context ? ((SDL_WindowData *) window->driverdata)->xwindow : None); - GLXContext glx_context = (GLXContext) context; + (context ? ((SDL_WindowData *)window->driverdata)->xwindow : None); + GLXContext glx_context = (GLXContext)context; int rc; if (!_this->gl_data) { @@ -866,9 +850,9 @@ X11_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) rc = _this->gl_data->glXMakeCurrent(display, drawable, glx_context); X11_XSetErrorHandler(handler); - if (errorCode != Success) { /* uhoh, an X error was thrown! */ - return -1; /* the error handler called SDL_SetError() already. */ - } else if (!rc) { /* glXMakeCurrent() failed without throwing an X error */ + if (errorCode != Success) { /* uhoh, an X error was thrown! */ + return -1; /* the error handler called SDL_SetError() already. */ + } else if (!rc) { /* glXMakeCurrent() failed without throwing an X error */ return SDL_SetError("Unable to make GL context current"); } @@ -884,17 +868,17 @@ X11_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) */ static int swapinterval = 0; -int -X11_GL_SetSwapInterval(_THIS, int interval) +int X11_GL_SetSwapInterval(_THIS, int interval) { int status = -1; if ((interval < 0) && (!_this->gl_data->HAS_GLX_EXT_swap_control_tear)) { SDL_SetError("Negative swap interval unsupported in this GL"); } else if (_this->gl_data->glXSwapIntervalEXT) { - Display *display = ((SDL_VideoData *) _this->driverdata)->display; + Display *display = ((SDL_VideoData *)_this->driverdata)->display; const SDL_WindowData *windowdata = (SDL_WindowData *) - SDL_GL_GetCurrentWindow()->driverdata; + SDL_GL_GetCurrentWindow() + ->driverdata; Window drawable = windowdata->xwindow; @@ -932,31 +916,31 @@ X11_GL_SetSwapInterval(_THIS, int interval) return status; } -int -X11_GL_GetSwapInterval(_THIS) +int X11_GL_GetSwapInterval(_THIS) { if (_this->gl_data->glXSwapIntervalEXT) { - Display *display = ((SDL_VideoData *) _this->driverdata)->display; + Display *display = ((SDL_VideoData *)_this->driverdata)->display; const SDL_WindowData *windowdata = (SDL_WindowData *) - SDL_GL_GetCurrentWindow()->driverdata; + SDL_GL_GetCurrentWindow() + ->driverdata; Window drawable = windowdata->xwindow; unsigned int allow_late_swap_tearing = 0; unsigned int interval = 0; if (_this->gl_data->HAS_GLX_EXT_swap_control_tear) { _this->gl_data->glXQueryDrawable(display, drawable, - GLX_LATE_SWAPS_TEAR_EXT, - &allow_late_swap_tearing); + GLX_LATE_SWAPS_TEAR_EXT, + &allow_late_swap_tearing); } _this->gl_data->glXQueryDrawable(display, drawable, GLX_SWAP_INTERVAL_EXT, &interval); if ((allow_late_swap_tearing) && (interval > 0)) { - return -((int) interval); + return -((int)interval); } - return (int) interval; + return (int)interval; } else if (_this->gl_data->glXGetSwapIntervalMESA) { return _this->gl_data->glXGetSwapIntervalMESA(); } else { @@ -964,21 +948,19 @@ X11_GL_GetSwapInterval(_THIS) } } -int -X11_GL_SwapWindow(_THIS, SDL_Window * window) +int X11_GL_SwapWindow(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; _this->gl_data->glXSwapBuffers(display, data->xwindow); return 0; } -void -X11_GL_DeleteContext(_THIS, SDL_GLContext context) +void X11_GL_DeleteContext(_THIS, SDL_GLContext context) { - Display *display = ((SDL_VideoData *) _this->driverdata)->display; - GLXContext glx_context = (GLXContext) context; + Display *display = ((SDL_VideoData *)_this->driverdata)->display; + GLXContext glx_context = (GLXContext)context; if (!_this->gl_data) { return; diff --git a/src/video/x11/SDL_x11opengl.h b/src/video/x11/SDL_x11opengl.h index 71e03c0c9..08530315b 100644 --- a/src/video/x11/SDL_x11opengl.h +++ b/src/video/x11/SDL_x11opengl.h @@ -42,26 +42,27 @@ struct SDL_GLDriverData implementation supports GLX_EXT_create_context_es2_profile. major = minor = 0 when unsupported. */ - struct { + struct + { int major; int minor; } es_profile_max_supported_version; - Bool (*glXQueryExtension) (Display*,int*,int*); - void *(*glXGetProcAddress) (const GLubyte*); - XVisualInfo *(*glXChooseVisual) (Display*,int,int*); - GLXContext (*glXCreateContext) (Display*,XVisualInfo*,GLXContext,Bool); - GLXContext (*glXCreateContextAttribsARB) (Display*,GLXFBConfig,GLXContext,Bool,const int *); - GLXFBConfig *(*glXChooseFBConfig) (Display*,int,const int *,int *); - XVisualInfo *(*glXGetVisualFromFBConfig) (Display*,GLXFBConfig); - void (*glXDestroyContext) (Display*, GLXContext); - Bool(*glXMakeCurrent) (Display*,GLXDrawable,GLXContext); - void (*glXSwapBuffers) (Display*, GLXDrawable); - void (*glXQueryDrawable) (Display*,GLXDrawable,int,unsigned int*); - void (*glXSwapIntervalEXT) (Display*,GLXDrawable,int); - int (*glXSwapIntervalSGI) (int); - int (*glXSwapIntervalMESA) (int); - int (*glXGetSwapIntervalMESA) (void); + Bool (*glXQueryExtension)(Display *, int *, int *); + void *(*glXGetProcAddress)(const GLubyte *); + XVisualInfo *(*glXChooseVisual)(Display *, int, int *); + GLXContext (*glXCreateContext)(Display *, XVisualInfo *, GLXContext, Bool); + GLXContext (*glXCreateContextAttribsARB)(Display *, GLXFBConfig, GLXContext, Bool, const int *); + GLXFBConfig *(*glXChooseFBConfig)(Display *, int, const int *, int *); + XVisualInfo *(*glXGetVisualFromFBConfig)(Display *, GLXFBConfig); + void (*glXDestroyContext)(Display *, GLXContext); + Bool (*glXMakeCurrent)(Display *, GLXDrawable, GLXContext); + void (*glXSwapBuffers)(Display *, GLXDrawable); + void (*glXQueryDrawable)(Display *, GLXDrawable, int, unsigned int *); + void (*glXSwapIntervalEXT)(Display *, GLXDrawable, int); + int (*glXSwapIntervalSGI)(int); + int (*glXSwapIntervalMESA)(int); + int (*glXGetSwapIntervalMESA)(void); }; /* OpenGL functions */ @@ -69,13 +70,13 @@ extern int X11_GL_LoadLibrary(_THIS, const char *path); extern void *X11_GL_GetProcAddress(_THIS, const char *proc); extern void X11_GL_UnloadLibrary(_THIS); extern SDL_bool X11_GL_UseEGL(_THIS); -extern XVisualInfo *X11_GL_GetVisual(_THIS, Display * display, int screen); -extern SDL_GLContext X11_GL_CreateContext(_THIS, SDL_Window * window); -extern int X11_GL_MakeCurrent(_THIS, SDL_Window * window, +extern XVisualInfo *X11_GL_GetVisual(_THIS, Display *display, int screen); +extern SDL_GLContext X11_GL_CreateContext(_THIS, SDL_Window *window); +extern int X11_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); extern int X11_GL_SetSwapInterval(_THIS, int interval); extern int X11_GL_GetSwapInterval(_THIS); -extern int X11_GL_SwapWindow(_THIS, SDL_Window * window); +extern int X11_GL_SwapWindow(_THIS, SDL_Window *window); extern void X11_GL_DeleteContext(_THIS, SDL_GLContext context); #endif /* SDL_VIDEO_OPENGL_GLX */ diff --git a/src/video/x11/SDL_x11opengles.c b/src/video/x11/SDL_x11opengles.c index e1ec4e4d2..4700b0c3b 100644 --- a/src/video/x11/SDL_x11opengles.c +++ b/src/video/x11/SDL_x11opengles.c @@ -29,10 +29,9 @@ /* EGL implementation of SDL OpenGL support */ -int -X11_GLES_LoadLibrary(_THIS, const char *path) +int X11_GLES_LoadLibrary(_THIS, const char *path) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; /* If the profile requested is not GL ES, switch over to X11_GL functions */ if ((_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) && @@ -49,18 +48,18 @@ X11_GLES_LoadLibrary(_THIS, const char *path) _this->GL_SwapWindow = X11_GL_SwapWindow; _this->GL_DeleteContext = X11_GL_DeleteContext; return X11_GL_LoadLibrary(_this, path); - #else +#else return SDL_SetError("SDL not configured with OpenGL/GLX support"); - #endif +#endif } return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType) data->display, 0); } XVisualInfo * -X11_GLES_GetVisual(_THIS, Display * display, int screen) +X11_GLES_GetVisual(_THIS, Display *display, int screen) { - + XVisualInfo *egl_visualinfo = NULL; EGLint visual_id; XVisualInfo vi_in; @@ -74,12 +73,13 @@ X11_GLES_GetVisual(_THIS, Display * display, int screen) if (_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, _this->egl_data->egl_config, EGL_NATIVE_VISUAL_ID, - &visual_id) == EGL_FALSE || !visual_id) { + &visual_id) == EGL_FALSE || + !visual_id) { /* Use the default visual when all else fails */ vi_in.screen = screen; egl_visualinfo = X11_XGetVisualInfo(display, - VisualScreenMask, - &vi_in, &out_count); + VisualScreenMask, + &vi_in, &out_count); } else { vi_in.screen = screen; vi_in.visualid = visual_id; @@ -90,10 +90,10 @@ X11_GLES_GetVisual(_THIS, Display * display, int screen) } SDL_GLContext -X11_GLES_CreateContext(_THIS, SDL_Window * window) +X11_GLES_CreateContext(_THIS, SDL_Window *window) { SDL_GLContext context; - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; X11_XSync(display, False); @@ -104,8 +104,8 @@ X11_GLES_CreateContext(_THIS, SDL_Window * window) } SDL_EGL_SwapWindow_impl(X11) -SDL_EGL_MakeCurrent_impl(X11) + SDL_EGL_MakeCurrent_impl(X11) #endif /* SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_EGL */ -/* vi: set ts=4 sw=4 expandtab: */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/x11/SDL_x11opengles.h b/src/video/x11/SDL_x11opengles.h index 5219553ca..406bbf05a 100644 --- a/src/video/x11/SDL_x11opengles.h +++ b/src/video/x11/SDL_x11opengles.h @@ -30,9 +30,9 @@ typedef struct SDL_PrivateGLESData { - /* 1401 If the struct-declaration-list contains no named members, the behavior is undefined. */ - /* warning: empty struct has size 0 in C, size 1 in C++ [-Wc++-compat] */ - int dummy; + /* 1401 If the struct-declaration-list contains no named members, the behavior is undefined. */ + /* warning: empty struct has size 0 in C, size 1 in C++ [-Wc++-compat] */ + int dummy; } SDL_PrivateGLESData; /* OpenGLES functions */ @@ -41,7 +41,7 @@ typedef struct SDL_PrivateGLESData #define X11_GLES_UnloadLibrary SDL_EGL_UnloadLibrary #define X11_GLES_SetSwapInterval SDL_EGL_SetSwapInterval #define X11_GLES_GetSwapInterval SDL_EGL_GetSwapInterval -#define X11_GLES_DeleteContext SDL_EGL_DeleteContext +#define X11_GLES_DeleteContext SDL_EGL_DeleteContext extern int X11_GLES_LoadLibrary(_THIS, const char *path); extern XVisualInfo *X11_GLES_GetVisual(_THIS, Display * display, int screen); diff --git a/src/video/x11/SDL_x11shape.c b/src/video/x11/SDL_x11shape.c index fe288454e..a11e60b48 100644 --- a/src/video/x11/SDL_x11shape.c +++ b/src/video/x11/SDL_x11shape.c @@ -27,13 +27,14 @@ #include "SDL_x11window.h" #include "../SDL_shape_internals.h" -SDL_WindowShaper* -X11_CreateShaper(SDL_Window* window) { - SDL_WindowShaper* result = NULL; - SDL_ShapeData* data = NULL; +SDL_WindowShaper * +X11_CreateShaper(SDL_Window *window) +{ + SDL_WindowShaper *result = NULL; + SDL_ShapeData *data = NULL; #if SDL_VIDEO_DRIVER_X11_XSHAPE - if (SDL_X11_HAVE_XSHAPE) { /* Make sure X server supports it. */ + if (SDL_X11_HAVE_XSHAPE) { /* Make sure X server supports it. */ result = SDL_malloc(sizeof(SDL_WindowShaper)); if (result == NULL) { SDL_OutOfMemory(); @@ -65,9 +66,9 @@ X11_CreateShaper(SDL_Window* window) { return result; } -int -X11_ResizeWindowShape(SDL_Window* window) { - SDL_ShapeData* data = window->shaper->driverdata; +int X11_ResizeWindowShape(SDL_Window *window) +{ + SDL_ShapeData *data = window->shaper->driverdata; unsigned int bitmapsize = window->w / 8; SDL_assert(data != NULL); @@ -83,21 +84,21 @@ X11_ResizeWindowShape(SDL_Window* window) { return SDL_OutOfMemory(); } } - SDL_memset(data->bitmap,0,data->bitmapsize); + SDL_memset(data->bitmap, 0, data->bitmapsize); window->shaper->userx = window->x; window->shaper->usery = window->y; - SDL_SetWindowPosition(window,-1000,-1000); + SDL_SetWindowPosition(window, -1000, -1000); return 0; } -int -X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) { +int X11_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode) +{ SDL_ShapeData *data = NULL; SDL_WindowData *windowdata = NULL; Pixmap shapemask; - + if (shaper == NULL || shape == NULL || shaper->driverdata == NULL) { return -1; } @@ -112,15 +113,15 @@ X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMo data = shaper->driverdata; /* Assume that shaper->alphacutoff already has a value, because SDL_SetWindowShape() should have given it one. */ - SDL_CalculateShapeBitmap(shaper->mode,shape,data->bitmap,8); + SDL_CalculateShapeBitmap(shaper->mode, shape, data->bitmap, 8); - windowdata = (SDL_WindowData*)(shaper->window->driverdata); - shapemask = X11_XCreateBitmapFromData(windowdata->videodata->display,windowdata->xwindow,data->bitmap,shaper->window->w,shaper->window->h); + windowdata = (SDL_WindowData *)(shaper->window->driverdata); + shapemask = X11_XCreateBitmapFromData(windowdata->videodata->display, windowdata->xwindow, data->bitmap, shaper->window->w, shaper->window->h); - X11_XShapeCombineMask(windowdata->videodata->display,windowdata->xwindow, ShapeBounding, 0, 0,shapemask, ShapeSet); - X11_XSync(windowdata->videodata->display,False); + X11_XShapeCombineMask(windowdata->videodata->display, windowdata->xwindow, ShapeBounding, 0, 0, shapemask, ShapeSet); + X11_XSync(windowdata->videodata->display, False); - X11_XFreePixmap(windowdata->videodata->display,shapemask); + X11_XFreePixmap(windowdata->videodata->display, shapemask); #endif return 0; diff --git a/src/video/x11/SDL_x11shape.h b/src/video/x11/SDL_x11shape.h index 4d54fb168..d24d25a9b 100644 --- a/src/video/x11/SDL_x11shape.h +++ b/src/video/x11/SDL_x11shape.h @@ -27,13 +27,14 @@ #include "SDL_shape.h" #include "../SDL_sysvideo.h" -typedef struct { - void* bitmap; +typedef struct +{ + void *bitmap; Uint32 bitmapsize; } SDL_ShapeData; -extern SDL_WindowShaper* X11_CreateShaper(SDL_Window* window); -extern int X11_ResizeWindowShape(SDL_Window* window); -extern int X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode); +extern SDL_WindowShaper *X11_CreateShaper(SDL_Window *window); +extern int X11_ResizeWindowShape(SDL_Window *window); +extern int X11_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shapeMode); #endif /* SDL_x11shape_h_ */ diff --git a/src/video/x11/SDL_x11touch.c b/src/video/x11/SDL_x11touch.c index c608cf24d..6d800363b 100644 --- a/src/video/x11/SDL_x11touch.c +++ b/src/video/x11/SDL_x11touch.c @@ -27,21 +27,17 @@ #include "SDL_x11xinput2.h" #include "../../events/SDL_touch_c.h" - -void -X11_InitTouch(_THIS) +void X11_InitTouch(_THIS) { X11_InitXinput2Multitouch(_this); } -void -X11_QuitTouch(_THIS) +void X11_QuitTouch(_THIS) { SDL_TouchQuit(); } -void -X11_ResetTouch(_THIS) +void X11_ResetTouch(_THIS) { X11_QuitTouch(_this); X11_InitTouch(_this); diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 42d3f9e5e..e3f2e24bb 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -49,8 +49,7 @@ static int X11_VideoInit(_THIS); static void X11_VideoQuit(_THIS); /* Find out what class name we should use */ -static char * -get_classname() +static char *get_classname() { char *spot; #if defined(__LINUX__) || defined(__FREEBSD__) @@ -93,12 +92,11 @@ get_classname() /* X11 driver bootstrap functions */ -static int (*orig_x11_errhandler) (Display *, XErrorEvent *) = NULL; +static int (*orig_x11_errhandler)(Display *, XErrorEvent *) = NULL; -static void -X11_DeleteDevice(SDL_VideoDevice * device) +static void X11_DeleteDevice(SDL_VideoDevice *device) { - SDL_VideoData *data = (SDL_VideoData *) device->driverdata; + SDL_VideoData *data = (SDL_VideoData *)device->driverdata; if (device->vulkan_config.loader_handle) { device->Vulkan_UnloadLibrary(device); } @@ -121,8 +119,7 @@ X11_DeleteDevice(SDL_VideoDevice * device) /* An error handler to reset the vidmode and then call the default handler. */ static SDL_bool safety_net_triggered = SDL_FALSE; -static int -X11_SafetyNetErrHandler(Display * d, XErrorEvent * e) +static int X11_SafetyNetErrHandler(Display *d, XErrorEvent *e) { SDL_VideoDevice *device = NULL; /* if we trigger an error in our error handler, don't try again. */ @@ -134,7 +131,7 @@ X11_SafetyNetErrHandler(Display * d, XErrorEvent * e) for (i = 0; i < device->num_displays; i++) { SDL_VideoDisplay *display = &device->displays[i]; if (SDL_memcmp(&display->current_mode, &display->desktop_mode, - sizeof (SDL_DisplayMode)) != 0) { + sizeof(SDL_DisplayMode)) != 0) { X11_SetDisplayMode(device, display, &display->desktop_mode); } } @@ -142,14 +139,13 @@ X11_SafetyNetErrHandler(Display * d, XErrorEvent * e) } if (orig_x11_errhandler != NULL) { - return orig_x11_errhandler(d, e); /* probably terminate. */ + return orig_x11_errhandler(d, e); /* probably terminate. */ } return 0; } -static SDL_VideoDevice * -X11_CreateDevice(void) +static SDL_VideoDevice *X11_CreateDevice(void) { SDL_VideoDevice *device; SDL_VideoData *data; @@ -173,12 +169,12 @@ X11_CreateDevice(void) } /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device == NULL) { SDL_OutOfMemory(); return NULL; } - data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); + data = (struct SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); if (data == NULL) { SDL_free(device); SDL_OutOfMemory(); @@ -334,9 +330,8 @@ VideoBootStrap X11_bootstrap = { X11_CreateDevice }; -static int (*handler) (Display *, XErrorEvent *) = NULL; -static int -X11_CheckWindowManagerErrorHandler(Display * d, XErrorEvent * e) +static int (*handler)(Display *, XErrorEvent *) = NULL; +static int X11_CheckWindowManagerErrorHandler(Display *d, XErrorEvent *e) { if (e->error_code == BadWindow) { return 0; @@ -345,10 +340,9 @@ X11_CheckWindowManagerErrorHandler(Display * d, XErrorEvent * e) } } -static void -X11_CheckWindowManager(_THIS) +static void X11_CheckWindowManager(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; Display *display = data->display; Atom _NET_SUPPORTING_WM_CHECK; int status, real_format; @@ -368,7 +362,7 @@ X11_CheckWindowManager(_THIS) status = X11_XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata); if (status == Success) { if (items_read) { - wm_window = ((Window*)propdata)[0]; + wm_window = ((Window *)propdata)[0]; } if (propdata) { X11_XFree(propdata); @@ -378,7 +372,7 @@ X11_CheckWindowManager(_THIS) if (wm_window) { status = X11_XGetWindowProperty(display, wm_window, _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata); - if (status != Success || !items_read || wm_window != ((Window*)propdata)[0]) { + if (status != Success || !items_read || wm_window != ((Window *)propdata)[0]) { wm_window = None; } if (status == Success && propdata) { @@ -406,11 +400,9 @@ X11_CheckWindowManager(_THIS) #endif } - -int -X11_VideoInit(_THIS) +int X11_VideoInit(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; /* Get the window class name, usually the name of the application */ data->classname = get_classname(); @@ -419,7 +411,7 @@ X11_VideoInit(_THIS) data->pid = getpid(); /* I have no idea how random this actually is, or has to be. */ - data->window_group = (XID) (((size_t) data->pid) ^ ((size_t) _this)); + data->window_group = (XID)(((size_t)data->pid) ^ ((size_t)_this)); /* Look up some useful Atoms */ #define GET_ATOM(X) data->X = X11_XInternAtom(data->display, #X, False) @@ -486,10 +478,9 @@ X11_VideoInit(_THIS) return 0; } -void -X11_VideoQuit(_THIS) +void X11_VideoQuit(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; if (data->clipboard_window) { X11_XDestroyWindow(data->display, data->clipboard_window); diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h index 511ed365c..6f3ae35ca 100644 --- a/src/video/x11/SDL_x11video.h +++ b/src/video/x11/SDL_x11video.h @@ -126,7 +126,7 @@ typedef struct SDL_VideoData SDL_Scancode key_layout[256]; SDL_bool selection_waiting; - SDL_bool broken_pointer_grab; /* true if XGrabPointer seems unreliable. */ + SDL_bool broken_pointer_grab; /* true if XGrabPointer seems unreliable. */ Uint32 last_mode_change_deadline; @@ -144,7 +144,7 @@ typedef struct SDL_VideoData int xkb_event; KeyCode filter_code; - Time filter_time; + Time filter_time; #if SDL_VIDEO_VULKAN /* Vulkan variables only valid if _this->vulkan_config.loader_handle is not NULL */ diff --git a/src/video/x11/SDL_x11vulkan.c b/src/video/x11/SDL_x11vulkan.c index 2bdce9821..c7fbd1fc5 100644 --- a/src/video/x11/SDL_x11vulkan.c +++ b/src/video/x11/SDL_x11vulkan.c @@ -31,9 +31,9 @@ /*#include */ #if defined(__OpenBSD__) -#define DEFAULT_VULKAN "libvulkan.so" +#define DEFAULT_VULKAN "libvulkan.so" #else -#define DEFAULT_VULKAN "libvulkan.so.1" +#define DEFAULT_VULKAN "libvulkan.so.1" #endif /* @@ -86,8 +86,7 @@ int X11_Vulkan_LoadLibrary(_THIS, const char *path) if (extensions == NULL) { goto fail; } - for (i = 0; i < extensionCount; i++) - { + for (i = 0; i < extensionCount; i++) { if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { hasSurfaceExtension = SDL_TRUE; } else if (SDL_strcmp(VK_KHR_XCB_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { @@ -98,16 +97,13 @@ int X11_Vulkan_LoadLibrary(_THIS, const char *path) } SDL_free(extensions); if (!hasSurfaceExtension) { - SDL_SetError("Installed Vulkan doesn't implement the " - VK_KHR_SURFACE_EXTENSION_NAME " extension"); + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_SURFACE_EXTENSION_NAME " extension"); goto fail; } if (hasXlibSurfaceExtension) { videoData->vulkan_xlib_xcb_library = NULL; } else if (!hasXCBSurfaceExtension) { - SDL_SetError("Installed Vulkan doesn't implement either the " - VK_KHR_XCB_SURFACE_EXTENSION_NAME "extension or the " - VK_KHR_XLIB_SURFACE_EXTENSION_NAME " extension"); + SDL_SetError("Installed Vulkan doesn't implement either the " VK_KHR_XCB_SURFACE_EXTENSION_NAME "extension or the " VK_KHR_XLIB_SURFACE_EXTENSION_NAME " extension"); goto fail; } else { const char *libX11XCBLibraryName = SDL_getenv("SDL_X11_XCB_LIBRARY"); @@ -157,13 +153,15 @@ SDL_bool X11_Vulkan_GetInstanceExtensions(_THIS, } if (videoData->vulkan_xlib_xcb_library) { static const char *const extensionsForXCB[] = { - VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_XCB_SURFACE_EXTENSION_NAME, + VK_KHR_SURFACE_EXTENSION_NAME, + VK_KHR_XCB_SURFACE_EXTENSION_NAME, }; return SDL_Vulkan_GetInstanceExtensions_Helper( count, names, SDL_arraysize(extensionsForXCB), extensionsForXCB); } else { static const char *const extensionsForXlib[] = { - VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_XLIB_SURFACE_EXTENSION_NAME, + VK_KHR_SURFACE_EXTENSION_NAME, + VK_KHR_XLIB_SURFACE_EXTENSION_NAME, }; return SDL_Vulkan_GetInstanceExtensions_Helper( count, names, SDL_arraysize(extensionsForXlib), extensionsForXlib); diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 4c5d5de8b..682604bb7 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -42,16 +42,16 @@ #include "SDL_timer.h" #include "SDL_syswm.h" -#define _NET_WM_STATE_REMOVE 0l -#define _NET_WM_STATE_ADD 1l +#define _NET_WM_STATE_REMOVE 0l +#define _NET_WM_STATE_ADD 1l static Bool isMapNotify(Display *dpy, XEvent *ev, XPointer win) { - return ev->type == MapNotify && ev->xmap.window == *((Window*)win); + return ev->type == MapNotify && ev->xmap.window == *((Window *)win); } static Bool isUnmapNotify(Display *dpy, XEvent *ev, XPointer win) { - return ev->type == UnmapNotify && ev->xunmap.window == *((Window*)win); + return ev->type == UnmapNotify && ev->xunmap.window == *((Window *)win); } /* @@ -59,8 +59,7 @@ static Bool isConfigureNotify(Display *dpy, XEvent *ev, XPointer win) { return ev->type == ConfigureNotify && ev->xconfigure.window == *((Window*)win); } -static Bool -X11_XIfEventTimeout(Display *display, XEvent *event_return, Bool (*predicate)(), XPointer arg, int timeoutMS) +static Bool X11_XIfEventTimeout(Display *display, XEvent *event_return, Bool (*predicate)(), XPointer arg, int timeoutMS) { Uint32 start = SDL_GetTicks(); @@ -73,11 +72,10 @@ X11_XIfEventTimeout(Display *display, XEvent *event_return, Bool (*predicate)(), } */ -static SDL_bool -X11_IsWindowMapped(_THIS, SDL_Window * window) +static SDL_bool X11_IsWindowMapped(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; XWindowAttributes attr; X11_XGetWindowAttributes(videodata->display, data->xwindow, &attr); @@ -89,8 +87,7 @@ X11_IsWindowMapped(_THIS, SDL_Window * window) } #if 0 -static SDL_bool -X11_IsActionAllowed(SDL_Window *window, Atom action) +static SDL_bool X11_IsActionAllowed(SDL_Window *window, Atom action) { SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Atom _NET_WM_ALLOWED_ACTIONS = data->videodata->_NET_WM_ALLOWED_ACTIONS; @@ -115,10 +112,9 @@ X11_IsActionAllowed(SDL_Window *window, Atom action) } #endif /* 0 */ -void -X11_SetNetWMState(_THIS, Window xwindow, Uint32 flags) +void X11_SetNetWMState(_THIS, Window xwindow, Uint32 flags) { - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; Display *display = videodata->display; /* !!! FIXME: just dereference videodata below instead of copying to locals. */ Atom _NET_WM_STATE = videodata->_NET_WM_STATE; @@ -164,7 +160,7 @@ X11_SetNetWMState(_THIS, Window xwindow, Uint32 flags) if (count > 0) { X11_XChangeProperty(display, xwindow, _NET_WM_STATE, XA_ATOM, 32, - PropModeReplace, (unsigned char *)atoms, count); + PropModeReplace, (unsigned char *)atoms, count); } else { X11_XDeleteProperty(display, xwindow, _NET_WM_STATE); } @@ -173,7 +169,7 @@ X11_SetNetWMState(_THIS, Window xwindow, Uint32 flags) Uint32 X11_GetNetWMState(_THIS, SDL_Window *window, Window xwindow) { - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; Display *display = videodata->display; Atom _NET_WM_STATE = videodata->_NET_WM_STATE; Atom _NET_WM_STATE_HIDDEN = videodata->_NET_WM_STATE_HIDDEN; @@ -189,10 +185,10 @@ X11_GetNetWMState(_THIS, SDL_Window *window, Window xwindow) Uint32 flags = 0; if (X11_XGetWindowProperty(display, xwindow, _NET_WM_STATE, - 0l, maxLength, False, XA_ATOM, &actualType, - &actualFormat, &numItems, &bytesAfter, - &propertyValue) == Success) { - Atom *atoms = (Atom *) propertyValue; + 0l, maxLength, False, XA_ATOM, &actualType, + &actualFormat, &numItems, &bytesAfter, + &propertyValue) == Success) { + Atom *atoms = (Atom *)propertyValue; int maximized = 0; int fullscreen = 0; @@ -205,7 +201,7 @@ X11_GetNetWMState(_THIS, SDL_Window *window, Window xwindow) maximized |= 1; } else if (atoms[i] == _NET_WM_STATE_MAXIMIZED_HORZ) { maximized |= 2; - } else if ( atoms[i] == _NET_WM_STATE_FULLSCREEN) { + } else if (atoms[i] == _NET_WM_STATE_FULLSCREEN) { fullscreen = 1; } } @@ -230,14 +226,13 @@ X11_GetNetWMState(_THIS, SDL_Window *window, Window xwindow) } } - /* If the window is unmapped, numItems will be zero and _NET_WM_STATE_HIDDEN * will not be set. Do an additional check to see if the window is unmapped * and mark it as SDL_WINDOW_HIDDEN if it is. */ { XWindowAttributes attr; - SDL_memset(&attr,0,sizeof(attr)); + SDL_memset(&attr, 0, sizeof(attr)); X11_XGetWindowAttributes(videodata->display, xwindow, &attr); if (attr.map_state == IsUnmapped) { flags |= SDL_WINDOW_HIDDEN; @@ -252,17 +247,16 @@ X11_GetNetWMState(_THIS, SDL_Window *window, Window xwindow) return flags; } -static int -SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) +static int SetupWindowData(_THIS, SDL_Window *window, Window w, BOOL created) { - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; SDL_WindowData *data; int numwindows = videodata->numwindows; int windowlistlength = videodata->windowlistlength; SDL_WindowData **windowlist = videodata->windowlist; /* Allocate the window data */ - data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data)); + data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data)); if (data == NULL) { return SDL_OutOfMemory(); } @@ -273,8 +267,8 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) if (SDL_X11_HAVE_UTF8 && videodata->im) { data->ic = X11_XCreateIC(videodata->im, XNClientWindow, w, XNFocusWindow, w, - XNInputStyle, XIMPreeditNothing | XIMStatusNothing, - NULL); + XNInputStyle, XIMPreeditNothing | XIMStatusNothing, + NULL); } #endif data->created = created; @@ -287,9 +281,10 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) videodata->numwindows++; } else { windowlist = - (SDL_WindowData **) SDL_realloc(windowlist, - (numwindows + - 1) * sizeof(*windowlist)); + (SDL_WindowData **)SDL_realloc(windowlist, + (numwindows + + 1) * + sizeof(*windowlist)); if (windowlist == NULL) { SDL_free(data); return SDL_OutOfMemory(); @@ -322,9 +317,9 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) { Window FocalWindow; - int RevertTo=0; + int RevertTo = 0; X11_XGetInputFocus(data->videodata->display, &FocalWindow, &RevertTo); - if (FocalWindow==w) { + if (FocalWindow == w) { window->flags |= SDL_WINDOW_INPUT_FOCUS; } @@ -342,8 +337,7 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) return 0; } -static void -SetWindowBordered(Display *display, int screen, Window window, SDL_bool border) +static void SetWindowBordered(Display *display, int screen, Window window, SDL_bool border) { /* * this code used to check for KWM_WIN_DECORATION, but KDE hasn't @@ -366,19 +360,18 @@ SetWindowBordered(Display *display, int screen, Window window, SDL_bool border) }; X11_XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32, - PropModeReplace, (unsigned char *) &MWMHints, - sizeof(MWMHints) / sizeof(long)); - } else { /* set the transient hints instead, if necessary */ + PropModeReplace, (unsigned char *)&MWMHints, + sizeof(MWMHints) / sizeof(long)); + } else { /* set the transient hints instead, if necessary */ X11_XSetTransientForHint(display, window, RootWindow(display, screen)); } } -int -X11_CreateWindow(_THIS, SDL_Window * window) +int X11_CreateWindow(_THIS, SDL_Window *window) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; SDL_DisplayData *displaydata = - (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; + (SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata; const SDL_bool force_override_redirect = SDL_GetHintBoolean(SDL_HINT_X11_FORCE_OVERRIDE_REDIRECT, SDL_FALSE); SDL_WindowData *windowdata; Display *display = data->display; @@ -417,7 +410,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) return -1; } } else if ((window->flags & SDL_WINDOW_OPENGL) && - !SDL_getenv("SDL_VIDEO_X11_VISUALID")) { + !SDL_getenv("SDL_VIDEO_X11_VISUALID")) { XVisualInfo *vinfo = NULL; #if SDL_VIDEO_OPENGL_EGL @@ -464,7 +457,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) xattr.colormap = X11_XCreateColormap(display, RootWindow(display, screen), - visual, AllocAll); + visual, AllocAll); /* If we can't create a colormap, then we must die */ if (!xattr.colormap) { @@ -530,7 +523,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) } else { xattr.colormap = X11_XCreateColormap(display, RootWindow(display, screen), - visual, AllocNone); + visual, AllocNone); } /* Always create this with the window->windowed.* fields; if we're @@ -540,10 +533,11 @@ X11_CreateWindow(_THIS, SDL_Window * window) migration to fullscreen after CreateSDLWindow returns, which will put all the SDL_Window fields and system state as expected. */ w = X11_XCreateWindow(display, RootWindow(display, screen), - window->windowed.x, window->windowed.y, window->windowed.w, window->windowed.h, - 0, depth, InputOutput, visual, - (CWOverrideRedirect | CWBackPixmap | CWBorderPixel | - CWBackingStore | CWColormap), &xattr); + window->windowed.x, window->windowed.y, window->windowed.w, window->windowed.h, + 0, depth, InputOutput, visual, + (CWOverrideRedirect | CWBackPixmap | CWBorderPixel | + CWBackingStore | CWColormap), + &xattr); if (!w) { return SDL_SetError("Couldn't create window"); } @@ -582,16 +576,16 @@ X11_CreateWindow(_THIS, SDL_Window * window) X11_XFree(classhints); /* Set the PID related to the window for the given hostname, if possible */ if (data->pid > 0) { - long pid = (long) data->pid; + long pid = (long)data->pid; _NET_WM_PID = X11_XInternAtom(display, "_NET_WM_PID", False); X11_XChangeProperty(display, w, _NET_WM_PID, XA_CARDINAL, 32, PropModeReplace, - (unsigned char *) &pid, 1); + (unsigned char *)&pid, 1); } /* Set the window manager state */ X11_SetNetWMState(_this, w, window->flags); - compositor = 2; /* don't disable compositing except for "normal" windows */ + compositor = 2; /* don't disable compositing except for "normal" windows */ if (window->flags & SDL_WINDOW_UTILITY) { wintype_name = "_NET_WM_WINDOW_TYPE_UTILITY"; @@ -599,23 +593,23 @@ X11_CreateWindow(_THIS, SDL_Window * window) wintype_name = "_NET_WM_WINDOW_TYPE_TOOLTIP"; } else if (window->flags & SDL_WINDOW_POPUP_MENU) { wintype_name = "_NET_WM_WINDOW_TYPE_POPUP_MENU"; - } else if ( ((hint = SDL_GetHint(SDL_HINT_X11_WINDOW_TYPE)) != NULL) && *hint ) { + } else if (((hint = SDL_GetHint(SDL_HINT_X11_WINDOW_TYPE)) != NULL) && *hint) { wintype_name = hint; } else { wintype_name = "_NET_WM_WINDOW_TYPE_NORMAL"; - compositor = 1; /* disable compositing for "normal" windows */ + compositor = 1; /* disable compositing for "normal" windows */ } /* Let the window manager know what type of window we are. */ _NET_WM_WINDOW_TYPE = X11_XInternAtom(display, "_NET_WM_WINDOW_TYPE", False); wintype = X11_XInternAtom(display, wintype_name, False); X11_XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32, - PropModeReplace, (unsigned char *)&wintype, 1); + PropModeReplace, (unsigned char *)&wintype, 1); if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, SDL_TRUE)) { _NET_WM_BYPASS_COMPOSITOR = X11_XInternAtom(display, "_NET_WM_BYPASS_COMPOSITOR", False); X11_XChangeProperty(display, w, _NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32, - PropModeReplace, - (unsigned char *)&compositor, 1); + PropModeReplace, + (unsigned char *)&compositor, 1); } { @@ -623,7 +617,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) int proto_count = 0; protocols[proto_count++] = data->WM_DELETE_WINDOW; /* Allow window to be deleted by the WM */ - protocols[proto_count++] = data->WM_TAKE_FOCUS; /* Since we will want to set input focus explicitly */ + protocols[proto_count++] = data->WM_TAKE_FOCUS; /* Since we will want to set input focus explicitly */ /* Default to using ping if there is no hint */ if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_NET_WM_PING, SDL_TRUE)) { @@ -639,23 +633,23 @@ X11_CreateWindow(_THIS, SDL_Window * window) X11_XDestroyWindow(display, w); return -1; } - windowdata = (SDL_WindowData *) window->driverdata; + windowdata = (SDL_WindowData *)window->driverdata; #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 || SDL_VIDEO_OPENGL_EGL - if ((window->flags & SDL_WINDOW_OPENGL) && + if ((window->flags & SDL_WINDOW_OPENGL) && ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) || SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE)) #if SDL_VIDEO_OPENGL_GLX && ( !_this->gl_data || X11_GL_UseEGL(_this) ) #endif ) { -#if SDL_VIDEO_OPENGL_EGL +#if SDL_VIDEO_OPENGL_EGL if (!_this->egl_data) { return -1; } /* Create the GLES window surface */ - windowdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) w); + windowdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType)w); if (windowdata->egl_surface == EGL_NO_SURFACE) { return SDL_SetError("Could not create GLES window surface"); @@ -665,7 +659,6 @@ X11_CreateWindow(_THIS, SDL_Window * window) #endif /* SDL_VIDEO_OPENGL_EGL */ } #endif - #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8 && windowdata->ic) { @@ -676,11 +669,11 @@ X11_CreateWindow(_THIS, SDL_Window * window) X11_Xinput2SelectTouch(_this, window); X11_XSelectInput(display, w, - (FocusChangeMask | EnterWindowMask | LeaveWindowMask | - ExposureMask | ButtonPressMask | ButtonReleaseMask | - PointerMotionMask | KeyPressMask | KeyReleaseMask | - PropertyChangeMask | StructureNotifyMask | - KeymapStateMask | fevent)); + (FocusChangeMask | EnterWindowMask | LeaveWindowMask | + ExposureMask | ButtonPressMask | ButtonReleaseMask | + PointerMotionMask | KeyPressMask | KeyReleaseMask | + PropertyChangeMask | StructureNotifyMask | + KeymapStateMask | fevent)); /* For _ICC_PROFILE. */ X11_XSelectInput(display, RootWindow(display, screen), PropertyChangeMask); @@ -690,10 +683,9 @@ X11_CreateWindow(_THIS, SDL_Window * window) return 0; } -int -X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) +int X11_CreateWindowFrom(_THIS, SDL_Window *window, const void *data) { - Window w = (Window) data; + Window w = (Window)data; window->title = X11_GetWindowTitle(_this, w); @@ -706,7 +698,7 @@ X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) char * X11_GetWindowTitle(_THIS, Window xwindow) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; Display *display = data->display; int status, real_format; Atom real_type; @@ -715,17 +707,17 @@ X11_GetWindowTitle(_THIS, Window xwindow) char *title = NULL; status = X11_XGetWindowProperty(display, xwindow, data->_NET_WM_NAME, - 0L, 8192L, False, data->UTF8_STRING, &real_type, &real_format, - &items_read, &items_left, &propdata); + 0L, 8192L, False, data->UTF8_STRING, &real_type, &real_format, + &items_read, &items_left, &propdata); if (status == Success && propdata) { - title = SDL_strdup(SDL_static_cast(char*, propdata)); + title = SDL_strdup(SDL_static_cast(char *, propdata)); X11_XFree(propdata); } else { status = X11_XGetWindowProperty(display, xwindow, XA_WM_NAME, - 0L, 8192L, False, XA_STRING, &real_type, &real_format, - &items_read, &items_left, &propdata); + 0L, 8192L, False, XA_STRING, &real_type, &real_format, + &items_read, &items_left, &propdata); if (status == Success && propdata) { - title = SDL_iconv_string("UTF-8", "", SDL_static_cast(char*, propdata), items_read+1); + title = SDL_iconv_string("UTF-8", "", SDL_static_cast(char *, propdata), items_read + 1); SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Failed to convert WM_NAME title expecting UTF8! Title: %s", title); X11_XFree(propdata); } else { @@ -736,10 +728,9 @@ X11_GetWindowTitle(_THIS, Window xwindow) return title; } -void -X11_SetWindowTitle(_THIS, SDL_Window * window) +void X11_SetWindowTitle(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Window xwindow = data->xwindow; Display *display = data->videodata->display; char *title = window->title ? window->title : ""; @@ -747,10 +738,9 @@ X11_SetWindowTitle(_THIS, SDL_Window * window) SDL_X11_SetWindowTitle(display, xwindow, title); } -void -X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) +void X11_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; Atom _NET_WM_ICON = data->videodata->_NET_WM_ICON; @@ -771,14 +761,14 @@ X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) propdata[1] = icon->h; dst = &propdata[2]; for (y = 0; y < icon->h; ++y) { - src = (Uint32*)((Uint8*)icon->pixels + y * icon->pitch); + src = (Uint32 *)((Uint8 *)icon->pixels + y * icon->pitch); for (x = 0; x < icon->w; ++x) { *dst++ = *src++; } } X11_XChangeProperty(display, data->xwindow, _NET_WM_ICON, XA_CARDINAL, - 32, PropModeReplace, (unsigned char *) propdata, - propsize); + 32, PropModeReplace, (unsigned char *)propdata, + propsize); } SDL_free(propdata); } else { @@ -788,8 +778,7 @@ X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) } static SDL_bool caught_x11_error = SDL_FALSE; -static int -X11_CatchAnyError(Display * d, XErrorEvent * e) +static int X11_CatchAnyError(Display *d, XErrorEvent *e) { /* this may happen during tumultuous times when we are polling anyhow, so just note we had an error and return control. */ @@ -797,15 +786,14 @@ X11_CatchAnyError(Display * d, XErrorEvent * e) return 0; } -void -X11_SetWindowPosition(_THIS, SDL_Window * window) +void X11_SetWindowPosition(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; - int (*prev_handler) (Display *, XErrorEvent *) = NULL; + int (*prev_handler)(Display *, XErrorEvent *) = NULL; unsigned int childCount; Window childReturn, root, parent; - Window* children; + Window *children; XWindowAttributes attrs; int orig_x, orig_y; Uint32 timeout; @@ -838,9 +826,9 @@ X11_SetWindowPosition(_THIS, SDL_Window * window) if ((x != orig_x) || (y != orig_y)) { window->x = x; window->y = y; - break; /* window moved, time to go. */ + break; /* window moved, time to go. */ } else if ((x == window->x) && (y == window->y)) { - break; /* we're at the place we wanted to be anyhow, drop out. */ + break; /* we're at the place we wanted to be anyhow, drop out. */ } } @@ -855,25 +843,24 @@ X11_SetWindowPosition(_THIS, SDL_Window * window) caught_x11_error = SDL_FALSE; } -void -X11_SetWindowMinimumSize(_THIS, SDL_Window * window) +void X11_SetWindowMinimumSize(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; if (window->flags & SDL_WINDOW_RESIZABLE) { - XSizeHints *sizehints = X11_XAllocSizeHints(); - long userhints; + XSizeHints *sizehints = X11_XAllocSizeHints(); + long userhints; - X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); + X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); - sizehints->min_width = window->min_w; - sizehints->min_height = window->min_h; - sizehints->flags |= PMinSize; + sizehints->min_width = window->min_w; + sizehints->min_height = window->min_h; + sizehints->flags |= PMinSize; - X11_XSetWMNormalHints(display, data->xwindow, sizehints); + X11_XSetWMNormalHints(display, data->xwindow, sizehints); - X11_XFree(sizehints); + X11_XFree(sizehints); /* See comment in X11_SetWindowSize. */ X11_XResizeWindow(display, data->xwindow, window->w, window->h); @@ -884,25 +871,24 @@ X11_SetWindowMinimumSize(_THIS, SDL_Window * window) X11_XFlush(display); } -void -X11_SetWindowMaximumSize(_THIS, SDL_Window * window) +void X11_SetWindowMaximumSize(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; if (window->flags & SDL_WINDOW_RESIZABLE) { - XSizeHints *sizehints = X11_XAllocSizeHints(); - long userhints; + XSizeHints *sizehints = X11_XAllocSizeHints(); + long userhints; - X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); + X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); - sizehints->max_width = window->max_w; - sizehints->max_height = window->max_h; - sizehints->flags |= PMaxSize; + sizehints->max_width = window->max_w; + sizehints->max_height = window->max_h; + sizehints->flags |= PMaxSize; - X11_XSetWMNormalHints(display, data->xwindow, sizehints); + X11_XSetWMNormalHints(display, data->xwindow, sizehints); - X11_XFree(sizehints); + X11_XFree(sizehints); /* See comment in X11_SetWindowSize. */ X11_XResizeWindow(display, data->xwindow, window->w, window->h); @@ -913,12 +899,11 @@ X11_SetWindowMaximumSize(_THIS, SDL_Window * window) X11_XFlush(display); } -void -X11_SetWindowSize(_THIS, SDL_Window * window) +void X11_SetWindowSize(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; - int (*prev_handler) (Display *, XErrorEvent *) = NULL; + int (*prev_handler)(Display *, XErrorEvent *) = NULL; XWindowAttributes attrs; int orig_w, orig_h; Uint32 timeout; @@ -932,20 +917,20 @@ X11_SetWindowSize(_THIS, SDL_Window * window) X11_ResizeWindowShape(window); } if (!(window->flags & SDL_WINDOW_RESIZABLE)) { - /* Apparently, if the X11 Window is set to a 'non-resizable' window, you cannot resize it using the X11_XResizeWindow, thus - we must set the size hints to adjust the window size. */ - XSizeHints *sizehints = X11_XAllocSizeHints(); - long userhints; + /* Apparently, if the X11 Window is set to a 'non-resizable' window, you cannot resize it using the X11_XResizeWindow, thus + we must set the size hints to adjust the window size. */ + XSizeHints *sizehints = X11_XAllocSizeHints(); + long userhints; - X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); + X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); - sizehints->min_width = sizehints->max_width = window->w; - sizehints->min_height = sizehints->max_height = window->h; - sizehints->flags |= PMinSize | PMaxSize; + sizehints->min_width = sizehints->max_width = window->w; + sizehints->min_height = sizehints->max_height = window->h; + sizehints->flags |= PMinSize | PMaxSize; - X11_XSetWMNormalHints(display, data->xwindow, sizehints); + X11_XSetWMNormalHints(display, data->xwindow, sizehints); - X11_XFree(sizehints); + X11_XFree(sizehints); /* From Pierre-Loup: WMs each have their little quirks with that. When you change the @@ -985,9 +970,9 @@ X11_SetWindowSize(_THIS, SDL_Window * window) if ((attrs.width != orig_w) || (attrs.height != orig_h)) { window->w = attrs.width; window->h = attrs.height; - break; /* window changed, time to go. */ + break; /* window changed, time to go. */ } else if ((attrs.width == window->w) && (attrs.height == window->h)) { - break; /* we're at the place we wanted to be anyhow, drop out. */ + break; /* we're at the place we wanted to be anyhow, drop out. */ } } @@ -1002,8 +987,7 @@ X11_SetWindowSize(_THIS, SDL_Window * window) caught_x11_error = SDL_FALSE; } -int -X11_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *bottom, int *right) +int X11_GetWindowBordersSize(_THIS, SDL_Window *window, int *top, int *left, int *bottom, int *right) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; @@ -1015,10 +999,9 @@ X11_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *b return 0; } -int -X11_SetWindowOpacity(_THIS, SDL_Window * window, float opacity) +int X11_SetWindowOpacity(_THIS, SDL_Window *window, float opacity) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; Atom _NET_WM_WINDOW_OPACITY = data->videodata->_NET_WM_WINDOW_OPACITY; @@ -1026,29 +1009,28 @@ X11_SetWindowOpacity(_THIS, SDL_Window * window, float opacity) X11_XDeleteProperty(display, data->xwindow, _NET_WM_WINDOW_OPACITY); } else { const Uint32 FullyOpaque = 0xFFFFFFFF; - const long alpha = (long) ((double)opacity * (double)FullyOpaque); + const long alpha = (long)((double)opacity * (double)FullyOpaque); X11_XChangeProperty(display, data->xwindow, _NET_WM_WINDOW_OPACITY, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *)&alpha, 1); + PropModeReplace, (unsigned char *)&alpha, 1); } return 0; } -int -X11_SetWindowModalFor(_THIS, SDL_Window * modal_window, SDL_Window * parent_window) { - SDL_WindowData *data = (SDL_WindowData *) modal_window->driverdata; - SDL_WindowData *parent_data = (SDL_WindowData *) parent_window->driverdata; +int X11_SetWindowModalFor(_THIS, SDL_Window *modal_window, SDL_Window *parent_window) +{ + SDL_WindowData *data = (SDL_WindowData *)modal_window->driverdata; + SDL_WindowData *parent_data = (SDL_WindowData *)parent_window->driverdata; Display *display = data->videodata->display; X11_XSetTransientForHint(display, data->xwindow, parent_data->xwindow); return 0; } -int -X11_SetWindowInputFocus(_THIS, SDL_Window * window) +int X11_SetWindowInputFocus(_THIS, SDL_Window *window) { if (X11_IsWindowMapped(_this, window)) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; X11_XSetInputFocus(display, data->xwindow, RevertToNone, CurrentTime); X11_XFlush(display); @@ -1057,14 +1039,13 @@ X11_SetWindowInputFocus(_THIS, SDL_Window * window) return -1; } -void -X11_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) +void X11_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered) { const SDL_bool focused = ((window->flags & SDL_WINDOW_INPUT_FOCUS) != 0); const SDL_bool visible = ((window->flags & SDL_WINDOW_HIDDEN) == 0); - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_DisplayData *displaydata = - (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; + (SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata; Display *display = data->videodata->display; XEvent event; @@ -1093,10 +1074,9 @@ X11_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) X11_XSync(display, False); } -void -X11_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable) +void X11_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; XSizeHints *sizehints = X11_XAllocSizeHints(); @@ -1131,11 +1111,10 @@ X11_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable) X11_XFlush(display); } -void -X11_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top) +void X11_SetWindowAlwaysOnTop(_THIS, SDL_Window *window, SDL_bool on_top) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; + SDL_DisplayData *displaydata = (SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata; Display *display = data->videodata->display; Atom _NET_WM_STATE = data->videodata->_NET_WM_STATE; Atom _NET_WM_STATE_ABOVE = data->videodata->_NET_WM_STATE_ABOVE; @@ -1154,17 +1133,16 @@ X11_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top) e.xclient.data.l[3] = 0l; X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, - SubstructureNotifyMask | SubstructureRedirectMask, &e); + SubstructureNotifyMask | SubstructureRedirectMask, &e); } else { X11_SetNetWMState(_this, data->xwindow, window->flags); } X11_XFlush(display); } -void -X11_ShowWindow(_THIS, SDL_Window * window) +void X11_ShowWindow(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; XEvent event; @@ -1187,11 +1165,10 @@ X11_ShowWindow(_THIS, SDL_Window * window) } } -void -X11_HideWindow(_THIS, SDL_Window * window) +void X11_HideWindow(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; + SDL_DisplayData *displaydata = (SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata; Display *display = data->videodata->display; XEvent event; @@ -1205,12 +1182,11 @@ X11_HideWindow(_THIS, SDL_Window * window) } } -static void -SetWindowActive(_THIS, SDL_Window * window) +static void SetWindowActive(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_DisplayData *displaydata = - (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; + (SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata; Display *display = data->videodata->display; Atom _NET_ACTIVE_WINDOW = data->videodata->_NET_ACTIVE_WINDOW; @@ -1224,21 +1200,20 @@ SetWindowActive(_THIS, SDL_Window * window) e.xclient.message_type = _NET_ACTIVE_WINDOW; e.xclient.format = 32; e.xclient.window = data->xwindow; - e.xclient.data.l[0] = 1; /* source indication. 1 = application */ + e.xclient.data.l[0] = 1; /* source indication. 1 = application */ e.xclient.data.l[1] = data->user_time; e.xclient.data.l[2] = 0; X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, - SubstructureNotifyMask | SubstructureRedirectMask, &e); + SubstructureNotifyMask | SubstructureRedirectMask, &e); X11_XFlush(display); } } -void -X11_RaiseWindow(_THIS, SDL_Window * window) +void X11_RaiseWindow(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; X11_XRaiseWindow(display, data->xwindow); @@ -1246,12 +1221,11 @@ X11_RaiseWindow(_THIS, SDL_Window * window) X11_XFlush(display); } -static void -SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized) +static void SetWindowMaximized(_THIS, SDL_Window *window, SDL_bool maximized) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_DisplayData *displaydata = - (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; + (SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata; Display *display = data->videodata->display; Atom _NET_WM_STATE = data->videodata->_NET_WM_STATE; Atom _NET_WM_STATE_MAXIMIZED_VERT = data->videodata->_NET_WM_STATE_MAXIMIZED_VERT; @@ -1286,33 +1260,30 @@ SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized) e.xclient.data.l[3] = 0l; X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, - SubstructureNotifyMask | SubstructureRedirectMask, &e); + SubstructureNotifyMask | SubstructureRedirectMask, &e); } else { X11_SetNetWMState(_this, data->xwindow, window->flags); } X11_XFlush(display); } -void -X11_MaximizeWindow(_THIS, SDL_Window * window) +void X11_MaximizeWindow(_THIS, SDL_Window *window) { SetWindowMaximized(_this, window, SDL_TRUE); } -void -X11_MinimizeWindow(_THIS, SDL_Window * window) +void X11_MinimizeWindow(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_DisplayData *displaydata = - (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; + (SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata; Display *display = data->videodata->display; X11_XIconifyWindow(display, data->xwindow, displaydata->screen); X11_XFlush(display); } -void -X11_RestoreWindow(_THIS, SDL_Window * window) +void X11_RestoreWindow(_THIS, SDL_Window *window) { SetWindowMaximized(_this, window, SDL_FALSE); X11_ShowWindow(_this, window); @@ -1320,11 +1291,10 @@ X11_RestoreWindow(_THIS, SDL_Window * window) } /* This asks the Window Manager to handle fullscreen for us. This is the modern way. */ -static void -X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _display, SDL_bool fullscreen) +static void X11_SetWindowFullscreenViaWM(_THIS, SDL_Window *window, SDL_VideoDisplay *_display, SDL_bool fullscreen) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - SDL_DisplayData *displaydata = (SDL_DisplayData *) _display->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; + SDL_DisplayData *displaydata = (SDL_DisplayData *)_display->driverdata; Display *display = data->videodata->display; Atom _NET_WM_STATE = data->videodata->_NET_WM_STATE; Atom _NET_WM_STATE_FULLSCREEN = data->videodata->_NET_WM_STATE_FULLSCREEN; @@ -1332,10 +1302,10 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis if (X11_IsWindowMapped(_this, window)) { XEvent e; /* !!! FIXME: most of this waiting code is copy/pasted from elsewhere. */ - int (*prev_handler) (Display *, XErrorEvent *) = NULL; + int (*prev_handler)(Display *, XErrorEvent *) = NULL; unsigned int childCount; Window childReturn, root, parent; - Window* children; + Window *children; XWindowAttributes attrs; int orig_w, orig_h, orig_x, orig_y; Uint64 timeout; @@ -1379,7 +1349,7 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis e.xclient.data.l[3] = 0l; X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, - SubstructureNotifyMask | SubstructureRedirectMask, &e); + SubstructureNotifyMask | SubstructureRedirectMask, &e); /* Fullscreen windows sometimes end up being marked maximized by window managers. Force it back to how we expect it to be. */ @@ -1398,7 +1368,7 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis e.xclient.data.l[2] = data->videodata->_NET_WM_STATE_MAXIMIZED_HORZ; e.xclient.data.l[3] = 0l; X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, - SubstructureNotifyMask | SubstructureRedirectMask, &e); + SubstructureNotifyMask | SubstructureRedirectMask, &e); } /* Wait a brief time to see if the window manager decided to let this happen. @@ -1429,7 +1399,7 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis } if (window_changed) { - break; /* window changed, time to go. */ + break; /* window changed, time to go. */ } } @@ -1455,7 +1425,7 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis } if (data->visual->class == DirectColor) { - if ( fullscreen ) { + if (fullscreen) { X11_XInstallColormap(display, data->colormap); } else { X11_XUninstallColormap(display, data->colormap); @@ -1465,8 +1435,7 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis X11_XFlush(display); } -void -X11_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * _display, SDL_bool fullscreen) +void X11_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *_display, SDL_bool fullscreen) { X11_SetWindowFullscreenViaWM(_this, window, _display, fullscreen); } @@ -1549,7 +1518,7 @@ typedef struct { */ static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) { - unsigned char *ret=NULL; + unsigned char *ret = NULL; Atom type; int fmt; unsigned long count; @@ -1564,22 +1533,22 @@ static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) bytes_fetch += bytes_left; } while (bytes_left != 0); - p->data=ret; - p->format=fmt; - p->count=count; - p->type=type; + p->data = ret; + p->format = fmt; + p->count = count; + p->type = type; } -void* -X11_GetWindowICCProfile(_THIS, SDL_Window * window, size_t * size) +void * +X11_GetWindowICCProfile(_THIS, SDL_Window *window, size_t *size) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; XWindowAttributes attributes; Atom icc_profile_atom; char icc_atom_string[sizeof("_ICC_PROFILE_") + 12]; - void* ret_icc_profile_data = NULL; - CARD8* icc_profile_data; + void *ret_icc_profile_data = NULL; + CARD8 *icc_profile_data; int real_format; unsigned long real_nitems; SDL_x11Prop atomProp; @@ -1616,14 +1585,13 @@ X11_GetWindowICCProfile(_THIS, SDL_Window * window, size_t * size) SDL_memcpy(ret_icc_profile_data, icc_profile_data, real_nitems); *size = real_nitems; X11_XFree(icc_profile_data); - + return ret_icc_profile_data; } -void -X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed) +void X11_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display; if (data == NULL) { @@ -1650,7 +1618,7 @@ X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed) /* Try for up to 5000ms (5s) to grab. If it still fails, stop trying. */ for (attempts = 0; attempts < 100; attempts++) { result = X11_XGrabPointer(display, data->xwindow, True, mask, GrabModeAsync, - GrabModeAsync, data->xwindow, None, CurrentTime); + GrabModeAsync, data->xwindow, None, CurrentTime); if (result == GrabSuccess) { data->mouse_grabbed = SDL_TRUE; break; @@ -1660,7 +1628,7 @@ X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed) if (result != GrabSuccess) { SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "The X server refused to let us grab the mouse. You might experience input bugs."); - data->videodata->broken_pointer_grab = SDL_TRUE; /* don't try again. */ + data->videodata->broken_pointer_grab = SDL_TRUE; /* don't try again. */ } } @@ -1676,10 +1644,9 @@ X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed) X11_XSync(display, False); } -void -X11_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed) +void X11_SetWindowKeyboardGrab(_THIS, SDL_Window *window, SDL_bool grabbed) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display; if (data == NULL) { @@ -1704,13 +1671,12 @@ X11_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed) X11_XSync(display, False); } -void -X11_DestroyWindow(_THIS, SDL_Window * window) +void X11_DestroyWindow(_THIS, SDL_Window *window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; if (window->shaper) { - SDL_ShapeData *shapedata = (SDL_ShapeData *) window->shaper->driverdata; + SDL_ShapeData *shapedata = (SDL_ShapeData *)window->shaper->driverdata; if (shapedata) { SDL_free(shapedata->bitmap); SDL_free(shapedata); @@ -1720,7 +1686,7 @@ X11_DestroyWindow(_THIS, SDL_Window * window) } if (data) { - SDL_VideoData *videodata = (SDL_VideoData *) data->videodata; + SDL_VideoData *videodata = (SDL_VideoData *)data->videodata; Display *display = videodata->display; int numwindows = videodata->numwindows; SDL_WindowData **windowlist = videodata->windowlist; @@ -1783,32 +1749,29 @@ X11_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) } } -int -X11_SetWindowHitTest(SDL_Window *window, SDL_bool enabled) +int X11_SetWindowHitTest(SDL_Window *window, SDL_bool enabled) { - return 0; /* just succeed, the real work is done elsewhere. */ + return 0; /* just succeed, the real work is done elsewhere. */ } -void -X11_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept) +void X11_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; Atom XdndAware = X11_XInternAtom(display, "XdndAware", False); if (accept) { Atom xdnd_version = 5; X11_XChangeProperty(display, data->xwindow, XdndAware, XA_ATOM, 32, - PropModeReplace, (unsigned char*)&xdnd_version, 1); + PropModeReplace, (unsigned char *)&xdnd_version, 1); } else { X11_XDeleteProperty(display, data->xwindow, XdndAware); } } -int -X11_FlashWindow(_THIS, SDL_Window * window, SDL_FlashOperation operation) +int X11_FlashWindow(_THIS, SDL_Window *window, SDL_FlashOperation operation) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; XWMHints *wmhints; @@ -1851,10 +1814,11 @@ X11_FlashWindow(_THIS, SDL_Window * window, SDL_FlashOperation operation) return 0; } -int SDL_X11_SetWindowTitle(Display* display, Window xwindow, char* title) { +int SDL_X11_SetWindowTitle(Display *display, Window xwindow, char *title) +{ Atom _NET_WM_NAME = X11_XInternAtom(display, "_NET_WM_NAME", False); XTextProperty titleprop; - int conv = X11_XmbTextListToTextProperty(display, (char**) &title, 1, XTextStyle, &titleprop); + int conv = X11_XmbTextListToTextProperty(display, (char **)&title, 1, XTextStyle, &titleprop); Status status; if (X11_XSupportsLocale() != True) { @@ -1864,7 +1828,7 @@ int SDL_X11_SetWindowTitle(Display* display, Window xwindow, char* title) { if (conv == 0) { X11_XSetTextProperty(display, xwindow, &titleprop, XA_WM_NAME); X11_XFree(titleprop.value); - /* we know this can't be a locale error as we checked X locale validity */ + /* we know this can't be a locale error as we checked X locale validity */ } else if (conv < 0) { return SDL_OutOfMemory(); } else { /* conv > 0 */ @@ -1873,7 +1837,7 @@ int SDL_X11_SetWindowTitle(Display* display, Window xwindow, char* title) { } #ifdef X_HAVE_UTF8_STRING - status = X11_Xutf8TextListToTextProperty(display, (char **) &title, 1, XUTF8StringStyle, &titleprop); + status = X11_Xutf8TextListToTextProperty(display, (char **)&title, 1, XUTF8StringStyle, &titleprop); if (status == Success) { X11_XSetTextProperty(display, xwindow, &titleprop, _NET_WM_NAME); X11_XFree(titleprop.value); diff --git a/src/video/x11/SDL_x11window.h b/src/video/x11/SDL_x11window.h index 5298decc4..25a459a86 100644 --- a/src/video/x11/SDL_x11window.h +++ b/src/video/x11/SDL_x11window.h @@ -27,9 +27,9 @@ video mode changes and we can respond to them by triggering more mode changes. */ -#define PENDING_FOCUS_TIME 200 +#define PENDING_FOCUS_TIME 200 -#if SDL_VIDEO_OPENGL_EGL +#if SDL_VIDEO_OPENGL_EGL #include #endif @@ -70,7 +70,7 @@ typedef struct Window xdnd_source; SDL_bool flashing_window; Uint32 flash_cancel_time; -#if SDL_VIDEO_OPENGL_EGL +#if SDL_VIDEO_OPENGL_EGL EGLSurface egl_surface; #endif #if SDL_VIDEO_DRIVER_X11_XFIXES @@ -83,8 +83,8 @@ typedef struct extern void X11_SetNetWMState(_THIS, Window xwindow, Uint32 flags); extern Uint32 X11_GetNetWMState(_THIS, SDL_Window *window, Window xwindow); -extern int X11_CreateWindow(_THIS, SDL_Window * window); -extern int X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data); +extern int X11_CreateWindow(_THIS, SDL_Window *window); +extern int X11_CreateWindowFrom(_THIS, SDL_Window *window, const void *data); extern char *X11_GetWindowTitle(_THIS, Window xwindow); extern void X11_SetWindowTitle(_THIS, SDL_Window * window); extern void X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon); @@ -114,10 +114,10 @@ extern void X11_DestroyWindow(_THIS, SDL_Window * window); extern SDL_bool X11_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info); extern int X11_SetWindowHitTest(SDL_Window *window, SDL_bool enabled); -extern void X11_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept); -extern int X11_FlashWindow(_THIS, SDL_Window * window, SDL_FlashOperation operation); +extern void X11_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept); +extern int X11_FlashWindow(_THIS, SDL_Window *window, SDL_FlashOperation operation); -int SDL_X11_SetWindowTitle(Display* display, Window xwindow, char* string); +int SDL_X11_SetWindowTitle(Display *display, Window xwindow, char *string); #endif /* SDL_x11window_h_ */ diff --git a/src/video/x11/SDL_x11xfixes.c b/src/video/x11/SDL_x11xfixes.c index dfe3a4c64..5e05c62d5 100644 --- a/src/video/x11/SDL_x11xfixes.c +++ b/src/video/x11/SDL_x11xfixes.c @@ -30,24 +30,21 @@ static int xfixes_initialized = 0; -static int -query_xfixes_version(Display *display, int major, int minor) +static int query_xfixes_version(Display *display, int major, int minor) { /* We don't care if this fails, so long as it sets major/minor on it's way out the door. */ X11_XFixesQueryVersion(display, &major, &minor); return (major * 1000) + minor; } -static SDL_bool -xfixes_version_atleast(const int version, const int wantmajor, const int wantminor) +static SDL_bool xfixes_version_atleast(const int version, const int wantmajor, const int wantminor) { return version >= ((wantmajor * 1000) + wantminor); } -void -X11_InitXfixes(_THIS) +void X11_InitXfixes(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; int version = 0; int event, error; @@ -67,14 +64,12 @@ X11_InitXfixes(_THIS) xfixes_initialized = 1; } -int -X11_XfixesIsInitialized() +int X11_XfixesIsInitialized() { return xfixes_initialized; } -void -X11_SetWindowMouseRect(_THIS, SDL_Window * window) +void X11_SetWindowMouseRect(_THIS, SDL_Window *window) { if (SDL_RectEmpty(&window->mouse_rect)) { X11_ConfineCursorWithFlags(_this, window, NULL, 0); @@ -83,7 +78,7 @@ X11_SetWindowMouseRect(_THIS, SDL_Window * window) X11_ConfineCursorWithFlags(_this, window, &window->mouse_rect, 0); } else { /* Save the state for when we get focus again */ - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; + SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata; SDL_memcpy(&wdata->barrier_rect, &window->mouse_rect, sizeof(wdata->barrier_rect)); @@ -92,14 +87,13 @@ X11_SetWindowMouseRect(_THIS, SDL_Window * window) } } -int -X11_ConfineCursorWithFlags(_THIS, SDL_Window * window, const SDL_Rect * rect, int flags) +int X11_ConfineCursorWithFlags(_THIS, SDL_Window *window, const SDL_Rect *rect, int flags) { /* Yaakuro: For some reason Xfixes when confining inside a rect where the * edges exactly match, a rectangle the cursor 'slips' out of the barrier. * To prevent that the lines for the barriers will span the whole screen. */ - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; SDL_WindowData *wdata; if (!X11_XfixesIsInitialized()) { @@ -108,11 +102,11 @@ X11_ConfineCursorWithFlags(_THIS, SDL_Window * window, const SDL_Rect * rect, in /* If there is already a set of barriers active, disable them. */ if (data->active_cursor_confined_window) { - X11_DestroyPointerBarrier(_this, data->active_cursor_confined_window); + X11_DestroyPointerBarrier(_this, data->active_cursor_confined_window); } SDL_assert(window != NULL); - wdata = (SDL_WindowData *) window->driverdata; + wdata = (SDL_WindowData *)window->driverdata; /* If user did not specify an area to confine, destroy the barrier that was/is assigned to * this window it was assigned */ @@ -140,28 +134,28 @@ X11_ConfineCursorWithFlags(_THIS, SDL_Window * window, const SDL_Rect * rect, in /** Create the left barrier */ wdata->barrier[0] = X11_XFixesCreatePointerBarrier(data->display, wdata->xwindow, - x1, bounds.y, - x1, bounds.y + bounds.h, - BarrierPositiveX, - 0, NULL); + x1, bounds.y, + x1, bounds.y + bounds.h, + BarrierPositiveX, + 0, NULL); /** Create the right barrier */ wdata->barrier[1] = X11_XFixesCreatePointerBarrier(data->display, wdata->xwindow, - x2, bounds.y, - x2, bounds.y + bounds.h, - BarrierNegativeX, - 0, NULL); + x2, bounds.y, + x2, bounds.y + bounds.h, + BarrierNegativeX, + 0, NULL); /** Create the top barrier */ wdata->barrier[2] = X11_XFixesCreatePointerBarrier(data->display, wdata->xwindow, - bounds.x, y1, - bounds.x + bounds.w, y1, - BarrierPositiveY, - 0, NULL); + bounds.x, y1, + bounds.x + bounds.w, y1, + BarrierPositiveY, + 0, NULL); /** Create the bottom barrier */ wdata->barrier[3] = X11_XFixesCreatePointerBarrier(data->display, wdata->xwindow, - bounds.x, y2, - bounds.x + bounds.w, y2, - BarrierNegativeY, - 0, NULL); + bounds.x, y2, + bounds.x + bounds.w, y2, + BarrierNegativeY, + 0, NULL); X11_XFlush(data->display); @@ -182,13 +176,12 @@ X11_ConfineCursorWithFlags(_THIS, SDL_Window * window, const SDL_Rect * rect, in return 0; } -void -X11_DestroyPointerBarrier(_THIS, SDL_Window * window) +void X11_DestroyPointerBarrier(_THIS, SDL_Window *window) { int i; - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; if (window) { - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; + SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata; for (i = 0; i < 4; i++) { if (wdata->barrier[i] > 0) { diff --git a/src/video/x11/SDL_x11xfixes.h b/src/video/x11/SDL_x11xfixes.h index 7239d3fd2..aee668e6b 100644 --- a/src/video/x11/SDL_x11xfixes.h +++ b/src/video/x11/SDL_x11xfixes.h @@ -30,9 +30,9 @@ extern void X11_InitXfixes(_THIS); extern int X11_XfixesIsInitialized(void); -extern void X11_SetWindowMouseRect(_THIS, SDL_Window * window); -extern int X11_ConfineCursorWithFlags(_THIS, SDL_Window * window, const SDL_Rect * rect, int flags); -extern void X11_DestroyPointerBarrier(_THIS, SDL_Window * window); +extern void X11_SetWindowMouseRect(_THIS, SDL_Window *window); +extern int X11_ConfineCursorWithFlags(_THIS, SDL_Window *window, const SDL_Rect *rect, int flags); +extern void X11_DestroyPointerBarrier(_THIS, SDL_Window *window); #endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c index a23e58744..44392ef7f 100644 --- a/src/video/x11/SDL_x11xinput2.c +++ b/src/video/x11/SDL_x11xinput2.c @@ -42,18 +42,19 @@ static int xinput2_multitouch_supported = 0; * this extension */ static int xinput2_opcode; -static void parse_valuators(const double *input_values, const unsigned char *mask,int mask_len, - double *output_values,int output_values_len) { - int i = 0,z = 0; +static void parse_valuators(const double *input_values, const unsigned char *mask, int mask_len, + double *output_values, int output_values_len) +{ + int i = 0, z = 0; int top = mask_len * 8; if (top > MAX_AXIS) { top = MAX_AXIS; } - SDL_memset(output_values,0,output_values_len * sizeof(double)); + SDL_memset(output_values, 0, output_values_len * sizeof(double)); for (; i < top && z < output_values_len; i++) { if (XIMaskIsSet(mask, i)) { - const int value = (int) *input_values; + const int value = (int)*input_values; output_values[z] = value; input_values++; } @@ -61,23 +62,20 @@ static void parse_valuators(const double *input_values, const unsigned char *mas } } -static int -query_xinput2_version(Display *display, int major, int minor) +static int query_xinput2_version(Display *display, int major, int minor) { /* We don't care if this fails, so long as it sets major/minor on it's way out the door. */ X11_XIQueryVersion(display, &major, &minor); return (major * 1000) + minor; } -static SDL_bool -xinput2_version_atleast(const int version, const int wantmajor, const int wantminor) +static SDL_bool xinput2_version_atleast(const int version, const int wantmajor, const int wantminor) { return version >= ((wantmajor * 1000) + wantminor); } #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH -static SDL_Window * -xinput2_get_sdlwindow(SDL_VideoData *videodata, Window window) +static SDL_Window *xinput2_get_sdlwindow(SDL_VideoData *videodata, Window window) { int i; for (i = 0; i < videodata->numwindows; i++) { @@ -89,8 +87,7 @@ xinput2_get_sdlwindow(SDL_VideoData *videodata, Window window) return NULL; } -static void -xinput2_normalize_touch_coordinates(SDL_Window *window, double in_x, double in_y, float *out_x, float *out_y) +static void xinput2_normalize_touch_coordinates(SDL_Window *window, double in_x, double in_y, float *out_x, float *out_y) { if (window) { if (window->w == 1) { @@ -113,11 +110,10 @@ xinput2_normalize_touch_coordinates(SDL_Window *window, double in_x, double in_y #endif /* SDL_VIDEO_DRIVER_X11_XINPUT2 */ -void -X11_InitXinput2(_THIS) +void X11_InitXinput2(_THIS) { #if SDL_VIDEO_DRIVER_X11_XINPUT2 - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; int version = 0; XIEventMask eventmask; @@ -125,14 +121,14 @@ X11_InitXinput2(_THIS) int event, err; /* - * Initialize XInput 2 - * According to http://who-t.blogspot.com/2009/05/xi2-recipes-part-1.html its better - * to inform Xserver what version of Xinput we support.The server will store the version we support. - * "As XI2 progresses it becomes important that you use this call as the server may treat the client - * differently depending on the supported version". - * - * FIXME:event and err are not needed but if not passed X11_XQueryExtension returns SegmentationFault - */ + * Initialize XInput 2 + * According to http://who-t.blogspot.com/2009/05/xi2-recipes-part-1.html its better + * to inform Xserver what version of Xinput we support.The server will store the version we support. + * "As XI2 progresses it becomes important that you use this call as the server may treat the client + * differently depending on the supported version". + * + * FIXME:event and err are not needed but if not passed X11_XQueryExtension returns SegmentationFault + */ if (!SDL_X11_HAVE_XINPUT2 || !X11_XQueryExtension(data->display, "XInputExtension", &xinput2_opcode, &event, &err)) { return; /* X server does not have XInput at all */ @@ -146,7 +142,7 @@ X11_InitXinput2(_THIS) xinput2_initialized = 1; -#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH /* Multitouch needs XInput 2.2 */ +#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH /* Multitouch needs XInput 2.2 */ xinput2_multitouch_supported = xinput2_version_atleast(version, 2, 2); #endif @@ -186,8 +182,7 @@ X11_InitXinput2(_THIS) } /* xi2 device went away? take it out of the list. */ -static void -xinput2_remove_device_info(SDL_VideoData *videodata, const int device_id) +static void xinput2_remove_device_info(SDL_VideoData *videodata, const int device_id) { SDL_XInput2DeviceInfo *prev = NULL; SDL_XInput2DeviceInfo *devinfo; @@ -208,8 +203,7 @@ xinput2_remove_device_info(SDL_VideoData *videodata, const int device_id) } #if SDL_VIDEO_DRIVER_X11_XINPUT2 -static SDL_XInput2DeviceInfo * -xinput2_get_device_info(SDL_VideoData *videodata, const int device_id) +static SDL_XInput2DeviceInfo *xinput2_get_device_info(SDL_VideoData *videodata, const int device_id) { /* cache device info as we see new devices. */ SDL_XInput2DeviceInfo *prev = NULL; @@ -221,7 +215,7 @@ xinput2_get_device_info(SDL_VideoData *videodata, const int device_id) for (devinfo = videodata->mouse_device_info; devinfo != NULL; devinfo = devinfo->next) { if (devinfo->device_id == device_id) { SDL_assert((devinfo == videodata->mouse_device_info) == (prev == NULL)); - if (prev != NULL) { /* move this to the front of the list, assuming we'll get more from this one. */ + if (prev != NULL) { /* move this to the front of the list, assuming we'll get more from this one. */ prev->next = devinfo->next; devinfo->next = videodata->mouse_device_info; videodata->mouse_device_info = devinfo; @@ -232,7 +226,7 @@ xinput2_get_device_info(SDL_VideoData *videodata, const int device_id) } /* don't know about this device yet, query and cache it. */ - devinfo = (SDL_XInput2DeviceInfo *) SDL_calloc(1, sizeof (SDL_XInput2DeviceInfo)); + devinfo = (SDL_XInput2DeviceInfo *)SDL_calloc(1, sizeof(SDL_XInput2DeviceInfo)); if (devinfo == NULL) { SDL_OutOfMemory(); return NULL; @@ -250,7 +244,7 @@ xinput2_get_device_info(SDL_VideoData *videodata, const int device_id) !!! FIXME: axis could be relative or absolute, and they might not even be the X and Y axes! !!! FIXME: But we go on, for now. Maybe we need a more robust mouse API in SDL3... */ for (i = 0; i < xidevinfo->num_classes; i++) { - const XIValuatorClassInfo *v = (const XIValuatorClassInfo *) xidevinfo->classes[i]; + const XIValuatorClassInfo *v = (const XIValuatorClassInfo *)xidevinfo->classes[i]; if (v->type == XIValuatorClass) { devinfo->relative[axis] = (v->mode == XIModeRelative) ? SDL_TRUE : SDL_FALSE; devinfo->minval[axis] = v->min; @@ -270,124 +264,123 @@ xinput2_get_device_info(SDL_VideoData *videodata, const int device_id) } #endif -int -X11_HandleXinput2Event(SDL_VideoData *videodata, XGenericEventCookie *cookie) +int X11_HandleXinput2Event(SDL_VideoData *videodata, XGenericEventCookie *cookie) { #if SDL_VIDEO_DRIVER_X11_XINPUT2 if (cookie->extension != xinput2_opcode) { return 0; } - switch(cookie->evtype) { - case XI_RawMotion: { - const XIRawEvent *rawev = (const XIRawEvent*)cookie->data; - SDL_Mouse *mouse = SDL_GetMouse(); - SDL_XInput2DeviceInfo *devinfo; - double coords[2]; - double processed_coords[2]; - int i; + switch (cookie->evtype) { + case XI_RawMotion: + { + const XIRawEvent *rawev = (const XIRawEvent *)cookie->data; + SDL_Mouse *mouse = SDL_GetMouse(); + SDL_XInput2DeviceInfo *devinfo; + double coords[2]; + double processed_coords[2]; + int i; - videodata->global_mouse_changed = SDL_TRUE; + videodata->global_mouse_changed = SDL_TRUE; - if (!mouse->relative_mode || mouse->relative_mode_warp) { - return 0; - } - - devinfo = xinput2_get_device_info(videodata, rawev->deviceid); - if (devinfo == NULL) { - return 0; /* oh well. */ - } - - parse_valuators(rawev->raw_values,rawev->valuators.mask, - rawev->valuators.mask_len,coords,2); - - if ((rawev->time == devinfo->prev_time) && (coords[0] == devinfo->prev_coords[0]) && (coords[1] == devinfo->prev_coords[1])) { - return 0; /* duplicate event, drop it. */ - } - - for (i = 0; i < 2; i++) { - if (devinfo->relative[i]) { - processed_coords[i] = coords[i]; - } else { - processed_coords[i] = devinfo->prev_coords[i] - coords[i]; /* convert absolute to relative */ - } - } - - SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 1, (int) processed_coords[0], (int) processed_coords[1]); - devinfo->prev_coords[0] = coords[0]; - devinfo->prev_coords[1] = coords[1]; - devinfo->prev_time = rawev->time; - return 1; + if (!mouse->relative_mode || mouse->relative_mode_warp) { + return 0; } - break; - case XI_HierarchyChanged: { - const XIHierarchyEvent *hierev = (const XIHierarchyEvent *) cookie->data; - int i; - for (i = 0; i < hierev->num_info; i++) { - if (hierev->info[i].flags & XISlaveRemoved) { - xinput2_remove_device_info(videodata, hierev->info[i].deviceid); - } + devinfo = xinput2_get_device_info(videodata, rawev->deviceid); + if (devinfo == NULL) { + return 0; /* oh well. */ + } + + parse_valuators(rawev->raw_values, rawev->valuators.mask, + rawev->valuators.mask_len, coords, 2); + + if ((rawev->time == devinfo->prev_time) && (coords[0] == devinfo->prev_coords[0]) && (coords[1] == devinfo->prev_coords[1])) { + return 0; /* duplicate event, drop it. */ + } + + for (i = 0; i < 2; i++) { + if (devinfo->relative[i]) { + processed_coords[i] = coords[i]; + } else { + processed_coords[i] = devinfo->prev_coords[i] - coords[i]; /* convert absolute to relative */ } } - break; - case XI_RawButtonPress: - case XI_RawButtonRelease: + SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 1, (int)processed_coords[0], (int)processed_coords[1]); + devinfo->prev_coords[0] = coords[0]; + devinfo->prev_coords[1] = coords[1]; + devinfo->prev_time = rawev->time; + return 1; + } break; + + case XI_HierarchyChanged: + { + const XIHierarchyEvent *hierev = (const XIHierarchyEvent *)cookie->data; + int i; + for (i = 0; i < hierev->num_info; i++) { + if (hierev->info[i].flags & XISlaveRemoved) { + xinput2_remove_device_info(videodata, hierev->info[i].deviceid); + } + } + } break; + + case XI_RawButtonPress: + case XI_RawButtonRelease: #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH - case XI_RawTouchBegin: - case XI_RawTouchUpdate: - case XI_RawTouchEnd: + case XI_RawTouchBegin: + case XI_RawTouchUpdate: + case XI_RawTouchEnd: #endif - videodata->global_mouse_changed = SDL_TRUE; - break; + videodata->global_mouse_changed = SDL_TRUE; + break; #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH - /* With multitouch, register to receive XI_Motion (which desctivates MotionNotify), - * so that we can distinguish real mouse motions from synthetic one. */ - case XI_Motion: { - const XIDeviceEvent *xev = (const XIDeviceEvent *) cookie->data; - int pointer_emulated = (xev->flags & XIPointerEmulated); + /* With multitouch, register to receive XI_Motion (which desctivates MotionNotify), + * so that we can distinguish real mouse motions from synthetic one. */ + case XI_Motion: + { + const XIDeviceEvent *xev = (const XIDeviceEvent *)cookie->data; + int pointer_emulated = (xev->flags & XIPointerEmulated); - if (! pointer_emulated) { - SDL_Mouse *mouse = SDL_GetMouse(); - if (!mouse->relative_mode || mouse->relative_mode_warp) { - SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event); - if (window) { - SDL_SendMouseMotion(window, 0, 0, xev->event_x, xev->event_y); - } + if (!pointer_emulated) { + SDL_Mouse *mouse = SDL_GetMouse(); + if (!mouse->relative_mode || mouse->relative_mode_warp) { + SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event); + if (window) { + SDL_SendMouseMotion(window, 0, 0, xev->event_x, xev->event_y); } } - return 1; } - break; + return 1; + } break; - case XI_TouchBegin: { - const XIDeviceEvent *xev = (const XIDeviceEvent *) cookie->data; - float x, y; - SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event); - xinput2_normalize_touch_coordinates(window, xev->event_x, xev->event_y, &x, &y); - SDL_SendTouch(xev->sourceid, xev->detail, window, SDL_TRUE, x, y, 1.0); - return 1; - } - break; - case XI_TouchEnd: { - const XIDeviceEvent *xev = (const XIDeviceEvent *) cookie->data; - float x, y; - SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event); - xinput2_normalize_touch_coordinates(window, xev->event_x, xev->event_y, &x, &y); - SDL_SendTouch(xev->sourceid, xev->detail, window, SDL_FALSE, x, y, 1.0); - return 1; - } - break; - case XI_TouchUpdate: { - const XIDeviceEvent *xev = (const XIDeviceEvent *) cookie->data; - float x, y; - SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event); - xinput2_normalize_touch_coordinates(window, xev->event_x, xev->event_y, &x, &y); - SDL_SendTouchMotion(xev->sourceid, xev->detail, window, x, y, 1.0); - return 1; - } - break; + case XI_TouchBegin: + { + const XIDeviceEvent *xev = (const XIDeviceEvent *)cookie->data; + float x, y; + SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event); + xinput2_normalize_touch_coordinates(window, xev->event_x, xev->event_y, &x, &y); + SDL_SendTouch(xev->sourceid, xev->detail, window, SDL_TRUE, x, y, 1.0); + return 1; + } break; + case XI_TouchEnd: + { + const XIDeviceEvent *xev = (const XIDeviceEvent *)cookie->data; + float x, y; + SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event); + xinput2_normalize_touch_coordinates(window, xev->event_x, xev->event_y, &x, &y); + SDL_SendTouch(xev->sourceid, xev->detail, window, SDL_FALSE, x, y, 1.0); + return 1; + } break; + case XI_TouchUpdate: + { + const XIDeviceEvent *xev = (const XIDeviceEvent *)cookie->data; + float x, y; + SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event); + xinput2_normalize_touch_coordinates(window, xev->event_x, xev->event_y, &x, &y); + SDL_SendTouchMotion(xev->sourceid, xev->detail, window, x, y, 1.0); + return 1; + } break; #endif } @@ -395,13 +388,12 @@ X11_HandleXinput2Event(SDL_VideoData *videodata, XGenericEventCookie *cookie) return 0; } -void -X11_InitXinput2Multitouch(_THIS) +void X11_InitXinput2Multitouch(_THIS) { #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; XIDeviceInfo *info; - int ndevices,i,j; + int ndevices, i, j; if (!X11_Xinput2IsMultitouchSupported()) { return; @@ -415,7 +407,7 @@ X11_InitXinput2Multitouch(_THIS) SDL_TouchID touchId; SDL_TouchDeviceType touchType; XIAnyClassInfo *class = dev->classes[j]; - XITouchClassInfo *t = (XITouchClassInfo*)class; + XITouchClassInfo *t = (XITouchClassInfo *)class; /* Only touch devices */ if (class->type != XITouchClass) { @@ -436,8 +428,7 @@ X11_InitXinput2Multitouch(_THIS) #endif } -void -X11_Xinput2SelectTouch(_THIS, SDL_Window *window) +void X11_Xinput2SelectTouch(_THIS, SDL_Window *window) { #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH SDL_VideoData *data = NULL; @@ -449,8 +440,8 @@ X11_Xinput2SelectTouch(_THIS, SDL_Window *window) return; } - data = (SDL_VideoData *) _this->driverdata; - window_data = (SDL_WindowData*)window->driverdata; + data = (SDL_VideoData *)_this->driverdata; + window_data = (SDL_WindowData *)window->driverdata; eventmask.deviceid = XIAllMasterDevices; eventmask.mask_len = sizeof(mask); @@ -461,13 +452,11 @@ X11_Xinput2SelectTouch(_THIS, SDL_Window *window) XISetMask(mask, XI_TouchEnd); XISetMask(mask, XI_Motion); - X11_XISelectEvents(data->display,window_data->xwindow,&eventmask,1); + X11_XISelectEvents(data->display, window_data->xwindow, &eventmask, 1); #endif } - -int -X11_Xinput2IsInitialized() +int X11_Xinput2IsInitialized() { #if SDL_VIDEO_DRIVER_X11_XINPUT2 return xinput2_initialized; @@ -476,8 +465,7 @@ X11_Xinput2IsInitialized() #endif } -int -X11_Xinput2IsMultitouchSupported() +int X11_Xinput2IsMultitouchSupported() { #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH return xinput2_initialized && xinput2_multitouch_supported; @@ -486,11 +474,10 @@ X11_Xinput2IsMultitouchSupported() #endif } -void -X11_Xinput2GrabTouch(_THIS, SDL_Window *window) +void X11_Xinput2GrabTouch(_THIS, SDL_Window *window) { #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; unsigned char mask[4] = { 0, 0, 0, 0 }; @@ -517,11 +504,10 @@ X11_Xinput2GrabTouch(_THIS, SDL_Window *window) #endif } -void -X11_Xinput2UngrabTouch(_THIS, SDL_Window *window) +void X11_Xinput2UngrabTouch(_THIS, SDL_Window *window) { #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; XIGrabModifiers mods; diff --git a/src/video/x11/SDL_x11xinput2.h b/src/video/x11/SDL_x11xinput2.h index 679beb97b..1f61965bc 100644 --- a/src/video/x11/SDL_x11xinput2.h +++ b/src/video/x11/SDL_x11xinput2.h @@ -32,7 +32,7 @@ typedef struct XGenericEventCookie XGenericEventCookie; extern void X11_InitXinput2(_THIS); extern void X11_InitXinput2Multitouch(_THIS); -extern int X11_HandleXinput2Event(SDL_VideoData *videodata,XGenericEventCookie *cookie); +extern int X11_HandleXinput2Event(SDL_VideoData *videodata, XGenericEventCookie *cookie); extern int X11_Xinput2IsInitialized(void); extern int X11_Xinput2IsMultitouchSupported(void); extern void X11_Xinput2SelectTouch(_THIS, SDL_Window *window); diff --git a/src/video/x11/edid.h b/src/video/x11/edid.h index cb9f0e87e..37abbec63 100644 --- a/src/video/x11/edid.h +++ b/src/video/x11/edid.h @@ -41,127 +41,127 @@ struct Timing struct DetailedTiming { - int pixel_clock; - int h_addr; - int h_blank; - int h_sync; - int h_front_porch; - int v_addr; - int v_blank; - int v_sync; - int v_front_porch; - int width_mm; - int height_mm; - int right_border; - int top_border; - int interlaced; - StereoType stereo; + int pixel_clock; + int h_addr; + int h_blank; + int h_sync; + int h_front_porch; + int v_addr; + int v_blank; + int v_sync; + int v_front_porch; + int width_mm; + int height_mm; + int right_border; + int top_border; + int interlaced; + StereoType stereo; - int digital_sync; + int digital_sync; union { - struct - { - int bipolar; - int serrations; - int sync_on_green; - } analog; + struct + { + int bipolar; + int serrations; + int sync_on_green; + } analog; - struct - { - int composite; - int serrations; - int negative_vsync; - int negative_hsync; - } digital; + struct + { + int composite; + int serrations; + int negative_vsync; + int negative_hsync; + } digital; } ad; }; struct MonitorInfo { - int checksum; - char manufacturer_code[4]; - int product_code; - unsigned int serial_number; - - int production_week; /* -1 if not specified */ - int production_year; /* -1 if not specified */ - int model_year; /* -1 if not specified */ + int checksum; + char manufacturer_code[4]; + int product_code; + unsigned int serial_number; - int major_version; - int minor_version; + int production_week; /* -1 if not specified */ + int production_year; /* -1 if not specified */ + int model_year; /* -1 if not specified */ + + int major_version; + int minor_version; + + int is_digital; - int is_digital; - union { - struct - { - int bits_per_primary; - Interface interface; - int rgb444; - int ycrcb444; - int ycrcb422; - } digital; + struct + { + int bits_per_primary; + Interface interface; + int rgb444; + int ycrcb444; + int ycrcb422; + } digital; - struct - { - double video_signal_level; - double sync_signal_level; - double total_signal_level; + struct + { + double video_signal_level; + double sync_signal_level; + double total_signal_level; - int blank_to_black; + int blank_to_black; - int separate_hv_sync; - int composite_sync_on_h; - int composite_sync_on_green; - int serration_on_vsync; - ColorType color_type; - } analog; + int separate_hv_sync; + int composite_sync_on_h; + int composite_sync_on_green; + int serration_on_vsync; + ColorType color_type; + } analog; } ad; - int width_mm; /* -1 if not specified */ - int height_mm; /* -1 if not specified */ - double aspect_ratio; /* -1.0 if not specififed */ + int width_mm; /* -1 if not specified */ + int height_mm; /* -1 if not specified */ + double aspect_ratio; /* -1.0 if not specififed */ - double gamma; /* -1.0 if not specified */ + double gamma; /* -1.0 if not specified */ - int standby; - int suspend; - int active_off; + int standby; + int suspend; + int active_off; - int srgb_is_standard; - int preferred_timing_includes_native; - int continuous_frequency; + int srgb_is_standard; + int preferred_timing_includes_native; + int continuous_frequency; - double red_x; - double red_y; - double green_x; - double green_y; - double blue_x; - double blue_y; - double white_x; - double white_y; + double red_x; + double red_y; + double green_x; + double green_y; + double blue_x; + double blue_y; + double white_x; + double white_y; - Timing established[24]; /* Terminated by 0x0x0 */ - Timing standard[8]; - - int n_detailed_timings; - DetailedTiming detailed_timings[4]; /* If monitor has a preferred - * mode, it is the first one - * (whether it has, is - * determined by the - * preferred_timing_includes - * bit. - */ + Timing established[24]; /* Terminated by 0x0x0 */ + Timing standard[8]; + + int n_detailed_timings; + DetailedTiming detailed_timings[4]; /* If monitor has a preferred + * mode, it is the first one + * (whether it has, is + * determined by the + * preferred_timing_includes + * bit. + */ /* Optional product description */ - char dsc_serial_number[14]; - char dsc_product_name[14]; - char dsc_string[14]; /* Unspecified ASCII data */ + char dsc_serial_number[14]; + char dsc_product_name[14]; + char dsc_string[14]; /* Unspecified ASCII data */ }; -MonitorInfo *decode_edid (const uchar *data); -void dump_monitor_info (MonitorInfo *info); -char * make_display_name (const char *output_name, - const MonitorInfo *info); +MonitorInfo *decode_edid(const uchar *data); +void dump_monitor_info(MonitorInfo *info); +char *make_display_name(const char *output_name, + const MonitorInfo *info); diff --git a/test/checkkeys.c b/test/checkkeys.c index de827f869..91b219f1e 100644 --- a/test/checkkeys.c +++ b/test/checkkeys.c @@ -49,8 +49,8 @@ print_string(char **text, size_t *maxlen, const char *fmt, ...) len = SDL_vsnprintf(*text, *maxlen, fmt, ap); if (len > 0) { *text += len; - if ( ((size_t) len) < *maxlen ) { - *maxlen -= (size_t) len; + if (((size_t)len) < *maxlen) { + *maxlen -= (size_t)len; } else { *maxlen = 0; } @@ -121,7 +121,7 @@ PrintModifierState() } static void -PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat) +PrintKey(SDL_Keysym *sym, SDL_bool pressed, SDL_bool repeat) { char message[512]; char *spot; @@ -133,17 +133,17 @@ PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat) /* Print the keycode, name and state */ if (sym->sym) { print_string(&spot, &left, - "Key %s: scancode %d = %s, keycode 0x%08X = %s ", - pressed ? "pressed " : "released", - sym->scancode, - SDL_GetScancodeName(sym->scancode), - sym->sym, SDL_GetKeyName(sym->sym)); + "Key %s: scancode %d = %s, keycode 0x%08X = %s ", + pressed ? "pressed " : "released", + sym->scancode, + SDL_GetScancodeName(sym->scancode), + sym->sym, SDL_GetKeyName(sym->sym)); } else { print_string(&spot, &left, - "Unknown Key (scancode %d = %s) %s ", - sym->scancode, - SDL_GetScancodeName(sym->scancode), - pressed ? "pressed " : "released"); + "Unknown Key (scancode %d = %s) %s ", + sym->scancode, + SDL_GetScancodeName(sym->scancode), + pressed ? "pressed " : "released"); } print_modifiers(&spot, &left); if (repeat) { @@ -159,15 +159,14 @@ PrintText(const char *eventtype, const char *text) char expanded[1024]; expanded[0] = '\0'; - for ( spot = text; *spot; ++spot ) { + for (spot = text; *spot; ++spot) { size_t length = SDL_strlen(expanded); SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", (unsigned char)*spot); } SDL_Log("%s Text (%s): \"%s%s\"\n", eventtype, expanded, *text == '"' ? "\\" : "", text); } -void -loop() +void loop() { SDL_Event event; /* Check for events */ @@ -249,8 +248,7 @@ loop() #endif } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { /* Enable standard application logging */ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); @@ -273,14 +271,14 @@ main(int argc, char *argv[]) 640, 480, 0); if (window == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n", - SDL_GetError()); + SDL_GetError()); quit(2); } renderer = SDL_CreateRenderer(window, -1, 0); if (renderer == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", - SDL_GetError()); + SDL_GetError()); quit(2); } diff --git a/test/checkkeysthreads.c b/test/checkkeysthreads.c index 00fb71bfe..c14cb29e9 100644 --- a/test/checkkeysthreads.c +++ b/test/checkkeysthreads.c @@ -45,8 +45,8 @@ print_string(char **text, size_t *maxlen, const char *fmt, ...) len = SDL_vsnprintf(*text, *maxlen, fmt, ap); if (len > 0) { *text += len; - if ( ((size_t) len) < *maxlen ) { - *maxlen -= (size_t) len; + if (((size_t)len) < *maxlen) { + *maxlen -= (size_t)len; } else { *maxlen = 0; } @@ -117,7 +117,7 @@ PrintModifierState() } static void -PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat) +PrintKey(SDL_Keysym *sym, SDL_bool pressed, SDL_bool repeat) { char message[512]; char *spot; @@ -129,17 +129,17 @@ PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat) /* Print the keycode, name and state */ if (sym->sym) { print_string(&spot, &left, - "Key %s: scancode %d = %s, keycode 0x%08X = %s ", - pressed ? "pressed " : "released", - sym->scancode, - SDL_GetScancodeName(sym->scancode), - sym->sym, SDL_GetKeyName(sym->sym)); + "Key %s: scancode %d = %s, keycode 0x%08X = %s ", + pressed ? "pressed " : "released", + sym->scancode, + SDL_GetScancodeName(sym->scancode), + sym->sym, SDL_GetKeyName(sym->sym)); } else { print_string(&spot, &left, - "Unknown Key (scancode %d = %s) %s ", - sym->scancode, - SDL_GetScancodeName(sym->scancode), - pressed ? "pressed " : "released"); + "Unknown Key (scancode %d = %s) %s ", + sym->scancode, + SDL_GetScancodeName(sym->scancode), + pressed ? "pressed " : "released"); } print_modifiers(&spot, &left); if (repeat) { @@ -156,21 +156,21 @@ PrintText(const char *eventtype, const char *text) char expanded[1024]; expanded[0] = '\0'; - for ( spot = text; *spot; ++spot ) { + for (spot = text; *spot; ++spot) { size_t length = SDL_strlen(expanded); SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", (unsigned char)*spot); } SDL_Log("%s Text (%s): \"%s%s\"\n", eventtype, expanded, *text == '"' ? "\\" : "", text); } -void -loop() +void loop() { SDL_Event event; /* Check for events */ /*SDL_WaitEvent(&event); emscripten does not like waiting*/ - fprintf(stderr, "starting loop\n"); fflush(stderr); + fprintf(stderr, "starting loop\n"); + fflush(stderr); // while (SDL_PollEvent(&event)) { while (!done && SDL_WaitEvent(&event)) { fprintf(stderr, "got event type: %" SDL_PRIu32 "\n", event.type); @@ -188,7 +188,8 @@ loop() break; case SDL_MOUSEBUTTONDOWN: /* Left button quits the app, other buttons toggles text input */ - fprintf(stderr, "mouse button down button: %d (LEFT=%d)\n", event.button.button, SDL_BUTTON_LEFT); fflush(stderr); + fprintf(stderr, "mouse button down button: %d (LEFT=%d)\n", event.button.button, SDL_BUTTON_LEFT); + fflush(stderr); if (event.button.button == SDL_BUTTON_LEFT) { done = 1; } else { @@ -207,9 +208,11 @@ loop() default: break; } - fprintf(stderr, "waiting new event\n"); fflush(stderr); + fprintf(stderr, "waiting new event\n"); + fflush(stderr); } - fprintf(stderr, "exiting event loop\n"); fflush(stderr); + fprintf(stderr, "exiting event loop\n"); + fflush(stderr); #ifdef __EMSCRIPTEN__ if (done) { emscripten_cancel_main_loop(); @@ -222,9 +225,10 @@ static int SDLCALL ping_thread(void *ptr) { int cnt; SDL_Event sdlevent; - SDL_memset(&sdlevent, 0 , sizeof(SDL_Event)); + SDL_memset(&sdlevent, 0, sizeof(SDL_Event)); for (cnt = 0; cnt < 10; ++cnt) { - fprintf(stderr, "sending event (%d/%d) from thread.\n", cnt + 1, 10); fflush(stderr); + fprintf(stderr, "sending event (%d/%d) from thread.\n", cnt + 1, 10); + fflush(stderr); sdlevent.type = SDL_KEYDOWN; sdlevent.key.keysym.sym = SDLK_1; SDL_PushEvent(&sdlevent); @@ -233,8 +237,7 @@ static int SDLCALL ping_thread(void *ptr) return cnt; } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { SDL_Window *window; SDL_Renderer *renderer; @@ -255,7 +258,7 @@ main(int argc, char *argv[]) 640, 480, 0); if (window == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n", - SDL_GetError()); + SDL_GetError()); quit(2); } diff --git a/test/controllermap.c b/test/controllermap.c index e4181363e..d172c776d 100644 --- a/test/controllermap.c +++ b/test/controllermap.c @@ -25,10 +25,11 @@ /* Define this for verbose output while mapping controllers */ #define DEBUG_CONTROLLERMAP -#define SCREEN_WIDTH 512 -#define SCREEN_HEIGHT 320 +#define SCREEN_WIDTH 512 +#define SCREEN_HEIGHT 320 -enum marker_type { +enum marker_type +{ MARKER_BUTTON, MARKER_AXIS, }; @@ -64,10 +65,10 @@ static struct { 174, 132, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_BACK */ { 232, 128, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_GUIDE */ { 289, 132, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_START */ - { 75, 154, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_LEFTSTICK */ + { 75, 154, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_LEFTSTICK */ { 305, 230, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_RIGHTSTICK */ - { 77, 40, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_LEFTSHOULDER */ - { 396, 36, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_RIGHTSHOULDER */ + { 77, 40, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_LEFTSHOULDER */ + { 396, 36, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_RIGHTSHOULDER */ { 154, 188, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_DPAD_UP */ { 154, 249, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_DPAD_DOWN */ { 116, 217, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_DPAD_LEFT */ @@ -77,16 +78,16 @@ static struct { 330, 135, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_PADDLE2 */ { 132, 175, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_PADDLE3 */ { 330, 175, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_PADDLE4 */ - { 0, 0, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_TOUCHPAD */ - { 74, 153, 270.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_LEFTX_NEGATIVE */ - { 74, 153, 90.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_LEFTX_POSITIVE */ - { 74, 153, 0.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_LEFTY_NEGATIVE */ - { 74, 153, 180.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_LEFTY_POSITIVE */ + { 0, 0, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_TOUCHPAD */ + { 74, 153, 270.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_LEFTX_NEGATIVE */ + { 74, 153, 90.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_LEFTX_POSITIVE */ + { 74, 153, 0.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_LEFTY_NEGATIVE */ + { 74, 153, 180.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_LEFTY_POSITIVE */ { 306, 231, 270.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_RIGHTX_NEGATIVE */ - { 306, 231, 90.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_RIGHTX_POSITIVE */ - { 306, 231, 0.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_RIGHTY_NEGATIVE */ + { 306, 231, 90.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_RIGHTX_POSITIVE */ + { 306, 231, 0.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_RIGHTY_NEGATIVE */ { 306, 231, 180.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_RIGHTY_POSITIVE */ - { 91, -20, 180.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_TRIGGERLEFT */ + { 91, -20, 180.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_TRIGGERLEFT */ { 375, -20, 180.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_TRIGGERRIGHT */ }; SDL_COMPILE_TIME_ASSERT(s_arrBindingDisplay, SDL_arraysize(s_arrBindingDisplay) == BINDING_COUNT); @@ -133,13 +134,15 @@ typedef struct { int button; - struct { + struct + { int axis; int axis_min; int axis_max; } axis; - struct { + struct + { int hat; int hat_mask; } hat; @@ -162,7 +165,7 @@ typedef struct static int s_nNumAxes; static AxisState *s_arrAxisState; - + static int s_iCurrentBinding; static Uint32 s_unPendingAdvanceTime; static SDL_bool s_bBindingComplete; @@ -175,9 +178,9 @@ static SDL_bool bind_touchpad = SDL_FALSE; static int StandardizeAxisValue(int nValue) { - if (nValue > SDL_JOYSTICK_AXIS_MAX/2) { + if (nValue > SDL_JOYSTICK_AXIS_MAX / 2) { return SDL_JOYSTICK_AXIS_MAX; - } else if (nValue < SDL_JOYSTICK_AXIS_MIN/2) { + } else if (nValue < SDL_JOYSTICK_AXIS_MIN / 2) { return SDL_JOYSTICK_AXIS_MIN; } else { return 0; @@ -205,8 +208,7 @@ SetCurrentBinding(int iBinding) } if (s_arrBindingOrder[iBinding] == SDL_CONTROLLER_BUTTON_TOUCHPAD && - !bind_touchpad) - { + !bind_touchpad) { SetCurrentBinding(iBinding + 1); return; } @@ -229,8 +231,7 @@ BBindingContainsBinding(const SDL_GameControllerExtendedBind *pBindingA, const S if (pBindingA->bindType != pBindingB->bindType) { return SDL_FALSE; } - switch (pBindingA->bindType) - { + switch (pBindingA->bindType) { case SDL_CONTROLLER_BINDTYPE_AXIS: if (pBindingA->value.axis.axis != pBindingB->value.axis.axis) { return SDL_FALSE; @@ -280,19 +281,18 @@ ConfigureBinding(const SDL_GameControllerExtendedBind *pBinding) } #ifdef DEBUG_CONTROLLERMAP - switch ( pBinding->bindType ) - { + switch (pBinding->bindType) { case SDL_CONTROLLER_BINDTYPE_NONE: - break; + break; case SDL_CONTROLLER_BINDTYPE_BUTTON: - SDL_Log("Configuring button binding for button %d\n", pBinding->value.button); - break; + SDL_Log("Configuring button binding for button %d\n", pBinding->value.button); + break; case SDL_CONTROLLER_BINDTYPE_AXIS: - SDL_Log("Configuring axis binding for axis %d %d/%d committed = %s\n", pBinding->value.axis.axis, pBinding->value.axis.axis_min, pBinding->value.axis.axis_max, pBinding->committed ? "true" : "false"); - break; + SDL_Log("Configuring axis binding for axis %d %d/%d committed = %s\n", pBinding->value.axis.axis, pBinding->value.axis.axis_min, pBinding->value.axis.axis_max, pBinding->committed ? "true" : "false"); + break; case SDL_CONTROLLER_BINDTYPE_HAT: - SDL_Log("Configuring hat binding for hat %d %d\n", pBinding->value.hat.hat, pBinding->value.hat.hat_mask); - break; + SDL_Log("Configuring hat binding for hat %d %d\n", pBinding->value.hat.hat, pBinding->value.hat.hat_mask); + break; } #endif /* DEBUG_CONTROLLERMAP */ @@ -301,7 +301,7 @@ ConfigureBinding(const SDL_GameControllerExtendedBind *pBinding) if (pCurrent->bindType != SDL_CONTROLLER_BINDTYPE_NONE) { SDL_bool bNativeDPad, bCurrentDPad; SDL_bool bNativeAxis, bCurrentAxis; - + bNativeDPad = (iCurrentElement == SDL_CONTROLLER_BUTTON_DPAD_UP || iCurrentElement == SDL_CONTROLLER_BUTTON_DPAD_DOWN || iCurrentElement == SDL_CONTROLLER_BUTTON_DPAD_LEFT || @@ -335,7 +335,7 @@ static SDL_bool BMergeAxisBindings(int iIndex) { SDL_GameControllerExtendedBind *pBindingA = &s_arrBindings[iIndex]; - SDL_GameControllerExtendedBind *pBindingB = &s_arrBindings[iIndex+1]; + SDL_GameControllerExtendedBind *pBindingB = &s_arrBindings[iIndex + 1]; if (pBindingA->bindType == SDL_CONTROLLER_BINDTYPE_AXIS && pBindingB->bindType == SDL_CONTROLLER_BINDTYPE_AXIS && pBindingA->value.axis.axis == pBindingB->value.axis.axis) { @@ -350,13 +350,13 @@ BMergeAxisBindings(int iIndex) } static void -WatchJoystick(SDL_Joystick * joystick) +WatchJoystick(SDL_Joystick *joystick) { - SDL_Texture *background_front, *background_back, *button, *axis, *marker=NULL; + SDL_Texture *background_front, *background_back, *button, *axis, *marker = NULL; const char *name = NULL; SDL_Event event; SDL_Rect dst; - Uint8 alpha=200, alpha_step = -1; + Uint8 alpha = 200, alpha_step = -1; Uint32 alpha_ticks = 0; SDL_JoystickID nJoystickID; @@ -374,9 +374,9 @@ WatchJoystick(SDL_Joystick * joystick) SDL_Log("Watching joystick %" SDL_PRIs32 ": (%s)\n", SDL_JoystickInstanceID(joystick), name ? name : "Unknown Joystick"); SDL_Log("Joystick has %d axes, %d hats, %d balls, and %d buttons\n", - SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick), - SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick)); - + SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick), + SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick)); + SDL_Log("\n\n\ ====================================================================================\n\ Press the buttons on your controller when indicated\n\ @@ -401,14 +401,14 @@ WatchJoystick(SDL_Joystick * joystick) int iElement = s_arrBindingOrder[s_iCurrentBinding]; switch (s_arrBindingDisplay[iElement].marker) { - case MARKER_AXIS: - marker = axis; - break; - case MARKER_BUTTON: - marker = button; - break; + case MARKER_AXIS: + marker = axis; + break; + case MARKER_BUTTON: + marker = button; + break; } - + dst.x = s_arrBindingDisplay[iElement].x; dst.y = s_arrBindingDisplay[iElement].y; SDL_QueryTexture(marker, NULL, NULL, &dst.w, &dst.h); @@ -436,7 +436,7 @@ WatchJoystick(SDL_Joystick * joystick) SDL_SetTextureColorMod(marker, 10, 255, 21); SDL_RenderCopyEx(screen, marker, NULL, &dst, s_arrBindingDisplay[iElement].angle, NULL, SDL_FLIP_NONE); SDL_RenderPresent(screen); - + while (SDL_PollEvent(&event) > 0) { switch (event.type) { case SDL_JOYDEVICEREMOVED: @@ -446,7 +446,7 @@ WatchJoystick(SDL_Joystick * joystick) break; case SDL_JOYAXISMOTION: if (event.jaxis.which == nJoystickID) { - const int MAX_ALLOWED_JITTER = SDL_JOYSTICK_AXIS_MAX / 80; /* ShanWan PS3 controller needed 96 */ + const int MAX_ALLOWED_JITTER = SDL_JOYSTICK_AXIS_MAX / 80; /* ShanWan PS3 controller needed 96 */ AxisState *pAxisState = &s_arrAxisState[event.jaxis.axis]; int nValue = event.jaxis.value; int nCurrentDistance, nFarthestDistance; @@ -702,12 +702,11 @@ WatchJoystick(SDL_Joystick * joystick) SDL_free(s_arrAxisState); s_arrAxisState = NULL; - + SDL_DestroyRenderer(screen); } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { const char *name; int i; @@ -772,11 +771,11 @@ main(int argc, char *argv[]) joystick = SDL_JoystickOpen(i); if (joystick == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_JoystickOpen(%d) failed: %s\n", i, - SDL_GetError()); + SDL_GetError()); } else { char guid[64]; SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick), - guid, sizeof (guid)); + guid, sizeof(guid)); SDL_Log(" axes: %d\n", SDL_JoystickNumAxes(joystick)); SDL_Log(" balls: %d\n", SDL_JoystickNumBalls(joystick)); SDL_Log(" hats: %d\n", SDL_JoystickNumHats(joystick)); diff --git a/test/loopwave.c b/test/loopwave.c index 026c8e619..73fa0ca31 100644 --- a/test/loopwave.c +++ b/test/loopwave.c @@ -30,9 +30,9 @@ static struct { SDL_AudioSpec spec; - Uint8 *sound; /* Pointer to wave data */ - Uint32 soundlen; /* Length of wave data */ - int soundpos; /* Current play position */ + Uint8 *sound; /* Pointer to wave data */ + Uint32 soundlen; /* Length of wave data */ + int soundpos; /* Current play position */ } wave; static SDL_AudioDeviceID device; @@ -65,7 +65,6 @@ open_audio() quit(2); } - /* Let the audio run */ SDL_PauseAudioDevice(device, SDL_FALSE); } @@ -79,7 +78,7 @@ static void reopen_audio() #endif void SDLCALL -fillerup(void *unused, Uint8 * stream, int len) +fillerup(void *unused, Uint8 *stream, int len) { Uint8 *waveptr; int waveleft; @@ -104,8 +103,7 @@ fillerup(void *unused, Uint8 * stream, int len) static int done = 0; #ifdef __EMSCRIPTEN__ -void -loop() +void loop() { if (done || (SDL_GetAudioDeviceStatus(device) != SDL_AUDIO_PLAYING)) { emscripten_cancel_main_loop(); @@ -113,8 +111,7 @@ loop() } #endif -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i; char *filename = NULL; @@ -123,7 +120,7 @@ main(int argc, char *argv[]) SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); /* Load the SDL library */ - if (SDL_Init(SDL_INIT_AUDIO|SDL_INIT_EVENTS) < 0) { + if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_EVENTS) < 0) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return 1; } diff --git a/test/loopwavequeue.c b/test/loopwavequeue.c index 8893e3b62..23157a381 100644 --- a/test/loopwavequeue.c +++ b/test/loopwavequeue.c @@ -30,11 +30,10 @@ static struct { SDL_AudioSpec spec; - Uint8 *sound; /* Pointer to wave data */ - Uint32 soundlen; /* Length of wave data */ + Uint8 *sound; /* Pointer to wave data */ + Uint32 soundlen; /* Length of wave data */ } wave; - /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void quit(int rc) @@ -44,14 +43,12 @@ quit(int rc) } static int done = 0; -void -poked(int sig) +void poked(int sig) { done = 1; } -void -loop() +void loop() { #ifdef __EMSCRIPTEN__ if (done || (SDL_GetAudioStatus() != SDL_AUDIO_PLAYING)) { @@ -61,19 +58,18 @@ loop() { /* The device from SDL_OpenAudio() is always device #1. */ const Uint32 queued = SDL_GetQueuedAudioSize(1); - SDL_Log("Device has %u bytes queued.\n", (unsigned int) queued); - if (queued <= 8192) { /* time to requeue the whole thing? */ + SDL_Log("Device has %u bytes queued.\n", (unsigned int)queued); + if (queued <= 8192) { /* time to requeue the whole thing? */ if (SDL_QueueAudio(1, wave.sound, wave.soundlen) == 0) { - SDL_Log("Device queued %u more bytes.\n", (unsigned int) wave.soundlen); + SDL_Log("Device queued %u more bytes.\n", (unsigned int)wave.soundlen); } else { - SDL_Log("Device FAILED to queue %u more bytes: %s\n", (unsigned int) wave.soundlen, SDL_GetError()); + SDL_Log("Device FAILED to queue %u more bytes: %s\n", (unsigned int)wave.soundlen, SDL_GetError()); } } } } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { char *filename = NULL; @@ -99,7 +95,7 @@ main(int argc, char *argv[]) quit(1); } - wave.spec.callback = NULL; /* we'll push audio. */ + wave.spec.callback = NULL; /* we'll push audio. */ #if HAVE_SIGNAL_H /* Set the signals */ @@ -130,14 +126,14 @@ main(int argc, char *argv[]) /* Note that we stuff the entire audio buffer into the queue in one shot. Most apps would want to feed it a little at a time, as it plays, but we're going for simplicity here. */ - + #ifdef __EMSCRIPTEN__ emscripten_set_main_loop(loop, 0, 1); #else while (!done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING)) { loop(); - SDL_Delay(100); /* let it play for awhile. */ + SDL_Delay(100); /* let it play for awhile. */ } #endif diff --git a/test/testatomic.c b/test/testatomic.c index ffb11c675..1bb0f2d8c 100644 --- a/test/testatomic.c +++ b/test/testatomic.c @@ -18,22 +18,20 @@ after calling each function. */ -static -const char * +static const char * tf(SDL_bool _tf) { static const char *t = "TRUE"; static const char *f = "FALSE"; if (_tf) { - return t; + return t; } return f; } -static -void RunBasicTest() +static void RunBasicTest() { int value; SDL_SpinLock lock = 0; @@ -95,15 +93,16 @@ void RunBasicTest() /* Number of concurrent incrementers */ #define NThreads 2 #define CountInc 100 -#define VALBITS (sizeof(atomicValue)*8) +#define VALBITS (sizeof(atomicValue) * 8) #define atomicValue int -#define CountTo ((atomicValue)((unsigned int)(1<<(VALBITS-1))-1)) -#define NInter (CountTo/CountInc/NThreads) -#define Expect (CountTo-NInter*CountInc*NThreads) +#define CountTo ((atomicValue)((unsigned int)(1 << (VALBITS - 1)) - 1)) +#define NInter (CountTo / CountInc / NThreads) +#define Expect (CountTo - NInter * CountInc * NThreads) -enum { - CountTo_GreaterThanZero = CountTo > 0, +enum +{ + CountTo_GreaterThanZero = CountTo > 0, }; SDL_COMPILE_TIME_ASSERT(size, CountTo_GreaterThanZero); /* check for rollover */ @@ -115,25 +114,23 @@ static SDL_atomic_t threadsRunning; static SDL_sem *threadDone; -static -int SDLCALL adder(void* junk) +static int SDLCALL adder(void *junk) { - unsigned long N=NInter; - SDL_Log("Thread subtracting %d %lu times\n",CountInc,N); + unsigned long N = NInter; + SDL_Log("Thread subtracting %d %lu times\n", CountInc, N); while (N--) { SDL_AtomicAdd(&good, -CountInc); - bad-=CountInc; + bad -= CountInc; } SDL_AtomicAdd(&threadsRunning, -1); SDL_SemPost(threadDone); return 0; } -static -void runAdder(void) +static void runAdder(void) { Uint32 start, end; - int T=NThreads; + int T = NThreads; start = SDL_GetTicks(); @@ -156,8 +153,7 @@ void runAdder(void) SDL_Log("Finished in %f sec\n", (end - start) / 1000.f); } -static -void RunEpicTest() +static void RunEpicTest() { int b; atomicValue v; @@ -165,80 +161,80 @@ void RunEpicTest() SDL_Log("\nepic test---------------------------------------\n\n"); SDL_Log("Size asserted to be >= 32-bit\n"); - SDL_assert(sizeof(atomicValue)>=4); + SDL_assert(sizeof(atomicValue) >= 4); SDL_Log("Check static initializer\n"); - v=SDL_AtomicGet(&good); - SDL_assert(v==42); + v = SDL_AtomicGet(&good); + SDL_assert(v == 42); - SDL_assert(bad==42); + SDL_assert(bad == 42); SDL_Log("Test negative values\n"); SDL_AtomicSet(&good, -5); - v=SDL_AtomicGet(&good); - SDL_assert(v==-5); + v = SDL_AtomicGet(&good); + SDL_assert(v == -5); SDL_Log("Verify maximum value\n"); SDL_AtomicSet(&good, CountTo); - v=SDL_AtomicGet(&good); - SDL_assert(v==CountTo); + v = SDL_AtomicGet(&good); + SDL_assert(v == CountTo); SDL_Log("Test compare and exchange\n"); - b=SDL_AtomicCAS(&good, 500, 43); + b = SDL_AtomicCAS(&good, 500, 43); SDL_assert(!b); /* no swap since CountTo!=500 */ - v=SDL_AtomicGet(&good); - SDL_assert(v==CountTo); /* ensure no swap */ + v = SDL_AtomicGet(&good); + SDL_assert(v == CountTo); /* ensure no swap */ - b=SDL_AtomicCAS(&good, CountTo, 44); + b = SDL_AtomicCAS(&good, CountTo, 44); SDL_assert(!!b); /* will swap */ - v=SDL_AtomicGet(&good); - SDL_assert(v==44); + v = SDL_AtomicGet(&good); + SDL_assert(v == 44); SDL_Log("Test Add\n"); - v=SDL_AtomicAdd(&good, 1); - SDL_assert(v==44); - v=SDL_AtomicGet(&good); - SDL_assert(v==45); + v = SDL_AtomicAdd(&good, 1); + SDL_assert(v == 44); + v = SDL_AtomicGet(&good); + SDL_assert(v == 45); - v=SDL_AtomicAdd(&good, 10); - SDL_assert(v==45); - v=SDL_AtomicGet(&good); - SDL_assert(v==55); + v = SDL_AtomicAdd(&good, 10); + SDL_assert(v == 45); + v = SDL_AtomicGet(&good); + SDL_assert(v == 55); SDL_Log("Test Add (Negative values)\n"); - v=SDL_AtomicAdd(&good, -20); - SDL_assert(v==55); - v=SDL_AtomicGet(&good); - SDL_assert(v==35); + v = SDL_AtomicAdd(&good, -20); + SDL_assert(v == 55); + v = SDL_AtomicGet(&good); + SDL_assert(v == 35); - v=SDL_AtomicAdd(&good, -50); /* crossing zero down */ - SDL_assert(v==35); - v=SDL_AtomicGet(&good); - SDL_assert(v==-15); + v = SDL_AtomicAdd(&good, -50); /* crossing zero down */ + SDL_assert(v == 35); + v = SDL_AtomicGet(&good); + SDL_assert(v == -15); - v=SDL_AtomicAdd(&good, 30); /* crossing zero up */ - SDL_assert(v==-15); - v=SDL_AtomicGet(&good); - SDL_assert(v==15); + v = SDL_AtomicAdd(&good, 30); /* crossing zero up */ + SDL_assert(v == -15); + v = SDL_AtomicGet(&good); + SDL_assert(v == 15); SDL_Log("Reset before count down test\n"); SDL_AtomicSet(&good, CountTo); - v=SDL_AtomicGet(&good); - SDL_assert(v==CountTo); + v = SDL_AtomicGet(&good); + SDL_assert(v == CountTo); - bad=CountTo; - SDL_assert(bad==CountTo); + bad = CountTo; + SDL_assert(bad == CountTo); - SDL_Log("Counting down from %d, Expect %d remaining\n",CountTo,Expect); + SDL_Log("Counting down from %d, Expect %d remaining\n", CountTo, Expect); runAdder(); - v=SDL_AtomicGet(&good); - SDL_Log("Atomic %d Non-Atomic %d\n",v,bad); - SDL_assert(v==Expect); - SDL_assert(bad!=Expect); + v = SDL_AtomicGet(&good); + SDL_Log("Atomic %d Non-Atomic %d\n", v, bad); + SDL_assert(v == Expect); + SDL_assert(bad != Expect); } /* End atomic operation test */ @@ -252,13 +248,13 @@ void RunEpicTest() */ #define TEST_SPINLOCK_FIFO -#define NUM_READERS 4 -#define NUM_WRITERS 4 -#define EVENTS_PER_WRITER 1000000 +#define NUM_READERS 4 +#define NUM_WRITERS 4 +#define EVENTS_PER_WRITER 1000000 /* The number of entries must be a power of 2 */ #define MAX_ENTRIES 256 -#define WRAP_MASK (MAX_ENTRIES-1) +#define WRAP_MASK (MAX_ENTRIES - 1) typedef struct { @@ -270,22 +266,22 @@ typedef struct { SDL_EventQueueEntry entries[MAX_ENTRIES]; - char cache_pad1[SDL_CACHELINE_SIZE-((sizeof(SDL_EventQueueEntry)*MAX_ENTRIES)%SDL_CACHELINE_SIZE)]; + char cache_pad1[SDL_CACHELINE_SIZE - ((sizeof(SDL_EventQueueEntry) * MAX_ENTRIES) % SDL_CACHELINE_SIZE)]; SDL_atomic_t enqueue_pos; - char cache_pad2[SDL_CACHELINE_SIZE-sizeof(SDL_atomic_t)]; + char cache_pad2[SDL_CACHELINE_SIZE - sizeof(SDL_atomic_t)]; SDL_atomic_t dequeue_pos; - char cache_pad3[SDL_CACHELINE_SIZE-sizeof(SDL_atomic_t)]; + char cache_pad3[SDL_CACHELINE_SIZE - sizeof(SDL_atomic_t)]; #ifdef TEST_SPINLOCK_FIFO SDL_SpinLock lock; SDL_atomic_t rwcount; SDL_atomic_t watcher; - char cache_pad4[SDL_CACHELINE_SIZE-sizeof(SDL_SpinLock)-2*sizeof(SDL_atomic_t)]; + char cache_pad4[SDL_CACHELINE_SIZE - sizeof(SDL_SpinLock) - 2 * sizeof(SDL_atomic_t)]; #endif SDL_atomic_t active; @@ -329,14 +325,14 @@ static SDL_bool EnqueueEvent_LockFree(SDL_EventQueue *queue, const SDL_Event *ev #endif queue_pos = (unsigned)SDL_AtomicGet(&queue->enqueue_pos); - for ( ; ; ) { + for (;;) { entry = &queue->entries[queue_pos & WRAP_MASK]; entry_seq = (unsigned)SDL_AtomicGet(&entry->sequence); delta = (int)(entry_seq - queue_pos); if (delta == 0) { /* The entry and the queue position match, try to increment the queue position */ - if (SDL_AtomicCAS(&queue->enqueue_pos, (int)queue_pos, (int)(queue_pos+1))) { + if (SDL_AtomicCAS(&queue->enqueue_pos, (int)queue_pos, (int)(queue_pos + 1))) { /* We own the object, fill it! */ entry->event = *event; SDL_AtomicSet(&entry->sequence, (int)(queue_pos + 1)); @@ -354,7 +350,7 @@ static SDL_bool EnqueueEvent_LockFree(SDL_EventQueue *queue, const SDL_Event *ev } #ifdef TEST_SPINLOCK_FIFO - (void) SDL_AtomicDecRef(&queue->rwcount); + (void)SDL_AtomicDecRef(&queue->rwcount); #endif return status; } @@ -376,17 +372,17 @@ static SDL_bool DequeueEvent_LockFree(SDL_EventQueue *queue, SDL_Event *event) #endif queue_pos = (unsigned)SDL_AtomicGet(&queue->dequeue_pos); - for ( ; ; ) { + for (;;) { entry = &queue->entries[queue_pos & WRAP_MASK]; entry_seq = (unsigned)SDL_AtomicGet(&entry->sequence); delta = (int)(entry_seq - (queue_pos + 1)); if (delta == 0) { /* The entry and the queue position match, try to increment the queue position */ - if (SDL_AtomicCAS(&queue->dequeue_pos, (int)queue_pos, (int)(queue_pos+1))) { + if (SDL_AtomicCAS(&queue->dequeue_pos, (int)queue_pos, (int)(queue_pos + 1))) { /* We own the object, fill it! */ *event = entry->event; - SDL_AtomicSet(&entry->sequence, (int)(queue_pos+MAX_ENTRIES)); + SDL_AtomicSet(&entry->sequence, (int)(queue_pos + MAX_ENTRIES)); status = SDL_TRUE; break; } @@ -401,7 +397,7 @@ static SDL_bool DequeueEvent_LockFree(SDL_EventQueue *queue, SDL_Event *event) } #ifdef TEST_SPINLOCK_FIFO - (void) SDL_AtomicDecRef(&queue->rwcount); + (void)SDL_AtomicDecRef(&queue->rwcount); #endif return status; } @@ -476,10 +472,10 @@ typedef struct { SDL_EventQueue *queue; int index; - char padding1[SDL_CACHELINE_SIZE-(sizeof(SDL_EventQueue*)+sizeof(int))%SDL_CACHELINE_SIZE]; + char padding1[SDL_CACHELINE_SIZE - (sizeof(SDL_EventQueue *) + sizeof(int)) % SDL_CACHELINE_SIZE]; int waits; SDL_bool lock_free; - char padding2[SDL_CACHELINE_SIZE-sizeof(int)-sizeof(SDL_bool)]; + char padding2[SDL_CACHELINE_SIZE - sizeof(int) - sizeof(SDL_bool)]; SDL_Thread *thread; } WriterData; @@ -489,11 +485,11 @@ typedef struct int counters[NUM_WRITERS]; int waits; SDL_bool lock_free; - char padding[SDL_CACHELINE_SIZE-(sizeof(SDL_EventQueue*)+sizeof(int)*NUM_WRITERS+sizeof(int)+sizeof(SDL_bool))%SDL_CACHELINE_SIZE]; + char padding[SDL_CACHELINE_SIZE - (sizeof(SDL_EventQueue *) + sizeof(int) * NUM_WRITERS + sizeof(int) + sizeof(SDL_bool)) % SDL_CACHELINE_SIZE]; SDL_Thread *thread; } ReaderData; -static int SDLCALL FIFO_Writer(void* _data) +static int SDLCALL FIFO_Writer(void *_data) { WriterData *data = (WriterData *)_data; SDL_EventQueue *queue = data->queue; @@ -526,16 +522,16 @@ static int SDLCALL FIFO_Writer(void* _data) return 0; } -static int SDLCALL FIFO_Reader(void* _data) +static int SDLCALL FIFO_Reader(void *_data) { ReaderData *data = (ReaderData *)_data; SDL_EventQueue *queue = data->queue; SDL_Event event; if (data->lock_free) { - for ( ; ; ) { + for (;;) { if (DequeueEvent_LockFree(queue, &event)) { - WriterData *writer = (WriterData*)event.user.data1; + WriterData *writer = (WriterData *)event.user.data1; ++data->counters[writer->index]; } else if (SDL_AtomicGet(&queue->active)) { ++data->waits; @@ -546,9 +542,9 @@ static int SDLCALL FIFO_Reader(void* _data) } } } else { - for ( ; ; ) { + for (;;) { if (DequeueEvent_Mutex(queue, &event)) { - WriterData *writer = (WriterData*)event.user.data1; + WriterData *writer = (WriterData *)event.user.data1; ++data->counters[writer->index]; } else if (SDL_AtomicGet(&queue->active)) { ++data->waits; @@ -564,7 +560,7 @@ static int SDLCALL FIFO_Reader(void* _data) #ifdef TEST_SPINLOCK_FIFO /* This thread periodically locks the queue for no particular reason */ -static int SDLCALL FIFO_Watcher(void* _data) +static int SDLCALL FIFO_Watcher(void *_data) { SDL_EventQueue *queue = (SDL_EventQueue *)_data; @@ -575,7 +571,7 @@ static int SDLCALL FIFO_Watcher(void* _data) SDL_Delay(0); } /* Do queue manipulation here... */ - (void) SDL_AtomicDecRef(&queue->watcher); + (void)SDL_AtomicDecRef(&queue->watcher); SDL_AtomicUnlock(&queue->lock); /* Wait a bit... */ @@ -621,7 +617,7 @@ static void RunFIFOTest(SDL_bool lock_free) SDL_zeroa(readerData); for (i = 0; i < NUM_READERS; ++i) { char name[64]; - SDL_snprintf(name, sizeof (name), "FIFOReader%d", i); + SDL_snprintf(name, sizeof(name), "FIFOReader%d", i); readerData[i].queue = &queue; readerData[i].lock_free = lock_free; readerData[i].thread = SDL_CreateThread(FIFO_Reader, name, &readerData[i]); @@ -632,7 +628,7 @@ static void RunFIFOTest(SDL_bool lock_free) SDL_zeroa(writerData); for (i = 0; i < NUM_WRITERS; ++i) { char name[64]; - SDL_snprintf(name, sizeof (name), "FIFOWriter%d", i); + SDL_snprintf(name, sizeof(name), "FIFOWriter%d", i); writerData[i].queue = &queue; writerData[i].index = i; writerData[i].lock_free = lock_free; @@ -669,7 +665,7 @@ static void RunFIFOTest(SDL_bool lock_free) for (i = 0; i < NUM_WRITERS; ++i) { SDL_Log("Writer %d wrote %d events, had %d waits\n", i, EVENTS_PER_WRITER, writerData[i].waits); } - SDL_Log("Writers wrote %d total events\n", NUM_WRITERS*EVENTS_PER_WRITER); + SDL_Log("Writers wrote %d total events\n", NUM_WRITERS * EVENTS_PER_WRITER); /* Print a breakdown of which readers read messages from which writer */ SDL_Log("\n"); @@ -700,8 +696,7 @@ static void RunFIFOTest(SDL_bool lock_free) /* End FIFO test */ /**************************************************************************/ -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { /* Enable standard application logging */ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); diff --git a/test/testaudiocapture.c b/test/testaudiocapture.c index 0a9170343..e6b9396d8 100644 --- a/test/testaudiocapture.c +++ b/test/testaudiocapture.c @@ -67,9 +67,9 @@ loop() SDL_DestroyRenderer(renderer); SDL_DestroyWindow(window); SDL_Quit(); - #ifdef __EMSCRIPTEN__ +#ifdef __EMSCRIPTEN__ emscripten_cancel_main_loop(); - #endif +#endif exit(0); } @@ -78,16 +78,15 @@ loop() trying to test the API, so we use SDL_DequeueAudio() here. */ while (SDL_TRUE) { Uint8 buf[1024]; - const Uint32 br = SDL_DequeueAudio(devid_in, buf, sizeof (buf)); + const Uint32 br = SDL_DequeueAudio(devid_in, buf, sizeof(buf)); SDL_QueueAudio(devid_out, buf, br); - if (br < sizeof (buf)) { + if (br < sizeof(buf)) { break; } } } -int -main(int argc, char **argv) +int main(int argc, char **argv) { /* (argv[1] == NULL means "open default device.") */ const char *devname = argv[1]; @@ -157,7 +156,10 @@ main(int argc, char **argv) #ifdef __EMSCRIPTEN__ emscripten_set_main_loop(loop, 0, 1); #else - while (1) { loop(); SDL_Delay(16); } + while (1) { + loop(); + SDL_Delay(16); + } #endif return 0; diff --git a/test/testaudiohotplug.c b/test/testaudiohotplug.c index 1b906e74a..2feca5a36 100644 --- a/test/testaudiohotplug.c +++ b/test/testaudiohotplug.c @@ -29,8 +29,8 @@ #include "testutils.h" static SDL_AudioSpec spec; -static Uint8 *sound = NULL; /* Pointer to wave data */ -static Uint32 soundlen = 0; /* Length of wave data */ +static Uint8 *sound = NULL; /* Pointer to wave data */ +static Uint32 soundlen = 0; /* Length of wave data */ static int posindex = 0; static Uint32 positions[64]; @@ -44,9 +44,9 @@ quit(int rc) } void SDLCALL -fillerup(void *_pos, Uint8 * stream, int len) +fillerup(void *_pos, Uint8 *stream, int len) { - Uint32 pos = *((Uint32 *) _pos); + Uint32 pos = *((Uint32 *)_pos); Uint8 *waveptr; int waveleft; @@ -65,17 +65,16 @@ fillerup(void *_pos, Uint8 * stream, int len) } SDL_memcpy(stream, waveptr, len); pos += len; - *((Uint32 *) _pos) = pos; + *((Uint32 *)_pos) = pos; } static int done = 0; -void -poked(int sig) +void poked(int sig) { done = 1; } -static const char* +static const char * devtypestr(int iscapture) { return iscapture ? "capture" : "output"; @@ -98,10 +97,10 @@ iteration() int iscapture = e.adevice.iscapture; const char *name = SDL_GetAudioDeviceName(index, iscapture); if (name != NULL) - SDL_Log("New %s audio device at index %u: %s\n", devtypestr(iscapture), (unsigned int) index, name); + SDL_Log("New %s audio device at index %u: %s\n", devtypestr(iscapture), (unsigned int)index, name); else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Got new %s device at index %u, but failed to get the name: %s\n", - devtypestr(iscapture), (unsigned int) index, SDL_GetError()); + devtypestr(iscapture), (unsigned int)index, SDL_GetError()); continue; } if (!iscapture) { @@ -112,21 +111,20 @@ iteration() if (!dev) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open '%s': %s\n", name, SDL_GetError()); } else { - SDL_Log("Opened '%s' as %u\n", name, (unsigned int) dev); + SDL_Log("Opened '%s' as %u\n", name, (unsigned int)dev); SDL_PauseAudioDevice(dev, 0); } } } else if (e.type == SDL_AUDIODEVICEREMOVED) { - dev = (SDL_AudioDeviceID) e.adevice.which; - SDL_Log("%s device %u removed.\n", devtypestr(e.adevice.iscapture), (unsigned int) dev); + dev = (SDL_AudioDeviceID)e.adevice.which; + SDL_Log("%s device %u removed.\n", devtypestr(e.adevice.iscapture), (unsigned int)dev); SDL_CloseAudioDevice(dev); } } } #ifdef __EMSCRIPTEN__ -void -loop() +void loop() { if (done) emscripten_cancel_main_loop(); @@ -135,8 +133,7 @@ loop() } #endif -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i; char *filename = NULL; diff --git a/test/testaudioinfo.c b/test/testaudioinfo.c index d2ea229e2..ecb26dc30 100644 --- a/test/testaudioinfo.c +++ b/test/testaudioinfo.c @@ -44,8 +44,7 @@ print_devices(int iscapture) } } -int -main(int argc, char **argv) +int main(int argc, char **argv) { char *deviceName = NULL; SDL_AudioSpec spec; @@ -98,7 +97,6 @@ main(int argc, char **argv) SDL_Log("SDL_AudioFormat: %X\n", spec.format); } - SDL_Quit(); return 0; } diff --git a/test/testautomation.c b/test/testautomation.c index 0245d1148..42a4ee39f 100644 --- a/test/testautomation.c +++ b/test/testautomation.c @@ -29,8 +29,7 @@ quit(int rc) exit(rc); } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int result; int testIterations = 1; @@ -63,7 +62,7 @@ main(int argc, char *argv[]) } } else if (SDL_strcasecmp(argv[i], "--execKey") == 0) { if (argv[i + 1]) { - SDL_sscanf(argv[i + 1], "%"SDL_PRIu64, &userExecKey); + SDL_sscanf(argv[i + 1], "%" SDL_PRIu64, &userExecKey); consumed = 2; } } else if (SDL_strcasecmp(argv[i], "--seed") == 0) { @@ -104,11 +103,11 @@ main(int argc, char *argv[]) /* Empty event queue */ done = 0; - for (i=0; i<100; i++) { - while (SDL_PollEvent(&event)) { - SDLTest_CommonEvent(state, &event, &done); - } - SDL_Delay(10); + for (i = 0; i < 100; i++) { + while (SDL_PollEvent(&event)) { + SDLTest_CommonEvent(state, &event, &done); + } + SDL_Delay(10); } /* Clean up */ diff --git a/test/testautomation_audio.c b/test/testautomation_audio.c index 86eb87574..fafbca37e 100644 --- a/test/testautomation_audio.c +++ b/test/testautomation_audio.c @@ -5,7 +5,7 @@ /* quiet windows compiler warnings */ #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) -# define _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_WARNINGS #endif #include @@ -18,20 +18,18 @@ /* Fixture */ -void -_audioSetUp(void *arg) +void _audioSetUp(void *arg) { /* Start SDL audio subsystem */ - int ret = SDL_InitSubSystem( SDL_INIT_AUDIO ); - SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_AUDIO)"); - SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_AUDIO)"); + int ret = SDL_InitSubSystem(SDL_INIT_AUDIO); + SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_AUDIO)"); + SDLTest_AssertCheck(ret == 0, "Check result from SDL_InitSubSystem(SDL_INIT_AUDIO)"); if (ret != 0) { - SDLTest_LogError("%s", SDL_GetError()); - } + SDLTest_LogError("%s", SDL_GetError()); + } } -void -_audioTearDown(void *arg) +void _audioTearDown(void *arg) { /* Remove a possibly created file from SDL disk writer audio driver; ignore errors */ remove("sdlaudio.raw"); @@ -39,23 +37,20 @@ _audioTearDown(void *arg) SDLTest_AssertPass("Cleanup of test files completed"); } - /* Global counter for callback invocation */ int _audio_testCallbackCounter; /* Global accumulator for total callback length */ int _audio_testCallbackLength; - /* Test callback function */ void SDLCALL _audio_testCallback(void *userdata, Uint8 *stream, int len) { - /* track that callback was called */ - _audio_testCallbackCounter++; - _audio_testCallbackLength += len; + /* track that callback was called */ + _audio_testCallbackCounter++; + _audio_testCallbackLength += len; } - /* Test case functions */ /** @@ -67,11 +62,11 @@ void SDLCALL _audio_testCallback(void *userdata, Uint8 *stream, int len) int audio_quitInitAudioSubSystem() { /* Stop SDL audio subsystem */ - SDL_QuitSubSystem( SDL_INIT_AUDIO ); - SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); + SDL_QuitSubSystem(SDL_INIT_AUDIO); + SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); - /* Restart audio again */ - _audioSetUp(NULL); + /* Restart audio again */ + _audioSetUp(NULL); return TEST_COMPLETED; } @@ -84,32 +79,32 @@ int audio_quitInitAudioSubSystem() */ int audio_initQuitAudio() { - int result; + int result; int i, iMax; - const char* audioDriver; + const char *audioDriver; /* Stop SDL audio subsystem */ - SDL_QuitSubSystem( SDL_INIT_AUDIO ); - SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); + SDL_QuitSubSystem(SDL_INIT_AUDIO); + SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); - /* Loop over all available audio drivers */ - iMax = SDL_GetNumAudioDrivers(); - SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()"); - SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax); - for (i = 0; i < iMax; i++) { - audioDriver = SDL_GetAudioDriver(i); - SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); - SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL"); - SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); + /* Loop over all available audio drivers */ + iMax = SDL_GetNumAudioDrivers(); + SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()"); + SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax); + for (i = 0; i < iMax; i++) { + audioDriver = SDL_GetAudioDriver(i); + SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); + SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL"); + SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); - /* Call Init */ - result = SDL_AudioInit(audioDriver); - SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver); - SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result); + /* Call Init */ + result = SDL_AudioInit(audioDriver); + SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver); + SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result); - /* Call Quit */ - SDL_AudioQuit(); - SDLTest_AssertPass("Call to SDL_AudioQuit()"); + /* Call Quit */ + SDL_AudioQuit(); + SDLTest_AssertPass("Call to SDL_AudioQuit()"); } /* NULL driver specification */ @@ -124,8 +119,8 @@ int audio_initQuitAudio() SDL_AudioQuit(); SDLTest_AssertPass("Call to SDL_AudioQuit()"); - /* Restart audio again */ - _audioSetUp(NULL); + /* Restart audio again */ + _audioSetUp(NULL); return TEST_COMPLETED; } @@ -142,79 +137,79 @@ int audio_initOpenCloseQuitAudio() { int result, expectedResult; int i, iMax, j, k; - const char* audioDriver; + const char *audioDriver; SDL_AudioSpec desired; /* Stop SDL audio subsystem */ - SDL_QuitSubSystem( SDL_INIT_AUDIO ); - SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); + SDL_QuitSubSystem(SDL_INIT_AUDIO); + SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); - /* Loop over all available audio drivers */ - iMax = SDL_GetNumAudioDrivers(); - SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()"); - SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax); - for (i = 0; i < iMax; i++) { - audioDriver = SDL_GetAudioDriver(i); - SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); - SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL"); - SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); + /* Loop over all available audio drivers */ + iMax = SDL_GetNumAudioDrivers(); + SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()"); + SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax); + for (i = 0; i < iMax; i++) { + audioDriver = SDL_GetAudioDriver(i); + SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); + SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL"); + SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); - /* Change specs */ - for (j = 0; j < 2; j++) { + /* Change specs */ + for (j = 0; j < 2; j++) { - /* Call Init */ - result = SDL_AudioInit(audioDriver); - SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver); - SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result); + /* Call Init */ + result = SDL_AudioInit(audioDriver); + SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver); + SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result); - /* Set spec */ - SDL_memset(&desired, 0, sizeof(desired)); - switch (j) { - case 0: - /* Set standard desired spec */ - desired.freq = 22050; - desired.format = AUDIO_S16SYS; - desired.channels = 2; - desired.samples = 4096; - desired.callback = _audio_testCallback; - desired.userdata = NULL; + /* Set spec */ + SDL_memset(&desired, 0, sizeof(desired)); + switch (j) { + case 0: + /* Set standard desired spec */ + desired.freq = 22050; + desired.format = AUDIO_S16SYS; + desired.channels = 2; + desired.samples = 4096; + desired.callback = _audio_testCallback; + desired.userdata = NULL; - case 1: - /* Set custom desired spec */ - desired.freq = 48000; - desired.format = AUDIO_F32SYS; - desired.channels = 2; - desired.samples = 2048; - desired.callback = _audio_testCallback; - desired.userdata = NULL; - break; + case 1: + /* Set custom desired spec */ + desired.freq = 48000; + desired.format = AUDIO_F32SYS; + desired.channels = 2; + desired.samples = 2048; + desired.callback = _audio_testCallback; + desired.userdata = NULL; + break; } /* Call Open (maybe multiple times) */ - for (k=0; k <= j; k++) { + for (k = 0; k <= j; k++) { result = SDL_OpenAudio(&desired, NULL); - SDLTest_AssertPass("Call to SDL_OpenAudio(desired_spec_%d, NULL), call %d", j, k+1); - expectedResult = (k==0) ? 0 : -1; + SDLTest_AssertPass("Call to SDL_OpenAudio(desired_spec_%d, NULL), call %d", j, k + 1); + expectedResult = (k == 0) ? 0 : -1; SDLTest_AssertCheck(result == expectedResult, "Verify return value; expected: %d, got: %d", expectedResult, result); } /* Call Close (maybe multiple times) */ - for (k=0; k <= j; k++) { + for (k = 0; k <= j; k++) { SDL_CloseAudio(); - SDLTest_AssertPass("Call to SDL_CloseAudio(), call %d", k+1); + SDLTest_AssertPass("Call to SDL_CloseAudio(), call %d", k + 1); } /* Call Quit (maybe multiple times) */ - for (k=0; k <= j; k++) { + for (k = 0; k <= j; k++) { SDL_AudioQuit(); - SDLTest_AssertPass("Call to SDL_AudioQuit(), call %d", k+1); + SDLTest_AssertPass("Call to SDL_AudioQuit(), call %d", k + 1); } } /* spec loop */ - } /* driver loop */ + } /* driver loop */ - /* Restart audio again */ - _audioSetUp(NULL); + /* Restart audio again */ + _audioSetUp(NULL); return TEST_COMPLETED; } @@ -231,52 +226,52 @@ int audio_pauseUnpauseAudio() int totalDelay; int pause_on; int originalCounter; - const char* audioDriver; + const char *audioDriver; SDL_AudioSpec desired; /* Stop SDL audio subsystem */ - SDL_QuitSubSystem( SDL_INIT_AUDIO ); - SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); + SDL_QuitSubSystem(SDL_INIT_AUDIO); + SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); - /* Loop over all available audio drivers */ - iMax = SDL_GetNumAudioDrivers(); - SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()"); - SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax); - for (i = 0; i < iMax; i++) { - audioDriver = SDL_GetAudioDriver(i); - SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); - SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL"); - SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); + /* Loop over all available audio drivers */ + iMax = SDL_GetNumAudioDrivers(); + SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()"); + SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax); + for (i = 0; i < iMax; i++) { + audioDriver = SDL_GetAudioDriver(i); + SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); + SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL"); + SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); - /* Change specs */ - for (j = 0; j < 2; j++) { + /* Change specs */ + for (j = 0; j < 2; j++) { - /* Call Init */ - result = SDL_AudioInit(audioDriver); - SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver); - SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result); + /* Call Init */ + result = SDL_AudioInit(audioDriver); + SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver); + SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result); - /* Set spec */ - SDL_memset(&desired, 0, sizeof(desired)); - switch (j) { - case 0: - /* Set standard desired spec */ - desired.freq = 22050; - desired.format = AUDIO_S16SYS; - desired.channels = 2; - desired.samples = 4096; - desired.callback = _audio_testCallback; - desired.userdata = NULL; + /* Set spec */ + SDL_memset(&desired, 0, sizeof(desired)); + switch (j) { + case 0: + /* Set standard desired spec */ + desired.freq = 22050; + desired.format = AUDIO_S16SYS; + desired.channels = 2; + desired.samples = 4096; + desired.callback = _audio_testCallback; + desired.userdata = NULL; - case 1: - /* Set custom desired spec */ - desired.freq = 48000; - desired.format = AUDIO_F32SYS; - desired.channels = 2; - desired.samples = 2048; - desired.callback = _audio_testCallback; - desired.userdata = NULL; - break; + case 1: + /* Set custom desired spec */ + desired.freq = 48000; + desired.format = AUDIO_F32SYS; + desired.channels = 2; + desired.samples = 2048; + desired.callback = _audio_testCallback; + desired.userdata = NULL; + break; } /* Call Open */ @@ -285,37 +280,36 @@ int audio_pauseUnpauseAudio() SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0 got: %d", result); /* Start and stop audio multiple times */ - for (l=0; l<3; l++) { - SDLTest_Log("Pause/Unpause iteration: %d", l+1); - + for (l = 0; l < 3; l++) { + SDLTest_Log("Pause/Unpause iteration: %d", l + 1); + /* Reset callback counters */ _audio_testCallbackCounter = 0; _audio_testCallbackLength = 0; /* Un-pause audio to start playing (maybe multiple times) */ pause_on = 0; - for (k=0; k <= j; k++) { + for (k = 0; k <= j; k++) { SDL_PauseAudio(pause_on); - SDLTest_AssertPass("Call to SDL_PauseAudio(%d), call %d", pause_on, k+1); + SDLTest_AssertPass("Call to SDL_PauseAudio(%d), call %d", pause_on, k + 1); } - + /* Wait for callback */ totalDelay = 0; do { SDL_Delay(10); totalDelay += 10; - } - while (_audio_testCallbackCounter == 0 && totalDelay < 1000); + } while (_audio_testCallbackCounter == 0 && totalDelay < 1000); SDLTest_AssertCheck(_audio_testCallbackCounter > 0, "Verify callback counter; expected: >0 got: %d", _audio_testCallbackCounter); SDLTest_AssertCheck(_audio_testCallbackLength > 0, "Verify callback length; expected: >0 got: %d", _audio_testCallbackLength); /* Pause audio to stop playing (maybe multiple times) */ - for (k=0; k <= j; k++) { - pause_on = (k==0) ? 1 : SDLTest_RandomIntegerInRange(99, 9999); + for (k = 0; k <= j; k++) { + pause_on = (k == 0) ? 1 : SDLTest_RandomIntegerInRange(99, 9999); SDL_PauseAudio(pause_on); - SDLTest_AssertPass("Call to SDL_PauseAudio(%d), call %d", pause_on, k+1); + SDLTest_AssertPass("Call to SDL_PauseAudio(%d), call %d", pause_on, k + 1); } - + /* Ensure callback is not called again */ originalCounter = _audio_testCallbackCounter; SDL_Delay(totalDelay + 10); @@ -331,7 +325,7 @@ int audio_pauseUnpauseAudio() SDLTest_AssertPass("Call to SDL_AudioQuit()"); } /* spec loop */ - } /* driver loop */ + } /* driver loop */ /* Restart audio again */ _audioSetUp(NULL); @@ -347,54 +341,54 @@ int audio_pauseUnpauseAudio() */ int audio_enumerateAndNameAudioDevices() { - int t, tt; - int i, n, nn; - const char *name, *nameAgain; + int t, tt; + int i, n, nn; + const char *name, *nameAgain; - /* Iterate over types: t=0 output device, t=1 input/capture device */ - for (t=0; t<2; t++) { + /* Iterate over types: t=0 output device, t=1 input/capture device */ + for (t = 0; t < 2; t++) { - /* Get number of devices. */ - n = SDL_GetNumAudioDevices(t); - SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(%i)", t); - SDLTest_Log("Number of %s devices < 0, reported as %i", (t) ? "capture" : "output", n); - SDLTest_AssertCheck(n >= 0, "Validate result is >= 0, got: %i", n); + /* Get number of devices. */ + n = SDL_GetNumAudioDevices(t); + SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(%i)", t); + SDLTest_Log("Number of %s devices < 0, reported as %i", (t) ? "capture" : "output", n); + SDLTest_AssertCheck(n >= 0, "Validate result is >= 0, got: %i", n); - /* Variation of non-zero type */ - if (t==1) { - tt = t + SDLTest_RandomIntegerInRange(1,10); - nn = SDL_GetNumAudioDevices(tt); - SDLTest_AssertCheck(n==nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", tt, n, nn); - nn = SDL_GetNumAudioDevices(-tt); - SDLTest_AssertCheck(n==nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", -tt, n, nn); - } + /* Variation of non-zero type */ + if (t == 1) { + tt = t + SDLTest_RandomIntegerInRange(1, 10); + nn = SDL_GetNumAudioDevices(tt); + SDLTest_AssertCheck(n == nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", tt, n, nn); + nn = SDL_GetNumAudioDevices(-tt); + SDLTest_AssertCheck(n == nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", -tt, n, nn); + } - /* List devices. */ - if (n>0) { - for (i=0; i 0) { + for (i = 0; i < n; i++) { + name = SDL_GetAudioDeviceName(i, t); + SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t); + SDLTest_AssertCheck(name != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, t); + if (name != NULL) { + SDLTest_AssertCheck(name[0] != '\0', "verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, t, name); + if (t == 1) { + /* Also try non-zero type */ + tt = t + SDLTest_RandomIntegerInRange(1, 10); + nameAgain = SDL_GetAudioDeviceName(i, tt); + SDLTest_AssertCheck(nameAgain != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, tt); + if (nameAgain != NULL) { + SDLTest_AssertCheck(nameAgain[0] != '\0', "Verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, tt, nameAgain); + SDLTest_AssertCheck(SDL_strcmp(name, nameAgain) == 0, + "Verify SDL_GetAudioDeviceName(%i, %i) and SDL_GetAudioDeviceName(%i %i) return the same string", + i, t, i, tt); + } + } + } } - } - } - } + } + } - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -405,45 +399,44 @@ int audio_enumerateAndNameAudioDevices() */ int audio_enumerateAndNameAudioDevicesNegativeTests() { - int t; - int i, j, no, nc; - const char *name; + int t; + int i, j, no, nc; + const char *name; - /* Get number of devices. */ - no = SDL_GetNumAudioDevices(0); - SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)"); - nc = SDL_GetNumAudioDevices(1); - SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(1)"); + /* Get number of devices. */ + no = SDL_GetNumAudioDevices(0); + SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)"); + nc = SDL_GetNumAudioDevices(1); + SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(1)"); - /* Invalid device index when getting name */ - for (t=0; t<2; t++) { - /* Negative device index */ - i = SDLTest_RandomIntegerInRange(-10,-1); - name = SDL_GetAudioDeviceName(i, t); - SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t); - SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result NULL, expected NULL, got: %s", i, t, (name == NULL) ? "NULL" : name); + /* Invalid device index when getting name */ + for (t = 0; t < 2; t++) { + /* Negative device index */ + i = SDLTest_RandomIntegerInRange(-10, -1); + name = SDL_GetAudioDeviceName(i, t); + SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t); + SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result NULL, expected NULL, got: %s", i, t, (name == NULL) ? "NULL" : name); - /* Device index past range */ - for (j=0; j<3; j++) { - i = (t) ? nc+j : no+j; - name = SDL_GetAudioDeviceName(i, t); - SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t); - SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name == NULL) ? "NULL" : name); - } + /* Device index past range */ + for (j = 0; j < 3; j++) { + i = (t) ? nc + j : no + j; + name = SDL_GetAudioDeviceName(i, t); + SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t); + SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name == NULL) ? "NULL" : name); + } - /* Capture index past capture range but within output range */ - if ((no>0) && (no>nc) && (t==1)) { - i = no-1; - name = SDL_GetAudioDeviceName(i, t); - SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t); - SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name == NULL) ? "NULL" : name); - } - } + /* Capture index past capture range but within output range */ + if ((no > 0) && (no > nc) && (t == 1)) { + i = no - 1; + name = SDL_GetAudioDeviceName(i, t); + SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t); + SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name == NULL) ? "NULL" : name); + } + } - return TEST_COMPLETED; + return TEST_COMPLETED; } - /** * \brief Checks available audio driver names. * @@ -452,30 +445,29 @@ int audio_enumerateAndNameAudioDevicesNegativeTests() */ int audio_printAudioDrivers() { - int i, n; - const char *name; + int i, n; + const char *name; - /* Get number of drivers */ - n = SDL_GetNumAudioDrivers(); - SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()"); - SDLTest_AssertCheck(n>=0, "Verify number of audio drivers >= 0, got: %i", n); + /* Get number of drivers */ + n = SDL_GetNumAudioDrivers(); + SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()"); + SDLTest_AssertCheck(n >= 0, "Verify number of audio drivers >= 0, got: %i", n); - /* List drivers. */ - if (n>0) { - for (i=0; i 0) { + for (i = 0; i < n; i++) { + name = SDL_GetAudioDriver(i); + SDLTest_AssertPass("Call to SDL_GetAudioDriver(%i)", i); + SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL"); + if (name != NULL) { + SDLTest_AssertCheck(name[0] != '\0', "Verify returned name is not empty, got: '%s'", name); + } + } + } - return TEST_COMPLETED; + return TEST_COMPLETED; } - /** * \brief Checks current audio driver name with initialized audio. * @@ -483,31 +475,30 @@ int audio_printAudioDrivers() */ int audio_printCurrentAudioDriver() { - /* Check current audio driver */ - const char *name = SDL_GetCurrentAudioDriver(); - SDLTest_AssertPass("Call to SDL_GetCurrentAudioDriver()"); - SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL"); - if (name != NULL) { - SDLTest_AssertCheck(name[0] != '\0', "Verify returned name is not empty, got: '%s'", name); - } + /* Check current audio driver */ + const char *name = SDL_GetCurrentAudioDriver(); + SDLTest_AssertPass("Call to SDL_GetCurrentAudioDriver()"); + SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL"); + if (name != NULL) { + SDLTest_AssertCheck(name[0] != '\0', "Verify returned name is not empty, got: '%s'", name); + } - return TEST_COMPLETED; + return TEST_COMPLETED; } /* Definition of all formats, channels, and frequencies used to test audio conversions */ const int _numAudioFormats = 18; SDL_AudioFormat _audioFormats[] = { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S16SYS, AUDIO_S16, AUDIO_U16LSB, - AUDIO_U16MSB, AUDIO_U16SYS, AUDIO_U16, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S32SYS, AUDIO_S32, - AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_F32SYS, AUDIO_F32 }; + AUDIO_U16MSB, AUDIO_U16SYS, AUDIO_U16, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S32SYS, AUDIO_S32, + AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_F32SYS, AUDIO_F32 }; const char *_audioFormatsVerbose[] = { "AUDIO_S8", "AUDIO_U8", "AUDIO_S16LSB", "AUDIO_S16MSB", "AUDIO_S16SYS", "AUDIO_S16", "AUDIO_U16LSB", - "AUDIO_U16MSB", "AUDIO_U16SYS", "AUDIO_U16", "AUDIO_S32LSB", "AUDIO_S32MSB", "AUDIO_S32SYS", "AUDIO_S32", - "AUDIO_F32LSB", "AUDIO_F32MSB", "AUDIO_F32SYS", "AUDIO_F32" }; + "AUDIO_U16MSB", "AUDIO_U16SYS", "AUDIO_U16", "AUDIO_S32LSB", "AUDIO_S32MSB", "AUDIO_S32SYS", "AUDIO_S32", + "AUDIO_F32LSB", "AUDIO_F32MSB", "AUDIO_F32SYS", "AUDIO_F32" }; const int _numAudioChannels = 4; Uint8 _audioChannels[] = { 1, 2, 4, 6 }; const int _numAudioFrequencies = 4; int _audioFrequencies[] = { 11025, 22050, 44100, 48000 }; - /** * \brief Builds various audio conversion structures * @@ -515,61 +506,61 @@ int _audioFrequencies[] = { 11025, 22050, 44100, 48000 }; */ int audio_buildAudioCVT() { - int result; - SDL_AudioCVT cvt; - SDL_AudioSpec spec1; - SDL_AudioSpec spec2; - int i, ii, j, jj, k, kk; + int result; + SDL_AudioCVT cvt; + SDL_AudioSpec spec1; + SDL_AudioSpec spec2; + int i, ii, j, jj, k, kk; - /* No conversion needed */ - spec1.format = AUDIO_S16LSB; - spec1.channels = 2; - spec1.freq = 22050; - result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, - spec1.format, spec1.channels, spec1.freq); - SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec1)"); - SDLTest_AssertCheck(result == 0, "Verify result value; expected: 0, got: %i", result); + /* No conversion needed */ + spec1.format = AUDIO_S16LSB; + spec1.channels = 2; + spec1.freq = 22050; + result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, + spec1.format, spec1.channels, spec1.freq); + SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec1)"); + SDLTest_AssertCheck(result == 0, "Verify result value; expected: 0, got: %i", result); - /* Typical conversion */ - spec1.format = AUDIO_S8; - spec1.channels = 1; - spec1.freq = 22050; - spec2.format = AUDIO_S16LSB; - spec2.channels = 2; - spec2.freq = 44100; - result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, - spec2.format, spec2.channels, spec2.freq); - SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec2)"); - SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result); + /* Typical conversion */ + spec1.format = AUDIO_S8; + spec1.channels = 1; + spec1.freq = 22050; + spec2.format = AUDIO_S16LSB; + spec2.channels = 2; + spec2.freq = 44100; + result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, + spec2.format, spec2.channels, spec2.freq); + SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec2)"); + SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result); - /* All source conversions with random conversion targets, allow 'null' conversions */ - for (i = 0; i < _numAudioFormats; i++) { - for (j = 0; j < _numAudioChannels; j++) { - for (k = 0; k < _numAudioFrequencies; k++) { - spec1.format = _audioFormats[i]; - spec1.channels = _audioChannels[j]; - spec1.freq = _audioFrequencies[k]; - ii = SDLTest_RandomIntegerInRange(0, _numAudioFormats - 1); - jj = SDLTest_RandomIntegerInRange(0, _numAudioChannels - 1); - kk = SDLTest_RandomIntegerInRange(0, _numAudioFrequencies - 1); - spec2.format = _audioFormats[ii]; - spec2.channels = _audioChannels[jj]; - spec2.freq = _audioFrequencies[kk]; - result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, - spec2.format, spec2.channels, spec2.freq); - SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)", - i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq); - SDLTest_AssertCheck(result == 0 || result == 1, "Verify result value; expected: 0 or 1, got: %i", result); - if (result<0) { - SDLTest_LogError("%s", SDL_GetError()); - } else { - SDLTest_AssertCheck(cvt.len_mult > 0, "Verify that cvt.len_mult value; expected: >0, got: %i", cvt.len_mult); + /* All source conversions with random conversion targets, allow 'null' conversions */ + for (i = 0; i < _numAudioFormats; i++) { + for (j = 0; j < _numAudioChannels; j++) { + for (k = 0; k < _numAudioFrequencies; k++) { + spec1.format = _audioFormats[i]; + spec1.channels = _audioChannels[j]; + spec1.freq = _audioFrequencies[k]; + ii = SDLTest_RandomIntegerInRange(0, _numAudioFormats - 1); + jj = SDLTest_RandomIntegerInRange(0, _numAudioChannels - 1); + kk = SDLTest_RandomIntegerInRange(0, _numAudioFrequencies - 1); + spec2.format = _audioFormats[ii]; + spec2.channels = _audioChannels[jj]; + spec2.freq = _audioFrequencies[kk]; + result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, + spec2.format, spec2.channels, spec2.freq); + SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)", + i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq); + SDLTest_AssertCheck(result == 0 || result == 1, "Verify result value; expected: 0 or 1, got: %i", result); + if (result < 0) { + SDLTest_LogError("%s", SDL_GetError()); + } else { + SDLTest_AssertCheck(cvt.len_mult > 0, "Verify that cvt.len_mult value; expected: >0, got: %i", cvt.len_mult); + } + } } - } } - } - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -579,42 +570,16 @@ int audio_buildAudioCVT() */ int audio_buildAudioCVTNegative() { - const char *expectedError = "Parameter 'cvt' is invalid"; - const char *error; - int result; - SDL_AudioCVT cvt; - SDL_AudioSpec spec1; - SDL_AudioSpec spec2; - int i; - char message[256]; + const char *expectedError = "Parameter 'cvt' is invalid"; + const char *error; + int result; + SDL_AudioCVT cvt; + SDL_AudioSpec spec1; + SDL_AudioSpec spec2; + int i; + char message[256]; - /* Valid format */ - spec1.format = AUDIO_S8; - spec1.channels = 1; - spec1.freq = 22050; - spec2.format = AUDIO_S16LSB; - spec2.channels = 2; - spec2.freq = 44100; - - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - - /* NULL input for CVT buffer */ - result = SDL_BuildAudioCVT((SDL_AudioCVT *)NULL, spec1.format, spec1.channels, spec1.freq, - spec2.format, spec2.channels, spec2.freq); - SDLTest_AssertPass("Call to SDL_BuildAudioCVT(NULL,...)"); - SDLTest_AssertCheck(result == -1, "Verify result value; expected: -1, got: %i", result); - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError, error); - } - - /* Invalid conversions */ - for (i = 1; i < 64; i++) { - /* Valid format to start with */ + /* Valid format */ spec1.format = AUDIO_S8; spec1.channels = 1; spec1.freq = 22050; @@ -625,46 +590,72 @@ int audio_buildAudioCVTNegative() SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); - /* Set various invalid format inputs */ - SDL_strlcpy(message, "Invalid: ", 256); - if (i & 1) { - SDL_strlcat(message, " spec1.format", 256); - spec1.format = 0; - } - if (i & 2) { - SDL_strlcat(message, " spec1.channels", 256); - spec1.channels = 0; - } - if (i & 4) { - SDL_strlcat(message, " spec1.freq", 256); - spec1.freq = 0; - } - if (i & 8) { - SDL_strlcat(message, " spec2.format", 256); - spec2.format = 0; - } - if (i & 16) { - SDL_strlcat(message, " spec2.channels", 256); - spec2.channels = 0; - } - if (i & 32) { - SDL_strlcat(message, " spec2.freq", 256); - spec2.freq = 0; - } - SDLTest_Log("%s", message); - result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, - spec2.format, spec2.channels, spec2.freq); - SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec2)"); + /* NULL input for CVT buffer */ + result = SDL_BuildAudioCVT((SDL_AudioCVT *)NULL, spec1.format, spec1.channels, spec1.freq, + spec2.format, spec2.channels, spec2.freq); + SDLTest_AssertPass("Call to SDL_BuildAudioCVT(NULL,...)"); SDLTest_AssertCheck(result == -1, "Verify result value; expected: -1, got: %i", result); error = SDL_GetError(); SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL && error[0] != '\0', "Validate that error message was not NULL or empty"); - } + SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); + if (error != NULL) { + SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, + "Validate error message, expected: '%s', got: '%s'", expectedError, error); + } - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); + /* Invalid conversions */ + for (i = 1; i < 64; i++) { + /* Valid format to start with */ + spec1.format = AUDIO_S8; + spec1.channels = 1; + spec1.freq = 22050; + spec2.format = AUDIO_S16LSB; + spec2.channels = 2; + spec2.freq = 44100; - return TEST_COMPLETED; + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); + + /* Set various invalid format inputs */ + SDL_strlcpy(message, "Invalid: ", 256); + if (i & 1) { + SDL_strlcat(message, " spec1.format", 256); + spec1.format = 0; + } + if (i & 2) { + SDL_strlcat(message, " spec1.channels", 256); + spec1.channels = 0; + } + if (i & 4) { + SDL_strlcat(message, " spec1.freq", 256); + spec1.freq = 0; + } + if (i & 8) { + SDL_strlcat(message, " spec2.format", 256); + spec2.format = 0; + } + if (i & 16) { + SDL_strlcat(message, " spec2.channels", 256); + spec2.channels = 0; + } + if (i & 32) { + SDL_strlcat(message, " spec2.freq", 256); + spec2.freq = 0; + } + SDLTest_Log("%s", message); + result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, + spec2.format, spec2.channels, spec2.freq); + SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec2)"); + SDLTest_AssertCheck(result == -1, "Verify result value; expected: -1, got: %i", result); + error = SDL_GetError(); + SDLTest_AssertPass("Call to SDL_GetError()"); + SDLTest_AssertCheck(error != NULL && error[0] != '\0', "Validate that error message was not NULL or empty"); + } + + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); + + return TEST_COMPLETED; } /** @@ -674,20 +665,18 @@ int audio_buildAudioCVTNegative() */ int audio_getAudioStatus() { - SDL_AudioStatus result; + SDL_AudioStatus result; - /* Check current audio status */ - result = SDL_GetAudioStatus(); - SDLTest_AssertPass("Call to SDL_GetAudioStatus()"); - SDLTest_AssertCheck(result == SDL_AUDIO_STOPPED || result == SDL_AUDIO_PLAYING || result == SDL_AUDIO_PAUSED, - "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i", - SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED, result); + /* Check current audio status */ + result = SDL_GetAudioStatus(); + SDLTest_AssertPass("Call to SDL_GetAudioStatus()"); + SDLTest_AssertCheck(result == SDL_AUDIO_STOPPED || result == SDL_AUDIO_PLAYING || result == SDL_AUDIO_PAUSED, + "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i", + SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED, result); - return TEST_COMPLETED; + return TEST_COMPLETED; } - - /** * \brief Opens, checks current audio status, and closes a device. * @@ -695,57 +684,57 @@ int audio_getAudioStatus() */ int audio_openCloseAndGetAudioStatus() { - SDL_AudioStatus result; - int i; - int count; - const char *device; - SDL_AudioDeviceID id; - SDL_AudioSpec desired, obtained; + SDL_AudioStatus result; + int i; + int count; + const char *device; + SDL_AudioDeviceID id; + SDL_AudioSpec desired, obtained; - /* Get number of devices. */ - count = SDL_GetNumAudioDevices(0); - SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)"); - if (count > 0) { - for (i = 0; i < count; i++) { - /* Get device name */ - device = SDL_GetAudioDeviceName(i, 0); - SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i); - SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL"); - if (device == NULL) { - return TEST_ABORTED; - } + /* Get number of devices. */ + count = SDL_GetNumAudioDevices(0); + SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)"); + if (count > 0) { + for (i = 0; i < count; i++) { + /* Get device name */ + device = SDL_GetAudioDeviceName(i, 0); + SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i); + SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL"); + if (device == NULL) { + return TEST_ABORTED; + } - /* Set standard desired spec */ - desired.freq=22050; - desired.format=AUDIO_S16SYS; - desired.channels=2; - desired.samples=4096; - desired.callback=_audio_testCallback; - desired.userdata=NULL; + /* Set standard desired spec */ + desired.freq = 22050; + desired.format = AUDIO_S16SYS; + desired.channels = 2; + desired.samples = 4096; + desired.callback = _audio_testCallback; + desired.userdata = NULL; - /* Open device */ - id = SDL_OpenAudioDevice(device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE); - SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device); - SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %" SDL_PRIu32, id); - if (id > 1) { + /* Open device */ + id = SDL_OpenAudioDevice(device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE); + SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device); + SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %" SDL_PRIu32, id); + if (id > 1) { - /* Check device audio status */ - result = SDL_GetAudioDeviceStatus(id); - SDLTest_AssertPass("Call to SDL_GetAudioDeviceStatus()"); - SDLTest_AssertCheck(result == SDL_AUDIO_STOPPED || result == SDL_AUDIO_PLAYING || result == SDL_AUDIO_PAUSED, - "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i", - SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED, result); + /* Check device audio status */ + result = SDL_GetAudioDeviceStatus(id); + SDLTest_AssertPass("Call to SDL_GetAudioDeviceStatus()"); + SDLTest_AssertCheck(result == SDL_AUDIO_STOPPED || result == SDL_AUDIO_PLAYING || result == SDL_AUDIO_PAUSED, + "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i", + SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED, result); - /* Close device again */ - SDL_CloseAudioDevice(id); - SDLTest_AssertPass("Call to SDL_CloseAudioDevice()"); - } - } - } else { - SDLTest_Log("No devices to test with"); - } + /* Close device again */ + SDL_CloseAudioDevice(id); + SDLTest_AssertPass("Call to SDL_CloseAudioDevice()"); + } + } + } else { + SDLTest_Log("No devices to test with"); + } - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -756,63 +745,62 @@ int audio_openCloseAndGetAudioStatus() */ int audio_lockUnlockOpenAudioDevice() { - int i; - int count; - const char *device; - SDL_AudioDeviceID id; - SDL_AudioSpec desired, obtained; + int i; + int count; + const char *device; + SDL_AudioDeviceID id; + SDL_AudioSpec desired, obtained; - /* Get number of devices. */ - count = SDL_GetNumAudioDevices(0); - SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)"); - if (count > 0) { - for (i = 0; i < count; i++) { - /* Get device name */ - device = SDL_GetAudioDeviceName(i, 0); - SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i); - SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL"); - if (device == NULL) { - return TEST_ABORTED; - } + /* Get number of devices. */ + count = SDL_GetNumAudioDevices(0); + SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)"); + if (count > 0) { + for (i = 0; i < count; i++) { + /* Get device name */ + device = SDL_GetAudioDeviceName(i, 0); + SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i); + SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL"); + if (device == NULL) { + return TEST_ABORTED; + } - /* Set standard desired spec */ - desired.freq=22050; - desired.format=AUDIO_S16SYS; - desired.channels=2; - desired.samples=4096; - desired.callback=_audio_testCallback; - desired.userdata=NULL; + /* Set standard desired spec */ + desired.freq = 22050; + desired.format = AUDIO_S16SYS; + desired.channels = 2; + desired.samples = 4096; + desired.callback = _audio_testCallback; + desired.userdata = NULL; - /* Open device */ - id = SDL_OpenAudioDevice(device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE); - SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device); - SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %" SDL_PRIu32, id); - if (id > 1) { - /* Lock to protect callback */ - SDL_LockAudioDevice(id); - SDLTest_AssertPass("SDL_LockAudioDevice(%" SDL_PRIu32 ")", id); + /* Open device */ + id = SDL_OpenAudioDevice(device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE); + SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device); + SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %" SDL_PRIu32, id); + if (id > 1) { + /* Lock to protect callback */ + SDL_LockAudioDevice(id); + SDLTest_AssertPass("SDL_LockAudioDevice(%" SDL_PRIu32 ")", id); - /* Simulate callback processing */ - SDL_Delay(10); - SDLTest_Log("Simulate callback processing - delay"); + /* Simulate callback processing */ + SDL_Delay(10); + SDLTest_Log("Simulate callback processing - delay"); - /* Unlock again */ - SDL_UnlockAudioDevice(id); - SDLTest_AssertPass("SDL_UnlockAudioDevice(%" SDL_PRIu32 ")", id); + /* Unlock again */ + SDL_UnlockAudioDevice(id); + SDLTest_AssertPass("SDL_UnlockAudioDevice(%" SDL_PRIu32 ")", id); - /* Close device again */ - SDL_CloseAudioDevice(id); - SDLTest_AssertPass("Call to SDL_CloseAudioDevice()"); - } - } - } else { - SDLTest_Log("No devices to test with"); - } + /* Close device again */ + SDL_CloseAudioDevice(id); + SDLTest_AssertPass("Call to SDL_CloseAudioDevice()"); + } + } + } else { + SDLTest_Log("No devices to test with"); + } - return TEST_COMPLETED; + return TEST_COMPLETED; } - /** * \brief Convert audio using various conversion structures * @@ -821,101 +809,100 @@ int audio_lockUnlockOpenAudioDevice() */ int audio_convertAudio() { - int result; - SDL_AudioCVT cvt; - SDL_AudioSpec spec1; - SDL_AudioSpec spec2; - int c; - char message[128]; - int i, ii, j, jj, k, kk, l, ll; + int result; + SDL_AudioCVT cvt; + SDL_AudioSpec spec1; + SDL_AudioSpec spec2; + int c; + char message[128]; + int i, ii, j, jj, k, kk, l, ll; - /* Iterate over bitmask that determines which parameters are modified in the conversion */ - for (c = 1; c < 8; c++) { - SDL_strlcpy(message, "Changing:", 128); - if (c & 1) { - SDL_strlcat(message, " Format", 128); - } - if (c & 2) { - SDL_strlcat(message, " Channels", 128); - } - if (c & 4) { - SDL_strlcat(message, " Frequencies", 128); - } - SDLTest_Log("%s", message); - /* All source conversions with random conversion targets */ - for (i = 0; i < _numAudioFormats; i++) { - for (j = 0; j < _numAudioChannels; j++) { - for (k = 0; k < _numAudioFrequencies; k++) { - spec1.format = _audioFormats[i]; - spec1.channels = _audioChannels[j]; - spec1.freq = _audioFrequencies[k]; - - /* Ensure we have a different target format */ - do { - if (c & 1) { - ii = SDLTest_RandomIntegerInRange(0, _numAudioFormats - 1); - } else { - ii = 1; - } - if (c & 2) { - jj = SDLTest_RandomIntegerInRange(0, _numAudioChannels - 1); - } else { - jj= j; - } - if (c & 4) { - kk = SDLTest_RandomIntegerInRange(0, _numAudioFrequencies - 1); - } else { - kk = k; - } - } while ((i == ii) && (j == jj) && (k == kk)); - spec2.format = _audioFormats[ii]; - spec2.channels = _audioChannels[jj]; - spec2.freq = _audioFrequencies[kk]; - - result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, - spec2.format, spec2.channels, spec2.freq); - SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)", - i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq); - SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result); - if (result != 1) { - SDLTest_LogError("%s", SDL_GetError()); - } else { - SDLTest_AssertCheck(cvt.len_mult > 0, "Verify that cvt.len_mult value; expected: >0, got: %i", cvt.len_mult); - if (cvt.len_mult < 1) { - return TEST_ABORTED; - } - - /* Create some random data to convert */ - l = 64; - ll = l * cvt.len_mult; - SDLTest_Log("Creating dummy sample buffer of %i length (%i bytes)", l, ll); - cvt.len = l; - cvt.buf = (Uint8 *)SDL_malloc(ll); - SDLTest_AssertCheck(cvt.buf != NULL, "Check data buffer to convert is not NULL"); - if (cvt.buf == NULL) { - return TEST_ABORTED; - } - - /* Convert the data */ - result = SDL_ConvertAudio(&cvt); - SDLTest_AssertPass("Call to SDL_ConvertAudio()"); - SDLTest_AssertCheck(result == 0, "Verify result value; expected: 0; got: %i", result); - SDLTest_AssertCheck(cvt.buf != NULL, "Verify conversion buffer is not NULL"); - SDLTest_AssertCheck(cvt.len_ratio > 0.0, "Verify conversion length ratio; expected: >0; got: %f", cvt.len_ratio); - - /* Free converted buffer */ - SDL_free(cvt.buf); - cvt.buf = NULL; - } + /* Iterate over bitmask that determines which parameters are modified in the conversion */ + for (c = 1; c < 8; c++) { + SDL_strlcpy(message, "Changing:", 128); + if (c & 1) { + SDL_strlcat(message, " Format", 128); + } + if (c & 2) { + SDL_strlcat(message, " Channels", 128); + } + if (c & 4) { + SDL_strlcat(message, " Frequencies", 128); + } + SDLTest_Log("%s", message); + /* All source conversions with random conversion targets */ + for (i = 0; i < _numAudioFormats; i++) { + for (j = 0; j < _numAudioChannels; j++) { + for (k = 0; k < _numAudioFrequencies; k++) { + spec1.format = _audioFormats[i]; + spec1.channels = _audioChannels[j]; + spec1.freq = _audioFrequencies[k]; + + /* Ensure we have a different target format */ + do { + if (c & 1) { + ii = SDLTest_RandomIntegerInRange(0, _numAudioFormats - 1); + } else { + ii = 1; + } + if (c & 2) { + jj = SDLTest_RandomIntegerInRange(0, _numAudioChannels - 1); + } else { + jj = j; + } + if (c & 4) { + kk = SDLTest_RandomIntegerInRange(0, _numAudioFrequencies - 1); + } else { + kk = k; + } + } while ((i == ii) && (j == jj) && (k == kk)); + spec2.format = _audioFormats[ii]; + spec2.channels = _audioChannels[jj]; + spec2.freq = _audioFrequencies[kk]; + + result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, + spec2.format, spec2.channels, spec2.freq); + SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)", + i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq); + SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result); + if (result != 1) { + SDLTest_LogError("%s", SDL_GetError()); + } else { + SDLTest_AssertCheck(cvt.len_mult > 0, "Verify that cvt.len_mult value; expected: >0, got: %i", cvt.len_mult); + if (cvt.len_mult < 1) { + return TEST_ABORTED; + } + + /* Create some random data to convert */ + l = 64; + ll = l * cvt.len_mult; + SDLTest_Log("Creating dummy sample buffer of %i length (%i bytes)", l, ll); + cvt.len = l; + cvt.buf = (Uint8 *)SDL_malloc(ll); + SDLTest_AssertCheck(cvt.buf != NULL, "Check data buffer to convert is not NULL"); + if (cvt.buf == NULL) { + return TEST_ABORTED; + } + + /* Convert the data */ + result = SDL_ConvertAudio(&cvt); + SDLTest_AssertPass("Call to SDL_ConvertAudio()"); + SDLTest_AssertCheck(result == 0, "Verify result value; expected: 0; got: %i", result); + SDLTest_AssertCheck(cvt.buf != NULL, "Verify conversion buffer is not NULL"); + SDLTest_AssertCheck(cvt.len_ratio > 0.0, "Verify conversion length ratio; expected: >0; got: %f", cvt.len_ratio); + + /* Free converted buffer */ + SDL_free(cvt.buf); + cvt.buf = NULL; + } + } + } } - } } - } - return TEST_COMPLETED; + return TEST_COMPLETED; } - /** * \brief Opens, checks current connected status, and closes a device. * @@ -923,118 +910,131 @@ int audio_convertAudio() */ int audio_openCloseAudioDeviceConnected() { - int result = -1; - int i; - int count; - const char *device; - SDL_AudioDeviceID id; - SDL_AudioSpec desired, obtained; + int result = -1; + int i; + int count; + const char *device; + SDL_AudioDeviceID id; + SDL_AudioSpec desired, obtained; - /* Get number of devices. */ - count = SDL_GetNumAudioDevices(0); - SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)"); - if (count > 0) { - for (i = 0; i < count; i++) { - /* Get device name */ - device = SDL_GetAudioDeviceName(i, 0); - SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i); - SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL"); - if (device == NULL) { - return TEST_ABORTED; - } + /* Get number of devices. */ + count = SDL_GetNumAudioDevices(0); + SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)"); + if (count > 0) { + for (i = 0; i < count; i++) { + /* Get device name */ + device = SDL_GetAudioDeviceName(i, 0); + SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i); + SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL"); + if (device == NULL) { + return TEST_ABORTED; + } - /* Set standard desired spec */ - desired.freq=22050; - desired.format=AUDIO_S16SYS; - desired.channels=2; - desired.samples=4096; - desired.callback=_audio_testCallback; - desired.userdata=NULL; + /* Set standard desired spec */ + desired.freq = 22050; + desired.format = AUDIO_S16SYS; + desired.channels = 2; + desired.samples = 4096; + desired.callback = _audio_testCallback; + desired.userdata = NULL; - /* Open device */ - id = SDL_OpenAudioDevice(device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE); - SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device); - SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >1, got: %" SDL_PRIu32, id); - if (id > 1) { + /* Open device */ + id = SDL_OpenAudioDevice(device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE); + SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device); + SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >1, got: %" SDL_PRIu32, id); + if (id > 1) { /* TODO: enable test code when function is available in SDL2 */ #ifdef AUDIODEVICECONNECTED_DEFINED - /* Get connected status */ - result = SDL_AudioDeviceConnected(id); - SDLTest_AssertPass("Call to SDL_AudioDeviceConnected()"); + /* Get connected status */ + result = SDL_AudioDeviceConnected(id); + SDLTest_AssertPass("Call to SDL_AudioDeviceConnected()"); #endif - SDLTest_AssertCheck(result == 1, "Verify returned value; expected: 1; got: %i", result); + SDLTest_AssertCheck(result == 1, "Verify returned value; expected: 1; got: %i", result); - /* Close device again */ - SDL_CloseAudioDevice(id); - SDLTest_AssertPass("Call to SDL_CloseAudioDevice()"); - } - } - } else { - SDLTest_Log("No devices to test with"); - } + /* Close device again */ + SDL_CloseAudioDevice(id); + SDLTest_AssertPass("Call to SDL_CloseAudioDevice()"); + } + } + } else { + SDLTest_Log("No devices to test with"); + } - return TEST_COMPLETED; + return TEST_COMPLETED; } - - /* ================= Test Case References ================== */ /* Audio test cases */ -static const SDLTest_TestCaseReference audioTest1 = - { (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevices, "audio_enumerateAndNameAudioDevices", "Enumerate and name available audio devices (output and capture)", TEST_ENABLED }; +static const SDLTest_TestCaseReference audioTest1 = { + (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevices, "audio_enumerateAndNameAudioDevices", "Enumerate and name available audio devices (output and capture)", TEST_ENABLED +}; -static const SDLTest_TestCaseReference audioTest2 = - { (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevicesNegativeTests, "audio_enumerateAndNameAudioDevicesNegativeTests", "Negative tests around enumeration and naming of audio devices.", TEST_ENABLED }; +static const SDLTest_TestCaseReference audioTest2 = { + (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevicesNegativeTests, "audio_enumerateAndNameAudioDevicesNegativeTests", "Negative tests around enumeration and naming of audio devices.", TEST_ENABLED +}; -static const SDLTest_TestCaseReference audioTest3 = - { (SDLTest_TestCaseFp)audio_printAudioDrivers, "audio_printAudioDrivers", "Checks available audio driver names.", TEST_ENABLED }; +static const SDLTest_TestCaseReference audioTest3 = { + (SDLTest_TestCaseFp)audio_printAudioDrivers, "audio_printAudioDrivers", "Checks available audio driver names.", TEST_ENABLED +}; -static const SDLTest_TestCaseReference audioTest4 = - { (SDLTest_TestCaseFp)audio_printCurrentAudioDriver, "audio_printCurrentAudioDriver", "Checks current audio driver name with initialized audio.", TEST_ENABLED }; +static const SDLTest_TestCaseReference audioTest4 = { + (SDLTest_TestCaseFp)audio_printCurrentAudioDriver, "audio_printCurrentAudioDriver", "Checks current audio driver name with initialized audio.", TEST_ENABLED +}; -static const SDLTest_TestCaseReference audioTest5 = - { (SDLTest_TestCaseFp)audio_buildAudioCVT, "audio_buildAudioCVT", "Builds various audio conversion structures.", TEST_ENABLED }; +static const SDLTest_TestCaseReference audioTest5 = { + (SDLTest_TestCaseFp)audio_buildAudioCVT, "audio_buildAudioCVT", "Builds various audio conversion structures.", TEST_ENABLED +}; -static const SDLTest_TestCaseReference audioTest6 = - { (SDLTest_TestCaseFp)audio_buildAudioCVTNegative, "audio_buildAudioCVTNegative", "Checks calls with invalid input to SDL_BuildAudioCVT", TEST_ENABLED }; +static const SDLTest_TestCaseReference audioTest6 = { + (SDLTest_TestCaseFp)audio_buildAudioCVTNegative, "audio_buildAudioCVTNegative", "Checks calls with invalid input to SDL_BuildAudioCVT", TEST_ENABLED +}; -static const SDLTest_TestCaseReference audioTest7 = - { (SDLTest_TestCaseFp)audio_getAudioStatus, "audio_getAudioStatus", "Checks current audio status.", TEST_ENABLED }; +static const SDLTest_TestCaseReference audioTest7 = { + (SDLTest_TestCaseFp)audio_getAudioStatus, "audio_getAudioStatus", "Checks current audio status.", TEST_ENABLED +}; -static const SDLTest_TestCaseReference audioTest8 = - { (SDLTest_TestCaseFp)audio_openCloseAndGetAudioStatus, "audio_openCloseAndGetAudioStatus", "Opens and closes audio device and get audio status.", TEST_ENABLED }; +static const SDLTest_TestCaseReference audioTest8 = { + (SDLTest_TestCaseFp)audio_openCloseAndGetAudioStatus, "audio_openCloseAndGetAudioStatus", "Opens and closes audio device and get audio status.", TEST_ENABLED +}; -static const SDLTest_TestCaseReference audioTest9 = - { (SDLTest_TestCaseFp)audio_lockUnlockOpenAudioDevice, "audio_lockUnlockOpenAudioDevice", "Locks and unlocks an open audio device.", TEST_ENABLED }; +static const SDLTest_TestCaseReference audioTest9 = { + (SDLTest_TestCaseFp)audio_lockUnlockOpenAudioDevice, "audio_lockUnlockOpenAudioDevice", "Locks and unlocks an open audio device.", TEST_ENABLED +}; /* TODO: enable test when SDL_ConvertAudio segfaults on cygwin have been fixed. */ /* For debugging, test case can be run manually using --filter audio_convertAudio */ -static const SDLTest_TestCaseReference audioTest10 = - { (SDLTest_TestCaseFp)audio_convertAudio, "audio_convertAudio", "Convert audio using available formats.", TEST_DISABLED }; +static const SDLTest_TestCaseReference audioTest10 = { + (SDLTest_TestCaseFp)audio_convertAudio, "audio_convertAudio", "Convert audio using available formats.", TEST_DISABLED +}; /* TODO: enable test when SDL_AudioDeviceConnected has been implemented. */ -static const SDLTest_TestCaseReference audioTest11 = - { (SDLTest_TestCaseFp)audio_openCloseAudioDeviceConnected, "audio_openCloseAudioDeviceConnected", "Opens and closes audio device and get connected status.", TEST_DISABLED }; +static const SDLTest_TestCaseReference audioTest11 = { + (SDLTest_TestCaseFp)audio_openCloseAudioDeviceConnected, "audio_openCloseAudioDeviceConnected", "Opens and closes audio device and get connected status.", TEST_DISABLED +}; -static const SDLTest_TestCaseReference audioTest12 = - { (SDLTest_TestCaseFp)audio_quitInitAudioSubSystem, "audio_quitInitAudioSubSystem", "Quit and re-init audio subsystem.", TEST_ENABLED }; +static const SDLTest_TestCaseReference audioTest12 = { + (SDLTest_TestCaseFp)audio_quitInitAudioSubSystem, "audio_quitInitAudioSubSystem", "Quit and re-init audio subsystem.", TEST_ENABLED +}; -static const SDLTest_TestCaseReference audioTest13 = - { (SDLTest_TestCaseFp)audio_initQuitAudio, "audio_initQuitAudio", "Init and quit audio drivers directly.", TEST_ENABLED }; +static const SDLTest_TestCaseReference audioTest13 = { + (SDLTest_TestCaseFp)audio_initQuitAudio, "audio_initQuitAudio", "Init and quit audio drivers directly.", TEST_ENABLED +}; -static const SDLTest_TestCaseReference audioTest14 = - { (SDLTest_TestCaseFp)audio_initOpenCloseQuitAudio, "audio_initOpenCloseQuitAudio", "Cycle through init, open, close and quit with various audio specs.", TEST_ENABLED }; +static const SDLTest_TestCaseReference audioTest14 = { + (SDLTest_TestCaseFp)audio_initOpenCloseQuitAudio, "audio_initOpenCloseQuitAudio", "Cycle through init, open, close and quit with various audio specs.", TEST_ENABLED +}; -static const SDLTest_TestCaseReference audioTest15 = - { (SDLTest_TestCaseFp)audio_pauseUnpauseAudio, "audio_pauseUnpauseAudio", "Pause and Unpause audio for various audio specs while testing callback.", TEST_ENABLED }; +static const SDLTest_TestCaseReference audioTest15 = { + (SDLTest_TestCaseFp)audio_pauseUnpauseAudio, "audio_pauseUnpauseAudio", "Pause and Unpause audio for various audio specs while testing callback.", TEST_ENABLED +}; /* Sequence of Audio test cases */ -static const SDLTest_TestCaseReference *audioTests[] = { +static const SDLTest_TestCaseReference *audioTests[] = { &audioTest1, &audioTest2, &audioTest3, &audioTest4, &audioTest5, &audioTest6, &audioTest7, &audioTest8, &audioTest9, &audioTest10, &audioTest11, &audioTest12, &audioTest13, &audioTest14, &audioTest15, NULL diff --git a/test/testautomation_clipboard.c b/test/testautomation_clipboard.c index 76090d1ea..b7bab5ada 100644 --- a/test/testautomation_clipboard.c +++ b/test/testautomation_clipboard.c @@ -18,8 +18,7 @@ * \sa * http://wiki.libsdl.org/SDL_HasClipboardText */ -int -clipboard_testHasClipboardText(void *arg) +int clipboard_testHasClipboardText(void *arg) { SDL_HasClipboardText(); SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded"); @@ -33,8 +32,7 @@ clipboard_testHasClipboardText(void *arg) * \sa * http://wiki.libsdl.org/SDL_HasPrimarySelectionText */ -int -clipboard_testHasPrimarySelectionText(void *arg) +int clipboard_testHasPrimarySelectionText(void *arg) { SDL_HasPrimarySelectionText(); SDLTest_AssertPass("Call to SDL_HasPrimarySelectionText succeeded"); @@ -48,8 +46,7 @@ clipboard_testHasPrimarySelectionText(void *arg) * \sa * http://wiki.libsdl.org/SDL_GetClipboardText */ -int -clipboard_testGetClipboardText(void *arg) +int clipboard_testGetClipboardText(void *arg) { char *charResult; charResult = SDL_GetClipboardText(); @@ -66,8 +63,7 @@ clipboard_testGetClipboardText(void *arg) * \sa * http://wiki.libsdl.org/SDL_GetPrimarySelectionText */ -int -clipboard_testGetPrimarySelectionText(void *arg) +int clipboard_testGetPrimarySelectionText(void *arg) { char *charResult; charResult = SDL_GetPrimarySelectionText(); @@ -83,8 +79,7 @@ clipboard_testGetPrimarySelectionText(void *arg) * \sa * http://wiki.libsdl.org/SDL_SetClipboardText */ -int -clipboard_testSetClipboardText(void *arg) +int clipboard_testSetClipboardText(void *arg) { char *textRef = SDLTest_RandomAsciiString(); char *text = SDL_strdup(textRef); @@ -112,8 +107,7 @@ clipboard_testSetClipboardText(void *arg) * \sa * http://wiki.libsdl.org/SDL_SetPrimarySelectionText */ -int -clipboard_testSetPrimarySelectionText(void *arg) +int clipboard_testSetPrimarySelectionText(void *arg) { char *textRef = SDLTest_RandomAsciiString(); char *text = SDL_strdup(textRef); @@ -143,8 +137,7 @@ clipboard_testSetPrimarySelectionText(void *arg) * http://wiki.libsdl.org/SDL_GetClipboardText * http://wiki.libsdl.org/SDL_SetClipboardText */ -int -clipboard_testClipboardTextFunctions(void *arg) +int clipboard_testClipboardTextFunctions(void *arg) { char *textRef = SDLTest_RandomAsciiString(); char *text = SDL_strdup(textRef); @@ -182,7 +175,7 @@ clipboard_testClipboardTextFunctions(void *arg) SDLTest_AssertCheck( charResult[0] == '\0', "Verify SDL_GetClipboardText returned string with length 0, got length %i", - (int) SDL_strlen(charResult)); + (int)SDL_strlen(charResult)); intResult = SDL_SetClipboardText((const char *)text); SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded"); SDLTest_AssertCheck( @@ -222,8 +215,7 @@ clipboard_testClipboardTextFunctions(void *arg) * http://wiki.libsdl.org/SDL_GetPrimarySelectionText * http://wiki.libsdl.org/SDL_SetPrimarySelectionText */ -int -clipboard_testPrimarySelectionTextFunctions(void *arg) +int clipboard_testPrimarySelectionTextFunctions(void *arg) { char *textRef = SDLTest_RandomAsciiString(); char *text = SDL_strdup(textRef); @@ -261,7 +253,7 @@ clipboard_testPrimarySelectionTextFunctions(void *arg) SDLTest_AssertCheck( charResult[0] == '\0', "Verify SDL_GetPrimarySelectionText returned string with length 0, got length %i", - (int) SDL_strlen(charResult)); + (int)SDL_strlen(charResult)); intResult = SDL_SetPrimarySelectionText((const char *)text); SDLTest_AssertPass("Call to SDL_SetPrimarySelectionText succeeded"); SDLTest_AssertCheck( @@ -294,36 +286,43 @@ clipboard_testPrimarySelectionTextFunctions(void *arg) return TEST_COMPLETED; } - /* ================= Test References ================== */ /* Clipboard test cases */ -static const SDLTest_TestCaseReference clipboardTest1 = - { (SDLTest_TestCaseFp)clipboard_testHasClipboardText, "clipboard_testHasClipboardText", "Check call to SDL_HasClipboardText", TEST_ENABLED }; +static const SDLTest_TestCaseReference clipboardTest1 = { + (SDLTest_TestCaseFp)clipboard_testHasClipboardText, "clipboard_testHasClipboardText", "Check call to SDL_HasClipboardText", TEST_ENABLED +}; -static const SDLTest_TestCaseReference clipboardTest2 = - { (SDLTest_TestCaseFp)clipboard_testHasPrimarySelectionText, "clipboard_testHasPrimarySelectionText", "Check call to SDL_HasPrimarySelectionText", TEST_ENABLED }; +static const SDLTest_TestCaseReference clipboardTest2 = { + (SDLTest_TestCaseFp)clipboard_testHasPrimarySelectionText, "clipboard_testHasPrimarySelectionText", "Check call to SDL_HasPrimarySelectionText", TEST_ENABLED +}; -static const SDLTest_TestCaseReference clipboardTest3 = - { (SDLTest_TestCaseFp)clipboard_testGetClipboardText, "clipboard_testGetClipboardText", "Check call to SDL_GetClipboardText", TEST_ENABLED }; +static const SDLTest_TestCaseReference clipboardTest3 = { + (SDLTest_TestCaseFp)clipboard_testGetClipboardText, "clipboard_testGetClipboardText", "Check call to SDL_GetClipboardText", TEST_ENABLED +}; -static const SDLTest_TestCaseReference clipboardTest4 = - { (SDLTest_TestCaseFp)clipboard_testGetPrimarySelectionText, "clipboard_testGetPrimarySelectionText", "Check call to SDL_GetPrimarySelectionText", TEST_ENABLED }; +static const SDLTest_TestCaseReference clipboardTest4 = { + (SDLTest_TestCaseFp)clipboard_testGetPrimarySelectionText, "clipboard_testGetPrimarySelectionText", "Check call to SDL_GetPrimarySelectionText", TEST_ENABLED +}; -static const SDLTest_TestCaseReference clipboardTest5 = - { (SDLTest_TestCaseFp)clipboard_testSetClipboardText, "clipboard_testSetClipboardText", "Check call to SDL_SetClipboardText", TEST_ENABLED }; +static const SDLTest_TestCaseReference clipboardTest5 = { + (SDLTest_TestCaseFp)clipboard_testSetClipboardText, "clipboard_testSetClipboardText", "Check call to SDL_SetClipboardText", TEST_ENABLED +}; -static const SDLTest_TestCaseReference clipboardTest6 = - { (SDLTest_TestCaseFp)clipboard_testSetPrimarySelectionText, "clipboard_testSetPrimarySelectionText", "Check call to SDL_SetPrimarySelectionText", TEST_ENABLED }; +static const SDLTest_TestCaseReference clipboardTest6 = { + (SDLTest_TestCaseFp)clipboard_testSetPrimarySelectionText, "clipboard_testSetPrimarySelectionText", "Check call to SDL_SetPrimarySelectionText", TEST_ENABLED +}; -static const SDLTest_TestCaseReference clipboardTest7 = - { (SDLTest_TestCaseFp)clipboard_testClipboardTextFunctions, "clipboard_testClipboardTextFunctions", "End-to-end test of SDL_xyzClipboardText functions", TEST_ENABLED }; +static const SDLTest_TestCaseReference clipboardTest7 = { + (SDLTest_TestCaseFp)clipboard_testClipboardTextFunctions, "clipboard_testClipboardTextFunctions", "End-to-end test of SDL_xyzClipboardText functions", TEST_ENABLED +}; -static const SDLTest_TestCaseReference clipboardTest8 = - { (SDLTest_TestCaseFp)clipboard_testPrimarySelectionTextFunctions, "clipboard_testPrimarySelectionTextFunctions", "End-to-end test of SDL_xyzPrimarySelectionText functions", TEST_ENABLED }; +static const SDLTest_TestCaseReference clipboardTest8 = { + (SDLTest_TestCaseFp)clipboard_testPrimarySelectionTextFunctions, "clipboard_testPrimarySelectionTextFunctions", "End-to-end test of SDL_xyzPrimarySelectionText functions", TEST_ENABLED +}; /* Sequence of Clipboard test cases */ -static const SDLTest_TestCaseReference *clipboardTests[] = { +static const SDLTest_TestCaseReference *clipboardTests[] = { &clipboardTest1, &clipboardTest2, &clipboardTest3, &clipboardTest4, &clipboardTest5, &clipboardTest6, &clipboardTest7, &clipboardTest8, NULL }; diff --git a/test/testautomation_events.c b/test/testautomation_events.c index 20f2ea5e4..6d0f3ff53 100644 --- a/test/testautomation_events.c +++ b/test/testautomation_events.c @@ -27,16 +27,16 @@ int _userdataValue2 = 2; /* Event filter that sets some flags and optionally checks userdata */ int SDLCALL _events_sampleNullEventFilter(void *userdata, SDL_Event *event) { - _eventFilterCalled = 1; + _eventFilterCalled = 1; - if (_userdataCheck != 0) { - SDLTest_AssertCheck(userdata != NULL, "Check userdata pointer, expected: non-NULL, got: %s", (userdata != NULL) ? "non-NULL" : "NULL"); - if (userdata != NULL) { - SDLTest_AssertCheck(*(int *)userdata == _userdataValue, "Check userdata value, expected: %i, got: %i", _userdataValue, *(int *)userdata); - } - } + if (_userdataCheck != 0) { + SDLTest_AssertCheck(userdata != NULL, "Check userdata pointer, expected: non-NULL, got: %s", (userdata != NULL) ? "non-NULL" : "NULL"); + if (userdata != NULL) { + SDLTest_AssertCheck(*(int *)userdata == _userdataValue, "Check userdata value, expected: %i, got: %i", _userdataValue, *(int *)userdata); + } + } - return 0; + return 0; } /** @@ -45,34 +45,32 @@ int SDLCALL _events_sampleNullEventFilter(void *userdata, SDL_Event *event) * @sa http://wiki.libsdl.org/SDL_PumpEvents * @sa http://wiki.libsdl.org/SDL_PollEvent */ -int -events_pushPumpAndPollUserevent(void *arg) +int events_pushPumpAndPollUserevent(void *arg) { - SDL_Event event1; - SDL_Event event2; - int result; + SDL_Event event1; + SDL_Event event2; + int result; - /* Create user event */ - event1.type = SDL_USEREVENT; - event1.user.code = SDLTest_RandomSint32(); - event1.user.data1 = (void *)&_userdataValue1; - event1.user.data2 = (void *)&_userdataValue2; + /* Create user event */ + event1.type = SDL_USEREVENT; + event1.user.code = SDLTest_RandomSint32(); + event1.user.data1 = (void *)&_userdataValue1; + event1.user.data2 = (void *)&_userdataValue2; - /* Push a user event onto the queue and force queue update */ - SDL_PushEvent(&event1); - SDLTest_AssertPass("Call to SDL_PushEvent()"); - SDL_PumpEvents(); - SDLTest_AssertPass("Call to SDL_PumpEvents()"); + /* Push a user event onto the queue and force queue update */ + SDL_PushEvent(&event1); + SDLTest_AssertPass("Call to SDL_PushEvent()"); + SDL_PumpEvents(); + SDLTest_AssertPass("Call to SDL_PumpEvents()"); - /* Poll for user event */ - result = SDL_PollEvent(&event2); - SDLTest_AssertPass("Call to SDL_PollEvent()"); - SDLTest_AssertCheck(result == 1, "Check result from SDL_PollEvent, expected: 1, got: %d", result); + /* Poll for user event */ + result = SDL_PollEvent(&event2); + SDLTest_AssertPass("Call to SDL_PollEvent()"); + SDLTest_AssertCheck(result == 1, "Check result from SDL_PollEvent, expected: 1, got: %d", result); - return TEST_COMPLETED; + return TEST_COMPLETED; } - /** * @brief Adds and deletes an event watch function with NULL userdata * @@ -80,47 +78,46 @@ events_pushPumpAndPollUserevent(void *arg) * @sa http://wiki.libsdl.org/SDL_DelEventWatch * */ -int -events_addDelEventWatch(void *arg) +int events_addDelEventWatch(void *arg) { - SDL_Event event; + SDL_Event event; - /* Create user event */ - event.type = SDL_USEREVENT; - event.user.code = SDLTest_RandomSint32(); - event.user.data1 = (void *)&_userdataValue1; - event.user.data2 = (void *)&_userdataValue2; + /* Create user event */ + event.type = SDL_USEREVENT; + event.user.code = SDLTest_RandomSint32(); + event.user.data1 = (void *)&_userdataValue1; + event.user.data2 = (void *)&_userdataValue2; - /* Disable userdata check */ - _userdataCheck = 0; + /* Disable userdata check */ + _userdataCheck = 0; - /* Reset event filter call tracker */ - _eventFilterCalled = 0; + /* Reset event filter call tracker */ + _eventFilterCalled = 0; - /* Add watch */ - SDL_AddEventWatch(_events_sampleNullEventFilter, NULL); - SDLTest_AssertPass("Call to SDL_AddEventWatch()"); + /* Add watch */ + SDL_AddEventWatch(_events_sampleNullEventFilter, NULL); + SDLTest_AssertPass("Call to SDL_AddEventWatch()"); - /* Push a user event onto the queue and force queue update */ - SDL_PushEvent(&event); - SDLTest_AssertPass("Call to SDL_PushEvent()"); - SDL_PumpEvents(); - SDLTest_AssertPass("Call to SDL_PumpEvents()"); - SDLTest_AssertCheck(_eventFilterCalled == 1, "Check that event filter was called"); + /* Push a user event onto the queue and force queue update */ + SDL_PushEvent(&event); + SDLTest_AssertPass("Call to SDL_PushEvent()"); + SDL_PumpEvents(); + SDLTest_AssertPass("Call to SDL_PumpEvents()"); + SDLTest_AssertCheck(_eventFilterCalled == 1, "Check that event filter was called"); - /* Delete watch */ - SDL_DelEventWatch(_events_sampleNullEventFilter, NULL); - SDLTest_AssertPass("Call to SDL_DelEventWatch()"); + /* Delete watch */ + SDL_DelEventWatch(_events_sampleNullEventFilter, NULL); + SDLTest_AssertPass("Call to SDL_DelEventWatch()"); - /* Push a user event onto the queue and force queue update */ - _eventFilterCalled = 0; - SDL_PushEvent(&event); - SDLTest_AssertPass("Call to SDL_PushEvent()"); - SDL_PumpEvents(); - SDLTest_AssertPass("Call to SDL_PumpEvents()"); - SDLTest_AssertCheck(_eventFilterCalled == 0, "Check that event filter was NOT called"); + /* Push a user event onto the queue and force queue update */ + _eventFilterCalled = 0; + SDL_PushEvent(&event); + SDLTest_AssertPass("Call to SDL_PushEvent()"); + SDL_PumpEvents(); + SDLTest_AssertPass("Call to SDL_PumpEvents()"); + SDLTest_AssertCheck(_eventFilterCalled == 0, "Check that event filter was NOT called"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -130,65 +127,66 @@ events_addDelEventWatch(void *arg) * @sa http://wiki.libsdl.org/SDL_DelEventWatch * */ -int -events_addDelEventWatchWithUserdata(void *arg) +int events_addDelEventWatchWithUserdata(void *arg) { - SDL_Event event; + SDL_Event event; - /* Create user event */ - event.type = SDL_USEREVENT; - event.user.code = SDLTest_RandomSint32(); - event.user.data1 = (void *)&_userdataValue1; - event.user.data2 = (void *)&_userdataValue2; + /* Create user event */ + event.type = SDL_USEREVENT; + event.user.code = SDLTest_RandomSint32(); + event.user.data1 = (void *)&_userdataValue1; + event.user.data2 = (void *)&_userdataValue2; - /* Enable userdata check and set a value to check */ - _userdataCheck = 1; - _userdataValue = SDLTest_RandomIntegerInRange(-1024, 1024); + /* Enable userdata check and set a value to check */ + _userdataCheck = 1; + _userdataValue = SDLTest_RandomIntegerInRange(-1024, 1024); - /* Reset event filter call tracker */ - _eventFilterCalled = 0; + /* Reset event filter call tracker */ + _eventFilterCalled = 0; - /* Add watch */ - SDL_AddEventWatch(_events_sampleNullEventFilter, (void *)&_userdataValue); - SDLTest_AssertPass("Call to SDL_AddEventWatch()"); + /* Add watch */ + SDL_AddEventWatch(_events_sampleNullEventFilter, (void *)&_userdataValue); + SDLTest_AssertPass("Call to SDL_AddEventWatch()"); - /* Push a user event onto the queue and force queue update */ - SDL_PushEvent(&event); - SDLTest_AssertPass("Call to SDL_PushEvent()"); - SDL_PumpEvents(); - SDLTest_AssertPass("Call to SDL_PumpEvents()"); - SDLTest_AssertCheck(_eventFilterCalled == 1, "Check that event filter was called"); + /* Push a user event onto the queue and force queue update */ + SDL_PushEvent(&event); + SDLTest_AssertPass("Call to SDL_PushEvent()"); + SDL_PumpEvents(); + SDLTest_AssertPass("Call to SDL_PumpEvents()"); + SDLTest_AssertCheck(_eventFilterCalled == 1, "Check that event filter was called"); - /* Delete watch */ - SDL_DelEventWatch(_events_sampleNullEventFilter, (void *)&_userdataValue); - SDLTest_AssertPass("Call to SDL_DelEventWatch()"); + /* Delete watch */ + SDL_DelEventWatch(_events_sampleNullEventFilter, (void *)&_userdataValue); + SDLTest_AssertPass("Call to SDL_DelEventWatch()"); - /* Push a user event onto the queue and force queue update */ - _eventFilterCalled = 0; - SDL_PushEvent(&event); - SDLTest_AssertPass("Call to SDL_PushEvent()"); - SDL_PumpEvents(); - SDLTest_AssertPass("Call to SDL_PumpEvents()"); - SDLTest_AssertCheck(_eventFilterCalled == 0, "Check that event filter was NOT called"); + /* Push a user event onto the queue and force queue update */ + _eventFilterCalled = 0; + SDL_PushEvent(&event); + SDLTest_AssertPass("Call to SDL_PushEvent()"); + SDL_PumpEvents(); + SDLTest_AssertPass("Call to SDL_PumpEvents()"); + SDLTest_AssertCheck(_eventFilterCalled == 0, "Check that event filter was NOT called"); - return TEST_COMPLETED; + return TEST_COMPLETED; } - /* ================= Test References ================== */ /* Events test cases */ -static const SDLTest_TestCaseReference eventsTest1 = - { (SDLTest_TestCaseFp)events_pushPumpAndPollUserevent, "events_pushPumpAndPollUserevent", "Pushes, pumps and polls a user event", TEST_ENABLED }; +static const SDLTest_TestCaseReference eventsTest1 = { + (SDLTest_TestCaseFp)events_pushPumpAndPollUserevent, "events_pushPumpAndPollUserevent", "Pushes, pumps and polls a user event", TEST_ENABLED +}; -static const SDLTest_TestCaseReference eventsTest2 = - { (SDLTest_TestCaseFp)events_addDelEventWatch, "events_addDelEventWatch", "Adds and deletes an event watch function with NULL userdata", TEST_ENABLED }; +static const SDLTest_TestCaseReference eventsTest2 = { + (SDLTest_TestCaseFp)events_addDelEventWatch, "events_addDelEventWatch", "Adds and deletes an event watch function with NULL userdata", TEST_ENABLED +}; -static const SDLTest_TestCaseReference eventsTest3 = - { (SDLTest_TestCaseFp)events_addDelEventWatchWithUserdata, "events_addDelEventWatchWithUserdata", "Adds and deletes an event watch function with userdata", TEST_ENABLED }; +static const SDLTest_TestCaseReference eventsTest3 = { + (SDLTest_TestCaseFp)events_addDelEventWatchWithUserdata, "events_addDelEventWatchWithUserdata", "Adds and deletes an event watch function with userdata", TEST_ENABLED +}; /* Sequence of Events test cases */ -static const SDLTest_TestCaseReference *eventsTests[] = { +static const SDLTest_TestCaseReference *eventsTests[] = { &eventsTest1, &eventsTest2, &eventsTest3, NULL }; diff --git a/test/testautomation_guid.c b/test/testautomation_guid.c index bab2b9fd5..593b7fbb9 100644 --- a/test/testautomation_guid.c +++ b/test/testautomation_guid.c @@ -11,30 +11,36 @@ #define NUM_TEST_GUIDS 5 -static struct { +static struct +{ char *str; Uint64 upper, lower; } test_guids[NUM_TEST_GUIDS] = { - { "0000000000000000" "ffffffffffffffff", - 0x0000000000000000, 0xfffffffffffffffflu }, - { "0011223344556677" "8091a2b3c4d5e6f0", - 0x0011223344556677lu, 0x8091a2b3c4d5e6f0lu }, - { "a011223344556677" "8091a2b3c4d5e6f0", - 0xa011223344556677lu, 0x8091a2b3c4d5e6f0lu }, - { "a011223344556677" "8091a2b3c4d5e6f1", - 0xa011223344556677lu, 0x8091a2b3c4d5e6f1lu }, - { "a011223344556677" "8191a2b3c4d5e6f0", - 0xa011223344556677lu, 0x8191a2b3c4d5e6f0lu }, + { "0000000000000000" + "ffffffffffffffff", + 0x0000000000000000, 0xfffffffffffffffflu }, + { "0011223344556677" + "8091a2b3c4d5e6f0", + 0x0011223344556677lu, 0x8091a2b3c4d5e6f0lu }, + { "a011223344556677" + "8091a2b3c4d5e6f0", + 0xa011223344556677lu, 0x8091a2b3c4d5e6f0lu }, + { "a011223344556677" + "8091a2b3c4d5e6f1", + 0xa011223344556677lu, 0x8091a2b3c4d5e6f1lu }, + { "a011223344556677" + "8191a2b3c4d5e6f0", + 0xa011223344556677lu, 0x8191a2b3c4d5e6f0lu }, }; static void -upper_lower_to_bytestring(Uint8* out, Uint64 upper, Uint64 lower) +upper_lower_to_bytestring(Uint8 *out, Uint64 upper, Uint64 lower) { Uint64 values[2]; int i, k; values[0] = upper; - values [1] = lower; + values[1] = lower; for (i = 0; i < 2; ++i) { Uint64 v = values[i]; @@ -46,7 +52,6 @@ upper_lower_to_bytestring(Uint8* out, Uint64 upper, Uint64 lower) } } - /* Test case functions */ /** @@ -128,14 +133,16 @@ TestGuidToString(void *arg) /* ================= Test References ================== */ /* GUID routine test cases */ -static const SDLTest_TestCaseReference guidTest1 = - { (SDLTest_TestCaseFp)TestGuidFromString, "TestGuidFromString", "Call to SDL_GUIDFromString", TEST_ENABLED }; +static const SDLTest_TestCaseReference guidTest1 = { + (SDLTest_TestCaseFp)TestGuidFromString, "TestGuidFromString", "Call to SDL_GUIDFromString", TEST_ENABLED +}; -static const SDLTest_TestCaseReference guidTest2 = - { (SDLTest_TestCaseFp)TestGuidToString, "TestGuidToString", "Call to SDL_GUIDToString", TEST_ENABLED }; +static const SDLTest_TestCaseReference guidTest2 = { + (SDLTest_TestCaseFp)TestGuidToString, "TestGuidToString", "Call to SDL_GUIDToString", TEST_ENABLED +}; /* Sequence of GUID routine test cases */ -static const SDLTest_TestCaseReference *guidTests[] = { +static const SDLTest_TestCaseReference *guidTests[] = { &guidTest1, &guidTest2, NULL diff --git a/test/testautomation_hints.c b/test/testautomation_hints.c index c3f5ddfaa..dbd30e119 100644 --- a/test/testautomation_hints.c +++ b/test/testautomation_hints.c @@ -7,9 +7,7 @@ #include "SDL.h" #include "SDL_test.h" - -const char* _HintsEnum[] = - { +const char *_HintsEnum[] = { SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_HINT_FRAMEBUFFER_ACCELERATION, SDL_HINT_GAMECONTROLLERCONFIG, @@ -33,9 +31,8 @@ const char* _HintsEnum[] = SDL_HINT_VIDEO_WIN_D3DCOMPILER, SDL_HINT_VIDEO_X11_XRANDR, SDL_HINT_XINPUT_ENABLED, - }; -const char* _HintsVerbose[] = - { +}; +const char *_HintsVerbose[] = { "SDL_ACCELEROMETER_AS_JOYSTICK", "SDL_FRAMEBUFFER_ACCELERATION", "SDL_GAMECONTROLLERCONFIG", @@ -59,7 +56,7 @@ const char* _HintsVerbose[] = "SDL_VIDEO_WIN_D3DCOMPILER", "SDL_VIDEO_X11_XRANDR", "SDL_XINPUT_ENABLED" - }; +}; SDL_COMPILE_TIME_ASSERT(HintsEnum, SDL_arraysize(_HintsEnum) == SDL_arraysize(_HintsVerbose)); @@ -70,193 +67,193 @@ const int _numHintsEnum = SDL_arraysize(_HintsEnum); /** * @brief Call to SDL_GetHint */ -int -hints_getHint(void *arg) +int hints_getHint(void *arg) { - const char *result1; - const char *result2; - int i; + const char *result1; + const char *result2; + int i; - for (i=0; i<_numHintsEnum; i++) { - result1 = SDL_GetHint(_HintsEnum[i]); - SDLTest_AssertPass("Call to SDL_GetHint(%s) - using define definition", (char*)_HintsEnum[i]); - result2 = SDL_GetHint(_HintsVerbose[i]); - SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", (char*)_HintsVerbose[i]); - SDLTest_AssertCheck( - (result1 == NULL && result2 == NULL) || (SDL_strcmp(result1, result2) == 0), - "Verify returned values are equal; got: result1='%s' result2='%s", - (result1 == NULL) ? "null" : result1, - (result2 == NULL) ? "null" : result2); - } + for (i = 0; i < _numHintsEnum; i++) { + result1 = SDL_GetHint(_HintsEnum[i]); + SDLTest_AssertPass("Call to SDL_GetHint(%s) - using define definition", (char *)_HintsEnum[i]); + result2 = SDL_GetHint(_HintsVerbose[i]); + SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", (char *)_HintsVerbose[i]); + SDLTest_AssertCheck( + (result1 == NULL && result2 == NULL) || (SDL_strcmp(result1, result2) == 0), + "Verify returned values are equal; got: result1='%s' result2='%s", + (result1 == NULL) ? "null" : result1, + (result2 == NULL) ? "null" : result2); + } - return TEST_COMPLETED; + return TEST_COMPLETED; } static void SDLCALL hints_testHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { - *(char **)userdata = hint ? SDL_strdup(hint) : NULL; + *(char **)userdata = hint ? SDL_strdup(hint) : NULL; } /** * @brief Call to SDL_SetHint */ -int -hints_setHint(void *arg) +int hints_setHint(void *arg) { - const char *testHint = "SDL_AUTOMATED_TEST_HINT"; - const char *originalValue; - char *value; - const char *testValue; - char *callbackValue; - SDL_bool result; - int i, j; + const char *testHint = "SDL_AUTOMATED_TEST_HINT"; + const char *originalValue; + char *value; + const char *testValue; + char *callbackValue; + SDL_bool result; + int i, j; - /* Create random values to set */ - value = SDLTest_RandomAsciiStringOfSize(10); + /* Create random values to set */ + value = SDLTest_RandomAsciiStringOfSize(10); - for (i=0; i<_numHintsEnum; i++) { - /* Capture current value */ - originalValue = SDL_GetHint(_HintsEnum[i]); - SDLTest_AssertPass("Call to SDL_GetHint(%s)", _HintsEnum[i]); + for (i = 0; i < _numHintsEnum; i++) { + /* Capture current value */ + originalValue = SDL_GetHint(_HintsEnum[i]); + SDLTest_AssertPass("Call to SDL_GetHint(%s)", _HintsEnum[i]); - /* Copy the original value, since it will be freed when we set it again */ - originalValue = originalValue ? SDL_strdup(originalValue) : NULL; + /* Copy the original value, since it will be freed when we set it again */ + originalValue = originalValue ? SDL_strdup(originalValue) : NULL; - /* Set value (twice) */ - for (j=1; j<=2; j++) { - result = SDL_SetHint(_HintsEnum[i], value); - SDLTest_AssertPass("Call to SDL_SetHint(%s, %s) (iteration %i)", _HintsEnum[i], value, j); - SDLTest_AssertCheck( - result == SDL_TRUE || result == SDL_FALSE, - "Verify valid result was returned, got: %i", - (int)result); - testValue = SDL_GetHint(_HintsEnum[i]); - SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", _HintsVerbose[i]); - SDLTest_AssertCheck( - (SDL_strcmp(value, testValue) == 0), - "Verify returned value equals set value; got: testValue='%s' value='%s", - (testValue == NULL) ? "null" : testValue, - value); + /* Set value (twice) */ + for (j = 1; j <= 2; j++) { + result = SDL_SetHint(_HintsEnum[i], value); + SDLTest_AssertPass("Call to SDL_SetHint(%s, %s) (iteration %i)", _HintsEnum[i], value, j); + SDLTest_AssertCheck( + result == SDL_TRUE || result == SDL_FALSE, + "Verify valid result was returned, got: %i", + (int)result); + testValue = SDL_GetHint(_HintsEnum[i]); + SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", _HintsVerbose[i]); + SDLTest_AssertCheck( + (SDL_strcmp(value, testValue) == 0), + "Verify returned value equals set value; got: testValue='%s' value='%s", + (testValue == NULL) ? "null" : testValue, + value); + } + + /* Reset original value */ + result = SDL_SetHint(_HintsEnum[i], originalValue); + SDLTest_AssertPass("Call to SDL_SetHint(%s, originalValue)", _HintsEnum[i]); + SDLTest_AssertCheck( + result == SDL_TRUE || result == SDL_FALSE, + "Verify valid result was returned, got: %i", + (int)result); + SDL_free((void *)originalValue); } - /* Reset original value */ - result = SDL_SetHint(_HintsEnum[i], originalValue); - SDLTest_AssertPass("Call to SDL_SetHint(%s, originalValue)", _HintsEnum[i]); + SDL_free(value); + + /* Set default value in environment */ + SDL_setenv(testHint, "original", 1); + + SDLTest_AssertPass("Call to SDL_GetHint() after saving and restoring hint"); + originalValue = SDL_GetHint(testHint); + value = (originalValue == NULL) ? NULL : SDL_strdup(originalValue); + SDL_SetHint(testHint, "temp"); + SDL_SetHint(testHint, value); + SDL_free(value); + testValue = SDL_GetHint(testHint); SDLTest_AssertCheck( - result == SDL_TRUE || result == SDL_FALSE, - "Verify valid result was returned, got: %i", - (int)result); - SDL_free((void *)originalValue); - } + testValue && SDL_strcmp(testValue, "original") == 0, + "testValue = %s, expected \"original\"", + testValue); - SDL_free(value); + SDLTest_AssertPass("Call to SDL_SetHintWithPriority(NULL, SDL_HINT_DEFAULT)"); + SDL_SetHintWithPriority(testHint, NULL, SDL_HINT_DEFAULT); + testValue = SDL_GetHint(testHint); + SDLTest_AssertCheck( + testValue && SDL_strcmp(testValue, "original") == 0, + "testValue = %s, expected \"original\"", + testValue); - /* Set default value in environment */ - SDL_setenv(testHint, "original", 1); + SDLTest_AssertPass("Call to SDL_SetHintWithPriority(\"temp\", SDL_HINT_OVERRIDE)"); + SDL_SetHintWithPriority(testHint, "temp", SDL_HINT_OVERRIDE); + testValue = SDL_GetHint(testHint); + SDLTest_AssertCheck( + testValue && SDL_strcmp(testValue, "temp") == 0, + "testValue = %s, expected \"temp\"", + testValue); - SDLTest_AssertPass("Call to SDL_GetHint() after saving and restoring hint"); - originalValue = SDL_GetHint(testHint); - value = (originalValue == NULL) ? NULL : SDL_strdup(originalValue); - SDL_SetHint(testHint, "temp"); - SDL_SetHint(testHint, value); - SDL_free(value); - testValue = SDL_GetHint(testHint); - SDLTest_AssertCheck( - testValue && SDL_strcmp(testValue, "original") == 0, - "testValue = %s, expected \"original\"", - testValue); + SDLTest_AssertPass("Call to SDL_SetHintWithPriority(NULL, SDL_HINT_OVERRIDE)"); + SDL_SetHintWithPriority(testHint, NULL, SDL_HINT_OVERRIDE); + testValue = SDL_GetHint(testHint); + SDLTest_AssertCheck( + testValue == NULL, + "testValue = %s, expected NULL", + testValue); - SDLTest_AssertPass("Call to SDL_SetHintWithPriority(NULL, SDL_HINT_DEFAULT)"); - SDL_SetHintWithPriority(testHint, NULL, SDL_HINT_DEFAULT); - testValue = SDL_GetHint(testHint); - SDLTest_AssertCheck( - testValue && SDL_strcmp(testValue, "original") == 0, - "testValue = %s, expected \"original\"", - testValue); + SDLTest_AssertPass("Call to SDL_ResetHint()"); + SDL_ResetHint(testHint); + testValue = SDL_GetHint(testHint); + SDLTest_AssertCheck( + testValue && SDL_strcmp(testValue, "original") == 0, + "testValue = %s, expected \"original\"", + testValue); - SDLTest_AssertPass("Call to SDL_SetHintWithPriority(\"temp\", SDL_HINT_OVERRIDE)"); - SDL_SetHintWithPriority(testHint, "temp", SDL_HINT_OVERRIDE); - testValue = SDL_GetHint(testHint); - SDLTest_AssertCheck( - testValue && SDL_strcmp(testValue, "temp") == 0, - "testValue = %s, expected \"temp\"", - testValue); + /* Make sure callback functionality works past a reset */ + SDLTest_AssertPass("Call to SDL_AddHintCallback()"); + callbackValue = NULL; + SDL_AddHintCallback(testHint, hints_testHintChanged, &callbackValue); + SDLTest_AssertCheck( + callbackValue && SDL_strcmp(callbackValue, "original") == 0, + "callbackValue = %s, expected \"original\"", + callbackValue); + SDL_free(callbackValue); - SDLTest_AssertPass("Call to SDL_SetHintWithPriority(NULL, SDL_HINT_OVERRIDE)"); - SDL_SetHintWithPriority(testHint, NULL, SDL_HINT_OVERRIDE); - testValue = SDL_GetHint(testHint); - SDLTest_AssertCheck( - testValue == NULL, - "testValue = %s, expected NULL", - testValue); + SDLTest_AssertPass("Call to SDL_SetHintWithPriority(\"temp\", SDL_HINT_OVERRIDE), using callback"); + callbackValue = NULL; + SDL_SetHintWithPriority(testHint, "temp", SDL_HINT_OVERRIDE); + SDLTest_AssertCheck( + callbackValue && SDL_strcmp(callbackValue, "temp") == 0, + "callbackValue = %s, expected \"temp\"", + callbackValue); + SDL_free(callbackValue); - SDLTest_AssertPass("Call to SDL_ResetHint()"); - SDL_ResetHint(testHint); - testValue = SDL_GetHint(testHint); - SDLTest_AssertCheck( - testValue && SDL_strcmp(testValue, "original") == 0, - "testValue = %s, expected \"original\"", - testValue); + SDLTest_AssertPass("Call to SDL_ResetHint(), using callback"); + callbackValue = NULL; + SDL_ResetHint(testHint); + SDLTest_AssertCheck( + callbackValue && SDL_strcmp(callbackValue, "original") == 0, + "callbackValue = %s, expected \"original\"", + callbackValue); - /* Make sure callback functionality works past a reset */ - SDLTest_AssertPass("Call to SDL_AddHintCallback()"); - callbackValue = NULL; - SDL_AddHintCallback(testHint, hints_testHintChanged, &callbackValue); - SDLTest_AssertCheck( - callbackValue && SDL_strcmp(callbackValue, "original") == 0, - "callbackValue = %s, expected \"original\"", - callbackValue); - SDL_free(callbackValue); + SDLTest_AssertPass("Call to SDL_SetHintWithPriority(\"temp\", SDL_HINT_OVERRIDE), using callback after reset"); + callbackValue = NULL; + SDL_SetHintWithPriority(testHint, "temp", SDL_HINT_OVERRIDE); + SDLTest_AssertCheck( + callbackValue && SDL_strcmp(callbackValue, "temp") == 0, + "callbackValue = %s, expected \"temp\"", + callbackValue); + SDL_free(callbackValue); - SDLTest_AssertPass("Call to SDL_SetHintWithPriority(\"temp\", SDL_HINT_OVERRIDE), using callback"); - callbackValue = NULL; - SDL_SetHintWithPriority(testHint, "temp", SDL_HINT_OVERRIDE); - SDLTest_AssertCheck( - callbackValue && SDL_strcmp(callbackValue, "temp") == 0, - "callbackValue = %s, expected \"temp\"", - callbackValue); - SDL_free(callbackValue); + SDLTest_AssertPass("Call to SDL_ResetHint(), after clearing callback"); + callbackValue = NULL; + SDL_DelHintCallback(testHint, hints_testHintChanged, &callbackValue); + SDL_ResetHint(testHint); + SDLTest_AssertCheck( + callbackValue == NULL, + "callbackValue = %s, expected \"(null)\"", + callbackValue); - SDLTest_AssertPass("Call to SDL_ResetHint(), using callback"); - callbackValue = NULL; - SDL_ResetHint(testHint); - SDLTest_AssertCheck( - callbackValue && SDL_strcmp(callbackValue, "original") == 0, - "callbackValue = %s, expected \"original\"", - callbackValue); - - SDLTest_AssertPass("Call to SDL_SetHintWithPriority(\"temp\", SDL_HINT_OVERRIDE), using callback after reset"); - callbackValue = NULL; - SDL_SetHintWithPriority(testHint, "temp", SDL_HINT_OVERRIDE); - SDLTest_AssertCheck( - callbackValue && SDL_strcmp(callbackValue, "temp") == 0, - "callbackValue = %s, expected \"temp\"", - callbackValue); - SDL_free(callbackValue); - - SDLTest_AssertPass("Call to SDL_ResetHint(), after clearing callback"); - callbackValue = NULL; - SDL_DelHintCallback(testHint, hints_testHintChanged, &callbackValue); - SDL_ResetHint(testHint); - SDLTest_AssertCheck( - callbackValue == NULL, - "callbackValue = %s, expected \"(null)\"", - callbackValue); - - return TEST_COMPLETED; + return TEST_COMPLETED; } /* ================= Test References ================== */ /* Hints test cases */ -static const SDLTest_TestCaseReference hintsTest1 = - { (SDLTest_TestCaseFp)hints_getHint, "hints_getHint", "Call to SDL_GetHint", TEST_ENABLED }; +static const SDLTest_TestCaseReference hintsTest1 = { + (SDLTest_TestCaseFp)hints_getHint, "hints_getHint", "Call to SDL_GetHint", TEST_ENABLED +}; -static const SDLTest_TestCaseReference hintsTest2 = - { (SDLTest_TestCaseFp)hints_setHint, "hints_setHint", "Call to SDL_SetHint", TEST_ENABLED }; +static const SDLTest_TestCaseReference hintsTest2 = { + (SDLTest_TestCaseFp)hints_setHint, "hints_setHint", "Call to SDL_SetHint", TEST_ENABLED +}; /* Sequence of Hints test cases */ -static const SDLTest_TestCaseReference *hintsTests[] = { +static const SDLTest_TestCaseReference *hintsTests[] = { &hintsTest1, &hintsTest2, NULL }; diff --git a/test/testautomation_joystick.c b/test/testautomation_joystick.c index 3baa4ee58..8104c6506 100644 --- a/test/testautomation_joystick.c +++ b/test/testautomation_joystick.c @@ -72,11 +72,12 @@ TestVirtualJoystick(void *arg) /* ================= Test References ================== */ /* Joystick routine test cases */ -static const SDLTest_TestCaseReference joystickTest1 = - { (SDLTest_TestCaseFp)TestVirtualJoystick, "TestVirtualJoystick", "Test virtual joystick functionality", TEST_ENABLED }; +static const SDLTest_TestCaseReference joystickTest1 = { + (SDLTest_TestCaseFp)TestVirtualJoystick, "TestVirtualJoystick", "Test virtual joystick functionality", TEST_ENABLED +}; /* Sequence of Joystick routine test cases */ -static const SDLTest_TestCaseReference *joystickTests[] = { +static const SDLTest_TestCaseReference *joystickTests[] = { &joystickTest1, NULL }; diff --git a/test/testautomation_keyboard.c b/test/testautomation_keyboard.c index a83f536dd..a8bf40bdf 100644 --- a/test/testautomation_keyboard.c +++ b/test/testautomation_keyboard.c @@ -18,25 +18,24 @@ * * @sa http://wiki.libsdl.org/SDL_GetKeyboardState */ -int -keyboard_getKeyboardState(void *arg) +int keyboard_getKeyboardState(void *arg) { - int numkeys; - Uint8 *state; + int numkeys; + Uint8 *state; - /* Case where numkeys pointer is NULL */ - state = (Uint8 *)SDL_GetKeyboardState(NULL); - SDLTest_AssertPass("Call to SDL_GetKeyboardState(NULL)"); - SDLTest_AssertCheck(state != NULL, "Validate that return value from SDL_GetKeyboardState is not NULL"); + /* Case where numkeys pointer is NULL */ + state = (Uint8 *)SDL_GetKeyboardState(NULL); + SDLTest_AssertPass("Call to SDL_GetKeyboardState(NULL)"); + SDLTest_AssertCheck(state != NULL, "Validate that return value from SDL_GetKeyboardState is not NULL"); - /* Case where numkeys pointer is not NULL */ - numkeys = -1; - state = (Uint8 *)SDL_GetKeyboardState(&numkeys); - SDLTest_AssertPass("Call to SDL_GetKeyboardState(&numkeys)"); - SDLTest_AssertCheck(state != NULL, "Validate that return value from SDL_GetKeyboardState is not NULL"); - SDLTest_AssertCheck(numkeys >= 0, "Validate that value of numkeys is >= 0, got: %i", numkeys); + /* Case where numkeys pointer is not NULL */ + numkeys = -1; + state = (Uint8 *)SDL_GetKeyboardState(&numkeys); + SDLTest_AssertPass("Call to SDL_GetKeyboardState(&numkeys)"); + SDLTest_AssertCheck(state != NULL, "Validate that return value from SDL_GetKeyboardState is not NULL"); + SDLTest_AssertCheck(numkeys >= 0, "Validate that value of numkeys is >= 0, got: %i", numkeys); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -44,14 +43,13 @@ keyboard_getKeyboardState(void *arg) * * @sa http://wiki.libsdl.org/SDL_GetKeyboardFocus */ -int -keyboard_getKeyboardFocus(void *arg) +int keyboard_getKeyboardFocus(void *arg) { - /* Call, but ignore return value */ - SDL_GetKeyboardFocus(); - SDLTest_AssertPass("Call to SDL_GetKeyboardFocus()"); + /* Call, but ignore return value */ + SDL_GetKeyboardFocus(); + SDLTest_AssertPass("Call to SDL_GetKeyboardFocus()"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -59,66 +57,64 @@ keyboard_getKeyboardFocus(void *arg) * * @sa http://wiki.libsdl.org/SDL_GetKeyFromName */ -int -keyboard_getKeyFromName(void *arg) +int keyboard_getKeyFromName(void *arg) { - SDL_Keycode result; + SDL_Keycode result; - /* Case where Key is known, 1 character input */ - result = SDL_GetKeyFromName("A"); - SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/single)"); - SDLTest_AssertCheck(result == SDLK_a, "Verify result from call, expected: %i, got: %" SDL_PRIs32, SDLK_a, result); + /* Case where Key is known, 1 character input */ + result = SDL_GetKeyFromName("A"); + SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/single)"); + SDLTest_AssertCheck(result == SDLK_a, "Verify result from call, expected: %i, got: %" SDL_PRIs32, SDLK_a, result); - /* Case where Key is known, 2 character input */ - result = SDL_GetKeyFromName("F1"); - SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/double)"); - SDLTest_AssertCheck(result == SDLK_F1, "Verify result from call, expected: %i, got: %" SDL_PRIs32, SDLK_F1, result); + /* Case where Key is known, 2 character input */ + result = SDL_GetKeyFromName("F1"); + SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/double)"); + SDLTest_AssertCheck(result == SDLK_F1, "Verify result from call, expected: %i, got: %" SDL_PRIs32, SDLK_F1, result); - /* Case where Key is known, 3 character input */ - result = SDL_GetKeyFromName("End"); - SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/triple)"); - SDLTest_AssertCheck(result == SDLK_END, "Verify result from call, expected: %i, got: %" SDL_PRIs32, SDLK_END, result); + /* Case where Key is known, 3 character input */ + result = SDL_GetKeyFromName("End"); + SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/triple)"); + SDLTest_AssertCheck(result == SDLK_END, "Verify result from call, expected: %i, got: %" SDL_PRIs32, SDLK_END, result); - /* Case where Key is known, 4 character input */ - result = SDL_GetKeyFromName("Find"); - SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/quad)"); - SDLTest_AssertCheck(result == SDLK_FIND, "Verify result from call, expected: %i, got: %" SDL_PRIs32, SDLK_FIND, result); + /* Case where Key is known, 4 character input */ + result = SDL_GetKeyFromName("Find"); + SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/quad)"); + SDLTest_AssertCheck(result == SDLK_FIND, "Verify result from call, expected: %i, got: %" SDL_PRIs32, SDLK_FIND, result); - /* Case where Key is known, multiple character input */ - result = SDL_GetKeyFromName("AudioStop"); - SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/multi)"); - SDLTest_AssertCheck(result == SDLK_AUDIOSTOP, "Verify result from call, expected: %i, got: %" SDL_PRIs32, SDLK_AUDIOSTOP, result); + /* Case where Key is known, multiple character input */ + result = SDL_GetKeyFromName("AudioStop"); + SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/multi)"); + SDLTest_AssertCheck(result == SDLK_AUDIOSTOP, "Verify result from call, expected: %i, got: %" SDL_PRIs32, SDLK_AUDIOSTOP, result); - /* Case where Key is unknown */ - result = SDL_GetKeyFromName("NotThere"); - SDLTest_AssertPass("Call to SDL_GetKeyFromName(unknown)"); - SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %" SDL_PRIs32, SDLK_UNKNOWN, result); + /* Case where Key is unknown */ + result = SDL_GetKeyFromName("NotThere"); + SDLTest_AssertPass("Call to SDL_GetKeyFromName(unknown)"); + SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %" SDL_PRIs32, SDLK_UNKNOWN, result); - /* Case where input is NULL/invalid */ - result = SDL_GetKeyFromName(NULL); - SDLTest_AssertPass("Call to SDL_GetKeyFromName(NULL)"); - SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %" SDL_PRIs32, SDLK_UNKNOWN, result); + /* Case where input is NULL/invalid */ + result = SDL_GetKeyFromName(NULL); + SDLTest_AssertPass("Call to SDL_GetKeyFromName(NULL)"); + SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %" SDL_PRIs32, SDLK_UNKNOWN, result); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* * Local helper to check for the invalid scancode error message */ -void -_checkInvalidScancodeError() +void _checkInvalidScancodeError() { - const char *expectedError = "Parameter 'scancode' is invalid"; - const char *error; - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError, error); - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - } + const char *expectedError = "Parameter 'scancode' is invalid"; + const char *error; + error = SDL_GetError(); + SDLTest_AssertPass("Call to SDL_GetError()"); + SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); + if (error != NULL) { + SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, + "Validate error message, expected: '%s', got: '%s'", expectedError, error); + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); + } } /** @@ -126,38 +122,37 @@ _checkInvalidScancodeError() * * @sa http://wiki.libsdl.org/SDL_GetKeyFromScancode */ -int -keyboard_getKeyFromScancode(void *arg) +int keyboard_getKeyFromScancode(void *arg) { - SDL_Keycode result; + SDL_Keycode result; - /* Case where input is valid */ - result = SDL_GetKeyFromScancode(SDL_SCANCODE_A); - SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(valid)"); - SDLTest_AssertCheck(result == SDLK_a, "Verify result from call, expected: %i, got: %" SDL_PRIs32, SDLK_a, result); + /* Case where input is valid */ + result = SDL_GetKeyFromScancode(SDL_SCANCODE_A); + SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(valid)"); + SDLTest_AssertCheck(result == SDLK_a, "Verify result from call, expected: %i, got: %" SDL_PRIs32, SDLK_a, result); - /* Case where input is zero */ - result = SDL_GetKeyFromScancode(0); - SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(0)"); - SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %" SDL_PRIs32, SDLK_UNKNOWN, result); + /* Case where input is zero */ + result = SDL_GetKeyFromScancode(0); + SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(0)"); + SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %" SDL_PRIs32, SDLK_UNKNOWN, result); - /* Clear error message */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); + /* Clear error message */ + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); - /* Case where input is invalid (too small) */ - result = SDL_GetKeyFromScancode(-999); - SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(-999)"); - SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %" SDL_PRIs32, SDLK_UNKNOWN, result); - _checkInvalidScancodeError(); + /* Case where input is invalid (too small) */ + result = SDL_GetKeyFromScancode(-999); + SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(-999)"); + SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %" SDL_PRIs32, SDLK_UNKNOWN, result); + _checkInvalidScancodeError(); - /* Case where input is invalid (too big) */ - result = SDL_GetKeyFromScancode(999); - SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(999)"); - SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %" SDL_PRIs32, SDLK_UNKNOWN, result); - _checkInvalidScancodeError(); + /* Case where input is invalid (too big) */ + result = SDL_GetKeyFromScancode(999); + SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(999)"); + SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %" SDL_PRIs32, SDLK_UNKNOWN, result); + _checkInvalidScancodeError(); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -165,55 +160,54 @@ keyboard_getKeyFromScancode(void *arg) * * @sa http://wiki.libsdl.org/SDL_GetKeyName */ -int -keyboard_getKeyName(void *arg) +int keyboard_getKeyName(void *arg) { - const char *result; - const char *expected; + const char *result; + const char *expected; - /* Case where key has a 1 character name */ - expected = "3"; - result = (char *)SDL_GetKeyName(SDLK_3); - SDLTest_AssertPass("Call to SDL_GetKeyName()"); - SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); - SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result); + /* Case where key has a 1 character name */ + expected = "3"; + result = (char *)SDL_GetKeyName(SDLK_3); + SDLTest_AssertPass("Call to SDL_GetKeyName()"); + SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); + SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result); - /* Case where key has a 2 character name */ - expected = "F1"; - result = (char *)SDL_GetKeyName(SDLK_F1); - SDLTest_AssertPass("Call to SDL_GetKeyName()"); - SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); - SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result); + /* Case where key has a 2 character name */ + expected = "F1"; + result = (char *)SDL_GetKeyName(SDLK_F1); + SDLTest_AssertPass("Call to SDL_GetKeyName()"); + SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); + SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result); - /* Case where key has a 3 character name */ - expected = "Cut"; - result = (char *)SDL_GetKeyName(SDLK_CUT); - SDLTest_AssertPass("Call to SDL_GetKeyName()"); - SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); - SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result); + /* Case where key has a 3 character name */ + expected = "Cut"; + result = (char *)SDL_GetKeyName(SDLK_CUT); + SDLTest_AssertPass("Call to SDL_GetKeyName()"); + SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); + SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result); - /* Case where key has a 4 character name */ - expected = "Down"; - result = (char *)SDL_GetKeyName(SDLK_DOWN); - SDLTest_AssertPass("Call to SDL_GetKeyName()"); - SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); - SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result); + /* Case where key has a 4 character name */ + expected = "Down"; + result = (char *)SDL_GetKeyName(SDLK_DOWN); + SDLTest_AssertPass("Call to SDL_GetKeyName()"); + SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); + SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result); - /* Case where key has a N character name */ - expected = "BrightnessUp"; - result = (char *)SDL_GetKeyName(SDLK_BRIGHTNESSUP); - SDLTest_AssertPass("Call to SDL_GetKeyName()"); - SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); - SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result); + /* Case where key has a N character name */ + expected = "BrightnessUp"; + result = (char *)SDL_GetKeyName(SDLK_BRIGHTNESSUP); + SDLTest_AssertPass("Call to SDL_GetKeyName()"); + SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); + SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result); - /* Case where key has a N character name with space */ - expected = "Keypad MemStore"; - result = (char *)SDL_GetKeyName(SDLK_KP_MEMSTORE); - SDLTest_AssertPass("Call to SDL_GetKeyName()"); - SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); - SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result); + /* Case where key has a N character name with space */ + expected = "Keypad MemStore"; + result = (char *)SDL_GetKeyName(SDLK_KP_MEMSTORE); + SDLTest_AssertPass("Call to SDL_GetKeyName()"); + SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); + SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -221,26 +215,25 @@ keyboard_getKeyName(void *arg) * * @sa http://wiki.libsdl.org/SDL_GetScancodeName */ -int -keyboard_getScancodeNameNegative(void *arg) +int keyboard_getScancodeNameNegative(void *arg) { - SDL_Scancode scancode; - const char *result; - const char *expected = ""; + SDL_Scancode scancode; + const char *result; + const char *expected = ""; - /* Clear error message */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); + /* Clear error message */ + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); - /* Out-of-bounds scancode */ - scancode = (SDL_Scancode)SDL_NUM_SCANCODES; - result = (char *)SDL_GetScancodeName(scancode); - SDLTest_AssertPass("Call to SDL_GetScancodeName(%d/large)", scancode); - SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); - SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result); - _checkInvalidScancodeError(); + /* Out-of-bounds scancode */ + scancode = (SDL_Scancode)SDL_NUM_SCANCODES; + result = (char *)SDL_GetScancodeName(scancode); + SDLTest_AssertPass("Call to SDL_GetScancodeName(%d/large)", scancode); + SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); + SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result); + _checkInvalidScancodeError(); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -248,36 +241,35 @@ keyboard_getScancodeNameNegative(void *arg) * * @sa http://wiki.libsdl.org/SDL_GetKeyName */ -int -keyboard_getKeyNameNegative(void *arg) +int keyboard_getKeyNameNegative(void *arg) { - SDL_Keycode keycode; - const char *result; - const char *expected = ""; + SDL_Keycode keycode; + const char *result; + const char *expected = ""; - /* Unknown keycode */ - keycode = SDLK_UNKNOWN; - result = (char *)SDL_GetKeyName(keycode); - SDLTest_AssertPass("Call to SDL_GetKeyName(%" SDL_PRIs32 "/unknown)", keycode); - SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); - SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result); + /* Unknown keycode */ + keycode = SDLK_UNKNOWN; + result = (char *)SDL_GetKeyName(keycode); + SDLTest_AssertPass("Call to SDL_GetKeyName(%" SDL_PRIs32 "/unknown)", keycode); + SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); + SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result); - /* Clear error message */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); + /* Clear error message */ + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); - /* Negative keycode */ - keycode = (SDL_Keycode)SDLTest_RandomIntegerInRange(-255, -1); - result = (char *)SDL_GetKeyName(keycode); - SDLTest_AssertPass("Call to SDL_GetKeyName(%" SDL_PRIs32 "/negative)", keycode); - SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); - SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result); - _checkInvalidScancodeError(); + /* Negative keycode */ + keycode = (SDL_Keycode)SDLTest_RandomIntegerInRange(-255, -1); + result = (char *)SDL_GetKeyName(keycode); + SDLTest_AssertPass("Call to SDL_GetKeyName(%" SDL_PRIs32 "/negative)", keycode); + SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); + SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result); + _checkInvalidScancodeError(); - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -286,106 +278,103 @@ keyboard_getKeyNameNegative(void *arg) * @sa http://wiki.libsdl.org/SDL_GetModState * @sa http://wiki.libsdl.org/SDL_SetModState */ -int -keyboard_getSetModState(void *arg) +int keyboard_getSetModState(void *arg) { - SDL_Keymod result; - SDL_Keymod currentState; - SDL_Keymod newState; - SDL_Keymod allStates = - KMOD_NONE | - KMOD_LSHIFT | - KMOD_RSHIFT | - KMOD_LCTRL | - KMOD_RCTRL | - KMOD_LALT | - KMOD_RALT | - KMOD_LGUI | - KMOD_RGUI | - KMOD_NUM | - KMOD_CAPS | - KMOD_MODE | - KMOD_SCROLL; + SDL_Keymod result; + SDL_Keymod currentState; + SDL_Keymod newState; + SDL_Keymod allStates = + KMOD_NONE | + KMOD_LSHIFT | + KMOD_RSHIFT | + KMOD_LCTRL | + KMOD_RCTRL | + KMOD_LALT | + KMOD_RALT | + KMOD_LGUI | + KMOD_RGUI | + KMOD_NUM | + KMOD_CAPS | + KMOD_MODE | + KMOD_SCROLL; - /* Get state, cache for later reset */ - result = SDL_GetModState(); - SDLTest_AssertPass("Call to SDL_GetModState()"); - SDLTest_AssertCheck(/*result >= 0 &&*/ result <= allStates, "Verify result from call is valid, expected: 0 <= result <= %i, got: %i", allStates, result); - currentState = result; + /* Get state, cache for later reset */ + result = SDL_GetModState(); + SDLTest_AssertPass("Call to SDL_GetModState()"); + SDLTest_AssertCheck(/*result >= 0 &&*/ result <= allStates, "Verify result from call is valid, expected: 0 <= result <= %i, got: %i", allStates, result); + currentState = result; - /* Set random state */ - newState = SDLTest_RandomIntegerInRange(0, allStates); - SDL_SetModState(newState); - SDLTest_AssertPass("Call to SDL_SetModState(%i)", newState); - result = SDL_GetModState(); - SDLTest_AssertPass("Call to SDL_GetModState()"); - SDLTest_AssertCheck(result == newState, "Verify result from call is valid, expected: %i, got: %i", newState, result); + /* Set random state */ + newState = SDLTest_RandomIntegerInRange(0, allStates); + SDL_SetModState(newState); + SDLTest_AssertPass("Call to SDL_SetModState(%i)", newState); + result = SDL_GetModState(); + SDLTest_AssertPass("Call to SDL_GetModState()"); + SDLTest_AssertCheck(result == newState, "Verify result from call is valid, expected: %i, got: %i", newState, result); - /* Set zero state */ - SDL_SetModState(0); - SDLTest_AssertPass("Call to SDL_SetModState(0)"); - result = SDL_GetModState(); - SDLTest_AssertPass("Call to SDL_GetModState()"); - SDLTest_AssertCheck(result == 0, "Verify result from call is valid, expected: 0, got: %i", result); + /* Set zero state */ + SDL_SetModState(0); + SDLTest_AssertPass("Call to SDL_SetModState(0)"); + result = SDL_GetModState(); + SDLTest_AssertPass("Call to SDL_GetModState()"); + SDLTest_AssertCheck(result == 0, "Verify result from call is valid, expected: 0, got: %i", result); - /* Revert back to cached current state if needed */ - if (currentState != 0) { - SDL_SetModState(currentState); - SDLTest_AssertPass("Call to SDL_SetModState(%i)", currentState); - result = SDL_GetModState(); - SDLTest_AssertPass("Call to SDL_GetModState()"); - SDLTest_AssertCheck(result == currentState, "Verify result from call is valid, expected: %i, got: %i", currentState, result); - } + /* Revert back to cached current state if needed */ + if (currentState != 0) { + SDL_SetModState(currentState); + SDLTest_AssertPass("Call to SDL_SetModState(%i)", currentState); + result = SDL_GetModState(); + SDLTest_AssertPass("Call to SDL_GetModState()"); + SDLTest_AssertCheck(result == currentState, "Verify result from call is valid, expected: %i, got: %i", currentState, result); + } - return TEST_COMPLETED; + return TEST_COMPLETED; } - /** * @brief Check call to SDL_StartTextInput and SDL_StopTextInput * * @sa http://wiki.libsdl.org/SDL_StartTextInput * @sa http://wiki.libsdl.org/SDL_StopTextInput */ -int -keyboard_startStopTextInput(void *arg) +int keyboard_startStopTextInput(void *arg) { - /* Start-Stop */ - SDL_StartTextInput(); - SDLTest_AssertPass("Call to SDL_StartTextInput()"); - SDL_StopTextInput(); - SDLTest_AssertPass("Call to SDL_StopTextInput()"); + /* Start-Stop */ + SDL_StartTextInput(); + SDLTest_AssertPass("Call to SDL_StartTextInput()"); + SDL_StopTextInput(); + SDLTest_AssertPass("Call to SDL_StopTextInput()"); - /* Stop-Start */ - SDL_StartTextInput(); - SDLTest_AssertPass("Call to SDL_StartTextInput()"); + /* Stop-Start */ + SDL_StartTextInput(); + SDLTest_AssertPass("Call to SDL_StartTextInput()"); - /* Start-Start */ - SDL_StartTextInput(); - SDLTest_AssertPass("Call to SDL_StartTextInput()"); + /* Start-Start */ + SDL_StartTextInput(); + SDLTest_AssertPass("Call to SDL_StartTextInput()"); - /* Stop-Stop */ - SDL_StopTextInput(); - SDLTest_AssertPass("Call to SDL_StopTextInput()"); - SDL_StopTextInput(); - SDLTest_AssertPass("Call to SDL_StopTextInput()"); + /* Stop-Stop */ + SDL_StopTextInput(); + SDLTest_AssertPass("Call to SDL_StopTextInput()"); + SDL_StopTextInput(); + SDLTest_AssertPass("Call to SDL_StopTextInput()"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* Internal function to test SDL_SetTextInputRect */ void _testSetTextInputRect(SDL_Rect refRect) { - SDL_Rect testRect; + SDL_Rect testRect; - testRect = refRect; - SDL_SetTextInputRect(&testRect); - SDLTest_AssertPass("Call to SDL_SetTextInputRect with refRect(x:%i,y:%i,w:%i,h:%i)", refRect.x, refRect.y, refRect.w, refRect.h); - SDLTest_AssertCheck( - (refRect.x == testRect.x) && (refRect.y == testRect.y) && (refRect.w == testRect.w) && (refRect.h == testRect.h), - "Check that input data was not modified, expected: x:%i,y:%i,w:%i,h:%i, got: x:%i,y:%i,w:%i,h:%i", - refRect.x, refRect.y, refRect.w, refRect.h, - testRect.x, testRect.y, testRect.w, testRect.h); + testRect = refRect; + SDL_SetTextInputRect(&testRect); + SDLTest_AssertPass("Call to SDL_SetTextInputRect with refRect(x:%i,y:%i,w:%i,h:%i)", refRect.x, refRect.y, refRect.w, refRect.h); + SDLTest_AssertCheck( + (refRect.x == testRect.x) && (refRect.y == testRect.y) && (refRect.w == testRect.w) && (refRect.h == testRect.h), + "Check that input data was not modified, expected: x:%i,y:%i,w:%i,h:%i, got: x:%i,y:%i,w:%i,h:%i", + refRect.x, refRect.y, refRect.w, refRect.h, + testRect.x, testRect.y, testRect.w, testRect.h); } /** @@ -393,79 +382,78 @@ void _testSetTextInputRect(SDL_Rect refRect) * * @sa http://wiki.libsdl.org/SDL_SetTextInputRect */ -int -keyboard_setTextInputRect(void *arg) +int keyboard_setTextInputRect(void *arg) { - SDL_Rect refRect; + SDL_Rect refRect; - /* Normal visible refRect, origin inside */ - refRect.x = SDLTest_RandomIntegerInRange(1, 50); - refRect.y = SDLTest_RandomIntegerInRange(1, 50); - refRect.w = SDLTest_RandomIntegerInRange(10, 50); - refRect.h = SDLTest_RandomIntegerInRange(10, 50); - _testSetTextInputRect(refRect); + /* Normal visible refRect, origin inside */ + refRect.x = SDLTest_RandomIntegerInRange(1, 50); + refRect.y = SDLTest_RandomIntegerInRange(1, 50); + refRect.w = SDLTest_RandomIntegerInRange(10, 50); + refRect.h = SDLTest_RandomIntegerInRange(10, 50); + _testSetTextInputRect(refRect); - /* Normal visible refRect, origin 0,0 */ - refRect.x = 0; - refRect.y = 0; - refRect.w = SDLTest_RandomIntegerInRange(10, 50); - refRect.h = SDLTest_RandomIntegerInRange(10, 50); - _testSetTextInputRect(refRect); + /* Normal visible refRect, origin 0,0 */ + refRect.x = 0; + refRect.y = 0; + refRect.w = SDLTest_RandomIntegerInRange(10, 50); + refRect.h = SDLTest_RandomIntegerInRange(10, 50); + _testSetTextInputRect(refRect); - /* 1Pixel refRect */ - refRect.x = SDLTest_RandomIntegerInRange(10, 50); - refRect.y = SDLTest_RandomIntegerInRange(10, 50); - refRect.w = 1; - refRect.h = 1; - _testSetTextInputRect(refRect); + /* 1Pixel refRect */ + refRect.x = SDLTest_RandomIntegerInRange(10, 50); + refRect.y = SDLTest_RandomIntegerInRange(10, 50); + refRect.w = 1; + refRect.h = 1; + _testSetTextInputRect(refRect); - /* 0pixel refRect */ - refRect.x = 1; - refRect.y = 1; - refRect.w = 1; - refRect.h = 0; - _testSetTextInputRect(refRect); + /* 0pixel refRect */ + refRect.x = 1; + refRect.y = 1; + refRect.w = 1; + refRect.h = 0; + _testSetTextInputRect(refRect); - /* 0pixel refRect */ - refRect.x = 1; - refRect.y = 1; - refRect.w = 0; - refRect.h = 1; - _testSetTextInputRect(refRect); + /* 0pixel refRect */ + refRect.x = 1; + refRect.y = 1; + refRect.w = 0; + refRect.h = 1; + _testSetTextInputRect(refRect); - /* 0pixel refRect */ - refRect.x = 1; - refRect.y = 1; - refRect.w = 0; - refRect.h = 0; - _testSetTextInputRect(refRect); + /* 0pixel refRect */ + refRect.x = 1; + refRect.y = 1; + refRect.w = 0; + refRect.h = 0; + _testSetTextInputRect(refRect); - /* 0pixel refRect */ - refRect.x = 0; - refRect.y = 0; - refRect.w = 0; - refRect.h = 0; - _testSetTextInputRect(refRect); + /* 0pixel refRect */ + refRect.x = 0; + refRect.y = 0; + refRect.w = 0; + refRect.h = 0; + _testSetTextInputRect(refRect); - /* negative refRect */ - refRect.x = SDLTest_RandomIntegerInRange(-200, -100); - refRect.y = SDLTest_RandomIntegerInRange(-200, -100); - refRect.w = 50; - refRect.h = 50; - _testSetTextInputRect(refRect); + /* negative refRect */ + refRect.x = SDLTest_RandomIntegerInRange(-200, -100); + refRect.y = SDLTest_RandomIntegerInRange(-200, -100); + refRect.w = 50; + refRect.h = 50; + _testSetTextInputRect(refRect); - /* oversized refRect */ - refRect.x = SDLTest_RandomIntegerInRange(1, 50); - refRect.y = SDLTest_RandomIntegerInRange(1, 50); - refRect.w = 5000; - refRect.h = 5000; - _testSetTextInputRect(refRect); + /* oversized refRect */ + refRect.x = SDLTest_RandomIntegerInRange(1, 50); + refRect.y = SDLTest_RandomIntegerInRange(1, 50); + refRect.w = 5000; + refRect.h = 5000; + _testSetTextInputRect(refRect); - /* NULL refRect */ - SDL_SetTextInputRect(NULL); - SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)"); + /* NULL refRect */ + SDL_SetTextInputRect(NULL); + SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -473,37 +461,36 @@ keyboard_setTextInputRect(void *arg) * * @sa http://wiki.libsdl.org/SDL_SetTextInputRect */ -int -keyboard_setTextInputRectNegative(void *arg) +int keyboard_setTextInputRectNegative(void *arg) { - /* Some platforms set also an error message; prepare for checking it */ + /* Some platforms set also an error message; prepare for checking it */ #if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA - const char *expectedError = "Parameter 'rect' is invalid"; - const char *error; + const char *expectedError = "Parameter 'rect' is invalid"; + const char *error; - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); #endif - /* NULL refRect */ - SDL_SetTextInputRect(NULL); - SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)"); + /* NULL refRect */ + SDL_SetTextInputRect(NULL); + SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)"); - /* Some platforms set also an error message; so check it */ + /* Some platforms set also an error message; so check it */ #if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError, error); - } + error = SDL_GetError(); + SDLTest_AssertPass("Call to SDL_GetError()"); + SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); + if (error != NULL) { + SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, + "Validate error message, expected: '%s', got: '%s'", expectedError, error); + } - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); #endif - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -512,22 +499,21 @@ keyboard_setTextInputRectNegative(void *arg) * @sa http://wiki.libsdl.org/SDL_GetScancodeFromKey * @sa http://wiki.libsdl.org/SDL_Keycode */ -int -keyboard_getScancodeFromKey(void *arg) +int keyboard_getScancodeFromKey(void *arg) { - SDL_Scancode scancode; + SDL_Scancode scancode; - /* Regular key */ - scancode = SDL_GetScancodeFromKey(SDLK_4); - SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_4)"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromKey, expected: %i, got: %i", SDL_SCANCODE_4, scancode); + /* Regular key */ + scancode = SDL_GetScancodeFromKey(SDLK_4); + SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_4)"); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromKey, expected: %i, got: %i", SDL_SCANCODE_4, scancode); - /* Virtual key */ - scancode = SDL_GetScancodeFromKey(SDLK_PLUS); - SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_PLUS)"); - SDLTest_AssertCheck(scancode == 0, "Validate return value from SDL_GetScancodeFromKey, expected: 0, got: %i", scancode); + /* Virtual key */ + scancode = SDL_GetScancodeFromKey(SDLK_PLUS); + SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_PLUS)"); + SDLTest_AssertCheck(scancode == 0, "Validate return value from SDL_GetScancodeFromKey, expected: 0, got: %i", scancode); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -536,71 +522,69 @@ keyboard_getScancodeFromKey(void *arg) * @sa http://wiki.libsdl.org/SDL_GetScancodeFromName * @sa http://wiki.libsdl.org/SDL_Keycode */ -int -keyboard_getScancodeFromName(void *arg) +int keyboard_getScancodeFromName(void *arg) { - SDL_Scancode scancode; + SDL_Scancode scancode; - /* Regular key, 1 character, first name in list */ - scancode = SDL_GetScancodeFromName("A"); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName('A')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_A, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_A, scancode); + /* Regular key, 1 character, first name in list */ + scancode = SDL_GetScancodeFromName("A"); + SDLTest_AssertPass("Call to SDL_GetScancodeFromName('A')"); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_A, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_A, scancode); - /* Regular key, 1 character */ - scancode = SDL_GetScancodeFromName("4"); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName('4')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_4, scancode); + /* Regular key, 1 character */ + scancode = SDL_GetScancodeFromName("4"); + SDLTest_AssertPass("Call to SDL_GetScancodeFromName('4')"); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_4, scancode); - /* Regular key, 2 characters */ - scancode = SDL_GetScancodeFromName("F1"); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName('F1')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_F1, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_F1, scancode); + /* Regular key, 2 characters */ + scancode = SDL_GetScancodeFromName("F1"); + SDLTest_AssertPass("Call to SDL_GetScancodeFromName('F1')"); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_F1, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_F1, scancode); - /* Regular key, 3 characters */ - scancode = SDL_GetScancodeFromName("End"); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName('End')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_END, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_END, scancode); + /* Regular key, 3 characters */ + scancode = SDL_GetScancodeFromName("End"); + SDLTest_AssertPass("Call to SDL_GetScancodeFromName('End')"); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_END, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_END, scancode); - /* Regular key, 4 characters */ - scancode = SDL_GetScancodeFromName("Find"); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Find')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_FIND, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_FIND, scancode); + /* Regular key, 4 characters */ + scancode = SDL_GetScancodeFromName("Find"); + SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Find')"); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_FIND, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_FIND, scancode); - /* Regular key, several characters */ - scancode = SDL_GetScancodeFromName("Backspace"); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Backspace')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_BACKSPACE, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_BACKSPACE, scancode); + /* Regular key, several characters */ + scancode = SDL_GetScancodeFromName("Backspace"); + SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Backspace')"); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_BACKSPACE, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_BACKSPACE, scancode); - /* Regular key, several characters with space */ - scancode = SDL_GetScancodeFromName("Keypad Enter"); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Keypad Enter')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_KP_ENTER, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_KP_ENTER, scancode); + /* Regular key, several characters with space */ + scancode = SDL_GetScancodeFromName("Keypad Enter"); + SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Keypad Enter')"); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_KP_ENTER, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_KP_ENTER, scancode); - /* Regular key, last name in list */ - scancode = SDL_GetScancodeFromName("Sleep"); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Sleep')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_SLEEP, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_SLEEP, scancode); + /* Regular key, last name in list */ + scancode = SDL_GetScancodeFromName("Sleep"); + SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Sleep')"); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_SLEEP, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_SLEEP, scancode); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* * Local helper to check for the invalid scancode error message */ -void -_checkInvalidNameError() +void _checkInvalidNameError() { - const char *expectedError = "Parameter 'name' is invalid"; - const char *error; - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError, error); - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - } + const char *expectedError = "Parameter 'name' is invalid"; + const char *error; + error = SDL_GetError(); + SDLTest_AssertPass("Call to SDL_GetError()"); + SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); + if (error != NULL) { + SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, + "Validate error message, expected: '%s', got: '%s'", expectedError, error); + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); + } } /** @@ -609,94 +593,105 @@ _checkInvalidNameError() * @sa http://wiki.libsdl.org/SDL_GetScancodeFromName * @sa http://wiki.libsdl.org/SDL_Keycode */ -int -keyboard_getScancodeFromNameNegative(void *arg) +int keyboard_getScancodeFromNameNegative(void *arg) { - const char *name; - SDL_Scancode scancode; + const char *name; + SDL_Scancode scancode; - /* Clear error message */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); + /* Clear error message */ + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); - /* Random string input */ - name = SDLTest_RandomAsciiStringOfSize(32); - SDLTest_Assert(name != NULL, "Check that random name is not NULL"); - if (name == NULL) { - return TEST_ABORTED; - } - scancode = SDL_GetScancodeFromName(name); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName('%s')", name); - SDL_free((void *)name); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode); - _checkInvalidNameError(); + /* Random string input */ + name = SDLTest_RandomAsciiStringOfSize(32); + SDLTest_Assert(name != NULL, "Check that random name is not NULL"); + if (name == NULL) { + return TEST_ABORTED; + } + scancode = SDL_GetScancodeFromName(name); + SDLTest_AssertPass("Call to SDL_GetScancodeFromName('%s')", name); + SDL_free((void *)name); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode); + _checkInvalidNameError(); - /* Zero length string input */ - name = ""; - scancode = SDL_GetScancodeFromName((const char *)name); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode); - _checkInvalidNameError(); + /* Zero length string input */ + name = ""; + scancode = SDL_GetScancodeFromName((const char *)name); + SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)"); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode); + _checkInvalidNameError(); - /* NULL input */ - name = NULL; - scancode = SDL_GetScancodeFromName((const char *)name); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode); - _checkInvalidNameError(); + /* NULL input */ + name = NULL; + scancode = SDL_GetScancodeFromName((const char *)name); + SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)"); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode); + _checkInvalidNameError(); - return TEST_COMPLETED; + return TEST_COMPLETED; } - - /* ================= Test References ================== */ /* Keyboard test cases */ -static const SDLTest_TestCaseReference keyboardTest1 = - { (SDLTest_TestCaseFp)keyboard_getKeyboardState, "keyboard_getKeyboardState", "Check call to SDL_GetKeyboardState with and without numkeys reference", TEST_ENABLED }; +static const SDLTest_TestCaseReference keyboardTest1 = { + (SDLTest_TestCaseFp)keyboard_getKeyboardState, "keyboard_getKeyboardState", "Check call to SDL_GetKeyboardState with and without numkeys reference", TEST_ENABLED +}; -static const SDLTest_TestCaseReference keyboardTest2 = - { (SDLTest_TestCaseFp)keyboard_getKeyboardFocus, "keyboard_getKeyboardFocus", "Check call to SDL_GetKeyboardFocus", TEST_ENABLED }; +static const SDLTest_TestCaseReference keyboardTest2 = { + (SDLTest_TestCaseFp)keyboard_getKeyboardFocus, "keyboard_getKeyboardFocus", "Check call to SDL_GetKeyboardFocus", TEST_ENABLED +}; -static const SDLTest_TestCaseReference keyboardTest3 = - { (SDLTest_TestCaseFp)keyboard_getKeyFromName, "keyboard_getKeyFromName", "Check call to SDL_GetKeyFromName for known, unknown and invalid name", TEST_ENABLED }; +static const SDLTest_TestCaseReference keyboardTest3 = { + (SDLTest_TestCaseFp)keyboard_getKeyFromName, "keyboard_getKeyFromName", "Check call to SDL_GetKeyFromName for known, unknown and invalid name", TEST_ENABLED +}; -static const SDLTest_TestCaseReference keyboardTest4 = - { (SDLTest_TestCaseFp)keyboard_getKeyFromScancode, "keyboard_getKeyFromScancode", "Check call to SDL_GetKeyFromScancode", TEST_ENABLED }; +static const SDLTest_TestCaseReference keyboardTest4 = { + (SDLTest_TestCaseFp)keyboard_getKeyFromScancode, "keyboard_getKeyFromScancode", "Check call to SDL_GetKeyFromScancode", TEST_ENABLED +}; -static const SDLTest_TestCaseReference keyboardTest5 = - { (SDLTest_TestCaseFp)keyboard_getKeyName, "keyboard_getKeyName", "Check call to SDL_GetKeyName", TEST_ENABLED }; +static const SDLTest_TestCaseReference keyboardTest5 = { + (SDLTest_TestCaseFp)keyboard_getKeyName, "keyboard_getKeyName", "Check call to SDL_GetKeyName", TEST_ENABLED +}; -static const SDLTest_TestCaseReference keyboardTest6 = - { (SDLTest_TestCaseFp)keyboard_getSetModState, "keyboard_getSetModState", "Check call to SDL_GetModState and SDL_SetModState", TEST_ENABLED }; +static const SDLTest_TestCaseReference keyboardTest6 = { + (SDLTest_TestCaseFp)keyboard_getSetModState, "keyboard_getSetModState", "Check call to SDL_GetModState and SDL_SetModState", TEST_ENABLED +}; -static const SDLTest_TestCaseReference keyboardTest7 = - { (SDLTest_TestCaseFp)keyboard_startStopTextInput, "keyboard_startStopTextInput", "Check call to SDL_StartTextInput and SDL_StopTextInput", TEST_ENABLED }; +static const SDLTest_TestCaseReference keyboardTest7 = { + (SDLTest_TestCaseFp)keyboard_startStopTextInput, "keyboard_startStopTextInput", "Check call to SDL_StartTextInput and SDL_StopTextInput", TEST_ENABLED +}; -static const SDLTest_TestCaseReference keyboardTest8 = - { (SDLTest_TestCaseFp)keyboard_setTextInputRect, "keyboard_setTextInputRect", "Check call to SDL_SetTextInputRect", TEST_ENABLED }; +static const SDLTest_TestCaseReference keyboardTest8 = { + (SDLTest_TestCaseFp)keyboard_setTextInputRect, "keyboard_setTextInputRect", "Check call to SDL_SetTextInputRect", TEST_ENABLED +}; -static const SDLTest_TestCaseReference keyboardTest9 = - { (SDLTest_TestCaseFp)keyboard_setTextInputRectNegative, "keyboard_setTextInputRectNegative", "Check call to SDL_SetTextInputRect with invalid data", TEST_ENABLED }; +static const SDLTest_TestCaseReference keyboardTest9 = { + (SDLTest_TestCaseFp)keyboard_setTextInputRectNegative, "keyboard_setTextInputRectNegative", "Check call to SDL_SetTextInputRect with invalid data", TEST_ENABLED +}; -static const SDLTest_TestCaseReference keyboardTest10 = - { (SDLTest_TestCaseFp)keyboard_getScancodeFromKey, "keyboard_getScancodeFromKey", "Check call to SDL_GetScancodeFromKey", TEST_ENABLED }; +static const SDLTest_TestCaseReference keyboardTest10 = { + (SDLTest_TestCaseFp)keyboard_getScancodeFromKey, "keyboard_getScancodeFromKey", "Check call to SDL_GetScancodeFromKey", TEST_ENABLED +}; -static const SDLTest_TestCaseReference keyboardTest11 = - { (SDLTest_TestCaseFp)keyboard_getScancodeFromName, "keyboard_getScancodeFromName", "Check call to SDL_GetScancodeFromName", TEST_ENABLED }; +static const SDLTest_TestCaseReference keyboardTest11 = { + (SDLTest_TestCaseFp)keyboard_getScancodeFromName, "keyboard_getScancodeFromName", "Check call to SDL_GetScancodeFromName", TEST_ENABLED +}; -static const SDLTest_TestCaseReference keyboardTest12 = - { (SDLTest_TestCaseFp)keyboard_getScancodeFromNameNegative, "keyboard_getScancodeFromNameNegative", "Check call to SDL_GetScancodeFromName with invalid data", TEST_ENABLED }; +static const SDLTest_TestCaseReference keyboardTest12 = { + (SDLTest_TestCaseFp)keyboard_getScancodeFromNameNegative, "keyboard_getScancodeFromNameNegative", "Check call to SDL_GetScancodeFromName with invalid data", TEST_ENABLED +}; -static const SDLTest_TestCaseReference keyboardTest13 = - { (SDLTest_TestCaseFp)keyboard_getKeyNameNegative, "keyboard_getKeyNameNegative", "Check call to SDL_GetKeyName with invalid data", TEST_ENABLED }; +static const SDLTest_TestCaseReference keyboardTest13 = { + (SDLTest_TestCaseFp)keyboard_getKeyNameNegative, "keyboard_getKeyNameNegative", "Check call to SDL_GetKeyName with invalid data", TEST_ENABLED +}; -static const SDLTest_TestCaseReference keyboardTest14 = - { (SDLTest_TestCaseFp)keyboard_getScancodeNameNegative, "keyboard_getScancodeNameNegative", "Check call to SDL_GetScancodeName with invalid data", TEST_ENABLED }; +static const SDLTest_TestCaseReference keyboardTest14 = { + (SDLTest_TestCaseFp)keyboard_getScancodeNameNegative, "keyboard_getScancodeNameNegative", "Check call to SDL_GetScancodeName with invalid data", TEST_ENABLED +}; /* Sequence of Keyboard test cases */ -static const SDLTest_TestCaseReference *keyboardTests[] = { +static const SDLTest_TestCaseReference *keyboardTests[] = { &keyboardTest1, &keyboardTest2, &keyboardTest3, &keyboardTest4, &keyboardTest5, &keyboardTest6, &keyboardTest7, &keyboardTest8, &keyboardTest9, &keyboardTest10, &keyboardTest11, &keyboardTest12, &keyboardTest13, &keyboardTest14, NULL diff --git a/test/testautomation_main.c b/test/testautomation_main.c index 97d235231..ed72e0d95 100644 --- a/test/testautomation_main.c +++ b/test/testautomation_main.c @@ -9,14 +9,13 @@ #include "SDL.h" #include "SDL_test.h" - /* ! * \brief Tests SDL_Init() and SDL_Quit() of Joystick and Haptic subsystems * \sa * http://wiki.libsdl.org/SDL_Init * http://wiki.libsdl.org/SDL_Quit */ -static int main_testInitQuitJoystickHaptic (void *arg) +static int main_testInitQuitJoystickHaptic(void *arg) { #if defined SDL_JOYSTICK_DISABLED || defined SDL_HAPTIC_DISABLED return TEST_SKIPPED; @@ -24,15 +23,15 @@ static int main_testInitQuitJoystickHaptic (void *arg) int enabled_subsystems; int initialized_subsystems = SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC; - SDLTest_AssertCheck( SDL_Init(initialized_subsystems) == 0, "SDL_Init multiple systems." ); + SDLTest_AssertCheck(SDL_Init(initialized_subsystems) == 0, "SDL_Init multiple systems."); enabled_subsystems = SDL_WasInit(initialized_subsystems); - SDLTest_AssertCheck( enabled_subsystems == initialized_subsystems, "SDL_WasInit(SDL_INIT_EVERYTHING) contains all systems (%i)", enabled_subsystems ); + SDLTest_AssertCheck(enabled_subsystems == initialized_subsystems, "SDL_WasInit(SDL_INIT_EVERYTHING) contains all systems (%i)", enabled_subsystems); SDL_Quit(); enabled_subsystems = SDL_WasInit(initialized_subsystems); - SDLTest_AssertCheck( enabled_subsystems == 0, "SDL_Quit should shut down everything (%i)", enabled_subsystems ); + SDLTest_AssertCheck(enabled_subsystems == 0, "SDL_Quit should shut down everything (%i)", enabled_subsystems); return TEST_COMPLETED; #endif @@ -44,7 +43,7 @@ static int main_testInitQuitJoystickHaptic (void *arg) * http://wiki.libsdl.org/SDL_Init * http://wiki.libsdl.org/SDL_Quit */ -static int main_testInitQuitSubSystem (void *arg) +static int main_testInitQuitSubSystem(void *arg) { #if defined SDL_JOYSTICK_DISABLED || defined SDL_HAPTIC_DISABLED || defined SDL_GAMECONTROLLER_DISABLED return TEST_SKIPPED; @@ -56,15 +55,15 @@ static int main_testInitQuitSubSystem (void *arg) int initialized_system; int subsystem = subsystems[i]; - SDLTest_AssertCheck( (SDL_WasInit(subsystem) & subsystem) == 0, "SDL_WasInit(%x) before init should be false", subsystem ); - SDLTest_AssertCheck( SDL_InitSubSystem(subsystem) == 0, "SDL_InitSubSystem(%x)", subsystem ); + SDLTest_AssertCheck((SDL_WasInit(subsystem) & subsystem) == 0, "SDL_WasInit(%x) before init should be false", subsystem); + SDLTest_AssertCheck(SDL_InitSubSystem(subsystem) == 0, "SDL_InitSubSystem(%x)", subsystem); initialized_system = SDL_WasInit(subsystem); - SDLTest_AssertCheck( (initialized_system & subsystem) != 0, "SDL_WasInit(%x) should be true (%x)", subsystem, initialized_system ); + SDLTest_AssertCheck((initialized_system & subsystem) != 0, "SDL_WasInit(%x) should be true (%x)", subsystem, initialized_system); SDL_QuitSubSystem(subsystem); - SDLTest_AssertCheck( (SDL_WasInit(subsystem) & subsystem) == 0, "SDL_WasInit(%x) after shutdown should be false", subsystem ); + SDLTest_AssertCheck((SDL_WasInit(subsystem) & subsystem) == 0, "SDL_WasInit(%x) after shutdown should be false", subsystem); } return TEST_COMPLETED; @@ -72,7 +71,7 @@ static int main_testInitQuitSubSystem (void *arg) } const int joy_and_controller = SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER; -static int main_testImpliedJoystickInit (void *arg) +static int main_testImpliedJoystickInit(void *arg) { #if defined SDL_JOYSTICK_DISABLED || defined SDL_GAMECONTROLLER_DISABLED return TEST_SKIPPED; @@ -80,24 +79,24 @@ static int main_testImpliedJoystickInit (void *arg) int initialized_system; /* First initialize the controller */ - SDLTest_AssertCheck( (SDL_WasInit(joy_and_controller) & joy_and_controller) == 0, "SDL_WasInit() before init should be false for joystick & controller" ); - SDLTest_AssertCheck( SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == 0, "SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER)" ); + SDLTest_AssertCheck((SDL_WasInit(joy_and_controller) & joy_and_controller) == 0, "SDL_WasInit() before init should be false for joystick & controller"); + SDLTest_AssertCheck(SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == 0, "SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER)"); /* Then make sure this implicitly initialized the joystick subsystem */ initialized_system = SDL_WasInit(joy_and_controller); - SDLTest_AssertCheck( (initialized_system & joy_and_controller) == joy_and_controller, "SDL_WasInit() should be true for joystick & controller (%x)", initialized_system ); + SDLTest_AssertCheck((initialized_system & joy_and_controller) == joy_and_controller, "SDL_WasInit() should be true for joystick & controller (%x)", initialized_system); /* Then quit the controller, and make sure that implicitly also quits the */ /* joystick subsystem */ SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER); initialized_system = SDL_WasInit(joy_and_controller); - SDLTest_AssertCheck( (initialized_system & joy_and_controller) == 0, "SDL_WasInit() should be false for joystick & controller (%x)", initialized_system ); + SDLTest_AssertCheck((initialized_system & joy_and_controller) == 0, "SDL_WasInit() should be false for joystick & controller (%x)", initialized_system); return TEST_COMPLETED; #endif } -static int main_testImpliedJoystickQuit (void *arg) +static int main_testImpliedJoystickQuit(void *arg) { #if defined SDL_JOYSTICK_DISABLED || defined SDL_GAMECONTROLLER_DISABLED return TEST_SKIPPED; @@ -105,19 +104,19 @@ static int main_testImpliedJoystickQuit (void *arg) int initialized_system; /* First initialize the controller and the joystick (explicitly) */ - SDLTest_AssertCheck( (SDL_WasInit(joy_and_controller) & joy_and_controller) == 0, "SDL_WasInit() before init should be false for joystick & controller" ); - SDLTest_AssertCheck( SDL_InitSubSystem(SDL_INIT_JOYSTICK) == 0, "SDL_InitSubSystem(SDL_INIT_JOYSTICK)" ); - SDLTest_AssertCheck( SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == 0, "SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER)" ); + SDLTest_AssertCheck((SDL_WasInit(joy_and_controller) & joy_and_controller) == 0, "SDL_WasInit() before init should be false for joystick & controller"); + SDLTest_AssertCheck(SDL_InitSubSystem(SDL_INIT_JOYSTICK) == 0, "SDL_InitSubSystem(SDL_INIT_JOYSTICK)"); + SDLTest_AssertCheck(SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == 0, "SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER)"); /* Then make sure they're both initialized properly */ initialized_system = SDL_WasInit(joy_and_controller); - SDLTest_AssertCheck( (initialized_system & joy_and_controller) == joy_and_controller, "SDL_WasInit() should be true for joystick & controller (%x)", initialized_system ); + SDLTest_AssertCheck((initialized_system & joy_and_controller) == joy_and_controller, "SDL_WasInit() should be true for joystick & controller (%x)", initialized_system); /* Then quit the controller, and make sure that it does NOT quit the */ /* explicitly initialized joystick subsystem. */ SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER); initialized_system = SDL_WasInit(joy_and_controller); - SDLTest_AssertCheck( (initialized_system & joy_and_controller) == SDL_INIT_JOYSTICK, "SDL_WasInit() should be false for joystick & controller (%x)", initialized_system ); + SDLTest_AssertCheck((initialized_system & joy_and_controller) == SDL_INIT_JOYSTICK, "SDL_WasInit() should be false for joystick & controller (%x)", initialized_system); SDL_QuitSubSystem(SDL_INIT_JOYSTICK); @@ -140,7 +139,7 @@ main_testSetError(void *arg) SDL_SetError(""); SDLTest_AssertCheck(SDL_strcmp(error, SDL_GetError()) == 0, "SDL_SetError(\"\")"); - for (i = 0; i < (sizeof(error)-1); ++i) { + for (i = 0; i < (sizeof(error) - 1); ++i) { error[i] = 'a' + (i % 26); } error[i] = '\0'; @@ -154,23 +153,28 @@ main_testSetError(void *arg) #pragma GCC diagnostic pop #endif -static const SDLTest_TestCaseReference mainTest1 = - { (SDLTest_TestCaseFp)main_testInitQuitJoystickHaptic, "main_testInitQuitJoystickHaptic", "Tests SDL_Init/Quit of Joystick and Haptic subsystem", TEST_ENABLED}; +static const SDLTest_TestCaseReference mainTest1 = { + (SDLTest_TestCaseFp)main_testInitQuitJoystickHaptic, "main_testInitQuitJoystickHaptic", "Tests SDL_Init/Quit of Joystick and Haptic subsystem", TEST_ENABLED +}; -static const SDLTest_TestCaseReference mainTest2 = - { (SDLTest_TestCaseFp)main_testInitQuitSubSystem, "main_testInitQuitSubSystem", "Tests SDL_InitSubSystem/QuitSubSystem", TEST_ENABLED}; +static const SDLTest_TestCaseReference mainTest2 = { + (SDLTest_TestCaseFp)main_testInitQuitSubSystem, "main_testInitQuitSubSystem", "Tests SDL_InitSubSystem/QuitSubSystem", TEST_ENABLED +}; -static const SDLTest_TestCaseReference mainTest3 = - { (SDLTest_TestCaseFp)main_testImpliedJoystickInit, "main_testImpliedJoystickInit", "Tests that init for gamecontroller properly implies joystick", TEST_ENABLED}; +static const SDLTest_TestCaseReference mainTest3 = { + (SDLTest_TestCaseFp)main_testImpliedJoystickInit, "main_testImpliedJoystickInit", "Tests that init for gamecontroller properly implies joystick", TEST_ENABLED +}; -static const SDLTest_TestCaseReference mainTest4 = - { (SDLTest_TestCaseFp)main_testImpliedJoystickQuit, "main_testImpliedJoystickQuit", "Tests that quit for gamecontroller doesn't quit joystick if you inited it explicitly", TEST_ENABLED}; +static const SDLTest_TestCaseReference mainTest4 = { + (SDLTest_TestCaseFp)main_testImpliedJoystickQuit, "main_testImpliedJoystickQuit", "Tests that quit for gamecontroller doesn't quit joystick if you inited it explicitly", TEST_ENABLED +}; -static const SDLTest_TestCaseReference mainTest5 = - { (SDLTest_TestCaseFp)main_testSetError, "main_testSetError", "Tests that SDL_SetError() handles arbitrarily large strings", TEST_ENABLED}; +static const SDLTest_TestCaseReference mainTest5 = { + (SDLTest_TestCaseFp)main_testSetError, "main_testSetError", "Tests that SDL_SetError() handles arbitrarily large strings", TEST_ENABLED +}; /* Sequence of Main test cases */ -static const SDLTest_TestCaseReference *mainTests[] = { +static const SDLTest_TestCaseReference *mainTests[] = { &mainTest1, &mainTest2, &mainTest3, diff --git a/test/testautomation_math.c b/test/testautomation_math.c index bdf5703a2..f3b34a262 100644 --- a/test/testautomation_math.c +++ b/test/testautomation_math.c @@ -2769,520 +2769,520 @@ atan2_bottomLeftQuadrantTest(void *args) /* SDL_floor test cases */ static const SDLTest_TestCaseReference floorTestInf = { - (SDLTest_TestCaseFp) floor_infCases, "floor_infCases", + (SDLTest_TestCaseFp)floor_infCases, "floor_infCases", "Checks positive and negative infinity", TEST_ENABLED }; static const SDLTest_TestCaseReference floorTestZero = { - (SDLTest_TestCaseFp) floor_zeroCases, "floor_zeroCases", + (SDLTest_TestCaseFp)floor_zeroCases, "floor_zeroCases", "Checks positive and negative zero", TEST_ENABLED }; static const SDLTest_TestCaseReference floorTestNan = { - (SDLTest_TestCaseFp) floor_nanCase, "floor_nanCase", + (SDLTest_TestCaseFp)floor_nanCase, "floor_nanCase", "Checks NAN", TEST_ENABLED }; static const SDLTest_TestCaseReference floorTestRound = { - (SDLTest_TestCaseFp) floor_roundNumbersCases, "floor_roundNumberCases", + (SDLTest_TestCaseFp)floor_roundNumbersCases, "floor_roundNumberCases", "Checks a set of integral values", TEST_ENABLED }; static const SDLTest_TestCaseReference floorTestFraction = { - (SDLTest_TestCaseFp) floor_fractionCases, "floor_fractionCases", + (SDLTest_TestCaseFp)floor_fractionCases, "floor_fractionCases", "Checks a set of fractions", TEST_ENABLED }; static const SDLTest_TestCaseReference floorTestRange = { - (SDLTest_TestCaseFp) floor_rangeTest, "floor_rangeTest", + (SDLTest_TestCaseFp)floor_rangeTest, "floor_rangeTest", "Checks a range of positive integer", TEST_ENABLED }; /* SDL_ceil test cases */ static const SDLTest_TestCaseReference ceilTestInf = { - (SDLTest_TestCaseFp) ceil_infCases, "ceil_infCases", + (SDLTest_TestCaseFp)ceil_infCases, "ceil_infCases", "Checks positive and negative infinity", TEST_ENABLED }; static const SDLTest_TestCaseReference ceilTestZero = { - (SDLTest_TestCaseFp) ceil_zeroCases, "ceil_zeroCases", + (SDLTest_TestCaseFp)ceil_zeroCases, "ceil_zeroCases", "Checks positive and negative zero", TEST_ENABLED }; static const SDLTest_TestCaseReference ceilTestNan = { - (SDLTest_TestCaseFp) ceil_nanCase, "ceil_nanCase", + (SDLTest_TestCaseFp)ceil_nanCase, "ceil_nanCase", "Checks NAN", TEST_ENABLED }; static const SDLTest_TestCaseReference ceilTestRound = { - (SDLTest_TestCaseFp) ceil_roundNumbersCases, "ceil_roundNumberCases", + (SDLTest_TestCaseFp)ceil_roundNumbersCases, "ceil_roundNumberCases", "Checks a set of integral values", TEST_ENABLED }; static const SDLTest_TestCaseReference ceilTestFraction = { - (SDLTest_TestCaseFp) ceil_fractionCases, "ceil_fractionCases", + (SDLTest_TestCaseFp)ceil_fractionCases, "ceil_fractionCases", "Checks a set of fractions", TEST_ENABLED }; static const SDLTest_TestCaseReference ceilTestRange = { - (SDLTest_TestCaseFp) ceil_rangeTest, "ceil_rangeTest", + (SDLTest_TestCaseFp)ceil_rangeTest, "ceil_rangeTest", "Checks a range of positive integer", TEST_ENABLED }; /* SDL_trunc test cases */ static const SDLTest_TestCaseReference truncTestInf = { - (SDLTest_TestCaseFp) trunc_infCases, "trunc_infCases", + (SDLTest_TestCaseFp)trunc_infCases, "trunc_infCases", "Checks positive and negative infinity", TEST_ENABLED }; static const SDLTest_TestCaseReference truncTestZero = { - (SDLTest_TestCaseFp) trunc_zeroCases, "trunc_zeroCases", + (SDLTest_TestCaseFp)trunc_zeroCases, "trunc_zeroCases", "Checks positive and negative zero", TEST_ENABLED }; static const SDLTest_TestCaseReference truncTestNan = { - (SDLTest_TestCaseFp) trunc_nanCase, "trunc_nanCase", + (SDLTest_TestCaseFp)trunc_nanCase, "trunc_nanCase", "Checks NAN", TEST_ENABLED }; static const SDLTest_TestCaseReference truncTestRound = { - (SDLTest_TestCaseFp) trunc_roundNumbersCases, "trunc_roundNumberCases", + (SDLTest_TestCaseFp)trunc_roundNumbersCases, "trunc_roundNumberCases", "Checks a set of integral values", TEST_ENABLED }; static const SDLTest_TestCaseReference truncTestFraction = { - (SDLTest_TestCaseFp) trunc_fractionCases, "trunc_fractionCases", + (SDLTest_TestCaseFp)trunc_fractionCases, "trunc_fractionCases", "Checks a set of fractions", TEST_ENABLED }; static const SDLTest_TestCaseReference truncTestRange = { - (SDLTest_TestCaseFp) trunc_rangeTest, "trunc_rangeTest", + (SDLTest_TestCaseFp)trunc_rangeTest, "trunc_rangeTest", "Checks a range of positive integer", TEST_ENABLED }; /* SDL_round test cases */ static const SDLTest_TestCaseReference roundTestInf = { - (SDLTest_TestCaseFp) round_infCases, "round_infCases", + (SDLTest_TestCaseFp)round_infCases, "round_infCases", "Checks positive and negative infinity", TEST_ENABLED }; static const SDLTest_TestCaseReference roundTestZero = { - (SDLTest_TestCaseFp) round_zeroCases, "round_zeroCases", + (SDLTest_TestCaseFp)round_zeroCases, "round_zeroCases", "Checks positive and negative zero", TEST_ENABLED }; static const SDLTest_TestCaseReference roundTestNan = { - (SDLTest_TestCaseFp) round_nanCase, "round_nanCase", + (SDLTest_TestCaseFp)round_nanCase, "round_nanCase", "Checks NAN", TEST_ENABLED }; static const SDLTest_TestCaseReference roundTestRound = { - (SDLTest_TestCaseFp) round_roundNumbersCases, "round_roundNumberCases", + (SDLTest_TestCaseFp)round_roundNumbersCases, "round_roundNumberCases", "Checks a set of integral values", TEST_ENABLED }; static const SDLTest_TestCaseReference roundTestFraction = { - (SDLTest_TestCaseFp) round_fractionCases, "round_fractionCases", + (SDLTest_TestCaseFp)round_fractionCases, "round_fractionCases", "Checks a set of fractions", TEST_ENABLED }; static const SDLTest_TestCaseReference roundTestRange = { - (SDLTest_TestCaseFp) round_rangeTest, "round_rangeTest", + (SDLTest_TestCaseFp)round_rangeTest, "round_rangeTest", "Checks a range of positive integer", TEST_ENABLED }; /* SDL_fabs test cases */ static const SDLTest_TestCaseReference fabsTestInf = { - (SDLTest_TestCaseFp) fabs_infCases, "fabs_infCases", + (SDLTest_TestCaseFp)fabs_infCases, "fabs_infCases", "Checks positive and negative infinity", TEST_ENABLED }; static const SDLTest_TestCaseReference fabsTestZero = { - (SDLTest_TestCaseFp) fabs_zeroCases, "fabs_zeroCases", + (SDLTest_TestCaseFp)fabs_zeroCases, "fabs_zeroCases", "Checks positive and negative zero", TEST_ENABLED }; static const SDLTest_TestCaseReference fabsTestNan = { - (SDLTest_TestCaseFp) fabs_nanCase, "fabs_nanCase", + (SDLTest_TestCaseFp)fabs_nanCase, "fabs_nanCase", "Checks NAN", TEST_ENABLED }; static const SDLTest_TestCaseReference fabsTestRange = { - (SDLTest_TestCaseFp) fabs_rangeTest, "fabs_rangeTest", + (SDLTest_TestCaseFp)fabs_rangeTest, "fabs_rangeTest", "Checks a range of positive integer", TEST_ENABLED }; /* SDL_copysign test cases */ static const SDLTest_TestCaseReference copysignTestInf = { - (SDLTest_TestCaseFp) copysign_infCases, "copysign_infCases", + (SDLTest_TestCaseFp)copysign_infCases, "copysign_infCases", "Checks positive and negative infinity", TEST_ENABLED }; static const SDLTest_TestCaseReference copysignTestZero = { - (SDLTest_TestCaseFp) copysign_zeroCases, "copysign_zeroCases", + (SDLTest_TestCaseFp)copysign_zeroCases, "copysign_zeroCases", "Checks positive and negative zero", TEST_ENABLED }; static const SDLTest_TestCaseReference copysignTestNan = { - (SDLTest_TestCaseFp) copysign_nanCases, "copysign_nanCases", + (SDLTest_TestCaseFp)copysign_nanCases, "copysign_nanCases", "Checks NANs", TEST_ENABLED }; static const SDLTest_TestCaseReference copysignTestRange = { - (SDLTest_TestCaseFp) copysign_rangeTest, "copysign_rangeTest", + (SDLTest_TestCaseFp)copysign_rangeTest, "copysign_rangeTest", "Checks a range of positive integer", TEST_ENABLED }; /* SDL_fmod test cases */ static const SDLTest_TestCaseReference fmodTestDivOfInf = { - (SDLTest_TestCaseFp) fmod_divOfInfCases, "fmod_divOfInfCases", + (SDLTest_TestCaseFp)fmod_divOfInfCases, "fmod_divOfInfCases", "Checks division of positive and negative infinity", TEST_ENABLED }; static const SDLTest_TestCaseReference fmodTestDivByInf = { - (SDLTest_TestCaseFp) fmod_divByInfCases, "fmod_divByInfCases", + (SDLTest_TestCaseFp)fmod_divByInfCases, "fmod_divByInfCases", "Checks division by positive and negative infinity", TEST_ENABLED }; static const SDLTest_TestCaseReference fmodTestDivOfZero = { - (SDLTest_TestCaseFp) fmod_divOfZeroCases, "fmod_divOfZeroCases", + (SDLTest_TestCaseFp)fmod_divOfZeroCases, "fmod_divOfZeroCases", "Checks division of positive and negative zero", TEST_ENABLED }; static const SDLTest_TestCaseReference fmodTestDivByZero = { - (SDLTest_TestCaseFp) fmod_divByZeroCases, "fmod_divByZeroCases", + (SDLTest_TestCaseFp)fmod_divByZeroCases, "fmod_divByZeroCases", "Checks division by positive and negative zero", TEST_ENABLED }; static const SDLTest_TestCaseReference fmodTestNan = { - (SDLTest_TestCaseFp) fmod_nanCases, "fmod_nanCases", + (SDLTest_TestCaseFp)fmod_nanCases, "fmod_nanCases", "Checks NANs", TEST_ENABLED }; static const SDLTest_TestCaseReference fmodTestRegular = { - (SDLTest_TestCaseFp) fmod_regularCases, "fmod_regularCases", + (SDLTest_TestCaseFp)fmod_regularCases, "fmod_regularCases", "Checks a set of regular values", TEST_ENABLED }; static const SDLTest_TestCaseReference fmodTestRange = { - (SDLTest_TestCaseFp) fmod_rangeTest, "fmod_rangeTest", + (SDLTest_TestCaseFp)fmod_rangeTest, "fmod_rangeTest", "Checks a range of positive integer", TEST_ENABLED }; /* SDL_exp test cases */ static const SDLTest_TestCaseReference expTestInf = { - (SDLTest_TestCaseFp) exp_infCases, "exp_infCases", + (SDLTest_TestCaseFp)exp_infCases, "exp_infCases", "Checks positive and negative infinity", TEST_ENABLED }; static const SDLTest_TestCaseReference expTestZero = { - (SDLTest_TestCaseFp) exp_zeroCases, "exp_zeroCases", + (SDLTest_TestCaseFp)exp_zeroCases, "exp_zeroCases", "Checks for positive and negative zero", TEST_ENABLED }; static const SDLTest_TestCaseReference expTestOverflow = { - (SDLTest_TestCaseFp) exp_overflowCase, "exp_overflowCase", + (SDLTest_TestCaseFp)exp_overflowCase, "exp_overflowCase", "Checks for overflow", TEST_ENABLED }; static const SDLTest_TestCaseReference expTestBase = { - (SDLTest_TestCaseFp) exp_baseCase, "exp_baseCase", + (SDLTest_TestCaseFp)exp_baseCase, "exp_baseCase", "Checks the base case", TEST_ENABLED }; static const SDLTest_TestCaseReference expTestRegular = { - (SDLTest_TestCaseFp) exp_regularCases, "exp_regularCases", + (SDLTest_TestCaseFp)exp_regularCases, "exp_regularCases", "Checks a set of regular values", TEST_ENABLED }; /* SDL_log test cases */ static const SDLTest_TestCaseReference logTestLimit = { - (SDLTest_TestCaseFp) log_limitCases, "log_limitCases", + (SDLTest_TestCaseFp)log_limitCases, "log_limitCases", "Checks the domain limits", TEST_ENABLED }; static const SDLTest_TestCaseReference logTestNan = { - (SDLTest_TestCaseFp) log_nanCases, "log_nanCases", + (SDLTest_TestCaseFp)log_nanCases, "log_nanCases", "Checks NAN and negative values", TEST_ENABLED }; static const SDLTest_TestCaseReference logTestBase = { - (SDLTest_TestCaseFp) log_baseCases, "log_baseCases", + (SDLTest_TestCaseFp)log_baseCases, "log_baseCases", "Checks the base cases", TEST_ENABLED }; static const SDLTest_TestCaseReference logTestRegular = { - (SDLTest_TestCaseFp) log_regularCases, "log_regularCases", + (SDLTest_TestCaseFp)log_regularCases, "log_regularCases", "Checks a set of regular values", TEST_ENABLED }; /* SDL_log10 test cases */ static const SDLTest_TestCaseReference log10TestLimit = { - (SDLTest_TestCaseFp) log10_limitCases, "log10_limitCases", + (SDLTest_TestCaseFp)log10_limitCases, "log10_limitCases", "Checks the domain limits", TEST_ENABLED }; static const SDLTest_TestCaseReference log10TestNan = { - (SDLTest_TestCaseFp) log10_nanCases, "log10_nanCases", + (SDLTest_TestCaseFp)log10_nanCases, "log10_nanCases", "Checks NAN and negative values", TEST_ENABLED }; static const SDLTest_TestCaseReference log10TestBase = { - (SDLTest_TestCaseFp) log10_baseCases, "log10_baseCases", + (SDLTest_TestCaseFp)log10_baseCases, "log10_baseCases", "Checks the base cases", TEST_ENABLED }; static const SDLTest_TestCaseReference log10TestRegular = { - (SDLTest_TestCaseFp) log10_regularCases, "log10_regularCases", + (SDLTest_TestCaseFp)log10_regularCases, "log10_regularCases", "Checks a set of regular values", TEST_ENABLED }; /* SDL_pow test cases */ static const SDLTest_TestCaseReference powTestExpInf1 = { - (SDLTest_TestCaseFp) pow_baseNOneExpInfCases, "pow_baseNOneExpInfCases", + (SDLTest_TestCaseFp)pow_baseNOneExpInfCases, "pow_baseNOneExpInfCases", "Checks for pow(-1, +/-inf)", TEST_ENABLED }; static const SDLTest_TestCaseReference powTestExpInf2 = { - (SDLTest_TestCaseFp) pow_baseZeroExpNInfCases, "pow_baseZeroExpNInfCases", + (SDLTest_TestCaseFp)pow_baseZeroExpNInfCases, "pow_baseZeroExpNInfCases", "Checks for pow(+/-0, -inf)", TEST_ENABLED }; static const SDLTest_TestCaseReference powTestExpInf3 = { - (SDLTest_TestCaseFp) pow_expInfCases, "pow_expInfCases", + (SDLTest_TestCaseFp)pow_expInfCases, "pow_expInfCases", "Checks for pow(x, +/-inf)", TEST_ENABLED }; static const SDLTest_TestCaseReference powTestBaseInf1 = { - (SDLTest_TestCaseFp) pow_basePInfCases, "pow_basePInfCases", + (SDLTest_TestCaseFp)pow_basePInfCases, "pow_basePInfCases", "Checks for pow(inf, x)", TEST_ENABLED }; static const SDLTest_TestCaseReference powTestBaseInf2 = { - (SDLTest_TestCaseFp) pow_baseNInfCases, "pow_baseNInfCases", + (SDLTest_TestCaseFp)pow_baseNInfCases, "pow_baseNInfCases", "Checks for pow(-inf, x)", TEST_ENABLED }; static const SDLTest_TestCaseReference powTestNan1 = { - (SDLTest_TestCaseFp) pow_badOperationCase, "pow_badOperationCase", + (SDLTest_TestCaseFp)pow_badOperationCase, "pow_badOperationCase", "Checks for negative finite base and non-integer finite exponent", TEST_ENABLED }; static const SDLTest_TestCaseReference powTestNan2 = { - (SDLTest_TestCaseFp) pow_base1ExpNanCase, "pow_base1ExpNanCase", + (SDLTest_TestCaseFp)pow_base1ExpNanCase, "pow_base1ExpNanCase", "Checks for pow(1.0, NAN)", TEST_ENABLED }; static const SDLTest_TestCaseReference powTestNan3 = { - (SDLTest_TestCaseFp) pow_baseNanExp0Cases, "pow_baseNanExp0Cases", + (SDLTest_TestCaseFp)pow_baseNanExp0Cases, "pow_baseNanExp0Cases", "Checks for pow(NAN, +/-0)", TEST_ENABLED }; static const SDLTest_TestCaseReference powTestNan4 = { - (SDLTest_TestCaseFp) pow_nanArgsCases, "pow_nanArgsCases", + (SDLTest_TestCaseFp)pow_nanArgsCases, "pow_nanArgsCases", "Checks for pow(x, y) with either x or y being NAN", TEST_ENABLED }; static const SDLTest_TestCaseReference powTestZero1 = { - (SDLTest_TestCaseFp) pow_baseNZeroExpOddCases, "pow_baseNZeroExpOddCases", + (SDLTest_TestCaseFp)pow_baseNZeroExpOddCases, "pow_baseNZeroExpOddCases", "Checks for pow(-0.0, y), with y an odd integer.", TEST_ENABLED }; static const SDLTest_TestCaseReference powTestZero2 = { - (SDLTest_TestCaseFp) pow_basePZeroExpOddCases, "pow_basePZeroExpOddCases", + (SDLTest_TestCaseFp)pow_basePZeroExpOddCases, "pow_basePZeroExpOddCases", "Checks for pow(0.0, y), with y an odd integer.", TEST_ENABLED }; static const SDLTest_TestCaseReference powTestZero3 = { - (SDLTest_TestCaseFp) pow_baseNZeroCases, "pow_baseNZeroCases", + (SDLTest_TestCaseFp)pow_baseNZeroCases, "pow_baseNZeroCases", "Checks for pow(-0.0, y), with y finite and even or non-integer number", TEST_ENABLED }; static const SDLTest_TestCaseReference powTestZero4 = { - (SDLTest_TestCaseFp) pow_basePZeroCases, "pow_basePZeroCases", + (SDLTest_TestCaseFp)pow_basePZeroCases, "pow_basePZeroCases", "Checks for pow(0.0, y), with y finite and even or non-integer number", TEST_ENABLED }; static const SDLTest_TestCaseReference powTestRegular = { - (SDLTest_TestCaseFp) pow_regularCases, "pow_regularCases", + (SDLTest_TestCaseFp)pow_regularCases, "pow_regularCases", "Checks a set of regular values", TEST_ENABLED }; static const SDLTest_TestCaseReference powTestPowOf2 = { - (SDLTest_TestCaseFp) pow_powerOfTwo, "pow_powerOfTwo", + (SDLTest_TestCaseFp)pow_powerOfTwo, "pow_powerOfTwo", "Checks the powers of two from 1 to 8", TEST_ENABLED }; static const SDLTest_TestCaseReference powTestRange = { - (SDLTest_TestCaseFp) pow_rangeTest, "pow_rangeTest", + (SDLTest_TestCaseFp)pow_rangeTest, "pow_rangeTest", "Checks a range of positive integer to the power of 0", TEST_ENABLED }; /* SDL_sqrt test cases */ static const SDLTest_TestCaseReference sqrtTestInf = { - (SDLTest_TestCaseFp) sqrt_infCase, "sqrt_infCase", + (SDLTest_TestCaseFp)sqrt_infCase, "sqrt_infCase", "Checks positive infinity", TEST_ENABLED }; static const SDLTest_TestCaseReference sqrtTestNan = { - (SDLTest_TestCaseFp) sqrt_nanCase, "sqrt_nanCase", + (SDLTest_TestCaseFp)sqrt_nanCase, "sqrt_nanCase", "Checks NAN", TEST_ENABLED }; static const SDLTest_TestCaseReference sqrtTestDomain = { - (SDLTest_TestCaseFp) sqrt_outOfDomainCases, "sqrt_outOfDomainCases", + (SDLTest_TestCaseFp)sqrt_outOfDomainCases, "sqrt_outOfDomainCases", "Checks for values out of the domain", TEST_ENABLED }; static const SDLTest_TestCaseReference sqrtTestBase = { - (SDLTest_TestCaseFp) sqrt_baseCases, "sqrt_baseCases", + (SDLTest_TestCaseFp)sqrt_baseCases, "sqrt_baseCases", "Checks the base cases", TEST_ENABLED }; static const SDLTest_TestCaseReference sqrtTestRegular = { - (SDLTest_TestCaseFp) sqrt_regularCases, "sqrt_regularCases", + (SDLTest_TestCaseFp)sqrt_regularCases, "sqrt_regularCases", "Checks a set of regular values", TEST_ENABLED }; /* SDL_scalbn test cases */ static const SDLTest_TestCaseReference scalbnTestInf = { - (SDLTest_TestCaseFp) scalbn_infCases, "scalbn_infCases", + (SDLTest_TestCaseFp)scalbn_infCases, "scalbn_infCases", "Checks positive and negative infinity arg", TEST_ENABLED }; static const SDLTest_TestCaseReference scalbnTestBaseZero = { - (SDLTest_TestCaseFp) scalbn_baseZeroCases, "scalbn_baseZeroCases", + (SDLTest_TestCaseFp)scalbn_baseZeroCases, "scalbn_baseZeroCases", "Checks for positive and negative zero arg", TEST_ENABLED }; static const SDLTest_TestCaseReference scalbnTestExpZero = { - (SDLTest_TestCaseFp) scalbn_expZeroCase, "scalbn_expZeroCase", + (SDLTest_TestCaseFp)scalbn_expZeroCase, "scalbn_expZeroCase", "Checks for zero exp", TEST_ENABLED }; static const SDLTest_TestCaseReference scalbnTestNan = { - (SDLTest_TestCaseFp) scalbn_nanCase, "scalbn_nanCase", + (SDLTest_TestCaseFp)scalbn_nanCase, "scalbn_nanCase", "Checks NAN", TEST_ENABLED }; static const SDLTest_TestCaseReference scalbnTestRegular = { - (SDLTest_TestCaseFp) scalbn_regularCases, "scalbn_regularCases", + (SDLTest_TestCaseFp)scalbn_regularCases, "scalbn_regularCases", "Checks a set of regular cases", TEST_ENABLED }; /* SDL_cos test cases */ static const SDLTest_TestCaseReference cosTestInf = { - (SDLTest_TestCaseFp) cos_infCases, "cos_infCases", + (SDLTest_TestCaseFp)cos_infCases, "cos_infCases", "Checks for positive and negative infinity", TEST_ENABLED }; static const SDLTest_TestCaseReference cosTestNan = { - (SDLTest_TestCaseFp) cos_nanCase, "cos_nanCase", + (SDLTest_TestCaseFp)cos_nanCase, "cos_nanCase", "Checks NAN", TEST_ENABLED }; static const SDLTest_TestCaseReference cosTestRegular = { - (SDLTest_TestCaseFp) cos_regularCases, "cos_regularCases", + (SDLTest_TestCaseFp)cos_regularCases, "cos_regularCases", "Checks a set of regular cases", TEST_ENABLED }; static const SDLTest_TestCaseReference cosTestPrecision = { - (SDLTest_TestCaseFp) cos_precisionTest, "cos_precisionTest", + (SDLTest_TestCaseFp)cos_precisionTest, "cos_precisionTest", "Checks cosine precision", TEST_ENABLED }; static const SDLTest_TestCaseReference cosTestRange = { - (SDLTest_TestCaseFp) cos_rangeTest, "cos_rangeTest", + (SDLTest_TestCaseFp)cos_rangeTest, "cos_rangeTest", "Checks a range of positive integer", TEST_ENABLED }; /* SDL_sin test cases */ static const SDLTest_TestCaseReference sinTestInf = { - (SDLTest_TestCaseFp) sin_infCases, "sin_infCases", + (SDLTest_TestCaseFp)sin_infCases, "sin_infCases", "Checks for positive and negative infinity", TEST_ENABLED }; static const SDLTest_TestCaseReference sinTestNan = { - (SDLTest_TestCaseFp) sin_nanCase, "sin_nanCase", + (SDLTest_TestCaseFp)sin_nanCase, "sin_nanCase", "Checks NAN", TEST_ENABLED }; static const SDLTest_TestCaseReference sinTestRegular = { - (SDLTest_TestCaseFp) sin_regularCases, "sin_regularCases", + (SDLTest_TestCaseFp)sin_regularCases, "sin_regularCases", "Checks a set of regular cases", TEST_ENABLED }; static const SDLTest_TestCaseReference sinTestPrecision = { - (SDLTest_TestCaseFp) sin_precisionTest, "sin_precisionTest", + (SDLTest_TestCaseFp)sin_precisionTest, "sin_precisionTest", "Checks sine precision", TEST_ENABLED }; static const SDLTest_TestCaseReference sinTestRange = { - (SDLTest_TestCaseFp) sin_rangeTest, "sin_rangeTest", + (SDLTest_TestCaseFp)sin_rangeTest, "sin_rangeTest", "Checks a range of positive integer", TEST_ENABLED }; /* SDL_tan test cases */ static const SDLTest_TestCaseReference tanTestInf = { - (SDLTest_TestCaseFp) tan_infCases, "tan_infCases", + (SDLTest_TestCaseFp)tan_infCases, "tan_infCases", "Checks for positive and negative infinity", TEST_ENABLED }; static const SDLTest_TestCaseReference tanTestNan = { - (SDLTest_TestCaseFp) tan_nanCase, "tan_nanCase", + (SDLTest_TestCaseFp)tan_nanCase, "tan_nanCase", "Checks NAN", TEST_ENABLED }; static const SDLTest_TestCaseReference tanTestZero = { - (SDLTest_TestCaseFp) tan_zeroCases, "tan_zeroCases", + (SDLTest_TestCaseFp)tan_zeroCases, "tan_zeroCases", "Checks a set of regular cases", TEST_ENABLED }; static const SDLTest_TestCaseReference tanTestPrecision = { - (SDLTest_TestCaseFp) tan_precisionTest, "tan_precisionTest", + (SDLTest_TestCaseFp)tan_precisionTest, "tan_precisionTest", "Checks tangent precision", TEST_ENABLED }; /* SDL_acos test cases */ static const SDLTest_TestCaseReference acosTestLimit = { - (SDLTest_TestCaseFp) acos_limitCases, "acos_limitCases", + (SDLTest_TestCaseFp)acos_limitCases, "acos_limitCases", "Checks the edge of the domain (+/-1)", TEST_ENABLED }; static const SDLTest_TestCaseReference acosTestOutOfDomain = { - (SDLTest_TestCaseFp) acos_outOfDomainCases, "acos_outOfDomainCases", + (SDLTest_TestCaseFp)acos_outOfDomainCases, "acos_outOfDomainCases", "Checks values outside the domain", TEST_ENABLED }; static const SDLTest_TestCaseReference acosTestNan = { - (SDLTest_TestCaseFp) acos_nanCase, "acos_nanCase", + (SDLTest_TestCaseFp)acos_nanCase, "acos_nanCase", "Checks NAN", TEST_ENABLED }; static const SDLTest_TestCaseReference acosTestPrecision = { - (SDLTest_TestCaseFp) acos_precisionTest, "acos_precisionTest", + (SDLTest_TestCaseFp)acos_precisionTest, "acos_precisionTest", "Checks acos precision", TEST_ENABLED }; /* SDL_asin test cases */ static const SDLTest_TestCaseReference asinTestLimit = { - (SDLTest_TestCaseFp) asin_limitCases, "asin_limitCases", + (SDLTest_TestCaseFp)asin_limitCases, "asin_limitCases", "Checks the edge of the domain (+/-1)", TEST_ENABLED }; static const SDLTest_TestCaseReference asinTestOutOfDomain = { - (SDLTest_TestCaseFp) asin_outOfDomainCases, "asin_outOfDomainCases", + (SDLTest_TestCaseFp)asin_outOfDomainCases, "asin_outOfDomainCases", "Checks values outside the domain", TEST_ENABLED }; static const SDLTest_TestCaseReference asinTestNan = { - (SDLTest_TestCaseFp) asin_nanCase, "asin_nanCase", + (SDLTest_TestCaseFp)asin_nanCase, "asin_nanCase", "Checks NAN", TEST_ENABLED }; static const SDLTest_TestCaseReference asinTestPrecision = { - (SDLTest_TestCaseFp) asin_precisionTest, "asin_precisionTest", + (SDLTest_TestCaseFp)asin_precisionTest, "asin_precisionTest", "Checks asin precision", TEST_ENABLED }; /* SDL_atan test cases */ static const SDLTest_TestCaseReference atanTestLimit = { - (SDLTest_TestCaseFp) atan_limitCases, "atan_limitCases", + (SDLTest_TestCaseFp)atan_limitCases, "atan_limitCases", "Checks the edge of the domain (+/-Infinity)", TEST_ENABLED }; static const SDLTest_TestCaseReference atanTestZero = { - (SDLTest_TestCaseFp) atan_zeroCases, "atan_zeroCases", + (SDLTest_TestCaseFp)atan_zeroCases, "atan_zeroCases", "Checks for positive and negative zero", TEST_ENABLED }; static const SDLTest_TestCaseReference atanTestNan = { - (SDLTest_TestCaseFp) atan_nanCase, "atan_nanCase", + (SDLTest_TestCaseFp)atan_nanCase, "atan_nanCase", "Checks NAN", TEST_ENABLED }; static const SDLTest_TestCaseReference atanTestPrecision = { - (SDLTest_TestCaseFp) atan_precisionTest, "atan_precisionTest", + (SDLTest_TestCaseFp)atan_precisionTest, "atan_precisionTest", "Checks atan precision", TEST_ENABLED }; /* SDL_atan2 test cases */ static const SDLTest_TestCaseReference atan2TestZero1 = { - (SDLTest_TestCaseFp) atan2_bothZeroCases, "atan2_bothZeroCases", + (SDLTest_TestCaseFp)atan2_bothZeroCases, "atan2_bothZeroCases", "Checks for both arguments being zero", TEST_ENABLED }; static const SDLTest_TestCaseReference atan2TestZero2 = { - (SDLTest_TestCaseFp) atan2_yZeroCases, "atan2_yZeroCases", + (SDLTest_TestCaseFp)atan2_yZeroCases, "atan2_yZeroCases", "Checks for y=0", TEST_ENABLED }; static const SDLTest_TestCaseReference atan2TestZero3 = { - (SDLTest_TestCaseFp) atan2_xZeroCases, "atan2_xZeroCases", + (SDLTest_TestCaseFp)atan2_xZeroCases, "atan2_xZeroCases", "Checks for x=0", TEST_ENABLED }; static const SDLTest_TestCaseReference atan2TestInf1 = { - (SDLTest_TestCaseFp) atan2_bothInfCases, "atan2_bothInfCases", + (SDLTest_TestCaseFp)atan2_bothInfCases, "atan2_bothInfCases", "Checks for both arguments being infinity", TEST_ENABLED }; static const SDLTest_TestCaseReference atan2TestInf2 = { - (SDLTest_TestCaseFp) atan2_yInfCases, "atan2_yInfCases", + (SDLTest_TestCaseFp)atan2_yInfCases, "atan2_yInfCases", "Checks for y=0", TEST_ENABLED }; static const SDLTest_TestCaseReference atan2TestInf3 = { - (SDLTest_TestCaseFp) atan2_xInfCases, "atan2_xInfCases", + (SDLTest_TestCaseFp)atan2_xInfCases, "atan2_xInfCases", "Checks for x=0", TEST_ENABLED }; static const SDLTest_TestCaseReference atan2TestNan = { - (SDLTest_TestCaseFp) atan2_nanCases, "atan2_nanCases", + (SDLTest_TestCaseFp)atan2_nanCases, "atan2_nanCases", "Checks NANs", TEST_ENABLED }; static const SDLTest_TestCaseReference atan2TestQuadrantTopRight = { - (SDLTest_TestCaseFp) atan2_topRightQuadrantTest, "atan2_topRightQuadrantTest", + (SDLTest_TestCaseFp)atan2_topRightQuadrantTest, "atan2_topRightQuadrantTest", "Checks values in the top right quadrant", TEST_ENABLED }; static const SDLTest_TestCaseReference atan2TestQuadrantTopLeft = { - (SDLTest_TestCaseFp) atan2_topLeftQuadrantTest, "atan2_topLeftQuadrantTest", + (SDLTest_TestCaseFp)atan2_topLeftQuadrantTest, "atan2_topLeftQuadrantTest", "Checks values in the top left quadrant", TEST_ENABLED }; static const SDLTest_TestCaseReference atan2TestQuadrantBottomRight = { - (SDLTest_TestCaseFp) atan2_bottomRightQuadrantTest, "atan2_bottomRightQuadrantTest", + (SDLTest_TestCaseFp)atan2_bottomRightQuadrantTest, "atan2_bottomRightQuadrantTest", "Checks values in the bottom right quadrant", TEST_ENABLED }; static const SDLTest_TestCaseReference atan2TestQuadrantBottomLeft = { - (SDLTest_TestCaseFp) atan2_bottomLeftQuadrantTest, "atan2_bottomLeftQuadrantTest", + (SDLTest_TestCaseFp)atan2_bottomLeftQuadrantTest, "atan2_bottomLeftQuadrantTest", "Checks values in the bottom left quadrant", TEST_ENABLED }; diff --git a/test/testautomation_mouse.c b/test/testautomation_mouse.c index d9cd4f0bd..22a437801 100644 --- a/test/testautomation_mouse.c +++ b/test/testautomation_mouse.c @@ -15,178 +15,175 @@ /* Helper to evaluate state returned from SDL_GetMouseState */ int _mouseStateCheck(Uint32 state) { - return (state == 0) || - (state == SDL_BUTTON(SDL_BUTTON_LEFT)) || - (state == SDL_BUTTON(SDL_BUTTON_MIDDLE)) || - (state == SDL_BUTTON(SDL_BUTTON_RIGHT)) || - (state == SDL_BUTTON(SDL_BUTTON_X1)) || - (state == SDL_BUTTON(SDL_BUTTON_X2)); + return (state == 0) || + (state == SDL_BUTTON(SDL_BUTTON_LEFT)) || + (state == SDL_BUTTON(SDL_BUTTON_MIDDLE)) || + (state == SDL_BUTTON(SDL_BUTTON_RIGHT)) || + (state == SDL_BUTTON(SDL_BUTTON_X1)) || + (state == SDL_BUTTON(SDL_BUTTON_X2)); } /** * @brief Check call to SDL_GetMouseState * */ -int -mouse_getMouseState(void *arg) +int mouse_getMouseState(void *arg) { - int x; - int y; - Uint32 state; + int x; + int y; + Uint32 state; - /* Pump some events to update mouse state */ - SDL_PumpEvents(); - SDLTest_AssertPass("Call to SDL_PumpEvents()"); + /* Pump some events to update mouse state */ + SDL_PumpEvents(); + SDLTest_AssertPass("Call to SDL_PumpEvents()"); - /* Case where x, y pointer is NULL */ - state = SDL_GetMouseState(NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetMouseState(NULL, NULL)"); - SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); + /* Case where x, y pointer is NULL */ + state = SDL_GetMouseState(NULL, NULL); + SDLTest_AssertPass("Call to SDL_GetMouseState(NULL, NULL)"); + SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); - /* Case where x pointer is not NULL */ - x = INT_MIN; - state = SDL_GetMouseState(&x, NULL); - SDLTest_AssertPass("Call to SDL_GetMouseState(&x, NULL)"); - SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x); - SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); + /* Case where x pointer is not NULL */ + x = INT_MIN; + state = SDL_GetMouseState(&x, NULL); + SDLTest_AssertPass("Call to SDL_GetMouseState(&x, NULL)"); + SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x); + SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); - /* Case where y pointer is not NULL */ - y = INT_MIN; - state = SDL_GetMouseState(NULL, &y); - SDLTest_AssertPass("Call to SDL_GetMouseState(NULL, &y)"); - SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y); - SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); + /* Case where y pointer is not NULL */ + y = INT_MIN; + state = SDL_GetMouseState(NULL, &y); + SDLTest_AssertPass("Call to SDL_GetMouseState(NULL, &y)"); + SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y); + SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); - /* Case where x and y pointer is not NULL */ - x = INT_MIN; - y = INT_MIN; - state = SDL_GetMouseState(&x, &y); - SDLTest_AssertPass("Call to SDL_GetMouseState(&x, &y)"); - SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x); - SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y); - SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); + /* Case where x and y pointer is not NULL */ + x = INT_MIN; + y = INT_MIN; + state = SDL_GetMouseState(&x, &y); + SDLTest_AssertPass("Call to SDL_GetMouseState(&x, &y)"); + SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x); + SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y); + SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Check call to SDL_GetRelativeMouseState * */ -int -mouse_getRelativeMouseState(void *arg) +int mouse_getRelativeMouseState(void *arg) { - int x; - int y; - Uint32 state; + int x; + int y; + Uint32 state; - /* Pump some events to update mouse state */ - SDL_PumpEvents(); - SDLTest_AssertPass("Call to SDL_PumpEvents()"); + /* Pump some events to update mouse state */ + SDL_PumpEvents(); + SDLTest_AssertPass("Call to SDL_PumpEvents()"); - /* Case where x, y pointer is NULL */ - state = SDL_GetRelativeMouseState(NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(NULL, NULL)"); - SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); + /* Case where x, y pointer is NULL */ + state = SDL_GetRelativeMouseState(NULL, NULL); + SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(NULL, NULL)"); + SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); - /* Case where x pointer is not NULL */ - x = INT_MIN; - state = SDL_GetRelativeMouseState(&x, NULL); - SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(&x, NULL)"); - SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x); - SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); + /* Case where x pointer is not NULL */ + x = INT_MIN; + state = SDL_GetRelativeMouseState(&x, NULL); + SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(&x, NULL)"); + SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x); + SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); - /* Case where y pointer is not NULL */ - y = INT_MIN; - state = SDL_GetRelativeMouseState(NULL, &y); - SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(NULL, &y)"); - SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y); - SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); + /* Case where y pointer is not NULL */ + y = INT_MIN; + state = SDL_GetRelativeMouseState(NULL, &y); + SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(NULL, &y)"); + SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y); + SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); - /* Case where x and y pointer is not NULL */ - x = INT_MIN; - y = INT_MIN; - state = SDL_GetRelativeMouseState(&x, &y); - SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(&x, &y)"); - SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x); - SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y); - SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); + /* Case where x and y pointer is not NULL */ + x = INT_MIN; + y = INT_MIN; + state = SDL_GetRelativeMouseState(&x, &y); + SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(&x, &y)"); + SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x); + SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y); + SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %" SDL_PRIu32, state); - return TEST_COMPLETED; + return TEST_COMPLETED; } - /* XPM definition of mouse Cursor */ static const char *_mouseArrowData[] = { - /* pixels */ - "X ", - "XX ", - "X.X ", - "X..X ", - "X...X ", - "X....X ", - "X.....X ", - "X......X ", - "X.......X ", - "X........X ", - "X.....XXXXX ", - "X..X..X ", - "X.X X..X ", - "XX X..X ", - "X X..X ", - " X..X ", - " X..X ", - " X..X ", - " XX ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " " + /* pixels */ + "X ", + "XX ", + "X.X ", + "X..X ", + "X...X ", + "X....X ", + "X.....X ", + "X......X ", + "X.......X ", + "X........X ", + "X.....XXXXX ", + "X..X..X ", + "X.X X..X ", + "XX X..X ", + "X X..X ", + " X..X ", + " X..X ", + " X..X ", + " XX ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }; /* Helper that creates a new mouse cursor from an XPM */ static SDL_Cursor *_initArrowCursor(const char *image[]) { - SDL_Cursor *cursor; - int i, row, col; - Uint8 data[4*32]; - Uint8 mask[4*32]; + SDL_Cursor *cursor; + int i, row, col; + Uint8 data[4 * 32]; + Uint8 mask[4 * 32]; - i = -1; - for ( row=0; row<32; ++row ) { - for ( col=0; col<32; ++col ) { - if ( col % 8 ) { - data[i] <<= 1; - mask[i] <<= 1; - } else { - ++i; - data[i] = mask[i] = 0; - } - switch (image[row][col]) { - case 'X': - data[i] |= 0x01; - mask[i] |= 0x01; - break; - case '.': - mask[i] |= 0x01; - break; - case ' ': - break; - } + i = -1; + for (row = 0; row < 32; ++row) { + for (col = 0; col < 32; ++col) { + if (col % 8) { + data[i] <<= 1; + mask[i] <<= 1; + } else { + ++i; + data[i] = mask[i] = 0; + } + switch (image[row][col]) { + case 'X': + data[i] |= 0x01; + mask[i] |= 0x01; + break; + case '.': + mask[i] |= 0x01; + break; + case ' ': + break; + } + } } - } - cursor = SDL_CreateCursor(data, mask, 32, 32, 0, 0); - return cursor; + cursor = SDL_CreateCursor(data, mask, 32, 32, 0, 0); + return cursor; } /** @@ -195,15 +192,14 @@ static SDL_Cursor *_initArrowCursor(const char *image[]) * @sa http://wiki.libsdl.org/SDL_CreateCursor * @sa http://wiki.libsdl.org/SDL_FreeCursor */ -int -mouse_createFreeCursor(void *arg) +int mouse_createFreeCursor(void *arg) { SDL_Cursor *cursor; /* Create a cursor */ cursor = _initArrowCursor(_mouseArrowData); - SDLTest_AssertPass("Call to SDL_CreateCursor()"); - SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL"); + SDLTest_AssertPass("Call to SDL_CreateCursor()"); + SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL"); if (cursor == NULL) { return TEST_ABORTED; } @@ -221,8 +217,7 @@ mouse_createFreeCursor(void *arg) * @sa http://wiki.libsdl.org/SDL_CreateColorCursor * @sa http://wiki.libsdl.org/SDL_FreeCursor */ -int -mouse_createFreeColorCursor(void *arg) +int mouse_createFreeColorCursor(void *arg) { SDL_Surface *face; SDL_Cursor *cursor; @@ -236,8 +231,8 @@ mouse_createFreeColorCursor(void *arg) /* Create a color cursor from surface */ cursor = SDL_CreateColorCursor(face, 0, 0); - SDLTest_AssertPass("Call to SDL_CreateColorCursor()"); - SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateColorCursor() is not NULL"); + SDLTest_AssertPass("Call to SDL_CreateColorCursor()"); + SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateColorCursor() is not NULL"); if (cursor == NULL) { SDL_FreeSurface(face); return TEST_ABORTED; @@ -260,18 +255,18 @@ void _changeCursorVisibility(int state) int newState; int result; - oldState = SDL_ShowCursor(SDL_QUERY); + oldState = SDL_ShowCursor(SDL_QUERY); SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)"); - result = SDL_ShowCursor(state); + result = SDL_ShowCursor(state); SDLTest_AssertPass("Call to SDL_ShowCursor(%s)", (state == SDL_ENABLE) ? "SDL_ENABLE" : "SDL_DISABLE"); SDLTest_AssertCheck(result == oldState, "Validate result from SDL_ShowCursor(%s), expected: %i, got: %i", - (state == SDL_ENABLE) ? "SDL_ENABLE" : "SDL_DISABLE", oldState, result); + (state == SDL_ENABLE) ? "SDL_ENABLE" : "SDL_DISABLE", oldState, result); newState = SDL_ShowCursor(SDL_QUERY); SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)"); SDLTest_AssertCheck(state == newState, "Validate new state, expected: %i, got: %i", - state, newState); + state, newState); } /** @@ -279,8 +274,7 @@ void _changeCursorVisibility(int state) * * @sa http://wiki.libsdl.org/SDL_ShowCursor */ -int -mouse_showCursor(void *arg) +int mouse_showCursor(void *arg) { int currentState; @@ -288,7 +282,7 @@ mouse_showCursor(void *arg) currentState = SDL_ShowCursor(SDL_QUERY); SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)"); SDLTest_AssertCheck(currentState == SDL_DISABLE || currentState == SDL_ENABLE, - "Validate result is %i or %i, got: %i", SDL_DISABLE, SDL_ENABLE, currentState); + "Validate result is %i or %i, got: %i", SDL_DISABLE, SDL_ENABLE, currentState); if (currentState == SDL_DISABLE) { /* Show the cursor, then hide it again */ _changeCursorVisibility(SDL_ENABLE); @@ -309,15 +303,14 @@ mouse_showCursor(void *arg) * * @sa http://wiki.libsdl.org/SDL_SetCursor */ -int -mouse_setCursor(void *arg) +int mouse_setCursor(void *arg) { SDL_Cursor *cursor; /* Create a cursor */ cursor = _initArrowCursor(_mouseArrowData); - SDLTest_AssertPass("Call to SDL_CreateCursor()"); - SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL"); + SDLTest_AssertPass("Call to SDL_CreateCursor()"); + SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL"); if (cursor == NULL) { return TEST_ABORTED; } @@ -342,15 +335,14 @@ mouse_setCursor(void *arg) * * @sa http://wiki.libsdl.org/SDL_GetCursor */ -int -mouse_getCursor(void *arg) +int mouse_getCursor(void *arg) { SDL_Cursor *cursor; /* Get current cursor */ cursor = SDL_GetCursor(); - SDLTest_AssertPass("Call to SDL_GetCursor()"); - SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_GetCursor() is not NULL"); + SDLTest_AssertPass("Call to SDL_GetCursor()"); + SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_GetCursor() is not NULL"); return TEST_COMPLETED; } @@ -361,52 +353,51 @@ mouse_getCursor(void *arg) * @sa http://wiki.libsdl.org/SDL_GetRelativeMouseMode * @sa http://wiki.libsdl.org/SDL_SetRelativeMouseMode */ -int -mouse_getSetRelativeMouseMode(void *arg) +int mouse_getSetRelativeMouseMode(void *arg) { int result; - int i; + int i; SDL_bool initialState; SDL_bool currentState; /* Capture original state so we can revert back to it later */ initialState = SDL_GetRelativeMouseMode(); - SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()"); + SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()"); - /* Repeat twice to check D->D transition */ - for (i=0; i<2; i++) { - /* Disable - should always be supported */ - result = SDL_SetRelativeMouseMode(SDL_FALSE); - SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(FALSE)"); - SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result); - currentState = SDL_GetRelativeMouseMode(); - SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()"); - SDLTest_AssertCheck(currentState == SDL_FALSE, "Validate current state is FALSE, got: %i", currentState); - } - - /* Repeat twice to check D->E->E transition */ - for (i=0; i<2; i++) { - /* Enable - may not be supported */ - result = SDL_SetRelativeMouseMode(SDL_TRUE); - SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(TRUE)"); - if (result != -1) { - SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result); - currentState = SDL_GetRelativeMouseMode(); - SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()"); - SDLTest_AssertCheck(currentState == SDL_TRUE, "Validate current state is TRUE, got: %i", currentState); - } - } - - /* Disable to check E->D transition */ + /* Repeat twice to check D->D transition */ + for (i = 0; i < 2; i++) { + /* Disable - should always be supported */ result = SDL_SetRelativeMouseMode(SDL_FALSE); SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(FALSE)"); SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result); - currentState = SDL_GetRelativeMouseMode(); + currentState = SDL_GetRelativeMouseMode(); SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()"); SDLTest_AssertCheck(currentState == SDL_FALSE, "Validate current state is FALSE, got: %i", currentState); + } - /* Revert to original state - ignore result */ - result = SDL_SetRelativeMouseMode(initialState); + /* Repeat twice to check D->E->E transition */ + for (i = 0; i < 2; i++) { + /* Enable - may not be supported */ + result = SDL_SetRelativeMouseMode(SDL_TRUE); + SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(TRUE)"); + if (result != -1) { + SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result); + currentState = SDL_GetRelativeMouseMode(); + SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()"); + SDLTest_AssertCheck(currentState == SDL_TRUE, "Validate current state is TRUE, got: %i", currentState); + } + } + + /* Disable to check E->D transition */ + result = SDL_SetRelativeMouseMode(SDL_FALSE); + SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(FALSE)"); + SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result); + currentState = SDL_GetRelativeMouseMode(); + SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()"); + SDLTest_AssertCheck(currentState == SDL_FALSE, "Validate current state is FALSE, got: %i", currentState); + + /* Revert to original state - ignore result */ + result = SDL_SetRelativeMouseMode(initialState); return TEST_COMPLETED; } @@ -419,12 +410,12 @@ mouse_getSetRelativeMouseMode(void *arg) */ SDL_Window *_createMouseSuiteTestWindow() { - int posX = 100, posY = 100, width = MOUSE_TESTWINDOW_WIDTH, height = MOUSE_TESTWINDOW_HEIGHT; - SDL_Window *window; - window = SDL_CreateWindow("mouse_createMouseSuiteTestWindow", posX, posY, width, height, 0); - SDLTest_AssertPass("SDL_CreateWindow()"); - SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result"); - return window; + int posX = 100, posY = 100, width = MOUSE_TESTWINDOW_WIDTH, height = MOUSE_TESTWINDOW_HEIGHT; + SDL_Window *window; + window = SDL_CreateWindow("mouse_createMouseSuiteTestWindow", posX, posY, width, height, 0); + SDLTest_AssertPass("SDL_CreateWindow()"); + SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result"); + return window; } /* @@ -432,11 +423,11 @@ SDL_Window *_createMouseSuiteTestWindow() */ void _destroyMouseSuiteTestWindow(SDL_Window *window) { - if (window != NULL) { - SDL_DestroyWindow(window); - window = NULL; - SDLTest_AssertPass("SDL_DestroyWindow()"); - } + if (window != NULL) { + SDL_DestroyWindow(window); + window = NULL; + SDLTest_AssertPass("SDL_DestroyWindow()"); + } } /** @@ -444,8 +435,7 @@ void _destroyMouseSuiteTestWindow(SDL_Window *window) * * @sa http://wiki.libsdl.org/SDL_WarpMouseInWindow */ -int -mouse_warpMouseInWindow(void *arg) +int mouse_warpMouseInWindow(void *arg) { const int w = MOUSE_TESTWINDOW_WIDTH, h = MOUSE_TESTWINDOW_HEIGHT; int numPositions = 6; @@ -457,47 +447,46 @@ mouse_warpMouseInWindow(void *arg) xPositions[0] = -1; xPositions[1] = 0; xPositions[2] = 1; - xPositions[3] = w-1; + xPositions[3] = w - 1; xPositions[4] = w; - xPositions[5] = w+1; + xPositions[5] = w + 1; yPositions[0] = -1; yPositions[1] = 0; yPositions[2] = 1; - yPositions[3] = h-1; + yPositions[3] = h - 1; yPositions[4] = h; - yPositions[5] = h+1; + yPositions[5] = h + 1; /* Create test window */ window = _createMouseSuiteTestWindow(); if (window == NULL) { - return TEST_ABORTED; + return TEST_ABORTED; } /* Mouse to random position inside window */ - x = SDLTest_RandomIntegerInRange(1, w-1); - y = SDLTest_RandomIntegerInRange(1, h-1); + x = SDLTest_RandomIntegerInRange(1, w - 1); + y = SDLTest_RandomIntegerInRange(1, h - 1); SDL_WarpMouseInWindow(window, x, y); SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y); - /* Same position again */ + /* Same position again */ SDL_WarpMouseInWindow(window, x, y); SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y); /* Mouse to various boundary positions */ - for (i=0; iformat == format, "Verify value of result.format; expected: %" SDL_PRIu32 ", got %" SDL_PRIu32, format, result->format); - SDLTest_AssertCheck(result->BitsPerPixel == 0, "Verify value of result.BitsPerPixel; expected: 0, got %u", result->BitsPerPixel); - SDLTest_AssertCheck(result->BytesPerPixel == 0, "Verify value of result.BytesPerPixel; expected: 0, got %u", result->BytesPerPixel); - masks = result->Rmask | result->Gmask | result->Bmask | result->Amask; - SDLTest_AssertCheck(masks == 0, "Verify value of result.[RGBA]mask combined; expected: 0, got %" SDL_PRIu32, masks); - - /* Deallocate again */ - SDL_FreeFormat(result); - SDLTest_AssertPass("Call to SDL_FreeFormat()"); - } - - /* RGB formats */ - for (i = 0; i < _numRGBPixelFormats; i++) { - format = _RGBPixelFormats[i]; - SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", _RGBPixelFormatsVerbose[i], format); + /* Blank/unknown format */ + format = 0; + SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", unknownFormat, format); /* Allocate format */ result = SDL_AllocFormat(format); SDLTest_AssertPass("Call to SDL_AllocFormat()"); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); if (result != NULL) { - SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %" SDL_PRIu32 ", got %" SDL_PRIu32, format, result->format); - SDLTest_AssertCheck(result->BitsPerPixel > 0, "Verify value of result.BitsPerPixel; expected: >0, got %u", result->BitsPerPixel); - SDLTest_AssertCheck(result->BytesPerPixel > 0, "Verify value of result.BytesPerPixel; expected: >0, got %u", result->BytesPerPixel); - if (result->palette != NULL) { - masks = result->Rmask | result->Gmask | result->Bmask | result->Amask; - SDLTest_AssertCheck(masks > 0, "Verify value of result.[RGBA]mask combined; expected: >0, got %" SDL_PRIu32, masks); - } + SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %" SDL_PRIu32 ", got %" SDL_PRIu32, format, result->format); + SDLTest_AssertCheck(result->BitsPerPixel == 0, "Verify value of result.BitsPerPixel; expected: 0, got %u", result->BitsPerPixel); + SDLTest_AssertCheck(result->BytesPerPixel == 0, "Verify value of result.BytesPerPixel; expected: 0, got %u", result->BytesPerPixel); + masks = result->Rmask | result->Gmask | result->Bmask | result->Amask; + SDLTest_AssertCheck(masks == 0, "Verify value of result.[RGBA]mask combined; expected: 0, got %" SDL_PRIu32, masks); - /* Deallocate again */ - SDL_FreeFormat(result); - SDLTest_AssertPass("Call to SDL_FreeFormat()"); + /* Deallocate again */ + SDL_FreeFormat(result); + SDLTest_AssertPass("Call to SDL_FreeFormat()"); } - } - /* Non-RGB formats */ - for (i = 0; i < _numNonRGBPixelFormats; i++) { - format = _nonRGBPixelFormats[i]; - SDLTest_Log("non-RGB Format: %s (%" SDL_PRIu32 ")", _nonRGBPixelFormatsVerbose[i], format); + /* RGB formats */ + for (i = 0; i < _numRGBPixelFormats; i++) { + format = _RGBPixelFormats[i]; + SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", _RGBPixelFormatsVerbose[i], format); - /* Try to allocate format */ - result = SDL_AllocFormat(format); - SDLTest_AssertPass("Call to SDL_AllocFormat()"); - SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); - } + /* Allocate format */ + result = SDL_AllocFormat(format); + SDLTest_AssertPass("Call to SDL_AllocFormat()"); + SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); + if (result != NULL) { + SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %" SDL_PRIu32 ", got %" SDL_PRIu32, format, result->format); + SDLTest_AssertCheck(result->BitsPerPixel > 0, "Verify value of result.BitsPerPixel; expected: >0, got %u", result->BitsPerPixel); + SDLTest_AssertCheck(result->BytesPerPixel > 0, "Verify value of result.BytesPerPixel; expected: >0, got %u", result->BytesPerPixel); + if (result->palette != NULL) { + masks = result->Rmask | result->Gmask | result->Bmask | result->Amask; + SDLTest_AssertCheck(masks > 0, "Verify value of result.[RGBA]mask combined; expected: >0, got %" SDL_PRIu32, masks); + } - /* Negative cases */ + /* Deallocate again */ + SDL_FreeFormat(result); + SDLTest_AssertPass("Call to SDL_FreeFormat()"); + } + } - /* Invalid Formats */ - for (i = 0; i < _numInvalidPixelFormats; i++) { + /* Non-RGB formats */ + for (i = 0; i < _numNonRGBPixelFormats; i++) { + format = _nonRGBPixelFormats[i]; + SDLTest_Log("non-RGB Format: %s (%" SDL_PRIu32 ")", _nonRGBPixelFormatsVerbose[i], format); + + /* Try to allocate format */ + result = SDL_AllocFormat(format); + SDLTest_AssertPass("Call to SDL_AllocFormat()"); + SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); + } + + /* Negative cases */ + + /* Invalid Formats */ + for (i = 0; i < _numInvalidPixelFormats; i++) { + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); + format = _invalidPixelFormats[i]; + result = SDL_AllocFormat(format); + SDLTest_AssertPass("Call to SDL_AllocFormat(%" SDL_PRIu32 ")", format); + SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); + error = SDL_GetError(); + SDLTest_AssertPass("Call to SDL_GetError()"); + SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); + if (error != NULL) { + SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, + "Validate error message, expected: '%s', got: '%s'", expectedError, error); + } + } + + /* Invalid free pointer */ SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); - format = _invalidPixelFormats[i]; - result = SDL_AllocFormat(format); - SDLTest_AssertPass("Call to SDL_AllocFormat(%" SDL_PRIu32 ")", format); - SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); + SDL_FreeFormat(NULL); + SDLTest_AssertPass("Call to SDL_FreeFormat(NULL)"); error = SDL_GetError(); SDLTest_AssertPass("Call to SDL_GetError()"); SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError, error); + SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, + "Validate error message, expected: '%s', got: '%s'", expectedError, error); } - } - /* Invalid free pointer */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - SDL_FreeFormat(NULL); - SDLTest_AssertPass("Call to SDL_FreeFormat(NULL)"); - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError, error); - } - - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -230,83 +223,82 @@ pixels_allocFreeFormat(void *arg) * * @sa http://wiki.libsdl.org/SDL_GetPixelFormatName */ -int -pixels_getPixelFormatName(void *arg) +int pixels_getPixelFormatName(void *arg) { - const char *unknownFormat = "SDL_PIXELFORMAT_UNKNOWN"; - const char *error; - int i; - Uint32 format; - const char *result; + const char *unknownFormat = "SDL_PIXELFORMAT_UNKNOWN"; + const char *error; + int i; + Uint32 format; + const char *result; - /* Blank/undefined format */ - format = 0; - SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", unknownFormat, format); - - /* Get name of format */ - result = SDL_GetPixelFormatName(format); - SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); - SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); - if (result != NULL) { - SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty"); - SDLTest_AssertCheck(SDL_strcmp(result, unknownFormat) == 0, - "Verify result text; expected: %s, got %s", unknownFormat, result); - } - - /* RGB formats */ - for (i = 0; i < _numRGBPixelFormats; i++) { - format = _RGBPixelFormats[i]; - SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", _RGBPixelFormatsVerbose[i], format); + /* Blank/undefined format */ + format = 0; + SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", unknownFormat, format); /* Get name of format */ result = SDL_GetPixelFormatName(format); SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); if (result != NULL) { - SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty"); - SDLTest_AssertCheck(SDL_strcmp(result, _RGBPixelFormatsVerbose[i]) == 0, - "Verify result text; expected: %s, got %s", _RGBPixelFormatsVerbose[i], result); + SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty"); + SDLTest_AssertCheck(SDL_strcmp(result, unknownFormat) == 0, + "Verify result text; expected: %s, got %s", unknownFormat, result); } - } - /* Non-RGB formats */ - for (i = 0; i < _numNonRGBPixelFormats; i++) { - format = _nonRGBPixelFormats[i]; - SDLTest_Log("non-RGB Format: %s (%" SDL_PRIu32 ")", _nonRGBPixelFormatsVerbose[i], format); + /* RGB formats */ + for (i = 0; i < _numRGBPixelFormats; i++) { + format = _RGBPixelFormats[i]; + SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", _RGBPixelFormatsVerbose[i], format); - /* Get name of format */ - result = SDL_GetPixelFormatName(format); - SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); - SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); - if (result != NULL) { - SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty"); - SDLTest_AssertCheck(SDL_strcmp(result, _nonRGBPixelFormatsVerbose[i]) == 0, - "Verify result text; expected: %s, got %s", _nonRGBPixelFormatsVerbose[i], result); + /* Get name of format */ + result = SDL_GetPixelFormatName(format); + SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); + SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); + if (result != NULL) { + SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty"); + SDLTest_AssertCheck(SDL_strcmp(result, _RGBPixelFormatsVerbose[i]) == 0, + "Verify result text; expected: %s, got %s", _RGBPixelFormatsVerbose[i], result); + } } - } - /* Negative cases */ + /* Non-RGB formats */ + for (i = 0; i < _numNonRGBPixelFormats; i++) { + format = _nonRGBPixelFormats[i]; + SDLTest_Log("non-RGB Format: %s (%" SDL_PRIu32 ")", _nonRGBPixelFormatsVerbose[i], format); - /* Invalid Formats */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - for (i = 0; i < _numInvalidPixelFormats; i++) { - format = _invalidPixelFormats[i]; - result = SDL_GetPixelFormatName(format); - SDLTest_AssertPass("Call to SDL_GetPixelFormatName(%" SDL_PRIu32 ")", format); - SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); - if (result != NULL) { - SDLTest_AssertCheck(result[0] != '\0', - "Verify result is non-empty; got: %s", result); - SDLTest_AssertCheck(SDL_strcmp(result, _invalidPixelFormatsVerbose[i]) == 0, - "Validate name is UNKNOWN, expected: '%s', got: '%s'", _invalidPixelFormatsVerbose[i], result); + /* Get name of format */ + result = SDL_GetPixelFormatName(format); + SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); + SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); + if (result != NULL) { + SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty"); + SDLTest_AssertCheck(SDL_strcmp(result, _nonRGBPixelFormatsVerbose[i]) == 0, + "Verify result text; expected: %s, got %s", _nonRGBPixelFormatsVerbose[i], result); + } } - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error == NULL || error[0] == '\0', "Validate that error message is empty"); - } - return TEST_COMPLETED; + /* Negative cases */ + + /* Invalid Formats */ + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); + for (i = 0; i < _numInvalidPixelFormats; i++) { + format = _invalidPixelFormats[i]; + result = SDL_GetPixelFormatName(format); + SDLTest_AssertPass("Call to SDL_GetPixelFormatName(%" SDL_PRIu32 ")", format); + SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); + if (result != NULL) { + SDLTest_AssertCheck(result[0] != '\0', + "Verify result is non-empty; got: %s", result); + SDLTest_AssertCheck(SDL_strcmp(result, _invalidPixelFormatsVerbose[i]) == 0, + "Validate name is UNKNOWN, expected: '%s', got: '%s'", _invalidPixelFormatsVerbose[i], result); + } + error = SDL_GetError(); + SDLTest_AssertPass("Call to SDL_GetError()"); + SDLTest_AssertCheck(error == NULL || error[0] == '\0', "Validate that error message is empty"); + } + + return TEST_COMPLETED; } /** @@ -315,89 +307,88 @@ pixels_getPixelFormatName(void *arg) * @sa http://wiki.libsdl.org/SDL_AllocPalette * @sa http://wiki.libsdl.org/SDL_FreePalette */ -int -pixels_allocFreePalette(void *arg) +int pixels_allocFreePalette(void *arg) { - const char *expectedError1 = "Parameter 'ncolors' is invalid"; - const char *expectedError2 = "Parameter 'palette' is invalid"; - const char *error; - int variation; - int i; - int ncolors; - SDL_Palette* result; + const char *expectedError1 = "Parameter 'ncolors' is invalid"; + const char *expectedError2 = "Parameter 'palette' is invalid"; + const char *error; + int variation; + int i; + int ncolors; + SDL_Palette *result; - /* Allocate palette */ - for (variation = 1; variation <= 3; variation++) { - switch (variation) { - /* Just one color */ - default: - case 1: - ncolors = 1; - break; - /* Two colors */ - case 2: - ncolors = 2; - break; - /* More than two colors */ - case 3: - ncolors = SDLTest_RandomIntegerInRange(8, 16); - break; + /* Allocate palette */ + for (variation = 1; variation <= 3; variation++) { + switch (variation) { + /* Just one color */ + default: + case 1: + ncolors = 1; + break; + /* Two colors */ + case 2: + ncolors = 2; + break; + /* More than two colors */ + case 3: + ncolors = SDLTest_RandomIntegerInRange(8, 16); + break; + } + + result = SDL_AllocPalette(ncolors); + SDLTest_AssertPass("Call to SDL_AllocPalette(%d)", ncolors); + SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); + if (result != NULL) { + SDLTest_AssertCheck(result->ncolors == ncolors, "Verify value of result.ncolors; expected: %u, got %u", ncolors, result->ncolors); + if (result->ncolors > 0) { + SDLTest_AssertCheck(result->colors != NULL, "Verify value of result.colors is not NULL"); + if (result->colors != NULL) { + for (i = 0; i < result->ncolors; i++) { + SDLTest_AssertCheck(result->colors[i].r == 255, "Verify value of result.colors[%d].r; expected: 255, got %u", i, result->colors[i].r); + SDLTest_AssertCheck(result->colors[i].g == 255, "Verify value of result.colors[%d].g; expected: 255, got %u", i, result->colors[i].g); + SDLTest_AssertCheck(result->colors[i].b == 255, "Verify value of result.colors[%d].b; expected: 255, got %u", i, result->colors[i].b); + } + } + } + + /* Deallocate again */ + SDL_FreePalette(result); + SDLTest_AssertPass("Call to SDL_FreePalette()"); + } } - result = SDL_AllocPalette(ncolors); - SDLTest_AssertPass("Call to SDL_AllocPalette(%d)", ncolors); - SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); - if (result != NULL) { - SDLTest_AssertCheck(result->ncolors == ncolors, "Verify value of result.ncolors; expected: %u, got %u", ncolors, result->ncolors); - if (result->ncolors > 0) { - SDLTest_AssertCheck(result->colors != NULL, "Verify value of result.colors is not NULL"); - if (result->colors != NULL) { - for (i = 0; i < result->ncolors; i++) { - SDLTest_AssertCheck(result->colors[i].r == 255, "Verify value of result.colors[%d].r; expected: 255, got %u", i, result->colors[i].r); - SDLTest_AssertCheck(result->colors[i].g == 255, "Verify value of result.colors[%d].g; expected: 255, got %u", i, result->colors[i].g); - SDLTest_AssertCheck(result->colors[i].b == 255, "Verify value of result.colors[%d].b; expected: 255, got %u", i, result->colors[i].b); - } - } - } + /* Negative cases */ - /* Deallocate again */ - SDL_FreePalette(result); - SDLTest_AssertPass("Call to SDL_FreePalette()"); + /* Invalid number of colors */ + for (ncolors = 0; ncolors > -3; ncolors--) { + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); + result = SDL_AllocPalette(ncolors); + SDLTest_AssertPass("Call to SDL_AllocPalette(%d)", ncolors); + SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); + error = SDL_GetError(); + SDLTest_AssertPass("Call to SDL_GetError()"); + SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); + if (error != NULL) { + SDLTest_AssertCheck(SDL_strcmp(error, expectedError1) == 0, + "Validate error message, expected: '%s', got: '%s'", expectedError1, error); + } } - } - /* Negative cases */ - - /* Invalid number of colors */ - for (ncolors = 0; ncolors > -3; ncolors--) { + /* Invalid free pointer */ SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); - result = SDL_AllocPalette(ncolors); - SDLTest_AssertPass("Call to SDL_AllocPalette(%d)", ncolors); - SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); + SDL_FreePalette(NULL); + SDLTest_AssertPass("Call to SDL_FreePalette(NULL)"); error = SDL_GetError(); SDLTest_AssertPass("Call to SDL_GetError()"); SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError1) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError1, error); + SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 0, + "Validate error message, expected: '%s', got: '%s'", expectedError2, error); } - } - /* Invalid free pointer */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - SDL_FreePalette(NULL); - SDLTest_AssertPass("Call to SDL_FreePalette(NULL)"); - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError2, error); - } - - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -507,11 +498,13 @@ pixels_calcGammaRamp(void *arg) /* ================= Test References ================== */ /* Pixels test cases */ -static const SDLTest_TestCaseReference pixelsTest1 = - { (SDLTest_TestCaseFp)pixels_allocFreeFormat, "pixels_allocFreeFormat", "Call to SDL_AllocFormat and SDL_FreeFormat", TEST_ENABLED }; +static const SDLTest_TestCaseReference pixelsTest1 = { + (SDLTest_TestCaseFp)pixels_allocFreeFormat, "pixels_allocFreeFormat", "Call to SDL_AllocFormat and SDL_FreeFormat", TEST_ENABLED +}; -static const SDLTest_TestCaseReference pixelsTest2 = - { (SDLTest_TestCaseFp)pixels_allocFreePalette, "pixels_allocFreePalette", "Call to SDL_AllocPalette and SDL_FreePalette", TEST_ENABLED }; +static const SDLTest_TestCaseReference pixelsTest2 = { + (SDLTest_TestCaseFp)pixels_allocFreePalette, "pixels_allocFreePalette", "Call to SDL_AllocPalette and SDL_FreePalette", TEST_ENABLED +}; static const SDLTest_TestCaseReference pixelsTest3 = { (SDLTest_TestCaseFp)pixels_calcGammaRamp, "pixels_calcGammaRamp", "Call to SDL_CalculateGammaRamp", TEST_ENABLED }; diff --git a/test/testautomation_platform.c b/test/testautomation_platform.c index 466ee5df7..3ffc6cdbb 100644 --- a/test/testautomation_platform.c +++ b/test/testautomation_platform.c @@ -19,7 +19,7 @@ * compare them directly, so we push it through a function to keep the * compiler quiet. --ryan. */ -static int _compareSizeOfType( size_t sizeoftype, size_t hardcodetype ) +static int _compareSizeOfType(size_t sizeoftype, size_t hardcodetype) { return sizeoftype != hardcodetype; } @@ -31,21 +31,21 @@ static int _compareSizeOfType( size_t sizeoftype, size_t hardcodetype ) */ int platform_testTypes(void *arg) { - int ret; + int ret; - ret = _compareSizeOfType( sizeof(Uint8), 1 ); - SDLTest_AssertCheck( ret == 0, "sizeof(Uint8) = %lu, expected 1", (unsigned long)sizeof(Uint8) ); + ret = _compareSizeOfType(sizeof(Uint8), 1); + SDLTest_AssertCheck(ret == 0, "sizeof(Uint8) = %lu, expected 1", (unsigned long)sizeof(Uint8)); - ret = _compareSizeOfType( sizeof(Uint16), 2 ); - SDLTest_AssertCheck( ret == 0, "sizeof(Uint16) = %lu, expected 2", (unsigned long)sizeof(Uint16) ); + ret = _compareSizeOfType(sizeof(Uint16), 2); + SDLTest_AssertCheck(ret == 0, "sizeof(Uint16) = %lu, expected 2", (unsigned long)sizeof(Uint16)); - ret = _compareSizeOfType( sizeof(Uint32), 4 ); - SDLTest_AssertCheck( ret == 0, "sizeof(Uint32) = %lu, expected 4", (unsigned long)sizeof(Uint32) ); + ret = _compareSizeOfType(sizeof(Uint32), 4); + SDLTest_AssertCheck(ret == 0, "sizeof(Uint32) = %lu, expected 4", (unsigned long)sizeof(Uint32)); - ret = _compareSizeOfType( sizeof(Uint64), 8 ); - SDLTest_AssertCheck( ret == 0, "sizeof(Uint64) = %lu, expected 8", (unsigned long)sizeof(Uint64) ); + ret = _compareSizeOfType(sizeof(Uint64), 8); + SDLTest_AssertCheck(ret == 0, "sizeof(Uint64) = %lu, expected 8", (unsigned long)sizeof(Uint64)); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -61,9 +61,10 @@ int platform_testEndianessAndSwap(void *arg) Uint32 value32 = 0xEFBEADDE; Uint32 swapped32 = 0xDEADBEEF; - union { - double d; - Uint32 ui32[2]; + union + { + double d; + Uint32 ui32[2]; } value_double; Uint64 value64, swapped64; @@ -75,17 +76,17 @@ int platform_testEndianessAndSwap(void *arg) swapped64 |= 0xDEADBEEF; value_double.d = 3.141593; - if ((*((char *) &value) >> 4) == 0x1) { + if ((*((char *)&value) >> 4) == 0x1) { real_byteorder = SDL_BIG_ENDIAN; } else { real_byteorder = SDL_LIL_ENDIAN; } /* Test endianness. */ - SDLTest_AssertCheck( real_byteorder == SDL_BYTEORDER, - "Machine detected as %s endian, appears to be %s endian.", - (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big", - (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big" ); + SDLTest_AssertCheck(real_byteorder == SDL_BYTEORDER, + "Machine detected as %s endian, appears to be %s endian.", + (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big", + (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big"); if (value_double.ui32[0] == 0x82c2bd7f && value_double.ui32[1] == 0x400921fb) { real_floatwordorder = SDL_LIL_ENDIAN; @@ -94,27 +95,28 @@ int platform_testEndianessAndSwap(void *arg) } /* Test endianness. */ - SDLTest_AssertCheck( real_floatwordorder == SDL_FLOATWORDORDER, - "Machine detected as having %s endian float word order, appears to be %s endian.", - (SDL_FLOATWORDORDER == SDL_LIL_ENDIAN) ? "little" : "big", - (real_floatwordorder == SDL_LIL_ENDIAN) ? "little" : (real_floatwordorder == SDL_BIG_ENDIAN) ? "big" : "unknown" ); + SDLTest_AssertCheck(real_floatwordorder == SDL_FLOATWORDORDER, + "Machine detected as having %s endian float word order, appears to be %s endian.", + (SDL_FLOATWORDORDER == SDL_LIL_ENDIAN) ? "little" : "big", + (real_floatwordorder == SDL_LIL_ENDIAN) ? "little" : (real_floatwordorder == SDL_BIG_ENDIAN) ? "big" + : "unknown"); /* Test 16 swap. */ - SDLTest_AssertCheck( SDL_Swap16(value16) == swapped16, - "SDL_Swap16(): 16 bit swapped: 0x%X => 0x%X", - value16, SDL_Swap16(value16) ); + SDLTest_AssertCheck(SDL_Swap16(value16) == swapped16, + "SDL_Swap16(): 16 bit swapped: 0x%X => 0x%X", + value16, SDL_Swap16(value16)); /* Test 32 swap. */ - SDLTest_AssertCheck( SDL_Swap32(value32) == swapped32, - "SDL_Swap32(): 32 bit swapped: 0x%" SDL_PRIX32 " => 0x%" SDL_PRIX32, - value32, SDL_Swap32(value32) ); + SDLTest_AssertCheck(SDL_Swap32(value32) == swapped32, + "SDL_Swap32(): 32 bit swapped: 0x%" SDL_PRIX32 " => 0x%" SDL_PRIX32, + value32, SDL_Swap32(value32)); /* Test 64 swap. */ - SDLTest_AssertCheck( SDL_Swap64(value64) == swapped64, - "SDL_Swap64(): 64 bit swapped: 0x%"SDL_PRIX64" => 0x%"SDL_PRIX64, - value64, SDL_Swap64(value64) ); + SDLTest_AssertCheck(SDL_Swap64(value64) == swapped64, + "SDL_Swap64(): 64 bit swapped: 0x%" SDL_PRIX64 " => 0x%" SDL_PRIX64, + value64, SDL_Swap64(value64)); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* ! @@ -126,41 +128,41 @@ int platform_testEndianessAndSwap(void *arg) * http://wiki.libsdl.org/SDL_GetRevision * http://wiki.libsdl.org/SDL_GetRevisionNumber */ -int platform_testGetFunctions (void *arg) +int platform_testGetFunctions(void *arg) { - char *platform; - char *revision; - int ret; - size_t len; + char *platform; + char *revision; + int ret; + size_t len; - platform = (char *)SDL_GetPlatform(); - SDLTest_AssertPass("SDL_GetPlatform()"); - SDLTest_AssertCheck(platform != NULL, "SDL_GetPlatform() != NULL"); - if (platform != NULL) { - len = SDL_strlen(platform); - SDLTest_AssertCheck(len > 0, - "SDL_GetPlatform(): expected non-empty platform, was platform: '%s', len: %i", - platform, - (int) len); - } + platform = (char *)SDL_GetPlatform(); + SDLTest_AssertPass("SDL_GetPlatform()"); + SDLTest_AssertCheck(platform != NULL, "SDL_GetPlatform() != NULL"); + if (platform != NULL) { + len = SDL_strlen(platform); + SDLTest_AssertCheck(len > 0, + "SDL_GetPlatform(): expected non-empty platform, was platform: '%s', len: %i", + platform, + (int)len); + } - ret = SDL_GetCPUCount(); - SDLTest_AssertPass("SDL_GetCPUCount()"); - SDLTest_AssertCheck(ret > 0, - "SDL_GetCPUCount(): expected count > 0, was: %i", - ret); + ret = SDL_GetCPUCount(); + SDLTest_AssertPass("SDL_GetCPUCount()"); + SDLTest_AssertCheck(ret > 0, + "SDL_GetCPUCount(): expected count > 0, was: %i", + ret); - ret = SDL_GetCPUCacheLineSize(); - SDLTest_AssertPass("SDL_GetCPUCacheLineSize()"); - SDLTest_AssertCheck(ret >= 0, - "SDL_GetCPUCacheLineSize(): expected size >= 0, was: %i", - ret); + ret = SDL_GetCPUCacheLineSize(); + SDLTest_AssertPass("SDL_GetCPUCacheLineSize()"); + SDLTest_AssertCheck(ret >= 0, + "SDL_GetCPUCacheLineSize(): expected size >= 0, was: %i", + ret); - revision = (char *)SDL_GetRevision(); - SDLTest_AssertPass("SDL_GetRevision()"); - SDLTest_AssertCheck(revision != NULL, "SDL_GetRevision() != NULL"); + revision = (char *)SDL_GetRevision(); + SDLTest_AssertPass("SDL_GetRevision()"); + SDLTest_AssertCheck(revision != NULL, "SDL_GetRevision() != NULL"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* ! @@ -177,41 +179,41 @@ int platform_testGetFunctions (void *arg) * http://wiki.libsdl.org/SDL_HasSSE42 * http://wiki.libsdl.org/SDL_HasAVX */ -int platform_testHasFunctions (void *arg) +int platform_testHasFunctions(void *arg) { - /* TODO: independently determine and compare values as well */ + /* TODO: independently determine and compare values as well */ - SDL_HasRDTSC(); - SDLTest_AssertPass("SDL_HasRDTSC()"); + SDL_HasRDTSC(); + SDLTest_AssertPass("SDL_HasRDTSC()"); - SDL_HasAltiVec(); - SDLTest_AssertPass("SDL_HasAltiVec()"); + SDL_HasAltiVec(); + SDLTest_AssertPass("SDL_HasAltiVec()"); - SDL_HasMMX(); - SDLTest_AssertPass("SDL_HasMMX()"); + SDL_HasMMX(); + SDLTest_AssertPass("SDL_HasMMX()"); - SDL_Has3DNow(); - SDLTest_AssertPass("SDL_Has3DNow()"); + SDL_Has3DNow(); + SDLTest_AssertPass("SDL_Has3DNow()"); - SDL_HasSSE(); - SDLTest_AssertPass("SDL_HasSSE()"); + SDL_HasSSE(); + SDLTest_AssertPass("SDL_HasSSE()"); - SDL_HasSSE2(); - SDLTest_AssertPass("SDL_HasSSE2()"); + SDL_HasSSE2(); + SDLTest_AssertPass("SDL_HasSSE2()"); - SDL_HasSSE3(); - SDLTest_AssertPass("SDL_HasSSE3()"); + SDL_HasSSE3(); + SDLTest_AssertPass("SDL_HasSSE3()"); - SDL_HasSSE41(); - SDLTest_AssertPass("SDL_HasSSE41()"); + SDL_HasSSE41(); + SDLTest_AssertPass("SDL_HasSSE41()"); - SDL_HasSSE42(); - SDLTest_AssertPass("SDL_HasSSE42()"); + SDL_HasSSE42(); + SDLTest_AssertPass("SDL_HasSSE42()"); - SDL_HasAVX(); - SDLTest_AssertPass("SDL_HasAVX()"); + SDL_HasAVX(); + SDLTest_AssertPass("SDL_HasAVX()"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* ! @@ -221,67 +223,65 @@ int platform_testHasFunctions (void *arg) */ int platform_testGetVersion(void *arg) { - SDL_version linked; - int major = SDL_MAJOR_VERSION; - int minor = SDL_MINOR_VERSION; + SDL_version linked; + int major = SDL_MAJOR_VERSION; + int minor = SDL_MINOR_VERSION; - SDL_GetVersion(&linked); - SDLTest_AssertCheck( linked.major >= major, - "SDL_GetVersion(): returned major %i (>= %i)", - linked.major, - major); - SDLTest_AssertCheck( linked.minor >= minor, - "SDL_GetVersion(): returned minor %i (>= %i)", - linked.minor, - minor); + SDL_GetVersion(&linked); + SDLTest_AssertCheck(linked.major >= major, + "SDL_GetVersion(): returned major %i (>= %i)", + linked.major, + major); + SDLTest_AssertCheck(linked.minor >= minor, + "SDL_GetVersion(): returned minor %i (>= %i)", + linked.minor, + minor); - return TEST_COMPLETED; + return TEST_COMPLETED; } - /* ! * \brief Tests SDL_VERSION macro */ int platform_testSDLVersion(void *arg) { - SDL_version compiled; - int major = SDL_MAJOR_VERSION; - int minor = SDL_MINOR_VERSION; + SDL_version compiled; + int major = SDL_MAJOR_VERSION; + int minor = SDL_MINOR_VERSION; - SDL_VERSION(&compiled); - SDLTest_AssertCheck( compiled.major >= major, - "SDL_VERSION() returned major %i (>= %i)", - compiled.major, - major); - SDLTest_AssertCheck( compiled.minor >= minor, - "SDL_VERSION() returned minor %i (>= %i)", - compiled.minor, - minor); + SDL_VERSION(&compiled); + SDLTest_AssertCheck(compiled.major >= major, + "SDL_VERSION() returned major %i (>= %i)", + compiled.major, + major); + SDLTest_AssertCheck(compiled.minor >= minor, + "SDL_VERSION() returned minor %i (>= %i)", + compiled.minor, + minor); - return TEST_COMPLETED; + return TEST_COMPLETED; } - /* ! * \brief Tests default SDL_Init */ int platform_testDefaultInit(void *arg) { - int ret; - int subsystem; + int ret; + int subsystem; - subsystem = SDL_WasInit(SDL_INIT_EVERYTHING); - SDLTest_AssertCheck( subsystem != 0, - "SDL_WasInit(0): returned %i, expected != 0", - subsystem); + subsystem = SDL_WasInit(SDL_INIT_EVERYTHING); + SDLTest_AssertCheck(subsystem != 0, + "SDL_WasInit(0): returned %i, expected != 0", + subsystem); - ret = SDL_Init(SDL_WasInit(SDL_INIT_EVERYTHING)); - SDLTest_AssertCheck( ret == 0, - "SDL_Init(0): returned %i, expected 0, error: %s", - ret, - SDL_GetError()); + ret = SDL_Init(SDL_WasInit(SDL_INIT_EVERYTHING)); + SDLTest_AssertCheck(ret == 0, + "SDL_Init(0): returned %i, expected 0, error: %s", + ret, + SDL_GetError()); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* ! @@ -293,47 +293,47 @@ int platform_testDefaultInit(void *arg) */ int platform_testGetSetClearError(void *arg) { - int result; - const char *testError = "Testing"; - char *lastError; - size_t len; + int result; + const char *testError = "Testing"; + char *lastError; + size_t len; - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL, - "SDL_GetError() != NULL"); - if (lastError != NULL) { - len = SDL_strlen(lastError); - SDLTest_AssertCheck(len == 0, - "SDL_GetError(): no message expected, len: %i", (int) len); - } + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError != NULL, + "SDL_GetError() != NULL"); + if (lastError != NULL) { + len = SDL_strlen(lastError); + SDLTest_AssertCheck(len == 0, + "SDL_GetError(): no message expected, len: %i", (int)len); + } - result = SDL_SetError("%s", testError); - SDLTest_AssertPass("SDL_SetError()"); - SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); - lastError = (char *)SDL_GetError(); - SDLTest_AssertCheck(lastError != NULL, - "SDL_GetError() != NULL"); - if (lastError != NULL) { - len = SDL_strlen(lastError); - SDLTest_AssertCheck(len == SDL_strlen(testError), - "SDL_GetError(): expected message len %i, was len: %i", - (int) SDL_strlen(testError), - (int) len); - SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0, - "SDL_GetError(): expected message %s, was message: %s", - testError, - lastError); - } + result = SDL_SetError("%s", testError); + SDLTest_AssertPass("SDL_SetError()"); + SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); + lastError = (char *)SDL_GetError(); + SDLTest_AssertCheck(lastError != NULL, + "SDL_GetError() != NULL"); + if (lastError != NULL) { + len = SDL_strlen(lastError); + SDLTest_AssertCheck(len == SDL_strlen(testError), + "SDL_GetError(): expected message len %i, was len: %i", + (int)SDL_strlen(testError), + (int)len); + SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0, + "SDL_GetError(): expected message %s, was message: %s", + testError, + lastError); + } - /* Clean up */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clean up */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* ! @@ -343,34 +343,34 @@ int platform_testGetSetClearError(void *arg) */ int platform_testSetErrorEmptyInput(void *arg) { - int result; - const char *testError = ""; - char *lastError; - size_t len; + int result; + const char *testError = ""; + char *lastError; + size_t len; - result = SDL_SetError("%s", testError); - SDLTest_AssertPass("SDL_SetError()"); - SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); - lastError = (char *)SDL_GetError(); - SDLTest_AssertCheck(lastError != NULL, - "SDL_GetError() != NULL"); - if (lastError != NULL) { - len = SDL_strlen(lastError); - SDLTest_AssertCheck(len == SDL_strlen(testError), - "SDL_GetError(): expected message len %i, was len: %i", - (int) SDL_strlen(testError), - (int) len); - SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - testError, - lastError); - } + result = SDL_SetError("%s", testError); + SDLTest_AssertPass("SDL_SetError()"); + SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); + lastError = (char *)SDL_GetError(); + SDLTest_AssertCheck(lastError != NULL, + "SDL_GetError() != NULL"); + if (lastError != NULL) { + len = SDL_strlen(lastError); + SDLTest_AssertCheck(len == SDL_strlen(testError), + "SDL_GetError(): expected message len %i, was len: %i", + (int)SDL_strlen(testError), + (int)len); + SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0, + "SDL_GetError(): expected message '%s', was message: '%s'", + testError, + lastError); + } - /* Clean up */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clean up */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - return TEST_COMPLETED; + return TEST_COMPLETED; } #if defined(HAVE_WFORMAT_OVERFLOW) @@ -385,77 +385,77 @@ int platform_testSetErrorEmptyInput(void *arg) */ int platform_testSetErrorInvalidInput(void *arg) { - int result; - const char *invalidError = NULL; - const char *probeError = "Testing"; - char *lastError; - size_t len; + int result; + const char *invalidError = NULL; + const char *probeError = "Testing"; + char *lastError; + size_t len; - /* Reset */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Reset */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - /* Check for no-op */ - result = SDL_SetError("%s", invalidError); - SDLTest_AssertPass("SDL_SetError()"); - SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); - lastError = (char *)SDL_GetError(); - SDLTest_AssertCheck(lastError != NULL, - "SDL_GetError() != NULL"); - if (lastError != NULL) { - len = SDL_strlen(lastError); - SDLTest_AssertCheck(len == 0 || SDL_strcmp(lastError, "(null)") == 0, - "SDL_GetError(): expected message len 0, was len: %i", - (int) len); - } + /* Check for no-op */ + result = SDL_SetError("%s", invalidError); + SDLTest_AssertPass("SDL_SetError()"); + SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); + lastError = (char *)SDL_GetError(); + SDLTest_AssertCheck(lastError != NULL, + "SDL_GetError() != NULL"); + if (lastError != NULL) { + len = SDL_strlen(lastError); + SDLTest_AssertCheck(len == 0 || SDL_strcmp(lastError, "(null)") == 0, + "SDL_GetError(): expected message len 0, was len: %i", + (int)len); + } - /* Set */ - result = SDL_SetError("%s", probeError); - SDLTest_AssertPass("SDL_SetError('%s')", probeError); - SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); + /* Set */ + result = SDL_SetError("%s", probeError); + SDLTest_AssertPass("SDL_SetError('%s')", probeError); + SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); - /* Check for no-op */ - result = SDL_SetError("%s", invalidError); - SDLTest_AssertPass("SDL_SetError(NULL)"); - SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); - lastError = (char *)SDL_GetError(); - SDLTest_AssertCheck(lastError != NULL, - "SDL_GetError() != NULL"); - if (lastError != NULL) { - len = SDL_strlen(lastError); - SDLTest_AssertCheck(len == 0 || SDL_strcmp( lastError, "(null)" ) == 0, - "SDL_GetError(): expected message len 0, was len: %i", - (int) len); - } + /* Check for no-op */ + result = SDL_SetError("%s", invalidError); + SDLTest_AssertPass("SDL_SetError(NULL)"); + SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); + lastError = (char *)SDL_GetError(); + SDLTest_AssertCheck(lastError != NULL, + "SDL_GetError() != NULL"); + if (lastError != NULL) { + len = SDL_strlen(lastError); + SDLTest_AssertCheck(len == 0 || SDL_strcmp(lastError, "(null)") == 0, + "SDL_GetError(): expected message len 0, was len: %i", + (int)len); + } - /* Reset */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Reset */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - /* Set and check */ - result = SDL_SetError("%s", probeError); - SDLTest_AssertPass("SDL_SetError()"); - SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); - lastError = (char *)SDL_GetError(); - SDLTest_AssertCheck(lastError != NULL, - "SDL_GetError() != NULL"); - if (lastError != NULL) { - len = SDL_strlen(lastError); - SDLTest_AssertCheck(len == SDL_strlen(probeError), - "SDL_GetError(): expected message len %i, was len: %i", - (int) SDL_strlen(probeError), - (int) len); - SDLTest_AssertCheck(SDL_strcmp(lastError, probeError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - probeError, - lastError); - } + /* Set and check */ + result = SDL_SetError("%s", probeError); + SDLTest_AssertPass("SDL_SetError()"); + SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); + lastError = (char *)SDL_GetError(); + SDLTest_AssertCheck(lastError != NULL, + "SDL_GetError() != NULL"); + if (lastError != NULL) { + len = SDL_strlen(lastError); + SDLTest_AssertCheck(len == SDL_strlen(probeError), + "SDL_GetError(): expected message len %i, was len: %i", + (int)SDL_strlen(probeError), + (int)len); + SDLTest_AssertCheck(SDL_strcmp(lastError, probeError) == 0, + "SDL_GetError(): expected message '%s', was message: '%s'", + probeError, + lastError); + } - /* Clean up */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clean up */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - return TEST_COMPLETED; + return TEST_COMPLETED; } #if defined(HAVE_WFORMAT_OVERFLOW) @@ -469,114 +469,124 @@ int platform_testSetErrorInvalidInput(void *arg) */ int platform_testGetPowerInfo(void *arg) { - SDL_PowerState state; - SDL_PowerState stateAgain; - int secs; - int secsAgain; - int pct; - int pctAgain; + SDL_PowerState state; + SDL_PowerState stateAgain; + int secs; + int secsAgain; + int pct; + int pctAgain; - state = SDL_GetPowerInfo(&secs, &pct); - SDLTest_AssertPass("SDL_GetPowerInfo()"); - SDLTest_AssertCheck( - state==SDL_POWERSTATE_UNKNOWN || - state==SDL_POWERSTATE_ON_BATTERY || - state==SDL_POWERSTATE_NO_BATTERY || - state==SDL_POWERSTATE_CHARGING || - state==SDL_POWERSTATE_CHARGED, - "SDL_GetPowerInfo(): state %i is one of the expected values", - (int)state); + state = SDL_GetPowerInfo(&secs, &pct); + SDLTest_AssertPass("SDL_GetPowerInfo()"); + SDLTest_AssertCheck( + state == SDL_POWERSTATE_UNKNOWN || + state == SDL_POWERSTATE_ON_BATTERY || + state == SDL_POWERSTATE_NO_BATTERY || + state == SDL_POWERSTATE_CHARGING || + state == SDL_POWERSTATE_CHARGED, + "SDL_GetPowerInfo(): state %i is one of the expected values", + (int)state); - if (state==SDL_POWERSTATE_ON_BATTERY) { - SDLTest_AssertCheck( - secs >= 0, - "SDL_GetPowerInfo(): on battery, secs >= 0, was: %i", - secs); - SDLTest_AssertCheck( - (pct >= 0) && (pct <= 100), - "SDL_GetPowerInfo(): on battery, pct=[0,100], was: %i", - pct); - } + if (state == SDL_POWERSTATE_ON_BATTERY) { + SDLTest_AssertCheck( + secs >= 0, + "SDL_GetPowerInfo(): on battery, secs >= 0, was: %i", + secs); + SDLTest_AssertCheck( + (pct >= 0) && (pct <= 100), + "SDL_GetPowerInfo(): on battery, pct=[0,100], was: %i", + pct); + } - if (state==SDL_POWERSTATE_UNKNOWN || - state==SDL_POWERSTATE_NO_BATTERY) - { - SDLTest_AssertCheck( - secs == -1, - "SDL_GetPowerInfo(): no battery, secs == -1, was: %i", - secs); - SDLTest_AssertCheck( - pct == -1, - "SDL_GetPowerInfo(): no battery, pct == -1, was: %i", - pct); - } + if (state == SDL_POWERSTATE_UNKNOWN || + state == SDL_POWERSTATE_NO_BATTERY) { + SDLTest_AssertCheck( + secs == -1, + "SDL_GetPowerInfo(): no battery, secs == -1, was: %i", + secs); + SDLTest_AssertCheck( + pct == -1, + "SDL_GetPowerInfo(): no battery, pct == -1, was: %i", + pct); + } - /* Partial return value variations */ - stateAgain = SDL_GetPowerInfo(&secsAgain, NULL); - SDLTest_AssertCheck( - state==stateAgain, + /* Partial return value variations */ + stateAgain = SDL_GetPowerInfo(&secsAgain, NULL); + SDLTest_AssertCheck( + state == stateAgain, "State %i returned when only 'secs' requested", stateAgain); - SDLTest_AssertCheck( - secs==secsAgain, + SDLTest_AssertCheck( + secs == secsAgain, "Value %i matches when only 'secs' requested", secsAgain); - stateAgain = SDL_GetPowerInfo(NULL, &pctAgain); - SDLTest_AssertCheck( - state==stateAgain, + stateAgain = SDL_GetPowerInfo(NULL, &pctAgain); + SDLTest_AssertCheck( + state == stateAgain, "State %i returned when only 'pct' requested", stateAgain); - SDLTest_AssertCheck( - pct==pctAgain, + SDLTest_AssertCheck( + pct == pctAgain, "Value %i matches when only 'pct' requested", pctAgain); - stateAgain = SDL_GetPowerInfo(NULL, NULL); - SDLTest_AssertCheck( - state==stateAgain, + stateAgain = SDL_GetPowerInfo(NULL, NULL); + SDLTest_AssertCheck( + state == stateAgain, "State %i returned when no value requested", stateAgain); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* ================= Test References ================== */ /* Platform test cases */ -static const SDLTest_TestCaseReference platformTest1 = - { (SDLTest_TestCaseFp)platform_testTypes, "platform_testTypes", "Tests predefined types", TEST_ENABLED}; +static const SDLTest_TestCaseReference platformTest1 = { + (SDLTest_TestCaseFp)platform_testTypes, "platform_testTypes", "Tests predefined types", TEST_ENABLED +}; -static const SDLTest_TestCaseReference platformTest2 = - { (SDLTest_TestCaseFp)platform_testEndianessAndSwap, "platform_testEndianessAndSwap", "Tests endianness and swap functions", TEST_ENABLED}; +static const SDLTest_TestCaseReference platformTest2 = { + (SDLTest_TestCaseFp)platform_testEndianessAndSwap, "platform_testEndianessAndSwap", "Tests endianness and swap functions", TEST_ENABLED +}; -static const SDLTest_TestCaseReference platformTest3 = - { (SDLTest_TestCaseFp)platform_testGetFunctions, "platform_testGetFunctions", "Tests various SDL_GetXYZ functions", TEST_ENABLED}; +static const SDLTest_TestCaseReference platformTest3 = { + (SDLTest_TestCaseFp)platform_testGetFunctions, "platform_testGetFunctions", "Tests various SDL_GetXYZ functions", TEST_ENABLED +}; -static const SDLTest_TestCaseReference platformTest4 = - { (SDLTest_TestCaseFp)platform_testHasFunctions, "platform_testHasFunctions", "Tests various SDL_HasXYZ functions", TEST_ENABLED}; +static const SDLTest_TestCaseReference platformTest4 = { + (SDLTest_TestCaseFp)platform_testHasFunctions, "platform_testHasFunctions", "Tests various SDL_HasXYZ functions", TEST_ENABLED +}; -static const SDLTest_TestCaseReference platformTest5 = - { (SDLTest_TestCaseFp)platform_testGetVersion, "platform_testGetVersion", "Tests SDL_GetVersion function", TEST_ENABLED}; +static const SDLTest_TestCaseReference platformTest5 = { + (SDLTest_TestCaseFp)platform_testGetVersion, "platform_testGetVersion", "Tests SDL_GetVersion function", TEST_ENABLED +}; -static const SDLTest_TestCaseReference platformTest6 = - { (SDLTest_TestCaseFp)platform_testSDLVersion, "platform_testSDLVersion", "Tests SDL_VERSION macro", TEST_ENABLED}; +static const SDLTest_TestCaseReference platformTest6 = { + (SDLTest_TestCaseFp)platform_testSDLVersion, "platform_testSDLVersion", "Tests SDL_VERSION macro", TEST_ENABLED +}; -static const SDLTest_TestCaseReference platformTest7 = - { (SDLTest_TestCaseFp)platform_testDefaultInit, "platform_testDefaultInit", "Tests default SDL_Init", TEST_ENABLED}; +static const SDLTest_TestCaseReference platformTest7 = { + (SDLTest_TestCaseFp)platform_testDefaultInit, "platform_testDefaultInit", "Tests default SDL_Init", TEST_ENABLED +}; -static const SDLTest_TestCaseReference platformTest8 = - { (SDLTest_TestCaseFp)platform_testGetSetClearError, "platform_testGetSetClearError", "Tests SDL_Get/Set/ClearError", TEST_ENABLED}; +static const SDLTest_TestCaseReference platformTest8 = { + (SDLTest_TestCaseFp)platform_testGetSetClearError, "platform_testGetSetClearError", "Tests SDL_Get/Set/ClearError", TEST_ENABLED +}; -static const SDLTest_TestCaseReference platformTest9 = - { (SDLTest_TestCaseFp)platform_testSetErrorEmptyInput, "platform_testSetErrorEmptyInput", "Tests SDL_SetError with empty input", TEST_ENABLED}; +static const SDLTest_TestCaseReference platformTest9 = { + (SDLTest_TestCaseFp)platform_testSetErrorEmptyInput, "platform_testSetErrorEmptyInput", "Tests SDL_SetError with empty input", TEST_ENABLED +}; -static const SDLTest_TestCaseReference platformTest10 = - { (SDLTest_TestCaseFp)platform_testSetErrorInvalidInput, "platform_testSetErrorInvalidInput", "Tests SDL_SetError with invalid input", TEST_ENABLED}; +static const SDLTest_TestCaseReference platformTest10 = { + (SDLTest_TestCaseFp)platform_testSetErrorInvalidInput, "platform_testSetErrorInvalidInput", "Tests SDL_SetError with invalid input", TEST_ENABLED +}; -static const SDLTest_TestCaseReference platformTest11 = - { (SDLTest_TestCaseFp)platform_testGetPowerInfo, "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED }; +static const SDLTest_TestCaseReference platformTest11 = { + (SDLTest_TestCaseFp)platform_testGetPowerInfo, "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED +}; /* Sequence of Platform test cases */ -static const SDLTest_TestCaseReference *platformTests[] = { +static const SDLTest_TestCaseReference *platformTests[] = { &platformTest1, &platformTest2, &platformTest3, diff --git a/test/testautomation_rect.c b/test/testautomation_rect.c index 853f544b5..f259cb960 100644 --- a/test/testautomation_rect.c +++ b/test/testautomation_rect.c @@ -17,24 +17,24 @@ */ void _validateIntersectRectAndLineResults( SDL_bool intersection, SDL_bool expectedIntersection, - SDL_Rect *rect, SDL_Rect * refRect, + SDL_Rect *rect, SDL_Rect *refRect, int x1, int y1, int x2, int y2, int x1Ref, int y1Ref, int x2Ref, int y2Ref) { SDLTest_AssertCheck(intersection == expectedIntersection, - "Check for correct intersection result: expected %s, got %s intersecting rect (%d,%d,%d,%d) with line (%d,%d - %d,%d)", - (expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - (intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - refRect->x, refRect->y, refRect->w, refRect->h, - x1Ref, y1Ref, x2Ref, y2Ref); + "Check for correct intersection result: expected %s, got %s intersecting rect (%d,%d,%d,%d) with line (%d,%d - %d,%d)", + (expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", + (intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", + refRect->x, refRect->y, refRect->w, refRect->h, + x1Ref, y1Ref, x2Ref, y2Ref); SDLTest_AssertCheck(rect->x == refRect->x && rect->y == refRect->y && rect->w == refRect->w && rect->h == refRect->h, - "Check that source rectangle was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rect->x, rect->y, rect->w, rect->h, - refRect->x, refRect->y, refRect->w, refRect->h); + "Check that source rectangle was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", + rect->x, rect->y, rect->w, rect->h, + refRect->x, refRect->y, refRect->w, refRect->h); SDLTest_AssertCheck(x1 == x1Ref && y1 == y1Ref && x2 == x2Ref && y2 == y2Ref, - "Check if line was incorrectly clipped or modified: got (%d,%d - %d,%d) expected (%d,%d - %d,%d)", - x1, y1, x2, y2, - x1Ref, y1Ref, x2Ref, y2Ref); + "Check if line was incorrectly clipped or modified: got (%d,%d - %d,%d) expected (%d,%d - %d,%d)", + x1, y1, x2, y2, + x1Ref, y1Ref, x2Ref, y2Ref); } /* Test case functions */ @@ -45,8 +45,7 @@ void _validateIntersectRectAndLineResults( * \sa * http://wiki.libsdl.org/SDL_IntersectRectAndLine */ -int -rect_testIntersectRectAndLine (void *arg) +int rect_testIntersectRectAndLine(void *arg) { SDL_Rect refRect = { 0, 0, 32, 32 }; SDL_Rect rect; @@ -77,14 +76,14 @@ rect_testIntersectRectAndLine (void *arg) x1 = -refRect.w; y1 = -refRect.h; - x2 = 2*refRect.w; - y2 = 2*refRect.h; + x2 = 2 * refRect.w; + y2 = 2 * refRect.h; rect = refRect; intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); - _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 0, 31, 31); + _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 0, 31, 31); - x1 = 2*refRect.w; - y1 = 2*refRect.h; + x1 = 2 * refRect.w; + y1 = 2 * refRect.h; x2 = -refRect.w; y2 = -refRect.h; rect = refRect; @@ -116,8 +115,7 @@ rect_testIntersectRectAndLine (void *arg) * \sa * http://wiki.libsdl.org/SDL_IntersectRectAndLine */ -int -rect_testIntersectRectAndLineInside (void *arg) +int rect_testIntersectRectAndLineInside(void *arg) { SDL_Rect refRect = { 0, 0, 32, 32 }; SDL_Rect rect; @@ -183,8 +181,7 @@ rect_testIntersectRectAndLineInside (void *arg) * \sa * http://wiki.libsdl.org/SDL_IntersectRectAndLine */ -int -rect_testIntersectRectAndLineOutside (void *arg) +int rect_testIntersectRectAndLineOutside(void *arg) { SDL_Rect refRect = { 0, 0, 32, 32 }; SDL_Rect rect; @@ -238,8 +235,7 @@ rect_testIntersectRectAndLineOutside (void *arg) * \sa * http://wiki.libsdl.org/SDL_IntersectRectAndLine */ -int -rect_testIntersectRectAndLineEmpty (void *arg) +int rect_testIntersectRectAndLineEmpty(void *arg) { SDL_Rect refRect; SDL_Rect rect; @@ -273,8 +269,7 @@ rect_testIntersectRectAndLineEmpty (void *arg) * \sa * http://wiki.libsdl.org/SDL_IntersectRectAndLine */ -int -rect_testIntersectRectAndLineParam (void *arg) +int rect_testIntersectRectAndLineParam(void *arg) { SDL_Rect rect = { 0, 0, 32, 32 }; int x1 = rect.w / 2; @@ -310,19 +305,19 @@ void _validateHasIntersectionResults( SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB) { SDLTest_AssertCheck(intersection == expectedIntersection, - "Check intersection result: expected %s, got %s intersecting A (%d,%d,%d,%d) with B (%d,%d,%d,%d)", - (expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - (intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - rectA->x, rectA->y, rectA->w, rectA->h, - rectB->x, rectB->y, rectB->w, rectB->h); + "Check intersection result: expected %s, got %s intersecting A (%d,%d,%d,%d) with B (%d,%d,%d,%d)", + (expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", + (intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", + rectA->x, rectA->y, rectA->w, rectA->h, + rectB->x, rectB->y, rectB->w, rectB->h); SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h, - "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectA->x, rectA->y, rectA->w, rectA->h, - refRectA->x, refRectA->y, refRectA->w, refRectA->h); + "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", + rectA->x, rectA->y, rectA->w, rectA->h, + refRectA->x, refRectA->y, refRectA->w, refRectA->h); SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h, - "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectB->x, rectB->y, rectB->w, rectB->h, - refRectB->x, refRectB->y, refRectB->w, refRectB->h); + "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", + rectB->x, rectB->y, rectB->w, rectB->h, + refRectB->x, refRectB->y, refRectB->w, refRectB->h); } /* ! @@ -336,11 +331,11 @@ void _validateIntersectRectResults( _validateHasIntersectionResults(intersection, expectedIntersection, rectA, rectB, refRectA, refRectB); if (result && expectedResult) { SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h, - "Check that intersection of rectangles A (%d,%d,%d,%d) and B (%d,%d,%d,%d) was correctly calculated, got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectA->x, rectA->y, rectA->w, rectA->h, - rectB->x, rectB->y, rectB->w, rectB->h, - result->x, result->y, result->w, result->h, - expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h); + "Check that intersection of rectangles A (%d,%d,%d,%d) and B (%d,%d,%d,%d) was correctly calculated, got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", + rectA->x, rectA->y, rectA->w, rectA->h, + rectB->x, rectB->y, rectB->w, rectB->h, + result->x, result->y, result->w, result->h, + expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h); } } @@ -352,19 +347,19 @@ void _validateUnionRectResults( SDL_Rect *result, SDL_Rect *expectedResult) { SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h, - "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectA->x, rectA->y, rectA->w, rectA->h, - refRectA->x, refRectA->y, refRectA->w, refRectA->h); + "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", + rectA->x, rectA->y, rectA->w, rectA->h, + refRectA->x, refRectA->y, refRectA->w, refRectA->h); SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h, - "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectB->x, rectB->y, rectB->w, rectB->h, - refRectB->x, refRectB->y, refRectB->w, refRectB->h); + "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", + rectB->x, rectB->y, rectB->w, rectB->h, + refRectB->x, refRectB->y, refRectB->w, refRectB->h); SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h, - "Check that union of rectangles A (%d,%d,%d,%d) and B (%d,%d,%d,%d) was correctly calculated, got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectA->x, rectA->y, rectA->w, rectA->h, - rectB->x, rectB->y, rectB->w, rectB->h, - result->x, result->y, result->w, result->h, - expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h); + "Check that union of rectangles A (%d,%d,%d,%d) and B (%d,%d,%d,%d) was correctly calculated, got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", + rectA->x, rectA->y, rectA->w, rectA->h, + rectB->x, rectB->y, rectB->w, rectB->h, + result->x, result->y, result->w, result->h, + expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h); } /* ! @@ -375,14 +370,14 @@ void _validateRectEmptyResults( SDL_Rect *rect, SDL_Rect *refRect) { SDLTest_AssertCheck(empty == expectedEmpty, - "Check for correct empty result: expected %s, got %s testing (%d,%d,%d,%d)", - (expectedEmpty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - rect->x, rect->y, rect->w, rect->h); + "Check for correct empty result: expected %s, got %s testing (%d,%d,%d,%d)", + (expectedEmpty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", + (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", + rect->x, rect->y, rect->w, rect->h); SDLTest_AssertCheck(rect->x == refRect->x && rect->y == refRect->y && rect->w == refRect->w && rect->h == refRect->h, - "Check that source rectangle was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rect->x, rect->y, rect->w, rect->h, - refRect->x, refRect->y, refRect->w, refRect->h); + "Check that source rectangle was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", + rect->x, rect->y, rect->w, rect->h, + refRect->x, refRect->y, refRect->w, refRect->h); } /* ! @@ -393,19 +388,19 @@ void _validateRectEqualsResults( SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB) { SDLTest_AssertCheck(equals == expectedEquals, - "Check for correct equals result: expected %s, got %s testing (%d,%d,%d,%d) and (%d,%d,%d,%d)", - (expectedEquals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - (equals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - rectA->x, rectA->y, rectA->w, rectA->h, - rectB->x, rectB->y, rectB->w, rectB->h); + "Check for correct equals result: expected %s, got %s testing (%d,%d,%d,%d) and (%d,%d,%d,%d)", + (expectedEquals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", + (equals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", + rectA->x, rectA->y, rectA->w, rectA->h, + rectB->x, rectB->y, rectB->w, rectB->h); SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h, - "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectA->x, rectA->y, rectA->w, rectA->h, - refRectA->x, refRectA->y, refRectA->w, refRectA->h); + "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", + rectA->x, rectA->y, rectA->w, rectA->h, + refRectA->x, refRectA->y, refRectA->w, refRectA->h); SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h, - "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectB->x, rectB->y, rectB->w, rectB->h, - refRectB->x, refRectB->y, refRectB->w, refRectB->h); + "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", + rectB->x, rectB->y, rectB->w, rectB->h, + refRectB->x, refRectB->y, refRectB->w, refRectB->h); } /* ! @@ -417,21 +412,21 @@ void _validateFRectEqualsResults( { int cmpRes; SDLTest_AssertCheck(equals == expectedEquals, - "Check for correct equals result: expected %s, got %s testing (%f,%f,%f,%f) and (%f,%f,%f,%f)", - (expectedEquals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - (equals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - rectA->x, rectA->y, rectA->w, rectA->h, - rectB->x, rectB->y, rectB->w, rectB->h); + "Check for correct equals result: expected %s, got %s testing (%f,%f,%f,%f) and (%f,%f,%f,%f)", + (expectedEquals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", + (equals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", + rectA->x, rectA->y, rectA->w, rectA->h, + rectB->x, rectB->y, rectB->w, rectB->h); cmpRes = SDL_memcmp(rectA, refRectA, sizeof(*rectA)); SDLTest_AssertCheck(cmpRes == 0, - "Check that source rectangle A was not modified: got (%f,%f,%f,%f) expected (%f,%f,%f,%f)", - rectA->x, rectA->y, rectA->w, rectA->h, - refRectA->x, refRectA->y, refRectA->w, refRectA->h); + "Check that source rectangle A was not modified: got (%f,%f,%f,%f) expected (%f,%f,%f,%f)", + rectA->x, rectA->y, rectA->w, rectA->h, + refRectA->x, refRectA->y, refRectA->w, refRectA->h); cmpRes = SDL_memcmp(rectB, refRectB, sizeof(*rectB)); SDLTest_AssertCheck(cmpRes == 0, - "Check that source rectangle B was not modified: got (%f,%f,%f,%f) expected (%f,%f,%f,%f)", - rectB->x, rectB->y, rectB->w, rectB->h, - refRectB->x, refRectB->y, refRectB->w, refRectB->h); + "Check that source rectangle B was not modified: got (%f,%f,%f,%f) expected (%f,%f,%f,%f)", + rectB->x, rectB->y, rectB->w, rectB->h, + refRectB->x, refRectB->y, refRectB->w, refRectB->h); } /* ! @@ -440,7 +435,7 @@ void _validateFRectEqualsResults( * \sa * http://wiki.libsdl.org/SDL_IntersectRect */ -int rect_testIntersectRectInside (void *arg) +int rect_testIntersectRectInside(void *arg) { SDL_Rect refRectA = { 0, 0, 32, 32 }; SDL_Rect refRectB; @@ -468,7 +463,7 @@ int rect_testIntersectRectInside (void *arg) * \sa * http://wiki.libsdl.org/SDL_IntersectRect */ -int rect_testIntersectRectOutside (void *arg) +int rect_testIntersectRectOutside(void *arg) { SDL_Rect refRectA = { 0, 0, 32, 32 }; SDL_Rect refRectB; @@ -496,7 +491,7 @@ int rect_testIntersectRectOutside (void *arg) * \sa * http://wiki.libsdl.org/SDL_IntersectRect */ -int rect_testIntersectRectPartial (void *arg) +int rect_testIntersectRectPartial(void *arg) { SDL_Rect refRectA = { 0, 0, 32, 32 }; SDL_Rect refRectB; @@ -585,7 +580,7 @@ int rect_testIntersectRectPartial (void *arg) * \sa * http://wiki.libsdl.org/SDL_IntersectRect */ -int rect_testIntersectRectPoint (void *arg) +int rect_testIntersectRectPoint(void *arg) { SDL_Rect refRectA = { 0, 0, 1, 1 }; SDL_Rect refRectB = { 0, 0, 1, 1 }; @@ -632,7 +627,7 @@ int rect_testIntersectRectPoint (void *arg) * \sa * http://wiki.libsdl.org/SDL_IntersectRect */ -int rect_testIntersectRectEmpty (void *arg) +int rect_testIntersectRectEmpty(void *arg) { SDL_Rect refRectA; SDL_Rect refRectB; @@ -707,7 +702,7 @@ int rect_testIntersectRectEmpty (void *arg) int rect_testIntersectRectParam(void *arg) { SDL_Rect rectA; - SDL_Rect rectB = {0}; + SDL_Rect rectB = { 0 }; SDL_Rect result; SDL_bool intersection; @@ -734,7 +729,7 @@ int rect_testIntersectRectParam(void *arg) * \sa * http://wiki.libsdl.org/SDL_HasIntersection */ -int rect_testHasIntersectionInside (void *arg) +int rect_testHasIntersectionInside(void *arg) { SDL_Rect refRectA = { 0, 0, 32, 32 }; SDL_Rect refRectB; @@ -761,7 +756,7 @@ int rect_testHasIntersectionInside (void *arg) * \sa * http://wiki.libsdl.org/SDL_HasIntersection */ -int rect_testHasIntersectionOutside (void *arg) +int rect_testHasIntersectionOutside(void *arg) { SDL_Rect refRectA = { 0, 0, 32, 32 }; SDL_Rect refRectB; @@ -788,7 +783,7 @@ int rect_testHasIntersectionOutside (void *arg) * \sa * http://wiki.libsdl.org/SDL_HasIntersection */ -int rect_testHasIntersectionPartial (void *arg) +int rect_testHasIntersectionPartial(void *arg) { SDL_Rect refRectA = { 0, 0, 32, 32 }; SDL_Rect refRectB; @@ -855,7 +850,7 @@ int rect_testHasIntersectionPartial (void *arg) * \sa * http://wiki.libsdl.org/SDL_HasIntersection */ -int rect_testHasIntersectionPoint (void *arg) +int rect_testHasIntersectionPoint(void *arg) { SDL_Rect refRectA = { 0, 0, 1, 1 }; SDL_Rect refRectB = { 0, 0, 1, 1 }; @@ -901,7 +896,7 @@ int rect_testHasIntersectionPoint (void *arg) * \sa * http://wiki.libsdl.org/SDL_HasIntersection */ -int rect_testHasIntersectionEmpty (void *arg) +int rect_testHasIntersectionEmpty(void *arg) { SDL_Rect refRectA; SDL_Rect refRectB; @@ -962,7 +957,7 @@ int rect_testHasIntersectionEmpty (void *arg) int rect_testHasIntersectionParam(void *arg) { SDL_Rect rectA; - SDL_Rect rectB = {0}; + SDL_Rect rectB = { 0 }; SDL_bool intersection; /* invalid parameter combinations */ @@ -996,14 +991,14 @@ int rect_testEnclosePoints(void *arg) int i; /* Create input data, tracking result */ - for (i=0; i=refClip.x) && (newx<(refClip.x + refClip.w)) && - (newy>=refClip.y) && (newy<(refClip.y + refClip.h))) { - if (expectedEnclosed==SDL_FALSE) { + if ((newx >= refClip.x) && (newx < (refClip.x + refClip.w)) && + (newy >= refClip.y) && (newy < (refClip.y + refClip.h))) { + if (expectedEnclosed == SDL_FALSE) { minx = newx; maxx = newx; miny = newy; @@ -1201,35 +1196,35 @@ int rect_testEnclosePointsWithClipping(void *arg) /* Call function and validate - special case: no result requested */ clip = refClip; anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, (SDL_Rect *)NULL); - SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult, - "Expected return value %s, got %s", - (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - (anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); - for (i=0; irefRectB.x) ? refRectA.x : refRectB.x; - miny = (refRectA.yrefRectB.y) ? refRectA.y : refRectB.y; + refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.y = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.w = 1; + refRectA.h = 1; + refRectB.x = SDLTest_RandomIntegerInRange(-1024, 1024) + dx * 2048; + refRectB.y = SDLTest_RandomIntegerInRange(-1024, 1024) + dx * 2048; + refRectB.w = 1; + refRectB.h = 1; + minx = (refRectA.x < refRectB.x) ? refRectA.x : refRectB.x; + maxx = (refRectA.x > refRectB.x) ? refRectA.x : refRectB.x; + miny = (refRectA.y < refRectB.y) ? refRectA.y : refRectB.y; + maxy = (refRectA.y > refRectB.y) ? refRectA.y : refRectB.y; expectedResult.x = minx; expectedResult.y = miny; expectedResult.w = maxx - minx + 1; @@ -1320,14 +1315,14 @@ int rect_testUnionRectOutside(void *arg) for (dx = -1; dx < 2; dx++) { for (dy = -1; dy < 2; dy++) { if ((dx != 0) || (dy != 0)) { - refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.w=SDLTest_RandomIntegerInRange(256, 512); - refRectA.h=SDLTest_RandomIntegerInRange(256, 512); - refRectB.x=refRectA.x + 1 + dx*2; - refRectB.y=refRectA.y + 1 + dy*2; - refRectB.w=refRectA.w - 2; - refRectB.h=refRectA.h - 2; + refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.y = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.w = SDLTest_RandomIntegerInRange(256, 512); + refRectA.h = SDLTest_RandomIntegerInRange(256, 512); + refRectB.x = refRectA.x + 1 + dx * 2; + refRectB.y = refRectA.y + 1 + dy * 2; + refRectB.w = refRectA.w - 2; + refRectB.h = refRectA.h - 2; expectedResult = refRectA; if (dx == -1) { expectedResult.x--; @@ -1366,14 +1361,14 @@ int rect_testUnionRectEmpty(void *arg) SDL_Rect result; /* A empty */ - refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.w=0; - refRectA.h=0; - refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectB.w=SDLTest_RandomIntegerInRange(1, 1024); - refRectB.h=SDLTest_RandomIntegerInRange(1, 1024); + refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.y = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.w = 0; + refRectA.h = 0; + refRectB.x = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectB.y = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectB.w = SDLTest_RandomIntegerInRange(1, 1024); + refRectB.h = SDLTest_RandomIntegerInRange(1, 1024); expectedResult = refRectB; rectA = refRectA; rectB = refRectB; @@ -1381,14 +1376,14 @@ int rect_testUnionRectEmpty(void *arg) _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); /* B empty */ - refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.w=SDLTest_RandomIntegerInRange(1, 1024); - refRectA.h=SDLTest_RandomIntegerInRange(1, 1024); - refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectB.w=0; - refRectB.h=0; + refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.y = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.w = SDLTest_RandomIntegerInRange(1, 1024); + refRectA.h = SDLTest_RandomIntegerInRange(1, 1024); + refRectB.x = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectB.y = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectB.w = 0; + refRectB.h = 0; expectedResult = refRectA; rectA = refRectA; rectB = refRectB; @@ -1396,18 +1391,18 @@ int rect_testUnionRectEmpty(void *arg) _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); /* A and B empty */ - refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.w=0; - refRectA.h=0; - refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectB.w=0; - refRectB.h=0; - result.x=0; - result.y=0; - result.w=0; - result.h=0; + refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.y = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.w = 0; + refRectA.h = 0; + refRectB.x = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectB.y = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectB.w = 0; + refRectB.h = 0; + result.x = 0; + result.y = 0; + result.w = 0; + result.h = 0; expectedResult = result; rectA = refRectA; rectB = refRectB; @@ -1432,24 +1427,24 @@ int rect_testUnionRectInside(void *arg) int dx, dy; /* Union 1x1 with itself */ - refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.w=1; - refRectA.h=1; + refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.y = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.w = 1; + refRectA.h = 1; expectedResult = refRectA; rectA = refRectA; SDL_UnionRect(&rectA, &rectA, &result); _validateUnionRectResults(&rectA, &rectA, &refRectA, &refRectA, &result, &expectedResult); /* Union 1x1 somewhere inside */ - refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.w=SDLTest_RandomIntegerInRange(256, 1024); - refRectA.h=SDLTest_RandomIntegerInRange(256, 1024); - refRectB.x=refRectA.x + 1 + SDLTest_RandomIntegerInRange(1, refRectA.w - 2); - refRectB.y=refRectA.y + 1 + SDLTest_RandomIntegerInRange(1, refRectA.h - 2); - refRectB.w=1; - refRectB.h=1; + refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.y = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.w = SDLTest_RandomIntegerInRange(256, 1024); + refRectA.h = SDLTest_RandomIntegerInRange(256, 1024); + refRectB.x = refRectA.x + 1 + SDLTest_RandomIntegerInRange(1, refRectA.w - 2); + refRectB.y = refRectA.y + 1 + SDLTest_RandomIntegerInRange(1, refRectA.h - 2); + refRectB.w = 1; + refRectB.h = 1; expectedResult = refRectA; rectA = refRectA; rectB = refRectB; @@ -1460,10 +1455,10 @@ int rect_testUnionRectInside(void *arg) for (dx = -1; dx < 2; dx++) { for (dy = -1; dy < 2; dy++) { if ((dx != 0) || (dy != 0)) { - refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.w=SDLTest_RandomIntegerInRange(256, 1024); - refRectA.h=SDLTest_RandomIntegerInRange(256, 1024); + refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.y = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.w = SDLTest_RandomIntegerInRange(256, 1024); + refRectA.h = SDLTest_RandomIntegerInRange(256, 1024); refRectB = refRectA; if (dx == -1) { refRectB.x++; @@ -1532,23 +1527,23 @@ int rect_testRectEmpty(void *arg) int w, h; /* Non-empty case */ - refRect.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRect.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRect.w=SDLTest_RandomIntegerInRange(256, 1024); - refRect.h=SDLTest_RandomIntegerInRange(256, 1024); + refRect.x = SDLTest_RandomIntegerInRange(-1024, 1024); + refRect.y = SDLTest_RandomIntegerInRange(-1024, 1024); + refRect.w = SDLTest_RandomIntegerInRange(256, 1024); + refRect.h = SDLTest_RandomIntegerInRange(256, 1024); expectedResult = SDL_FALSE; rect = refRect; result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)&rect); _validateRectEmptyResults(result, expectedResult, &rect, &refRect); /* Empty case */ - for (w=-1; w<2; w++) { - for (h=-1; h<2; h++) { + for (w = -1; w < 2; w++) { + for (h = -1; h < 2; h++) { if ((w != 1) || (h != 1)) { - refRect.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRect.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRect.w=w; - refRect.h=h; + refRect.x = SDLTest_RandomIntegerInRange(-1024, 1024); + refRect.y = SDLTest_RandomIntegerInRange(-1024, 1024); + refRect.w = w; + refRect.h = h; expectedResult = SDL_TRUE; rect = refRect; result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)&rect); @@ -1593,10 +1588,10 @@ int rect_testRectEquals(void *arg) SDL_bool result; /* Equals */ - refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.w=SDLTest_RandomIntegerInRange(1, 1024); - refRectA.h=SDLTest_RandomIntegerInRange(1, 1024); + refRectA.x = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.y = SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.w = SDLTest_RandomIntegerInRange(1, 1024); + refRectA.h = SDLTest_RandomIntegerInRange(1, 1024); refRectB = refRectA; expectedResult = SDL_TRUE; rectA = refRectA; @@ -1620,14 +1615,14 @@ int rect_testRectEqualsParam(void *arg) SDL_bool result; /* data setup */ - rectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); - rectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); - rectA.w=SDLTest_RandomIntegerInRange(1, 1024); - rectA.h=SDLTest_RandomIntegerInRange(1, 1024); - rectB.x=SDLTest_RandomIntegerInRange(-1024, 1024); - rectB.y=SDLTest_RandomIntegerInRange(-1024, 1024); - rectB.w=SDLTest_RandomIntegerInRange(1, 1024); - rectB.h=SDLTest_RandomIntegerInRange(1, 1024); + rectA.x = SDLTest_RandomIntegerInRange(-1024, 1024); + rectA.y = SDLTest_RandomIntegerInRange(-1024, 1024); + rectA.w = SDLTest_RandomIntegerInRange(1, 1024); + rectA.h = SDLTest_RandomIntegerInRange(1, 1024); + rectB.x = SDLTest_RandomIntegerInRange(-1024, 1024); + rectB.y = SDLTest_RandomIntegerInRange(-1024, 1024); + rectB.w = SDLTest_RandomIntegerInRange(1, 1024); + rectB.h = SDLTest_RandomIntegerInRange(1, 1024); /* invalid parameter combinations */ result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)&rectB); @@ -1656,10 +1651,10 @@ int rect_testFRectEquals(void *arg) SDL_bool result; /* Equals */ - refRectA.x=(float)SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.y=(float)SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.w=(float)SDLTest_RandomIntegerInRange(1, 1024); - refRectA.h=(float)SDLTest_RandomIntegerInRange(1, 1024); + refRectA.x = (float)SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.y = (float)SDLTest_RandomIntegerInRange(-1024, 1024); + refRectA.w = (float)SDLTest_RandomIntegerInRange(1, 1024); + refRectA.h = (float)SDLTest_RandomIntegerInRange(1, 1024); refRectB = refRectA; expectedResult = SDL_TRUE; rectA = refRectA; @@ -1683,14 +1678,14 @@ int rect_testFRectEqualsParam(void *arg) SDL_bool result; /* data setup -- For the purpose of this test, the values don't matter. */ - rectA.x=SDLTest_RandomFloat(); - rectA.y=SDLTest_RandomFloat(); - rectA.w=SDLTest_RandomFloat(); - rectA.h=SDLTest_RandomFloat(); - rectB.x=SDLTest_RandomFloat(); - rectB.y=SDLTest_RandomFloat(); - rectB.w=SDLTest_RandomFloat(); - rectB.h=SDLTest_RandomFloat(); + rectA.x = SDLTest_RandomFloat(); + rectA.y = SDLTest_RandomFloat(); + rectA.w = SDLTest_RandomFloat(); + rectA.h = SDLTest_RandomFloat(); + rectB.x = SDLTest_RandomFloat(); + rectB.y = SDLTest_RandomFloat(); + rectB.w = SDLTest_RandomFloat(); + rectB.h = SDLTest_RandomFloat(); /* invalid parameter combinations */ result = (SDL_bool)SDL_FRectEquals((const SDL_FRect *)NULL, (const SDL_FRect *)&rectB); @@ -1708,107 +1703,138 @@ int rect_testFRectEqualsParam(void *arg) /* Rect test cases */ /* SDL_IntersectRectAndLine */ -static const SDLTest_TestCaseReference rectTest1 = - { (SDLTest_TestCaseFp)rect_testIntersectRectAndLine,"rect_testIntersectRectAndLine", "Tests SDL_IntersectRectAndLine clipping cases", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest1 = { + (SDLTest_TestCaseFp)rect_testIntersectRectAndLine, "rect_testIntersectRectAndLine", "Tests SDL_IntersectRectAndLine clipping cases", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest2 = - { (SDLTest_TestCaseFp)rect_testIntersectRectAndLineInside, "rect_testIntersectRectAndLineInside", "Tests SDL_IntersectRectAndLine with line fully contained in rect", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest2 = { + (SDLTest_TestCaseFp)rect_testIntersectRectAndLineInside, "rect_testIntersectRectAndLineInside", "Tests SDL_IntersectRectAndLine with line fully contained in rect", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest3 = - { (SDLTest_TestCaseFp)rect_testIntersectRectAndLineOutside, "rect_testIntersectRectAndLineOutside", "Tests SDL_IntersectRectAndLine with line fully outside of rect", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest3 = { + (SDLTest_TestCaseFp)rect_testIntersectRectAndLineOutside, "rect_testIntersectRectAndLineOutside", "Tests SDL_IntersectRectAndLine with line fully outside of rect", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest4 = - { (SDLTest_TestCaseFp)rect_testIntersectRectAndLineEmpty, "rect_testIntersectRectAndLineEmpty", "Tests SDL_IntersectRectAndLine with empty rectangle ", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest4 = { + (SDLTest_TestCaseFp)rect_testIntersectRectAndLineEmpty, "rect_testIntersectRectAndLineEmpty", "Tests SDL_IntersectRectAndLine with empty rectangle ", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest5 = - { (SDLTest_TestCaseFp)rect_testIntersectRectAndLineParam, "rect_testIntersectRectAndLineParam", "Negative tests against SDL_IntersectRectAndLine with invalid parameters", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest5 = { + (SDLTest_TestCaseFp)rect_testIntersectRectAndLineParam, "rect_testIntersectRectAndLineParam", "Negative tests against SDL_IntersectRectAndLine with invalid parameters", TEST_ENABLED +}; /* SDL_IntersectRect */ -static const SDLTest_TestCaseReference rectTest6 = - { (SDLTest_TestCaseFp)rect_testIntersectRectInside, "rect_testIntersectRectInside", "Tests SDL_IntersectRect with B fully contained in A", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest6 = { + (SDLTest_TestCaseFp)rect_testIntersectRectInside, "rect_testIntersectRectInside", "Tests SDL_IntersectRect with B fully contained in A", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest7 = - { (SDLTest_TestCaseFp)rect_testIntersectRectOutside, "rect_testIntersectRectOutside", "Tests SDL_IntersectRect with B fully outside of A", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest7 = { + (SDLTest_TestCaseFp)rect_testIntersectRectOutside, "rect_testIntersectRectOutside", "Tests SDL_IntersectRect with B fully outside of A", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest8 = - { (SDLTest_TestCaseFp)rect_testIntersectRectPartial, "rect_testIntersectRectPartial", "Tests SDL_IntersectRect with B partially intersecting A", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest8 = { + (SDLTest_TestCaseFp)rect_testIntersectRectPartial, "rect_testIntersectRectPartial", "Tests SDL_IntersectRect with B partially intersecting A", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest9 = - { (SDLTest_TestCaseFp)rect_testIntersectRectPoint, "rect_testIntersectRectPoint", "Tests SDL_IntersectRect with 1x1 sized rectangles", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest9 = { + (SDLTest_TestCaseFp)rect_testIntersectRectPoint, "rect_testIntersectRectPoint", "Tests SDL_IntersectRect with 1x1 sized rectangles", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest10 = - { (SDLTest_TestCaseFp)rect_testIntersectRectEmpty, "rect_testIntersectRectEmpty", "Tests SDL_IntersectRect with empty rectangles", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest10 = { + (SDLTest_TestCaseFp)rect_testIntersectRectEmpty, "rect_testIntersectRectEmpty", "Tests SDL_IntersectRect with empty rectangles", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest11 = - { (SDLTest_TestCaseFp)rect_testIntersectRectParam, "rect_testIntersectRectParam", "Negative tests against SDL_IntersectRect with invalid parameters", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest11 = { + (SDLTest_TestCaseFp)rect_testIntersectRectParam, "rect_testIntersectRectParam", "Negative tests against SDL_IntersectRect with invalid parameters", TEST_ENABLED +}; /* SDL_HasIntersection */ -static const SDLTest_TestCaseReference rectTest12 = - { (SDLTest_TestCaseFp)rect_testHasIntersectionInside, "rect_testHasIntersectionInside", "Tests SDL_HasIntersection with B fully contained in A", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest12 = { + (SDLTest_TestCaseFp)rect_testHasIntersectionInside, "rect_testHasIntersectionInside", "Tests SDL_HasIntersection with B fully contained in A", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest13 = - { (SDLTest_TestCaseFp)rect_testHasIntersectionOutside, "rect_testHasIntersectionOutside", "Tests SDL_HasIntersection with B fully outside of A", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest13 = { + (SDLTest_TestCaseFp)rect_testHasIntersectionOutside, "rect_testHasIntersectionOutside", "Tests SDL_HasIntersection with B fully outside of A", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest14 = - { (SDLTest_TestCaseFp)rect_testHasIntersectionPartial,"rect_testHasIntersectionPartial", "Tests SDL_HasIntersection with B partially intersecting A", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest14 = { + (SDLTest_TestCaseFp)rect_testHasIntersectionPartial, "rect_testHasIntersectionPartial", "Tests SDL_HasIntersection with B partially intersecting A", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest15 = - { (SDLTest_TestCaseFp)rect_testHasIntersectionPoint, "rect_testHasIntersectionPoint", "Tests SDL_HasIntersection with 1x1 sized rectangles", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest15 = { + (SDLTest_TestCaseFp)rect_testHasIntersectionPoint, "rect_testHasIntersectionPoint", "Tests SDL_HasIntersection with 1x1 sized rectangles", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest16 = - { (SDLTest_TestCaseFp)rect_testHasIntersectionEmpty, "rect_testHasIntersectionEmpty", "Tests SDL_HasIntersection with empty rectangles", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest16 = { + (SDLTest_TestCaseFp)rect_testHasIntersectionEmpty, "rect_testHasIntersectionEmpty", "Tests SDL_HasIntersection with empty rectangles", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest17 = - { (SDLTest_TestCaseFp)rect_testHasIntersectionParam, "rect_testHasIntersectionParam", "Negative tests against SDL_HasIntersection with invalid parameters", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest17 = { + (SDLTest_TestCaseFp)rect_testHasIntersectionParam, "rect_testHasIntersectionParam", "Negative tests against SDL_HasIntersection with invalid parameters", TEST_ENABLED +}; /* SDL_EnclosePoints */ -static const SDLTest_TestCaseReference rectTest18 = - { (SDLTest_TestCaseFp)rect_testEnclosePoints, "rect_testEnclosePoints", "Tests SDL_EnclosePoints without clipping", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest18 = { + (SDLTest_TestCaseFp)rect_testEnclosePoints, "rect_testEnclosePoints", "Tests SDL_EnclosePoints without clipping", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest19 = - { (SDLTest_TestCaseFp)rect_testEnclosePointsWithClipping, "rect_testEnclosePointsWithClipping", "Tests SDL_EnclosePoints with clipping", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest19 = { + (SDLTest_TestCaseFp)rect_testEnclosePointsWithClipping, "rect_testEnclosePointsWithClipping", "Tests SDL_EnclosePoints with clipping", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest20 = - { (SDLTest_TestCaseFp)rect_testEnclosePointsRepeatedInput, "rect_testEnclosePointsRepeatedInput", "Tests SDL_EnclosePoints with repeated input", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest20 = { + (SDLTest_TestCaseFp)rect_testEnclosePointsRepeatedInput, "rect_testEnclosePointsRepeatedInput", "Tests SDL_EnclosePoints with repeated input", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest21 = - { (SDLTest_TestCaseFp)rect_testEnclosePointsParam, "rect_testEnclosePointsParam", "Negative tests against SDL_EnclosePoints with invalid parameters", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest21 = { + (SDLTest_TestCaseFp)rect_testEnclosePointsParam, "rect_testEnclosePointsParam", "Negative tests against SDL_EnclosePoints with invalid parameters", TEST_ENABLED +}; /* SDL_UnionRect */ -static const SDLTest_TestCaseReference rectTest22 = - { (SDLTest_TestCaseFp)rect_testUnionRectInside, "rect_testUnionRectInside", "Tests SDL_UnionRect where rect B is inside rect A", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest22 = { + (SDLTest_TestCaseFp)rect_testUnionRectInside, "rect_testUnionRectInside", "Tests SDL_UnionRect where rect B is inside rect A", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest23 = - { (SDLTest_TestCaseFp)rect_testUnionRectOutside, "rect_testUnionRectOutside", "Tests SDL_UnionRect where rect B is outside rect A", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest23 = { + (SDLTest_TestCaseFp)rect_testUnionRectOutside, "rect_testUnionRectOutside", "Tests SDL_UnionRect where rect B is outside rect A", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest24 = - { (SDLTest_TestCaseFp)rect_testUnionRectEmpty, "rect_testUnionRectEmpty", "Tests SDL_UnionRect where rect A or rect B are empty", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest24 = { + (SDLTest_TestCaseFp)rect_testUnionRectEmpty, "rect_testUnionRectEmpty", "Tests SDL_UnionRect where rect A or rect B are empty", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest25 = - { (SDLTest_TestCaseFp)rect_testUnionRectParam, "rect_testUnionRectParam", "Negative tests against SDL_UnionRect with invalid parameters", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest25 = { + (SDLTest_TestCaseFp)rect_testUnionRectParam, "rect_testUnionRectParam", "Negative tests against SDL_UnionRect with invalid parameters", TEST_ENABLED +}; /* SDL_RectEmpty */ -static const SDLTest_TestCaseReference rectTest26 = - { (SDLTest_TestCaseFp)rect_testRectEmpty, "rect_testRectEmpty", "Tests SDL_RectEmpty with various inputs", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest26 = { + (SDLTest_TestCaseFp)rect_testRectEmpty, "rect_testRectEmpty", "Tests SDL_RectEmpty with various inputs", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest27 = - { (SDLTest_TestCaseFp)rect_testRectEmptyParam, "rect_testRectEmptyParam", "Negative tests against SDL_RectEmpty with invalid parameters", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest27 = { + (SDLTest_TestCaseFp)rect_testRectEmptyParam, "rect_testRectEmptyParam", "Negative tests against SDL_RectEmpty with invalid parameters", TEST_ENABLED +}; /* SDL_RectEquals */ -static const SDLTest_TestCaseReference rectTest28 = - { (SDLTest_TestCaseFp)rect_testRectEquals, "rect_testRectEquals", "Tests SDL_RectEquals with various inputs", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest28 = { + (SDLTest_TestCaseFp)rect_testRectEquals, "rect_testRectEquals", "Tests SDL_RectEquals with various inputs", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest29 = - { (SDLTest_TestCaseFp)rect_testRectEqualsParam, "rect_testRectEqualsParam", "Negative tests against SDL_RectEquals with invalid parameters", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest29 = { + (SDLTest_TestCaseFp)rect_testRectEqualsParam, "rect_testRectEqualsParam", "Negative tests against SDL_RectEquals with invalid parameters", TEST_ENABLED +}; /* SDL_FRectEquals */ -static const SDLTest_TestCaseReference rectTest30 = - { (SDLTest_TestCaseFp)rect_testFRectEquals, "rect_testFRectEquals", "Tests SDL_FRectEquals with various inputs", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest30 = { + (SDLTest_TestCaseFp)rect_testFRectEquals, "rect_testFRectEquals", "Tests SDL_FRectEquals with various inputs", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rectTest31 = - { (SDLTest_TestCaseFp)rect_testFRectEqualsParam, "rect_testFRectEqualsParam", "Negative tests against SDL_FRectEquals with invalid parameters", TEST_ENABLED }; +static const SDLTest_TestCaseReference rectTest31 = { + (SDLTest_TestCaseFp)rect_testFRectEqualsParam, "rect_testFRectEqualsParam", "Negative tests against SDL_FRectEquals with invalid parameters", TEST_ENABLED +}; /* ! * \brief Sequence of Rect test cases; functions that handle simple rectangles including overlaps and merges. @@ -1816,13 +1842,12 @@ static const SDLTest_TestCaseReference rectTest31 = * \sa * http://wiki.libsdl.org/CategoryRect */ -static const SDLTest_TestCaseReference *rectTests[] = { +static const SDLTest_TestCaseReference *rectTests[] = { &rectTest1, &rectTest2, &rectTest3, &rectTest4, &rectTest5, &rectTest6, &rectTest7, &rectTest8, &rectTest9, &rectTest10, &rectTest11, &rectTest12, &rectTest13, &rectTest14, &rectTest15, &rectTest16, &rectTest17, &rectTest18, &rectTest19, &rectTest20, &rectTest21, &rectTest22, &rectTest23, &rectTest24, &rectTest25, &rectTest26, &rectTest27, &rectTest28, &rectTest29, &rectTest30, &rectTest31, NULL }; - /* Rect test suite (global) */ SDLTest_TestSuiteReference rectTestSuite = { "Rect", diff --git a/test/testautomation_render.c b/test/testautomation_render.c index 6989a022f..74b963146 100644 --- a/test/testautomation_render.c +++ b/test/testautomation_render.c @@ -10,14 +10,14 @@ /* ================= Test Case Implementation ================== */ -#define TESTRENDER_SCREEN_W 80 -#define TESTRENDER_SCREEN_H 60 +#define TESTRENDER_SCREEN_W 80 +#define TESTRENDER_SCREEN_H 60 -#define RENDER_COMPARE_FORMAT SDL_PIXELFORMAT_ARGB8888 -#define RENDER_COMPARE_AMASK 0xff000000 /**< Alpha bit mask. */ -#define RENDER_COMPARE_RMASK 0x00ff0000 /**< Red bit mask. */ -#define RENDER_COMPARE_GMASK 0x0000ff00 /**< Green bit mask. */ -#define RENDER_COMPARE_BMASK 0x000000ff /**< Blue bit mask. */ +#define RENDER_COMPARE_FORMAT SDL_PIXELFORMAT_ARGB8888 +#define RENDER_COMPARE_AMASK 0xff000000 /**< Alpha bit mask. */ +#define RENDER_COMPARE_RMASK 0x00ff0000 /**< Red bit mask. */ +#define RENDER_COMPARE_GMASK 0x0000ff00 /**< Green bit mask. */ +#define RENDER_COMPARE_BMASK 0x000000ff /**< Blue bit mask. */ #define ALLOWABLE_ERROR_OPAQUE 0 #define ALLOWABLE_ERROR_BLENDED 64 @@ -28,7 +28,7 @@ SDL_Renderer *renderer = NULL; /* Prototypes for helper functions */ -static int _clearScreen (void); +static int _clearScreen(void); static void _compare(SDL_Surface *reference, int allowable_error); static int _hasTexAlpha(void); static int _hasTexColor(void); @@ -42,22 +42,22 @@ static int _isSupported(int code); */ void InitCreateRenderer(void *arg) { - int posX = 100, posY = 100, width = 320, height = 240; - renderer = NULL; - window = SDL_CreateWindow("render_testCreateRenderer", posX, posY, width, height, 0); - SDLTest_AssertPass("SDL_CreateWindow()"); - SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result"); - if (window == NULL) { - return; - } + int posX = 100, posY = 100, width = 320, height = 240; + renderer = NULL; + window = SDL_CreateWindow("render_testCreateRenderer", posX, posY, width, height, 0); + SDLTest_AssertPass("SDL_CreateWindow()"); + SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result"); + if (window == NULL) { + return; + } - renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); - SDLTest_AssertPass("SDL_CreateRenderer()"); - SDLTest_AssertCheck(renderer != NULL, "Check SDL_CreateRenderer result"); - if (renderer == NULL) { - SDL_DestroyWindow(window); - return; - } + renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); + SDLTest_AssertPass("SDL_CreateRenderer()"); + SDLTest_AssertCheck(renderer != NULL, "Check SDL_CreateRenderer result"); + if (renderer == NULL) { + SDL_DestroyWindow(window); + return; + } } /* @@ -65,36 +65,33 @@ void InitCreateRenderer(void *arg) */ void CleanupDestroyRenderer(void *arg) { - if (renderer != NULL) { - SDL_DestroyRenderer(renderer); - renderer = NULL; - SDLTest_AssertPass("SDL_DestroyRenderer()"); - } + if (renderer != NULL) { + SDL_DestroyRenderer(renderer); + renderer = NULL; + SDLTest_AssertPass("SDL_DestroyRenderer()"); + } - if (window != NULL) { - SDL_DestroyWindow(window); - window = NULL; - SDLTest_AssertPass("SDL_DestroyWindow"); - } + if (window != NULL) { + SDL_DestroyWindow(window); + window = NULL; + SDLTest_AssertPass("SDL_DestroyWindow"); + } } - /** * @brief Tests call to SDL_GetNumRenderDrivers * * \sa * http://wiki.libsdl.org/SDL_GetNumRenderDrivers */ -int -render_testGetNumRenderDrivers(void *arg) +int render_testGetNumRenderDrivers(void *arg) { - int n; - n = SDL_GetNumRenderDrivers(); - SDLTest_AssertCheck(n >= 1, "Number of renderers >= 1, reported as %i", n); - return TEST_COMPLETED; + int n; + n = SDL_GetNumRenderDrivers(); + SDLTest_AssertCheck(n >= 1, "Number of renderers >= 1, reported as %i", n); + return TEST_COMPLETED; } - /** * @brief Tests the SDL primitives for rendering. * @@ -104,106 +101,106 @@ render_testGetNumRenderDrivers(void *arg) * http://wiki.libsdl.org/SDL_RenderDrawLine * */ -int render_testPrimitives (void *arg) +int render_testPrimitives(void *arg) { - int ret; - int x, y; - SDL_Rect rect; - SDL_Surface *referenceSurface = NULL; - int checkFailCount1; - int checkFailCount2; + int ret; + int x, y; + SDL_Rect rect; + SDL_Surface *referenceSurface = NULL; + int checkFailCount1; + int checkFailCount2; - /* Clear surface. */ - _clearScreen(); + /* Clear surface. */ + _clearScreen(); - /* Need drawcolor or just skip test. */ - SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor"); + /* Need drawcolor or just skip test. */ + SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor"); - /* Draw a rectangle. */ - rect.x = 40; - rect.y = 0; - rect.w = 40; - rect.h = 80; + /* Draw a rectangle. */ + rect.x = 40; + rect.y = 0; + rect.w = 40; + rect.h = 80; - ret = SDL_SetRenderDrawColor(renderer, 13, 73, 200, SDL_ALPHA_OPAQUE ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); + ret = SDL_SetRenderDrawColor(renderer, 13, 73, 200, SDL_ALPHA_OPAQUE); + SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); - ret = SDL_RenderFillRect(renderer, &rect ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret); + ret = SDL_RenderFillRect(renderer, &rect); + SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret); - /* Draw a rectangle. */ - rect.x = 10; - rect.y = 10; - rect.w = 60; - rect.h = 40; - ret = SDL_SetRenderDrawColor(renderer, 200, 0, 100, SDL_ALPHA_OPAQUE ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); + /* Draw a rectangle. */ + rect.x = 10; + rect.y = 10; + rect.w = 60; + rect.h = 40; + ret = SDL_SetRenderDrawColor(renderer, 200, 0, 100, SDL_ALPHA_OPAQUE); + SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); - ret = SDL_RenderFillRect(renderer, &rect ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret); + ret = SDL_RenderFillRect(renderer, &rect); + SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret); - /* Draw some points like so: - * X.X.X.X.. - * .X.X.X.X. - * X.X.X.X.. */ - checkFailCount1 = 0; - checkFailCount2 = 0; - for (y=0; y<3; y++) { - for (x = y % 2; x @@ -21,9 +21,9 @@ /* ================= Test Case Implementation ================== */ -const char* RWopsReadTestFilename = "rwops_read"; -const char* RWopsWriteTestFilename = "rwops_write"; -const char* RWopsAlphabetFilename = "rwops_alphabet"; +const char *RWopsReadTestFilename = "rwops_read"; +const char *RWopsWriteTestFilename = "rwops_write"; +const char *RWopsAlphabetFilename = "rwops_alphabet"; static const char RWopsHelloWorldTestString[] = "Hello World!"; static const char RWopsHelloWorldCompString[] = "Hello World!"; @@ -31,8 +31,7 @@ static const char RWopsAlphabetString[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; /* Fixture */ -void -RWopsSetUp(void *arg) +void RWopsSetUp(void *arg) { size_t fileLen; FILE *handle; @@ -47,36 +46,35 @@ RWopsSetUp(void *arg) /* Create a test file */ handle = fopen(RWopsReadTestFilename, "w"); SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsReadTestFilename); - if (handle == NULL) { - return; + if (handle == NULL) { + return; } /* Write some known text into it */ fileLen = SDL_strlen(RWopsHelloWorldTestString); writtenLen = fwrite(RWopsHelloWorldTestString, 1, fileLen, handle); - SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", (int) fileLen, (int) writtenLen); + SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", (int)fileLen, (int)writtenLen); result = fclose(handle); SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result); /* Create a second test file */ handle = fopen(RWopsAlphabetFilename, "w"); SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsAlphabetFilename); - if (handle == NULL) { - return; + if (handle == NULL) { + return; } /* Write alphabet text into it */ fileLen = SDL_strlen(RWopsAlphabetString); writtenLen = fwrite(RWopsAlphabetString, 1, fileLen, handle); - SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", (int) fileLen, (int) writtenLen); + SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", (int)fileLen, (int)writtenLen); result = fclose(handle); SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result); SDLTest_AssertPass("Creation of test file completed"); } -void -RWopsTearDown(void *arg) +void RWopsTearDown(void *arg) { int result; @@ -97,77 +95,76 @@ RWopsTearDown(void *arg) * http://wiki.libsdl.org/SDL_RWseek * http://wiki.libsdl.org/SDL_RWread */ -void -_testGenericRWopsValidations(SDL_RWops *rw, int write) +void _testGenericRWopsValidations(SDL_RWops *rw, int write) { - char buf[sizeof(RWopsHelloWorldTestString)]; - Sint64 i; - size_t s; - int seekPos = SDLTest_RandomIntegerInRange(4, 8); + char buf[sizeof(RWopsHelloWorldTestString)]; + Sint64 i; + size_t s; + int seekPos = SDLTest_RandomIntegerInRange(4, 8); - /* Clear buffer */ - SDL_zeroa(buf); + /* Clear buffer */ + SDL_zeroa(buf); - /* Set to start. */ - i = SDL_RWseek(rw, 0, RW_SEEK_SET ); - SDLTest_AssertPass("Call to SDL_RWseek succeeded"); - SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %"SDL_PRIs64, i); + /* Set to start. */ + i = SDL_RWseek(rw, 0, RW_SEEK_SET); + SDLTest_AssertPass("Call to SDL_RWseek succeeded"); + SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %" SDL_PRIs64, i); - /* Test write. */ - s = SDL_RWwrite(rw, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1, 1); - SDLTest_AssertPass("Call to SDL_RWwrite succeeded"); - if (write) { - SDLTest_AssertCheck(s == (size_t)1, "Verify result of writing one byte with SDL_RWwrite, expected 1, got %i", (int) s); - } else { - SDLTest_AssertCheck(s == (size_t)0, "Verify result of writing with SDL_RWwrite, expected: 0, got %i", (int) s); - } + /* Test write. */ + s = SDL_RWwrite(rw, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString) - 1, 1); + SDLTest_AssertPass("Call to SDL_RWwrite succeeded"); + if (write) { + SDLTest_AssertCheck(s == (size_t)1, "Verify result of writing one byte with SDL_RWwrite, expected 1, got %i", (int)s); + } else { + SDLTest_AssertCheck(s == (size_t)0, "Verify result of writing with SDL_RWwrite, expected: 0, got %i", (int)s); + } - /* Test seek to random position */ - i = SDL_RWseek( rw, seekPos, RW_SEEK_SET ); - SDLTest_AssertPass("Call to SDL_RWseek succeeded"); - SDLTest_AssertCheck(i == (Sint64)seekPos, "Verify seek to %i with SDL_RWseek (RW_SEEK_SET), expected %i, got %"SDL_PRIs64, seekPos, seekPos, i); + /* Test seek to random position */ + i = SDL_RWseek(rw, seekPos, RW_SEEK_SET); + SDLTest_AssertPass("Call to SDL_RWseek succeeded"); + SDLTest_AssertCheck(i == (Sint64)seekPos, "Verify seek to %i with SDL_RWseek (RW_SEEK_SET), expected %i, got %" SDL_PRIs64, seekPos, seekPos, i); - /* Test seek back to start */ - i = SDL_RWseek(rw, 0, RW_SEEK_SET ); - SDLTest_AssertPass("Call to SDL_RWseek succeeded"); - SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %"SDL_PRIs64, i); + /* Test seek back to start */ + i = SDL_RWseek(rw, 0, RW_SEEK_SET); + SDLTest_AssertPass("Call to SDL_RWseek succeeded"); + SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %" SDL_PRIs64, i); - /* Test read */ - s = SDL_RWread( rw, buf, 1, sizeof(RWopsHelloWorldTestString)-1 ); - SDLTest_AssertPass("Call to SDL_RWread succeeded"); - SDLTest_AssertCheck( - s == (size_t)(sizeof(RWopsHelloWorldTestString)-1), - "Verify result from SDL_RWread, expected %i, got %i", - (int) (sizeof(RWopsHelloWorldTestString)-1), - (int) s); - SDLTest_AssertCheck( - SDL_memcmp(buf, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1 ) == 0, - "Verify read bytes match expected string, expected '%s', got '%s'", RWopsHelloWorldTestString, buf); + /* Test read */ + s = SDL_RWread(rw, buf, 1, sizeof(RWopsHelloWorldTestString) - 1); + SDLTest_AssertPass("Call to SDL_RWread succeeded"); + SDLTest_AssertCheck( + s == (size_t)(sizeof(RWopsHelloWorldTestString) - 1), + "Verify result from SDL_RWread, expected %i, got %i", + (int)(sizeof(RWopsHelloWorldTestString) - 1), + (int)s); + SDLTest_AssertCheck( + SDL_memcmp(buf, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString) - 1) == 0, + "Verify read bytes match expected string, expected '%s', got '%s'", RWopsHelloWorldTestString, buf); - /* More seek tests. */ - i = SDL_RWseek( rw, -4, RW_SEEK_CUR ); - SDLTest_AssertPass("Call to SDL_RWseek(...,-4,RW_SEEK_CUR) succeeded"); - SDLTest_AssertCheck( - i == (Sint64)(sizeof(RWopsHelloWorldTestString)-5), - "Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %i", - (int) (sizeof(RWopsHelloWorldTestString)-5), - (int) i); + /* More seek tests. */ + i = SDL_RWseek(rw, -4, RW_SEEK_CUR); + SDLTest_AssertPass("Call to SDL_RWseek(...,-4,RW_SEEK_CUR) succeeded"); + SDLTest_AssertCheck( + i == (Sint64)(sizeof(RWopsHelloWorldTestString) - 5), + "Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %i", + (int)(sizeof(RWopsHelloWorldTestString) - 5), + (int)i); - i = SDL_RWseek( rw, -1, RW_SEEK_END ); - SDLTest_AssertPass("Call to SDL_RWseek(...,-1,RW_SEEK_END) succeeded"); - SDLTest_AssertCheck( - i == (Sint64)(sizeof(RWopsHelloWorldTestString)-2), - "Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %i", - (int) (sizeof(RWopsHelloWorldTestString)-2), - (int) i); + i = SDL_RWseek(rw, -1, RW_SEEK_END); + SDLTest_AssertPass("Call to SDL_RWseek(...,-1,RW_SEEK_END) succeeded"); + SDLTest_AssertCheck( + i == (Sint64)(sizeof(RWopsHelloWorldTestString) - 2), + "Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %i", + (int)(sizeof(RWopsHelloWorldTestString) - 2), + (int)i); - /* Invalid whence seek */ - i = SDL_RWseek( rw, 0, 999 ); - SDLTest_AssertPass("Call to SDL_RWseek(...,0,invalid_whence) succeeded"); - SDLTest_AssertCheck( - i == (Sint64)(-1), - "Verify seek with SDL_RWseek (invalid_whence); expected: -1, got %i", - (int) i); + /* Invalid whence seek */ + i = SDL_RWseek(rw, 0, 999); + SDLTest_AssertPass("Call to SDL_RWseek(...,0,invalid_whence) succeeded"); + SDLTest_AssertCheck( + i == (Sint64)(-1), + "Verify seek with SDL_RWseek (invalid_whence); expected: -1, got %i", + (int)i); } /* ! @@ -176,45 +173,44 @@ _testGenericRWopsValidations(SDL_RWops *rw, int write) * \sa http://wiki.libsdl.org/SDL_RWFromFile * */ -int -rwops_testParamNegative (void) +int rwops_testParamNegative(void) { - SDL_RWops *rwops; + SDL_RWops *rwops; - /* These should all fail. */ - rwops = SDL_RWFromFile(NULL, NULL); - SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, NULL) succeeded"); - SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, NULL) returns NULL"); + /* These should all fail. */ + rwops = SDL_RWFromFile(NULL, NULL); + SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, NULL) succeeded"); + SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, NULL) returns NULL"); - rwops = SDL_RWFromFile(NULL, "ab+"); - SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, \"ab+\") succeeded"); - SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, \"ab+\") returns NULL"); + rwops = SDL_RWFromFile(NULL, "ab+"); + SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, \"ab+\") succeeded"); + SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, \"ab+\") returns NULL"); - rwops = SDL_RWFromFile(NULL, "sldfkjsldkfj"); - SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, \"sldfkjsldkfj\") succeeded"); - SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, \"sldfkjsldkfj\") returns NULL"); + rwops = SDL_RWFromFile(NULL, "sldfkjsldkfj"); + SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, \"sldfkjsldkfj\") succeeded"); + SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, \"sldfkjsldkfj\") returns NULL"); - rwops = SDL_RWFromFile("something", ""); - SDLTest_AssertPass("Call to SDL_RWFromFile(\"something\", \"\") succeeded"); - SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(\"something\", \"\") returns NULL"); + rwops = SDL_RWFromFile("something", ""); + SDLTest_AssertPass("Call to SDL_RWFromFile(\"something\", \"\") succeeded"); + SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(\"something\", \"\") returns NULL"); - rwops = SDL_RWFromFile("something", NULL); - SDLTest_AssertPass("Call to SDL_RWFromFile(\"something\", NULL) succeeded"); - SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(\"something\", NULL) returns NULL"); + rwops = SDL_RWFromFile("something", NULL); + SDLTest_AssertPass("Call to SDL_RWFromFile(\"something\", NULL) succeeded"); + SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(\"something\", NULL) returns NULL"); - rwops = SDL_RWFromMem((void *)NULL, 10); - SDLTest_AssertPass("Call to SDL_RWFromMem(NULL, 10) succeeded"); - SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromMem(NULL, 10) returns NULL"); + rwops = SDL_RWFromMem((void *)NULL, 10); + SDLTest_AssertPass("Call to SDL_RWFromMem(NULL, 10) succeeded"); + SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromMem(NULL, 10) returns NULL"); - rwops = SDL_RWFromMem((void *)RWopsAlphabetString, 0); - SDLTest_AssertPass("Call to SDL_RWFromMem(data, 0) succeeded"); - SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromMem(data, 0) returns NULL"); + rwops = SDL_RWFromMem((void *)RWopsAlphabetString, 0); + SDLTest_AssertPass("Call to SDL_RWFromMem(data, 0) succeeded"); + SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromMem(data, 0) returns NULL"); - rwops = SDL_RWFromConstMem((const void *)RWopsAlphabetString, 0); - SDLTest_AssertPass("Call to SDL_RWFromConstMem(data, 0) succeeded"); - SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromConstMem(data, 0) returns NULL"); + rwops = SDL_RWFromConstMem((const void *)RWopsAlphabetString, 0); + SDLTest_AssertPass("Call to SDL_RWFromConstMem(data, 0) succeeded"); + SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromConstMem(data, 0) returns NULL"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -223,41 +219,39 @@ rwops_testParamNegative (void) * \sa http://wiki.libsdl.org/SDL_RWFromMem * \sa http://wiki.libsdl.org/SDL_RWClose */ -int -rwops_testMem (void) +int rwops_testMem(void) { - char mem[sizeof(RWopsHelloWorldTestString)]; - SDL_RWops *rw; - int result; + char mem[sizeof(RWopsHelloWorldTestString)]; + SDL_RWops *rw; + int result; - /* Clear buffer */ - SDL_zeroa(mem); + /* Clear buffer */ + SDL_zeroa(mem); - /* Open */ - rw = SDL_RWFromMem(mem, sizeof(RWopsHelloWorldTestString)-1); - SDLTest_AssertPass("Call to SDL_RWFromMem() succeeded"); - SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromMem does not return NULL"); + /* Open */ + rw = SDL_RWFromMem(mem, sizeof(RWopsHelloWorldTestString) - 1); + SDLTest_AssertPass("Call to SDL_RWFromMem() succeeded"); + SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromMem does not return NULL"); - /* Bail out if NULL */ - if (rw == NULL) { - return TEST_ABORTED; - } + /* Bail out if NULL */ + if (rw == NULL) { + return TEST_ABORTED; + } - /* Check type */ - SDLTest_AssertCheck(rw->type == SDL_RWOPS_MEMORY, "Verify RWops type is SDL_RWOPS_MEMORY; expected: %d, got: %" SDL_PRIu32, SDL_RWOPS_MEMORY, rw->type); + /* Check type */ + SDLTest_AssertCheck(rw->type == SDL_RWOPS_MEMORY, "Verify RWops type is SDL_RWOPS_MEMORY; expected: %d, got: %" SDL_PRIu32, SDL_RWOPS_MEMORY, rw->type); - /* Run generic tests */ - _testGenericRWopsValidations(rw, 1); + /* Run generic tests */ + _testGenericRWopsValidations(rw, 1); - /* Close */ - result = SDL_RWclose(rw); - SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); - SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); + /* Close */ + result = SDL_RWclose(rw); + SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); + SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); - return TEST_COMPLETED; + return TEST_COMPLETED; } - /** * @brief Tests opening from memory. * @@ -265,37 +259,35 @@ rwops_testMem (void) * http://wiki.libsdl.org/SDL_RWFromConstMem * http://wiki.libsdl.org/SDL_RWClose */ -int -rwops_testConstMem (void) +int rwops_testConstMem(void) { - SDL_RWops *rw; - int result; + SDL_RWops *rw; + int result; - /* Open handle */ - rw = SDL_RWFromConstMem( RWopsHelloWorldCompString, sizeof(RWopsHelloWorldCompString)-1 ); - SDLTest_AssertPass("Call to SDL_RWFromConstMem() succeeded"); - SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromConstMem does not return NULL"); + /* Open handle */ + rw = SDL_RWFromConstMem(RWopsHelloWorldCompString, sizeof(RWopsHelloWorldCompString) - 1); + SDLTest_AssertPass("Call to SDL_RWFromConstMem() succeeded"); + SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromConstMem does not return NULL"); - /* Bail out if NULL */ - if (rw == NULL) { - return TEST_ABORTED; - } + /* Bail out if NULL */ + if (rw == NULL) { + return TEST_ABORTED; + } - /* Check type */ - SDLTest_AssertCheck(rw->type == SDL_RWOPS_MEMORY_RO, "Verify RWops type is SDL_RWOPS_MEMORY_RO; expected: %d, got: %" SDL_PRIu32, SDL_RWOPS_MEMORY_RO, rw->type); + /* Check type */ + SDLTest_AssertCheck(rw->type == SDL_RWOPS_MEMORY_RO, "Verify RWops type is SDL_RWOPS_MEMORY_RO; expected: %d, got: %" SDL_PRIu32, SDL_RWOPS_MEMORY_RO, rw->type); - /* Run generic tests */ - _testGenericRWopsValidations( rw, 0 ); + /* Run generic tests */ + _testGenericRWopsValidations(rw, 0); - /* Close handle */ - result = SDL_RWclose(rw); - SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); - SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); + /* Close handle */ + result = SDL_RWclose(rw); + SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); + SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); - return TEST_COMPLETED; + return TEST_COMPLETED; } - /** * @brief Tests reading from file. * @@ -303,46 +295,45 @@ rwops_testConstMem (void) * http://wiki.libsdl.org/SDL_RWFromFile * http://wiki.libsdl.org/SDL_RWClose */ -int -rwops_testFileRead(void) +int rwops_testFileRead(void) { - SDL_RWops *rw; - int result; + SDL_RWops *rw; + int result; - /* Read test. */ - rw = SDL_RWFromFile(RWopsReadTestFilename, "r"); - SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"r\") succeeded"); - SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in read mode does not return NULL"); + /* Read test. */ + rw = SDL_RWFromFile(RWopsReadTestFilename, "r"); + SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"r\") succeeded"); + SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in read mode does not return NULL"); - /* Bail out if NULL */ - if (rw == NULL) { - return TEST_ABORTED; - } + /* Bail out if NULL */ + if (rw == NULL) { + return TEST_ABORTED; + } - /* Check type */ + /* Check type */ #if defined(__ANDROID__) - SDLTest_AssertCheck( - rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE, - "Verify RWops type is SDL_RWOPS_STDFILE or SDL_RWOPS_JNIFILE; expected: %d|%d, got: %d", SDL_RWOPS_STDFILE, SDL_RWOPS_JNIFILE, rw->type); + SDLTest_AssertCheck( + rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE, + "Verify RWops type is SDL_RWOPS_STDFILE or SDL_RWOPS_JNIFILE; expected: %d|%d, got: %d", SDL_RWOPS_STDFILE, SDL_RWOPS_JNIFILE, rw->type); #elif defined(__WIN32__) - SDLTest_AssertCheck( - rw->type == SDL_RWOPS_WINFILE, - "Verify RWops type is SDL_RWOPS_WINFILE; expected: %d, got: %d", SDL_RWOPS_WINFILE, rw->type); + SDLTest_AssertCheck( + rw->type == SDL_RWOPS_WINFILE, + "Verify RWops type is SDL_RWOPS_WINFILE; expected: %d, got: %d", SDL_RWOPS_WINFILE, rw->type); #else - SDLTest_AssertCheck( - rw->type == SDL_RWOPS_STDFILE, - "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %" SDL_PRIu32, SDL_RWOPS_STDFILE, rw->type); + SDLTest_AssertCheck( + rw->type == SDL_RWOPS_STDFILE, + "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %" SDL_PRIu32, SDL_RWOPS_STDFILE, rw->type); #endif - /* Run generic tests */ - _testGenericRWopsValidations( rw, 0 ); + /* Run generic tests */ + _testGenericRWopsValidations(rw, 0); - /* Close handle */ - result = SDL_RWclose(rw); - SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); - SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); + /* Close handle */ + result = SDL_RWclose(rw); + SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); + SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -352,49 +343,47 @@ rwops_testFileRead(void) * http://wiki.libsdl.org/SDL_RWFromFile * http://wiki.libsdl.org/SDL_RWClose */ -int -rwops_testFileWrite(void) +int rwops_testFileWrite(void) { - SDL_RWops *rw; - int result; + SDL_RWops *rw; + int result; - /* Write test. */ - rw = SDL_RWFromFile(RWopsWriteTestFilename, "w+"); - SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"w+\") succeeded"); - SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in write mode does not return NULL"); + /* Write test. */ + rw = SDL_RWFromFile(RWopsWriteTestFilename, "w+"); + SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"w+\") succeeded"); + SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in write mode does not return NULL"); - /* Bail out if NULL */ - if (rw == NULL) { - return TEST_ABORTED; - } + /* Bail out if NULL */ + if (rw == NULL) { + return TEST_ABORTED; + } - /* Check type */ + /* Check type */ #if defined(__ANDROID__) - SDLTest_AssertCheck( - rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE, - "Verify RWops type is SDL_RWOPS_STDFILE or SDL_RWOPS_JNIFILE; expected: %d|%d, got: %d", SDL_RWOPS_STDFILE, SDL_RWOPS_JNIFILE, rw->type); + SDLTest_AssertCheck( + rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE, + "Verify RWops type is SDL_RWOPS_STDFILE or SDL_RWOPS_JNIFILE; expected: %d|%d, got: %d", SDL_RWOPS_STDFILE, SDL_RWOPS_JNIFILE, rw->type); #elif defined(__WIN32__) - SDLTest_AssertCheck( - rw->type == SDL_RWOPS_WINFILE, - "Verify RWops type is SDL_RWOPS_WINFILE; expected: %d, got: %d", SDL_RWOPS_WINFILE, rw->type); + SDLTest_AssertCheck( + rw->type == SDL_RWOPS_WINFILE, + "Verify RWops type is SDL_RWOPS_WINFILE; expected: %d, got: %d", SDL_RWOPS_WINFILE, rw->type); #else - SDLTest_AssertCheck( - rw->type == SDL_RWOPS_STDFILE, - "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %" SDL_PRIu32, SDL_RWOPS_STDFILE, rw->type); + SDLTest_AssertCheck( + rw->type == SDL_RWOPS_STDFILE, + "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %" SDL_PRIu32, SDL_RWOPS_STDFILE, rw->type); #endif - /* Run generic tests */ - _testGenericRWopsValidations( rw, 1 ); + /* Run generic tests */ + _testGenericRWopsValidations(rw, 1); - /* Close handle */ - result = SDL_RWclose(rw); - SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); - SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); + /* Close handle */ + result = SDL_RWclose(rw); + SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); + SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); - return TEST_COMPLETED; + return TEST_COMPLETED; } - /** * @brief Tests reading from file handle * @@ -506,27 +495,26 @@ rwops_testFPWrite(void) * \sa http://wiki.libsdl.org/SDL_AllocRW * \sa http://wiki.libsdl.org/SDL_FreeRW */ -int -rwops_testAllocFree (void) +int rwops_testAllocFree(void) { - /* Allocate context */ - SDL_RWops *rw = SDL_AllocRW(); - SDLTest_AssertPass("Call to SDL_AllocRW() succeeded"); - SDLTest_AssertCheck(rw != NULL, "Validate result from SDL_AllocRW() is not NULL"); - if (rw == NULL) { - return TEST_ABORTED; - } + /* Allocate context */ + SDL_RWops *rw = SDL_AllocRW(); + SDLTest_AssertPass("Call to SDL_AllocRW() succeeded"); + SDLTest_AssertCheck(rw != NULL, "Validate result from SDL_AllocRW() is not NULL"); + if (rw == NULL) { + return TEST_ABORTED; + } - /* Check type */ - SDLTest_AssertCheck( - rw->type == SDL_RWOPS_UNKNOWN, - "Verify RWops type is SDL_RWOPS_UNKNOWN; expected: %d, got: %" SDL_PRIu32, SDL_RWOPS_UNKNOWN, rw->type); + /* Check type */ + SDLTest_AssertCheck( + rw->type == SDL_RWOPS_UNKNOWN, + "Verify RWops type is SDL_RWOPS_UNKNOWN; expected: %d, got: %" SDL_PRIu32, SDL_RWOPS_UNKNOWN, rw->type); - /* Free context again */ - SDL_FreeRW(rw); - SDLTest_AssertPass("Call to SDL_FreeRW() succeeded"); + /* Free context again */ + SDL_FreeRW(rw); + SDLTest_AssertPass("Call to SDL_FreeRW() succeeded"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -535,63 +523,61 @@ rwops_testAllocFree (void) * \sa http://wiki.libsdl.org/SDL_RWFromMem * \sa http://wiki.libsdl.org/SDL_RWFromFile */ -int -rwops_testCompareRWFromMemWithRWFromFile(void) +int rwops_testCompareRWFromMemWithRWFromFile(void) { - int slen = 26; - char buffer_file[27]; - char buffer_mem[27]; - size_t rv_file; - size_t rv_mem; - Uint64 sv_file; - Uint64 sv_mem; - SDL_RWops* rwops_file; - SDL_RWops* rwops_mem; - int size; - int result; + int slen = 26; + char buffer_file[27]; + char buffer_mem[27]; + size_t rv_file; + size_t rv_mem; + Uint64 sv_file; + Uint64 sv_mem; + SDL_RWops *rwops_file; + SDL_RWops *rwops_mem; + int size; + int result; + for (size = 5; size < 10; size++) { + /* Terminate buffer */ + buffer_file[slen] = 0; + buffer_mem[slen] = 0; - for (size=5; size<10; size++) { - /* Terminate buffer */ - buffer_file[slen] = 0; - buffer_mem[slen] = 0; + /* Read/seek from memory */ + rwops_mem = SDL_RWFromMem((void *)RWopsAlphabetString, slen); + SDLTest_AssertPass("Call to SDL_RWFromMem()"); + rv_mem = SDL_RWread(rwops_mem, buffer_mem, size, 6); + SDLTest_AssertPass("Call to SDL_RWread(mem, size=%d)", size); + sv_mem = SDL_RWseek(rwops_mem, 0, SEEK_END); + SDLTest_AssertPass("Call to SDL_RWseek(mem,SEEK_END)"); + result = SDL_RWclose(rwops_mem); + SDLTest_AssertPass("Call to SDL_RWclose(mem)"); + SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); - /* Read/seek from memory */ - rwops_mem = SDL_RWFromMem((void *)RWopsAlphabetString, slen); - SDLTest_AssertPass("Call to SDL_RWFromMem()"); - rv_mem = SDL_RWread(rwops_mem, buffer_mem, size, 6); - SDLTest_AssertPass("Call to SDL_RWread(mem, size=%d)", size); - sv_mem = SDL_RWseek(rwops_mem, 0, SEEK_END); - SDLTest_AssertPass("Call to SDL_RWseek(mem,SEEK_END)"); - result = SDL_RWclose(rwops_mem); - SDLTest_AssertPass("Call to SDL_RWclose(mem)"); - SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); + /* Read/see from file */ + rwops_file = SDL_RWFromFile(RWopsAlphabetFilename, "r"); + SDLTest_AssertPass("Call to SDL_RWFromFile()"); + rv_file = SDL_RWread(rwops_file, buffer_file, size, 6); + SDLTest_AssertPass("Call to SDL_RWread(file, size=%d)", size); + sv_file = SDL_RWseek(rwops_file, 0, SEEK_END); + SDLTest_AssertPass("Call to SDL_RWseek(file,SEEK_END)"); + result = SDL_RWclose(rwops_file); + SDLTest_AssertPass("Call to SDL_RWclose(file)"); + SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); - /* Read/see from file */ - rwops_file = SDL_RWFromFile(RWopsAlphabetFilename, "r"); - SDLTest_AssertPass("Call to SDL_RWFromFile()"); - rv_file = SDL_RWread(rwops_file, buffer_file, size, 6); - SDLTest_AssertPass("Call to SDL_RWread(file, size=%d)", size); - sv_file = SDL_RWseek(rwops_file, 0, SEEK_END); - SDLTest_AssertPass("Call to SDL_RWseek(file,SEEK_END)"); - result = SDL_RWclose(rwops_file); - SDLTest_AssertPass("Call to SDL_RWclose(file)"); - SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); + /* Compare */ + SDLTest_AssertCheck(rv_mem == rv_file, "Verify returned read blocks matches for mem and file reads; got: rv_mem=%d rv_file=%d", (int)rv_mem, (int)rv_file); + SDLTest_AssertCheck(sv_mem == sv_file, "Verify SEEK_END position matches for mem and file seeks; got: sv_mem=%d sv_file=%d", (int)sv_mem, (int)sv_file); + SDLTest_AssertCheck(buffer_mem[slen] == 0, "Verify mem buffer termination; expected: 0, got: %d", buffer_mem[slen]); + SDLTest_AssertCheck(buffer_file[slen] == 0, "Verify file buffer termination; expected: 0, got: %d", buffer_file[slen]); + SDLTest_AssertCheck( + SDL_strncmp(buffer_mem, RWopsAlphabetString, slen) == 0, + "Verify mem buffer contain alphabet string; expected: %s, got: %s", RWopsAlphabetString, buffer_mem); + SDLTest_AssertCheck( + SDL_strncmp(buffer_file, RWopsAlphabetString, slen) == 0, + "Verify file buffer contain alphabet string; expected: %s, got: %s", RWopsAlphabetString, buffer_file); + } - /* Compare */ - SDLTest_AssertCheck(rv_mem == rv_file, "Verify returned read blocks matches for mem and file reads; got: rv_mem=%d rv_file=%d", (int) rv_mem, (int) rv_file); - SDLTest_AssertCheck(sv_mem == sv_file, "Verify SEEK_END position matches for mem and file seeks; got: sv_mem=%d sv_file=%d", (int) sv_mem, (int) sv_file); - SDLTest_AssertCheck(buffer_mem[slen] == 0, "Verify mem buffer termination; expected: 0, got: %d", buffer_mem[slen]); - SDLTest_AssertCheck(buffer_file[slen] == 0, "Verify file buffer termination; expected: 0, got: %d", buffer_file[slen]); - SDLTest_AssertCheck( - SDL_strncmp(buffer_mem, RWopsAlphabetString, slen) == 0, - "Verify mem buffer contain alphabet string; expected: %s, got: %s", RWopsAlphabetString, buffer_mem); - SDLTest_AssertCheck( - SDL_strncmp(buffer_file, RWopsAlphabetString, slen) == 0, - "Verify file buffer contain alphabet string; expected: %s, got: %s", RWopsAlphabetString, buffer_file); - } - - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -603,143 +589,146 @@ rwops_testCompareRWFromMemWithRWFromFile(void) * http://wiki.libsdl.org/SDL_ReadBE16 * http://wiki.libsdl.org/SDL_WriteBE16 */ -int -rwops_testFileWriteReadEndian(void) +int rwops_testFileWriteReadEndian(void) { - SDL_RWops *rw; - Sint64 result; - int mode; - size_t objectsWritten; - Uint16 BE16value; - Uint32 BE32value; - Uint64 BE64value; - Uint16 LE16value; - Uint32 LE32value; - Uint64 LE64value; - Uint16 BE16test; - Uint32 BE32test; - Uint64 BE64test; - Uint16 LE16test; - Uint32 LE32test; - Uint64 LE64test; - int cresult; + SDL_RWops *rw; + Sint64 result; + int mode; + size_t objectsWritten; + Uint16 BE16value; + Uint32 BE32value; + Uint64 BE64value; + Uint16 LE16value; + Uint32 LE32value; + Uint64 LE64value; + Uint16 BE16test; + Uint32 BE32test; + Uint64 BE64test; + Uint16 LE16test; + Uint32 LE32test; + Uint64 LE64test; + int cresult; - for (mode = 0; mode < 3; mode++) { + for (mode = 0; mode < 3; mode++) { - /* Create test data */ - switch (mode) { - default: - case 0: - SDLTest_Log("All 0 values"); - BE16value = 0; - BE32value = 0; - BE64value = 0; - LE16value = 0; - LE32value = 0; - LE64value = 0; - break; - case 1: - SDLTest_Log("All 1 values"); - BE16value = 1; - BE32value = 1; - BE64value = 1; - LE16value = 1; - LE32value = 1; - LE64value = 1; - break; - case 2: - SDLTest_Log("Random values"); - BE16value = SDLTest_RandomUint16(); - BE32value = SDLTest_RandomUint32(); - BE64value = SDLTest_RandomUint64(); - LE16value = SDLTest_RandomUint16(); - LE32value = SDLTest_RandomUint32(); - LE64value = SDLTest_RandomUint64(); - break; - } + /* Create test data */ + switch (mode) { + default: + case 0: + SDLTest_Log("All 0 values"); + BE16value = 0; + BE32value = 0; + BE64value = 0; + LE16value = 0; + LE32value = 0; + LE64value = 0; + break; + case 1: + SDLTest_Log("All 1 values"); + BE16value = 1; + BE32value = 1; + BE64value = 1; + LE16value = 1; + LE32value = 1; + LE64value = 1; + break; + case 2: + SDLTest_Log("Random values"); + BE16value = SDLTest_RandomUint16(); + BE32value = SDLTest_RandomUint32(); + BE64value = SDLTest_RandomUint64(); + LE16value = SDLTest_RandomUint16(); + LE32value = SDLTest_RandomUint32(); + LE64value = SDLTest_RandomUint64(); + break; + } - /* Write test. */ - rw = SDL_RWFromFile(RWopsWriteTestFilename, "w+"); - SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"w+\")"); - SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in write mode does not return NULL"); + /* Write test. */ + rw = SDL_RWFromFile(RWopsWriteTestFilename, "w+"); + SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"w+\")"); + SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in write mode does not return NULL"); - /* Bail out if NULL */ - if (rw == NULL) { - return TEST_ABORTED; - } + /* Bail out if NULL */ + if (rw == NULL) { + return TEST_ABORTED; + } - /* Write test data */ - objectsWritten = SDL_WriteBE16(rw, BE16value); - SDLTest_AssertPass("Call to SDL_WriteBE16()"); - SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int) objectsWritten); - objectsWritten = SDL_WriteBE32(rw, BE32value); - SDLTest_AssertPass("Call to SDL_WriteBE32()"); - SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int) objectsWritten); - objectsWritten = SDL_WriteBE64(rw, BE64value); - SDLTest_AssertPass("Call to SDL_WriteBE64()"); - SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int) objectsWritten); - objectsWritten = SDL_WriteLE16(rw, LE16value); - SDLTest_AssertPass("Call to SDL_WriteLE16()"); - SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int) objectsWritten); - objectsWritten = SDL_WriteLE32(rw, LE32value); - SDLTest_AssertPass("Call to SDL_WriteLE32()"); - SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int) objectsWritten); - objectsWritten = SDL_WriteLE64(rw, LE64value); - SDLTest_AssertPass("Call to SDL_WriteLE64()"); - SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int) objectsWritten); + /* Write test data */ + objectsWritten = SDL_WriteBE16(rw, BE16value); + SDLTest_AssertPass("Call to SDL_WriteBE16()"); + SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int)objectsWritten); + objectsWritten = SDL_WriteBE32(rw, BE32value); + SDLTest_AssertPass("Call to SDL_WriteBE32()"); + SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int)objectsWritten); + objectsWritten = SDL_WriteBE64(rw, BE64value); + SDLTest_AssertPass("Call to SDL_WriteBE64()"); + SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int)objectsWritten); + objectsWritten = SDL_WriteLE16(rw, LE16value); + SDLTest_AssertPass("Call to SDL_WriteLE16()"); + SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int)objectsWritten); + objectsWritten = SDL_WriteLE32(rw, LE32value); + SDLTest_AssertPass("Call to SDL_WriteLE32()"); + SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int)objectsWritten); + objectsWritten = SDL_WriteLE64(rw, LE64value); + SDLTest_AssertPass("Call to SDL_WriteLE64()"); + SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int)objectsWritten); - /* Test seek to start */ - result = SDL_RWseek( rw, 0, RW_SEEK_SET ); - SDLTest_AssertPass("Call to SDL_RWseek succeeded"); - SDLTest_AssertCheck(result == 0, "Verify result from position 0 with SDL_RWseek, expected 0, got %i", (int) result); + /* Test seek to start */ + result = SDL_RWseek(rw, 0, RW_SEEK_SET); + SDLTest_AssertPass("Call to SDL_RWseek succeeded"); + SDLTest_AssertCheck(result == 0, "Verify result from position 0 with SDL_RWseek, expected 0, got %i", (int)result); - /* Read test data */ - BE16test = SDL_ReadBE16(rw); - SDLTest_AssertPass("Call to SDL_ReadBE16()"); - SDLTest_AssertCheck(BE16test == BE16value, "Validate return value from SDL_ReadBE16, expected: %hu, got: %hu", BE16value, BE16test); - BE32test = SDL_ReadBE32(rw); - SDLTest_AssertPass("Call to SDL_ReadBE32()"); - SDLTest_AssertCheck(BE32test == BE32value, "Validate return value from SDL_ReadBE32, expected: %" SDL_PRIu32 ", got: %" SDL_PRIu32, BE32value, BE32test); - BE64test = SDL_ReadBE64(rw); - SDLTest_AssertPass("Call to SDL_ReadBE64()"); - SDLTest_AssertCheck(BE64test == BE64value, "Validate return value from SDL_ReadBE64, expected: %"SDL_PRIu64", got: %"SDL_PRIu64, BE64value, BE64test); - LE16test = SDL_ReadLE16(rw); - SDLTest_AssertPass("Call to SDL_ReadLE16()"); - SDLTest_AssertCheck(LE16test == LE16value, "Validate return value from SDL_ReadLE16, expected: %hu, got: %hu", LE16value, LE16test); - LE32test = SDL_ReadLE32(rw); - SDLTest_AssertPass("Call to SDL_ReadLE32()"); - SDLTest_AssertCheck(LE32test == LE32value, "Validate return value from SDL_ReadLE32, expected: %" SDL_PRIu32 ", got: %" SDL_PRIu32, LE32value, LE32test); - LE64test = SDL_ReadLE64(rw); - SDLTest_AssertPass("Call to SDL_ReadLE64()"); - SDLTest_AssertCheck(LE64test == LE64value, "Validate return value from SDL_ReadLE64, expected: %"SDL_PRIu64", got: %"SDL_PRIu64, LE64value, LE64test); + /* Read test data */ + BE16test = SDL_ReadBE16(rw); + SDLTest_AssertPass("Call to SDL_ReadBE16()"); + SDLTest_AssertCheck(BE16test == BE16value, "Validate return value from SDL_ReadBE16, expected: %hu, got: %hu", BE16value, BE16test); + BE32test = SDL_ReadBE32(rw); + SDLTest_AssertPass("Call to SDL_ReadBE32()"); + SDLTest_AssertCheck(BE32test == BE32value, "Validate return value from SDL_ReadBE32, expected: %" SDL_PRIu32 ", got: %" SDL_PRIu32, BE32value, BE32test); + BE64test = SDL_ReadBE64(rw); + SDLTest_AssertPass("Call to SDL_ReadBE64()"); + SDLTest_AssertCheck(BE64test == BE64value, "Validate return value from SDL_ReadBE64, expected: %" SDL_PRIu64 ", got: %" SDL_PRIu64, BE64value, BE64test); + LE16test = SDL_ReadLE16(rw); + SDLTest_AssertPass("Call to SDL_ReadLE16()"); + SDLTest_AssertCheck(LE16test == LE16value, "Validate return value from SDL_ReadLE16, expected: %hu, got: %hu", LE16value, LE16test); + LE32test = SDL_ReadLE32(rw); + SDLTest_AssertPass("Call to SDL_ReadLE32()"); + SDLTest_AssertCheck(LE32test == LE32value, "Validate return value from SDL_ReadLE32, expected: %" SDL_PRIu32 ", got: %" SDL_PRIu32, LE32value, LE32test); + LE64test = SDL_ReadLE64(rw); + SDLTest_AssertPass("Call to SDL_ReadLE64()"); + SDLTest_AssertCheck(LE64test == LE64value, "Validate return value from SDL_ReadLE64, expected: %" SDL_PRIu64 ", got: %" SDL_PRIu64, LE64value, LE64test); - /* Close handle */ - cresult = SDL_RWclose(rw); - SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); - SDLTest_AssertCheck(cresult == 0, "Verify result value is 0; got: %d", cresult); - } + /* Close handle */ + cresult = SDL_RWclose(rw); + SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); + SDLTest_AssertCheck(cresult == 0, "Verify result value is 0; got: %d", cresult); + } - return TEST_COMPLETED; + return TEST_COMPLETED; } - /* ================= Test References ================== */ /* RWops test cases */ -static const SDLTest_TestCaseReference rwopsTest1 = - { (SDLTest_TestCaseFp)rwops_testParamNegative, "rwops_testParamNegative", "Negative test for SDL_RWFromFile parameters", TEST_ENABLED }; +static const SDLTest_TestCaseReference rwopsTest1 = { + (SDLTest_TestCaseFp)rwops_testParamNegative, "rwops_testParamNegative", "Negative test for SDL_RWFromFile parameters", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rwopsTest2 = - { (SDLTest_TestCaseFp)rwops_testMem, "rwops_testMem", "Tests opening from memory", TEST_ENABLED }; +static const SDLTest_TestCaseReference rwopsTest2 = { + (SDLTest_TestCaseFp)rwops_testMem, "rwops_testMem", "Tests opening from memory", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rwopsTest3 = - { (SDLTest_TestCaseFp)rwops_testConstMem, "rwops_testConstMem", "Tests opening from (const) memory", TEST_ENABLED }; +static const SDLTest_TestCaseReference rwopsTest3 = { + (SDLTest_TestCaseFp)rwops_testConstMem, "rwops_testConstMem", "Tests opening from (const) memory", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rwopsTest4 = - { (SDLTest_TestCaseFp)rwops_testFileRead, "rwops_testFileRead", "Tests reading from a file", TEST_ENABLED }; +static const SDLTest_TestCaseReference rwopsTest4 = { + (SDLTest_TestCaseFp)rwops_testFileRead, "rwops_testFileRead", "Tests reading from a file", TEST_ENABLED +}; -static const SDLTest_TestCaseReference rwopsTest5 = - { (SDLTest_TestCaseFp)rwops_testFileWrite, "rwops_testFileWrite", "Test writing to a file", TEST_ENABLED }; +static const SDLTest_TestCaseReference rwopsTest5 = { + (SDLTest_TestCaseFp)rwops_testFileWrite, "rwops_testFileWrite", "Test writing to a file", TEST_ENABLED +}; static const SDLTest_TestCaseReference rwopsTest6 = { (SDLTest_TestCaseFp)rwops_testFPRead, "rwops_testFPRead", "Test reading from file pointer", TEST_ENABLED }; @@ -757,7 +746,7 @@ static const SDLTest_TestCaseReference rwopsTest10 = { (SDLTest_TestCaseFp)rwops_testCompareRWFromMemWithRWFromFile, "rwops_testCompareRWFromMemWithRWFromFile", "Compare RWFromMem and RWFromFile RWops for read and seek", TEST_ENABLED }; /* Sequence of RWops test cases */ -static const SDLTest_TestCaseReference *rwopsTests[] = { +static const SDLTest_TestCaseReference *rwopsTests[] = { &rwopsTest1, &rwopsTest2, &rwopsTest3, &rwopsTest4, &rwopsTest5, &rwopsTest6, &rwopsTest7, &rwopsTest8, &rwopsTest9, &rwopsTest10, NULL }; diff --git a/test/testautomation_sdltest.c b/test/testautomation_sdltest.c index 9c97e6013..53e357154 100644 --- a/test/testautomation_sdltest.c +++ b/test/testautomation_sdltest.c @@ -30,1280 +30,1277 @@ extern char *SDLTest_GenerateRunSeed(const int length); /** * @brief Calls to SDLTest_GenerateRunSeed() */ -int -sdltest_generateRunSeed(void *arg) +int sdltest_generateRunSeed(void *arg) { - char* result; - size_t i, l; - int j; - - for (i = 1; i <= 10; i += 3) { - result = SDLTest_GenerateRunSeed((const int)i); - SDLTest_AssertPass("Call to SDLTest_GenerateRunSeed()"); - SDLTest_AssertCheck(result != NULL, "Verify returned value is not NULL"); - if (result != NULL) { - l = SDL_strlen(result); - SDLTest_AssertCheck(l == i, "Verify length of returned value is %d, got: %d", (int) i, (int) l); - SDL_free(result); - } - } + char *result; + size_t i, l; + int j; - /* Negative cases */ - for (j = -2; j <= 0; j++) { - result = SDLTest_GenerateRunSeed((const int)j); - SDLTest_AssertPass("Call to SDLTest_GenerateRunSeed()"); - SDLTest_AssertCheck(result == NULL, "Verify returned value is not NULL"); - } - - return TEST_COMPLETED; + for (i = 1; i <= 10; i += 3) { + result = SDLTest_GenerateRunSeed((const int)i); + SDLTest_AssertPass("Call to SDLTest_GenerateRunSeed()"); + SDLTest_AssertCheck(result != NULL, "Verify returned value is not NULL"); + if (result != NULL) { + l = SDL_strlen(result); + SDLTest_AssertCheck(l == i, "Verify length of returned value is %d, got: %d", (int)i, (int)l); + SDL_free(result); + } + } + + /* Negative cases */ + for (j = -2; j <= 0; j++) { + result = SDLTest_GenerateRunSeed((const int)j); + SDLTest_AssertPass("Call to SDLTest_GenerateRunSeed()"); + SDLTest_AssertCheck(result == NULL, "Verify returned value is not NULL"); + } + + return TEST_COMPLETED; } /** * @brief Calls to SDLTest_GetFuzzerInvocationCount() */ -int -sdltest_getFuzzerInvocationCount(void *arg) +int sdltest_getFuzzerInvocationCount(void *arg) { - Uint8 result; - int fuzzerCount1, fuzzerCount2; + Uint8 result; + int fuzzerCount1, fuzzerCount2; - fuzzerCount1 = SDLTest_GetFuzzerInvocationCount(); - SDLTest_AssertPass("Call to SDLTest_GetFuzzerInvocationCount()"); - SDLTest_AssertCheck(fuzzerCount1 >= 0, "Verify returned value, expected: >=0, got: %d", fuzzerCount1); + fuzzerCount1 = SDLTest_GetFuzzerInvocationCount(); + SDLTest_AssertPass("Call to SDLTest_GetFuzzerInvocationCount()"); + SDLTest_AssertCheck(fuzzerCount1 >= 0, "Verify returned value, expected: >=0, got: %d", fuzzerCount1); - result = SDLTest_RandomUint8(); - SDLTest_AssertPass("Call to SDLTest_RandomUint8(), returned %d", result); + result = SDLTest_RandomUint8(); + SDLTest_AssertPass("Call to SDLTest_RandomUint8(), returned %d", result); - fuzzerCount2 = SDLTest_GetFuzzerInvocationCount(); - SDLTest_AssertPass("Call to SDLTest_GetFuzzerInvocationCount()"); - SDLTest_AssertCheck(fuzzerCount2 > fuzzerCount1, "Verify returned value, expected: >%d, got: %d", fuzzerCount1, fuzzerCount2); + fuzzerCount2 = SDLTest_GetFuzzerInvocationCount(); + SDLTest_AssertPass("Call to SDLTest_GetFuzzerInvocationCount()"); + SDLTest_AssertCheck(fuzzerCount2 > fuzzerCount1, "Verify returned value, expected: >%d, got: %d", fuzzerCount1, fuzzerCount2); - return TEST_COMPLETED; + return TEST_COMPLETED; } - /** * @brief Calls to random number generators */ -int -sdltest_randomNumber(void *arg) +int sdltest_randomNumber(void *arg) { - Sint64 result; - double dresult; - Uint64 umax; - Sint64 min, max; + Sint64 result; + double dresult; + Uint64 umax; + Sint64 min, max; - result = (Sint64)SDLTest_RandomUint8(); - umax = (1 << 8) - 1; - SDLTest_AssertPass("Call to SDLTest_RandomUint8"); - SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%"SDL_PRIu64"], got: %"SDL_PRIs64, umax, result); + result = (Sint64)SDLTest_RandomUint8(); + umax = (1 << 8) - 1; + SDLTest_AssertPass("Call to SDLTest_RandomUint8"); + SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%" SDL_PRIu64 "], got: %" SDL_PRIs64, umax, result); - result = (Sint64)SDLTest_RandomSint8(); - min = 0 - (1 << 7); - max = (1 << 7) - 1; - SDLTest_AssertPass("Call to SDLTest_RandomSint8"); - SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%"SDL_PRIs64",%"SDL_PRIs64"], got: %"SDL_PRIs64, min, max, result); + result = (Sint64)SDLTest_RandomSint8(); + min = 0 - (1 << 7); + max = (1 << 7) - 1; + SDLTest_AssertPass("Call to SDLTest_RandomSint8"); + SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%" SDL_PRIs64 ",%" SDL_PRIs64 "], got: %" SDL_PRIs64, min, max, result); - result = (Sint64)SDLTest_RandomUint16(); - umax = (1 << 16) - 1; - SDLTest_AssertPass("Call to SDLTest_RandomUint16"); - SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%"SDL_PRIu64"], got: %"SDL_PRIs64, umax, result); + result = (Sint64)SDLTest_RandomUint16(); + umax = (1 << 16) - 1; + SDLTest_AssertPass("Call to SDLTest_RandomUint16"); + SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%" SDL_PRIu64 "], got: %" SDL_PRIs64, umax, result); - result = (Sint64)SDLTest_RandomSint16(); - min = 0 - (1 << 15); - max = (1 << 15) - 1; - SDLTest_AssertPass("Call to SDLTest_RandomSint16"); - SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%"SDL_PRIs64",%"SDL_PRIs64"], got: %"SDL_PRIs64, min, max, result); + result = (Sint64)SDLTest_RandomSint16(); + min = 0 - (1 << 15); + max = (1 << 15) - 1; + SDLTest_AssertPass("Call to SDLTest_RandomSint16"); + SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%" SDL_PRIs64 ",%" SDL_PRIs64 "], got: %" SDL_PRIs64, min, max, result); - result = (Sint64)SDLTest_RandomUint32(); - umax = ((Uint64)1 << 32) - 1; - SDLTest_AssertPass("Call to SDLTest_RandomUint32"); - SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%"SDL_PRIu64"], got: %"SDL_PRIs64, umax, result); + result = (Sint64)SDLTest_RandomUint32(); + umax = ((Uint64)1 << 32) - 1; + SDLTest_AssertPass("Call to SDLTest_RandomUint32"); + SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%" SDL_PRIu64 "], got: %" SDL_PRIs64, umax, result); - result = (Sint64)SDLTest_RandomSint32(); - min = 0 - ((Sint64)1 << 31); - max = ((Sint64)1 << 31) - 1; - SDLTest_AssertPass("Call to SDLTest_RandomSint32"); - SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%"SDL_PRIs64",%"SDL_PRIs64"], got: %"SDL_PRIs64, min, max, result); + result = (Sint64)SDLTest_RandomSint32(); + min = 0 - ((Sint64)1 << 31); + max = ((Sint64)1 << 31) - 1; + SDLTest_AssertPass("Call to SDLTest_RandomSint32"); + SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%" SDL_PRIs64 ",%" SDL_PRIs64 "], got: %" SDL_PRIs64, min, max, result); - SDLTest_RandomUint64(); - SDLTest_AssertPass("Call to SDLTest_RandomUint64"); + SDLTest_RandomUint64(); + SDLTest_AssertPass("Call to SDLTest_RandomUint64"); - result = SDLTest_RandomSint64(); - SDLTest_AssertPass("Call to SDLTest_RandomSint64"); + result = SDLTest_RandomSint64(); + SDLTest_AssertPass("Call to SDLTest_RandomSint64"); - dresult = (double)SDLTest_RandomUnitFloat(); - SDLTest_AssertPass("Call to SDLTest_RandomUnitFloat"); - SDLTest_AssertCheck(dresult >= 0.0 && dresult < 1.0, "Verify result value, expected: [0.0,1.0[, got: %e", dresult); + dresult = (double)SDLTest_RandomUnitFloat(); + SDLTest_AssertPass("Call to SDLTest_RandomUnitFloat"); + SDLTest_AssertCheck(dresult >= 0.0 && dresult < 1.0, "Verify result value, expected: [0.0,1.0[, got: %e", dresult); - dresult = (double)SDLTest_RandomFloat(); - SDLTest_AssertPass("Call to SDLTest_RandomFloat"); - SDLTest_AssertCheck(dresult >= (double)(-FLT_MAX) && dresult <= (double)FLT_MAX, "Verify result value, expected: [%e,%e], got: %e", (double)(-FLT_MAX), (double)FLT_MAX, dresult); + dresult = (double)SDLTest_RandomFloat(); + SDLTest_AssertPass("Call to SDLTest_RandomFloat"); + SDLTest_AssertCheck(dresult >= (double)(-FLT_MAX) && dresult <= (double)FLT_MAX, "Verify result value, expected: [%e,%e], got: %e", (double)(-FLT_MAX), (double)FLT_MAX, dresult); - dresult = (double)SDLTest_RandomUnitDouble(); - SDLTest_AssertPass("Call to SDLTest_RandomUnitDouble"); - SDLTest_AssertCheck(dresult >= 0.0 && dresult < 1.0, "Verify result value, expected: [0.0,1.0[, got: %e", dresult); + dresult = (double)SDLTest_RandomUnitDouble(); + SDLTest_AssertPass("Call to SDLTest_RandomUnitDouble"); + SDLTest_AssertCheck(dresult >= 0.0 && dresult < 1.0, "Verify result value, expected: [0.0,1.0[, got: %e", dresult); - dresult = SDLTest_RandomDouble(); - SDLTest_AssertPass("Call to SDLTest_RandomDouble"); + dresult = SDLTest_RandomDouble(); + SDLTest_AssertPass("Call to SDLTest_RandomDouble"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* * @brief Calls to random boundary number generators for Uint8 */ -int -sdltest_randomBoundaryNumberUint8(void *arg) +int sdltest_randomBoundaryNumberUint8(void *arg) { - const char *expectedError = "That operation is not supported"; - char *lastError; - Uint64 uresult; + const char *expectedError = "That operation is not supported"; + char *lastError; + Uint64 uresult; - /* Clean error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clean error messages */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ + uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 10, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10, + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 11, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ + uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 11, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11, + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 12, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ + uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 12, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11 || uresult == 12, + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 13, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ + uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 13, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13, + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 20, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ + uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 20, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(20, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ + uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(20, 10, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 20, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0 || uresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ + uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 20, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); + SDLTest_AssertCheck( + uresult == 0 || uresult == 21, + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 99, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 100, - "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */ + uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 99, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); + SDLTest_AssertCheck( + uresult == 100, + "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(1, 0xff, SDL_FALSE) returns 0 (no error) */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 255, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0, - "Validate result value for parameters (1,255,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); + /* RandomUintXBoundaryValue(1, 0xff, SDL_FALSE) returns 0 (no error) */ + uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 255, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); + SDLTest_AssertCheck( + uresult == 0, + "Validate result value for parameters (1,255,SDL_FALSE); expected: 0, got: %" SDL_PRIs64, uresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - /* RandomUintXBoundaryValue(0, 0xfe, SDL_FALSE) returns 0xff (no error) */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 254, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0xff, - "Validate result value for parameters (0,254,SDL_FALSE); expected: 0xff, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); + /* RandomUintXBoundaryValue(0, 0xfe, SDL_FALSE) returns 0xff (no error) */ + uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 254, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); + SDLTest_AssertCheck( + uresult == 0xff, + "Validate result value for parameters (0,254,SDL_FALSE); expected: 0xff, got: %" SDL_PRIs64, uresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - /* RandomUintXBoundaryValue(0, 0xff, SDL_FALSE) returns 0 (sets error) */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 255, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0, - "Validate result value for parameters(0,255,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); + /* RandomUintXBoundaryValue(0, 0xff, SDL_FALSE) returns 0 (sets error) */ + uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 255, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); + SDLTest_AssertCheck( + uresult == 0, + "Validate result value for parameters(0,255,SDL_FALSE); expected: 0, got: %" SDL_PRIs64, uresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, + "SDL_GetError(): expected message '%s', was message: '%s'", + expectedError, + lastError); - /* Clear error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clear error messages */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* * @brief Calls to random boundary number generators for Uint16 */ -int -sdltest_randomBoundaryNumberUint16(void *arg) +int sdltest_randomBoundaryNumberUint16(void *arg) { - const char *expectedError = "That operation is not supported"; - char *lastError; - Uint64 uresult; + const char *expectedError = "That operation is not supported"; + char *lastError; + Uint64 uresult; - /* Clean error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clean error messages */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ + uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 10, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10, + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 11, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ + uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 11, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11, + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 12, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ + uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 12, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11 || uresult == 12, + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 13, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ + uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 13, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13, + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 20, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ + uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 20, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(20, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ + uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(20, 10, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 20, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0 || uresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ + uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 20, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); + SDLTest_AssertCheck( + uresult == 0 || uresult == 21, + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 99, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 100, - "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */ + uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 99, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); + SDLTest_AssertCheck( + uresult == 100, + "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(1, 0xffff, SDL_FALSE) returns 0 (no error) */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 0xffff, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0, - "Validate result value for parameters (1,0xffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); + /* RandomUintXBoundaryValue(1, 0xffff, SDL_FALSE) returns 0 (no error) */ + uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 0xffff, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); + SDLTest_AssertCheck( + uresult == 0, + "Validate result value for parameters (1,0xffff,SDL_FALSE); expected: 0, got: %" SDL_PRIs64, uresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - /* RandomUintXBoundaryValue(0, 0xfffe, SDL_FALSE) returns 0xffff (no error) */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xfffe, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0xffff, - "Validate result value for parameters (0,0xfffe,SDL_FALSE); expected: 0xffff, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); + /* RandomUintXBoundaryValue(0, 0xfffe, SDL_FALSE) returns 0xffff (no error) */ + uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xfffe, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); + SDLTest_AssertCheck( + uresult == 0xffff, + "Validate result value for parameters (0,0xfffe,SDL_FALSE); expected: 0xffff, got: %" SDL_PRIs64, uresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - /* RandomUintXBoundaryValue(0, 0xffff, SDL_FALSE) returns 0 (sets error) */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xffff, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0, - "Validate result value for parameters(0,0xffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); + /* RandomUintXBoundaryValue(0, 0xffff, SDL_FALSE) returns 0 (sets error) */ + uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xffff, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); + SDLTest_AssertCheck( + uresult == 0, + "Validate result value for parameters(0,0xffff,SDL_FALSE); expected: 0, got: %" SDL_PRIs64, uresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, + "SDL_GetError(): expected message '%s', was message: '%s'", + expectedError, + lastError); - /* Clear error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clear error messages */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* * @brief Calls to random boundary number generators for Uint32 */ -int -sdltest_randomBoundaryNumberUint32(void *arg) +int sdltest_randomBoundaryNumberUint32(void *arg) { - const char *expectedError = "That operation is not supported"; - char *lastError; - Uint64 uresult; + const char *expectedError = "That operation is not supported"; + char *lastError; + Uint64 uresult; - /* Clean error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clean error messages */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ + uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 10, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10, + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 11, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ + uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 11, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11, + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 12, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ + uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 12, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11 || uresult == 12, + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 13, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ + uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 13, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13, + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 20, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ + uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 20, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(20, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ + uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(20, 10, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 20, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0 || uresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ + uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 20, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); + SDLTest_AssertCheck( + uresult == 0 || uresult == 21, + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 99, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 100, - "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */ + uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 99, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); + SDLTest_AssertCheck( + uresult == 100, + "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(1, 0xffffffff, SDL_FALSE) returns 0 (no error) */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 0xffffffff, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0, - "Validate result value for parameters (1,0xffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); + /* RandomUintXBoundaryValue(1, 0xffffffff, SDL_FALSE) returns 0 (no error) */ + uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 0xffffffff, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); + SDLTest_AssertCheck( + uresult == 0, + "Validate result value for parameters (1,0xffffffff,SDL_FALSE); expected: 0, got: %" SDL_PRIs64, uresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - /* RandomUintXBoundaryValue(0, 0xfffffffe, SDL_FALSE) returns 0xffffffff (no error) */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xfffffffe, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0xffffffff, - "Validate result value for parameters (0,0xfffffffe,SDL_FALSE); expected: 0xffffffff, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); + /* RandomUintXBoundaryValue(0, 0xfffffffe, SDL_FALSE) returns 0xffffffff (no error) */ + uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xfffffffe, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); + SDLTest_AssertCheck( + uresult == 0xffffffff, + "Validate result value for parameters (0,0xfffffffe,SDL_FALSE); expected: 0xffffffff, got: %" SDL_PRIs64, uresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - /* RandomUintXBoundaryValue(0, 0xffffffff, SDL_FALSE) returns 0 (sets error) */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xffffffff, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0, - "Validate result value for parameters(0,0xffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); + /* RandomUintXBoundaryValue(0, 0xffffffff, SDL_FALSE) returns 0 (sets error) */ + uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xffffffff, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); + SDLTest_AssertCheck( + uresult == 0, + "Validate result value for parameters(0,0xffffffff,SDL_FALSE); expected: 0, got: %" SDL_PRIs64, uresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, + "SDL_GetError(): expected message '%s', was message: '%s'", + expectedError, + lastError); - /* Clear error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clear error messages */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* * @brief Calls to random boundary number generators for Uint64 */ -int -sdltest_randomBoundaryNumberUint64(void *arg) +int sdltest_randomBoundaryNumberUint64(void *arg) { - const char *expectedError = "That operation is not supported"; - char *lastError; - Uint64 uresult; + const char *expectedError = "That operation is not supported"; + char *lastError; + Uint64 uresult; - /* Clean error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clean error messages */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ + uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 10, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10, + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 11, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ + uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 11, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11, + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 12, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ + uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 12, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11 || uresult == 12, + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 13, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ + uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 13, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13, + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 20, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ + uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 20, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(20, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ + uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(20, 10, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); + SDLTest_AssertCheck( + uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, 20, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0 || uresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ + uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, 20, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); + SDLTest_AssertCheck( + uresult == 0 || uresult == 21, + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, 99, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 100, - "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult); + /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */ + uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, 99, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); + SDLTest_AssertCheck( + uresult == 100, + "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %" SDL_PRIs64, uresult); - /* RandomUintXBoundaryValue(1, 0xffffffffffffffff, SDL_FALSE) returns 0 (no error) */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, (Uint64)0xffffffffffffffffULL, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0, - "Validate result value for parameters (1,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); + /* RandomUintXBoundaryValue(1, 0xffffffffffffffff, SDL_FALSE) returns 0 (no error) */ + uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, (Uint64)0xffffffffffffffffULL, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); + SDLTest_AssertCheck( + uresult == 0, + "Validate result value for parameters (1,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %" SDL_PRIs64, uresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - /* RandomUintXBoundaryValue(0, 0xfffffffffffffffe, SDL_FALSE) returns 0xffffffffffffffff (no error) */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xfffffffffffffffeULL, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == (Uint64)0xffffffffffffffffULL, - "Validate result value for parameters (0,0xfffffffffffffffe,SDL_FALSE); expected: 0xffffffffffffffff, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); + /* RandomUintXBoundaryValue(0, 0xfffffffffffffffe, SDL_FALSE) returns 0xffffffffffffffff (no error) */ + uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xfffffffffffffffeULL, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); + SDLTest_AssertCheck( + uresult == (Uint64)0xffffffffffffffffULL, + "Validate result value for parameters (0,0xfffffffffffffffe,SDL_FALSE); expected: 0xffffffffffffffff, got: %" SDL_PRIs64, uresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - /* RandomUintXBoundaryValue(0, 0xffffffffffffffff, SDL_FALSE) returns 0 (sets error) */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xffffffffffffffffULL, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0, - "Validate result value for parameters(0,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); + /* RandomUintXBoundaryValue(0, 0xffffffffffffffff, SDL_FALSE) returns 0 (sets error) */ + uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xffffffffffffffffULL, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); + SDLTest_AssertCheck( + uresult == 0, + "Validate result value for parameters(0,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %" SDL_PRIs64, uresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, + "SDL_GetError(): expected message '%s', was message: '%s'", + expectedError, + lastError); - /* Clear error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clear error messages */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* * @brief Calls to random boundary number generators for Sint8 */ -int -sdltest_randomBoundaryNumberSint8(void *arg) +int sdltest_randomBoundaryNumberSint8(void *arg) { - const char *expectedError = "That operation is not supported"; - char *lastError; - Sint64 sresult; + const char *expectedError = "That operation is not supported"; + char *lastError; + Sint64 sresult; - /* Clean error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clean error messages */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ + sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 10, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10, + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 11, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ + sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 11, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11, + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 12, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ + sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 12, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11 || sresult == 12, + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 13, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ + sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 13, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13, + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 20, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ + sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 20, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(20, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ + sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(20, 10, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(1, 20, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == 0 || sresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ + sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(1, 20, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); + SDLTest_AssertCheck( + sresult == 0 || sresult == 21, + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(SCHAR_MIN, 99, SDL_FALSE) returns 100 */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, 99, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == 100, - "Validate result value for parameters (SCHAR_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(SCHAR_MIN, 99, SDL_FALSE) returns 100 */ + sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, 99, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); + SDLTest_AssertCheck( + sresult == 100, + "Validate result value for parameters (SCHAR_MIN,99,SDL_FALSE); expected: 100, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (no error) */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == SCHAR_MIN, - "Validate result value for parameters (SCHAR_MIN + 1,SCHAR_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SCHAR_MIN, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); + /* RandomSintXBoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (no error) */ + sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); + SDLTest_AssertCheck( + sresult == SCHAR_MIN, + "Validate result value for parameters (SCHAR_MIN + 1,SCHAR_MAX,SDL_FALSE); expected: %d, got: %" SDL_PRIs64, SCHAR_MIN, sresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - /* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX - 1, SDL_FALSE) returns SCHAR_MAX (no error) */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX -1, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == SCHAR_MAX, - "Validate result value for parameters (SCHAR_MIN,SCHAR_MAX - 1,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SCHAR_MAX, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); + /* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX - 1, SDL_FALSE) returns SCHAR_MAX (no error) */ + sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX - 1, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); + SDLTest_AssertCheck( + sresult == SCHAR_MAX, + "Validate result value for parameters (SCHAR_MIN,SCHAR_MAX - 1,SDL_FALSE); expected: %d, got: %" SDL_PRIs64, SCHAR_MAX, sresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - /* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (sets error) */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == SCHAR_MIN, - "Validate result value for parameters(SCHAR_MIN,SCHAR_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SCHAR_MIN, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); + /* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (sets error) */ + sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); + SDLTest_AssertCheck( + sresult == SCHAR_MIN, + "Validate result value for parameters(SCHAR_MIN,SCHAR_MAX,SDL_FALSE); expected: %d, got: %" SDL_PRIs64, SCHAR_MIN, sresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, + "SDL_GetError(): expected message '%s', was message: '%s'", + expectedError, + lastError); - /* Clear error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clear error messages */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* * @brief Calls to random boundary number generators for Sint16 */ -int -sdltest_randomBoundaryNumberSint16(void *arg) +int sdltest_randomBoundaryNumberSint16(void *arg) { - const char *expectedError = "That operation is not supported"; - char *lastError; - Sint64 sresult; + const char *expectedError = "That operation is not supported"; + char *lastError; + Sint64 sresult; - /* Clean error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clean error messages */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ + sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 10, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10, + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 11, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ + sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 11, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11, + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 12, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ + sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 12, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11 || sresult == 12, + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 13, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ + sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 13, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13, + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 20, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ + sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 20, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(20, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ + sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(20, 10, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(1, 20, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == 0 || sresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ + sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(1, 20, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); + SDLTest_AssertCheck( + sresult == 0 || sresult == 21, + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(SHRT_MIN, 99, SDL_FALSE) returns 100 */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, 99, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == 100, - "Validate result value for parameters (SHRT_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(SHRT_MIN, 99, SDL_FALSE) returns 100 */ + sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, 99, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); + SDLTest_AssertCheck( + sresult == 100, + "Validate result value for parameters (SHRT_MIN,99,SDL_FALSE); expected: 100, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE) returns SHRT_MIN (no error) */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == SHRT_MIN, - "Validate result value for parameters (SHRT_MIN+1,SHRT_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SHRT_MIN, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); + /* RandomSintXBoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE) returns SHRT_MIN (no error) */ + sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); + SDLTest_AssertCheck( + sresult == SHRT_MIN, + "Validate result value for parameters (SHRT_MIN+1,SHRT_MAX,SDL_FALSE); expected: %d, got: %" SDL_PRIs64, SHRT_MIN, sresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - /* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE) returns SHRT_MAX (no error) */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == SHRT_MAX, - "Validate result value for parameters (SHRT_MIN,SHRT_MAX - 1,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SHRT_MAX, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); + /* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE) returns SHRT_MAX (no error) */ + sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); + SDLTest_AssertCheck( + sresult == SHRT_MAX, + "Validate result value for parameters (SHRT_MIN,SHRT_MAX - 1,SDL_FALSE); expected: %d, got: %" SDL_PRIs64, SHRT_MAX, sresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - /* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE) returns 0 (sets error) */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == SHRT_MIN, - "Validate result value for parameters(SHRT_MIN,SHRT_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SHRT_MIN, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); + /* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE) returns 0 (sets error) */ + sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); + SDLTest_AssertCheck( + sresult == SHRT_MIN, + "Validate result value for parameters(SHRT_MIN,SHRT_MAX,SDL_FALSE); expected: %d, got: %" SDL_PRIs64, SHRT_MIN, sresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, + "SDL_GetError(): expected message '%s', was message: '%s'", + expectedError, + lastError); - /* Clear error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clear error messages */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* * @brief Calls to random boundary number generators for Sint32 */ -int -sdltest_randomBoundaryNumberSint32(void *arg) +int sdltest_randomBoundaryNumberSint32(void *arg) { - const char *expectedError = "That operation is not supported"; - char *lastError; - Sint64 sresult; + const char *expectedError = "That operation is not supported"; + char *lastError; + Sint64 sresult; #if ((ULONG_MAX) == (UINT_MAX)) - Sint32 long_min = LONG_MIN; - Sint32 long_max = LONG_MAX; + Sint32 long_min = LONG_MIN; + Sint32 long_max = LONG_MAX; #else - Sint32 long_min = INT_MIN; - Sint32 long_max = INT_MAX; + Sint32 long_min = INT_MIN; + Sint32 long_max = INT_MAX; #endif - /* Clean error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clean error messages */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ + sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 10, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10, + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 11, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ + sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 11, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11, + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 12, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ + sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 12, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11 || sresult == 12, + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 13, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ + sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 13, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13, + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 20, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ + sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 20, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(20, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ + sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(20, 10, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(1, 20, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == 0 || sresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ + sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(1, 20, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); + SDLTest_AssertCheck( + sresult == 0 || sresult == 21, + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(LONG_MIN, 99, SDL_FALSE) returns 100 */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, 99, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == 100, - "Validate result value for parameters (LONG_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(LONG_MIN, 99, SDL_FALSE) returns 100 */ + sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, 99, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); + SDLTest_AssertCheck( + sresult == 100, + "Validate result value for parameters (LONG_MIN,99,SDL_FALSE); expected: 100, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(LONG_MIN + 1, LONG_MAX, SDL_FALSE) returns LONG_MIN (no error) */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min + 1, long_max, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == long_min, - "Validate result value for parameters (LONG_MIN+1,LONG_MAX,SDL_FALSE); expected: %" SDL_PRIs32 ", got: %" SDL_PRIs64, long_min, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); + /* RandomSintXBoundaryValue(LONG_MIN + 1, LONG_MAX, SDL_FALSE) returns LONG_MIN (no error) */ + sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min + 1, long_max, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); + SDLTest_AssertCheck( + sresult == long_min, + "Validate result value for parameters (LONG_MIN+1,LONG_MAX,SDL_FALSE); expected: %" SDL_PRIs32 ", got: %" SDL_PRIs64, long_min, sresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - /* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX - 1, SDL_FALSE) returns LONG_MAX (no error) */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max - 1, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == long_max, - "Validate result value for parameters (LONG_MIN,LONG_MAX - 1,SDL_FALSE); expected: %" SDL_PRIs32 ", got: %" SDL_PRIs64, long_max, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); + /* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX - 1, SDL_FALSE) returns LONG_MAX (no error) */ + sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max - 1, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); + SDLTest_AssertCheck( + sresult == long_max, + "Validate result value for parameters (LONG_MIN,LONG_MAX - 1,SDL_FALSE); expected: %" SDL_PRIs32 ", got: %" SDL_PRIs64, long_max, sresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - /* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX, SDL_FALSE) returns 0 (sets error) */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == long_min, - "Validate result value for parameters(LONG_MIN,LONG_MAX,SDL_FALSE); expected: %" SDL_PRIs32 ", got: %" SDL_PRIs64, long_min, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); + /* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX, SDL_FALSE) returns 0 (sets error) */ + sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); + SDLTest_AssertCheck( + sresult == long_min, + "Validate result value for parameters(LONG_MIN,LONG_MAX,SDL_FALSE); expected: %" SDL_PRIs32 ", got: %" SDL_PRIs64, long_min, sresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, + "SDL_GetError(): expected message '%s', was message: '%s'", + expectedError, + lastError); - /* Clear error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clear error messages */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* * @brief Calls to random boundary number generators for Sint64 */ -int -sdltest_randomBoundaryNumberSint64(void *arg) +int sdltest_randomBoundaryNumberSint64(void *arg) { - const char *expectedError = "That operation is not supported"; - char *lastError; - Sint64 sresult; + const char *expectedError = "That operation is not supported"; + char *lastError; + Sint64 sresult; - /* Clean error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clean error messages */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ + sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 10, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10, + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 11, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ + sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 11, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11, + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 12, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ + sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 12, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11 || sresult == 12, + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 13, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ + sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 13, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13, + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 20, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ + sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 20, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(20, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ + sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(20, 10, SDL_TRUE); + SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); + SDLTest_AssertCheck( + sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(1, 20, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == 0 || sresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ + sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(1, 20, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); + SDLTest_AssertCheck( + sresult == 0 || sresult == 21, + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(LLONG_MIN, 99, SDL_FALSE) returns 100 */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN, 99, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == 100, - "Validate result value for parameters (LLONG_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult); + /* RandomSintXBoundaryValue(LLONG_MIN, 99, SDL_FALSE) returns 100 */ + sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN, 99, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); + SDLTest_AssertCheck( + sresult == 100, + "Validate result value for parameters (LLONG_MIN,99,SDL_FALSE); expected: 100, got: %" SDL_PRIs64, sresult); - /* RandomSintXBoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE) returns LLONG_MIN (no error) */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN + 1, INT64_MAX, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == INT64_MIN, - "Validate result value for parameters (LLONG_MIN+1,LLONG_MAX,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, INT64_MIN, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); + /* RandomSintXBoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE) returns LLONG_MIN (no error) */ + sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN + 1, INT64_MAX, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); + SDLTest_AssertCheck( + sresult == INT64_MIN, + "Validate result value for parameters (LLONG_MIN+1,LLONG_MAX,SDL_FALSE); expected: %" SDL_PRIs64 ", got: %" SDL_PRIs64, INT64_MIN, sresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - /* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE) returns LLONG_MAX (no error) */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN, INT64_MAX - 1, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == INT64_MAX, - "Validate result value for parameters (LLONG_MIN,LLONG_MAX - 1,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, INT64_MAX, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); + /* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE) returns LLONG_MAX (no error) */ + sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN, INT64_MAX - 1, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); + SDLTest_AssertCheck( + sresult == INT64_MAX, + "Validate result value for parameters (LLONG_MIN,LLONG_MAX - 1,SDL_FALSE); expected: %" SDL_PRIs64 ", got: %" SDL_PRIs64, INT64_MAX, sresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - /* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE) returns 0 (sets error) */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN, INT64_MAX, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == INT64_MIN, - "Validate result value for parameters(LLONG_MIN,LLONG_MAX,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, INT64_MIN, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); + /* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE) returns 0 (sets error) */ + sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN, INT64_MAX, SDL_FALSE); + SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); + SDLTest_AssertCheck( + sresult == INT64_MIN, + "Validate result value for parameters(LLONG_MIN,LLONG_MAX,SDL_FALSE); expected: %" SDL_PRIs64 ", got: %" SDL_PRIs64, INT64_MIN, sresult); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, + "SDL_GetError(): expected message '%s', was message: '%s'", + expectedError, + lastError); - /* Clear error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clear error messages */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Calls to SDLTest_RandomIntegerInRange */ -int -sdltest_randomIntegerInRange(void *arg) +int sdltest_randomIntegerInRange(void *arg) { - Sint32 min, max; - Sint32 result; + Sint32 min, max; + Sint32 result; #if ((ULONG_MAX) == (UINT_MAX)) - Sint32 long_min = LONG_MIN; - Sint32 long_max = LONG_MAX; + Sint32 long_min = LONG_MIN; + Sint32 long_max = LONG_MAX; #else - Sint32 long_min = INT_MIN; - Sint32 long_max = INT_MAX; + Sint32 long_min = INT_MIN; + Sint32 long_max = INT_MAX; #endif - /* Standard range */ - min = (Sint32)SDLTest_RandomSint16(); - max = min + (Sint32)SDLTest_RandomUint8() + 2; - result = SDLTest_RandomIntegerInRange(min, max); - SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(min,max)"); - SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%" SDL_PRIs32 ",%" SDL_PRIs32 "], got: %" SDL_PRIs32, min, max, result); + /* Standard range */ + min = (Sint32)SDLTest_RandomSint16(); + max = min + (Sint32)SDLTest_RandomUint8() + 2; + result = SDLTest_RandomIntegerInRange(min, max); + SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(min,max)"); + SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%" SDL_PRIs32 ",%" SDL_PRIs32 "], got: %" SDL_PRIs32, min, max, result); - /* One Range */ - min = (Sint32)SDLTest_RandomSint16(); - max = min + 1; - result = SDLTest_RandomIntegerInRange(min, max); - SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(min,min+1)"); - SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%" SDL_PRIs32 ",%" SDL_PRIs32 "], got: %" SDL_PRIs32, min, max, result); + /* One Range */ + min = (Sint32)SDLTest_RandomSint16(); + max = min + 1; + result = SDLTest_RandomIntegerInRange(min, max); + SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(min,min+1)"); + SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%" SDL_PRIs32 ",%" SDL_PRIs32 "], got: %" SDL_PRIs32, min, max, result); - /* Zero range */ - min = (Sint32)SDLTest_RandomSint16(); - max = min; - result = SDLTest_RandomIntegerInRange(min, max); - SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(min,min)"); - SDLTest_AssertCheck(min == result, "Validated returned value; expected: %" SDL_PRIs32 ", got: %" SDL_PRIs32, min, result); + /* Zero range */ + min = (Sint32)SDLTest_RandomSint16(); + max = min; + result = SDLTest_RandomIntegerInRange(min, max); + SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(min,min)"); + SDLTest_AssertCheck(min == result, "Validated returned value; expected: %" SDL_PRIs32 ", got: %" SDL_PRIs32, min, result); - /* Zero range at zero */ - min = 0; - max = 0; - result = SDLTest_RandomIntegerInRange(min, max); - SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(0,0)"); - SDLTest_AssertCheck(result == 0, "Validated returned value; expected: 0, got: %" SDL_PRIs32, result); + /* Zero range at zero */ + min = 0; + max = 0; + result = SDLTest_RandomIntegerInRange(min, max); + SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(0,0)"); + SDLTest_AssertCheck(result == 0, "Validated returned value; expected: 0, got: %" SDL_PRIs32, result); - /* Swapped min-max */ - min = (Sint32)SDLTest_RandomSint16(); - max = min + (Sint32)SDLTest_RandomUint8() + 2; - result = SDLTest_RandomIntegerInRange(max, min); - SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(max,min)"); - SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%" SDL_PRIs32 ",%" SDL_PRIs32 "], got: %" SDL_PRIs32, min, max, result); + /* Swapped min-max */ + min = (Sint32)SDLTest_RandomSint16(); + max = min + (Sint32)SDLTest_RandomUint8() + 2; + result = SDLTest_RandomIntegerInRange(max, min); + SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(max,min)"); + SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%" SDL_PRIs32 ",%" SDL_PRIs32 "], got: %" SDL_PRIs32, min, max, result); - /* Range with min at integer limit */ - min = long_min; - max = long_max + (Sint32)SDLTest_RandomSint16(); - result = SDLTest_RandomIntegerInRange(min, max); - SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(SINT32_MIN,...)"); - SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%" SDL_PRIs32 ",%" SDL_PRIs32 "], got: %" SDL_PRIs32, min, max, result); + /* Range with min at integer limit */ + min = long_min; + max = long_max + (Sint32)SDLTest_RandomSint16(); + result = SDLTest_RandomIntegerInRange(min, max); + SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(SINT32_MIN,...)"); + SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%" SDL_PRIs32 ",%" SDL_PRIs32 "], got: %" SDL_PRIs32, min, max, result); - /* Range with max at integer limit */ - min = long_min - (Sint32)SDLTest_RandomSint16(); - max = long_max; - result = SDLTest_RandomIntegerInRange(min, max); - SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(...,SINT32_MAX)"); - SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%" SDL_PRIs32 ",%" SDL_PRIs32 "], got: %" SDL_PRIs32, min, max, result); + /* Range with max at integer limit */ + min = long_min - (Sint32)SDLTest_RandomSint16(); + max = long_max; + result = SDLTest_RandomIntegerInRange(min, max); + SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(...,SINT32_MAX)"); + SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%" SDL_PRIs32 ",%" SDL_PRIs32 "], got: %" SDL_PRIs32, min, max, result); - /* Full integer range */ - min = long_min; - max = long_max; - result = SDLTest_RandomIntegerInRange(min, max); - SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(SINT32_MIN,SINT32_MAX)"); - SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%" SDL_PRIs32 ",%" SDL_PRIs32 "], got: %" SDL_PRIs32, min, max, result); + /* Full integer range */ + min = long_min; + max = long_max; + result = SDLTest_RandomIntegerInRange(min, max); + SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(SINT32_MIN,SINT32_MAX)"); + SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%" SDL_PRIs32 ",%" SDL_PRIs32 "], got: %" SDL_PRIs32, min, max, result); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Calls to SDLTest_RandomAsciiString */ -int -sdltest_randomAsciiString(void *arg) +int sdltest_randomAsciiString(void *arg) { - char* result; - size_t len; - int nonAsciiCharacters; - size_t i; + char *result; + size_t len; + int nonAsciiCharacters; + size_t i; - result = SDLTest_RandomAsciiString(); - SDLTest_AssertPass("Call to SDLTest_RandomAsciiString()"); - SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL"); - if (result != NULL) { - len = SDL_strlen(result); - SDLTest_AssertCheck(len >= 1 && len <= 255, "Validate that result length; expected: len=[1,255], got: %d", (int) len); - nonAsciiCharacters = 0; - for (i=0; i= 1 && len <= 255, "Validate that result length; expected: len=[1,255], got: %d", (int)len); + nonAsciiCharacters = 0; + for (i = 0; i < len; i++) { + if (SDL_iscntrl(result[i])) { + nonAsciiCharacters++; + } + } + SDLTest_AssertCheck(nonAsciiCharacters == 0, "Validate that result does not contain non-Ascii characters, got: %d", nonAsciiCharacters); + if (nonAsciiCharacters) { + SDLTest_LogError("Invalid result from generator: '%s'", result); + } + SDL_free(result); + } - return TEST_COMPLETED; + return TEST_COMPLETED; } - /** * @brief Calls to SDLTest_RandomAsciiStringWithMaximumLength */ -int -sdltest_randomAsciiStringWithMaximumLength(void *arg) +int sdltest_randomAsciiStringWithMaximumLength(void *arg) { - const char* expectedError = "Parameter 'maxLength' is invalid"; - char* lastError; - char* result; - size_t targetLen; - size_t len; - int nonAsciiCharacters; - size_t i; + const char *expectedError = "Parameter 'maxLength' is invalid"; + char *lastError; + char *result; + size_t targetLen; + size_t len; + int nonAsciiCharacters; + size_t i; - targetLen = 16 + SDLTest_RandomUint8(); - result = SDLTest_RandomAsciiStringWithMaximumLength((int) targetLen); - SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringWithMaximumLength(%d)", (int) targetLen); - SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL"); - if (result != NULL) { - len = SDL_strlen(result); - SDLTest_AssertCheck(len >= 1 && len <= targetLen, "Validate that result length; expected: len=[1,%d], got: %d", (int) targetLen, (int) len); - nonAsciiCharacters = 0; - for (i=0; i= 1 && len <= targetLen, "Validate that result length; expected: len=[1,%d], got: %d", (int)targetLen, (int)len); + nonAsciiCharacters = 0; + for (i = 0; i < len; i++) { + if (SDL_iscntrl(result[i])) { + nonAsciiCharacters++; + } + } + SDLTest_AssertCheck(nonAsciiCharacters == 0, "Validate that result does not contain non-Ascii characters, got: %d", nonAsciiCharacters); + if (nonAsciiCharacters) { + SDLTest_LogError("Invalid result from generator: '%s'", result); + } + SDL_free(result); + } - /* Negative test */ - targetLen = 0; - result = SDLTest_RandomAsciiStringWithMaximumLength((int) targetLen); - SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringWithMaximumLength(%d)", (int) targetLen); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); + /* Negative test */ + targetLen = 0; + result = SDLTest_RandomAsciiStringWithMaximumLength((int)targetLen); + SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringWithMaximumLength(%d)", (int)targetLen); + SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, + "SDL_GetError(): expected message '%s', was message: '%s'", + expectedError, + lastError); - /* Clear error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); + /* Clear error messages */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Calls to SDLTest_RandomAsciiStringOfSize */ -int -sdltest_randomAsciiStringOfSize(void *arg) +int sdltest_randomAsciiStringOfSize(void *arg) { - const char* expectedError = "Parameter 'size' is invalid"; - char* lastError; - char* result; - size_t targetLen; - size_t len; - int nonAsciiCharacters; - size_t i; + const char *expectedError = "Parameter 'size' is invalid"; + char *lastError; + char *result; + size_t targetLen; + size_t len; + int nonAsciiCharacters; + size_t i; - /* Positive test */ - targetLen = 16 + SDLTest_RandomUint8(); - result = SDLTest_RandomAsciiStringOfSize((int) targetLen); - SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringOfSize(%d)", (int) targetLen); - SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL"); - if (result != NULL) { - len = SDL_strlen(result); - SDLTest_AssertCheck(len == targetLen, "Validate that result length; expected: len=%d, got: %d", (int) targetLen, (int) len); - nonAsciiCharacters = 0; - for (i=0; i> 1); \ - expected_result = 1; \ - result = SDL_snprintf(text, sizeof(text), format_specifier, expected_##var##_output); \ - result = SDL_sscanf(text, format_specifier, &var##_output); \ - SDLTest_AssertPass("Call to SDL_sscanf(\"%s\", \"%s\", &output)", text, #format_specifier); \ - SDLTest_AssertCheck(expected_##var##_output == var##_output, "Check output, expected: " format_specifier ", got: " format_specifier, expected_##var##_output, var##_output); \ - SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); \ - \ - var##_output = 123; \ - expected_##var##_output = ~(type)(((unsigned type)(~0)) >> 1); \ - expected_result = 1; \ - result = SDL_snprintf(text, sizeof(text), format_specifier, expected_##var##_output); \ - result = SDL_sscanf(text, format_specifier, &var##_output); \ - SDLTest_AssertPass("Call to SDL_sscanf(\"%s\", \"%s\", &output)", text, #format_specifier); \ - SDLTest_AssertCheck(expected_##var##_output == var##_output, "Check output, expected: " format_specifier ", got: " format_specifier, expected_##var##_output, var##_output); \ - SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); \ +#define SIZED_TEST_CASE(type, var, format_specifier) \ + var##_output = 123; \ + expected_##var##_output = (type)(((unsigned type)(~0)) >> 1); \ + expected_result = 1; \ + result = SDL_snprintf(text, sizeof(text), format_specifier, expected_##var##_output); \ + result = SDL_sscanf(text, format_specifier, &var##_output); \ + SDLTest_AssertPass("Call to SDL_sscanf(\"%s\", \"%s\", &output)", text, #format_specifier); \ + SDLTest_AssertCheck(expected_##var##_output == var##_output, "Check output, expected: " format_specifier ", got: " format_specifier, expected_##var##_output, var##_output); \ + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); \ + \ + var##_output = 123; \ + expected_##var##_output = ~(type)(((unsigned type)(~0)) >> 1); \ + expected_result = 1; \ + result = SDL_snprintf(text, sizeof(text), format_specifier, expected_##var##_output); \ + result = SDL_sscanf(text, format_specifier, &var##_output); \ + SDLTest_AssertPass("Call to SDL_sscanf(\"%s\", \"%s\", &output)", text, #format_specifier); \ + SDLTest_AssertCheck(expected_##var##_output == var##_output, "Check output, expected: " format_specifier ", got: " format_specifier, expected_##var##_output, var##_output); \ + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); - SIZED_TEST_CASE(short, short, "%hd") - SIZED_TEST_CASE(long, long, "%ld") - SIZED_TEST_CASE(long long, long_long, "%lld") + SIZED_TEST_CASE(short, short, "%hd") + SIZED_TEST_CASE(long, long, "%ld") + SIZED_TEST_CASE(long long, long_long, "%lld") - size_output = 123; - expected_size_output = (size_t)~0; - expected_result = 1; - result = SDL_snprintf(text, sizeof(text), "%zu", expected_size_output); - result = SDL_sscanf(text, "%zu", &size_output); - SDLTest_AssertPass("Call to SDL_sscanf(\"%s\", \"%%zu\", &output)", text); - SDLTest_AssertCheck(expected_size_output == size_output, "Check output, expected: %zu, got: %zu", expected_size_output, size_output); - SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + size_output = 123; + expected_size_output = (size_t)~0; + expected_result = 1; + result = SDL_snprintf(text, sizeof(text), "%zu", expected_size_output); + result = SDL_sscanf(text, "%zu", &size_output); + SDLTest_AssertPass("Call to SDL_sscanf(\"%s\", \"%%zu\", &output)", text); + SDLTest_AssertCheck(expected_size_output == size_output, "Check output, expected: %zu, got: %zu", expected_size_output, size_output); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); - return TEST_COMPLETED; + return TEST_COMPLETED; } #if defined(HAVE_WFORMAT) || defined(HAVE_WFORMAT_EXTRA_ARGS) @@ -403,11 +399,11 @@ stdlib_sscanf(void *arg) #endif #if defined(_WIN64) -# define SIZE_FORMAT "I64u" +#define SIZE_FORMAT "I64u" #elif defined(__WIN32__) -# define SIZE_FORMAT "I32u" +#define SIZE_FORMAT "I32u" #else -# define SIZE_FORMAT "zu" +#define SIZE_FORMAT "zu" #endif typedef struct @@ -418,8 +414,7 @@ typedef struct int status; } overflow_test; -static const overflow_test multiplications[] = -{ +static const overflow_test multiplications[] = { { 1, 1, 1, 0 }, { 0, 0, 0, 0 }, { SDL_SIZE_MAX, 0, 0, 0 }, @@ -432,8 +427,7 @@ static const overflow_test multiplications[] = { SDL_SIZE_MAX, SDL_SIZE_MAX, 0, -1 }, }; -static const overflow_test additions[] = -{ +static const overflow_test additions[] = { { 1, 1, 2, 0 }, { 0, 0, 0, 0 }, { SDL_SIZE_MAX, 0, SDL_SIZE_MAX, 0 }, @@ -448,142 +442,147 @@ static const overflow_test additions[] = static int stdlib_overflow(void *arg) { - size_t i; - size_t useBuiltin; + size_t i; + size_t useBuiltin; - for (useBuiltin = 0; useBuiltin < 2; useBuiltin++) { - if (useBuiltin) { - SDLTest_Log("Using gcc/clang builtins if possible"); - } else { - SDLTest_Log("Not using gcc/clang builtins"); - } + for (useBuiltin = 0; useBuiltin < 2; useBuiltin++) { + if (useBuiltin) { + SDLTest_Log("Using gcc/clang builtins if possible"); + } else { + SDLTest_Log("Not using gcc/clang builtins"); + } - for (i = 0; i < SDL_arraysize(multiplications); i++) { - const overflow_test *t = &multiplications[i]; - int status; - size_t result = ~t->result; + for (i = 0; i < SDL_arraysize(multiplications); i++) { + const overflow_test *t = &multiplications[i]; + int status; + size_t result = ~t->result; - if (useBuiltin) { - status = SDL_size_mul_overflow(t->a, t->b, &result); - } else { - /* This disables the macro that tries to use a gcc/clang - * builtin, so we test the fallback implementation instead. */ - status = (SDL_size_mul_overflow)(t->a, t->b, &result); - } + if (useBuiltin) { + status = SDL_size_mul_overflow(t->a, t->b, &result); + } else { + /* This disables the macro that tries to use a gcc/clang + * builtin, so we test the fallback implementation instead. */ + status = (SDL_size_mul_overflow)(t->a, t->b, &result); + } - if (t->status == 0) { - SDLTest_AssertCheck(status == 0, - "(%" SIZE_FORMAT " * %" SIZE_FORMAT ") should succeed", - t->a, t->b); - SDLTest_AssertCheck(result == t->result, - "(%" SIZE_FORMAT " * %" SIZE_FORMAT "): expected %" SIZE_FORMAT ", got %" SIZE_FORMAT, - t->a, t->b, t->result, result); - } else { - SDLTest_AssertCheck(status == -1, - "(%" SIZE_FORMAT " * %" SIZE_FORMAT ") should fail", - t->a, t->b); - } + if (t->status == 0) { + SDLTest_AssertCheck(status == 0, + "(%" SIZE_FORMAT " * %" SIZE_FORMAT ") should succeed", + t->a, t->b); + SDLTest_AssertCheck(result == t->result, + "(%" SIZE_FORMAT " * %" SIZE_FORMAT "): expected %" SIZE_FORMAT ", got %" SIZE_FORMAT, + t->a, t->b, t->result, result); + } else { + SDLTest_AssertCheck(status == -1, + "(%" SIZE_FORMAT " * %" SIZE_FORMAT ") should fail", + t->a, t->b); + } - if (t->a == t->b) { - continue; - } + if (t->a == t->b) { + continue; + } - result = ~t->result; + result = ~t->result; - if (useBuiltin) { - status = SDL_size_mul_overflow(t->b, t->a, &result); - } else { - status = (SDL_size_mul_overflow)(t->b, t->a, &result); - } + if (useBuiltin) { + status = SDL_size_mul_overflow(t->b, t->a, &result); + } else { + status = (SDL_size_mul_overflow)(t->b, t->a, &result); + } - if (t->status == 0) { - SDLTest_AssertCheck(status == 0, - "(%" SIZE_FORMAT " * %" SIZE_FORMAT ") should succeed", - t->b, t->a); - SDLTest_AssertCheck(result == t->result, - "(%" SIZE_FORMAT " * %" SIZE_FORMAT "): expected %" SIZE_FORMAT ", got %" SIZE_FORMAT, - t->b, t->a, t->result, result); - } else { - SDLTest_AssertCheck(status == -1, - "(%" SIZE_FORMAT " * %" SIZE_FORMAT ") should fail", - t->b, t->a); - } - } + if (t->status == 0) { + SDLTest_AssertCheck(status == 0, + "(%" SIZE_FORMAT " * %" SIZE_FORMAT ") should succeed", + t->b, t->a); + SDLTest_AssertCheck(result == t->result, + "(%" SIZE_FORMAT " * %" SIZE_FORMAT "): expected %" SIZE_FORMAT ", got %" SIZE_FORMAT, + t->b, t->a, t->result, result); + } else { + SDLTest_AssertCheck(status == -1, + "(%" SIZE_FORMAT " * %" SIZE_FORMAT ") should fail", + t->b, t->a); + } + } - for (i = 0; i < SDL_arraysize(additions); i++) { - const overflow_test *t = &additions[i]; - int status; - size_t result = ~t->result; + for (i = 0; i < SDL_arraysize(additions); i++) { + const overflow_test *t = &additions[i]; + int status; + size_t result = ~t->result; - if (useBuiltin) { - status = SDL_size_add_overflow(t->a, t->b, &result); - } else { - status = (SDL_size_add_overflow)(t->a, t->b, &result); - } + if (useBuiltin) { + status = SDL_size_add_overflow(t->a, t->b, &result); + } else { + status = (SDL_size_add_overflow)(t->a, t->b, &result); + } - if (t->status == 0) { - SDLTest_AssertCheck(status == 0, - "(%" SIZE_FORMAT " + %" SIZE_FORMAT ") should succeed", - t->a, t->b); - SDLTest_AssertCheck(result == t->result, - "(%" SIZE_FORMAT " + %" SIZE_FORMAT "): expected %" SIZE_FORMAT ", got %" SIZE_FORMAT, - t->a, t->b, t->result, result); - } else { - SDLTest_AssertCheck(status == -1, - "(%" SIZE_FORMAT " + %" SIZE_FORMAT ") should fail", - t->a, t->b); - } + if (t->status == 0) { + SDLTest_AssertCheck(status == 0, + "(%" SIZE_FORMAT " + %" SIZE_FORMAT ") should succeed", + t->a, t->b); + SDLTest_AssertCheck(result == t->result, + "(%" SIZE_FORMAT " + %" SIZE_FORMAT "): expected %" SIZE_FORMAT ", got %" SIZE_FORMAT, + t->a, t->b, t->result, result); + } else { + SDLTest_AssertCheck(status == -1, + "(%" SIZE_FORMAT " + %" SIZE_FORMAT ") should fail", + t->a, t->b); + } - if (t->a == t->b) { - continue; - } + if (t->a == t->b) { + continue; + } - result = ~t->result; + result = ~t->result; - if (useBuiltin) { - status = SDL_size_add_overflow(t->b, t->a, &result); - } else { - status = (SDL_size_add_overflow)(t->b, t->a, &result); - } + if (useBuiltin) { + status = SDL_size_add_overflow(t->b, t->a, &result); + } else { + status = (SDL_size_add_overflow)(t->b, t->a, &result); + } - if (t->status == 0) { - SDLTest_AssertCheck(status == 0, - "(%" SIZE_FORMAT " + %" SIZE_FORMAT ") should succeed", - t->b, t->a); - SDLTest_AssertCheck(result == t->result, - "(%" SIZE_FORMAT " + %" SIZE_FORMAT "): expected %" SIZE_FORMAT ", got %" SIZE_FORMAT, - t->b, t->a, t->result, result); - } else { - SDLTest_AssertCheck(status == -1, - "(%" SIZE_FORMAT " + %" SIZE_FORMAT ") should fail", - t->b, t->a); - } - } - } + if (t->status == 0) { + SDLTest_AssertCheck(status == 0, + "(%" SIZE_FORMAT " + %" SIZE_FORMAT ") should succeed", + t->b, t->a); + SDLTest_AssertCheck(result == t->result, + "(%" SIZE_FORMAT " + %" SIZE_FORMAT "): expected %" SIZE_FORMAT ", got %" SIZE_FORMAT, + t->b, t->a, t->result, result); + } else { + SDLTest_AssertCheck(status == -1, + "(%" SIZE_FORMAT " + %" SIZE_FORMAT ") should fail", + t->b, t->a); + } + } + } - return TEST_COMPLETED; + return TEST_COMPLETED; } /* ================= Test References ================== */ /* Standard C routine test cases */ -static const SDLTest_TestCaseReference stdlibTest1 = - { (SDLTest_TestCaseFp)stdlib_strlcpy, "stdlib_strlcpy", "Call to SDL_strlcpy", TEST_ENABLED }; +static const SDLTest_TestCaseReference stdlibTest1 = { + (SDLTest_TestCaseFp)stdlib_strlcpy, "stdlib_strlcpy", "Call to SDL_strlcpy", TEST_ENABLED +}; -static const SDLTest_TestCaseReference stdlibTest2 = - { (SDLTest_TestCaseFp)stdlib_snprintf, "stdlib_snprintf", "Call to SDL_snprintf", TEST_ENABLED }; +static const SDLTest_TestCaseReference stdlibTest2 = { + (SDLTest_TestCaseFp)stdlib_snprintf, "stdlib_snprintf", "Call to SDL_snprintf", TEST_ENABLED +}; -static const SDLTest_TestCaseReference stdlibTest3 = - { (SDLTest_TestCaseFp)stdlib_getsetenv, "stdlib_getsetenv", "Call to SDL_getenv and SDL_setenv", TEST_ENABLED }; +static const SDLTest_TestCaseReference stdlibTest3 = { + (SDLTest_TestCaseFp)stdlib_getsetenv, "stdlib_getsetenv", "Call to SDL_getenv and SDL_setenv", TEST_ENABLED +}; -static const SDLTest_TestCaseReference stdlibTest4 = - { (SDLTest_TestCaseFp)stdlib_sscanf, "stdlib_sscanf", "Call to SDL_sscanf", TEST_ENABLED }; +static const SDLTest_TestCaseReference stdlibTest4 = { + (SDLTest_TestCaseFp)stdlib_sscanf, "stdlib_sscanf", "Call to SDL_sscanf", TEST_ENABLED +}; -static const SDLTest_TestCaseReference stdlibTestOverflow = - { stdlib_overflow, "stdlib_overflow", "Overflow detection", TEST_ENABLED }; +static const SDLTest_TestCaseReference stdlibTestOverflow = { + stdlib_overflow, "stdlib_overflow", "Overflow detection", TEST_ENABLED +}; /* Sequence of Standard C routine test cases */ -static const SDLTest_TestCaseReference *stdlibTests[] = { +static const SDLTest_TestCaseReference *stdlibTests[] = { &stdlibTest1, &stdlibTest2, &stdlibTest3, diff --git a/test/testautomation_suites.h b/test/testautomation_suites.h index 7fcce1b1c..6fdcd8388 100644 --- a/test/testautomation_suites.h +++ b/test/testautomation_suites.h @@ -32,7 +32,7 @@ extern SDLTest_TestSuiteReference timerTestSuite; extern SDLTest_TestSuiteReference videoTestSuite; /* All test suites */ -SDLTest_TestSuiteReference *testSuites[] = { +SDLTest_TestSuiteReference *testSuites[] = { &audioTestSuite, &clipboardTestSuite, &eventsTestSuite, diff --git a/test/testautomation_surface.c b/test/testautomation_surface.c index 5479c607f..6619d7a97 100644 --- a/test/testautomation_surface.c +++ b/test/testautomation_surface.c @@ -29,14 +29,13 @@ static SDL_Surface *testSurface = NULL; /* Helper functions for the test cases */ -#define TEST_SURFACE_WIDTH testSurface->w +#define TEST_SURFACE_WIDTH testSurface->w #define TEST_SURFACE_HEIGHT testSurface->h /* Fixture */ /* Create a 32-bit writable surface for blitting tests */ -void -_surfaceSetUp(void *arg) +void _surfaceSetUp(void *arg) { int result; SDL_BlendMode blendMode = SDL_BLENDMODE_NONE; @@ -58,17 +57,16 @@ _surfaceSetUp(void *arg) testSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, referenceSurface->w, referenceSurface->h, 32, rmask, gmask, bmask, amask); SDLTest_AssertCheck(testSurface != NULL, "Check that testSurface is not NULL"); if (testSurface != NULL) { - /* Disable blend mode for target surface */ - result = SDL_SetSurfaceBlendMode(testSurface, blendMode); - SDLTest_AssertCheck(result == 0, "Validate result from SDL_SetSurfaceBlendMode, expected: 0, got: %i", result); - result = SDL_GetSurfaceBlendMode(testSurface, ¤tBlendMode); - SDLTest_AssertCheck(result == 0, "Validate result from SDL_GetSurfaceBlendMode, expected: 0, got: %i", result); - SDLTest_AssertCheck(currentBlendMode == blendMode, "Validate blendMode, expected: %i, got: %i", blendMode, currentBlendMode); + /* Disable blend mode for target surface */ + result = SDL_SetSurfaceBlendMode(testSurface, blendMode); + SDLTest_AssertCheck(result == 0, "Validate result from SDL_SetSurfaceBlendMode, expected: 0, got: %i", result); + result = SDL_GetSurfaceBlendMode(testSurface, ¤tBlendMode); + SDLTest_AssertCheck(result == 0, "Validate result from SDL_GetSurfaceBlendMode, expected: 0, got: %i", result); + SDLTest_AssertCheck(currentBlendMode == blendMode, "Validate blendMode, expected: %i, got: %i", blendMode, currentBlendMode); } } -void -_surfaceTearDown(void *arg) +void _surfaceTearDown(void *arg) { SDL_FreeSurface(referenceSurface); referenceSurface = NULL; @@ -85,9 +83,9 @@ void _clearTestSurface() Uint32 color; /* Clear surface. */ - color = SDL_MapRGBA( testSurface->format, 0, 0, 0, 0); + color = SDL_MapRGBA(testSurface->format, 0, 0, 0, 0); SDLTest_AssertPass("Call to SDL_MapRGBA()"); - ret = SDL_FillRect( testSurface, NULL, color); + ret = SDL_FillRect(testSurface, NULL, color); SDLTest_AssertPass("Call to SDL_FillRect()"); SDLTest_AssertCheck(ret == 0, "Verify result from SDL_FillRect, expected: 0, got: %i", ret); } @@ -121,23 +119,23 @@ void _testBlitBlendMode(int mode) return; } - /* Reset alpha modulation */ + /* Reset alpha modulation */ ret = SDL_SetSurfaceAlphaMod(face, 255); SDLTest_AssertPass("Call to SDL_SetSurfaceAlphaMod()"); SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceAlphaMod(), expected: 0, got: %i", ret); - /* Reset color modulation */ + /* Reset color modulation */ ret = SDL_SetSurfaceColorMod(face, 255, 255, 255); SDLTest_AssertPass("Call to SDL_SetSurfaceColorMod()"); SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceColorMod(), expected: 0, got: %i", ret); - /* Reset color key */ + /* Reset color key */ ret = SDL_SetColorKey(face, SDL_FALSE, 0); SDLTest_AssertPass("Call to SDL_SetColorKey()"); SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey(), expected: 0, got: %i", ret); /* Clear the test surface */ - _clearTestSurface(); + _clearTestSurface(); /* Target rect size */ rect.w = face->w; @@ -149,7 +147,7 @@ void _testBlitBlendMode(int mode) /* Optionally set blend mode. */ if (mode >= 0) { - ret = SDL_SetSurfaceBlendMode( face, (SDL_BlendMode)mode ); + ret = SDL_SetSurfaceBlendMode(face, (SDL_BlendMode)mode); SDLTest_AssertPass("Call to SDL_SetSurfaceBlendMode()"); SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceBlendMode(..., %i), expected: 0, got: %i", mode, ret); } @@ -159,50 +157,50 @@ void _testBlitBlendMode(int mode) checkFailCount2 = 0; checkFailCount3 = 0; checkFailCount4 = 0; - for (j=0; j <= nj; j+=4) { - for (i=0; i <= ni; i+=4) { - if (mode == -2) { - /* Set color mod. */ - ret = SDL_SetSurfaceColorMod( face, (255/nj)*j, (255/ni)*i, (255/nj)*j ); - if (ret != 0) { - checkFailCount2++; + for (j = 0; j <= nj; j += 4) { + for (i = 0; i <= ni; i += 4) { + if (mode == -2) { + /* Set color mod. */ + ret = SDL_SetSurfaceColorMod(face, (255 / nj) * j, (255 / ni) * i, (255 / nj) * j); + if (ret != 0) { + checkFailCount2++; + } + } else if (mode == -3) { + /* Set alpha mod. */ + ret = SDL_SetSurfaceAlphaMod(face, (255 / ni) * i); + if (ret != 0) { + checkFailCount3++; + } + } else if (mode == -4) { + /* Crazy blending mode magic. */ + nmode = (i / 4 * j / 4) % 4; + if (nmode == 0) { + bmode = SDL_BLENDMODE_NONE; + } else if (nmode == 1) { + bmode = SDL_BLENDMODE_BLEND; + } else if (nmode == 2) { + bmode = SDL_BLENDMODE_ADD; + } else if (nmode == 3) { + bmode = SDL_BLENDMODE_MOD; + } else { + /* Should be impossible, but some static checkers are too imprecise and will complain */ + SDLTest_LogError("Invalid: nmode=%d", nmode); + return; + } + ret = SDL_SetSurfaceBlendMode(face, bmode); + if (ret != 0) { + checkFailCount4++; + } } - } else if (mode == -3) { - /* Set alpha mod. */ - ret = SDL_SetSurfaceAlphaMod( face, (255/ni)*i ); + + /* Blitting. */ + rect.x = i; + rect.y = j; + ret = SDL_BlitSurface(face, NULL, testSurface, &rect); if (ret != 0) { - checkFailCount3++; - } - } else if (mode == -4) { - /* Crazy blending mode magic. */ - nmode = (i/4*j/4) % 4; - if (nmode==0) { - bmode = SDL_BLENDMODE_NONE; - } else if (nmode==1) { - bmode = SDL_BLENDMODE_BLEND; - } else if (nmode==2) { - bmode = SDL_BLENDMODE_ADD; - } else if (nmode==3) { - bmode = SDL_BLENDMODE_MOD; - } else { - /* Should be impossible, but some static checkers are too imprecise and will complain */ - SDLTest_LogError("Invalid: nmode=%d", nmode); - return; - } - ret = SDL_SetSurfaceBlendMode( face, bmode ); - if (ret != 0) { - checkFailCount4++; + checkFailCount1++; } } - - /* Blitting. */ - rect.x = i; - rect.y = j; - ret = SDL_BlitSurface( face, NULL, testSurface, &rect ); - if (ret != 0) { - checkFailCount1++; - } - } } SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_BlitSurface, expected: 0, got: %i", checkFailCount1); SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetSurfaceColorMod, expected: 0, got: %i", checkFailCount2); @@ -215,8 +213,7 @@ void _testBlitBlendMode(int mode) } /* Helper to check that a file exists */ -void -_AssertFileExist(const char *filename) +void _AssertFileExist(const char *filename) { struct stat st; int ret = stat(filename, &st); @@ -224,14 +221,12 @@ _AssertFileExist(const char *filename) SDLTest_AssertCheck(ret == 0, "Verify file '%s' exists", filename); } - /* Test case functions */ /** * @brief Tests sprite saving and loading */ -int -surface_testSaveLoadBitmap(void *arg) +int surface_testSaveLoadBitmap(void *arg) { int ret; const char *sampleFilename = "testSaveLoadBitmap.bmp"; @@ -278,8 +273,7 @@ surface_testSaveLoadBitmap(void *arg) /* ! * Tests surface conversion. */ -int -surface_testSurfaceConversion(void *arg) +int surface_testSurfaceConversion(void *arg) { SDL_Surface *rface = NULL, *face = NULL; int ret = 0; @@ -293,9 +287,9 @@ surface_testSurfaceConversion(void *arg) /* Set transparent pixel as the pixel at (0,0) */ if (face->format->palette) { - ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels); - SDLTest_AssertPass("Call to SDL_SetColorKey()"); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey, expected: 0, got: %i", ret); + ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *)face->pixels); + SDLTest_AssertPass("Call to SDL_SetColorKey()"); + SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey, expected: 0, got: %i", ret); } /* Convert to 32 bit to compare. */ @@ -304,7 +298,7 @@ surface_testSurfaceConversion(void *arg) SDLTest_AssertCheck(rface != NULL, "Verify result from SDL_ConvertSurface is not NULL"); /* Compare surface. */ - ret = SDLTest_CompareSurfaces( rface, face, 0 ); + ret = SDLTest_CompareSurfaces(rface, face, 0); SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ @@ -316,12 +310,10 @@ surface_testSurfaceConversion(void *arg) return TEST_COMPLETED; } - /* ! * Tests surface conversion across all pixel formats. */ -int -surface_testCompleteSurfaceConversion(void *arg) +int surface_testCompleteSurfaceConversion(void *arg) { Uint32 pixel_formats[] = { SDL_PIXELFORMAT_INDEX8, @@ -365,13 +357,13 @@ surface_testCompleteSurfaceConversion(void *arg) /* Set transparent pixel as the pixel at (0,0) */ if (face->format->palette) { - ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels); - SDLTest_AssertPass("Call to SDL_SetColorKey()"); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey, expected: 0, got: %i", ret); + ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *)face->pixels); + SDLTest_AssertPass("Call to SDL_SetColorKey()"); + SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey, expected: 0, got: %i", ret); } - for ( i = 0; i < SDL_arraysize(pixel_formats); ++i ) { - for ( j = 0; j < SDL_arraysize(pixel_formats); ++j ) { + for (i = 0; i < SDL_arraysize(pixel_formats); ++i) { + for (j = 0; j < SDL_arraysize(pixel_formats); ++j) { fmt1 = SDL_AllocFormat(pixel_formats[i]); SDL_assert(fmt1 != NULL); cvt1 = SDL_ConvertSurface(face, fmt1, 0); @@ -390,7 +382,7 @@ surface_testCompleteSurfaceConversion(void *arg) SDL_assert(final != NULL); /* Compare surface. */ - ret = SDLTest_CompareSurfaces( face, final, 0 ); + ret = SDLTest_CompareSurfaces(face, final, 0); SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); SDL_FreeSurface(final); } @@ -403,17 +395,15 @@ surface_testCompleteSurfaceConversion(void *arg) } /* Clean up. */ - SDL_FreeSurface( face ); + SDL_FreeSurface(face); return TEST_COMPLETED; } - /** * @brief Tests sprite loading. A failure case. */ -int -surface_testLoadFailure(void *arg) +int surface_testLoadFailure(void *arg) { SDL_Surface *face = SDL_LoadBMP("nonexistant.bmp"); SDLTest_AssertCheck(face == NULL, "SDL_CreateLoadBmp"); @@ -424,191 +414,181 @@ surface_testLoadFailure(void *arg) /** * @brief Tests some blitting routines. */ -int -surface_testBlit(void *arg) +int surface_testBlit(void *arg) { - int ret; - SDL_Surface *compareSurface; + int ret; + SDL_Surface *compareSurface; - /* Basic blitting */ - _testBlitBlendMode(-1); + /* Basic blitting */ + _testBlitBlendMode(-1); - /* Verify result by comparing surfaces */ - compareSurface = SDLTest_ImageBlit(); - ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); + /* Verify result by comparing surfaces */ + compareSurface = SDLTest_ImageBlit(); + ret = SDLTest_CompareSurfaces(testSurface, compareSurface, 0); + SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - /* Clean up. */ - SDL_FreeSurface(compareSurface); + /* Clean up. */ + SDL_FreeSurface(compareSurface); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Tests some blitting routines with color mod */ -int -surface_testBlitColorMod(void *arg) +int surface_testBlitColorMod(void *arg) { - int ret; - SDL_Surface *compareSurface; + int ret; + SDL_Surface *compareSurface; - /* Basic blitting with color mod */ - _testBlitBlendMode(-2); + /* Basic blitting with color mod */ + _testBlitBlendMode(-2); - /* Verify result by comparing surfaces */ - compareSurface = SDLTest_ImageBlitColor(); - ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); + /* Verify result by comparing surfaces */ + compareSurface = SDLTest_ImageBlitColor(); + ret = SDLTest_CompareSurfaces(testSurface, compareSurface, 0); + SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - /* Clean up. */ - SDL_FreeSurface(compareSurface); + /* Clean up. */ + SDL_FreeSurface(compareSurface); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Tests some blitting routines with alpha mod */ -int -surface_testBlitAlphaMod(void *arg) +int surface_testBlitAlphaMod(void *arg) { - int ret; - SDL_Surface *compareSurface; + int ret; + SDL_Surface *compareSurface; - /* Basic blitting with alpha mod */ - _testBlitBlendMode(-3); + /* Basic blitting with alpha mod */ + _testBlitBlendMode(-3); - /* Verify result by comparing surfaces */ - compareSurface = SDLTest_ImageBlitAlpha(); - ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); + /* Verify result by comparing surfaces */ + compareSurface = SDLTest_ImageBlitAlpha(); + ret = SDLTest_CompareSurfaces(testSurface, compareSurface, 0); + SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - /* Clean up. */ - SDL_FreeSurface(compareSurface); + /* Clean up. */ + SDL_FreeSurface(compareSurface); - return TEST_COMPLETED; -} - - -/** - * @brief Tests some more blitting routines. - */ -int -surface_testBlitBlendNone(void *arg) -{ - int ret; - SDL_Surface *compareSurface; - - /* Basic blitting */ - _testBlitBlendMode(SDL_BLENDMODE_NONE); - - /* Verify result by comparing surfaces */ - compareSurface = SDLTest_ImageBlitBlendNone(); - ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - - /* Clean up. */ - SDL_FreeSurface(compareSurface); - - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Tests some more blitting routines. */ -int -surface_testBlitBlendBlend(void *arg) +int surface_testBlitBlendNone(void *arg) { - int ret; - SDL_Surface *compareSurface; + int ret; + SDL_Surface *compareSurface; - /* Blend blitting */ - _testBlitBlendMode(SDL_BLENDMODE_BLEND); + /* Basic blitting */ + _testBlitBlendMode(SDL_BLENDMODE_NONE); - /* Verify result by comparing surfaces */ - compareSurface = SDLTest_ImageBlitBlend(); - ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); + /* Verify result by comparing surfaces */ + compareSurface = SDLTest_ImageBlitBlendNone(); + ret = SDLTest_CompareSurfaces(testSurface, compareSurface, 0); + SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - /* Clean up. */ - SDL_FreeSurface(compareSurface); + /* Clean up. */ + SDL_FreeSurface(compareSurface); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Tests some more blitting routines. */ -int -surface_testBlitBlendAdd(void *arg) +int surface_testBlitBlendBlend(void *arg) { - int ret; - SDL_Surface *compareSurface; + int ret; + SDL_Surface *compareSurface; - /* Add blitting */ - _testBlitBlendMode(SDL_BLENDMODE_ADD); + /* Blend blitting */ + _testBlitBlendMode(SDL_BLENDMODE_BLEND); - /* Verify result by comparing surfaces */ - compareSurface = SDLTest_ImageBlitBlendAdd(); - ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); + /* Verify result by comparing surfaces */ + compareSurface = SDLTest_ImageBlitBlend(); + ret = SDLTest_CompareSurfaces(testSurface, compareSurface, 0); + SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - /* Clean up. */ - SDL_FreeSurface(compareSurface); + /* Clean up. */ + SDL_FreeSurface(compareSurface); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Tests some more blitting routines. */ -int -surface_testBlitBlendMod(void *arg) +int surface_testBlitBlendAdd(void *arg) { - int ret; - SDL_Surface *compareSurface; + int ret; + SDL_Surface *compareSurface; - /* Mod blitting */ - _testBlitBlendMode(SDL_BLENDMODE_MOD); + /* Add blitting */ + _testBlitBlendMode(SDL_BLENDMODE_ADD); - /* Verify result by comparing surfaces */ - compareSurface = SDLTest_ImageBlitBlendMod(); - ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); + /* Verify result by comparing surfaces */ + compareSurface = SDLTest_ImageBlitBlendAdd(); + ret = SDLTest_CompareSurfaces(testSurface, compareSurface, 0); + SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - /* Clean up. */ - SDL_FreeSurface(compareSurface); + /* Clean up. */ + SDL_FreeSurface(compareSurface); - return TEST_COMPLETED; + return TEST_COMPLETED; +} + +/** + * @brief Tests some more blitting routines. + */ +int surface_testBlitBlendMod(void *arg) +{ + int ret; + SDL_Surface *compareSurface; + + /* Mod blitting */ + _testBlitBlendMode(SDL_BLENDMODE_MOD); + + /* Verify result by comparing surfaces */ + compareSurface = SDLTest_ImageBlitBlendMod(); + ret = SDLTest_CompareSurfaces(testSurface, compareSurface, 0); + SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); + + /* Clean up. */ + SDL_FreeSurface(compareSurface); + + return TEST_COMPLETED; } /** * @brief Tests some more blitting routines with loop */ -int -surface_testBlitBlendLoop(void *arg) { +int surface_testBlitBlendLoop(void *arg) +{ - int ret; - SDL_Surface *compareSurface; + int ret; + SDL_Surface *compareSurface; - /* All blitting modes */ - _testBlitBlendMode(-4); + /* All blitting modes */ + _testBlitBlendMode(-4); - /* Verify result by comparing surfaces */ - compareSurface = SDLTest_ImageBlitBlendAll(); - ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); + /* Verify result by comparing surfaces */ + compareSurface = SDLTest_ImageBlitBlendAll(); + ret = SDLTest_CompareSurfaces(testSurface, compareSurface, 0); + SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - /* Clean up. */ - SDL_FreeSurface(compareSurface); - - return TEST_COMPLETED; + /* Clean up. */ + SDL_FreeSurface(compareSurface); + return TEST_COMPLETED; } -int -surface_testOverflow(void *arg) +int surface_testOverflow(void *arg) { char buf[1024]; const char *expectedError; @@ -752,7 +732,7 @@ surface_testOverflow(void *arg) SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); - if (sizeof (size_t) == 4 && sizeof (int) >= 4) { + if (sizeof(size_t) == 4 && sizeof(int) >= 4) { expectedError = "Out of memory"; surface = SDL_CreateRGBSurfaceWithFormat(0, SDL_MAX_SINT32, 1, 8, SDL_PIXELFORMAT_INDEX8); SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width + alignment"); @@ -780,50 +760,63 @@ surface_testOverflow(void *arg) /* ================= Test References ================== */ /* Surface test cases */ -static const SDLTest_TestCaseReference surfaceTest1 = - { (SDLTest_TestCaseFp)surface_testSaveLoadBitmap, "surface_testSaveLoadBitmap", "Tests sprite saving and loading.", TEST_ENABLED}; +static const SDLTest_TestCaseReference surfaceTest1 = { + (SDLTest_TestCaseFp)surface_testSaveLoadBitmap, "surface_testSaveLoadBitmap", "Tests sprite saving and loading.", TEST_ENABLED +}; -static const SDLTest_TestCaseReference surfaceTest2 = - { (SDLTest_TestCaseFp)surface_testBlit, "surface_testBlit", "Tests basic blitting.", TEST_ENABLED}; +static const SDLTest_TestCaseReference surfaceTest2 = { + (SDLTest_TestCaseFp)surface_testBlit, "surface_testBlit", "Tests basic blitting.", TEST_ENABLED +}; -static const SDLTest_TestCaseReference surfaceTest3 = - { (SDLTest_TestCaseFp)surface_testBlitBlendNone, "surface_testBlitBlendNone", "Tests blitting routines with none blending mode.", TEST_ENABLED}; +static const SDLTest_TestCaseReference surfaceTest3 = { + (SDLTest_TestCaseFp)surface_testBlitBlendNone, "surface_testBlitBlendNone", "Tests blitting routines with none blending mode.", TEST_ENABLED +}; -static const SDLTest_TestCaseReference surfaceTest4 = - { (SDLTest_TestCaseFp)surface_testLoadFailure, "surface_testLoadFailure", "Tests sprite loading. A failure case.", TEST_ENABLED}; +static const SDLTest_TestCaseReference surfaceTest4 = { + (SDLTest_TestCaseFp)surface_testLoadFailure, "surface_testLoadFailure", "Tests sprite loading. A failure case.", TEST_ENABLED +}; -static const SDLTest_TestCaseReference surfaceTest5 = - { (SDLTest_TestCaseFp)surface_testSurfaceConversion, "surface_testSurfaceConversion", "Tests surface conversion.", TEST_ENABLED}; +static const SDLTest_TestCaseReference surfaceTest5 = { + (SDLTest_TestCaseFp)surface_testSurfaceConversion, "surface_testSurfaceConversion", "Tests surface conversion.", TEST_ENABLED +}; -static const SDLTest_TestCaseReference surfaceTest6 = - { (SDLTest_TestCaseFp)surface_testCompleteSurfaceConversion, "surface_testCompleteSurfaceConversion", "Tests surface conversion across all pixel formats", TEST_ENABLED}; +static const SDLTest_TestCaseReference surfaceTest6 = { + (SDLTest_TestCaseFp)surface_testCompleteSurfaceConversion, "surface_testCompleteSurfaceConversion", "Tests surface conversion across all pixel formats", TEST_ENABLED +}; -static const SDLTest_TestCaseReference surfaceTest7 = - { (SDLTest_TestCaseFp)surface_testBlitColorMod, "surface_testBlitColorMod", "Tests some blitting routines with color mod.", TEST_ENABLED}; +static const SDLTest_TestCaseReference surfaceTest7 = { + (SDLTest_TestCaseFp)surface_testBlitColorMod, "surface_testBlitColorMod", "Tests some blitting routines with color mod.", TEST_ENABLED +}; -static const SDLTest_TestCaseReference surfaceTest8 = - { (SDLTest_TestCaseFp)surface_testBlitAlphaMod, "surface_testBlitAlphaMod", "Tests some blitting routines with alpha mod.", TEST_ENABLED}; +static const SDLTest_TestCaseReference surfaceTest8 = { + (SDLTest_TestCaseFp)surface_testBlitAlphaMod, "surface_testBlitAlphaMod", "Tests some blitting routines with alpha mod.", TEST_ENABLED +}; /* TODO: rewrite test case, define new test data and re-enable; current implementation fails */ -static const SDLTest_TestCaseReference surfaceTest9 = - { (SDLTest_TestCaseFp)surface_testBlitBlendLoop, "surface_testBlitBlendLoop", "Test blitting routines with various blending modes", TEST_DISABLED}; +static const SDLTest_TestCaseReference surfaceTest9 = { + (SDLTest_TestCaseFp)surface_testBlitBlendLoop, "surface_testBlitBlendLoop", "Test blitting routines with various blending modes", TEST_DISABLED +}; /* TODO: rewrite test case, define new test data and re-enable; current implementation fails */ -static const SDLTest_TestCaseReference surfaceTest10 = - { (SDLTest_TestCaseFp)surface_testBlitBlendBlend, "surface_testBlitBlendBlend", "Tests blitting routines with blend blending mode.", TEST_DISABLED}; +static const SDLTest_TestCaseReference surfaceTest10 = { + (SDLTest_TestCaseFp)surface_testBlitBlendBlend, "surface_testBlitBlendBlend", "Tests blitting routines with blend blending mode.", TEST_DISABLED +}; /* TODO: rewrite test case, define new test data and re-enable; current implementation fails */ -static const SDLTest_TestCaseReference surfaceTest11 = - { (SDLTest_TestCaseFp)surface_testBlitBlendAdd, "surface_testBlitBlendAdd", "Tests blitting routines with add blending mode.", TEST_DISABLED}; +static const SDLTest_TestCaseReference surfaceTest11 = { + (SDLTest_TestCaseFp)surface_testBlitBlendAdd, "surface_testBlitBlendAdd", "Tests blitting routines with add blending mode.", TEST_DISABLED +}; -static const SDLTest_TestCaseReference surfaceTest12 = - { (SDLTest_TestCaseFp)surface_testBlitBlendMod, "surface_testBlitBlendMod", "Tests blitting routines with mod blending mode.", TEST_ENABLED}; +static const SDLTest_TestCaseReference surfaceTest12 = { + (SDLTest_TestCaseFp)surface_testBlitBlendMod, "surface_testBlitBlendMod", "Tests blitting routines with mod blending mode.", TEST_ENABLED +}; -static const SDLTest_TestCaseReference surfaceTestOverflow = - { surface_testOverflow, "surface_testOverflow", "Test overflow detection.", TEST_ENABLED}; +static const SDLTest_TestCaseReference surfaceTestOverflow = { + surface_testOverflow, "surface_testOverflow", "Test overflow detection.", TEST_ENABLED +}; /* Sequence of Surface test cases */ -static const SDLTest_TestCaseReference *surfaceTests[] = { +static const SDLTest_TestCaseReference *surfaceTests[] = { &surfaceTest1, &surfaceTest2, &surfaceTest3, &surfaceTest4, &surfaceTest5, &surfaceTest6, &surfaceTest7, &surfaceTest8, &surfaceTest9, &surfaceTest10, &surfaceTest11, &surfaceTest12, &surfaceTestOverflow, NULL diff --git a/test/testautomation_syswm.c b/test/testautomation_syswm.c index d9fd982b3..f636e1518 100644 --- a/test/testautomation_syswm.c +++ b/test/testautomation_syswm.c @@ -13,19 +13,18 @@ /** * @brief Call to SDL_GetWindowWMInfo */ -int -syswm_getWindowWMInfo(void *arg) +int syswm_getWindowWMInfo(void *arg) { SDL_bool result; SDL_Window *window; SDL_SysWMinfo info; - window = SDL_CreateWindow("", 0, 0, 0, 0, SDL_WINDOW_HIDDEN); - SDLTest_AssertPass("Call to SDL_CreateWindow()"); - SDLTest_AssertCheck(window != NULL, "Check that value returned from SDL_CreateWindow is not NULL"); - if (window == NULL) { - return TEST_ABORTED; - } + window = SDL_CreateWindow("", 0, 0, 0, 0, SDL_WINDOW_HIDDEN); + SDLTest_AssertPass("Call to SDL_CreateWindow()"); + SDLTest_AssertCheck(window != NULL, "Check that value returned from SDL_CreateWindow is not NULL"); + if (window == NULL) { + return TEST_ABORTED; + } /* Initialize info structure with SDL version info */ SDL_VERSION(&info.version); @@ -35,20 +34,21 @@ syswm_getWindowWMInfo(void *arg) SDLTest_AssertPass("Call to SDL_GetWindowWMInfo()"); SDLTest_Log((result == SDL_TRUE) ? "Got window information" : "Couldn't get window information"); - SDL_DestroyWindow(window); - SDLTest_AssertPass("Call to SDL_DestroyWindow()"); + SDL_DestroyWindow(window); + SDLTest_AssertPass("Call to SDL_DestroyWindow()"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* ================= Test References ================== */ /* SysWM test cases */ -static const SDLTest_TestCaseReference syswmTest1 = - { (SDLTest_TestCaseFp)syswm_getWindowWMInfo, "syswm_getWindowWMInfo", "Call to SDL_GetWindowWMInfo", TEST_ENABLED }; +static const SDLTest_TestCaseReference syswmTest1 = { + (SDLTest_TestCaseFp)syswm_getWindowWMInfo, "syswm_getWindowWMInfo", "Call to SDL_GetWindowWMInfo", TEST_ENABLED +}; /* Sequence of SysWM test cases */ -static const SDLTest_TestCaseReference *syswmTests[] = { +static const SDLTest_TestCaseReference *syswmTests[] = { &syswmTest1, NULL }; diff --git a/test/testautomation_timer.c b/test/testautomation_timer.c index 3cb160ae1..1002a36eb 100644 --- a/test/testautomation_timer.c +++ b/test/testautomation_timer.c @@ -18,16 +18,15 @@ int _timerCallbackCalled = 0; /* Fixture */ -void -_timerSetUp(void *arg) +void _timerSetUp(void *arg) { /* Start SDL timer subsystem */ - int ret = SDL_InitSubSystem( SDL_INIT_TIMER ); - SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_TIMER)"); - SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_TIMER)"); + int ret = SDL_InitSubSystem(SDL_INIT_TIMER); + SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_TIMER)"); + SDLTest_AssertCheck(ret == 0, "Check result from SDL_InitSubSystem(SDL_INIT_TIMER)"); if (ret != 0) { - SDLTest_LogError("%s", SDL_GetError()); - } + SDLTest_LogError("%s", SDL_GetError()); + } } /* Test case functions */ @@ -35,160 +34,160 @@ _timerSetUp(void *arg) /** * @brief Call to SDL_GetPerformanceCounter */ -int -timer_getPerformanceCounter(void *arg) +int timer_getPerformanceCounter(void *arg) { - Uint64 result; + Uint64 result; - result = SDL_GetPerformanceCounter(); - SDLTest_AssertPass("Call to SDL_GetPerformanceCounter()"); - SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %"SDL_PRIu64, result); + result = SDL_GetPerformanceCounter(); + SDLTest_AssertPass("Call to SDL_GetPerformanceCounter()"); + SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %" SDL_PRIu64, result); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Call to SDL_GetPerformanceFrequency */ -int -timer_getPerformanceFrequency(void *arg) +int timer_getPerformanceFrequency(void *arg) { - Uint64 result; + Uint64 result; - result = SDL_GetPerformanceFrequency(); - SDLTest_AssertPass("Call to SDL_GetPerformanceFrequency()"); - SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %"SDL_PRIu64, result); + result = SDL_GetPerformanceFrequency(); + SDLTest_AssertPass("Call to SDL_GetPerformanceFrequency()"); + SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %" SDL_PRIu64, result); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Call to SDL_Delay and SDL_GetTicks */ -int -timer_delayAndGetTicks(void *arg) +int timer_delayAndGetTicks(void *arg) { - const Uint32 testDelay = 100; - const Uint32 marginOfError = 25; - Uint32 result; - Uint32 result2; - Uint32 difference; + const Uint32 testDelay = 100; + const Uint32 marginOfError = 25; + Uint32 result; + Uint32 result2; + Uint32 difference; - /* Zero delay */ - SDL_Delay(0); - SDLTest_AssertPass("Call to SDL_Delay(0)"); + /* Zero delay */ + SDL_Delay(0); + SDLTest_AssertPass("Call to SDL_Delay(0)"); - /* Non-zero delay */ - SDL_Delay(1); - SDLTest_AssertPass("Call to SDL_Delay(1)"); + /* Non-zero delay */ + SDL_Delay(1); + SDLTest_AssertPass("Call to SDL_Delay(1)"); - SDL_Delay(SDLTest_RandomIntegerInRange(5, 15)); - SDLTest_AssertPass("Call to SDL_Delay()"); + SDL_Delay(SDLTest_RandomIntegerInRange(5, 15)); + SDLTest_AssertPass("Call to SDL_Delay()"); - /* Get ticks count - should be non-zero by now */ - result = SDL_GetTicks(); - SDLTest_AssertPass("Call to SDL_GetTicks()"); - SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %" SDL_PRIu32, result); + /* Get ticks count - should be non-zero by now */ + result = SDL_GetTicks(); + SDLTest_AssertPass("Call to SDL_GetTicks()"); + SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %" SDL_PRIu32, result); - /* Delay a bit longer and measure ticks and verify difference */ - SDL_Delay(testDelay); - SDLTest_AssertPass("Call to SDL_Delay(%" SDL_PRIu32 ")", testDelay); - result2 = SDL_GetTicks(); - SDLTest_AssertPass("Call to SDL_GetTicks()"); - SDLTest_AssertCheck(result2 > 0, "Check result value, expected: >0, got: %" SDL_PRIu32, result2); - difference = result2 - result; - SDLTest_AssertCheck(difference > (testDelay - marginOfError), "Check difference, expected: >%" SDL_PRIu32 ", got: %" SDL_PRIu32, testDelay - marginOfError, difference); - SDLTest_AssertCheck(difference < (testDelay + marginOfError), "Check difference, expected: <%" SDL_PRIu32 ", got: %" SDL_PRIu32, testDelay + marginOfError, difference); + /* Delay a bit longer and measure ticks and verify difference */ + SDL_Delay(testDelay); + SDLTest_AssertPass("Call to SDL_Delay(%" SDL_PRIu32 ")", testDelay); + result2 = SDL_GetTicks(); + SDLTest_AssertPass("Call to SDL_GetTicks()"); + SDLTest_AssertCheck(result2 > 0, "Check result value, expected: >0, got: %" SDL_PRIu32, result2); + difference = result2 - result; + SDLTest_AssertCheck(difference > (testDelay - marginOfError), "Check difference, expected: >%" SDL_PRIu32 ", got: %" SDL_PRIu32, testDelay - marginOfError, difference); + SDLTest_AssertCheck(difference < (testDelay + marginOfError), "Check difference, expected: <%" SDL_PRIu32 ", got: %" SDL_PRIu32, testDelay + marginOfError, difference); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* Test callback */ Uint32 SDLCALL _timerTestCallback(Uint32 interval, void *param) { - _timerCallbackCalled = 1; + _timerCallbackCalled = 1; - if (_paramCheck != 0) { - SDLTest_AssertCheck(param != NULL, "Check param pointer, expected: non-NULL, got: %s", (param != NULL) ? "non-NULL" : "NULL"); - if (param != NULL) { - SDLTest_AssertCheck(*(int *)param == _paramValue, "Check param value, expected: %i, got: %i", _paramValue, *(int *)param); - } - } + if (_paramCheck != 0) { + SDLTest_AssertCheck(param != NULL, "Check param pointer, expected: non-NULL, got: %s", (param != NULL) ? "non-NULL" : "NULL"); + if (param != NULL) { + SDLTest_AssertCheck(*(int *)param == _paramValue, "Check param value, expected: %i, got: %i", _paramValue, *(int *)param); + } + } - return 0; + return 0; } /** * @brief Call to SDL_AddTimer and SDL_RemoveTimer */ -int -timer_addRemoveTimer(void *arg) +int timer_addRemoveTimer(void *arg) { - SDL_TimerID id; - SDL_bool result; - int param; + SDL_TimerID id; + SDL_bool result; + int param; - /* Reset state */ - _paramCheck = 0; - _timerCallbackCalled = 0; + /* Reset state */ + _paramCheck = 0; + _timerCallbackCalled = 0; - /* Set timer with a long delay */ - id = SDL_AddTimer(10000, _timerTestCallback, NULL); - SDLTest_AssertPass("Call to SDL_AddTimer(10000,...)"); - SDLTest_AssertCheck(id > 0, "Check result value, expected: >0, got: %d", id); + /* Set timer with a long delay */ + id = SDL_AddTimer(10000, _timerTestCallback, NULL); + SDLTest_AssertPass("Call to SDL_AddTimer(10000,...)"); + SDLTest_AssertCheck(id > 0, "Check result value, expected: >0, got: %d", id); - /* Remove timer again and check that callback was not called */ - result = SDL_RemoveTimer(id); - SDLTest_AssertPass("Call to SDL_RemoveTimer()"); - SDLTest_AssertCheck(result == SDL_TRUE, "Check result value, expected: %i, got: %i", SDL_TRUE, result); - SDLTest_AssertCheck(_timerCallbackCalled == 0, "Check callback WAS NOT called, expected: 0, got: %i", _timerCallbackCalled); + /* Remove timer again and check that callback was not called */ + result = SDL_RemoveTimer(id); + SDLTest_AssertPass("Call to SDL_RemoveTimer()"); + SDLTest_AssertCheck(result == SDL_TRUE, "Check result value, expected: %i, got: %i", SDL_TRUE, result); + SDLTest_AssertCheck(_timerCallbackCalled == 0, "Check callback WAS NOT called, expected: 0, got: %i", _timerCallbackCalled); - /* Try to remove timer again (should be a NOOP) */ - result = SDL_RemoveTimer(id); - SDLTest_AssertPass("Call to SDL_RemoveTimer()"); - SDLTest_AssertCheck(result == SDL_FALSE, "Check result value, expected: %i, got: %i", SDL_FALSE, result); + /* Try to remove timer again (should be a NOOP) */ + result = SDL_RemoveTimer(id); + SDLTest_AssertPass("Call to SDL_RemoveTimer()"); + SDLTest_AssertCheck(result == SDL_FALSE, "Check result value, expected: %i, got: %i", SDL_FALSE, result); - /* Reset state */ - param = SDLTest_RandomIntegerInRange(-1024, 1024); - _paramCheck = 1; - _paramValue = param; - _timerCallbackCalled = 0; + /* Reset state */ + param = SDLTest_RandomIntegerInRange(-1024, 1024); + _paramCheck = 1; + _paramValue = param; + _timerCallbackCalled = 0; - /* Set timer with a short delay */ - id = SDL_AddTimer(10, _timerTestCallback, (void *)¶m); - SDLTest_AssertPass("Call to SDL_AddTimer(10, param)"); - SDLTest_AssertCheck(id > 0, "Check result value, expected: >0, got: %d", id); + /* Set timer with a short delay */ + id = SDL_AddTimer(10, _timerTestCallback, (void *)¶m); + SDLTest_AssertPass("Call to SDL_AddTimer(10, param)"); + SDLTest_AssertCheck(id > 0, "Check result value, expected: >0, got: %d", id); - /* Wait to let timer trigger callback */ - SDL_Delay(100); - SDLTest_AssertPass("Call to SDL_Delay(100)"); + /* Wait to let timer trigger callback */ + SDL_Delay(100); + SDLTest_AssertPass("Call to SDL_Delay(100)"); - /* Remove timer again and check that callback was called */ - result = SDL_RemoveTimer(id); - SDLTest_AssertPass("Call to SDL_RemoveTimer()"); - SDLTest_AssertCheck(result == SDL_FALSE, "Check result value, expected: %i, got: %i", SDL_FALSE, result); - SDLTest_AssertCheck(_timerCallbackCalled == 1, "Check callback WAS called, expected: 1, got: %i", _timerCallbackCalled); + /* Remove timer again and check that callback was called */ + result = SDL_RemoveTimer(id); + SDLTest_AssertPass("Call to SDL_RemoveTimer()"); + SDLTest_AssertCheck(result == SDL_FALSE, "Check result value, expected: %i, got: %i", SDL_FALSE, result); + SDLTest_AssertCheck(_timerCallbackCalled == 1, "Check callback WAS called, expected: 1, got: %i", _timerCallbackCalled); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* ================= Test References ================== */ /* Timer test cases */ -static const SDLTest_TestCaseReference timerTest1 = - { (SDLTest_TestCaseFp)timer_getPerformanceCounter, "timer_getPerformanceCounter", "Call to SDL_GetPerformanceCounter", TEST_ENABLED }; +static const SDLTest_TestCaseReference timerTest1 = { + (SDLTest_TestCaseFp)timer_getPerformanceCounter, "timer_getPerformanceCounter", "Call to SDL_GetPerformanceCounter", TEST_ENABLED +}; -static const SDLTest_TestCaseReference timerTest2 = - { (SDLTest_TestCaseFp)timer_getPerformanceFrequency, "timer_getPerformanceFrequency", "Call to SDL_GetPerformanceFrequency", TEST_ENABLED }; +static const SDLTest_TestCaseReference timerTest2 = { + (SDLTest_TestCaseFp)timer_getPerformanceFrequency, "timer_getPerformanceFrequency", "Call to SDL_GetPerformanceFrequency", TEST_ENABLED +}; -static const SDLTest_TestCaseReference timerTest3 = - { (SDLTest_TestCaseFp)timer_delayAndGetTicks, "timer_delayAndGetTicks", "Call to SDL_Delay and SDL_GetTicks", TEST_ENABLED }; +static const SDLTest_TestCaseReference timerTest3 = { + (SDLTest_TestCaseFp)timer_delayAndGetTicks, "timer_delayAndGetTicks", "Call to SDL_Delay and SDL_GetTicks", TEST_ENABLED +}; -static const SDLTest_TestCaseReference timerTest4 = - { (SDLTest_TestCaseFp)timer_addRemoveTimer, "timer_addRemoveTimer", "Call to SDL_AddTimer and SDL_RemoveTimer", TEST_ENABLED }; +static const SDLTest_TestCaseReference timerTest4 = { + (SDLTest_TestCaseFp)timer_addRemoveTimer, "timer_addRemoveTimer", "Call to SDL_AddTimer and SDL_RemoveTimer", TEST_ENABLED +}; /* Sequence of Timer test cases */ -static const SDLTest_TestCaseReference *timerTests[] = { +static const SDLTest_TestCaseReference *timerTests[] = { &timerTest1, &timerTest2, &timerTest3, &timerTest4, NULL }; diff --git a/test/testautomation_video.c b/test/testautomation_video.c index fe8c4f095..2e4a6920e 100644 --- a/test/testautomation_video.c +++ b/test/testautomation_video.c @@ -25,22 +25,22 @@ */ SDL_Window *_createVideoSuiteTestWindow(const char *title) { - SDL_Window* window; - int x, y, w, h; - SDL_WindowFlags flags; + SDL_Window *window; + int x, y, w, h; + SDL_WindowFlags flags; - /* Standard window */ - x = SDLTest_RandomIntegerInRange(1, 100); - y = SDLTest_RandomIntegerInRange(1, 100); - w = SDLTest_RandomIntegerInRange(320, 1024); - h = SDLTest_RandomIntegerInRange(320, 768); - flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS; + /* Standard window */ + x = SDLTest_RandomIntegerInRange(1, 100); + y = SDLTest_RandomIntegerInRange(1, 100); + w = SDLTest_RandomIntegerInRange(320, 1024); + h = SDLTest_RandomIntegerInRange(320, 768); + flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS; - window = SDL_CreateWindow(title, x, y, w, h, flags); - SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags); - SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); + window = SDL_CreateWindow(title, x, y, w, h, flags); + SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags); + SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); - return window; + return window; } /* @@ -48,11 +48,11 @@ SDL_Window *_createVideoSuiteTestWindow(const char *title) */ void _destroyVideoSuiteTestWindow(SDL_Window *window) { - if (window != NULL) { - SDL_DestroyWindow(window); - window = NULL; - SDLTest_AssertPass("Call to SDL_DestroyWindow()"); - } + if (window != NULL) { + SDL_DestroyWindow(window); + window = NULL; + SDLTest_AssertPass("Call to SDL_DestroyWindow()"); + } } /* Test case functions */ @@ -60,8 +60,7 @@ void _destroyVideoSuiteTestWindow(SDL_Window *window) /** * @brief Enable and disable screensaver while checking state */ -int -video_enableDisableScreensaver(void *arg) +int video_enableDisableScreensaver(void *arg) { SDL_bool initialResult; SDL_bool result; @@ -71,39 +70,39 @@ video_enableDisableScreensaver(void *arg) SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); if (initialResult == SDL_TRUE) { - /* Currently enabled: disable first, then enable again */ + /* Currently enabled: disable first, then enable again */ - /* Disable screensaver and check */ - SDL_DisableScreenSaver(); - SDLTest_AssertPass("Call to SDL_DisableScreenSaver()"); - result = SDL_IsScreenSaverEnabled(); - SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); - SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result); + /* Disable screensaver and check */ + SDL_DisableScreenSaver(); + SDLTest_AssertPass("Call to SDL_DisableScreenSaver()"); + result = SDL_IsScreenSaverEnabled(); + SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); + SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result); - /* Enable screensaver and check */ - SDL_EnableScreenSaver(); - SDLTest_AssertPass("Call to SDL_EnableScreenSaver()"); - result = SDL_IsScreenSaverEnabled(); - SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); - SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result); + /* Enable screensaver and check */ + SDL_EnableScreenSaver(); + SDLTest_AssertPass("Call to SDL_EnableScreenSaver()"); + result = SDL_IsScreenSaverEnabled(); + SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); + SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result); } else { - /* Currently disabled: enable first, then disable again */ + /* Currently disabled: enable first, then disable again */ - /* Enable screensaver and check */ - SDL_EnableScreenSaver(); - SDLTest_AssertPass("Call to SDL_EnableScreenSaver()"); - result = SDL_IsScreenSaverEnabled(); - SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); - SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result); + /* Enable screensaver and check */ + SDL_EnableScreenSaver(); + SDLTest_AssertPass("Call to SDL_EnableScreenSaver()"); + result = SDL_IsScreenSaverEnabled(); + SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); + SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result); - /* Disable screensaver and check */ - SDL_DisableScreenSaver(); - SDLTest_AssertPass("Call to SDL_DisableScreenSaver()"); - result = SDL_IsScreenSaverEnabled(); - SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); - SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result); + /* Disable screensaver and check */ + SDL_DisableScreenSaver(); + SDLTest_AssertPass("Call to SDL_DisableScreenSaver()"); + result = SDL_IsScreenSaverEnabled(); + SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); + SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result); } return TEST_COMPLETED; @@ -112,402 +111,393 @@ video_enableDisableScreensaver(void *arg) /** * @brief Tests the functionality of the SDL_CreateWindow function using different positions */ -int -video_createWindowVariousPositions(void *arg) +int video_createWindowVariousPositions(void *arg) { - SDL_Window* window; - const char* title = "video_createWindowVariousPositions Test Window"; - int x, y, w, h; - int xVariation, yVariation; + SDL_Window *window; + const char *title = "video_createWindowVariousPositions Test Window"; + int x, y, w, h; + int xVariation, yVariation; - for (xVariation = 0; xVariation < 6; xVariation++) { - for (yVariation = 0; yVariation < 6; yVariation++) { - switch(xVariation) { - default: - case 0: - /* Zero X Position */ - x = 0; - break; - case 1: - /* Random X position inside screen */ - x = SDLTest_RandomIntegerInRange(1, 100); - break; - case 2: - /* Random X position outside screen (positive) */ - x = SDLTest_RandomIntegerInRange(10000, 11000); - break; - case 3: - /* Random X position outside screen (negative) */ - x = SDLTest_RandomIntegerInRange(-1000, -100); - break; - case 4: - /* Centered X position */ - x = SDL_WINDOWPOS_CENTERED; - break; - case 5: - /* Undefined X position */ - x = SDL_WINDOWPOS_UNDEFINED; - break; + for (xVariation = 0; xVariation < 6; xVariation++) { + for (yVariation = 0; yVariation < 6; yVariation++) { + switch (xVariation) { + default: + case 0: + /* Zero X Position */ + x = 0; + break; + case 1: + /* Random X position inside screen */ + x = SDLTest_RandomIntegerInRange(1, 100); + break; + case 2: + /* Random X position outside screen (positive) */ + x = SDLTest_RandomIntegerInRange(10000, 11000); + break; + case 3: + /* Random X position outside screen (negative) */ + x = SDLTest_RandomIntegerInRange(-1000, -100); + break; + case 4: + /* Centered X position */ + x = SDL_WINDOWPOS_CENTERED; + break; + case 5: + /* Undefined X position */ + x = SDL_WINDOWPOS_UNDEFINED; + break; + } + + switch (yVariation) { + default: + case 0: + /* Zero X Position */ + y = 0; + break; + case 1: + /* Random X position inside screen */ + y = SDLTest_RandomIntegerInRange(1, 100); + break; + case 2: + /* Random X position outside screen (positive) */ + y = SDLTest_RandomIntegerInRange(10000, 11000); + break; + case 3: + /* Random Y position outside screen (negative) */ + y = SDLTest_RandomIntegerInRange(-1000, -100); + break; + case 4: + /* Centered Y position */ + y = SDL_WINDOWPOS_CENTERED; + break; + case 5: + /* Undefined Y position */ + y = SDL_WINDOWPOS_UNDEFINED; + break; + } + + w = SDLTest_RandomIntegerInRange(32, 96); + h = SDLTest_RandomIntegerInRange(32, 96); + window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN); + SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h); + SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); + + /* Clean up */ + _destroyVideoSuiteTestWindow(window); + } } - switch(yVariation) { - default: - case 0: - /* Zero X Position */ - y = 0; - break; - case 1: - /* Random X position inside screen */ - y = SDLTest_RandomIntegerInRange(1, 100); - break; - case 2: - /* Random X position outside screen (positive) */ - y = SDLTest_RandomIntegerInRange(10000, 11000); - break; - case 3: - /* Random Y position outside screen (negative) */ - y = SDLTest_RandomIntegerInRange(-1000, -100); - break; - case 4: - /* Centered Y position */ - y = SDL_WINDOWPOS_CENTERED; - break; - case 5: - /* Undefined Y position */ - y = SDL_WINDOWPOS_UNDEFINED; - break; - } - - w = SDLTest_RandomIntegerInRange(32, 96); - h = SDLTest_RandomIntegerInRange(32, 96); - window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN); - SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h); - SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - } - } - - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Tests the functionality of the SDL_CreateWindow function using different sizes */ -int -video_createWindowVariousSizes(void *arg) +int video_createWindowVariousSizes(void *arg) { - SDL_Window* window; - const char* title = "video_createWindowVariousSizes Test Window"; - int x, y, w, h; - int wVariation, hVariation; + SDL_Window *window; + const char *title = "video_createWindowVariousSizes Test Window"; + int x, y, w, h; + int wVariation, hVariation; - x = SDLTest_RandomIntegerInRange(1, 100); - y = SDLTest_RandomIntegerInRange(1, 100); - for (wVariation = 0; wVariation < 3; wVariation++) { - for (hVariation = 0; hVariation < 3; hVariation++) { - switch(wVariation) { - case 0: - /* Width of 1 */ - w = 1; - break; - case 1: - /* Random "normal" width */ - w = SDLTest_RandomIntegerInRange(320, 1920); - break; - case 2: - /* Random "large" width */ - w = SDLTest_RandomIntegerInRange(2048, 4095); - break; + x = SDLTest_RandomIntegerInRange(1, 100); + y = SDLTest_RandomIntegerInRange(1, 100); + for (wVariation = 0; wVariation < 3; wVariation++) { + for (hVariation = 0; hVariation < 3; hVariation++) { + switch (wVariation) { + case 0: + /* Width of 1 */ + w = 1; + break; + case 1: + /* Random "normal" width */ + w = SDLTest_RandomIntegerInRange(320, 1920); + break; + case 2: + /* Random "large" width */ + w = SDLTest_RandomIntegerInRange(2048, 4095); + break; + } + + switch (hVariation) { + case 0: + /* Height of 1 */ + h = 1; + break; + case 1: + /* Random "normal" height */ + h = SDLTest_RandomIntegerInRange(320, 1080); + break; + case 2: + /* Random "large" height */ + h = SDLTest_RandomIntegerInRange(2048, 4095); + break; + } + + window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN); + SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h); + SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); + + /* Clean up */ + _destroyVideoSuiteTestWindow(window); + } } - switch(hVariation) { - case 0: - /* Height of 1 */ - h = 1; - break; - case 1: - /* Random "normal" height */ - h = SDLTest_RandomIntegerInRange(320, 1080); - break; - case 2: - /* Random "large" height */ - h = SDLTest_RandomIntegerInRange(2048, 4095); - break; - } - - window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN); - SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h); - SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - } - } - - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Tests the functionality of the SDL_CreateWindow function using different flags */ -int -video_createWindowVariousFlags(void *arg) +int video_createWindowVariousFlags(void *arg) { - SDL_Window* window; - const char* title = "video_createWindowVariousFlags Test Window"; - int x, y, w, h; - int fVariation; - SDL_WindowFlags flags; + SDL_Window *window; + const char *title = "video_createWindowVariousFlags Test Window"; + int x, y, w, h; + int fVariation; + SDL_WindowFlags flags; - /* Standard window */ - x = SDLTest_RandomIntegerInRange(1, 100); - y = SDLTest_RandomIntegerInRange(1, 100); - w = SDLTest_RandomIntegerInRange(320, 1024); - h = SDLTest_RandomIntegerInRange(320, 768); + /* Standard window */ + x = SDLTest_RandomIntegerInRange(1, 100); + y = SDLTest_RandomIntegerInRange(1, 100); + w = SDLTest_RandomIntegerInRange(320, 1024); + h = SDLTest_RandomIntegerInRange(320, 768); - for (fVariation = 0; fVariation < 14; fVariation++) { - switch(fVariation) { - default: - case 0: - flags = SDL_WINDOW_FULLSCREEN; - /* Skip - blanks screen; comment out next line to run test */ - continue; - break; - case 1: - flags = SDL_WINDOW_FULLSCREEN_DESKTOP; - /* Skip - blanks screen; comment out next line to run test */ - continue; - break; - case 2: - flags = SDL_WINDOW_OPENGL; - break; - case 3: - flags = SDL_WINDOW_SHOWN; - break; - case 4: - flags = SDL_WINDOW_HIDDEN; - break; - case 5: - flags = SDL_WINDOW_BORDERLESS; - break; - case 6: - flags = SDL_WINDOW_RESIZABLE; - break; - case 7: - flags = SDL_WINDOW_MINIMIZED; - break; - case 8: - flags = SDL_WINDOW_MAXIMIZED; - break; - case 9: - flags = SDL_WINDOW_MOUSE_GRABBED; - break; - case 10: - flags = SDL_WINDOW_INPUT_FOCUS; - break; - case 11: - flags = SDL_WINDOW_MOUSE_FOCUS; - break; - case 12: - flags = SDL_WINDOW_FOREIGN; - break; - case 13: - flags = SDL_WINDOW_KEYBOARD_GRABBED; - break; + for (fVariation = 0; fVariation < 14; fVariation++) { + switch (fVariation) { + default: + case 0: + flags = SDL_WINDOW_FULLSCREEN; + /* Skip - blanks screen; comment out next line to run test */ + continue; + break; + case 1: + flags = SDL_WINDOW_FULLSCREEN_DESKTOP; + /* Skip - blanks screen; comment out next line to run test */ + continue; + break; + case 2: + flags = SDL_WINDOW_OPENGL; + break; + case 3: + flags = SDL_WINDOW_SHOWN; + break; + case 4: + flags = SDL_WINDOW_HIDDEN; + break; + case 5: + flags = SDL_WINDOW_BORDERLESS; + break; + case 6: + flags = SDL_WINDOW_RESIZABLE; + break; + case 7: + flags = SDL_WINDOW_MINIMIZED; + break; + case 8: + flags = SDL_WINDOW_MAXIMIZED; + break; + case 9: + flags = SDL_WINDOW_MOUSE_GRABBED; + break; + case 10: + flags = SDL_WINDOW_INPUT_FOCUS; + break; + case 11: + flags = SDL_WINDOW_MOUSE_FOCUS; + break; + case 12: + flags = SDL_WINDOW_FOREIGN; + break; + case 13: + flags = SDL_WINDOW_KEYBOARD_GRABBED; + break; + } + + window = SDL_CreateWindow(title, x, y, w, h, flags); + SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags); + SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); + + /* Clean up */ + _destroyVideoSuiteTestWindow(window); } - window = SDL_CreateWindow(title, x, y, w, h, flags); - SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags); - SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - } - - return TEST_COMPLETED; + return TEST_COMPLETED; } - /** * @brief Tests the functionality of the SDL_GetWindowFlags function */ -int -video_getWindowFlags(void *arg) +int video_getWindowFlags(void *arg) { - SDL_Window* window; - const char* title = "video_getWindowFlags Test Window"; - SDL_WindowFlags flags; - Uint32 actualFlags; + SDL_Window *window; + const char *title = "video_getWindowFlags Test Window"; + SDL_WindowFlags flags; + Uint32 actualFlags; - /* Reliable flag set always set in test window */ - flags = SDL_WINDOW_SHOWN; + /* Reliable flag set always set in test window */ + flags = SDL_WINDOW_SHOWN; - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window != NULL) { - actualFlags = SDL_GetWindowFlags(window); - SDLTest_AssertPass("Call to SDL_GetWindowFlags()"); - SDLTest_AssertCheck((flags & actualFlags) == flags, "Verify returned value has flags %d set, got: %" SDL_PRIu32, flags, actualFlags); - } + /* Call against new test window */ + window = _createVideoSuiteTestWindow(title); + if (window != NULL) { + actualFlags = SDL_GetWindowFlags(window); + SDLTest_AssertPass("Call to SDL_GetWindowFlags()"); + SDLTest_AssertCheck((flags & actualFlags) == flags, "Verify returned value has flags %d set, got: %" SDL_PRIu32, flags, actualFlags); + } - /* Clean up */ - _destroyVideoSuiteTestWindow(window); + /* Clean up */ + _destroyVideoSuiteTestWindow(window); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Tests the functionality of the SDL_GetNumDisplayModes function */ -int -video_getNumDisplayModes(void *arg) +int video_getNumDisplayModes(void *arg) { - int result; - int displayNum; - int i; + int result; + int displayNum; + int i; - /* Get number of displays */ - displayNum = SDL_GetNumVideoDisplays(); - SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()"); + /* Get number of displays */ + displayNum = SDL_GetNumVideoDisplays(); + SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()"); - /* Make call for each display */ - for (i=0; i= 1, "Validate returned value from function; expected: >=1; got: %d", result); - } + /* Make call for each display */ + for (i = 0; i < displayNum; i++) { + result = SDL_GetNumDisplayModes(i); + SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d)", i); + SDLTest_AssertCheck(result >= 1, "Validate returned value from function; expected: >=1; got: %d", result); + } - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Tests negative call to SDL_GetNumDisplayModes function */ -int -video_getNumDisplayModesNegative(void *arg) +int video_getNumDisplayModesNegative(void *arg) { - int result; - int displayNum; - int displayIndex; + int result; + int displayNum; + int displayIndex; - /* Get number of displays */ - displayNum = SDL_GetNumVideoDisplays(); - SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()"); + /* Get number of displays */ + displayNum = SDL_GetNumVideoDisplays(); + SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()"); - /* Invalid boundary values */ - displayIndex = SDLTest_RandomSint32BoundaryValue(0, displayNum, SDL_FALSE); - result = SDL_GetNumDisplayModes(displayIndex); - SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/boundary)", displayIndex); - SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result); + /* Invalid boundary values */ + displayIndex = SDLTest_RandomSint32BoundaryValue(0, displayNum, SDL_FALSE); + result = SDL_GetNumDisplayModes(displayIndex); + SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/boundary)", displayIndex); + SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result); - /* Large (out-of-bounds) display index */ - displayIndex = SDLTest_RandomIntegerInRange(-2000, -1000); - result = SDL_GetNumDisplayModes(displayIndex); - SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large negative)", displayIndex); - SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result); + /* Large (out-of-bounds) display index */ + displayIndex = SDLTest_RandomIntegerInRange(-2000, -1000); + result = SDL_GetNumDisplayModes(displayIndex); + SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large negative)", displayIndex); + SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result); - displayIndex = SDLTest_RandomIntegerInRange(1000, 2000); - result = SDL_GetNumDisplayModes(displayIndex); - SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large positive)", displayIndex); - SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result); + displayIndex = SDLTest_RandomIntegerInRange(1000, 2000); + result = SDL_GetNumDisplayModes(displayIndex); + SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large positive)", displayIndex); + SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Tests the functionality of the SDL_GetClosestDisplayMode function against current resolution */ -int -video_getClosestDisplayModeCurrentResolution(void *arg) +int video_getClosestDisplayModeCurrentResolution(void *arg) { - int result; - SDL_DisplayMode current; - SDL_DisplayMode target; - SDL_DisplayMode closest; - SDL_DisplayMode* dResult; - int displayNum; - int i; - int variation; + int result; + SDL_DisplayMode current; + SDL_DisplayMode target; + SDL_DisplayMode closest; + SDL_DisplayMode *dResult; + int displayNum; + int i; + int variation; - /* Get number of displays */ - displayNum = SDL_GetNumVideoDisplays(); - SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()"); + /* Get number of displays */ + displayNum = SDL_GetNumVideoDisplays(); + SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()"); - /* Make calls for each display */ - for (i=0; iw, "Verify return value matches assigned value; expected: %d, got: %d", closest.w, dResult->w); + SDLTest_AssertCheck(closest.h == dResult->h, "Verify return value matches assigned value; expected: %d, got: %d", closest.h, dResult->h); + } } - /* Set the desired resolution equals to current resolution */ - target.w = current.w; - target.h = current.h; - for (variation = 0; variation < 8; variation ++) { - /* Vary constraints on other query parameters */ - target.format = (variation & 1) ? current.format : 0; - target.refresh_rate = (variation & 2) ? current.refresh_rate : 0; - target.driverdata = (variation & 4) ? current.driverdata : 0; - - /* Make call */ - dResult = SDL_GetClosestDisplayMode(i, &target, &closest); - SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=current/variation%d)", variation); - SDLTest_AssertCheck(dResult != NULL, "Verify returned value is not NULL"); - - /* Check that one gets the current resolution back again */ - SDLTest_AssertCheck(closest.w == current.w, "Verify returned width matches current width; expected: %d, got: %d", current.w, closest.w); - SDLTest_AssertCheck(closest.h == current.h, "Verify returned height matches current height; expected: %d, got: %d", current.h, closest.h); - SDLTest_AssertCheck(closest.w == dResult->w, "Verify return value matches assigned value; expected: %d, got: %d", closest.w, dResult->w); - SDLTest_AssertCheck(closest.h == dResult->h, "Verify return value matches assigned value; expected: %d, got: %d", closest.h, dResult->h); - } - } - - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Tests the functionality of the SDL_GetClosestDisplayMode function against random resolution */ -int -video_getClosestDisplayModeRandomResolution(void *arg) +int video_getClosestDisplayModeRandomResolution(void *arg) { - SDL_DisplayMode target; - SDL_DisplayMode closest; - int displayNum; - int i; - int variation; + SDL_DisplayMode target; + SDL_DisplayMode closest; + int displayNum; + int i; + int variation; - /* Get number of displays */ - displayNum = SDL_GetNumVideoDisplays(); - SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()"); + /* Get number of displays */ + displayNum = SDL_GetNumVideoDisplays(); + SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()"); - /* Make calls for each display */ - for (i=0; i 0, "Validate mode.w content; expected: >0, got: %d", mode.w); - SDLTest_AssertCheck(mode.h > 0, "Validate mode.h content; expected: >0, got: %d", mode.h); - SDLTest_AssertCheck(mode.refresh_rate > 0, "Validate mode.refresh_rate content; expected: >0, got: %d", mode.refresh_rate); - } + /* Call against new test window */ + window = _createVideoSuiteTestWindow(title); + if (window != NULL) { + result = SDL_GetWindowDisplayMode(window, &mode); + SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode()"); + SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result); + SDLTest_AssertCheck(mode.w > 0, "Validate mode.w content; expected: >0, got: %d", mode.w); + SDLTest_AssertCheck(mode.h > 0, "Validate mode.h content; expected: >0, got: %d", mode.h); + SDLTest_AssertCheck(mode.refresh_rate > 0, "Validate mode.refresh_rate content; expected: >0, got: %d", mode.refresh_rate); + } - /* Clean up */ - _destroyVideoSuiteTestWindow(window); + /* Clean up */ + _destroyVideoSuiteTestWindow(window); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* Helper function that checks for an 'Invalid window' error */ void _checkInvalidWindowError() { - const char *invalidWindowError = "Invalid window"; - char *lastError; + const char *invalidWindowError = "Invalid window"; + char *lastError; - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL"); - if (lastError != NULL) { - SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - invalidWindowError, - lastError); - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - } + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL"); + if (lastError != NULL) { + SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0, + "SDL_GetError(): expected message '%s', was message: '%s'", + invalidWindowError, + lastError); + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); + } } /** @@ -624,43 +613,42 @@ void _checkInvalidWindowError() * * @sa http://wiki.libsdl.org/SDL_GetWindowDisplayMode */ -int -video_getWindowDisplayModeNegative(void *arg) +int video_getWindowDisplayModeNegative(void *arg) { - const char *expectedError = "Parameter 'mode' is invalid"; - char *lastError; - SDL_Window* window; - const char* title = "video_getWindowDisplayModeNegative Test Window"; - SDL_DisplayMode mode; - int result; + const char *expectedError = "Parameter 'mode' is invalid"; + char *lastError; + SDL_Window *window; + const char *title = "video_getWindowDisplayModeNegative Test Window"; + SDL_DisplayMode mode; + int result; - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window != NULL) { - result = SDL_GetWindowDisplayMode(window, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(...,mode=NULL)"); - SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL"); - if (lastError != NULL) { - SDLTest_AssertCheck(SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); - } - } + /* Call against new test window */ + window = _createVideoSuiteTestWindow(title); + if (window != NULL) { + result = SDL_GetWindowDisplayMode(window, NULL); + SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(...,mode=NULL)"); + SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result); + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL"); + if (lastError != NULL) { + SDLTest_AssertCheck(SDL_strcmp(lastError, expectedError) == 0, + "SDL_GetError(): expected message '%s', was message: '%s'", + expectedError, + lastError); + } + } - /* Clean up */ - _destroyVideoSuiteTestWindow(window); + /* Clean up */ + _destroyVideoSuiteTestWindow(window); - /* Call against invalid window */ - result = SDL_GetWindowDisplayMode(NULL, &mode); - SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(window=NULL,...)"); - SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result); - _checkInvalidWindowError(); + /* Call against invalid window */ + result = SDL_GetWindowDisplayMode(NULL, &mode); + SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(window=NULL,...)"); + SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result); + _checkInvalidWindowError(); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -750,75 +738,73 @@ video_getWindowGammaRampNegative(void *arg) } /* Helper for setting and checking the window mouse grab state */ -void -_setAndCheckWindowMouseGrabState(SDL_Window* window, SDL_bool desiredState) +void _setAndCheckWindowMouseGrabState(SDL_Window *window, SDL_bool desiredState) { - SDL_bool currentState; + SDL_bool currentState; - /* Set state */ - SDL_SetWindowMouseGrab(window, desiredState); - SDLTest_AssertPass("Call to SDL_SetWindowMouseGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); + /* Set state */ + SDL_SetWindowMouseGrab(window, desiredState); + SDLTest_AssertPass("Call to SDL_SetWindowMouseGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); - /* Get and check state */ - currentState = SDL_GetWindowMouseGrab(window); - SDLTest_AssertPass("Call to SDL_GetWindowMouseGrab()"); - SDLTest_AssertCheck( - currentState == desiredState, - "Validate returned state; expected: %s, got: %s", - (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE", - (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); + /* Get and check state */ + currentState = SDL_GetWindowMouseGrab(window); + SDLTest_AssertPass("Call to SDL_GetWindowMouseGrab()"); + SDLTest_AssertCheck( + currentState == desiredState, + "Validate returned state; expected: %s, got: %s", + (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE", + (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); - if (desiredState) { - SDLTest_AssertCheck( - SDL_GetGrabbedWindow() == window, - "Grabbed window should be to our window"); - SDLTest_AssertCheck( - SDL_GetWindowGrab(window), - "SDL_GetWindowGrab() should return SDL_TRUE"); - SDLTest_AssertCheck( - SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_GRABBED, - "SDL_WINDOW_MOUSE_GRABBED should be set"); - } else { - SDLTest_AssertCheck( - !(SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_GRABBED), - "SDL_WINDOW_MOUSE_GRABBED should be unset"); - } + if (desiredState) { + SDLTest_AssertCheck( + SDL_GetGrabbedWindow() == window, + "Grabbed window should be to our window"); + SDLTest_AssertCheck( + SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_TRUE"); + SDLTest_AssertCheck( + SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_GRABBED, + "SDL_WINDOW_MOUSE_GRABBED should be set"); + } else { + SDLTest_AssertCheck( + !(SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_GRABBED), + "SDL_WINDOW_MOUSE_GRABBED should be unset"); + } } /* Helper for setting and checking the window keyboard grab state */ -void -_setAndCheckWindowKeyboardGrabState(SDL_Window* window, SDL_bool desiredState) +void _setAndCheckWindowKeyboardGrabState(SDL_Window *window, SDL_bool desiredState) { - SDL_bool currentState; + SDL_bool currentState; - /* Set state */ - SDL_SetWindowKeyboardGrab(window, desiredState); - SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); + /* Set state */ + SDL_SetWindowKeyboardGrab(window, desiredState); + SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); - /* Get and check state */ - currentState = SDL_GetWindowKeyboardGrab(window); - SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab()"); - SDLTest_AssertCheck( - currentState == desiredState, - "Validate returned state; expected: %s, got: %s", - (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE", - (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); + /* Get and check state */ + currentState = SDL_GetWindowKeyboardGrab(window); + SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab()"); + SDLTest_AssertCheck( + currentState == desiredState, + "Validate returned state; expected: %s, got: %s", + (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE", + (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); - if (desiredState) { - SDLTest_AssertCheck( - SDL_GetGrabbedWindow() == window, - "Grabbed window should be set to our window"); - SDLTest_AssertCheck( - SDL_GetWindowGrab(window), - "SDL_GetWindowGrab() should return SDL_TRUE"); - SDLTest_AssertCheck( - SDL_GetWindowFlags(window) & SDL_WINDOW_KEYBOARD_GRABBED, - "SDL_WINDOW_KEYBOARD_GRABBED should be set"); - } else { - SDLTest_AssertCheck( - !(SDL_GetWindowFlags(window) & SDL_WINDOW_KEYBOARD_GRABBED), - "SDL_WINDOW_KEYBOARD_GRABBED should be unset"); - } + if (desiredState) { + SDLTest_AssertCheck( + SDL_GetGrabbedWindow() == window, + "Grabbed window should be set to our window"); + SDLTest_AssertCheck( + SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_TRUE"); + SDLTest_AssertCheck( + SDL_GetWindowFlags(window) & SDL_WINDOW_KEYBOARD_GRABBED, + "SDL_WINDOW_KEYBOARD_GRABBED should be set"); + } else { + SDLTest_AssertCheck( + !(SDL_GetWindowFlags(window) & SDL_WINDOW_KEYBOARD_GRABBED), + "SDL_WINDOW_KEYBOARD_GRABBED should be unset"); + } } /** @@ -827,201 +813,198 @@ _setAndCheckWindowKeyboardGrabState(SDL_Window* window, SDL_bool desiredState) * @sa http://wiki.libsdl.org/SDL_GetWindowGrab * @sa http://wiki.libsdl.org/SDL_SetWindowGrab */ -int -video_getSetWindowGrab(void *arg) +int video_getSetWindowGrab(void *arg) { - const char* title = "video_getSetWindowGrab Test Window"; - SDL_Window* window; - SDL_bool originalMouseState, originalKeyboardState; + const char *title = "video_getSetWindowGrab Test Window"; + SDL_Window *window; + SDL_bool originalMouseState, originalKeyboardState; - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window == NULL) { - return TEST_ABORTED; - } + /* Call against new test window */ + window = _createVideoSuiteTestWindow(title); + if (window == NULL) { + return TEST_ABORTED; + } - /* Get state */ - originalMouseState = SDL_GetWindowMouseGrab(window); - SDLTest_AssertPass("Call to SDL_GetWindowMouseGrab()"); - originalKeyboardState = SDL_GetWindowKeyboardGrab(window); - SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab()"); + /* Get state */ + originalMouseState = SDL_GetWindowMouseGrab(window); + SDLTest_AssertPass("Call to SDL_GetWindowMouseGrab()"); + originalKeyboardState = SDL_GetWindowKeyboardGrab(window); + SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab()"); - /* F */ - _setAndCheckWindowKeyboardGrabState(window, SDL_FALSE); - _setAndCheckWindowMouseGrabState(window, SDL_FALSE); - SDLTest_AssertCheck(!SDL_GetWindowGrab(window), - "SDL_GetWindowGrab should return SDL_FALSE"); - SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL, - "Expected NULL grabbed window"); + /* F */ + _setAndCheckWindowKeyboardGrabState(window, SDL_FALSE); + _setAndCheckWindowMouseGrabState(window, SDL_FALSE); + SDLTest_AssertCheck(!SDL_GetWindowGrab(window), + "SDL_GetWindowGrab should return SDL_FALSE"); + SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL, + "Expected NULL grabbed window"); - /* F --> F */ - _setAndCheckWindowMouseGrabState(window, SDL_FALSE); - _setAndCheckWindowKeyboardGrabState(window, SDL_FALSE); - SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL, - "Expected NULL grabbed window"); + /* F --> F */ + _setAndCheckWindowMouseGrabState(window, SDL_FALSE); + _setAndCheckWindowKeyboardGrabState(window, SDL_FALSE); + SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL, + "Expected NULL grabbed window"); - /* F --> T */ - _setAndCheckWindowMouseGrabState(window, SDL_TRUE); - _setAndCheckWindowKeyboardGrabState(window, SDL_TRUE); - SDLTest_AssertCheck(SDL_GetWindowGrab(window), - "SDL_GetWindowGrab() should return SDL_TRUE"); + /* F --> T */ + _setAndCheckWindowMouseGrabState(window, SDL_TRUE); + _setAndCheckWindowKeyboardGrabState(window, SDL_TRUE); + SDLTest_AssertCheck(SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_TRUE"); - /* T --> T */ - _setAndCheckWindowKeyboardGrabState(window, SDL_TRUE); - _setAndCheckWindowMouseGrabState(window, SDL_TRUE); - SDLTest_AssertCheck(SDL_GetWindowGrab(window), - "SDL_GetWindowGrab() should return SDL_TRUE"); + /* T --> T */ + _setAndCheckWindowKeyboardGrabState(window, SDL_TRUE); + _setAndCheckWindowMouseGrabState(window, SDL_TRUE); + SDLTest_AssertCheck(SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_TRUE"); - /* M: T --> F */ - /* K: T --> T */ - _setAndCheckWindowKeyboardGrabState(window, SDL_TRUE); - _setAndCheckWindowMouseGrabState(window, SDL_FALSE); - SDLTest_AssertCheck(SDL_GetWindowGrab(window), - "SDL_GetWindowGrab() should return SDL_TRUE"); + /* M: T --> F */ + /* K: T --> T */ + _setAndCheckWindowKeyboardGrabState(window, SDL_TRUE); + _setAndCheckWindowMouseGrabState(window, SDL_FALSE); + SDLTest_AssertCheck(SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_TRUE"); - /* M: F --> T */ - /* K: T --> F */ - _setAndCheckWindowMouseGrabState(window, SDL_TRUE); - _setAndCheckWindowKeyboardGrabState(window, SDL_FALSE); - SDLTest_AssertCheck(SDL_GetWindowGrab(window), - "SDL_GetWindowGrab() should return SDL_TRUE"); + /* M: F --> T */ + /* K: T --> F */ + _setAndCheckWindowMouseGrabState(window, SDL_TRUE); + _setAndCheckWindowKeyboardGrabState(window, SDL_FALSE); + SDLTest_AssertCheck(SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_TRUE"); - /* M: T --> F */ - /* K: F --> F */ - _setAndCheckWindowMouseGrabState(window, SDL_FALSE); - _setAndCheckWindowKeyboardGrabState(window, SDL_FALSE); - SDLTest_AssertCheck(!SDL_GetWindowGrab(window), - "SDL_GetWindowGrab() should return SDL_FALSE"); - SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL, - "Expected NULL grabbed window"); + /* M: T --> F */ + /* K: F --> F */ + _setAndCheckWindowMouseGrabState(window, SDL_FALSE); + _setAndCheckWindowKeyboardGrabState(window, SDL_FALSE); + SDLTest_AssertCheck(!SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_FALSE"); + SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL, + "Expected NULL grabbed window"); - /* Using the older SDL_SetWindowGrab API should only grab mouse by default */ - SDL_SetWindowGrab(window, SDL_TRUE); - SDLTest_AssertPass("Call to SDL_SetWindowGrab(SDL_TRUE)"); - SDLTest_AssertCheck(SDL_GetWindowGrab(window), - "SDL_GetWindowGrab() should return SDL_TRUE"); - SDLTest_AssertCheck(SDL_GetWindowMouseGrab(window), - "SDL_GetWindowMouseGrab() should return SDL_TRUE"); - SDLTest_AssertCheck(!SDL_GetWindowKeyboardGrab(window), - "SDL_GetWindowKeyboardGrab() should return SDL_FALSE"); - SDL_SetWindowGrab(window, SDL_FALSE); - SDLTest_AssertCheck(!SDL_GetWindowGrab(window), - "SDL_GetWindowGrab() should return SDL_FALSE"); - SDLTest_AssertCheck(!SDL_GetWindowMouseGrab(window), - "SDL_GetWindowMouseGrab() should return SDL_FALSE"); - SDLTest_AssertCheck(!SDL_GetWindowKeyboardGrab(window), - "SDL_GetWindowKeyboardGrab() should return SDL_FALSE"); + /* Using the older SDL_SetWindowGrab API should only grab mouse by default */ + SDL_SetWindowGrab(window, SDL_TRUE); + SDLTest_AssertPass("Call to SDL_SetWindowGrab(SDL_TRUE)"); + SDLTest_AssertCheck(SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_TRUE"); + SDLTest_AssertCheck(SDL_GetWindowMouseGrab(window), + "SDL_GetWindowMouseGrab() should return SDL_TRUE"); + SDLTest_AssertCheck(!SDL_GetWindowKeyboardGrab(window), + "SDL_GetWindowKeyboardGrab() should return SDL_FALSE"); + SDL_SetWindowGrab(window, SDL_FALSE); + SDLTest_AssertCheck(!SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_FALSE"); + SDLTest_AssertCheck(!SDL_GetWindowMouseGrab(window), + "SDL_GetWindowMouseGrab() should return SDL_FALSE"); + SDLTest_AssertCheck(!SDL_GetWindowKeyboardGrab(window), + "SDL_GetWindowKeyboardGrab() should return SDL_FALSE"); - /* Now test with SDL_HINT_GRAB_KEYBOARD set. We should get keyboard grab now. */ - SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, "1"); - SDL_SetWindowGrab(window, SDL_TRUE); - SDLTest_AssertPass("Call to SDL_SetWindowGrab(SDL_TRUE)"); - SDLTest_AssertCheck(SDL_GetWindowGrab(window), - "SDL_GetWindowGrab() should return SDL_TRUE"); - SDLTest_AssertCheck(SDL_GetWindowMouseGrab(window), - "SDL_GetWindowMouseGrab() should return SDL_TRUE"); - SDLTest_AssertCheck(SDL_GetWindowKeyboardGrab(window), - "SDL_GetWindowKeyboardGrab() should return SDL_TRUE"); - SDL_SetWindowGrab(window, SDL_FALSE); - SDLTest_AssertCheck(!SDL_GetWindowGrab(window), - "SDL_GetWindowGrab() should return SDL_FALSE"); - SDLTest_AssertCheck(!SDL_GetWindowMouseGrab(window), - "SDL_GetWindowMouseGrab() should return SDL_FALSE"); - SDLTest_AssertCheck(!SDL_GetWindowKeyboardGrab(window), - "SDL_GetWindowKeyboardGrab() should return SDL_FALSE"); + /* Now test with SDL_HINT_GRAB_KEYBOARD set. We should get keyboard grab now. */ + SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, "1"); + SDL_SetWindowGrab(window, SDL_TRUE); + SDLTest_AssertPass("Call to SDL_SetWindowGrab(SDL_TRUE)"); + SDLTest_AssertCheck(SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_TRUE"); + SDLTest_AssertCheck(SDL_GetWindowMouseGrab(window), + "SDL_GetWindowMouseGrab() should return SDL_TRUE"); + SDLTest_AssertCheck(SDL_GetWindowKeyboardGrab(window), + "SDL_GetWindowKeyboardGrab() should return SDL_TRUE"); + SDL_SetWindowGrab(window, SDL_FALSE); + SDLTest_AssertCheck(!SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_FALSE"); + SDLTest_AssertCheck(!SDL_GetWindowMouseGrab(window), + "SDL_GetWindowMouseGrab() should return SDL_FALSE"); + SDLTest_AssertCheck(!SDL_GetWindowKeyboardGrab(window), + "SDL_GetWindowKeyboardGrab() should return SDL_FALSE"); - /* Negative tests */ - SDL_GetWindowGrab(NULL); - SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)"); - _checkInvalidWindowError(); + /* Negative tests */ + SDL_GetWindowGrab(NULL); + SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)"); + _checkInvalidWindowError(); - SDL_GetWindowKeyboardGrab(NULL); - SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab(window=NULL)"); - _checkInvalidWindowError(); + SDL_GetWindowKeyboardGrab(NULL); + SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab(window=NULL)"); + _checkInvalidWindowError(); - SDL_SetWindowGrab(NULL, SDL_FALSE); - SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)"); - _checkInvalidWindowError(); + SDL_SetWindowGrab(NULL, SDL_FALSE); + SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)"); + _checkInvalidWindowError(); - SDL_SetWindowKeyboardGrab(NULL, SDL_FALSE); - SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(window=NULL,SDL_FALSE)"); - _checkInvalidWindowError(); + SDL_SetWindowKeyboardGrab(NULL, SDL_FALSE); + SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(window=NULL,SDL_FALSE)"); + _checkInvalidWindowError(); - SDL_SetWindowGrab(NULL, SDL_TRUE); - SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_TRUE)"); - _checkInvalidWindowError(); + SDL_SetWindowGrab(NULL, SDL_TRUE); + SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_TRUE)"); + _checkInvalidWindowError(); - SDL_SetWindowKeyboardGrab(NULL, SDL_TRUE); - SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(window=NULL,SDL_TRUE)"); - _checkInvalidWindowError(); + SDL_SetWindowKeyboardGrab(NULL, SDL_TRUE); + SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(window=NULL,SDL_TRUE)"); + _checkInvalidWindowError(); - /* Restore state */ - _setAndCheckWindowMouseGrabState(window, originalMouseState); - _setAndCheckWindowKeyboardGrabState(window, originalKeyboardState); + /* Restore state */ + _setAndCheckWindowMouseGrabState(window, originalMouseState); + _setAndCheckWindowKeyboardGrabState(window, originalKeyboardState); - /* Clean up */ - _destroyVideoSuiteTestWindow(window); + /* Clean up */ + _destroyVideoSuiteTestWindow(window); - return TEST_COMPLETED; + return TEST_COMPLETED; } - /** * @brief Tests call to SDL_GetWindowID and SDL_GetWindowFromID * * @sa http://wiki.libsdl.org/SDL_GetWindowID * @sa http://wiki.libsdl.org/SDL_SetWindowFromID */ -int -video_getWindowId(void *arg) +int video_getWindowId(void *arg) { - const char* title = "video_getWindowId Test Window"; - SDL_Window* window; - SDL_Window* result; - Uint32 id, randomId; + const char *title = "video_getWindowId Test Window"; + SDL_Window *window; + SDL_Window *result; + Uint32 id, randomId; - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window == NULL) { - return TEST_ABORTED; - } + /* Call against new test window */ + window = _createVideoSuiteTestWindow(title); + if (window == NULL) { + return TEST_ABORTED; + } - /* Get ID */ - id = SDL_GetWindowID(window); - SDLTest_AssertPass("Call to SDL_GetWindowID()"); + /* Get ID */ + id = SDL_GetWindowID(window); + SDLTest_AssertPass("Call to SDL_GetWindowID()"); - /* Get window from ID */ - result = SDL_GetWindowFromID(id); - SDLTest_AssertPass("Call to SDL_GetWindowID(%" SDL_PRIu32 ")", id); - SDLTest_AssertCheck(result == window, "Verify result matches window pointer"); + /* Get window from ID */ + result = SDL_GetWindowFromID(id); + SDLTest_AssertPass("Call to SDL_GetWindowID(%" SDL_PRIu32 ")", id); + SDLTest_AssertCheck(result == window, "Verify result matches window pointer"); - /* Get window from random large ID, no result check */ - randomId = SDLTest_RandomIntegerInRange(UINT8_MAX,UINT16_MAX); - result = SDL_GetWindowFromID(randomId); - SDLTest_AssertPass("Call to SDL_GetWindowID(%" SDL_PRIu32 "/random_large)", randomId); + /* Get window from random large ID, no result check */ + randomId = SDLTest_RandomIntegerInRange(UINT8_MAX, UINT16_MAX); + result = SDL_GetWindowFromID(randomId); + SDLTest_AssertPass("Call to SDL_GetWindowID(%" SDL_PRIu32 "/random_large)", randomId); - /* Get window from 0 and Uint32 max ID, no result check */ - result = SDL_GetWindowFromID(0); - SDLTest_AssertPass("Call to SDL_GetWindowID(0)"); - result = SDL_GetWindowFromID(UINT32_MAX); - SDLTest_AssertPass("Call to SDL_GetWindowID(UINT32_MAX)"); + /* Get window from 0 and Uint32 max ID, no result check */ + result = SDL_GetWindowFromID(0); + SDLTest_AssertPass("Call to SDL_GetWindowID(0)"); + result = SDL_GetWindowFromID(UINT32_MAX); + SDLTest_AssertPass("Call to SDL_GetWindowID(UINT32_MAX)"); - /* Clean up */ - _destroyVideoSuiteTestWindow(window); + /* Clean up */ + _destroyVideoSuiteTestWindow(window); - /* Get window from ID for closed window */ - result = SDL_GetWindowFromID(id); - SDLTest_AssertPass("Call to SDL_GetWindowID(%" SDL_PRIu32 "/closed_window)", id); - SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); + /* Get window from ID for closed window */ + result = SDL_GetWindowFromID(id); + SDLTest_AssertPass("Call to SDL_GetWindowID(%" SDL_PRIu32 "/closed_window)", id); + SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); - /* Negative test */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - id = SDL_GetWindowID(NULL); - SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)"); - _checkInvalidWindowError(); + /* Negative test */ + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); + id = SDL_GetWindowID(NULL); + SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)"); + _checkInvalidWindowError(); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -1029,35 +1012,34 @@ video_getWindowId(void *arg) * * @sa http://wiki.libsdl.org/SDL_GetWindowPixelFormat */ -int -video_getWindowPixelFormat(void *arg) +int video_getWindowPixelFormat(void *arg) { - const char* title = "video_getWindowPixelFormat Test Window"; - SDL_Window* window; - Uint32 format; + const char *title = "video_getWindowPixelFormat Test Window"; + SDL_Window *window; + Uint32 format; - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window == NULL) { - return TEST_ABORTED; - } + /* Call against new test window */ + window = _createVideoSuiteTestWindow(title); + if (window == NULL) { + return TEST_ABORTED; + } - /* Get format */ - format = SDL_GetWindowPixelFormat(window); - SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat()"); - SDLTest_AssertCheck(format != SDL_PIXELFORMAT_UNKNOWN, "Verify that returned format is valid; expected: != %d, got: %" SDL_PRIu32, SDL_PIXELFORMAT_UNKNOWN, format); + /* Get format */ + format = SDL_GetWindowPixelFormat(window); + SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat()"); + SDLTest_AssertCheck(format != SDL_PIXELFORMAT_UNKNOWN, "Verify that returned format is valid; expected: != %d, got: %" SDL_PRIu32, SDL_PIXELFORMAT_UNKNOWN, format); - /* Clean up */ - _destroyVideoSuiteTestWindow(window); + /* Clean up */ + _destroyVideoSuiteTestWindow(window); - /* Negative test */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - format = SDL_GetWindowPixelFormat(NULL); - SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)"); - _checkInvalidWindowError(); + /* Negative test */ + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); + format = SDL_GetWindowPixelFormat(NULL); + SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)"); + _checkInvalidWindowError(); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -1066,145 +1048,144 @@ video_getWindowPixelFormat(void *arg) * @sa http://wiki.libsdl.org/SDL_GetWindowPosition * @sa http://wiki.libsdl.org/SDL_SetWindowPosition */ -int -video_getSetWindowPosition(void *arg) +int video_getSetWindowPosition(void *arg) { - const char* title = "video_getSetWindowPosition Test Window"; - SDL_Window* window; - int xVariation, yVariation; - int referenceX, referenceY; - int currentX, currentY; - int desiredX, desiredY; + const char *title = "video_getSetWindowPosition Test Window"; + SDL_Window *window; + int xVariation, yVariation; + int referenceX, referenceY; + int currentX, currentY; + int desiredX, desiredY; - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window == NULL) { - return TEST_ABORTED; - } - - for (xVariation = 0; xVariation < 4; xVariation++) { - for (yVariation = 0; yVariation < 4; yVariation++) { - switch(xVariation) { - default: - case 0: - /* Zero X Position */ - desiredX = 0; - break; - case 1: - /* Random X position inside screen */ - desiredX = SDLTest_RandomIntegerInRange(1, 100); - break; - case 2: - /* Random X position outside screen (positive) */ - desiredX = SDLTest_RandomIntegerInRange(10000, 11000); - break; - case 3: - /* Random X position outside screen (negative) */ - desiredX = SDLTest_RandomIntegerInRange(-1000, -100); - break; + /* Call against new test window */ + window = _createVideoSuiteTestWindow(title); + if (window == NULL) { + return TEST_ABORTED; } - switch(yVariation) { - default: - case 0: - /* Zero X Position */ - desiredY = 0; - break; - case 1: - /* Random X position inside screen */ - desiredY = SDLTest_RandomIntegerInRange(1, 100); - break; - case 2: - /* Random X position outside screen (positive) */ - desiredY = SDLTest_RandomIntegerInRange(10000, 11000); - break; - case 3: - /* Random Y position outside screen (negative) */ - desiredY = SDLTest_RandomIntegerInRange(-1000, -100); - break; + for (xVariation = 0; xVariation < 4; xVariation++) { + for (yVariation = 0; yVariation < 4; yVariation++) { + switch (xVariation) { + default: + case 0: + /* Zero X Position */ + desiredX = 0; + break; + case 1: + /* Random X position inside screen */ + desiredX = SDLTest_RandomIntegerInRange(1, 100); + break; + case 2: + /* Random X position outside screen (positive) */ + desiredX = SDLTest_RandomIntegerInRange(10000, 11000); + break; + case 3: + /* Random X position outside screen (negative) */ + desiredX = SDLTest_RandomIntegerInRange(-1000, -100); + break; + } + + switch (yVariation) { + default: + case 0: + /* Zero X Position */ + desiredY = 0; + break; + case 1: + /* Random X position inside screen */ + desiredY = SDLTest_RandomIntegerInRange(1, 100); + break; + case 2: + /* Random X position outside screen (positive) */ + desiredY = SDLTest_RandomIntegerInRange(10000, 11000); + break; + case 3: + /* Random Y position outside screen (negative) */ + desiredY = SDLTest_RandomIntegerInRange(-1000, -100); + break; + } + + /* Set position */ + SDL_SetWindowPosition(window, desiredX, desiredY); + SDLTest_AssertPass("Call to SDL_SetWindowPosition(...,%d,%d)", desiredX, desiredY); + + /* Get position */ + currentX = desiredX + 1; + currentY = desiredY + 1; + SDL_GetWindowPosition(window, ¤tX, ¤tY); + SDLTest_AssertPass("Call to SDL_GetWindowPosition()"); + SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX); + SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY); + + /* Get position X */ + currentX = desiredX + 1; + SDL_GetWindowPosition(window, ¤tX, NULL); + SDLTest_AssertPass("Call to SDL_GetWindowPosition(&y=NULL)"); + SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX); + + /* Get position Y */ + currentY = desiredY + 1; + SDL_GetWindowPosition(window, NULL, ¤tY); + SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL)"); + SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY); + } } - /* Set position */ - SDL_SetWindowPosition(window, desiredX, desiredY); - SDLTest_AssertPass("Call to SDL_SetWindowPosition(...,%d,%d)", desiredX, desiredY); + /* Dummy call with both pointers NULL */ + SDL_GetWindowPosition(window, NULL, NULL); + SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL,&y=NULL)"); - /* Get position */ - currentX = desiredX + 1; - currentY = desiredY + 1; - SDL_GetWindowPosition(window, ¤tX, ¤tY); - SDLTest_AssertPass("Call to SDL_GetWindowPosition()"); - SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX); - SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY); + /* Clean up */ + _destroyVideoSuiteTestWindow(window); - /* Get position X */ - currentX = desiredX + 1; - SDL_GetWindowPosition(window, ¤tX, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowPosition(&y=NULL)"); - SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX); + /* Set some 'magic' value for later check that nothing was changed */ + referenceX = SDLTest_RandomSint32(); + referenceY = SDLTest_RandomSint32(); + currentX = referenceX; + currentY = referenceY; + desiredX = SDLTest_RandomSint32(); + desiredY = SDLTest_RandomSint32(); - /* Get position Y */ - currentY = desiredY + 1; - SDL_GetWindowPosition(window, NULL, ¤tY); - SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL)"); - SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY); - } - } + /* Negative tests */ + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); + SDL_GetWindowPosition(NULL, ¤tX, ¤tY); + SDLTest_AssertPass("Call to SDL_GetWindowPosition(window=NULL)"); + SDLTest_AssertCheck( + currentX == referenceX && currentY == referenceY, + "Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d", + referenceX, referenceY, + currentX, currentY); + _checkInvalidWindowError(); - /* Dummy call with both pointers NULL */ - SDL_GetWindowPosition(window, NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL,&y=NULL)"); + SDL_GetWindowPosition(NULL, NULL, NULL); + SDLTest_AssertPass("Call to SDL_GetWindowPosition(NULL, NULL, NULL)"); + _checkInvalidWindowError(); - /* Clean up */ - _destroyVideoSuiteTestWindow(window); + SDL_SetWindowPosition(NULL, desiredX, desiredY); + SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)"); + _checkInvalidWindowError(); - /* Set some 'magic' value for later check that nothing was changed */ - referenceX = SDLTest_RandomSint32(); - referenceY = SDLTest_RandomSint32(); - currentX = referenceX; - currentY = referenceY; - desiredX = SDLTest_RandomSint32(); - desiredY = SDLTest_RandomSint32(); - - /* Negative tests */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - SDL_GetWindowPosition(NULL, ¤tX, ¤tY); - SDLTest_AssertPass("Call to SDL_GetWindowPosition(window=NULL)"); - SDLTest_AssertCheck( - currentX == referenceX && currentY == referenceY, - "Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d", - referenceX, referenceY, - currentX, currentY); - _checkInvalidWindowError(); - - SDL_GetWindowPosition(NULL, NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowPosition(NULL, NULL, NULL)"); - _checkInvalidWindowError(); - - SDL_SetWindowPosition(NULL, desiredX, desiredY); - SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)"); - _checkInvalidWindowError(); - - return TEST_COMPLETED; + return TEST_COMPLETED; } /* Helper function that checks for an 'Invalid parameter' error */ void _checkInvalidParameterError() { - const char *invalidParameterError = "Parameter"; - char *lastError; + const char *invalidParameterError = "Parameter"; + char *lastError; - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL"); - if (lastError != NULL) { - SDLTest_AssertCheck(SDL_strncmp(lastError, invalidParameterError, SDL_strlen(invalidParameterError)) == 0, - "SDL_GetError(): expected message starts with '%s', was message: '%s'", - invalidParameterError, - lastError); - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - } + lastError = (char *)SDL_GetError(); + SDLTest_AssertPass("SDL_GetError()"); + SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL"); + if (lastError != NULL) { + SDLTest_AssertCheck(SDL_strncmp(lastError, invalidParameterError, SDL_strlen(invalidParameterError)) == 0, + "SDL_GetError(): expected message starts with '%s', was message: '%s'", + invalidParameterError, + lastError); + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); + } } /** @@ -1213,679 +1194,673 @@ void _checkInvalidParameterError() * @sa http://wiki.libsdl.org/SDL_GetWindowSize * @sa http://wiki.libsdl.org/SDL_SetWindowSize */ -int -video_getSetWindowSize(void *arg) +int video_getSetWindowSize(void *arg) { - const char* title = "video_getSetWindowSize Test Window"; - SDL_Window* window; - int result; - SDL_Rect display; - int maxwVariation, maxhVariation; - int wVariation, hVariation; - int referenceW, referenceH; - int currentW, currentH; - int desiredW, desiredH; + const char *title = "video_getSetWindowSize Test Window"; + SDL_Window *window; + int result; + SDL_Rect display; + int maxwVariation, maxhVariation; + int wVariation, hVariation; + int referenceW, referenceH; + int currentW, currentH; + int desiredW, desiredH; - /* Get display bounds for size range */ - result = SDL_GetDisplayBounds(0, &display); - SDLTest_AssertPass("SDL_GetDisplayBounds()"); - SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result); - if (result != 0) { - return TEST_ABORTED; - } + /* Get display bounds for size range */ + result = SDL_GetDisplayBounds(0, &display); + SDLTest_AssertPass("SDL_GetDisplayBounds()"); + SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result); + if (result != 0) { + return TEST_ABORTED; + } - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window == NULL) { - return TEST_ABORTED; - } + /* Call against new test window */ + window = _createVideoSuiteTestWindow(title); + if (window == NULL) { + return TEST_ABORTED; + } #ifdef __WIN32__ - /* Platform clips window size to screen size */ - maxwVariation = 4; - maxhVariation = 4; + /* Platform clips window size to screen size */ + maxwVariation = 4; + maxhVariation = 4; #else - /* Platform allows window size >= screen size */ - maxwVariation = 5; - maxhVariation = 5; + /* Platform allows window size >= screen size */ + maxwVariation = 5; + maxhVariation = 5; #endif - - for (wVariation = 0; wVariation < maxwVariation; wVariation++) { - for (hVariation = 0; hVariation < maxhVariation; hVariation++) { - switch(wVariation) { - default: - case 0: - /* 1 Pixel Wide */ - desiredW = 1; - break; - case 1: - /* Random width inside screen */ - desiredW = SDLTest_RandomIntegerInRange(1, 100); - break; - case 2: - /* Width 1 pixel smaller than screen */ - desiredW = display.w - 1; - break; - case 3: - /* Width at screen size */ - desiredW = display.w; - break; - case 4: - /* Width 1 pixel larger than screen */ - desiredW = display.w + 1; - break; + + for (wVariation = 0; wVariation < maxwVariation; wVariation++) { + for (hVariation = 0; hVariation < maxhVariation; hVariation++) { + switch (wVariation) { + default: + case 0: + /* 1 Pixel Wide */ + desiredW = 1; + break; + case 1: + /* Random width inside screen */ + desiredW = SDLTest_RandomIntegerInRange(1, 100); + break; + case 2: + /* Width 1 pixel smaller than screen */ + desiredW = display.w - 1; + break; + case 3: + /* Width at screen size */ + desiredW = display.w; + break; + case 4: + /* Width 1 pixel larger than screen */ + desiredW = display.w + 1; + break; + } + + switch (hVariation) { + default: + case 0: + /* 1 Pixel High */ + desiredH = 1; + break; + case 1: + /* Random height inside screen */ + desiredH = SDLTest_RandomIntegerInRange(1, 100); + break; + case 2: + /* Height 1 pixel smaller than screen */ + desiredH = display.h - 1; + break; + case 3: + /* Height at screen size */ + desiredH = display.h; + break; + case 4: + /* Height 1 pixel larger than screen */ + desiredH = display.h + 1; + break; + } + + /* Set size */ + SDL_SetWindowSize(window, desiredW, desiredH); + SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH); + + /* Get size */ + currentW = desiredW + 1; + currentH = desiredH + 1; + SDL_GetWindowSize(window, ¤tW, ¤tH); + SDLTest_AssertPass("Call to SDL_GetWindowSize()"); + SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW); + SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); + + /* Get just width */ + currentW = desiredW + 1; + SDL_GetWindowSize(window, ¤tW, NULL); + SDLTest_AssertPass("Call to SDL_GetWindowSize(&h=NULL)"); + SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW); + + /* Get just height */ + currentH = desiredH + 1; + SDL_GetWindowSize(window, NULL, ¤tH); + SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL)"); + SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); + } } - switch(hVariation) { - default: - case 0: - /* 1 Pixel High */ - desiredH = 1; - break; - case 1: - /* Random height inside screen */ - desiredH = SDLTest_RandomIntegerInRange(1, 100); - break; - case 2: - /* Height 1 pixel smaller than screen */ - desiredH = display.h - 1; - break; - case 3: - /* Height at screen size */ - desiredH = display.h; - break; - case 4: - /* Height 1 pixel larger than screen */ - desiredH = display.h + 1; - break; + /* Dummy call with both pointers NULL */ + SDL_GetWindowSize(window, NULL, NULL); + SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL,&h=NULL)"); + + /* Negative tests for parameter input */ + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); + for (desiredH = -2; desiredH < 2; desiredH++) { + for (desiredW = -2; desiredW < 2; desiredW++) { + if (desiredW <= 0 || desiredH <= 0) { + SDL_SetWindowSize(window, desiredW, desiredH); + SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH); + _checkInvalidParameterError(); + } + } } - /* Set size */ - SDL_SetWindowSize(window, desiredW, desiredH); - SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH); + /* Clean up */ + _destroyVideoSuiteTestWindow(window); - /* Get size */ - currentW = desiredW + 1; - currentH = desiredH + 1; - SDL_GetWindowSize(window, ¤tW, ¤tH); - SDLTest_AssertPass("Call to SDL_GetWindowSize()"); - SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW); - SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); + /* Set some 'magic' value for later check that nothing was changed */ + referenceW = SDLTest_RandomSint32(); + referenceH = SDLTest_RandomSint32(); + currentW = referenceW; + currentH = referenceH; + desiredW = SDLTest_RandomSint32(); + desiredH = SDLTest_RandomSint32(); - /* Get just width */ - currentW = desiredW + 1; - SDL_GetWindowSize(window, ¤tW, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowSize(&h=NULL)"); - SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW); + /* Negative tests for window input */ + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); + SDL_GetWindowSize(NULL, ¤tW, ¤tH); + SDLTest_AssertPass("Call to SDL_GetWindowSize(window=NULL)"); + SDLTest_AssertCheck( + currentW == referenceW && currentH == referenceH, + "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", + referenceW, referenceH, + currentW, currentH); + _checkInvalidWindowError(); - /* Get just height */ - currentH = desiredH + 1; - SDL_GetWindowSize(window, NULL, ¤tH); - SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL)"); - SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); - } - } + SDL_GetWindowSize(NULL, NULL, NULL); + SDLTest_AssertPass("Call to SDL_GetWindowSize(NULL, NULL, NULL)"); + _checkInvalidWindowError(); - /* Dummy call with both pointers NULL */ - SDL_GetWindowSize(window, NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL,&h=NULL)"); + SDL_SetWindowSize(NULL, desiredW, desiredH); + SDLTest_AssertPass("Call to SDL_SetWindowSize(window=NULL)"); + _checkInvalidWindowError(); - /* Negative tests for parameter input */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - for (desiredH = -2; desiredH < 2; desiredH++) { - for (desiredW = -2; desiredW < 2; desiredW++) { - if (desiredW <= 0 || desiredH <= 0) { - SDL_SetWindowSize(window, desiredW, desiredH); - SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH); - _checkInvalidParameterError(); - } - } - } - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - - /* Set some 'magic' value for later check that nothing was changed */ - referenceW = SDLTest_RandomSint32(); - referenceH = SDLTest_RandomSint32(); - currentW = referenceW; - currentH = referenceH; - desiredW = SDLTest_RandomSint32(); - desiredH = SDLTest_RandomSint32(); - - /* Negative tests for window input */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - SDL_GetWindowSize(NULL, ¤tW, ¤tH); - SDLTest_AssertPass("Call to SDL_GetWindowSize(window=NULL)"); - SDLTest_AssertCheck( - currentW == referenceW && currentH == referenceH, - "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", - referenceW, referenceH, - currentW, currentH); - _checkInvalidWindowError(); - - SDL_GetWindowSize(NULL, NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowSize(NULL, NULL, NULL)"); - _checkInvalidWindowError(); - - SDL_SetWindowSize(NULL, desiredW, desiredH); - SDLTest_AssertPass("Call to SDL_SetWindowSize(window=NULL)"); - _checkInvalidWindowError(); - - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Tests call to SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize * */ -int -video_getSetWindowMinimumSize(void *arg) +int video_getSetWindowMinimumSize(void *arg) { - const char* title = "video_getSetWindowMinimumSize Test Window"; - SDL_Window* window; - int result; - SDL_Rect display; - int wVariation, hVariation; - int referenceW, referenceH; - int currentW, currentH; - int desiredW = 1; - int desiredH = 1; + const char *title = "video_getSetWindowMinimumSize Test Window"; + SDL_Window *window; + int result; + SDL_Rect display; + int wVariation, hVariation; + int referenceW, referenceH; + int currentW, currentH; + int desiredW = 1; + int desiredH = 1; - /* Get display bounds for size range */ - result = SDL_GetDisplayBounds(0, &display); - SDLTest_AssertPass("SDL_GetDisplayBounds()"); - SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result); - if (result != 0) { - return TEST_ABORTED; - } - - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window == NULL) { - return TEST_ABORTED; - } - - for (wVariation = 0; wVariation < 5; wVariation++) { - for (hVariation = 0; hVariation < 5; hVariation++) { - switch(wVariation) { - case 0: - /* 1 Pixel Wide */ - desiredW = 1; - break; - case 1: - /* Random width inside screen */ - desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1); - break; - case 2: - /* Width at screen size */ - desiredW = display.w; - break; + /* Get display bounds for size range */ + result = SDL_GetDisplayBounds(0, &display); + SDLTest_AssertPass("SDL_GetDisplayBounds()"); + SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result); + if (result != 0) { + return TEST_ABORTED; } - switch(hVariation) { - case 0: - /* 1 Pixel High */ - desiredH = 1; - break; - case 1: - /* Random height inside screen */ - desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1); - break; - case 2: - /* Height at screen size */ - desiredH = display.h; - break; - case 4: - /* Height 1 pixel larger than screen */ - desiredH = display.h + 1; - break; + /* Call against new test window */ + window = _createVideoSuiteTestWindow(title); + if (window == NULL) { + return TEST_ABORTED; } - /* Set size */ - SDL_SetWindowMinimumSize(window, desiredW, desiredH); - SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH); + for (wVariation = 0; wVariation < 5; wVariation++) { + for (hVariation = 0; hVariation < 5; hVariation++) { + switch (wVariation) { + case 0: + /* 1 Pixel Wide */ + desiredW = 1; + break; + case 1: + /* Random width inside screen */ + desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1); + break; + case 2: + /* Width at screen size */ + desiredW = display.w; + break; + } - /* Get size */ - currentW = desiredW + 1; - currentH = desiredH + 1; - SDL_GetWindowMinimumSize(window, ¤tW, ¤tH); - SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize()"); - SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW); - SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); + switch (hVariation) { + case 0: + /* 1 Pixel High */ + desiredH = 1; + break; + case 1: + /* Random height inside screen */ + desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1); + break; + case 2: + /* Height at screen size */ + desiredH = display.h; + break; + case 4: + /* Height 1 pixel larger than screen */ + desiredH = display.h + 1; + break; + } - /* Get just width */ - currentW = desiredW + 1; - SDL_GetWindowMinimumSize(window, ¤tW, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&h=NULL)"); - SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH); + /* Set size */ + SDL_SetWindowMinimumSize(window, desiredW, desiredH); + SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH); - /* Get just height */ - currentH = desiredH + 1; - SDL_GetWindowMinimumSize(window, NULL, ¤tH); - SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL)"); - SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH); - } - } + /* Get size */ + currentW = desiredW + 1; + currentH = desiredH + 1; + SDL_GetWindowMinimumSize(window, ¤tW, ¤tH); + SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize()"); + SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW); + SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); - /* Dummy call with both pointers NULL */ - SDL_GetWindowMinimumSize(window, NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL,&h=NULL)"); + /* Get just width */ + currentW = desiredW + 1; + SDL_GetWindowMinimumSize(window, ¤tW, NULL); + SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&h=NULL)"); + SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH); - /* Negative tests for parameter input */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - for (desiredH = -2; desiredH < 2; desiredH++) { - for (desiredW = -2; desiredW < 2; desiredW++) { - if (desiredW <= 0 || desiredH <= 0) { - SDL_SetWindowMinimumSize(window, desiredW, desiredH); - SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH); - _checkInvalidParameterError(); - } + /* Get just height */ + currentH = desiredH + 1; + SDL_GetWindowMinimumSize(window, NULL, ¤tH); + SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL)"); + SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH); + } } - } - /* Clean up */ - _destroyVideoSuiteTestWindow(window); + /* Dummy call with both pointers NULL */ + SDL_GetWindowMinimumSize(window, NULL, NULL); + SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL,&h=NULL)"); - /* Set some 'magic' value for later check that nothing was changed */ - referenceW = SDLTest_RandomSint32(); - referenceH = SDLTest_RandomSint32(); - currentW = referenceW; - currentH = referenceH; - desiredW = SDLTest_RandomSint32(); - desiredH = SDLTest_RandomSint32(); + /* Negative tests for parameter input */ + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); + for (desiredH = -2; desiredH < 2; desiredH++) { + for (desiredW = -2; desiredW < 2; desiredW++) { + if (desiredW <= 0 || desiredH <= 0) { + SDL_SetWindowMinimumSize(window, desiredW, desiredH); + SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH); + _checkInvalidParameterError(); + } + } + } - /* Negative tests for window input */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - SDL_GetWindowMinimumSize(NULL, ¤tW, ¤tH); - SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(window=NULL)"); - SDLTest_AssertCheck( - currentW == referenceW && currentH == referenceH, - "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", - referenceW, referenceH, - currentW, currentH); - _checkInvalidWindowError(); + /* Clean up */ + _destroyVideoSuiteTestWindow(window); - SDL_GetWindowMinimumSize(NULL, NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(NULL, NULL, NULL)"); - _checkInvalidWindowError(); + /* Set some 'magic' value for later check that nothing was changed */ + referenceW = SDLTest_RandomSint32(); + referenceH = SDLTest_RandomSint32(); + currentW = referenceW; + currentH = referenceH; + desiredW = SDLTest_RandomSint32(); + desiredH = SDLTest_RandomSint32(); - SDL_SetWindowMinimumSize(NULL, desiredW, desiredH); - SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(window=NULL)"); - _checkInvalidWindowError(); + /* Negative tests for window input */ + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); + SDL_GetWindowMinimumSize(NULL, ¤tW, ¤tH); + SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(window=NULL)"); + SDLTest_AssertCheck( + currentW == referenceW && currentH == referenceH, + "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", + referenceW, referenceH, + currentW, currentH); + _checkInvalidWindowError(); - return TEST_COMPLETED; + SDL_GetWindowMinimumSize(NULL, NULL, NULL); + SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(NULL, NULL, NULL)"); + _checkInvalidWindowError(); + + SDL_SetWindowMinimumSize(NULL, desiredW, desiredH); + SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(window=NULL)"); + _checkInvalidWindowError(); + + return TEST_COMPLETED; } /** * @brief Tests call to SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize * */ -int -video_getSetWindowMaximumSize(void *arg) +int video_getSetWindowMaximumSize(void *arg) { - const char* title = "video_getSetWindowMaximumSize Test Window"; - SDL_Window* window; - int result; - SDL_Rect display; - int wVariation, hVariation; - int referenceW, referenceH; - int currentW, currentH; - int desiredW, desiredH; + const char *title = "video_getSetWindowMaximumSize Test Window"; + SDL_Window *window; + int result; + SDL_Rect display; + int wVariation, hVariation; + int referenceW, referenceH; + int currentW, currentH; + int desiredW, desiredH; - /* Get display bounds for size range */ - result = SDL_GetDisplayBounds(0, &display); - SDLTest_AssertPass("SDL_GetDisplayBounds()"); - SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result); - if (result != 0) { - return TEST_ABORTED; - } - - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window == NULL) { - return TEST_ABORTED; - } - - for (wVariation = 0; wVariation < 3; wVariation++) { - for (hVariation = 0; hVariation < 3; hVariation++) { - switch(wVariation) { - case 0: - /* 1 Pixel Wide */ - desiredW = 1; - break; - case 1: - /* Random width inside screen */ - desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1); - break; - case 2: - /* Width at screen size */ - desiredW = display.w; - break; + /* Get display bounds for size range */ + result = SDL_GetDisplayBounds(0, &display); + SDLTest_AssertPass("SDL_GetDisplayBounds()"); + SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result); + if (result != 0) { + return TEST_ABORTED; } - switch(hVariation) { - case 0: - /* 1 Pixel High */ - desiredH = 1; - break; - case 1: - /* Random height inside screen */ - desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1); - break; - case 2: - /* Height at screen size */ - desiredH = display.h; - break; + /* Call against new test window */ + window = _createVideoSuiteTestWindow(title); + if (window == NULL) { + return TEST_ABORTED; } - /* Set size */ - SDL_SetWindowMaximumSize(window, desiredW, desiredH); - SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH); + for (wVariation = 0; wVariation < 3; wVariation++) { + for (hVariation = 0; hVariation < 3; hVariation++) { + switch (wVariation) { + case 0: + /* 1 Pixel Wide */ + desiredW = 1; + break; + case 1: + /* Random width inside screen */ + desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1); + break; + case 2: + /* Width at screen size */ + desiredW = display.w; + break; + } - /* Get size */ - currentW = desiredW + 1; - currentH = desiredH + 1; - SDL_GetWindowMaximumSize(window, ¤tW, ¤tH); - SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize()"); - SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW); - SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); + switch (hVariation) { + case 0: + /* 1 Pixel High */ + desiredH = 1; + break; + case 1: + /* Random height inside screen */ + desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1); + break; + case 2: + /* Height at screen size */ + desiredH = display.h; + break; + } - /* Get just width */ - currentW = desiredW + 1; - SDL_GetWindowMaximumSize(window, ¤tW, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&h=NULL)"); - SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH); + /* Set size */ + SDL_SetWindowMaximumSize(window, desiredW, desiredH); + SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH); - /* Get just height */ - currentH = desiredH + 1; - SDL_GetWindowMaximumSize(window, NULL, ¤tH); - SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL)"); - SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH); - } - } + /* Get size */ + currentW = desiredW + 1; + currentH = desiredH + 1; + SDL_GetWindowMaximumSize(window, ¤tW, ¤tH); + SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize()"); + SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW); + SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); - /* Dummy call with both pointers NULL */ - SDL_GetWindowMaximumSize(window, NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL,&h=NULL)"); + /* Get just width */ + currentW = desiredW + 1; + SDL_GetWindowMaximumSize(window, ¤tW, NULL); + SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&h=NULL)"); + SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH); - /* Negative tests for parameter input */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - for (desiredH = -2; desiredH < 2; desiredH++) { - for (desiredW = -2; desiredW < 2; desiredW++) { - if (desiredW <= 0 || desiredH <= 0) { - SDL_SetWindowMaximumSize(window, desiredW, desiredH); - SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH); - _checkInvalidParameterError(); - } + /* Get just height */ + currentH = desiredH + 1; + SDL_GetWindowMaximumSize(window, NULL, ¤tH); + SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL)"); + SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH); + } } - } - /* Clean up */ - _destroyVideoSuiteTestWindow(window); + /* Dummy call with both pointers NULL */ + SDL_GetWindowMaximumSize(window, NULL, NULL); + SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL,&h=NULL)"); - /* Set some 'magic' value for later check that nothing was changed */ - referenceW = SDLTest_RandomSint32(); - referenceH = SDLTest_RandomSint32(); - currentW = referenceW; - currentH = referenceH; - desiredW = SDLTest_RandomSint32(); - desiredH = SDLTest_RandomSint32(); + /* Negative tests for parameter input */ + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); + for (desiredH = -2; desiredH < 2; desiredH++) { + for (desiredW = -2; desiredW < 2; desiredW++) { + if (desiredW <= 0 || desiredH <= 0) { + SDL_SetWindowMaximumSize(window, desiredW, desiredH); + SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH); + _checkInvalidParameterError(); + } + } + } - /* Negative tests */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - SDL_GetWindowMaximumSize(NULL, ¤tW, ¤tH); - SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(window=NULL)"); - SDLTest_AssertCheck( - currentW == referenceW && currentH == referenceH, - "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", - referenceW, referenceH, - currentW, currentH); - _checkInvalidWindowError(); + /* Clean up */ + _destroyVideoSuiteTestWindow(window); - SDL_GetWindowMaximumSize(NULL, NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(NULL, NULL, NULL)"); - _checkInvalidWindowError(); + /* Set some 'magic' value for later check that nothing was changed */ + referenceW = SDLTest_RandomSint32(); + referenceH = SDLTest_RandomSint32(); + currentW = referenceW; + currentH = referenceH; + desiredW = SDLTest_RandomSint32(); + desiredH = SDLTest_RandomSint32(); - SDL_SetWindowMaximumSize(NULL, desiredW, desiredH); - SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(window=NULL)"); - _checkInvalidWindowError(); + /* Negative tests */ + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); + SDL_GetWindowMaximumSize(NULL, ¤tW, ¤tH); + SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(window=NULL)"); + SDLTest_AssertCheck( + currentW == referenceW && currentH == referenceH, + "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", + referenceW, referenceH, + currentW, currentH); + _checkInvalidWindowError(); - return TEST_COMPLETED; + SDL_GetWindowMaximumSize(NULL, NULL, NULL); + SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(NULL, NULL, NULL)"); + _checkInvalidWindowError(); + + SDL_SetWindowMaximumSize(NULL, desiredW, desiredH); + SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(window=NULL)"); + _checkInvalidWindowError(); + + return TEST_COMPLETED; } - /** * @brief Tests call to SDL_SetWindowData and SDL_GetWindowData * * @sa http://wiki.libsdl.org/SDL_SetWindowData * @sa http://wiki.libsdl.org/SDL_GetWindowData */ -int -video_getSetWindowData(void *arg) +int video_getSetWindowData(void *arg) { - int returnValue = TEST_COMPLETED; - const char* title = "video_setGetWindowData Test Window"; - SDL_Window* window; - const char *referenceName = "TestName"; - const char *name = "TestName"; - const char *referenceName2 = "TestName2"; - const char *name2 = "TestName2"; - int datasize; - char *referenceUserdata = NULL; - char *userdata = NULL; - char *referenceUserdata2 = NULL; - char *userdata2 = NULL; - char *result; - int iteration; + int returnValue = TEST_COMPLETED; + const char *title = "video_setGetWindowData Test Window"; + SDL_Window *window; + const char *referenceName = "TestName"; + const char *name = "TestName"; + const char *referenceName2 = "TestName2"; + const char *name2 = "TestName2"; + int datasize; + char *referenceUserdata = NULL; + char *userdata = NULL; + char *referenceUserdata2 = NULL; + char *userdata2 = NULL; + char *result; + int iteration; - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window == NULL) { - return TEST_ABORTED; - } + /* Call against new test window */ + window = _createVideoSuiteTestWindow(title); + if (window == NULL) { + return TEST_ABORTED; + } - /* Create testdata */ - datasize = SDLTest_RandomIntegerInRange(1, 32); - referenceUserdata = SDLTest_RandomAsciiStringOfSize(datasize); - if (referenceUserdata == NULL) { - returnValue = TEST_ABORTED; - goto cleanup; - } - userdata = SDL_strdup(referenceUserdata); - if (userdata == NULL) { - returnValue = TEST_ABORTED; - goto cleanup; - } - datasize = SDLTest_RandomIntegerInRange(1, 32); - referenceUserdata2 = SDLTest_RandomAsciiStringOfSize(datasize); - if (referenceUserdata2 == NULL) { - returnValue = TEST_ABORTED; - goto cleanup; - } - userdata2 = (char *)SDL_strdup(referenceUserdata2); - if (userdata2 == NULL) { - returnValue = TEST_ABORTED; - goto cleanup; - } + /* Create testdata */ + datasize = SDLTest_RandomIntegerInRange(1, 32); + referenceUserdata = SDLTest_RandomAsciiStringOfSize(datasize); + if (referenceUserdata == NULL) { + returnValue = TEST_ABORTED; + goto cleanup; + } + userdata = SDL_strdup(referenceUserdata); + if (userdata == NULL) { + returnValue = TEST_ABORTED; + goto cleanup; + } + datasize = SDLTest_RandomIntegerInRange(1, 32); + referenceUserdata2 = SDLTest_RandomAsciiStringOfSize(datasize); + if (referenceUserdata2 == NULL) { + returnValue = TEST_ABORTED; + goto cleanup; + } + userdata2 = (char *)SDL_strdup(referenceUserdata2); + if (userdata2 == NULL) { + returnValue = TEST_ABORTED; + goto cleanup; + } - /* Get non-existent data */ - result = (char *)SDL_GetWindowData(window, name); - SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - - /* Set data */ - result = (char *)SDL_SetWindowData(window, name, userdata); - SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s)", name, userdata); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); - - /* Get data (twice) */ - for (iteration = 1; iteration <= 2; iteration++) { + /* Get non-existent data */ result = (char *)SDL_GetWindowData(window, name); - SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [iteration %d]", name, iteration); + SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name); + SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); + SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); + + /* Set data */ + result = (char *)SDL_SetWindowData(window, name, userdata); + SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s)", name, userdata); + SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); + SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); + SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); + + /* Get data (twice) */ + for (iteration = 1; iteration <= 2; iteration++) { + result = (char *)SDL_GetWindowData(window, name); + SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [iteration %d]", name, iteration); + SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result); + SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); + } + + /* Set data again twice */ + for (iteration = 1; iteration <= 2; iteration++) { + result = (char *)SDL_SetWindowData(window, name, userdata); + SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [iteration %d]", name, userdata, iteration); + SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result); + SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); + SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); + } + + /* Get data again */ + result = (char *)SDL_GetWindowData(window, name); + SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again]", name); SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result); SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - } - /* Set data again twice */ - for (iteration = 1; iteration <= 2; iteration++) { - result = (char *)SDL_SetWindowData(window, name, userdata); - SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [iteration %d]", name, userdata, iteration); + /* Set data with new data */ + result = (char *)SDL_SetWindowData(window, name, userdata2); + SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata]", name, userdata2); SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result); SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); - } + SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); - /* Get data again */ - result = (char *)SDL_GetWindowData(window, name); - SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again]", name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); + /* Set data with new data again */ + result = (char *)SDL_SetWindowData(window, name, userdata2); + SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata again]", name, userdata2); + SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result); + SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); + SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); + SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); - /* Set data with new data */ - result = (char *)SDL_SetWindowData(window, name, userdata2); - SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata]", name, userdata2); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); + /* Get new data */ + result = (char *)SDL_GetWindowData(window, name); + SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name); + SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result); + SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - /* Set data with new data again */ - result = (char *)SDL_SetWindowData(window, name, userdata2); - SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata again]", name, userdata2); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); + /* Set data with NULL to clear */ + result = (char *)SDL_SetWindowData(window, name, NULL); + SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL)", name); + SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result); + SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); + SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); + SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); - /* Get new data */ - result = (char *)SDL_GetWindowData(window, name); - SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); + /* Set data with NULL to clear again */ + result = (char *)SDL_SetWindowData(window, name, NULL); + SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL) [again]", name); + SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); + SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); + SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); + SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); - /* Set data with NULL to clear */ - result = (char *)SDL_SetWindowData(window, name, NULL); - SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL)", name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); + /* Get non-existent data */ + result = (char *)SDL_GetWindowData(window, name); + SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name); + SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); + SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - /* Set data with NULL to clear again */ - result = (char *)SDL_SetWindowData(window, name, NULL); - SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL) [again]", name); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); + /* Get non-existent data new name */ + result = (char *)SDL_GetWindowData(window, name2); + SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name2); + SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); + SDLTest_AssertCheck(SDL_strcmp(referenceName2, name2) == 0, "Validate that name2 was not changed, expected: %s, got: %s", referenceName2, name2); - /* Get non-existent data */ - result = (char *)SDL_GetWindowData(window, name); - SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); + /* Set data (again) */ + result = (char *)SDL_SetWindowData(window, name, userdata); + SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [again, after clear]", name, userdata); + SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); + SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); + SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); - /* Get non-existent data new name */ - result = (char *)SDL_GetWindowData(window, name2); - SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name2); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - SDLTest_AssertCheck(SDL_strcmp(referenceName2, name2) == 0, "Validate that name2 was not changed, expected: %s, got: %s", referenceName2, name2); + /* Get data (again) */ + result = (char *)SDL_GetWindowData(window, name); + SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again, after clear]", name); + SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result); + SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - /* Set data (again) */ - result = (char *)SDL_SetWindowData(window, name, userdata); - SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [again, after clear]", name, userdata); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); + /* Negative test */ + SDL_ClearError(); + SDLTest_AssertPass("Call to SDL_ClearError()"); - /* Get data (again) */ - result = (char *)SDL_GetWindowData(window, name); - SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again, after clear]", name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); + /* Set with invalid window */ + result = (char *)SDL_SetWindowData(NULL, name, userdata); + SDLTest_AssertPass("Call to SDL_SetWindowData(window=NULL)"); + SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); + _checkInvalidWindowError(); - /* Negative test */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); + /* Set data with NULL name, valid userdata */ + result = (char *)SDL_SetWindowData(window, NULL, userdata); + SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL)"); + SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); + _checkInvalidParameterError(); - /* Set with invalid window */ - result = (char *)SDL_SetWindowData(NULL, name, userdata); - SDLTest_AssertPass("Call to SDL_SetWindowData(window=NULL)"); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - _checkInvalidWindowError(); + /* Set data with empty name, valid userdata */ + result = (char *)SDL_SetWindowData(window, "", userdata); + SDLTest_AssertPass("Call to SDL_SetWindowData(name='')"); + SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); + _checkInvalidParameterError(); - /* Set data with NULL name, valid userdata */ - result = (char *)SDL_SetWindowData(window, NULL, userdata); - SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL)"); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - _checkInvalidParameterError(); + /* Set data with NULL name, NULL userdata */ + result = (char *)SDL_SetWindowData(window, NULL, NULL); + SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL,userdata=NULL)"); + SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); + _checkInvalidParameterError(); - /* Set data with empty name, valid userdata */ - result = (char *)SDL_SetWindowData(window, "", userdata); - SDLTest_AssertPass("Call to SDL_SetWindowData(name='')"); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - _checkInvalidParameterError(); + /* Set data with empty name, NULL userdata */ + result = (char *)SDL_SetWindowData(window, "", NULL); + SDLTest_AssertPass("Call to SDL_SetWindowData(name='',userdata=NULL)"); + SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); + _checkInvalidParameterError(); - /* Set data with NULL name, NULL userdata */ - result = (char *)SDL_SetWindowData(window, NULL, NULL); - SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL,userdata=NULL)"); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - _checkInvalidParameterError(); + /* Get with invalid window */ + result = (char *)SDL_GetWindowData(NULL, name); + SDLTest_AssertPass("Call to SDL_GetWindowData(window=NULL)"); + SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); + _checkInvalidWindowError(); - /* Set data with empty name, NULL userdata */ - result = (char *)SDL_SetWindowData(window, "", NULL); - SDLTest_AssertPass("Call to SDL_SetWindowData(name='',userdata=NULL)"); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - _checkInvalidParameterError(); + /* Get data with NULL name */ + result = (char *)SDL_GetWindowData(window, NULL); + SDLTest_AssertPass("Call to SDL_GetWindowData(name=NULL)"); + SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); + _checkInvalidParameterError(); - /* Get with invalid window */ - result = (char *)SDL_GetWindowData(NULL, name); - SDLTest_AssertPass("Call to SDL_GetWindowData(window=NULL)"); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - _checkInvalidWindowError(); + /* Get data with empty name */ + result = (char *)SDL_GetWindowData(window, ""); + SDLTest_AssertPass("Call to SDL_GetWindowData(name='')"); + SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); + _checkInvalidParameterError(); - /* Get data with NULL name */ - result = (char *)SDL_GetWindowData(window, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowData(name=NULL)"); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - _checkInvalidParameterError(); + /* Clean up */ + _destroyVideoSuiteTestWindow(window); - /* Get data with empty name */ - result = (char *)SDL_GetWindowData(window, ""); - SDLTest_AssertPass("Call to SDL_GetWindowData(name='')"); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - _checkInvalidParameterError(); +cleanup: + SDL_free(referenceUserdata); + SDL_free(referenceUserdata2); + SDL_free(userdata); + SDL_free(userdata2); - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - - cleanup: - SDL_free(referenceUserdata); - SDL_free(referenceUserdata2); - SDL_free(userdata); - SDL_free(userdata2); - - return returnValue; + return returnValue; } /** -* @brief Tests the functionality of the SDL_WINDOWPOS_CENTERED_DISPLAY along with SDL_WINDOW_FULLSCREEN_DESKTOP. -* -* Espeically useful when run on a multi-monitor system with different DPI scales per monitor, -* to test that the window size is maintained when moving between monitors. -*/ -int -video_setWindowCenteredOnDisplay(void *arg) + * @brief Tests the functionality of the SDL_WINDOWPOS_CENTERED_DISPLAY along with SDL_WINDOW_FULLSCREEN_DESKTOP. + * + * Espeically useful when run on a multi-monitor system with different DPI scales per monitor, + * to test that the window size is maintained when moving between monitors. + */ +int video_setWindowCenteredOnDisplay(void *arg) { SDL_Window *window; const char *title = "video_setWindowCenteredOnDisplay Test Window"; @@ -2007,32 +1982,41 @@ video_setWindowCenteredOnDisplay(void *arg) /* ================= Test References ================== */ /* Video test cases */ -static const SDLTest_TestCaseReference videoTest1 = - { (SDLTest_TestCaseFp)video_enableDisableScreensaver, "video_enableDisableScreensaver", "Enable and disable screenaver while checking state", TEST_ENABLED }; +static const SDLTest_TestCaseReference videoTest1 = { + (SDLTest_TestCaseFp)video_enableDisableScreensaver, "video_enableDisableScreensaver", "Enable and disable screenaver while checking state", TEST_ENABLED +}; -static const SDLTest_TestCaseReference videoTest2 = - { (SDLTest_TestCaseFp)video_createWindowVariousPositions, "video_createWindowVariousPositions", "Create windows at various locations", TEST_ENABLED }; +static const SDLTest_TestCaseReference videoTest2 = { + (SDLTest_TestCaseFp)video_createWindowVariousPositions, "video_createWindowVariousPositions", "Create windows at various locations", TEST_ENABLED +}; -static const SDLTest_TestCaseReference videoTest3 = - { (SDLTest_TestCaseFp)video_createWindowVariousSizes, "video_createWindowVariousSizes", "Create windows with various sizes", TEST_ENABLED }; +static const SDLTest_TestCaseReference videoTest3 = { + (SDLTest_TestCaseFp)video_createWindowVariousSizes, "video_createWindowVariousSizes", "Create windows with various sizes", TEST_ENABLED +}; -static const SDLTest_TestCaseReference videoTest4 = - { (SDLTest_TestCaseFp)video_createWindowVariousFlags, "video_createWindowVariousFlags", "Create windows using various flags", TEST_ENABLED }; +static const SDLTest_TestCaseReference videoTest4 = { + (SDLTest_TestCaseFp)video_createWindowVariousFlags, "video_createWindowVariousFlags", "Create windows using various flags", TEST_ENABLED +}; -static const SDLTest_TestCaseReference videoTest5 = - { (SDLTest_TestCaseFp)video_getWindowFlags, "video_getWindowFlags", "Get window flags set during SDL_CreateWindow", TEST_ENABLED }; +static const SDLTest_TestCaseReference videoTest5 = { + (SDLTest_TestCaseFp)video_getWindowFlags, "video_getWindowFlags", "Get window flags set during SDL_CreateWindow", TEST_ENABLED +}; -static const SDLTest_TestCaseReference videoTest6 = - { (SDLTest_TestCaseFp)video_getNumDisplayModes, "video_getNumDisplayModes", "Use SDL_GetNumDisplayModes function to get number of display modes", TEST_ENABLED }; +static const SDLTest_TestCaseReference videoTest6 = { + (SDLTest_TestCaseFp)video_getNumDisplayModes, "video_getNumDisplayModes", "Use SDL_GetNumDisplayModes function to get number of display modes", TEST_ENABLED +}; -static const SDLTest_TestCaseReference videoTest7 = - { (SDLTest_TestCaseFp)video_getNumDisplayModesNegative, "video_getNumDisplayModesNegative", "Negative tests for SDL_GetNumDisplayModes", TEST_ENABLED }; +static const SDLTest_TestCaseReference videoTest7 = { + (SDLTest_TestCaseFp)video_getNumDisplayModesNegative, "video_getNumDisplayModesNegative", "Negative tests for SDL_GetNumDisplayModes", TEST_ENABLED +}; -static const SDLTest_TestCaseReference videoTest8 = - { (SDLTest_TestCaseFp)video_getClosestDisplayModeCurrentResolution, "video_getClosestDisplayModeCurrentResolution", "Use function to get closes match to requested display mode for current resolution", TEST_ENABLED }; +static const SDLTest_TestCaseReference videoTest8 = { + (SDLTest_TestCaseFp)video_getClosestDisplayModeCurrentResolution, "video_getClosestDisplayModeCurrentResolution", "Use function to get closes match to requested display mode for current resolution", TEST_ENABLED +}; -static const SDLTest_TestCaseReference videoTest9 = - { (SDLTest_TestCaseFp)video_getClosestDisplayModeRandomResolution, "video_getClosestDisplayModeRandomResolution", "Use function to get closes match to requested display mode for random resolution", TEST_ENABLED }; +static const SDLTest_TestCaseReference videoTest9 = { + (SDLTest_TestCaseFp)video_getClosestDisplayModeRandomResolution, "video_getClosestDisplayModeRandomResolution", "Use function to get closes match to requested display mode for random resolution", TEST_ENABLED +}; static const SDLTest_TestCaseReference videoTest10 = { (SDLTest_TestCaseFp)video_getWindowBrightness, "video_getWindowBrightness", "Get window brightness", TEST_ENABLED }; @@ -2080,7 +2064,7 @@ static const SDLTest_TestCaseReference videoTest24 = { (SDLTest_TestCaseFp) video_setWindowCenteredOnDisplay, "video_setWindowCenteredOnDisplay", "Checks using SDL_WINDOWPOS_CENTERED_DISPLAY centers the window on a display", TEST_ENABLED }; /* Sequence of Video test cases */ -static const SDLTest_TestCaseReference *videoTests[] = { +static const SDLTest_TestCaseReference *videoTests[] = { &videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6, &videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12, &videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17, diff --git a/test/testbounds.c b/test/testbounds.c index 23f981777..4afecf701 100644 --- a/test/testbounds.c +++ b/test/testbounds.c @@ -23,7 +23,7 @@ int main(int argc, char **argv) total = SDL_GetNumVideoDisplays(); for (i = 0; i < total; i++) { - SDL_Rect bounds = { -1,-1,-1,-1 }, usable = { -1,-1,-1,-1 }; + SDL_Rect bounds = { -1, -1, -1, -1 }, usable = { -1, -1, -1, -1 }; SDL_GetDisplayBounds(i, &bounds); SDL_GetDisplayUsableBounds(i, &usable); SDL_Log("Display #%d ('%s'): bounds={(%d,%d),%dx%d}, usable={(%d,%d),%dx%d}", diff --git a/test/testcustomcursor.c b/test/testcustomcursor.c index d63a38a56..81d72c9cb 100644 --- a/test/testcustomcursor.c +++ b/test/testcustomcursor.c @@ -22,59 +22,58 @@ /* Stolen from the mailing list */ /* Creates a new mouse cursor from an XPM */ - /* XPM */ static const char *arrow[] = { - /* width height num_colors chars_per_pixel */ - " 32 32 3 1", - /* colors */ - "X c #000000", - ". c #ffffff", - " c None", - /* pixels */ - "X ", - "XX ", - "X.X ", - "X..X ", - "X...X ", - "X....X ", - "X.....X ", - "X......X ", - "X.......X ", - "X........X ", - "X.....XXXXX ", - "X..X..X ", - "X.X X..X ", - "XX X..X ", - "X X..X ", - " X..X ", - " X..X ", - " X..X ", - " XX ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - "0,0" -}; + /* width height num_colors chars_per_pixel */ + " 32 32 3 1", + /* colors */ + "X c #000000", + ". c #ffffff", + " c None", + /* pixels */ + "X ", + "XX ", + "X.X ", + "X..X ", + "X...X ", + "X....X ", + "X.....X ", + "X......X ", + "X.......X ", + "X........X ", + "X.....XXXXX ", + "X..X..X ", + "X.X X..X ", + "XX X..X ", + "X X..X ", + " X..X ", + " X..X ", + " X..X ", + " XX ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "0,0" +}; -static SDL_Cursor* +static SDL_Cursor * init_color_cursor(const char *file) { SDL_Cursor *cursor = NULL; SDL_Surface *surface = SDL_LoadBMP(file); if (surface) { if (surface->format->palette) { - SDL_SetColorKey(surface, 1, *(Uint8 *) surface->pixels); + SDL_SetColorKey(surface, 1, *(Uint8 *)surface->pixels); } else { switch (surface->format->BitsPerPixel) { case 15: @@ -97,45 +96,45 @@ init_color_cursor(const char *file) return cursor; } -static SDL_Cursor* +static SDL_Cursor * init_system_cursor(const char *image[]) { - int i, row, col; - Uint8 data[4*32]; - Uint8 mask[4*32]; - int hot_x, hot_y; + int i, row, col; + Uint8 data[4 * 32]; + Uint8 mask[4 * 32]; + int hot_x, hot_y; - i = -1; - for (row=0; row<32; ++row) { - for (col=0; col<32; ++col) { - if (col % 8) { - data[i] <<= 1; - mask[i] <<= 1; - } else { - ++i; - data[i] = mask[i] = 0; - } - switch (image[4+row][col]) { - case 'X': - data[i] |= 0x01; - mask[i] |= 0x01; - break; - case '.': - mask[i] |= 0x01; - break; - case ' ': - break; - } + i = -1; + for (row = 0; row < 32; ++row) { + for (col = 0; col < 32; ++col) { + if (col % 8) { + data[i] <<= 1; + mask[i] <<= 1; + } else { + ++i; + data[i] = mask[i] = 0; + } + switch (image[4 + row][col]) { + case 'X': + data[i] |= 0x01; + mask[i] |= 0x01; + break; + case '.': + mask[i] |= 0x01; + break; + case ' ': + break; + } + } } - } - SDL_sscanf(image[4+row], "%d,%d", &hot_x, &hot_y); - return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y); + SDL_sscanf(image[4 + row], "%d,%d", &hot_x, &hot_y); + return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y); } static SDLTest_CommonState *state; int done; -static SDL_Cursor *cursors[1+SDL_NUM_SYSTEM_CURSORS]; -static SDL_SystemCursor cursor_types[1+SDL_NUM_SYSTEM_CURSORS]; +static SDL_Cursor *cursors[1 + SDL_NUM_SYSTEM_CURSORS]; +static SDL_SystemCursor cursor_types[1 + SDL_NUM_SYSTEM_CURSORS]; static int num_cursors; static int current_cursor; static int show_cursor; @@ -148,8 +147,7 @@ quit(int rc) exit(rc); } -void -loop() +void loop() { int i; SDL_Event event; @@ -170,20 +168,48 @@ loop() SDL_SetCursor(cursors[current_cursor]); switch ((int)cursor_types[current_cursor]) { - case (SDL_SystemCursor)-1: SDL_Log("Custom cursor"); break; - case SDL_SYSTEM_CURSOR_ARROW: SDL_Log("Arrow"); break; - case SDL_SYSTEM_CURSOR_IBEAM: SDL_Log("I-beam"); break; - case SDL_SYSTEM_CURSOR_WAIT: SDL_Log("Wait"); break; - case SDL_SYSTEM_CURSOR_CROSSHAIR: SDL_Log("Crosshair"); break; - case SDL_SYSTEM_CURSOR_WAITARROW: SDL_Log("Small wait cursor (or Wait if not available)"); break; - case SDL_SYSTEM_CURSOR_SIZENWSE: SDL_Log("Double arrow pointing northwest and southeast"); break; - case SDL_SYSTEM_CURSOR_SIZENESW: SDL_Log("Double arrow pointing northeast and southwest"); break; - case SDL_SYSTEM_CURSOR_SIZEWE: SDL_Log("Double arrow pointing west and east"); break; - case SDL_SYSTEM_CURSOR_SIZENS: SDL_Log("Double arrow pointing north and south"); break; - case SDL_SYSTEM_CURSOR_SIZEALL: SDL_Log("Four pointed arrow pointing north, south, east, and west"); break; - case SDL_SYSTEM_CURSOR_NO: SDL_Log("Slashed circle or crossbones"); break; - case SDL_SYSTEM_CURSOR_HAND: SDL_Log("Hand"); break; - default: SDL_Log("UNKNOWN CURSOR TYPE, FIX THIS PROGRAM."); break; + case (SDL_SystemCursor)-1: + SDL_Log("Custom cursor"); + break; + case SDL_SYSTEM_CURSOR_ARROW: + SDL_Log("Arrow"); + break; + case SDL_SYSTEM_CURSOR_IBEAM: + SDL_Log("I-beam"); + break; + case SDL_SYSTEM_CURSOR_WAIT: + SDL_Log("Wait"); + break; + case SDL_SYSTEM_CURSOR_CROSSHAIR: + SDL_Log("Crosshair"); + break; + case SDL_SYSTEM_CURSOR_WAITARROW: + SDL_Log("Small wait cursor (or Wait if not available)"); + break; + case SDL_SYSTEM_CURSOR_SIZENWSE: + SDL_Log("Double arrow pointing northwest and southeast"); + break; + case SDL_SYSTEM_CURSOR_SIZENESW: + SDL_Log("Double arrow pointing northeast and southwest"); + break; + case SDL_SYSTEM_CURSOR_SIZEWE: + SDL_Log("Double arrow pointing west and east"); + break; + case SDL_SYSTEM_CURSOR_SIZENS: + SDL_Log("Double arrow pointing north and south"); + break; + case SDL_SYSTEM_CURSOR_SIZEALL: + SDL_Log("Four pointed arrow pointing north, south, east, and west"); + break; + case SDL_SYSTEM_CURSOR_NO: + SDL_Log("Slashed circle or crossbones"); + break; + case SDL_SYSTEM_CURSOR_HAND: + SDL_Log("Hand"); + break; + default: + SDL_Log("UNKNOWN CURSOR TYPE, FIX THIS PROGRAM."); + break; } } else { @@ -192,7 +218,7 @@ loop() } } } - + for (i = 0; i < state->num_windows; ++i) { SDL_Renderer *renderer = state->renderers[i]; SDL_RenderClear(renderer); @@ -205,8 +231,7 @@ loop() #endif } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i; const char *color_cursor = NULL; diff --git a/test/testdisplayinfo.c b/test/testdisplayinfo.c index 89cdbfd62..9c1c1f520 100644 --- a/test/testdisplayinfo.c +++ b/test/testdisplayinfo.c @@ -29,8 +29,7 @@ print_mode(const char *prefix, const SDL_DisplayMode *mode) mode->w, mode->h, mode->refresh_rate); } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { SDL_DisplayMode mode; int num_displays, dpy; @@ -81,7 +80,7 @@ main(int argc, char *argv[]) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, " MODE %d: failed to query (%s)\n", m, SDL_GetError()); } else { char prefix[64]; - SDL_snprintf(prefix, sizeof (prefix), " MODE %d", m); + SDL_snprintf(prefix, sizeof(prefix), " MODE %d", m); print_mode(prefix, &mode); } } diff --git a/test/testdraw2.c b/test/testdraw2.c index e4be559c1..6713d5d00 100644 --- a/test/testdraw2.c +++ b/test/testdraw2.c @@ -37,8 +37,7 @@ static const Uint32 fps_check_delay = 5000; int done; -void -DrawPoints(SDL_Renderer * renderer) +void DrawPoints(SDL_Renderer *renderer) { int i; int x, y; @@ -71,8 +70,8 @@ DrawPoints(SDL_Renderer * renderer) cycle_direction = -cycle_direction; } } - SDL_SetRenderDrawColor(renderer, 255, (Uint8) current_color, - (Uint8) current_color, (Uint8) current_alpha); + SDL_SetRenderDrawColor(renderer, 255, (Uint8)current_color, + (Uint8)current_color, (Uint8)current_alpha); x = rand() % viewport.w; y = rand() % viewport.h; @@ -80,8 +79,7 @@ DrawPoints(SDL_Renderer * renderer) } } -void -DrawLines(SDL_Renderer * renderer) +void DrawLines(SDL_Renderer *renderer) { int i; int x1, y1, x2, y2; @@ -114,8 +112,8 @@ DrawLines(SDL_Renderer * renderer) cycle_direction = -cycle_direction; } } - SDL_SetRenderDrawColor(renderer, 255, (Uint8) current_color, - (Uint8) current_color, (Uint8) current_alpha); + SDL_SetRenderDrawColor(renderer, 255, (Uint8)current_color, + (Uint8)current_color, (Uint8)current_alpha); if (i == 0) { SDL_RenderDrawLine(renderer, 0, 0, viewport.w - 1, viewport.h - 1); @@ -123,17 +121,16 @@ DrawLines(SDL_Renderer * renderer) SDL_RenderDrawLine(renderer, 0, viewport.h / 2, viewport.w - 1, viewport.h / 2); SDL_RenderDrawLine(renderer, viewport.w / 2, 0, viewport.w / 2, viewport.h - 1); } else { - x1 = (rand() % (viewport.w*2)) - viewport.w; - x2 = (rand() % (viewport.w*2)) - viewport.w; - y1 = (rand() % (viewport.h*2)) - viewport.h; - y2 = (rand() % (viewport.h*2)) - viewport.h; + x1 = (rand() % (viewport.w * 2)) - viewport.w; + x2 = (rand() % (viewport.w * 2)) - viewport.w; + y1 = (rand() % (viewport.h * 2)) - viewport.h; + y2 = (rand() % (viewport.h * 2)) - viewport.h; SDL_RenderDrawLine(renderer, x1, y1, x2, y2); } } } -void -DrawRects(SDL_Renderer * renderer) +void DrawRects(SDL_Renderer *renderer) { int i; SDL_Rect rect; @@ -166,19 +163,18 @@ DrawRects(SDL_Renderer * renderer) cycle_direction = -cycle_direction; } } - SDL_SetRenderDrawColor(renderer, 255, (Uint8) current_color, - (Uint8) current_color, (Uint8) current_alpha); + SDL_SetRenderDrawColor(renderer, 255, (Uint8)current_color, + (Uint8)current_color, (Uint8)current_alpha); rect.w = rand() % (viewport.h / 2); rect.h = rand() % (viewport.h / 2); - rect.x = (rand() % (viewport.w*2) - viewport.w) - (rect.w / 2); - rect.y = (rand() % (viewport.h*2) - viewport.h) - (rect.h / 2); + rect.x = (rand() % (viewport.w * 2) - viewport.w) - (rect.w / 2); + rect.y = (rand() % (viewport.h * 2) - viewport.h) - (rect.h / 2); SDL_RenderFillRect(renderer, &rect); } } -void -loop() +void loop() { Uint32 now; int i; @@ -212,16 +208,14 @@ loop() if (SDL_TICKS_PASSED(now, next_fps_check)) { /* Print out some timing information */ const Uint32 then = next_fps_check - fps_check_delay; - const double fps = ((double) frames * 1000) / (now - then); + const double fps = ((double)frames * 1000) / (now - then); SDL_Log("%2.2f frames per second\n", fps); next_fps_check = now + fps_check_delay; frames = 0; } - } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i; @@ -270,12 +264,13 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - static const char *options[] = { - "[--blend none|blend|add|mod]", + static const char *options[] = { + "[--blend none|blend|add|mod]", "[--cyclecolor]", "[--cyclealpha]", "[num_objects]", - NULL }; + NULL + }; SDLTest_CommonLogUsage(state, argv[0], options); return 1; } @@ -308,7 +303,6 @@ main(int argc, char *argv[]) } #endif - SDLTest_CommonQuit(state); return 0; diff --git a/test/testdrawchessboard.c b/test/testdrawchessboard.c index 682b5b732..5b162da52 100644 --- a/test/testdrawchessboard.c +++ b/test/testdrawchessboard.c @@ -28,25 +28,22 @@ SDL_Renderer *renderer; SDL_Surface *surface; int done; -void -DrawChessBoard() +void DrawChessBoard() { - int row = 0,column = 0,x = 0; + int row = 0, column = 0, x = 0; SDL_Rect rect, darea; /* Get the Size of drawing surface */ SDL_RenderGetViewport(renderer, &darea); - for ( ; row < 8; row++) - { - column = row%2; + for (; row < 8; row++) { + column = row % 2; x = column; - for ( ; column < 4+(row%2); column++) - { + for (; column < 4 + (row % 2); column++) { SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0xFF); - rect.w = darea.w/8; - rect.h = darea.h/8; + rect.w = darea.w / 8; + rect.h = darea.h / 8; rect.x = x * rect.w; rect.y = row * rect.h; x = x + 2; @@ -55,25 +52,24 @@ DrawChessBoard() } } -void -loop() +void loop() { SDL_Event e; while (SDL_PollEvent(&e)) { - - /* Re-create when window has been resized */ - if ((e.type == SDL_WINDOWEVENT) && (e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)) { - SDL_DestroyRenderer(renderer); + /* Re-create when window has been resized */ + if ((e.type == SDL_WINDOWEVENT) && (e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)) { - surface = SDL_GetWindowSurface(window); - renderer = SDL_CreateSoftwareRenderer(surface); - /* Clear the rendering surface with the specified color */ - SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF); - SDL_RenderClear(renderer); - } + SDL_DestroyRenderer(renderer); - if (e.type == SDL_QUIT) { + surface = SDL_GetWindowSurface(window); + renderer = SDL_CreateSoftwareRenderer(surface); + /* Clear the rendering surface with the specified color */ + SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF); + SDL_RenderClear(renderer); + } + + if (e.type == SDL_QUIT) { done = 1; #ifdef __EMSCRIPTEN__ emscripten_cancel_main_loop(); @@ -97,8 +93,7 @@ loop() SDL_UpdateWindowSurface(window); } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { /* Enable standard application logging */ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); @@ -109,17 +104,16 @@ main(int argc, char *argv[]) return 1; } - /* Create window and renderer for given surface */ window = SDL_CreateWindow("Chess Board", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_RESIZABLE); if (window == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n",SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n", SDL_GetError()); return 1; } surface = SDL_GetWindowSurface(window); renderer = SDL_CreateSoftwareRenderer(surface); if (renderer == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Render creation for surface fail : %s\n",SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Render creation for surface fail : %s\n", SDL_GetError()); return 1; } @@ -127,7 +121,6 @@ main(int argc, char *argv[]) SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF); SDL_RenderClear(renderer); - /* Draw the Image on rendering surface */ done = 0; #ifdef __EMSCRIPTEN__ diff --git a/test/testdropfile.c b/test/testdropfile.c index a2ce5f9a7..78389da5f 100644 --- a/test/testdropfile.c +++ b/test/testdropfile.c @@ -25,8 +25,7 @@ quit(int rc) exit(rc); } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i, done; SDL_Event event; @@ -76,13 +75,13 @@ main(int argc, char *argv[]) /* Check for events */ while (SDL_PollEvent(&event)) { if (event.type == SDL_DROPBEGIN) { - SDL_Log("Drop beginning on window %u", (unsigned int) event.drop.windowID); + SDL_Log("Drop beginning on window %u", (unsigned int)event.drop.windowID); } else if (event.type == SDL_DROPCOMPLETE) { - SDL_Log("Drop complete on window %u", (unsigned int) event.drop.windowID); + SDL_Log("Drop complete on window %u", (unsigned int)event.drop.windowID); } else if ((event.type == SDL_DROPFILE) || (event.type == SDL_DROPTEXT)) { const char *typestr = (event.type == SDL_DROPFILE) ? "File" : "Text"; char *dropped_filedir = event.drop.file; - SDL_Log("%s dropped on window %u: %s", typestr, (unsigned int) event.drop.windowID, dropped_filedir); + SDL_Log("%s dropped on window %u: %s", typestr, (unsigned int)event.drop.windowID, dropped_filedir); /* Normally you'd have to do this, but this is freed in SDLTest_CommonEvent() */ /*SDL_free(dropped_filedir);*/ } diff --git a/test/testerror.c b/test/testerror.c index 8992ad591..4484b5538 100644 --- a/test/testerror.c +++ b/test/testerror.c @@ -32,17 +32,16 @@ ThreadFunc(void *data) { /* Set the child thread error string */ SDL_SetError("Thread %s (%lu) had a problem: %s", - (char *) data, SDL_ThreadID(), "nevermind"); + (char *)data, SDL_ThreadID(), "nevermind"); while (alive) { - SDL_Log("Thread '%s' is alive!\n", (char *) data); + SDL_Log("Thread '%s' is alive!\n", (char *)data); SDL_Delay(1 * 1000); } SDL_Log("Child thread error string: %s\n", SDL_GetError()); return 0; } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { SDL_Thread *thread; diff --git a/test/testevdev.c b/test/testevdev.c index b762f23f0..cadd32264 100644 --- a/test/testevdev.c +++ b/test/testevdev.c @@ -31,10 +31,11 @@ static const struct { int code; const char *name; -} device_classes[] = -{ -#define CLS(x) \ - { SDL_UDEV_DEVICE_ ## x, #x } +} device_classes[] = { +#define CLS(x) \ + { \ + SDL_UDEV_DEVICE_##x, #x \ + } CLS(MOUSE), CLS(KEYBOARD), CLS(JOYSTICK), @@ -48,18 +49,18 @@ static const struct typedef struct { - const char *name; - uint16_t bus_type; - uint16_t vendor_id; - uint16_t product_id; - uint16_t version; - uint8_t ev[(EV_MAX + 1) / 8]; - uint8_t keys[(KEY_MAX + 1) / 8]; - uint8_t abs[(ABS_MAX + 1) / 8]; - uint8_t rel[(REL_MAX + 1) / 8]; - uint8_t ff[(FF_MAX + 1) / 8]; - uint8_t props[INPUT_PROP_MAX / 8]; - int expected; + const char *name; + uint16_t bus_type; + uint16_t vendor_id; + uint16_t product_id; + uint16_t version; + uint8_t ev[(EV_MAX + 1) / 8]; + uint8_t keys[(KEY_MAX + 1) / 8]; + uint8_t abs[(ABS_MAX + 1) / 8]; + uint8_t rel[(REL_MAX + 1) / 8]; + uint8_t ff[(FF_MAX + 1) / 8]; + uint8_t props[INPUT_PROP_MAX / 8]; + int expected; } GuessTest; /* @@ -73,10 +74,11 @@ typedef struct */ #define ZEROx4 0, 0, 0, 0 #define ZEROx8 ZEROx4, ZEROx4 -#define FFx4 0xff, 0xff, 0xff, 0xff -#define FFx8 FFx4, FFx4 +#define FFx4 0xff, 0xff, 0xff, 0xff +#define FFx8 FFx4, FFx4 /* Test-cases derived from real devices or from Linux kernel source */ +/* *INDENT-OFF* */ /* clang-format off */ static const GuessTest guess_tests[] = { { @@ -934,6 +936,7 @@ static const GuessTest guess_tests[] = .expected = SDL_UDEV_DEVICE_UNKNOWN, } }; +/* *INDENT-ON* */ /* clang-format on */ /* The Linux kernel provides capability info in EVIOCGBIT and in /sys * as an array of unsigned long in native byte order, rather than an array @@ -950,7 +953,7 @@ static const GuessTest guess_tests[] = * an appropriate byteswapping function for the architecture's word size. */ SDL_COMPILE_TIME_ASSERT(sizeof_long, sizeof(unsigned long) == 4 || sizeof(unsigned long) == 8); #define SwapLongLE(X) \ - ((sizeof(unsigned long) == 4) ? SDL_SwapLE32(X) : SDL_SwapLE64(X)) + ((sizeof(unsigned long) == 4) ? SDL_SwapLE32(X) : SDL_SwapLE64(X)) static int run_test(void) @@ -962,7 +965,8 @@ run_test(void) const GuessTest *t = &guess_tests[i]; size_t j; int actual; - struct { + struct + { unsigned long ev[NBITS(EV_MAX)]; unsigned long abs[NBITS(ABS_MAX)]; unsigned long keys[NBITS(KEY_MAX)]; @@ -1033,8 +1037,7 @@ run_test(void) #endif -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { return run_test() ? 0 : 1; } diff --git a/test/testfile.c b/test/testfile.c index 752cddb6f..225ed7d5c 100644 --- a/test/testfile.c +++ b/test/testfile.c @@ -32,8 +32,8 @@ #define FBASENAME1 "../Documents/sdldata1" /* this file will be created during tests */ #define FBASENAME2 "../Documents/sdldata2" /* this file should not exist before starting test */ #else -#define FBASENAME1 "sdldata1" /* this file will be created during tests */ -#define FBASENAME2 "sdldata2" /* this file should not exist before starting test */ +#define FBASENAME1 "sdldata1" /* this file will be created during tests */ +#define FBASENAME2 "sdldata2" /* this file should not exist before starting test */ #endif #ifndef NULL @@ -48,22 +48,19 @@ cleanup(void) } static void -rwops_error_quit(unsigned line, SDL_RWops * rwops) +rwops_error_quit(unsigned line, SDL_RWops *rwops) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "testfile.c(%d): failed\n", line); if (rwops) { - rwops->close(rwops); /* This calls SDL_FreeRW(rwops); */ + rwops->close(rwops); /* This calls SDL_FreeRW(rwops); */ } cleanup(); - exit(1); /* quit with rwops error (test failed) */ + exit(1); /* quit with rwops error (test failed) */ } -#define RWOP_ERR_QUIT(x) rwops_error_quit( __LINE__, (x) ) +#define RWOP_ERR_QUIT(x) rwops_error_quit(__LINE__, (x)) - - -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { SDL_RWops *rwops = NULL; char test_buf[30]; @@ -73,7 +70,7 @@ main(int argc, char *argv[]) cleanup(); -/* test 1 : basic argument test: all those calls to SDL_RWFromFile should fail */ + /* test 1 : basic argument test: all those calls to SDL_RWFromFile should fail */ rwops = SDL_RWFromFile(NULL, NULL); if (rwops) { @@ -97,16 +94,16 @@ main(int argc, char *argv[]) } SDL_Log("test1 OK\n"); -/* test 2 : check that inexistent file is not successfully opened/created when required */ -/* modes : r, r+ imply that file MUST exist - modes : a, a+, w, w+ checks that it succeeds (file may not exists) + /* test 2 : check that inexistent file is not successfully opened/created when required */ + /* modes : r, r+ imply that file MUST exist + modes : a, a+, w, w+ checks that it succeeds (file may not exists) - */ - rwops = SDL_RWFromFile(FBASENAME2, "rb"); /* this file doesn't exist that call must fail */ + */ + rwops = SDL_RWFromFile(FBASENAME2, "rb"); /* this file doesn't exist that call must fail */ if (rwops) { RWOP_ERR_QUIT(rwops); } - rwops = SDL_RWFromFile(FBASENAME2, "rb+"); /* this file doesn't exist that call must fail */ + rwops = SDL_RWFromFile(FBASENAME2, "rb+"); /* this file doesn't exist that call must fail */ if (rwops) { RWOP_ERR_QUIT(rwops); } @@ -136,10 +133,10 @@ main(int argc, char *argv[]) unlink(FBASENAME2); SDL_Log("test2 OK\n"); -/* test 3 : creation, writing , reading, seeking, - test : w mode, r mode, w+ mode - */ - rwops = SDL_RWFromFile(FBASENAME1, "wb"); /* write only */ + /* test 3 : creation, writing , reading, seeking, + test : w mode, r mode, w+ mode + */ + rwops = SDL_RWFromFile(FBASENAME1, "wb"); /* write only */ if (rwops == NULL) { RWOP_ERR_QUIT(rwops); } @@ -157,11 +154,11 @@ main(int argc, char *argv[]) } if (0 != rwops->read(rwops, test_buf, 1, 1)) { RWOP_ERR_QUIT(rwops); /* we are in write only mode */ - } + } rwops->close(rwops); - rwops = SDL_RWFromFile(FBASENAME1, "rb"); /* read mode, file must exists */ + rwops = SDL_RWFromFile(FBASENAME1, "rb"); /* read mode, file must exists */ if (rwops == NULL) { RWOP_ERR_QUIT(rwops); } @@ -198,8 +195,8 @@ main(int argc, char *argv[]) rwops->close(rwops); -/* test 3: same with w+ mode */ - rwops = SDL_RWFromFile(FBASENAME1, "wb+"); /* write + read + truncation */ + /* test 3: same with w+ mode */ + rwops = SDL_RWFromFile(FBASENAME1, "wb+"); /* write + read + truncation */ if (rwops == NULL) { RWOP_ERR_QUIT(rwops); } @@ -249,8 +246,8 @@ main(int argc, char *argv[]) rwops->close(rwops); SDL_Log("test3 OK\n"); -/* test 4: same in r+ mode */ - rwops = SDL_RWFromFile(FBASENAME1, "rb+"); /* write + read + file must exists, no truncation */ + /* test 4: same in r+ mode */ + rwops = SDL_RWFromFile(FBASENAME1, "rb+"); /* write + read + file must exists, no truncation */ if (rwops == NULL) { RWOP_ERR_QUIT(rwops); } @@ -300,8 +297,8 @@ main(int argc, char *argv[]) rwops->close(rwops); SDL_Log("test4 OK\n"); -/* test5 : append mode */ - rwops = SDL_RWFromFile(FBASENAME1, "ab+"); /* write + read + append */ + /* test5 : append mode */ + rwops = SDL_RWFromFile(FBASENAME1, "ab+"); /* write + read + append */ if (rwops == NULL) { RWOP_ERR_QUIT(rwops); } @@ -357,5 +354,5 @@ main(int argc, char *argv[]) rwops->close(rwops); SDL_Log("test5 OK\n"); cleanup(); - return 0; /* all ok */ + return 0; /* all ok */ } diff --git a/test/testfilesystem.c b/test/testfilesystem.c index 2f1e494b3..401c873bf 100644 --- a/test/testfilesystem.c +++ b/test/testfilesystem.c @@ -14,8 +14,7 @@ #include #include "SDL.h" -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { char *base_path; char *pref_path; @@ -30,8 +29,8 @@ main(int argc, char *argv[]) base_path = SDL_GetBasePath(); if (base_path == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find base path: %s\n", - SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find base path: %s\n", + SDL_GetError()); } else { SDL_Log("base path: '%s'\n", base_path); SDL_free(base_path); @@ -39,8 +38,8 @@ main(int argc, char *argv[]) pref_path = SDL_GetPrefPath("libsdl", "test_filesystem"); if (pref_path == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path: %s\n", - SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path: %s\n", + SDL_GetError()); } else { SDL_Log("pref path: '%s'\n", pref_path); SDL_free(pref_path); @@ -48,8 +47,8 @@ main(int argc, char *argv[]) pref_path = SDL_GetPrefPath(NULL, "test_filesystem"); if (pref_path == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path without organization: %s\n", - SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path without organization: %s\n", + SDL_GetError()); } else { SDL_Log("pref path: '%s'\n", pref_path); SDL_free(pref_path); diff --git a/test/testgamecontroller.c b/test/testgamecontroller.c index 56245ad13..a2f0d0e5a 100644 --- a/test/testgamecontroller.c +++ b/test/testgamecontroller.c @@ -31,46 +31,57 @@ #define BUTTON_SIZE 50 #define AXIS_SIZE 50 +#define BUTTON_SIZE 50 +#define AXIS_SIZE 50 /* This is indexed by SDL_GameControllerButton. */ -static const struct { int x; int y; } button_positions[] = { - {387, 167}, /* SDL_CONTROLLER_BUTTON_A */ - {431, 132}, /* SDL_CONTROLLER_BUTTON_B */ - {342, 132}, /* SDL_CONTROLLER_BUTTON_X */ - {389, 101}, /* SDL_CONTROLLER_BUTTON_Y */ - {174, 132}, /* SDL_CONTROLLER_BUTTON_BACK */ - {232, 128}, /* SDL_CONTROLLER_BUTTON_GUIDE */ - {289, 132}, /* SDL_CONTROLLER_BUTTON_START */ - {75, 154}, /* SDL_CONTROLLER_BUTTON_LEFTSTICK */ - {305, 230}, /* SDL_CONTROLLER_BUTTON_RIGHTSTICK */ - {77, 40}, /* SDL_CONTROLLER_BUTTON_LEFTSHOULDER */ - {396, 36}, /* SDL_CONTROLLER_BUTTON_RIGHTSHOULDER */ - {154, 188}, /* SDL_CONTROLLER_BUTTON_DPAD_UP */ - {154, 249}, /* SDL_CONTROLLER_BUTTON_DPAD_DOWN */ - {116, 217}, /* SDL_CONTROLLER_BUTTON_DPAD_LEFT */ - {186, 217}, /* SDL_CONTROLLER_BUTTON_DPAD_RIGHT */ - {232, 174}, /* SDL_CONTROLLER_BUTTON_MISC1 */ - {132, 135}, /* SDL_CONTROLLER_BUTTON_PADDLE1 */ - {330, 135}, /* SDL_CONTROLLER_BUTTON_PADDLE2 */ - {132, 175}, /* SDL_CONTROLLER_BUTTON_PADDLE3 */ - {330, 175}, /* SDL_CONTROLLER_BUTTON_PADDLE4 */ - {0, 0}, /* SDL_CONTROLLER_BUTTON_TOUCHPAD */ +static const struct +{ + int x; + int y; +} button_positions[] = { + { 387, 167 }, /* SDL_CONTROLLER_BUTTON_A */ + { 431, 132 }, /* SDL_CONTROLLER_BUTTON_B */ + { 342, 132 }, /* SDL_CONTROLLER_BUTTON_X */ + { 389, 101 }, /* SDL_CONTROLLER_BUTTON_Y */ + { 174, 132 }, /* SDL_CONTROLLER_BUTTON_BACK */ + { 232, 128 }, /* SDL_CONTROLLER_BUTTON_GUIDE */ + { 289, 132 }, /* SDL_CONTROLLER_BUTTON_START */ + { 75, 154 }, /* SDL_CONTROLLER_BUTTON_LEFTSTICK */ + { 305, 230 }, /* SDL_CONTROLLER_BUTTON_RIGHTSTICK */ + { 77, 40 }, /* SDL_CONTROLLER_BUTTON_LEFTSHOULDER */ + { 396, 36 }, /* SDL_CONTROLLER_BUTTON_RIGHTSHOULDER */ + { 154, 188 }, /* SDL_CONTROLLER_BUTTON_DPAD_UP */ + { 154, 249 }, /* SDL_CONTROLLER_BUTTON_DPAD_DOWN */ + { 116, 217 }, /* SDL_CONTROLLER_BUTTON_DPAD_LEFT */ + { 186, 217 }, /* SDL_CONTROLLER_BUTTON_DPAD_RIGHT */ + { 232, 174 }, /* SDL_CONTROLLER_BUTTON_MISC1 */ + { 132, 135 }, /* SDL_CONTROLLER_BUTTON_PADDLE1 */ + { 330, 135 }, /* SDL_CONTROLLER_BUTTON_PADDLE2 */ + { 132, 175 }, /* SDL_CONTROLLER_BUTTON_PADDLE3 */ + { 330, 175 }, /* SDL_CONTROLLER_BUTTON_PADDLE4 */ + { 0, 0 }, /* SDL_CONTROLLER_BUTTON_TOUCHPAD */ }; SDL_COMPILE_TIME_ASSERT(button_positions, SDL_arraysize(button_positions) == SDL_CONTROLLER_BUTTON_MAX); /* This is indexed by SDL_GameControllerAxis. */ -static const struct { int x; int y; double angle; } axis_positions[] = { - {74, 153, 270.0}, /* LEFTX */ - {74, 153, 0.0}, /* LEFTY */ - {306, 231, 270.0}, /* RIGHTX */ - {306, 231, 0.0}, /* RIGHTY */ - {91, -20, 0.0}, /* TRIGGERLEFT */ - {375, -20, 0.0}, /* TRIGGERRIGHT */ +static const struct +{ + int x; + int y; + double angle; +} axis_positions[] = { + { 74, 153, 270.0 }, /* LEFTX */ + { 74, 153, 0.0 }, /* LEFTY */ + { 306, 231, 270.0 }, /* RIGHTX */ + { 306, 231, 0.0 }, /* RIGHTY */ + { 91, -20, 0.0 }, /* TRIGGERLEFT */ + { 375, -20, 0.0 }, /* TRIGGERRIGHT */ }; SDL_COMPILE_TIME_ASSERT(axis_positions, SDL_arraysize(axis_positions) == SDL_CONTROLLER_AXIS_MAX); /* This is indexed by SDL_JoystickPowerLevel + 1. */ -static const char* power_level_strings[] = { +static const char *power_level_strings[] = { "unknown", /* SDL_JOYSTICK_POWER_UNKNOWN */ "empty", /* SDL_JOYSTICK_POWER_EMPTY */ "low", /* SDL_JOYSTICK_POWER_LOW */ @@ -267,7 +278,7 @@ static void DelController(SDL_JoystickID controller) --num_controllers; if (i < num_controllers) { - SDL_memcpy(&gamecontrollers[i], &gamecontrollers[i+1], (num_controllers - i) * sizeof(*gamecontrollers)); + SDL_memcpy(&gamecontrollers[i], &gamecontrollers[i + 1], (num_controllers - i) * sizeof(*gamecontrollers)); } if (num_controllers > 0) { @@ -294,35 +305,34 @@ static Uint16 ConvertAxisToRumble(Sint16 axisval) */ typedef struct { - Uint8 ucEnableBits1; /* 0 */ - Uint8 ucEnableBits2; /* 1 */ - Uint8 ucRumbleRight; /* 2 */ - Uint8 ucRumbleLeft; /* 3 */ - Uint8 ucHeadphoneVolume; /* 4 */ - Uint8 ucSpeakerVolume; /* 5 */ - Uint8 ucMicrophoneVolume; /* 6 */ - Uint8 ucAudioEnableBits; /* 7 */ - Uint8 ucMicLightMode; /* 8 */ - Uint8 ucAudioMuteBits; /* 9 */ - Uint8 rgucRightTriggerEffect[11]; /* 10 */ - Uint8 rgucLeftTriggerEffect[11]; /* 21 */ - Uint8 rgucUnknown1[6]; /* 32 */ - Uint8 ucLedFlags; /* 38 */ - Uint8 rgucUnknown2[2]; /* 39 */ - Uint8 ucLedAnim; /* 41 */ - Uint8 ucLedBrightness; /* 42 */ - Uint8 ucPadLights; /* 43 */ - Uint8 ucLedRed; /* 44 */ - Uint8 ucLedGreen; /* 45 */ - Uint8 ucLedBlue; /* 46 */ + Uint8 ucEnableBits1; /* 0 */ + Uint8 ucEnableBits2; /* 1 */ + Uint8 ucRumbleRight; /* 2 */ + Uint8 ucRumbleLeft; /* 3 */ + Uint8 ucHeadphoneVolume; /* 4 */ + Uint8 ucSpeakerVolume; /* 5 */ + Uint8 ucMicrophoneVolume; /* 6 */ + Uint8 ucAudioEnableBits; /* 7 */ + Uint8 ucMicLightMode; /* 8 */ + Uint8 ucAudioMuteBits; /* 9 */ + Uint8 rgucRightTriggerEffect[11]; /* 10 */ + Uint8 rgucLeftTriggerEffect[11]; /* 21 */ + Uint8 rgucUnknown1[6]; /* 32 */ + Uint8 ucLedFlags; /* 38 */ + Uint8 rgucUnknown2[2]; /* 39 */ + Uint8 ucLedAnim; /* 41 */ + Uint8 ucLedBrightness; /* 42 */ + Uint8 ucPadLights; /* 43 */ + Uint8 ucLedRed; /* 44 */ + Uint8 ucLedGreen; /* 45 */ + Uint8 ucLedBlue; /* 46 */ } DS5EffectsState_t; static void CyclePS5TriggerEffect() { DS5EffectsState_t state; - Uint8 effects[3][11] = - { + Uint8 effects[3][11] = { /* Clear trigger effect */ { 0x05, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Constant resistance across entire trigger pull */ @@ -413,7 +423,7 @@ static void CloseVirtualController() { int i; - for (i = SDL_NumJoysticks(); i--; ) { + for (i = SDL_NumJoysticks(); i--;) { if (SDL_JoystickIsVirtual(i)) { SDL_JoystickDetachVirtual(i); } @@ -508,7 +518,7 @@ static void VirtualControllerMouseMotion(int x, int y) valueY = (Sint16)(distanceY * -SDL_JOYSTICK_AXIS_MIN); } SDL_JoystickSetVirtualAxis(virtual_joystick, virtual_axis_active, valueX); - SDL_JoystickSetVirtualAxis(virtual_joystick, virtual_axis_active+1, valueY); + SDL_JoystickSetVirtualAxis(virtual_joystick, virtual_axis_active + 1, valueY); } } } @@ -545,14 +555,13 @@ static void VirtualControllerMouseUp(int x, int y) SDL_JoystickSetVirtualAxis(virtual_joystick, virtual_axis_active, SDL_JOYSTICK_AXIS_MIN); } else { SDL_JoystickSetVirtualAxis(virtual_joystick, virtual_axis_active, 0); - SDL_JoystickSetVirtualAxis(virtual_joystick, virtual_axis_active+1, 0); + SDL_JoystickSetVirtualAxis(virtual_joystick, virtual_axis_active + 1, 0); } virtual_axis_active = SDL_CONTROLLER_AXIS_INVALID; } } -void -loop(void *arg) +void loop(void *arg) { SDL_Event event; int i; @@ -565,12 +574,12 @@ loop(void *arg) while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) == 1) { switch (event.type) { case SDL_CONTROLLERDEVICEADDED: - SDL_Log("Game controller device %d added.\n", (int) SDL_JoystickGetDeviceInstanceID(event.cdevice.which)); + SDL_Log("Game controller device %d added.\n", (int)SDL_JoystickGetDeviceInstanceID(event.cdevice.which)); AddController(event.cdevice.which, SDL_TRUE); break; case SDL_CONTROLLERDEVICEREMOVED: - SDL_Log("Game controller device %d removed.\n", (int) event.cdevice.which); + SDL_Log("Game controller device %d removed.\n", (int)event.cdevice.which); DelController(event.cdevice.which); break; @@ -592,7 +601,7 @@ loop(void *arg) case SDL_CONTROLLERSENSORUPDATE: SDL_Log("Controller %" SDL_PRIs32 " sensor %s: %.2f, %.2f, %.2f (%" SDL_PRIu64 ")\n", event.csensor.which, - GetSensorName((SDL_SensorType) event.csensor.sensor), + GetSensorName((SDL_SensorType)event.csensor.sensor), event.csensor.data[0], event.csensor.data[1], event.csensor.data[2], @@ -606,7 +615,7 @@ loop(void *arg) if (event.caxis.value <= (-SDL_JOYSTICK_AXIS_MAX / 2) || event.caxis.value >= (SDL_JOYSTICK_AXIS_MAX / 2)) { SetController(event.caxis.which); } - SDL_Log("Controller %" SDL_PRIs32 " axis %s changed to %d\n", event.caxis.which, SDL_GameControllerGetStringForAxis((SDL_GameControllerAxis) event.caxis.axis), event.caxis.value); + SDL_Log("Controller %" SDL_PRIs32 " axis %s changed to %d\n", event.caxis.which, SDL_GameControllerGetStringForAxis((SDL_GameControllerAxis)event.caxis.axis), event.caxis.value); break; #endif /* VERBOSE_AXES */ @@ -615,7 +624,7 @@ loop(void *arg) if (event.type == SDL_CONTROLLERBUTTONDOWN) { SetController(event.cbutton.which); } - SDL_Log("Controller %" SDL_PRIs32 " button %s %s\n", event.cbutton.which, SDL_GameControllerGetStringForButton((SDL_GameControllerButton) event.cbutton.button), event.cbutton.state ? "pressed" : "released"); + SDL_Log("Controller %" SDL_PRIs32 " button %s %s\n", event.cbutton.which, SDL_GameControllerGetStringForButton((SDL_GameControllerButton)event.cbutton.button), event.cbutton.state ? "pressed" : "released"); /* Cycle PS5 trigger effects when the microphone button is pressed */ if (event.type == SDL_CONTROLLERBUTTONDOWN && @@ -701,7 +710,7 @@ loop(void *arg) if (showing_front) { for (i = 0; i < SDL_CONTROLLER_AXIS_MAX; ++i) { - const Sint16 deadzone = 8000; /* !!! FIXME: real deadzone */ + const Sint16 deadzone = 8000; /* !!! FIXME: real deadzone */ const Sint16 value = SDL_GameControllerGetAxis(gamecontroller, (SDL_GameControllerAxis)(i)); if (value < -deadzone) { const double angle = axis_positions[i].angle; @@ -739,10 +748,10 @@ loop(void *arg) b = 0; } else { r = 0; - b = (Uint8)(((int)(x) * 255) / 32767); + b = (Uint8)(((int)(x)*255) / 32767); } if (y > 0) { - g = (Uint8)(((int)(y) * 255) / 32767); + g = (Uint8)(((int)(y)*255) / 32767); } else { g = 0; } @@ -782,8 +791,7 @@ loop(void *arg) #endif } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i; int controller_count = 0; @@ -802,7 +810,7 @@ main(int argc, char *argv[]) SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); /* Initialize SDL (Note: video is required to start event loop) */ - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER ) < 0) { + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) < 0) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return 1; } @@ -829,7 +837,7 @@ main(int argc, char *argv[]) const char *description; SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(i), - guid, sizeof (guid)); + guid, sizeof(guid)); if (SDL_IsGameController(i)) { controller_count++; @@ -879,8 +887,8 @@ main(int argc, char *argv[]) description = "Joystick"; } SDL_Log("%s %d: %s%s%s (guid %s, VID 0x%.4x, PID 0x%.4x, player index = %d)\n", - description, i, name ? name : "Unknown", path ? ", " : "", path ? path : "", guid, - SDL_JoystickGetDeviceVendor(i), SDL_JoystickGetDeviceProduct(i), SDL_JoystickGetDevicePlayerIndex(i)); + description, i, name ? name : "Unknown", path ? ", " : "", path ? path : "", guid, + SDL_JoystickGetDeviceVendor(i), SDL_JoystickGetDeviceProduct(i), SDL_JoystickGetDevicePlayerIndex(i)); } SDL_Log("There are %d game controller(s) attached (%d joystick(s))\n", controller_count, SDL_NumJoysticks()); diff --git a/test/testgeometry.c b/test/testgeometry.c index 39e450a16..fad5280cb 100644 --- a/test/testgeometry.c +++ b/test/testgeometry.c @@ -41,8 +41,7 @@ quit(int rc) exit(rc); } -int -LoadSprite(const char *file) +int LoadSprite(const char *file) { int i; @@ -63,9 +62,7 @@ LoadSprite(const char *file) return 0; } - -void -loop() +void loop() { int i; SDL_Event event; @@ -164,8 +161,7 @@ loop() #endif } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i; const char *icon = "icon.bmp"; @@ -219,7 +215,7 @@ main(int argc, char *argv[]) /* Create the windows, initialize the renderers, and load the textures */ sprites = - (SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites)); + (SDL_Texture **)SDL_malloc(state->num_windows * sizeof(*sprites)); if (sprites == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); @@ -238,7 +234,6 @@ main(int argc, char *argv[]) } } - srand((unsigned int)time(NULL)); /* Main render loop */ @@ -252,16 +247,16 @@ main(int argc, char *argv[]) while (!done) { ++frames; loop(); - } + } #endif /* Print out some timing information */ now = SDL_GetTicks(); if (now > then) { - double fps = ((double) frames * 1000) / (now - then); + double fps = ((double)frames * 1000) / (now - then); SDL_Log("%2.2f frames per second\n", fps); } - + quit(0); return 0; diff --git a/test/testgesture.c b/test/testgesture.c index 9a2d7bf6b..bf0359620 100644 --- a/test/testgesture.c +++ b/test/testgesture.c @@ -26,9 +26,9 @@ #include "SDL_test.h" #include "SDL_test_common.h" -#define WIDTH 640 +#define WIDTH 640 #define HEIGHT 480 -#define BPP 4 +#define BPP 4 /* MUST BE A POWER OF 2! */ #define EVENT_BUF_SIZE 256 @@ -38,7 +38,7 @@ static SDLTest_CommonState *state; static SDL_Event events[EVENT_BUF_SIZE]; static int eventWrite; -static int colors[7] = {0xFF,0xFF00,0xFF0000,0xFFFF00,0x00FFFF,0xFF00FF,0xFFFFFF}; +static int colors[7] = { 0xFF, 0xFF00, 0xFF0000, 0xFFFF00, 0x00FFFF, 0xFF00FF, 0xFFFFFF }; static int quitting = 0; typedef struct @@ -54,7 +54,6 @@ typedef struct static Knob knob = { 0.0f, 0.1f, { 0.0f, 0.0f } }; - static void setpix(SDL_Surface *screen, float _x, float _y, unsigned int col) { @@ -65,26 +64,26 @@ setpix(SDL_Surface *screen, float _x, float _y, unsigned int col) const int y = (int)_y; float a; - if ( (x < 0) || (x >= screen->w) || (y < 0) || (y >= screen->h) ) { + if ((x < 0) || (x >= screen->w) || (y < 0) || (y >= screen->h)) { return; } - pixmem32 = (Uint32 *) screen->pixels + y * screen->pitch / BPP + x; + pixmem32 = (Uint32 *)screen->pixels + y * screen->pitch / BPP + x; SDL_memcpy(&colour, pixmem32, screen->format->BytesPerPixel); - SDL_GetRGB(colour,screen->format,&r,&g,&b); + SDL_GetRGB(colour, screen->format, &r, &g, &b); /* r = 0;g = 0; b = 0; */ - a = (float) ((col >> 24) & 0xFF); + a = (float)((col >> 24) & 0xFF); if (a == 0) { a = 0xFF; /* Hack, to make things easier. */ } a = (a == 0.0f) ? 1 : (a / 255.0f); - r = (Uint8) (r * (1 - a) + ((col >> 16) & 0xFF) * a); - g = (Uint8) (g * (1 - a) + ((col >> 8) & 0xFF) * a); - b = (Uint8) (b * (1 - a) + ((col >> 0) & 0xFF) * a); + r = (Uint8)(r * (1 - a) + ((col >> 16) & 0xFF) * a); + g = (Uint8)(g * (1 - a) + ((col >> 8) & 0xFF) * a); + b = (Uint8)(b * (1 - a) + ((col >> 0) & 0xFF) * a); colour = SDL_MapRGB(screen->format, r, g, b); *pixmem32 = colour; @@ -104,9 +103,9 @@ drawLine(SDL_Surface *screen, float x0, float y0, float x1, float y1, unsigned i static void drawCircle(SDL_Surface *screen, float x, float y, float r, unsigned int c) { - float tx,ty, xr; - for (ty = (float) -SDL_fabs(r); ty <= (float) SDL_fabs((int) r); ty++) { - xr = (float) SDL_sqrt(r * r - ty * ty); + float tx, ty, xr; + for (ty = (float)-SDL_fabs(r); ty <= (float)SDL_fabs((int)r); ty++) { + xr = (float)SDL_sqrt(r * r - ty * ty); if (r > 0) { /* r > 0 ==> filled circle */ for (tx = -xr + 0.5f; tx <= xr - 0.5f; tx++) { setpix(screen, x + tx, y + ty, c); @@ -145,15 +144,15 @@ DrawScreen(SDL_Window *window) float x, y; unsigned int c, col; - if ( (event->type == SDL_FINGERMOTION) || - (event->type == SDL_FINGERDOWN) || - (event->type == SDL_FINGERUP) ) { + if ((event->type == SDL_FINGERMOTION) || + (event->type == SDL_FINGERDOWN) || + (event->type == SDL_FINGERUP)) { x = event->tfinger.x; y = event->tfinger.y; /* draw the touch: */ c = colors[event->tfinger.fingerId % 7]; - col = ((unsigned int) (c * (0.1f + 0.85f))) | (unsigned int) (0xFF * age) << 24; + col = ((unsigned int)(c * (0.1f + 0.85f))) | (unsigned int)(0xFF * age) << 24; if (event->type == SDL_FINGERMOTION) { drawCircle(screen, x * screen->w, y * screen->h, 5, col); @@ -181,78 +180,79 @@ loop(void) SDLTest_CommonEvent(state, &event, &quitting); /* Record _all_ events */ - events[eventWrite & (EVENT_BUF_SIZE-1)] = event; + events[eventWrite & (EVENT_BUF_SIZE - 1)] = event; eventWrite++; switch (event.type) { - case SDL_KEYDOWN: - switch (event.key.keysym.sym) { - case SDLK_i: { - for (i = 0; i < SDL_GetNumTouchDevices(); ++i) { - const SDL_TouchID id = SDL_GetTouchDevice(i); - const char *name = SDL_GetTouchName(i); - SDL_Log("Fingers Down on device %"SDL_PRIs64" (%s): %d", id, name, SDL_GetNumTouchFingers(id)); - } - break; - } - - case SDLK_SPACE: - SDL_RecordGesture(-1); - break; - - case SDLK_s: - stream = SDL_RWFromFile("gestureSave", "w"); - SDL_Log("Wrote %i templates", SDL_SaveAllDollarTemplates(stream)); - SDL_RWclose(stream); - break; - - case SDLK_l: - stream = SDL_RWFromFile("gestureSave", "r"); - SDL_Log("Loaded: %i", SDL_LoadDollarTemplates(-1, stream)); - SDL_RWclose(stream); - break; + case SDL_KEYDOWN: + switch (event.key.keysym.sym) { + case SDLK_i: + { + for (i = 0; i < SDL_GetNumTouchDevices(); ++i) { + const SDL_TouchID id = SDL_GetTouchDevice(i); + const char *name = SDL_GetTouchName(i); + SDL_Log("Fingers Down on device %" SDL_PRIs64 " (%s): %d", id, name, SDL_GetNumTouchFingers(id)); } break; + } + + case SDLK_SPACE: + SDL_RecordGesture(-1); + break; + + case SDLK_s: + stream = SDL_RWFromFile("gestureSave", "w"); + SDL_Log("Wrote %i templates", SDL_SaveAllDollarTemplates(stream)); + SDL_RWclose(stream); + break; + + case SDLK_l: + stream = SDL_RWFromFile("gestureSave", "r"); + SDL_Log("Loaded: %i", SDL_LoadDollarTemplates(-1, stream)); + SDL_RWclose(stream); + break; + } + break; #if VERBOSE - case SDL_FINGERMOTION: - SDL_Log("Finger: %"SDL_PRIs64", x: %f, y: %f",event.tfinger.fingerId, - event.tfinger.x,event.tfinger.y); - break; + case SDL_FINGERMOTION: + SDL_Log("Finger: %" SDL_PRIs64 ", x: %f, y: %f", event.tfinger.fingerId, + event.tfinger.x, event.tfinger.y); + break; - case SDL_FINGERDOWN: - SDL_Log("Finger: %"SDL_PRIs64" down - x: %f, y: %f", - event.tfinger.fingerId,event.tfinger.x,event.tfinger.y); - break; + case SDL_FINGERDOWN: + SDL_Log("Finger: %" SDL_PRIs64 " down - x: %f, y: %f", + event.tfinger.fingerId, event.tfinger.x, event.tfinger.y); + break; - case SDL_FINGERUP: - SDL_Log("Finger: %"SDL_PRIs64" up - x: %f, y: %f", - event.tfinger.fingerId,event.tfinger.x,event.tfinger.y); - break; + case SDL_FINGERUP: + SDL_Log("Finger: %" SDL_PRIs64 " up - x: %f, y: %f", + event.tfinger.fingerId, event.tfinger.x, event.tfinger.y); + break; #endif - case SDL_MULTIGESTURE: + case SDL_MULTIGESTURE: #if VERBOSE - SDL_Log("Multi Gesture: x = %f, y = %f, dAng = %f, dR = %f", - event.mgesture.x, event.mgesture.y, - event.mgesture.dTheta, event.mgesture.dDist); - SDL_Log("MG: numDownTouch = %i",event.mgesture.numFingers); + SDL_Log("Multi Gesture: x = %f, y = %f, dAng = %f, dR = %f", + event.mgesture.x, event.mgesture.y, + event.mgesture.dTheta, event.mgesture.dDist); + SDL_Log("MG: numDownTouch = %i", event.mgesture.numFingers); #endif - knob.p.x = event.mgesture.x; - knob.p.y = event.mgesture.y; - knob.ang += event.mgesture.dTheta; - knob.r += event.mgesture.dDist; - break; + knob.p.x = event.mgesture.x; + knob.p.y = event.mgesture.y; + knob.ang += event.mgesture.dTheta; + knob.r += event.mgesture.dDist; + break; - case SDL_DOLLARGESTURE: - SDL_Log("Gesture %"SDL_PRIs64" performed, error: %f", - event.dgesture.gestureId, event.dgesture.error); - break; + case SDL_DOLLARGESTURE: + SDL_Log("Gesture %" SDL_PRIs64 " performed, error: %f", + event.dgesture.gestureId, event.dgesture.error); + break; - case SDL_DOLLARRECORD: - SDL_Log("Recorded gesture: %"SDL_PRIs64"",event.dgesture.gestureId); - break; + case SDL_DOLLARRECORD: + SDL_Log("Recorded gesture: %" SDL_PRIs64 "", event.dgesture.gestureId); + break; } } @@ -269,7 +269,7 @@ loop(void) #endif } -int main(int argc, char* argv[]) +int main(int argc, char *argv[]) { state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); if (state == NULL) { diff --git a/test/testgl2.c b/test/testgl2.c index 9bc3ec6bd..b6fa1bee1 100644 --- a/test/testgl2.c +++ b/test/testgl2.c @@ -26,12 +26,11 @@ typedef struct GL_Context { -#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; +#define SDL_PROC(ret, func, params) ret(APIENTRY *func) params; #include "../src/render/opengl/SDL_glfuncs.h" #undef SDL_PROC } GL_Context; - /* Undefine this if you want a flat cube instead of a rainbow cube */ #define SHADED_CUBE @@ -39,7 +38,7 @@ static SDLTest_CommonState *state; static SDL_GLContext context; static GL_Context ctx; -static int LoadContext(GL_Context * data) +static int LoadContext(GL_Context *data) { #if SDL_VIDEO_DRIVER_UIKIT #define __SDL_NOGETPROCADDR__ @@ -50,15 +49,15 @@ static int LoadContext(GL_Context * data) #endif #if defined __SDL_NOGETPROCADDR__ -#define SDL_PROC(ret,func,params) data->func=func; +#define SDL_PROC(ret, func, params) data->func = func; #else -#define SDL_PROC(ret,func,params) \ - do { \ - data->func = SDL_GL_GetProcAddress(#func); \ - if ( ! data->func ) { \ +#define SDL_PROC(ret, func, params) \ + do { \ + data->func = SDL_GL_GetProcAddress(#func); \ + if (!data->func) { \ return SDL_SetError("Couldn't load GL function %s: %s", #func, SDL_GetError()); \ - } \ - } while ( 0 ); + } \ + } while (0); #endif /* __SDL_NOGETPROCADDR__ */ #include "../src/render/opengl/SDL_glfuncs.h" @@ -66,13 +65,12 @@ static int LoadContext(GL_Context * data) return 0; } - /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void quit(int rc) { if (context) { - /* SDL_GL_MakeCurrent(0, NULL); *//* doesn't do anything */ + /* SDL_GL_MakeCurrent(0, NULL); */ /* doesn't do anything */ SDL_GL_DeleteContext(context); } SDLTest_CommonQuit(state); @@ -83,24 +81,24 @@ static void Render() { static float color[8][3] = { - {1.0, 1.0, 0.0}, - {1.0, 0.0, 0.0}, - {0.0, 0.0, 0.0}, - {0.0, 1.0, 0.0}, - {0.0, 1.0, 1.0}, - {1.0, 1.0, 1.0}, - {1.0, 0.0, 1.0}, - {0.0, 0.0, 1.0} + { 1.0, 1.0, 0.0 }, + { 1.0, 0.0, 0.0 }, + { 0.0, 0.0, 0.0 }, + { 0.0, 1.0, 0.0 }, + { 0.0, 1.0, 1.0 }, + { 1.0, 1.0, 1.0 }, + { 1.0, 0.0, 1.0 }, + { 0.0, 0.0, 1.0 } }; static float cube[8][3] = { - {0.5, 0.5, -0.5}, - {0.5, -0.5, -0.5}, - {-0.5, -0.5, -0.5}, - {-0.5, 0.5, -0.5}, - {-0.5, 0.5, 0.5}, - {0.5, 0.5, 0.5}, - {0.5, -0.5, 0.5}, - {-0.5, -0.5, 0.5} + { 0.5, 0.5, -0.5 }, + { 0.5, -0.5, -0.5 }, + { -0.5, -0.5, -0.5 }, + { -0.5, 0.5, -0.5 }, + { -0.5, 0.5, 0.5 }, + { 0.5, 0.5, 0.5 }, + { 0.5, -0.5, 0.5 }, + { -0.5, -0.5, 0.5 } }; /* Do our drawing, too. */ @@ -163,7 +161,7 @@ Render() ctx.glVertex3fv(cube[2]); ctx.glColor3fv(color[7]); ctx.glVertex3fv(cube[7]); -#else /* flat cube */ +#else /* flat cube */ ctx.glColor3f(1.0, 0.0, 0.0); ctx.glVertex3fv(cube[0]); ctx.glVertex3fv(cube[1]); @@ -207,8 +205,7 @@ Render() ctx.glRotatef(5.0, 1.0, 1.0, 1.0); } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int fsaa, accel; int value; @@ -237,11 +234,11 @@ main(int argc, char *argv[]) consumed = SDLTest_CommonArg(state, i); if (consumed == 0) { - if (SDL_strcasecmp(argv[i], "--fsaa") == 0 && i+1 < argc) { - fsaa = SDL_atoi(argv[i+1]); + if (SDL_strcasecmp(argv[i], "--fsaa") == 0 && i + 1 < argc) { + fsaa = SDL_atoi(argv[i + 1]); consumed = 2; - } else if (SDL_strcasecmp(argv[i], "--accel") == 0 && i+1 < argc) { - accel = SDL_atoi(argv[i+1]); + } else if (SDL_strcasecmp(argv[i], "--accel") == 0 && i + 1 < argc) { + accel = SDL_atoi(argv[i + 1]); consumed = 2; } else { consumed = -1; @@ -280,7 +277,7 @@ main(int argc, char *argv[]) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError()); quit(2); } - + /* Important: call this *after* creating the context */ if (LoadContext(&ctx) < 0) { SDL_Log("Could not load GL functions\n"); @@ -297,7 +294,7 @@ main(int argc, char *argv[]) swap_interval = 1; } } else { - SDL_GL_SetSwapInterval(0); /* disable vsync. */ + SDL_GL_SetSwapInterval(0); /* disable vsync. */ swap_interval = 0; } @@ -345,25 +342,25 @@ main(int argc, char *argv[]) SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", - SDL_GetError()); + SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); if (!status) { SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, - value); + value); } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", - SDL_GetError()); + SDL_GetError()); } } if (accel >= 0) { status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); if (!status) { SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel, - value); + value); } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", - SDL_GetError()); + SDL_GetError()); } } @@ -376,7 +373,7 @@ main(int argc, char *argv[]) ctx.glEnable(GL_DEPTH_TEST); ctx.glDepthFunc(GL_LESS); ctx.glShadeModel(GL_SMOOTH); - + /* Main render loop */ frames = 0; then = SDL_GetTicks(); @@ -423,7 +420,7 @@ main(int argc, char *argv[]) now = SDL_GetTicks(); if (now > then) { SDL_Log("%2.2f frames per second\n", - ((double) frames * 1000) / (now - then)); + ((double)frames * 1000) / (now - then)); } quit(0); return 0; @@ -431,8 +428,7 @@ main(int argc, char *argv[]) #else /* HAVE_OPENGL */ -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n"); return 1; diff --git a/test/testgles.c b/test/testgles.c index 1cd09b660..93c6be365 100644 --- a/test/testgles.c +++ b/test/testgles.c @@ -51,38 +51,34 @@ quit(int rc) static void Render() { - static GLubyte color[8][4] = { {255, 0, 0, 0}, - {255, 0, 0, 255}, - {0, 255, 0, 255}, - {0, 255, 0, 255}, - {0, 255, 0, 255}, - {255, 255, 255, 255}, - {255, 0, 255, 255}, - {0, 0, 255, 255} - }; - static GLfloat cube[8][3] = { {0.5, 0.5, -0.5}, - {0.5f, -0.5f, -0.5f}, - {-0.5f, -0.5f, -0.5f}, - {-0.5f, 0.5f, -0.5f}, - {-0.5f, 0.5f, 0.5f}, - {0.5f, 0.5f, 0.5f}, - {0.5f, -0.5f, 0.5f}, - {-0.5f, -0.5f, 0.5f} - }; + static GLubyte color[8][4] = { { 255, 0, 0, 0 }, + { 255, 0, 0, 255 }, + { 0, 255, 0, 255 }, + { 0, 255, 0, 255 }, + { 0, 255, 0, 255 }, + { 255, 255, 255, 255 }, + { 255, 0, 255, 255 }, + { 0, 0, 255, 255 } }; + static GLfloat cube[8][3] = { { 0.5, 0.5, -0.5 }, + { 0.5f, -0.5f, -0.5f }, + { -0.5f, -0.5f, -0.5f }, + { -0.5f, 0.5f, -0.5f }, + { -0.5f, 0.5f, 0.5f }, + { 0.5f, 0.5f, 0.5f }, + { 0.5f, -0.5f, 0.5f }, + { -0.5f, -0.5f, 0.5f } }; static GLubyte indices[36] = { 0, 3, 4, - 4, 5, 0, - 0, 5, 6, - 6, 1, 0, - 6, 7, 2, - 2, 1, 6, - 7, 4, 3, - 3, 2, 7, - 5, 4, 7, - 7, 6, 5, - 2, 3, 1, - 3, 0, 1 - }; - + 4, 5, 0, + 0, 5, 6, + 6, 1, 0, + 6, 7, 2, + 2, 1, 6, + 7, 4, 3, + 3, 2, 7, + 5, 4, 7, + 7, 6, 5, + 2, 3, 1, + 3, 0, 1 }; /* Do our drawing, too. */ glClearColor(0.0, 0.0, 0.0, 1.0); @@ -99,8 +95,7 @@ Render() glRotatef(5.0, 1.0, 1.0, 1.0); } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int fsaa, accel; int value; @@ -163,11 +158,11 @@ main(int argc, char *argv[]) state->gl_minor_version = 1; state->gl_profile_mask = SDL_GL_CONTEXT_PROFILE_ES; if (fsaa) { - state->gl_multisamplebuffers=1; - state->gl_multisamplesamples=fsaa; + state->gl_multisamplebuffers = 1; + state->gl_multisamplesamples = fsaa; } if (accel) { - state->gl_accelerated=1; + state->gl_accelerated = 1; } if (!SDLTest_CommonInit(state)) { quit(2); @@ -208,28 +203,28 @@ main(int argc, char *argv[]) SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n", - SDL_GetError()); + SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); if (!status) { SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n", - SDL_GetError()); + SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); if (!status) { SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n", - SDL_GetError()); + SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); if (!status) { SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value); } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", - SDL_GetError()); + SDL_GetError()); } if (fsaa) { status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value); @@ -237,15 +232,15 @@ main(int argc, char *argv[]) SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", - SDL_GetError()); + SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); if (!status) { SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, - value); + value); } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", - SDL_GetError()); + SDL_GetError()); } } if (accel) { @@ -254,7 +249,7 @@ main(int argc, char *argv[]) SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", - SDL_GetError()); + SDL_GetError()); } } @@ -293,23 +288,23 @@ main(int argc, char *argv[]) switch (event.type) { case SDL_WINDOWEVENT: switch (event.window.event) { - case SDL_WINDOWEVENT_RESIZED: - for (i = 0; i < state->num_windows; ++i) { - if (event.window.windowID == SDL_GetWindowID(state->windows[i])) { - status = SDL_GL_MakeCurrent(state->windows[i], context[i]); - if (status) { - SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); - break; - } - /* Change view port to the new window dimensions */ - glViewport(0, 0, event.window.data1, event.window.data2); - /* Update window content */ - Render(); - SDL_GL_SwapWindow(state->windows[i]); + case SDL_WINDOWEVENT_RESIZED: + for (i = 0; i < state->num_windows; ++i) { + if (event.window.windowID == SDL_GetWindowID(state->windows[i])) { + status = SDL_GL_MakeCurrent(state->windows[i], context[i]); + if (status) { + SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); break; } + /* Change view port to the new window dimensions */ + glViewport(0, 0, event.window.data1, event.window.data2); + /* Update window content */ + Render(); + SDL_GL_SwapWindow(state->windows[i]); + break; } - break; + } + break; } } SDLTest_CommonEvent(state, &event, &done); @@ -334,18 +329,17 @@ main(int argc, char *argv[]) now = SDL_GetTicks(); if (now > then) { SDL_Log("%2.2f frames per second\n", - ((double) frames * 1000) / (now - then)); + ((double)frames * 1000) / (now - then)); } #if !defined(__ANDROID__) quit(0); -#endif +#endif return 0; } #else /* HAVE_OPENGLES */ -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL ES support on this system\n"); return 1; diff --git a/test/testgles2.c b/test/testgles2.c index 45e7471cf..e67746bc5 100644 --- a/test/testgles2.c +++ b/test/testgles2.c @@ -33,7 +33,7 @@ typedef struct GLES2_Context { -#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; +#define SDL_PROC(ret, func, params) ret(APIENTRY *func) params; #include "../src/render/opengles2/SDL_gles2funcs.h" #undef SDL_PROC } GLES2_Context; @@ -63,7 +63,7 @@ static SDL_GLContext *context = NULL; static int depth = 16; static GLES2_Context ctx; -static int LoadContext(GLES2_Context * data) +static int LoadContext(GLES2_Context *data) { #if SDL_VIDEO_DRIVER_UIKIT #define __SDL_NOGETPROCADDR__ @@ -74,15 +74,15 @@ static int LoadContext(GLES2_Context * data) #endif #if defined __SDL_NOGETPROCADDR__ -#define SDL_PROC(ret,func,params) data->func=func; +#define SDL_PROC(ret, func, params) data->func = func; #else -#define SDL_PROC(ret,func,params) \ - do { \ - data->func = SDL_GL_GetProcAddress(#func); \ - if ( ! data->func ) { \ +#define SDL_PROC(ret, func, params) \ + do { \ + data->func = SDL_GL_GetProcAddress(#func); \ + if (!data->func) { \ return SDL_SetError("Couldn't load GLES2 function %s: %s", #func, SDL_GetError()); \ - } \ - } while ( 0 ); + } \ + } while (0); #endif /* __SDL_NOGETPROCADDR__ */ #include "../src/render/opengles2/SDL_gles2funcs.h" @@ -110,19 +110,19 @@ quit(int rc) exit(rc); } -#define GL_CHECK(x) \ - x; \ - { \ - GLenum glError = ctx.glGetError(); \ - if (glError != GL_NO_ERROR) { \ +#define GL_CHECK(x) \ + x; \ + { \ + GLenum glError = ctx.glGetError(); \ + if (glError != GL_NO_ERROR) { \ SDL_Log("glGetError() = %i (0x%.8x) at line %i\n", glError, glError, __LINE__); \ - quit(1); \ - } \ - } + quit(1); \ + } \ + } -/* - * Simulates desktop's glRotatef. The matrix is returned in column-major - * order. +/* + * Simulates desktop's glRotatef. The matrix is returned in column-major + * order. */ static void rotate_matrix(float angle, float x, float y, float z, float *r) @@ -161,16 +161,16 @@ rotate_matrix(float angle, float x, float y, float z, float *r) } } -/* - * Simulates gluPerspectiveMatrix +/* + * Simulates gluPerspectiveMatrix */ -static void +static void perspective_matrix(float fovy, float aspect, float znear, float zfar, float *r) { int i; float f; - f = 1.0f/SDL_tanf(fovy * 0.5f); + f = 1.0f / SDL_tanf(fovy * 0.5f); for (i = 0; i < 16; i++) { r[i] = 0.0; @@ -184,7 +184,7 @@ perspective_matrix(float fovy, float aspect, float znear, float zfar, float *r) r[15] = 0.0f; } -/* +/* * Multiplies lhs by rhs and writes out to r. All matrices are 4x4 and column * major. In-place multiplication is supported. */ @@ -209,7 +209,7 @@ multiply_matrix(float *lhs, float *rhs, float *r) } } -/* +/* * Create shader, load in source, compile, dump debug as necessary. * * shader: Pointer to return created shader ID. @@ -217,7 +217,7 @@ multiply_matrix(float *lhs, float *rhs, float *r) * shader_type: Passed to GL, e.g. GL_VERTEX_SHADER. */ static void -process_shader(GLuint *shader, const char * source, GLint shader_type) +process_shader(GLuint *shader, const char *source, GLint shader_type) { GLint status = GL_FALSE; const char *shaders[1] = { NULL }; @@ -270,67 +270,137 @@ link_program(struct shader_data *data) } /* 3D data. Vertex range -0.5..0.5 in all axes. -* Z -0.5 is near, 0.5 is far. */ -const float _vertices[] = -{ + * Z -0.5 is near, 0.5 is far. */ +const float _vertices[] = { /* Front face. */ /* Bottom left */ - -0.5, 0.5, -0.5, - 0.5, -0.5, -0.5, - -0.5, -0.5, -0.5, + -0.5, + 0.5, + -0.5, + 0.5, + -0.5, + -0.5, + -0.5, + -0.5, + -0.5, /* Top right */ - -0.5, 0.5, -0.5, - 0.5, 0.5, -0.5, - 0.5, -0.5, -0.5, + -0.5, + 0.5, + -0.5, + 0.5, + 0.5, + -0.5, + 0.5, + -0.5, + -0.5, /* Left face */ /* Bottom left */ - -0.5, 0.5, 0.5, - -0.5, -0.5, -0.5, - -0.5, -0.5, 0.5, + -0.5, + 0.5, + 0.5, + -0.5, + -0.5, + -0.5, + -0.5, + -0.5, + 0.5, /* Top right */ - -0.5, 0.5, 0.5, - -0.5, 0.5, -0.5, - -0.5, -0.5, -0.5, + -0.5, + 0.5, + 0.5, + -0.5, + 0.5, + -0.5, + -0.5, + -0.5, + -0.5, /* Top face */ /* Bottom left */ - -0.5, 0.5, 0.5, - 0.5, 0.5, -0.5, - -0.5, 0.5, -0.5, + -0.5, + 0.5, + 0.5, + 0.5, + 0.5, + -0.5, + -0.5, + 0.5, + -0.5, /* Top right */ - -0.5, 0.5, 0.5, - 0.5, 0.5, 0.5, - 0.5, 0.5, -0.5, + -0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + -0.5, /* Right face */ /* Bottom left */ - 0.5, 0.5, -0.5, - 0.5, -0.5, 0.5, - 0.5, -0.5, -0.5, + 0.5, + 0.5, + -0.5, + 0.5, + -0.5, + 0.5, + 0.5, + -0.5, + -0.5, /* Top right */ - 0.5, 0.5, -0.5, - 0.5, 0.5, 0.5, - 0.5, -0.5, 0.5, + 0.5, + 0.5, + -0.5, + 0.5, + 0.5, + 0.5, + 0.5, + -0.5, + 0.5, /* Back face */ /* Bottom left */ - 0.5, 0.5, 0.5, - -0.5, -0.5, 0.5, - 0.5, -0.5, 0.5, + 0.5, + 0.5, + 0.5, + -0.5, + -0.5, + 0.5, + 0.5, + -0.5, + 0.5, /* Top right */ - 0.5, 0.5, 0.5, - -0.5, 0.5, 0.5, - -0.5, -0.5, 0.5, + 0.5, + 0.5, + 0.5, + -0.5, + 0.5, + 0.5, + -0.5, + -0.5, + 0.5, /* Bottom face */ /* Bottom left */ - -0.5, -0.5, -0.5, - 0.5, -0.5, 0.5, - -0.5, -0.5, 0.5, + -0.5, + -0.5, + -0.5, + 0.5, + -0.5, + 0.5, + -0.5, + -0.5, + 0.5, /* Top right */ - -0.5, -0.5, -0.5, - 0.5, -0.5, -0.5, - 0.5, -0.5, 0.5, + -0.5, + -0.5, + -0.5, + 0.5, + -0.5, + -0.5, + 0.5, + -0.5, + 0.5, }; -const float _colors[] = -{ +const float _colors[] = { /* Front face */ /* Bottom left */ 1.0, 0.0, 0.0, /* red */ @@ -387,32 +457,32 @@ const float _colors[] = 1.0, 0.0, 1.0, /* magenta */ }; -const char* _shader_vert_src = -" attribute vec4 av4position; " -" attribute vec3 av3color; " -" uniform mat4 mvp; " -" varying vec3 vv3color; " -" void main() { " -" vv3color = av3color; " -" gl_Position = mvp * av4position; " -" } "; +const char *_shader_vert_src = + " attribute vec4 av4position; " + " attribute vec3 av3color; " + " uniform mat4 mvp; " + " varying vec3 vv3color; " + " void main() { " + " vv3color = av3color; " + " gl_Position = mvp * av4position; " + " } "; -const char* _shader_frag_src = -" precision lowp float; " -" varying vec3 vv3color; " -" void main() { " -" gl_FragColor = vec4(vv3color, 1.0); " -" } "; +const char *_shader_frag_src = + " precision lowp float; " + " varying vec3 vv3color; " + " void main() { " + " gl_FragColor = vec4(vv3color, 1.0); " + " } "; static void -Render(unsigned int width, unsigned int height, shader_data* data) +Render(unsigned int width, unsigned int height, shader_data *data) { float matrix_rotate[16], matrix_modelview[16], matrix_perspective[16], matrix_mvp[16]; - /* - * Do some rotation with Euler angles. It is not a fixed axis as - * quaterions would be, but the effect is cool. - */ + /* + * Do some rotation with Euler angles. It is not a fixed axis as + * quaterions would be, but the effect is cool. + */ rotate_matrix((float)data->angle_x, 1.0f, 0.0f, 0.0f, matrix_modelview); rotate_matrix((float)data->angle_y, 0.0f, 1.0f, 0.0f, matrix_rotate); @@ -425,7 +495,7 @@ Render(unsigned int width, unsigned int height, shader_data* data) /* Pull the camera back from the cube */ matrix_modelview[14] -= 2.5; - perspective_matrix(45.0f, (float)width/height, 0.01f, 100.0f, matrix_perspective); + perspective_matrix(45.0f, (float)width / height, 0.01f, 100.0f, matrix_perspective); multiply_matrix(matrix_perspective, matrix_modelview, matrix_mvp); GL_CHECK(ctx.glUniformMatrix4fv(data->attr_mvp, 1, GL_FALSE, matrix_mvp)); @@ -486,7 +556,7 @@ render_window(int index) #ifndef __EMSCRIPTEN__ static int SDLCALL -render_thread_fn(void* render_ctx) +render_thread_fn(void *render_ctx) { thread_data *thread = render_ctx; @@ -549,8 +619,7 @@ loop() #endif } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int fsaa, accel, threaded; int value; @@ -615,11 +684,11 @@ main(int argc, char *argv[]) state->gl_profile_mask = SDL_GL_CONTEXT_PROFILE_ES; if (fsaa) { - state->gl_multisamplebuffers=1; - state->gl_multisamplesamples=fsaa; + state->gl_multisamplebuffers = 1; + state->gl_multisamplesamples = fsaa; } if (accel) { - state->gl_accelerated=1; + state->gl_accelerated = 1; } if (!SDLTest_CommonInit(state)) { quit(2); @@ -631,7 +700,7 @@ main(int argc, char *argv[]) SDL_Log("Out of memory!\n"); quit(2); } - + /* Create OpenGL ES contexts */ for (i = 0; i < state->num_windows; i++) { context[i] = SDL_GL_CreateContext(state->windows[i]); @@ -648,8 +717,6 @@ main(int argc, char *argv[]) return 0; } - - if (state->render_flags & SDL_RENDERER_PRESENTVSYNC) { SDL_GL_SetSwapInterval(1); } else { @@ -670,28 +737,28 @@ main(int argc, char *argv[]) if (!status) { SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); } else { - SDL_Log( "Failed to get SDL_GL_RED_SIZE: %s\n", + SDL_Log("Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); if (!status) { SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); } else { - SDL_Log( "Failed to get SDL_GL_GREEN_SIZE: %s\n", + SDL_Log("Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); if (!status) { SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); } else { - SDL_Log( "Failed to get SDL_GL_BLUE_SIZE: %s\n", + SDL_Log("Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); if (!status) { SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value); } else { - SDL_Log( "Failed to get SDL_GL_DEPTH_SIZE: %s\n", + SDL_Log("Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError()); } if (fsaa) { @@ -699,15 +766,15 @@ main(int argc, char *argv[]) if (!status) { SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); } else { - SDL_Log( "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", + SDL_Log("Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); if (!status) { SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, - value); + value); } else { - SDL_Log( "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", + SDL_Log("Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", SDL_GetError()); } } @@ -716,7 +783,7 @@ main(int argc, char *argv[]) if (!status) { SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); } else { - SDL_Log( "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", + SDL_Log("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", SDL_GetError()); } } @@ -738,7 +805,9 @@ main(int argc, char *argv[]) ctx.glViewport(0, 0, w, h); data = &datas[i]; - data->angle_x = 0; data->angle_y = 0; data->angle_z = 0; + data->angle_x = 0; + data->angle_y = 0; + data->angle_z = 0; /* Shader Initialization */ process_shader(&data->shader_vert, _shader_vert_src, GL_VERTEX_SHADER); @@ -792,7 +861,7 @@ main(int argc, char *argv[]) emscripten_set_main_loop(loop, 0, 1); #else if (threaded) { - threads = (thread_data*)SDL_calloc(state->num_windows, sizeof(thread_data)); + threads = (thread_data *)SDL_calloc(state->num_windows, sizeof(thread_data)); /* Start a render thread for each window */ for (i = 0; i < state->num_windows; ++i) { @@ -822,7 +891,7 @@ main(int argc, char *argv[]) now = SDL_GetTicks(); if (now > then) { SDL_Log("%2.2f frames per second\n", - ((double) frames * 1000) / (now - then)); + ((double)frames * 1000) / (now - then)); } #if !defined(__ANDROID__) && !defined(__NACL__) quit(0); @@ -832,8 +901,7 @@ main(int argc, char *argv[]) #else /* HAVE_OPENGLES2 */ -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { SDL_Log("No OpenGL ES support on this system\n"); return 1; diff --git a/test/testgles2_sdf.c b/test/testgles2_sdf.c index d2d36f99a..d9cf12f8c 100644 --- a/test/testgles2_sdf.c +++ b/test/testgles2_sdf.c @@ -31,12 +31,11 @@ typedef struct GLES2_Context { -#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; +#define SDL_PROC(ret, func, params) ret(APIENTRY *func) params; #include "../src/render/opengles2/SDL_gles2funcs.h" #undef SDL_PROC } GLES2_Context; - static SDL_Surface *g_surf_sdf = NULL; GLenum g_texture; GLenum g_texture_type = GL_TEXTURE_2D; @@ -59,14 +58,12 @@ typedef enum GLuint g_uniform_locations[16]; - - static SDLTest_CommonState *state; static SDL_GLContext *context = NULL; static int depth = 16; static GLES2_Context ctx; -static int LoadContext(GLES2_Context * data) +static int LoadContext(GLES2_Context *data) { #if SDL_VIDEO_DRIVER_UIKIT #define __SDL_NOGETPROCADDR__ @@ -77,15 +74,15 @@ static int LoadContext(GLES2_Context * data) #endif #if defined __SDL_NOGETPROCADDR__ -#define SDL_PROC(ret,func,params) data->func=func; +#define SDL_PROC(ret, func, params) data->func = func; #else -#define SDL_PROC(ret,func,params) \ - do { \ - data->func = SDL_GL_GetProcAddress(#func); \ - if ( ! data->func ) { \ +#define SDL_PROC(ret, func, params) \ + do { \ + data->func = SDL_GL_GetProcAddress(#func); \ + if (!data->func) { \ return SDL_SetError("Couldn't load GLES2 function %s: %s", #func, SDL_GetError()); \ - } \ - } while ( 0 ); + } \ + } while (0); #endif /* __SDL_NOGETPROCADDR__ */ #include "../src/render/opengles2/SDL_gles2funcs.h" @@ -113,18 +110,17 @@ quit(int rc) exit(rc); } -#define GL_CHECK(x) \ - x; \ - { \ - GLenum glError = ctx.glGetError(); \ - if (glError != GL_NO_ERROR) { \ +#define GL_CHECK(x) \ + x; \ + { \ + GLenum glError = ctx.glGetError(); \ + if (glError != GL_NO_ERROR) { \ SDL_Log("glGetError() = %i (0x%.8x) at line %i\n", glError, glError, __LINE__); \ - quit(1); \ - } \ - } + quit(1); \ + } \ + } - -/* +/* * Create shader, load in source, compile, dump debug as necessary. * * shader: Pointer to return created shader ID. @@ -242,16 +238,12 @@ static const char *GLES2_FragmentSrc_TextureABGRSrc_SDF_dbg = " \ } \ "; - static float g_val = 1.0f; -static int g_use_SDF = 1; -static int g_use_SDF_debug = 0; +static int g_use_SDF = 1; +static int g_use_SDF_debug = 0; static float g_angle = 0.0f; static float matrix_mvp[4][4]; - - - typedef struct shader_data { GLuint shader_program, shader_frag, shader_vert; @@ -272,15 +264,14 @@ Render(unsigned int width, unsigned int height, shader_data* data) GL_CHECK(ctx.glUniformMatrix4fv(g_uniform_locations[GLES2_UNIFORM_PROJECTION], 1, GL_FALSE, (const float *)matrix_mvp)); GL_CHECK(ctx.glUniform4f(g_uniform_locations[GLES2_UNIFORM_COLOR], 1.0f, 1.0f, 1.0f, 1.0f)); - GL_CHECK(ctx.glVertexAttribPointer(GLES2_ATTRIBUTE_ANGLE, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) (verts + 16))); - GL_CHECK(ctx.glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) (verts + 8))); - GL_CHECK(ctx.glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) verts)); + GL_CHECK(ctx.glVertexAttribPointer(GLES2_ATTRIBUTE_ANGLE, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *)(verts + 16))); + GL_CHECK(ctx.glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *)(verts + 8))); + GL_CHECK(ctx.glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *)verts)); GL_CHECK(ctx.glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)); } - -void renderCopy_angle(float degree_angle) +void renderCopy_angle(float degree_angle) { const float radian_angle = (float)(3.141592 * degree_angle) / 180.0; const GLfloat s = (GLfloat) SDL_sin(radian_angle); @@ -296,8 +287,7 @@ void renderCopy_angle(float degree_angle) *(verts++) = c; } - -void renderCopy_position(SDL_Rect *srcrect, SDL_Rect *dstrect) +void renderCopy_position(SDL_Rect *srcrect, SDL_Rect *dstrect) { GLfloat minx, miny, maxx, maxy; GLfloat minu, maxu, minv, maxv; @@ -347,8 +337,8 @@ void loop() while (SDL_PollEvent(&event) && !done) { switch (event.type) { case SDL_KEYDOWN: - { - const int sym = event.key.keysym.sym; + { + const int sym = event.key.keysym.sym; if (sym == SDLK_TAB) { SDL_Log("Tab"); @@ -374,35 +364,50 @@ void loop() break; } + if (sym == SDLK_LEFT) { + g_val -= 0.05f; + } + if (sym == SDLK_RIGHT) { + g_val += 0.05f; + } + if (sym == SDLK_UP) { + g_angle -= 1.0f; + } + if (sym == SDLK_DOWN) { + g_angle += 1.0f; + } + + break; + } + case SDL_WINDOWEVENT: switch (event.window.event) { - case SDL_WINDOWEVENT_RESIZED: - for (i = 0; i < state->num_windows; ++i) { - if (event.window.windowID == SDL_GetWindowID(state->windows[i])) { - int w, h; - status = SDL_GL_MakeCurrent(state->windows[i], context[i]); - if (status) { - SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); - break; - } - /* Change view port to the new window dimensions */ - SDL_GL_GetDrawableSize(state->windows[i], &w, &h); - ctx.glViewport(0, 0, w, h); - state->window_w = event.window.data1; - state->window_h = event.window.data2; - /* Update window content */ - Render(event.window.data1, event.window.data2, &datas[i]); - SDL_GL_SwapWindow(state->windows[i]); + case SDL_WINDOWEVENT_RESIZED: + for (i = 0; i < state->num_windows; ++i) { + if (event.window.windowID == SDL_GetWindowID(state->windows[i])) { + int w, h; + status = SDL_GL_MakeCurrent(state->windows[i], context[i]); + if (status) { + SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); break; } + /* Change view port to the new window dimensions */ + SDL_GL_GetDrawableSize(state->windows[i], &w, &h); + ctx.glViewport(0, 0, w, h); + state->window_w = event.window.data1; + state->window_h = event.window.data2; + /* Update window content */ + Render(event.window.data1, event.window.data2, &datas[i]); + SDL_GL_SwapWindow(state->windows[i]); + break; } - break; + } + break; } } SDLTest_CommonEvent(state, &event, &done); } - matrix_mvp[3][0] = -1.0f; matrix_mvp[3][3] = 1.0f; @@ -433,20 +438,19 @@ void loop() rd.x = (w - rd.w) / 2; rd.y = (h - rd.h) / 2; renderCopy_position(&rs, &rd); } - if (!done) { - for (i = 0; i < state->num_windows; ++i) { - status = SDL_GL_MakeCurrent(state->windows[i], context[i]); - if (status) { - SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); + for (i = 0; i < state->num_windows; ++i) { + status = SDL_GL_MakeCurrent(state->windows[i], context[i]); + if (status) { + SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); - /* Continue for next window */ - continue; - } - Render(state->window_w, state->window_h, &datas[i]); - SDL_GL_SwapWindow(state->windows[i]); - } + /* Continue for next window */ + continue; + } + Render(state->window_w, state->window_h, &datas[i]); + SDL_GL_SwapWindow(state->windows[i]); + } } #ifdef __EMSCRIPTEN__ else { @@ -455,8 +459,7 @@ void loop() #endif } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int fsaa, accel; int value; @@ -518,11 +521,11 @@ main(int argc, char *argv[]) state->gl_profile_mask = SDL_GL_CONTEXT_PROFILE_ES; if (fsaa) { - state->gl_multisamplebuffers=1; - state->gl_multisamplesamples=fsaa; + state->gl_multisamplebuffers = 1; + state->gl_multisamplesamples = fsaa; } if (accel) { - state->gl_accelerated=1; + state->gl_accelerated = 1; } if (!SDLTest_CommonInit(state)) { quit(2); @@ -534,7 +537,7 @@ main(int argc, char *argv[]) SDL_Log("Out of memory!\n"); quit(2); } - + /* Create OpenGL ES contexts */ for (i = 0; i < state->num_windows; i++) { context[i] = SDL_GL_CreateContext(state->windows[i]); @@ -551,8 +554,8 @@ main(int argc, char *argv[]) return 0; } - SDL_memset(matrix_mvp, 0, sizeof (matrix_mvp)); - + SDL_memset(matrix_mvp, 0, sizeof(matrix_mvp)); + { SDL_Surface *tmp; char *f; @@ -564,7 +567,7 @@ main(int argc, char *argv[]) } else { f = "testgles2_sdf_img_normal.bmp"; } - + SDL_Log("SDF is %s", g_use_SDF ? "enabled" : "disabled"); /* Load SDF BMP image */ @@ -592,10 +595,10 @@ main(int argc, char *argv[]) #else /* Generate SDF image using SDL_ttf */ - #include "SDL_ttf.h" +#include "SDL_ttf.h" char *font_file = "./font/DroidSansFallback.ttf"; char *str = "Abcde"; - SDL_Color color = { 0, 0,0, 255}; + SDL_Color color = { 0, 0, 0, 255 }; TTF_Init(); TTF_Font *font = TTF_OpenFont(font_file, 72); @@ -623,7 +626,6 @@ main(int argc, char *argv[]) SDL_SetSurfaceBlendMode(g_surf_sdf, SDL_BLENDMODE_BLEND); } - if (state->render_flags & SDL_RENDERER_PRESENTVSYNC) { SDL_GL_SetSwapInterval(1); } else { @@ -643,28 +645,28 @@ main(int argc, char *argv[]) if (!status) { SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); } else { - SDL_Log( "Failed to get SDL_GL_RED_SIZE: %s\n", + SDL_Log("Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); if (!status) { SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); } else { - SDL_Log( "Failed to get SDL_GL_GREEN_SIZE: %s\n", + SDL_Log("Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); if (!status) { SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); } else { - SDL_Log( "Failed to get SDL_GL_BLUE_SIZE: %s\n", + SDL_Log("Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); if (!status) { SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value); } else { - SDL_Log( "Failed to get SDL_GL_DEPTH_SIZE: %s\n", + SDL_Log("Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError()); } if (fsaa) { @@ -672,15 +674,15 @@ main(int argc, char *argv[]) if (!status) { SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); } else { - SDL_Log( "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", + SDL_Log("Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); if (!status) { SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, - value); + value); } else { - SDL_Log( "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", + SDL_Log("Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", SDL_GetError()); } } @@ -689,7 +691,7 @@ main(int argc, char *argv[]) if (!status) { SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); } else { - SDL_Log( "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", + SDL_Log("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", SDL_GetError()); } } @@ -728,7 +730,6 @@ main(int argc, char *argv[]) GL_CHECK(ctx.glTexSubImage2D(g_texture_type, 0, 0 /* xoffset */, 0 /* yoffset */, g_surf_sdf->w, g_surf_sdf->h, format, type, g_surf_sdf->pixels)); } - SDL_GL_GetDrawableSize(state->windows[i], &w, &h); ctx.glViewport(0, 0, w, h); @@ -767,23 +768,20 @@ main(int argc, char *argv[]) GL_CHECK(ctx.glUseProgram(data->shader_program)); - ctx.glEnableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_ANGLE); - ctx.glDisableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_CENTER); + ctx.glEnableVertexAttribArray((GLenum)GLES2_ATTRIBUTE_ANGLE); + ctx.glDisableVertexAttribArray((GLenum)GLES2_ATTRIBUTE_CENTER); ctx.glEnableVertexAttribArray(GLES2_ATTRIBUTE_POSITION); - ctx.glEnableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_TEXCOORD); - - - ctx.glUniform1i(g_uniform_locations[GLES2_UNIFORM_TEXTURE], 0); /* always texture unit 0. */ - ctx.glActiveTexture(GL_TEXTURE0); - ctx.glBindTexture(g_texture_type, g_texture); - GL_CHECK(ctx.glClearColor(1, 1, 1, 1)); - - // SDL_BLENDMODE_BLEND - GL_CHECK(ctx.glEnable(GL_BLEND)); - ctx.glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - ctx.glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD); + ctx.glEnableVertexAttribArray((GLenum)GLES2_ATTRIBUTE_TEXCOORD); + ctx.glUniform1i(g_uniform_locations[GLES2_UNIFORM_TEXTURE], 0); /* always texture unit 0. */ + ctx.glActiveTexture(GL_TEXTURE0); + ctx.glBindTexture(g_texture_type, g_texture); + GL_CHECK(ctx.glClearColor(1, 1, 1, 1)); + // SDL_BLENDMODE_BLEND + GL_CHECK(ctx.glEnable(GL_BLEND)); + ctx.glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + ctx.glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD); } /* Main render loop */ @@ -803,7 +801,7 @@ main(int argc, char *argv[]) now = SDL_GetTicks(); if (now > then) { SDL_Log("%2.2f frames per second\n", - ((double) frames * 1000) / (now - then)); + ((double)frames * 1000) / (now - then)); } #if !defined(__ANDROID__) && !defined(__NACL__) quit(0); @@ -813,8 +811,7 @@ main(int argc, char *argv[]) #else /* HAVE_OPENGLES2 */ -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { SDL_Log("No OpenGL ES support on this system\n"); return 1; diff --git a/test/testhaptic.c b/test/testhaptic.c index 55fe299af..fa4186376 100644 --- a/test/testhaptic.c +++ b/test/testhaptic.c @@ -20,21 +20,18 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND static SDL_Haptic *haptic; - /* * prototypes */ static void abort_execution(void); static void HapticPrintSupported(SDL_Haptic *); - /** * @brief The entry point of this force feedback demo. * @param[in] argc Number of arguments. * @param[in] argv Array of argc arguments. */ -int -main(int argc, char **argv) +int main(int argc, char **argv) { int i; char *name; @@ -53,9 +50,9 @@ main(int argc, char **argv) name = argv[1]; if ((SDL_strcmp(name, "--help") == 0) || (SDL_strcmp(name, "-h") == 0)) { SDL_Log("USAGE: %s [device]\n" - "If device is a two-digit number it'll use it as an index, otherwise\n" - "it'll use it as if it were part of the device's name.\n", - argv[0]); + "If device is a two-digit number it'll use it as an index, otherwise\n" + "it'll use it as if it were part of the device's name.\n", + argv[0]); return 0; } @@ -85,7 +82,7 @@ main(int argc, char **argv) if (i >= SDL_NumHaptics()) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.\n", - name); + name); return 1; } } @@ -93,7 +90,7 @@ main(int argc, char **argv) haptic = SDL_HapticOpen(i); if (haptic == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n", - SDL_GetError()); + SDL_GetError()); return 1; } SDL_Log("Device: %s\n", SDL_HapticName(i)); @@ -117,8 +114,8 @@ main(int argc, char **argv) SDL_Log(" effect %d: Sine Wave\n", nefx); efx[nefx].type = SDL_HAPTIC_SINE; efx[nefx].periodic.period = 1000; - efx[nefx].periodic.magnitude = -0x2000; /* Negative magnitude and ... */ - efx[nefx].periodic.phase = 18000; /* ... 180 degrees phase shift => cancel eachother */ + efx[nefx].periodic.magnitude = -0x2000; /* Negative magnitude and ... */ + efx[nefx].periodic.phase = 18000; /* ... 180 degrees phase shift => cancel eachother */ efx[nefx].periodic.length = 5000; efx[nefx].periodic.attack_length = 1000; efx[nefx].periodic.fade_length = 1000; @@ -145,13 +142,13 @@ main(int argc, char **argv) } nefx++; } - + /* Now the classical constant effect. */ if (supported & SDL_HAPTIC_CONSTANT) { SDL_Log(" effect %d: Constant Force\n", nefx); efx[nefx].type = SDL_HAPTIC_CONSTANT; efx[nefx].constant.direction.type = SDL_HAPTIC_POLAR; - efx[nefx].constant.direction.dir[0] = 20000; /* Force comes from the south-west. */ + efx[nefx].constant.direction.dir[0] = 20000; /* Force comes from the south-west. */ efx[nefx].constant.length = 5000; efx[nefx].constant.level = 0x6000; efx[nefx].constant.attack_length = 1000; @@ -163,7 +160,7 @@ main(int argc, char **argv) } nefx++; } - + /* The cute spring effect. */ if (supported & SDL_HAPTIC_SPRING) { SDL_Log(" effect %d: Condition Spring\n", nefx); @@ -174,7 +171,7 @@ main(int argc, char **argv) efx[nefx].condition.left_sat[i] = 0xFFFF; efx[nefx].condition.right_coeff[i] = 0x2000; efx[nefx].condition.left_coeff[i] = 0x2000; - efx[nefx].condition.center[i] = 0x1000; /* Displace the center for it to move. */ + efx[nefx].condition.center[i] = 0x1000; /* Displace the center for it to move. */ } id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); if (id[nefx] < 0) { @@ -211,7 +208,7 @@ main(int argc, char **argv) efx[nefx].condition.left_sat[i] = 0xFFFF; efx[nefx].condition.right_coeff[i] = 0x2000; efx[nefx].condition.left_coeff[i] = 0x2000; - efx[nefx].condition.deadband[i] = 0x1000; /* 1/16th of axis-range around the center is 'dead'. */ + efx[nefx].condition.deadband[i] = 0x1000; /* 1/16th of axis-range around the center is 'dead'. */ } id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); if (id[nefx] < 0) { @@ -238,14 +235,14 @@ main(int argc, char **argv) } nefx++; } - + /* Now we'll try a ramp effect */ if (supported & SDL_HAPTIC_RAMP) { SDL_Log(" effect %d: Ramp\n", nefx); efx[nefx].type = SDL_HAPTIC_RAMP; efx[nefx].ramp.direction.type = SDL_HAPTIC_CARTESIAN; - efx[nefx].ramp.direction.dir[0] = 1; /* Force comes from */ - efx[nefx].ramp.direction.dir[1] = -1; /* the north-east. */ + efx[nefx].ramp.direction.dir[0] = 1; /* Force comes from */ + efx[nefx].ramp.direction.dir[1] = -1; /* the north-east. */ efx[nefx].ramp.length = 5000; efx[nefx].ramp.start = 0x4000; efx[nefx].ramp.end = -0x4000; @@ -274,13 +271,11 @@ main(int argc, char **argv) nefx++; } - - SDL_Log - ("\nNow playing effects for 5 seconds each with 1 second delay between\n"); + SDL_Log("\nNow playing effects for 5 seconds each with 1 second delay between\n"); for (i = 0; i < nefx; i++) { SDL_Log(" Playing effect %d\n", i); SDL_HapticRunEffect(haptic, id[i], 1); - SDL_Delay(6000); /* Effects only have length 5000 */ + SDL_Delay(6000); /* Effects only have length 5000 */ } /* Quit */ @@ -292,7 +287,6 @@ main(int argc, char **argv) return 0; } - /* * Cleans up a bit. */ @@ -307,18 +301,17 @@ abort_execution(void) exit(1); } - /* * Displays information about the haptic device. */ static void -HapticPrintSupported(SDL_Haptic * ptr) +HapticPrintSupported(SDL_Haptic *ptr) { unsigned int supported; supported = SDL_HapticQuery(ptr); SDL_Log(" Supported effects [%d effects, %d playing]:\n", - SDL_HapticNumEffects(ptr), SDL_HapticNumEffectsPlaying(ptr)); + SDL_HapticNumEffects(ptr), SDL_HapticNumEffectsPlaying(ptr)); if (supported & SDL_HAPTIC_CONSTANT) { SDL_Log(" constant\n"); } diff --git a/test/testhittesting.c b/test/testhittesting.c index 24444db26..92ddf8c42 100644 --- a/test/testhittesting.c +++ b/test/testhittesting.c @@ -29,9 +29,10 @@ hitTest(SDL_Window *window, const SDL_Point *pt, void *data) SDL_GetWindowSize(window, &w, &h); - #define REPORT_RESIZE_HIT(name) { \ +#define REPORT_RESIZE_HIT(name) \ + { \ SDL_Log("HIT-TEST: RESIZE_" #name "\n"); \ - return SDL_HITTEST_RESIZE_##name; \ + return SDL_HITTEST_RESIZE_##name; \ } if (pt->x < RESIZE_BORDER && pt->y < RESIZE_BORDER) { @@ -56,7 +57,6 @@ hitTest(SDL_Window *window, const SDL_Point *pt, void *data) return SDL_HITTEST_NORMAL; } - int main(int argc, char **argv) { int done = 0; @@ -87,39 +87,38 @@ int main(int argc, char **argv) while (SDL_PollEvent(&e)) { nothing_to_do = 0; - switch (e.type) - { - case SDL_MOUSEBUTTONDOWN: - SDL_Log("button down!\n"); - break; + switch (e.type) { + case SDL_MOUSEBUTTONDOWN: + SDL_Log("button down!\n"); + break; - case SDL_MOUSEBUTTONUP: - SDL_Log("button up!\n"); - break; + case SDL_MOUSEBUTTONUP: + SDL_Log("button up!\n"); + break; - case SDL_WINDOWEVENT: - if (e.window.event == SDL_WINDOWEVENT_MOVED) { - SDL_Log("Window event moved to (%d, %d)!\n", (int) e.window.data1, (int) e.window.data2); - } - break; + case SDL_WINDOWEVENT: + if (e.window.event == SDL_WINDOWEVENT_MOVED) { + SDL_Log("Window event moved to (%d, %d)!\n", (int)e.window.data1, (int)e.window.data2); + } + break; - case SDL_KEYDOWN: - if (e.key.keysym.sym == SDLK_ESCAPE) { - done = 1; - } else if (e.key.keysym.sym == SDLK_x) { - if (areas == NULL) { - areas = drag_areas; - numareas = SDL_arraysize(drag_areas); - } else { - areas = NULL; - numareas = 0; - } - } - break; - - case SDL_QUIT: + case SDL_KEYDOWN: + if (e.key.keysym.sym == SDLK_ESCAPE) { done = 1; - break; + } else if (e.key.keysym.sym == SDLK_x) { + if (areas == NULL) { + areas = drag_areas; + numareas = SDL_arraysize(drag_areas); + } else { + areas = NULL; + numareas = 0; + } + } + break; + + case SDL_QUIT: + done = 1; + break; } } diff --git a/test/testhotplug.c b/test/testhotplug.c index 10b1b1b0e..a0854f8d6 100644 --- a/test/testhotplug.c +++ b/test/testhotplug.c @@ -20,8 +20,7 @@ #if !defined SDL_JOYSTICK_DISABLED && !defined SDL_HAPTIC_DISABLED -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { SDL_Joystick *joystick = NULL; SDL_Haptic *haptic = NULL; @@ -30,7 +29,7 @@ main(int argc, char *argv[]) int i; SDL_bool enable_haptic = SDL_TRUE; Uint32 init_subsystems = SDL_INIT_VIDEO | SDL_INIT_JOYSTICK; - + for (i = 1; i < argc; ++i) { if (SDL_strcasecmp(argv[i], "--nohaptic") == 0) { enable_haptic = SDL_FALSE; @@ -40,7 +39,7 @@ main(int argc, char *argv[]) if (enable_haptic) { init_subsystems |= SDL_INIT_HAPTIC; } - + /* Enable standard application logging */ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); @@ -64,72 +63,71 @@ main(int argc, char *argv[]) while (keepGoing) { SDL_Event event; while (SDL_PollEvent(&event)) { - switch(event.type) - { - case SDL_QUIT: - keepGoing = SDL_FALSE; - break; - case SDL_JOYDEVICEADDED: - if (joystick != NULL) { - SDL_Log("Only one joystick supported by this test\n"); - } else { - joystick = SDL_JoystickOpen(event.jdevice.which); - instance = SDL_JoystickInstanceID(joystick); - SDL_Log("Joy Added : %" SDL_PRIs32 " : %s\n", event.jdevice.which, SDL_JoystickName(joystick)); - if (enable_haptic) { - if (SDL_JoystickIsHaptic(joystick)) { - haptic = SDL_HapticOpenFromJoystick(joystick); - if (haptic) { - SDL_Log("Joy Haptic Opened\n"); - if (SDL_HapticRumbleInit( haptic ) != 0) { - SDL_Log("Could not init Rumble!: %s\n", SDL_GetError()); - SDL_HapticClose(haptic); - haptic = NULL; - } - } else { - SDL_Log("Joy haptic open FAILED!: %s\n", SDL_GetError()); + switch (event.type) { + case SDL_QUIT: + keepGoing = SDL_FALSE; + break; + case SDL_JOYDEVICEADDED: + if (joystick != NULL) { + SDL_Log("Only one joystick supported by this test\n"); + } else { + joystick = SDL_JoystickOpen(event.jdevice.which); + instance = SDL_JoystickInstanceID(joystick); + SDL_Log("Joy Added : %" SDL_PRIs32 " : %s\n", event.jdevice.which, SDL_JoystickName(joystick)); + if (enable_haptic) { + if (SDL_JoystickIsHaptic(joystick)) { + haptic = SDL_HapticOpenFromJoystick(joystick); + if (haptic) { + SDL_Log("Joy Haptic Opened\n"); + if (SDL_HapticRumbleInit(haptic) != 0) { + SDL_Log("Could not init Rumble!: %s\n", SDL_GetError()); + SDL_HapticClose(haptic); + haptic = NULL; } } else { - SDL_Log("No haptic found\n"); + SDL_Log("Joy haptic open FAILED!: %s\n", SDL_GetError()); } + } else { + SDL_Log("No haptic found\n"); } } - break; - case SDL_JOYDEVICEREMOVED: - if (instance == event.jdevice.which) { - SDL_Log("Joy Removed: %" SDL_PRIs32 "\n", event.jdevice.which); - instance = -1; - if (enable_haptic && haptic) { - SDL_HapticClose(haptic); - haptic = NULL; - } - SDL_JoystickClose(joystick); - joystick = NULL; - } else { - SDL_Log("Unknown joystick diconnected\n"); - } - break; - case SDL_JOYAXISMOTION: -/* -// SDL_Log("Axis Move: %d\n", event.jaxis.axis); -*/ - if (enable_haptic) { - SDL_HapticRumblePlay(haptic, 0.25, 250); - } - break; - case SDL_JOYBUTTONDOWN: - SDL_Log("Button Press: %d\n", event.jbutton.button); + } + break; + case SDL_JOYDEVICEREMOVED: + if (instance == event.jdevice.which) { + SDL_Log("Joy Removed: %" SDL_PRIs32 "\n", event.jdevice.which); + instance = -1; if (enable_haptic && haptic) { - SDL_HapticRumblePlay(haptic, 0.25, 250); + SDL_HapticClose(haptic); + haptic = NULL; } - if (event.jbutton.button == 0) { - SDL_Log("Exiting due to button press of button 0\n"); - keepGoing = SDL_FALSE; - } - break; - case SDL_JOYBUTTONUP: - SDL_Log("Button Release: %d\n", event.jbutton.button); - break; + SDL_JoystickClose(joystick); + joystick = NULL; + } else { + SDL_Log("Unknown joystick diconnected\n"); + } + break; + case SDL_JOYAXISMOTION: + /* + // SDL_Log("Axis Move: %d\n", event.jaxis.axis); + */ + if (enable_haptic) { + SDL_HapticRumblePlay(haptic, 0.25, 250); + } + break; + case SDL_JOYBUTTONDOWN: + SDL_Log("Button Press: %d\n", event.jbutton.button); + if (enable_haptic && haptic) { + SDL_HapticRumblePlay(haptic, 0.25, 250); + } + if (event.jbutton.button == 0) { + SDL_Log("Exiting due to button press of button 0\n"); + keepGoing = SDL_FALSE; + } + break; + case SDL_JOYBUTTONUP: + SDL_Log("Button Release: %d\n", event.jbutton.button); + break; } } } diff --git a/test/testiconv.c b/test/testiconv.c index e437fe9fb..084821a37 100644 --- a/test/testiconv.c +++ b/test/testiconv.c @@ -12,7 +12,7 @@ /* quiet windows compiler warnings */ #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) -# define _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_WARNINGS #endif #include @@ -24,15 +24,14 @@ static size_t widelen(char *data) { size_t len = 0; - Uint32 *p = (Uint32 *) data; + Uint32 *p = (Uint32 *)data; while (*p++) { ++len; } return len; } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { const char *formats[] = { "UTF8", @@ -49,7 +48,7 @@ main(int argc, char *argv[]) "UCS-4", }; - char * fname; + char *fname; char buffer[BUFSIZ]; char *ucs4; char *test[2]; diff --git a/test/testime.c b/test/testime.c index 0d6d4fecc..c0e580c16 100644 --- a/test/testime.c +++ b/test/testime.c @@ -42,30 +42,31 @@ static SDLTest_CommonState *state; static SDL_Rect textRect, markedRect; -static SDL_Color lineColor = {0,0,0,255}; -static SDL_Color backColor = {255,255,255,255}; -static SDL_Color textColor = {0,0,0,255}; +static SDL_Color lineColor = { 0, 0, 0, 255 }; +static SDL_Color backColor = { 255, 255, 255, 255 }; +static SDL_Color textColor = { 0, 0, 0, 255 }; static char text[MAX_TEXT_LENGTH], markedText[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; static int cursor = 0; #ifdef HAVE_SDL_TTF static TTF_Font *font; #else -#define UNIFONT_MAX_CODEPOINT 0x1ffff -#define UNIFONT_NUM_GLYPHS 0x20000 +#define UNIFONT_MAX_CODEPOINT 0x1ffff +#define UNIFONT_NUM_GLYPHS 0x20000 /* Using 512x512 textures that are supported everywhere. */ -#define UNIFONT_TEXTURE_WIDTH 512 -#define UNIFONT_GLYPHS_IN_ROW (UNIFONT_TEXTURE_WIDTH / 16) +#define UNIFONT_TEXTURE_WIDTH 512 +#define UNIFONT_GLYPHS_IN_ROW (UNIFONT_TEXTURE_WIDTH / 16) #define UNIFONT_GLYPHS_IN_TEXTURE (UNIFONT_GLYPHS_IN_ROW * UNIFONT_GLYPHS_IN_ROW) -#define UNIFONT_NUM_TEXTURES ((UNIFONT_NUM_GLYPHS + UNIFONT_GLYPHS_IN_TEXTURE - 1) / UNIFONT_GLYPHS_IN_TEXTURE) -#define UNIFONT_TEXTURE_SIZE (UNIFONT_TEXTURE_WIDTH * UNIFONT_TEXTURE_WIDTH * 4) -#define UNIFONT_TEXTURE_PITCH (UNIFONT_TEXTURE_WIDTH * 4) -#define UNIFONT_DRAW_SCALE 2 -struct UnifontGlyph { +#define UNIFONT_NUM_TEXTURES ((UNIFONT_NUM_GLYPHS + UNIFONT_GLYPHS_IN_TEXTURE - 1) / UNIFONT_GLYPHS_IN_TEXTURE) +#define UNIFONT_TEXTURE_SIZE (UNIFONT_TEXTURE_WIDTH * UNIFONT_TEXTURE_WIDTH * 4) +#define UNIFONT_TEXTURE_PITCH (UNIFONT_TEXTURE_WIDTH * 4) +#define UNIFONT_DRAW_SCALE 2 +struct UnifontGlyph +{ Uint8 width; Uint8 data[32]; -} *unifontGlyph; +} * unifontGlyph; static SDL_Texture **unifontTexture; -static Uint8 unifontTextureLoaded[UNIFONT_NUM_TEXTURES] = {0}; +static Uint8 unifontTextureLoaded[UNIFONT_NUM_TEXTURES] = { 0 }; /* Unifont loading code start */ @@ -151,7 +152,7 @@ static int unifont_init(const char *fontname) bytesRead = SDL_RWread(hexFile, hexBuffer, 1, 9); if (numGlyphs > 0 && bytesRead == 0) { break; /* EOF */ - } + } if ((numGlyphs == 0 && bytesRead == 0) || (numGlyphs > 0 && bytesRead < 9)) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Unexpected end of hex file.\n"); return -1; @@ -259,7 +260,7 @@ static void unifont_make_rgba(Uint8 *src, Uint8 *dst, Uint8 width) static int unifont_load_texture(Uint32 textureID) { int i; - Uint8 * textureRGBA; + Uint8 *textureRGBA; if (textureID >= UNIFONT_NUM_TEXTURES) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Tried to load out of range texture %" SDL_PRIu32 "\n", textureID); @@ -363,7 +364,7 @@ size_t utf8_length(unsigned char c) c = (unsigned char)(0xff & c); if (c < 0x80) return 1; - else if ((c >> 5) ==0x6) + else if ((c >> 5) == 0x6) return 2; else if ((c >> 4) == 0xe) return 3; @@ -455,13 +456,13 @@ void CleanupVideo() void _Redraw(int rendererID) { - SDL_Renderer * renderer = state->renderers[rendererID]; + SDL_Renderer *renderer = state->renderers[rendererID]; SDL_Rect drawnTextRect, cursorRect, underlineRect; drawnTextRect = textRect; drawnTextRect.w = 0; SDL_SetRenderDrawColor(renderer, backColor.r, backColor.g, backColor.b, backColor.a); - SDL_RenderFillRect(renderer,&textRect); + SDL_RenderFillRect(renderer, &textRect); if (*text) { #ifdef HAVE_SDL_TTF @@ -473,10 +474,10 @@ void _Redraw(int rendererID) drawnTextRect.w = textSur->w; drawnTextRect.h = textSur->h; - texture = SDL_CreateTextureFromSurface(renderer,textSur); + texture = SDL_CreateTextureFromSurface(renderer, textSur); SDL_FreeSurface(textSur); - SDL_RenderCopy(renderer,texture,NULL,&drawnTextRect); + SDL_RenderCopy(renderer, texture, NULL, &drawnTextRect); SDL_DestroyTexture(texture); #else char *utext = text; @@ -519,7 +520,7 @@ void _Redraw(int rendererID) drawnTextRect.w = 0; SDL_SetRenderDrawColor(renderer, backColor.r, backColor.g, backColor.b, backColor.a); - SDL_RenderFillRect(renderer,&markedRect); + SDL_RenderFillRect(renderer, &markedRect); if (markedText[0]) { #ifdef HAVE_SDL_TTF @@ -544,10 +545,10 @@ void _Redraw(int rendererID) drawnTextRect.w = textSur->w; drawnTextRect.h = textSur->h; - texture = SDL_CreateTextureFromSurface(renderer,textSur); + texture = SDL_CreateTextureFromSurface(renderer, textSur); SDL_FreeSurface(textSur); - SDL_RenderCopy(renderer,texture,NULL,&drawnTextRect); + SDL_RenderCopy(renderer, texture, NULL, &drawnTextRect); SDL_DestroyTexture(texture); #else int i = 0; @@ -590,7 +591,7 @@ void _Redraw(int rendererID) } SDL_SetRenderDrawColor(renderer, lineColor.r, lineColor.g, lineColor.b, lineColor.a); - SDL_RenderFillRect(renderer,&cursorRect); + SDL_RenderFillRect(renderer, &cursorRect); SDL_SetTextInputRect(&markedRect); } @@ -627,7 +628,7 @@ int main(int argc, char *argv[]) if (state == NULL) { return 1; } - for (i = 1; i < argc;i++) { + for (i = 1; i < argc; i++) { SDLTest_CommonArg(state, i); } for (argc--, argv++; argc > 0; argc--, argv++) { @@ -653,7 +654,6 @@ int main(int argc, char *argv[]) return 2; } - #ifdef HAVE_SDL_TTF /* Initialize fonts */ TTF_Init(); @@ -686,86 +686,84 @@ int main(int argc, char *argv[]) /* Check for events */ while (SDL_PollEvent(&event)) { SDLTest_CommonEvent(state, &event, &done); - switch(event.type) { - case SDL_KEYDOWN: { - switch (event.key.keysym.sym) - { - case SDLK_RETURN: - text[0]=0x00; - Redraw(); - break; - case SDLK_BACKSPACE: - /* Only delete text if not in editing mode. */ - if (!markedText[0]) { - size_t textlen = SDL_strlen(text); - - do { - if (textlen==0) { - break; - } - if ((text[textlen-1] & 0x80) == 0x00) { - /* One byte */ - text[textlen-1]=0x00; - break; - } - if ((text[textlen-1] & 0xC0) == 0x80) { - /* Byte from the multibyte sequence */ - text[textlen-1]=0x00; - textlen--; - } - if ((text[textlen-1] & 0xC0) == 0xC0) { - /* First byte of multibyte sequence */ - text[textlen-1]=0x00; - break; - } - } while (1); - - Redraw(); - } - break; - } - - if (done) { - break; - } - - SDL_Log("Keyboard: scancode 0x%08X = %s, keycode 0x%08" SDL_PRIX32 " = %s\n", - event.key.keysym.scancode, - SDL_GetScancodeName(event.key.keysym.scancode), - SDL_static_cast(Uint32, event.key.keysym.sym), - SDL_GetKeyName(event.key.keysym.sym)); - break; - - case SDL_TEXTINPUT: - if (event.text.text[0] == '\0' || event.text.text[0] == '\n' || markedRect.w < 0) { - break; - } - - SDL_Log("Keyboard: text input \"%s\"\n", event.text.text); - - if (SDL_strlen(text) + SDL_strlen(event.text.text) < sizeof(text)) { - SDL_strlcat(text, event.text.text, sizeof(text)); - } - - SDL_Log("text inputed: %s\n", text); - - /* After text inputed, we can clear up markedText because it */ - /* is committed */ - markedText[0] = 0; + switch (event.type) { + case SDL_KEYDOWN: + { + switch (event.key.keysym.sym) { + case SDLK_RETURN: + text[0] = 0x00; Redraw(); break; + case SDLK_BACKSPACE: + /* Only delete text if not in editing mode. */ + if (!markedText[0]) { + size_t textlen = SDL_strlen(text); - case SDL_TEXTEDITING: - SDL_Log("text editing \"%s\", selected range (%" SDL_PRIs32 ", %" SDL_PRIs32 ")\n", - event.edit.text, event.edit.start, event.edit.length); + do { + if (textlen == 0) { + break; + } + if ((text[textlen - 1] & 0x80) == 0x00) { + /* One byte */ + text[textlen - 1] = 0x00; + break; + } + if ((text[textlen - 1] & 0xC0) == 0x80) { + /* Byte from the multibyte sequence */ + text[textlen - 1] = 0x00; + textlen--; + } + if ((text[textlen - 1] & 0xC0) == 0xC0) { + /* First byte of multibyte sequence */ + text[textlen - 1] = 0x00; + break; + } + } while (1); - SDL_strlcpy(markedText, event.edit.text, SDL_TEXTEDITINGEVENT_TEXT_SIZE); - cursor = event.edit.start; - Redraw(); + Redraw(); + } break; } + + if (done) { + break; + } + + SDL_Log("Keyboard: scancode 0x%08X = %s, keycode 0x%08" SDL_PRIX32 " = %s\n", + event.key.keysym.scancode, + SDL_GetScancodeName(event.key.keysym.scancode), + SDL_static_cast(Uint32, event.key.keysym.sym), + SDL_GetKeyName(event.key.keysym.sym)); break; + case SDL_TEXTINPUT: + if (event.text.text[0] == '\0' || event.text.text[0] == '\n' || markedRect.w < 0) { + break; + } + + SDL_Log("Keyboard: text input \"%s\"\n", event.text.text); + + if (SDL_strlen(text) + SDL_strlen(event.text.text) < sizeof(text)) { + SDL_strlcat(text, event.text.text, sizeof(text)); + } + + SDL_Log("text inputed: %s\n", text); + + /* After text inputed, we can clear up markedText because it */ + /* is committed */ + markedText[0] = 0; + Redraw(); + break; + + case SDL_TEXTEDITING: + SDL_Log("text editing \"%s\", selected range (%" SDL_PRIs32 ", %" SDL_PRIs32 ")\n", + event.edit.text, event.edit.start, event.edit.length); + + SDL_strlcpy(markedText, event.edit.text, SDL_TEXTEDITINGEVENT_TEXT_SIZE); + cursor = event.edit.start; + Redraw(); + break; + } break; } } } diff --git a/test/testintersections.c b/test/testintersections.c index 1216adc0c..ac21da074 100644 --- a/test/testintersections.c +++ b/test/testintersections.c @@ -22,7 +22,12 @@ #include "SDL_test_common.h" -#define SWAP(typ,a,b) do{typ t=a;a=b;b=t;}while (0) +#define SWAP(typ, a, b) \ + do { \ + typ t = a; \ + a = b; \ + b = t; \ + } while (0) #define NUM_OBJECTS 100 static SDLTest_CommonState *state; @@ -37,8 +42,7 @@ static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE; int mouse_begin_x = -1, mouse_begin_y = -1; int done; -void -DrawPoints(SDL_Renderer * renderer) +void DrawPoints(SDL_Renderer *renderer) { int i; int x, y; @@ -71,8 +75,8 @@ DrawPoints(SDL_Renderer * renderer) cycle_direction = -cycle_direction; } } - SDL_SetRenderDrawColor(renderer, 255, (Uint8) current_color, - (Uint8) current_color, (Uint8) current_alpha); + SDL_SetRenderDrawColor(renderer, 255, (Uint8)current_color, + (Uint8)current_color, (Uint8)current_alpha); x = rand() % viewport.w; y = rand() % viewport.h; @@ -102,9 +106,7 @@ add_line(int x1, int y1, int x2, int y2) return ++num_lines; } - -void -DrawLines(SDL_Renderer * renderer) +void DrawLines(SDL_Renderer *renderer) { int i; SDL_Rect viewport; @@ -147,7 +149,7 @@ add_rect(int x1, int y1, int x2, int y2) } SDL_Log("adding rect (%d, %d), (%d, %d) [%dx%d]\n", x1, y1, x2, y2, - x2 - x1, y2 - y1); + x2 - x1, y2 - y1); rects[num_rects].x = x1; rects[num_rects].y = y1; @@ -158,14 +160,14 @@ add_rect(int x1, int y1, int x2, int y2) } static void -DrawRects(SDL_Renderer * renderer) +DrawRects(SDL_Renderer *renderer) { SDL_SetRenderDrawColor(renderer, 255, 127, 0, 255); SDL_RenderFillRects(renderer, rects, num_rects); } static void -DrawRectLineIntersections(SDL_Renderer * renderer) +DrawRectLineIntersections(SDL_Renderer *renderer) { int i, j; @@ -189,7 +191,7 @@ DrawRectLineIntersections(SDL_Renderer * renderer) } static void -DrawRectRectIntersections(SDL_Renderer * renderer) +DrawRectRectIntersections(SDL_Renderer *renderer) { int i, j; @@ -204,8 +206,7 @@ DrawRectRectIntersections(SDL_Renderer * renderer) } } -void -loop() +void loop() { int i; SDL_Event event; @@ -271,8 +272,7 @@ loop() #endif } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i; Uint32 then, now, frames; @@ -361,7 +361,7 @@ main(int argc, char *argv[]) /* Print out some timing information */ now = SDL_GetTicks(); if (now > then) { - double fps = ((double) frames * 1000) / (now - then); + double fps = ((double)frames * 1000) / (now - then); SDL_Log("%2.2f frames per second\n", fps); } return 0; diff --git a/test/testjoystick.c b/test/testjoystick.c index e20618ca6..b2533e05f 100644 --- a/test/testjoystick.c +++ b/test/testjoystick.c @@ -28,8 +28,8 @@ #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 480 #else -#define SCREEN_WIDTH 640 -#define SCREEN_HEIGHT 480 +#define SCREEN_WIDTH 640 +#define SCREEN_HEIGHT 480 #endif static SDL_Window *window = NULL; @@ -44,7 +44,7 @@ PrintJoystick(SDL_Joystick *joy) char guid[64]; SDL_assert(SDL_JoystickFromInstanceID(SDL_JoystickInstanceID(joy)) == joy); - SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joy), guid, sizeof (guid)); + SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joy), guid, sizeof(guid)); switch (SDL_JoystickGetType(joy)) { case SDL_JOYSTICK_TYPE_GAMECONTROLLER: type = "Game Controller"; @@ -103,8 +103,7 @@ DrawRect(SDL_Renderer *r, const int x, const int y, const int w, const int h) SDL_RenderFillRect(r, &area); } -void -loop(void *arg) +void loop(void *arg) { SDL_Event event; int i; @@ -117,7 +116,7 @@ loop(void *arg) switch (event.type) { case SDL_JOYDEVICEADDED: - SDL_Log("Joystick device %d added.\n", (int) event.jdevice.which); + SDL_Log("Joystick device %d added.\n", (int)event.jdevice.which); if (joystick == NULL) { joystick = SDL_JoystickOpen(event.jdevice.which); if (joystick) { @@ -129,7 +128,7 @@ loop(void *arg) break; case SDL_JOYDEVICEREMOVED: - SDL_Log("Joystick device %d removed.\n", (int) event.jdevice.which); + SDL_Log("Joystick device %d removed.\n", (int)event.jdevice.which); if (event.jdevice.which == SDL_JoystickInstanceID(joystick)) { SDL_JoystickClose(joystick); joystick = SDL_JoystickOpen(0); @@ -222,7 +221,7 @@ loop(void *arg) SDL_SetRenderDrawColor(screen, 0xFF, 0x00, 0x00, SDL_ALPHA_OPAQUE); for (i = 0; i < SDL_JoystickNumAxes(joystick); ++i) { /* Draw the X/Y axis */ - x = (((int) SDL_JoystickGetAxis(joystick, i)) + 32768); + x = (((int)SDL_JoystickGetAxis(joystick, i)) + 32768); x *= SCREEN_WIDTH; x /= 65535; if (x < 0) { @@ -232,7 +231,7 @@ loop(void *arg) } ++i; if (i < SDL_JoystickNumAxes(joystick)) { - y = (((int) SDL_JoystickGetAxis(joystick, i)) + 32768); + y = (((int)SDL_JoystickGetAxis(joystick, i)) + 32768); } else { y = 32768; } @@ -251,19 +250,19 @@ loop(void *arg) for (i = 0; i < SDL_JoystickNumHats(joystick); ++i) { /* Derive the new position */ const Uint8 hat_pos = SDL_JoystickGetHat(joystick, i); - x = SCREEN_WIDTH/2; - y = SCREEN_HEIGHT/2; + x = SCREEN_WIDTH / 2; + y = SCREEN_HEIGHT / 2; if (hat_pos & SDL_HAT_UP) { y = 0; } else if (hat_pos & SDL_HAT_DOWN) { - y = SCREEN_HEIGHT-8; + y = SCREEN_HEIGHT - 8; } if (hat_pos & SDL_HAT_LEFT) { x = 0; } else if (hat_pos & SDL_HAT_RIGHT) { - x = SCREEN_WIDTH-8; + x = SCREEN_WIDTH - 8; } DrawRect(screen, x, y, 8, 8); @@ -280,8 +279,7 @@ loop(void *arg) #endif } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0"); diff --git a/test/testkeys.c b/test/testkeys.c index e52935981..ed7ac086c 100644 --- a/test/testkeys.c +++ b/test/testkeys.c @@ -19,8 +19,7 @@ #include "SDL.h" -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { SDL_Scancode scancode; @@ -33,7 +32,7 @@ main(int argc, char *argv[]) } for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) { SDL_Log("Scancode #%d, \"%s\"\n", scancode, - SDL_GetScancodeName(scancode)); + SDL_GetScancodeName(scancode)); } SDL_Quit(); return 0; diff --git a/test/testloadso.c b/test/testloadso.c index 830352558..1665814fa 100644 --- a/test/testloadso.c +++ b/test/testloadso.c @@ -11,7 +11,7 @@ */ /* Test program to test dynamic loading with the loadso subsystem. -*/ + */ #include #include @@ -19,10 +19,9 @@ #include "SDL.h" -typedef int (*fntype) (const char *); +typedef int (*fntype)(const char *); -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int retval = 0; int hello = 0; @@ -56,13 +55,13 @@ main(int argc, char *argv[]) lib = SDL_LoadObject(libname); if (lib == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadObject('%s') failed: %s\n", - libname, SDL_GetError()); + libname, SDL_GetError()); retval = 3; } else { - fn = (fntype) SDL_LoadFunction(lib, symname); + fn = (fntype)SDL_LoadFunction(lib, symname); if (fn == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadFunction('%s') failed: %s\n", - symname, SDL_GetError()); + symname, SDL_GetError()); retval = 4; } else { SDL_Log("Found %s in %s at %p\n", symname, libname, fn); diff --git a/test/testlocale.c b/test/testlocale.c index 3a4a6f041..e1607682c 100644 --- a/test/testlocale.c +++ b/test/testlocale.c @@ -61,7 +61,7 @@ int main(int argc, char **argv) SDL_Quit(); } - return 0; + return 0; } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/test/testlock.c b/test/testlock.c index b0e7f0c6e..3b48d3468 100644 --- a/test/testlock.c +++ b/test/testlock.c @@ -35,21 +35,18 @@ SDL_Quit_Wrapper(void) SDL_Quit(); } -void -printid(void) +void printid(void) { SDL_Log("Process %lu: exiting\n", SDL_ThreadID()); } -void -terminate(int sig) +void terminate(int sig) { signal(SIGINT, terminate); SDL_AtomicSet(&doterminate, 1); } -void -closemutex(int sig) +void closemutex(int sig) { SDL_threadID id = SDL_ThreadID(); int i; @@ -91,8 +88,7 @@ Run(void *data) return 0; } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i; int maxproc = 6; @@ -119,7 +115,7 @@ main(int argc, char *argv[]) atexit(printid); for (i = 0; i < maxproc; ++i) { char name[64]; - SDL_snprintf(name, sizeof (name), "Worker%d", i); + SDL_snprintf(name, sizeof(name), "Worker%d", i); if ((threads[i] = SDL_CreateThread(Run, name, NULL)) == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread!\n"); } @@ -127,5 +123,5 @@ main(int argc, char *argv[]) signal(SIGINT, terminate); Run(NULL); - return 0; /* Never reached */ + return 0; /* Never reached */ } diff --git a/test/testmessage.c b/test/testmessage.c index 88c672576..478e9fd6a 100644 --- a/test/testmessage.c +++ b/test/testmessage.c @@ -29,15 +29,12 @@ static int SDLCALL button_messagebox(void *eventNumber) { const SDL_MessageBoxButtonData buttons[] = { - { - SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, - 0, - "OK" - },{ - SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, - 1, - "Cancel" - }, + { SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, + 0, + "OK" }, + { SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, + 1, + "Cancel" }, }; SDL_MessageBoxData data = { @@ -46,8 +43,8 @@ button_messagebox(void *eventNumber) "Custom MessageBox", "This is a custom messagebox", 2, - NULL,/* buttons */ - NULL /* Default color scheme */ + NULL, /* buttons */ + NULL /* Default color scheme */ }; int button = -1; @@ -69,7 +66,8 @@ button_messagebox(void *eventNumber) quit(2); } } - SDL_Log("Pressed button: %d, %s\n", button, button == -1 ? "[closed]" : button == 1 ? "Cancel" : "OK"); + SDL_Log("Pressed button: %d, %s\n", button, button == -1 ? "[closed]" : button == 1 ? "Cancel" + : "OK"); if (eventNumber) { SDL_Event event; @@ -80,8 +78,7 @@ button_messagebox(void *eventNumber) return 0; } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int success; @@ -89,36 +86,36 @@ main(int argc, char *argv[]) SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "Simple MessageBox", - "This is a simple error MessageBox", - NULL); + "Simple MessageBox", + "This is a simple error MessageBox", + NULL); if (success == -1) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); quit(1); } success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "Simple MessageBox", - "This is a simple MessageBox with a newline:\r\nHello world!", - NULL); + "Simple MessageBox", + "This is a simple MessageBox with a newline:\r\nHello world!", + NULL); if (success == -1) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); quit(1); } success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - NULL, - "NULL Title", - NULL); + NULL, + "NULL Title", + NULL); if (success == -1) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); quit(1); } success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "NULL Message", - NULL, - NULL); + "NULL Message", + NULL, + NULL); if (success == -1) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); quit(1); @@ -126,9 +123,9 @@ main(int argc, char *argv[]) /* Google says this is Traditional Chinese for "beef with broccoli" */ success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "UTF-8 Simple MessageBox", - "Unicode text: '牛肉西蘭花' ...", - NULL); + "UTF-8 Simple MessageBox", + "Unicode text: '牛肉西蘭花' ...", + NULL); if (success == -1) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); quit(1); @@ -136,9 +133,9 @@ main(int argc, char *argv[]) /* Google says this is Traditional Chinese for "beef with broccoli" */ success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "UTF-8 Simple MessageBox", - "Unicode text and newline:\r\n'牛肉西蘭花'\n'牛肉西蘭花'", - NULL); + "UTF-8 Simple MessageBox", + "Unicode text and newline:\r\n'牛肉西蘭花'\n'牛肉西蘭花'", + NULL); if (success == -1) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); quit(1); @@ -146,9 +143,9 @@ main(int argc, char *argv[]) /* Google says this is Traditional Chinese for "beef with broccoli" */ success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "牛肉西蘭花", - "Unicode text in the title.", - NULL); + "牛肉西蘭花", + "Unicode text in the title.", + NULL); if (success == -1) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); quit(1); @@ -170,7 +167,7 @@ main(int argc, char *argv[]) int status = 0; SDL_Event event; intptr_t eventNumber = SDL_RegisterEvents(1); - SDL_Thread* thread = SDL_CreateThread(&button_messagebox, "MessageBox", (void*)eventNumber); + SDL_Thread *thread = SDL_CreateThread(&button_messagebox, "MessageBox", (void *)eventNumber); while (SDL_WaitEvent(&event)) { if (event.type == eventNumber) { @@ -195,9 +192,9 @@ main(int argc, char *argv[]) SDL_RenderPresent(renderer); success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "Simple MessageBox", - "This is a simple error MessageBox with a parent window. Press a key or close the window after dismissing this messagebox.", - window); + "Simple MessageBox", + "This is a simple error MessageBox with a parent window. Press a key or close the window after dismissing this messagebox.", + window); if (success == -1) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); quit(1); diff --git a/test/testmouse.c b/test/testmouse.c index 6b3f4ce27..598eadd5a 100644 --- a/test/testmouse.c +++ b/test/testmouse.c @@ -22,13 +22,14 @@ #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 480 #else -#define SCREEN_WIDTH 640 -#define SCREEN_HEIGHT 480 +#define SCREEN_WIDTH 640 +#define SCREEN_HEIGHT 480 #endif static SDL_Window *window; -typedef struct _Object { +typedef struct _Object +{ struct _Object *next; int x1, y1, x2, y2; @@ -49,8 +50,7 @@ static float wheel_y = SCREEN_HEIGHT * 0.5f; static SDL_bool done = SDL_FALSE; -void -DrawObject(SDL_Renderer * renderer, Object * object) +void DrawObject(SDL_Renderer *renderer, Object *object) { SDL_SetRenderDrawColor(renderer, object->r, object->g, object->b, 255); @@ -80,8 +80,7 @@ DrawObject(SDL_Renderer * renderer, Object * object) } } -void -DrawObjects(SDL_Renderer * renderer) +void DrawObjects(SDL_Renderer *renderer) { Object *next = objects; while (next != NULL) { @@ -90,8 +89,7 @@ DrawObjects(SDL_Renderer * renderer) } } -void -AppendObject(Object *object) +void AppendObject(Object *object) { if (objects) { Object *next = objects; @@ -104,8 +102,7 @@ AppendObject(Object *object) } } -void -loop(void *arg) +void loop(void *arg) { SDL_Renderer *renderer = (SDL_Renderer *)arg; SDL_Event event; @@ -114,23 +111,23 @@ loop(void *arg) while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_MOUSEWHEEL: - if (event.wheel.direction == SDL_MOUSEWHEEL_FLIPPED) { - event.wheel.preciseX *= -1.0f; - event.wheel.preciseY *= -1.0f; - event.wheel.x *= -1; - event.wheel.y *= -1; - } - if (event.wheel.preciseX != 0.0f) { - wheel_x_active = SDL_TRUE; - /* "positive to the right and negative to the left" */ - wheel_x += event.wheel.preciseX * 10.0f; - } - if (event.wheel.preciseY != 0.0f) { - wheel_y_active = SDL_TRUE; - /* "positive away from the user and negative towards the user" */ - wheel_y -= event.wheel.preciseY * 10.0f; - } - break; + if (event.wheel.direction == SDL_MOUSEWHEEL_FLIPPED) { + event.wheel.preciseX *= -1.0f; + event.wheel.preciseY *= -1.0f; + event.wheel.x *= -1; + event.wheel.y *= -1; + } + if (event.wheel.preciseX != 0.0f) { + wheel_x_active = SDL_TRUE; + /* "positive to the right and negative to the left" */ + wheel_x += event.wheel.preciseX * 10.0f; + } + if (event.wheel.preciseY != 0.0f) { + wheel_y_active = SDL_TRUE; + /* "positive away from the user and negative towards the user" */ + wheel_y -= event.wheel.preciseY * 10.0f; + } + break; case SDL_MOUSEMOTION: if (active == NULL) { @@ -150,11 +147,28 @@ loop(void *arg) } switch (event.button.button) { - case SDL_BUTTON_LEFT: active->r = 255; buttons |= SDL_BUTTON_LMASK; break; - case SDL_BUTTON_MIDDLE: active->g = 255; buttons |= SDL_BUTTON_MMASK; break; - case SDL_BUTTON_RIGHT: active->b = 255; buttons |= SDL_BUTTON_RMASK; break; - case SDL_BUTTON_X1: active->r = 255; active->b = 255; buttons |= SDL_BUTTON_X1MASK; break; - case SDL_BUTTON_X2: active->g = 255; active->b = 255; buttons |= SDL_BUTTON_X2MASK; break; + case SDL_BUTTON_LEFT: + active->r = 255; + buttons |= SDL_BUTTON_LMASK; + break; + case SDL_BUTTON_MIDDLE: + active->g = 255; + buttons |= SDL_BUTTON_MMASK; + break; + case SDL_BUTTON_RIGHT: + active->b = 255; + buttons |= SDL_BUTTON_RMASK; + break; + case SDL_BUTTON_X1: + active->r = 255; + active->b = 255; + buttons |= SDL_BUTTON_X1MASK; + break; + case SDL_BUTTON_X2: + active->g = 255; + active->b = 255; + buttons |= SDL_BUTTON_X2MASK; + break; } break; @@ -164,11 +178,21 @@ loop(void *arg) } switch (event.button.button) { - case SDL_BUTTON_LEFT: buttons &= ~SDL_BUTTON_LMASK; break; - case SDL_BUTTON_MIDDLE: buttons &= ~SDL_BUTTON_MMASK; break; - case SDL_BUTTON_RIGHT: buttons &= ~SDL_BUTTON_RMASK; break; - case SDL_BUTTON_X1: buttons &= ~SDL_BUTTON_X1MASK; break; - case SDL_BUTTON_X2: buttons &= ~SDL_BUTTON_X2MASK; break; + case SDL_BUTTON_LEFT: + buttons &= ~SDL_BUTTON_LMASK; + break; + case SDL_BUTTON_MIDDLE: + buttons &= ~SDL_BUTTON_MMASK; + break; + case SDL_BUTTON_RIGHT: + buttons &= ~SDL_BUTTON_RMASK; + break; + case SDL_BUTTON_X1: + buttons &= ~SDL_BUTTON_X1MASK; + break; + case SDL_BUTTON_X2: + buttons &= ~SDL_BUTTON_X2MASK; + break; } if (buttons == 0) { @@ -225,8 +249,7 @@ loop(void *arg) #endif } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { SDL_Renderer *renderer; diff --git a/test/testmultiaudio.c b/test/testmultiaudio.c index e4de22861..48171ff24 100644 --- a/test/testmultiaudio.c +++ b/test/testmultiaudio.c @@ -20,8 +20,8 @@ #include "testutils.h" static SDL_AudioSpec spec; -static Uint8 *sound = NULL; /* Pointer to wave data */ -static Uint32 soundlen = 0; /* Length of wave data */ +static Uint8 *sound = NULL; /* Pointer to wave data */ +static Uint32 soundlen = 0; /* Length of wave data */ typedef struct { @@ -33,9 +33,9 @@ typedef struct callback_data cbd[64]; void SDLCALL -play_through_once(void *arg, Uint8 * stream, int len) +play_through_once(void *arg, Uint8 *stream, int len) { - callback_data *cbdata = (callback_data *) arg; + callback_data *cbdata = (callback_data *)arg; Uint8 *waveptr = sound + cbdata->soundpos; int waveleft = soundlen - cbdata->soundpos; int cpy = len; @@ -53,8 +53,7 @@ play_through_once(void *arg, Uint8 * stream, int len) } } -void -loop() +void loop() { if (SDL_AtomicGet(&cbd[0].done)) { #ifdef __EMSCRIPTEN__ @@ -72,17 +71,17 @@ test_multi_audio(int devcount) { int keep_going = 1; int i; - -#ifdef __ANDROID__ + +#ifdef __ANDROID__ SDL_Event event; - + /* Create a Window to get fully initialized event processing for testing pause on Android. */ SDL_CreateWindow("testmultiaudio", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 320, 240, 0); #endif if (devcount > 64) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Too many devices (%d), clamping to 64...\n", - devcount); + devcount); devcount = 64; } @@ -104,10 +103,11 @@ test_multi_audio(int devcount) emscripten_set_main_loop(loop, 0, 1); #else while (!SDL_AtomicGet(&cbd[0].done)) { - #ifdef __ANDROID__ +#ifdef __ANDROID__ /* Empty queue, some application events would prevent pause. */ - while (SDL_PollEvent(&event)) {} - #endif + while (SDL_PollEvent(&event)) { + } +#endif SDL_Delay(100); } SDL_PauseAudioDevice(cbd[0].dev, 1); @@ -142,10 +142,11 @@ test_multi_audio(int devcount) keep_going = 1; } } - #ifdef __ANDROID__ +#ifdef __ANDROID__ /* Empty queue, some application events would prevent pause. */ - while (SDL_PollEvent(&event)) {} - #endif + while (SDL_PollEvent(&event)) { + } +#endif SDL_Delay(100); } @@ -162,9 +163,7 @@ test_multi_audio(int devcount) #endif } - -int -main(int argc, char **argv) +int main(int argc, char **argv) { int devcount = 0; @@ -178,7 +177,7 @@ main(int argc, char **argv) } SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver()); - + devcount = SDL_GetNumAudioDevices(0); if (devcount < 1) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio devices!\n"); @@ -188,7 +187,7 @@ main(int argc, char **argv) /* Load the wave file into memory */ if (SDL_LoadWAV(file, &spec, &sound, &soundlen) == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", file, - SDL_GetError()); + SDL_GetError()); } else { test_multi_audio(devcount); SDL_FreeWAV(sound); diff --git a/test/testnative.c b/test/testnative.c index 7cb28a3b0..ff0973338 100644 --- a/test/testnative.c +++ b/test/testnative.c @@ -13,7 +13,7 @@ #include #include /* for srand() */ -#include /* for time() */ +#include /* for time() */ #include "testnative.h" #include "testutils.h" @@ -53,8 +53,7 @@ quit(int rc) exit(rc); } -void -MoveSprites(SDL_Renderer * renderer, SDL_Texture * sprite) +void MoveSprites(SDL_Renderer *renderer, SDL_Texture *sprite) { int sprite_w, sprite_h; int i; @@ -92,8 +91,7 @@ MoveSprites(SDL_Renderer * renderer, SDL_Texture * sprite) SDL_RenderPresent(renderer); } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i, done; const char *driver; @@ -109,7 +107,7 @@ main(int argc, char *argv[]) if (SDL_VideoInit(NULL) < 0) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video: %s\n", - SDL_GetError()); + SDL_GetError()); exit(1); } driver = SDL_GetCurrentVideoDriver(); @@ -123,7 +121,7 @@ main(int argc, char *argv[]) } if (factory == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find native window code for %s driver\n", - driver); + driver); quit(2); } SDL_Log("Creating native window for %s driver\n", driver); @@ -158,8 +156,8 @@ main(int argc, char *argv[]) /* Allocate memory for the sprite info */ SDL_GetWindowSize(window, &window_w, &window_h); SDL_QueryTexture(sprite, NULL, NULL, &sprite_w, &sprite_h); - positions = (SDL_Rect *) SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect)); - velocities = (SDL_Rect *) SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect)); + positions = (SDL_Rect *)SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect)); + velocities = (SDL_Rect *)SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect)); if (positions == NULL || velocities == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); diff --git a/test/testnative.h b/test/testnative.h index 694f46ec8..88b4d8491 100644 --- a/test/testnative.h +++ b/test/testnative.h @@ -22,8 +22,8 @@ typedef struct { const char *tag; - void *(*CreateNativeWindow) (int w, int h); - void (*DestroyNativeWindow) (void *window); + void *(*CreateNativeWindow)(int w, int h); + void (*DestroyNativeWindow)(void *window); } NativeWindowFactory; #ifdef SDL_VIDEO_DRIVER_WINDOWS diff --git a/test/testnativew32.c b/test/testnativew32.c index a9bf2c779..fa44beb74 100644 --- a/test/testnativew32.c +++ b/test/testnativew32.c @@ -52,7 +52,7 @@ CreateWindowNative(int w, int h) wc.hInstance = GetModuleHandle(NULL); wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1); + wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wc.lpszMenuName = NULL; wc.lpszClassName = "SDL Test"; @@ -80,7 +80,7 @@ CreateWindowNative(int w, int h) static void DestroyWindowNative(void *window) { - DestroyWindow((HWND) window); + DestroyWindow((HWND)window); } #endif diff --git a/test/testnativex11.c b/test/testnativex11.c index f6bd0c0e4..3a414a7c1 100644 --- a/test/testnativex11.c +++ b/test/testnativex11.c @@ -38,14 +38,14 @@ CreateWindowX11(int w, int h) XMapRaised(dpy, window); XSync(dpy, False); } - return (void *) window; + return (void *)window; } static void DestroyWindowX11(void *window) { if (dpy) { - XDestroyWindow(dpy, (Window) window); + XDestroyWindow(dpy, (Window)window); XCloseDisplay(dpy); } } diff --git a/test/testoffscreen.c b/test/testoffscreen.c index 64219df19..c1d7667e1 100644 --- a/test/testoffscreen.c +++ b/test/testoffscreen.c @@ -32,8 +32,7 @@ static int width = 640; static int height = 480; static unsigned int max_frames = 200; -void -draw() +void draw() { SDL_Rect Rect; @@ -51,10 +50,9 @@ draw() SDL_RenderPresent(renderer); } -void -save_surface_to_bmp() +void save_surface_to_bmp() { - SDL_Surface* surface; + SDL_Surface *surface; Uint32 r_mask, g_mask, b_mask, a_mask; Uint32 pixel_format; char file[128]; @@ -73,15 +71,14 @@ save_surface_to_bmp() SDL_FreeSurface(surface); } -void -loop() +void loop() { SDL_Event event; /* Check for events */ while (SDL_PollEvent(&event)) { switch (event.type) { - case SDL_QUIT: + case SDL_QUIT: done = SDL_TRUE; break; } @@ -97,8 +94,7 @@ loop() #endif } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { #ifndef __EMSCRIPTEN__ Uint32 then, now, frames; @@ -110,18 +106,18 @@ main(int argc, char *argv[]) /* Force the offscreen renderer, if it cannot be created then fail out */ if (SDL_VideoInit("offscreen") < 0) { SDL_Log("Couldn't initialize the offscreen video driver: %s\n", - SDL_GetError()); + SDL_GetError()); return SDL_FALSE; } - /* If OPENGL fails to init it will fallback to using a framebuffer for rendering */ + /* If OPENGL fails to init it will fallback to using a framebuffer for rendering */ window = SDL_CreateWindow("Offscreen Test", - SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - width, height, 0); + SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, + width, height, 0); if (window == NULL) { SDL_Log("Couldn't create window: %s\n", - SDL_GetError()); + SDL_GetError()); return SDL_FALSE; } @@ -129,7 +125,7 @@ main(int argc, char *argv[]) if (renderer == NULL) { SDL_Log("Couldn't create renderer: %s\n", - SDL_GetError()); + SDL_GetError()); return SDL_FALSE; } @@ -157,7 +153,7 @@ main(int argc, char *argv[]) if (frames % (max_frames / 10) == 0) { now = SDL_GetTicks(); if (now > then) { - double fps = ((double) frames * 1000) / (now - then); + double fps = ((double)frames * 1000) / (now - then); SDL_Log("Frames remaining: %" SDL_PRIu32 " rendering at %2.2f frames per second\n", max_frames - frames, fps); } } diff --git a/test/testoverlay2.c b/test/testoverlay2.c index c57c1604f..f388fabff 100644 --- a/test/testoverlay2.c +++ b/test/testoverlay2.c @@ -30,9 +30,10 @@ #define MOOSEPIC_W 64 #define MOOSEPIC_H 88 -#define MOOSEFRAME_SIZE (MOOSEPIC_W * MOOSEPIC_H) +#define MOOSEFRAME_SIZE (MOOSEPIC_W * MOOSEPIC_H) #define MOOSEFRAMES_COUNT 10 +/* *INDENT-OFF* */ /* clang-format off */ SDL_Color MooseColors[84] = { {49, 49, 49, SDL_ALPHA_OPAQUE} , {66, 24, 0, SDL_ALPHA_OPAQUE} @@ -139,8 +140,9 @@ SDL_Color MooseColors[84] = { , {231, 231, 231, SDL_ALPHA_OPAQUE} , {239, 206, 173, SDL_ALPHA_OPAQUE} }; +/* *INDENT-ON* */ /* clang-format on */ -Uint8 MooseFrame[MOOSEFRAMES_COUNT][MOOSEFRAME_SIZE*2]; +Uint8 MooseFrame[MOOSEFRAMES_COUNT][MOOSEFRAME_SIZE * 2]; SDL_Texture *MooseTexture; SDL_Rect displayrect; int window_w; @@ -176,8 +178,7 @@ PrintUsage(char *argv0) SDL_Log("\n"); } -void -loop() +void loop() { SDL_Event event; @@ -234,8 +235,7 @@ loop() #endif } -int -main(int argc, char **argv) +int main(int argc, char **argv) { Uint8 *RawMooseData; SDL_RWops *handle; @@ -260,19 +260,19 @@ main(int argc, char **argv) fps = SDL_atoi(argv[2]); if (fps == 0) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, - "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); + "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); quit(10); } if ((fps < 0) || (fps > 1000)) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, - "The -fps option must be in range from 1 to 1000, default is 12.\n"); + "The -fps option must be in range from 1 to 1000, default is 12.\n"); quit(10); } argv += 2; argc -= 2; } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, - "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); + "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); quit(10); } } else if (SDL_strcmp(argv[1], "-nodelay") == 0) { @@ -284,23 +284,22 @@ main(int argc, char **argv) scale = SDL_atoi(argv[2]); if (scale == 0) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, - "The -scale option requires an argument [from 1 to 50], default is 5.\n"); + "The -scale option requires an argument [from 1 to 50], default is 5.\n"); quit(10); } if ((scale < 0) || (scale > 50)) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, - "The -scale option must be in range from 1 to 50, default is 5.\n"); + "The -scale option must be in range from 1 to 50, default is 5.\n"); quit(10); } argv += 2; argc -= 2; } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, - "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); + "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); quit(10); } - } else if ((SDL_strcmp(argv[1], "-help") == 0) - || (SDL_strcmp(argv[1], "-h") == 0)) { + } else if ((SDL_strcmp(argv[1], "-help") == 0) || (SDL_strcmp(argv[1], "-h") == 0)) { PrintUsage(argv[0]); quit(0); } else { @@ -310,7 +309,7 @@ main(int argc, char **argv) break; } - RawMooseData = (Uint8 *) SDL_malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT); + RawMooseData = (Uint8 *)SDL_malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT); if (RawMooseData == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't allocate memory for movie !\n"); quit(1); @@ -365,7 +364,7 @@ main(int argc, char **argv) /* SDL_SetTextureColorMod(MooseTexture, 0xff, 0x80, 0x80); */ for (i = 0; i < MOOSEFRAMES_COUNT; i++) { - Uint8 MooseFrameRGB[MOOSEFRAME_SIZE*3]; + Uint8 MooseFrameRGB[MOOSEFRAME_SIZE * 3]; Uint8 *rgb; Uint8 *frame; @@ -377,9 +376,9 @@ main(int argc, char **argv) rgb[2] = MooseColors[frame[j]].b; rgb += 3; } - ConvertRGBtoYUV(SDL_PIXELFORMAT_YV12, MooseFrameRGB, MOOSEPIC_W*3, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, - SDL_GetYUVConversionModeForResolution(MOOSEPIC_W, MOOSEPIC_H), - 0, 100); + ConvertRGBtoYUV(SDL_PIXELFORMAT_YV12, MooseFrameRGB, MOOSEPIC_W * 3, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, + SDL_GetYUVConversionModeForResolution(MOOSEPIC_W, MOOSEPIC_H), + 0, 100); } SDL_free(RawMooseData); @@ -406,7 +405,7 @@ main(int argc, char **argv) #else while (!done) { loop(); - } + } #endif SDL_DestroyRenderer(renderer); diff --git a/test/testplatform.c b/test/testplatform.c index bed1af684..8617088ac 100644 --- a/test/testplatform.c +++ b/test/testplatform.c @@ -45,8 +45,7 @@ SDL_COMPILE_TIME_ASSERT(SDL_MIN_SINT64, SDL_MIN_SINT64 == ~0x7fffffffffffffffll) SDL_COMPILE_TIME_ASSERT(SDL_MAX_UINT64, SDL_MAX_UINT64 == 18446744073709551615ull); SDL_COMPILE_TIME_ASSERT(SDL_MIN_UINT64, SDL_MIN_UINT64 == 0); -int -TestTypes(SDL_bool verbose) +int TestTypes(SDL_bool verbose) { int error = 0; @@ -81,8 +80,7 @@ TestTypes(SDL_bool verbose) return error ? 1 : 0; } -int -TestEndian(SDL_bool verbose) +int TestEndian(SDL_bool verbose) { int error = 0; Uint16 value = 0x1234; @@ -94,9 +92,10 @@ TestEndian(SDL_bool verbose) Uint32 swapped32 = 0xDEADBEEF; Uint64 value64, swapped64; - union { - double d; - Uint32 ui32[2]; + union + { + double d; + Uint32 ui32[2]; } value_double; value64 = 0xEFBEADDE; @@ -109,9 +108,9 @@ TestEndian(SDL_bool verbose) if (verbose) { SDL_Log("Detected a %s endian machine.\n", - (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big"); + (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big"); } - if ((*((char *) &value) >> 4) == 0x1) { + if ((*((char *)&value) >> 4) == 0x1) { real_byteorder = SDL_BIG_ENDIAN; } else { real_byteorder = SDL_LIL_ENDIAN; @@ -119,13 +118,13 @@ TestEndian(SDL_bool verbose) if (real_byteorder != SDL_BYTEORDER) { if (verbose) { SDL_Log("Actually a %s endian machine!\n", - (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big"); + (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big"); } ++error; } if (verbose) { SDL_Log("Detected a %s endian float word order machine.\n", - (SDL_FLOATWORDORDER == SDL_LIL_ENDIAN) ? "little" : "big"); + (SDL_FLOATWORDORDER == SDL_LIL_ENDIAN) ? "little" : "big"); } if (value_double.ui32[0] == 0x82c2bd7f && value_double.ui32[1] == 0x400921fb) { real_floatwordorder = SDL_LIL_ENDIAN; @@ -135,13 +134,14 @@ TestEndian(SDL_bool verbose) if (real_floatwordorder != SDL_FLOATWORDORDER) { if (verbose) { SDL_Log("Actually a %s endian float word order machine!\n", - (real_floatwordorder == SDL_LIL_ENDIAN) ? "little" : (real_floatwordorder == SDL_BIG_ENDIAN) ? "big" : "unknown" ); + (real_floatwordorder == SDL_LIL_ENDIAN) ? "little" : (real_floatwordorder == SDL_BIG_ENDIAN) ? "big" + : "unknown"); } ++error; } if (verbose) { SDL_Log("Value 16 = 0x%X, swapped = 0x%X\n", value16, - SDL_Swap16(value16)); + SDL_Swap16(value16)); } if (SDL_Swap16(value16) != swapped16) { if (verbose) { @@ -161,8 +161,8 @@ TestEndian(SDL_bool verbose) ++error; } if (verbose) { - SDL_Log("Value 64 = 0x%"SDL_PRIX64", swapped = 0x%"SDL_PRIX64"\n", value64, - SDL_Swap64(value64)); + SDL_Log("Value 64 = 0x%" SDL_PRIX64 ", swapped = 0x%" SDL_PRIX64 "\n", value64, + SDL_Swap64(value64)); } if (SDL_Swap64(value64) != swapped64) { if (verbose) { @@ -173,64 +173,64 @@ TestEndian(SDL_bool verbose) return error ? 1 : 0; } -static int TST_allmul (void *a, void *b, int arg, void *result, void *expected) +static int TST_allmul(void *a, void *b, int arg, void *result, void *expected) { (*(long long *)result) = ((*(long long *)a) * (*(long long *)b)); return (*(long long *)result) == (*(long long *)expected); } -static int TST_alldiv (void *a, void *b, int arg, void *result, void *expected) +static int TST_alldiv(void *a, void *b, int arg, void *result, void *expected) { (*(long long *)result) = ((*(long long *)a) / (*(long long *)b)); return (*(long long *)result) == (*(long long *)expected); } -static int TST_allrem (void *a, void *b, int arg, void *result, void *expected) +static int TST_allrem(void *a, void *b, int arg, void *result, void *expected) { (*(long long *)result) = ((*(long long *)a) % (*(long long *)b)); return (*(long long *)result) == (*(long long *)expected); } -static int TST_ualldiv (void *a, void *b, int arg, void *result, void *expected) +static int TST_ualldiv(void *a, void *b, int arg, void *result, void *expected) { (*(unsigned long long *)result) = ((*(unsigned long long *)a) / (*(unsigned long long *)b)); return (*(unsigned long long *)result) == (*(unsigned long long *)expected); } -static int TST_uallrem (void *a, void *b, int arg, void *result, void *expected) +static int TST_uallrem(void *a, void *b, int arg, void *result, void *expected) { (*(unsigned long long *)result) = ((*(unsigned long long *)a) % (*(unsigned long long *)b)); return (*(unsigned long long *)result) == (*(unsigned long long *)expected); } -static int TST_allshl (void *a, void *b, int arg, void *result, void *expected) +static int TST_allshl(void *a, void *b, int arg, void *result, void *expected) { (*(long long *)result) = (*(long long *)a) << arg; return (*(long long *)result) == (*(long long *)expected); } -static int TST_aullshl (void *a, void *b, int arg, void *result, void *expected) +static int TST_aullshl(void *a, void *b, int arg, void *result, void *expected) { (*(unsigned long long *)result) = (*(unsigned long long *)a) << arg; return (*(unsigned long long *)result) == (*(unsigned long long *)expected); } -static int TST_allshr (void *a, void *b, int arg, void *result, void *expected) +static int TST_allshr(void *a, void *b, int arg, void *result, void *expected) { (*(long long *)result) = (*(long long *)a) >> arg; return (*(long long *)result) == (*(long long *)expected); } -static int TST_aullshr (void *a, void *b, int arg, void *result, void *expected) +static int TST_aullshr(void *a, void *b, int arg, void *result, void *expected) { (*(unsigned long long *)result) = (*(unsigned long long *)a) >> arg; return (*(unsigned long long *)result) == (*(unsigned long long *)expected); } - typedef int (*LL_Intrinsic)(void *a, void *b, int arg, void *result, void *expected); -typedef struct { +typedef struct +{ const char *operation; LL_Intrinsic routine; unsigned long long a, b; @@ -238,133 +238,130 @@ typedef struct { unsigned long long expected_result; } LL_Test; -static LL_Test LL_Tests[] = -{ +static LL_Test LL_Tests[] = { /* UNDEFINED {"_allshl", &TST_allshl, 0xFFFFFFFFFFFFFFFFll, 0ll, 65, 0x0000000000000000ll}, */ - {"_allshl", &TST_allshl, 0xFFFFFFFFFFFFFFFFll, 0ll, 1, 0xFFFFFFFFFFFFFFFEll}, - {"_allshl", &TST_allshl, 0xFFFFFFFFFFFFFFFFll, 0ll, 32, 0xFFFFFFFF00000000ll}, - {"_allshl", &TST_allshl, 0xFFFFFFFFFFFFFFFFll, 0ll, 33, 0xFFFFFFFE00000000ll}, - {"_allshl", &TST_allshl, 0xFFFFFFFFFFFFFFFFll, 0ll, 0, 0xFFFFFFFFFFFFFFFFll}, + { "_allshl", &TST_allshl, 0xFFFFFFFFFFFFFFFFll, 0ll, 1, 0xFFFFFFFFFFFFFFFEll }, + { "_allshl", &TST_allshl, 0xFFFFFFFFFFFFFFFFll, 0ll, 32, 0xFFFFFFFF00000000ll }, + { "_allshl", &TST_allshl, 0xFFFFFFFFFFFFFFFFll, 0ll, 33, 0xFFFFFFFE00000000ll }, + { "_allshl", &TST_allshl, 0xFFFFFFFFFFFFFFFFll, 0ll, 0, 0xFFFFFFFFFFFFFFFFll }, - {"_allshr", &TST_allshr, 0xAAAAAAAA55555555ll, 0ll, 63, 0xFFFFFFFFFFFFFFFFll}, + { "_allshr", &TST_allshr, 0xAAAAAAAA55555555ll, 0ll, 63, 0xFFFFFFFFFFFFFFFFll }, /* UNDEFINED {"_allshr", &TST_allshr, 0xFFFFFFFFFFFFFFFFll, 0ll, 65, 0xFFFFFFFFFFFFFFFFll}, */ - {"_allshr", &TST_allshr, 0xFFFFFFFFFFFFFFFFll, 0ll, 1, 0xFFFFFFFFFFFFFFFFll}, - {"_allshr", &TST_allshr, 0xFFFFFFFFFFFFFFFFll, 0ll, 32, 0xFFFFFFFFFFFFFFFFll}, - {"_allshr", &TST_allshr, 0xFFFFFFFFFFFFFFFFll, 0ll, 33, 0xFFFFFFFFFFFFFFFFll}, - {"_allshr", &TST_allshr, 0xFFFFFFFFFFFFFFFFll, 0ll, 0, 0xFFFFFFFFFFFFFFFFll}, + { "_allshr", &TST_allshr, 0xFFFFFFFFFFFFFFFFll, 0ll, 1, 0xFFFFFFFFFFFFFFFFll }, + { "_allshr", &TST_allshr, 0xFFFFFFFFFFFFFFFFll, 0ll, 32, 0xFFFFFFFFFFFFFFFFll }, + { "_allshr", &TST_allshr, 0xFFFFFFFFFFFFFFFFll, 0ll, 33, 0xFFFFFFFFFFFFFFFFll }, + { "_allshr", &TST_allshr, 0xFFFFFFFFFFFFFFFFll, 0ll, 0, 0xFFFFFFFFFFFFFFFFll }, /* UNDEFINED {"_allshr", &TST_allshr, 0x5F5F5F5F5F5F5F5Fll, 0ll, 65, 0x0000000000000000ll}, */ - {"_allshr", &TST_allshr, 0x5F5F5F5F5F5F5F5Fll, 0ll, 1, 0x2FAFAFAFAFAFAFAFll}, - {"_allshr", &TST_allshr, 0x5F5F5F5F5F5F5F5Fll, 0ll, 32, 0x000000005F5F5F5Fll}, - {"_allshr", &TST_allshr, 0x5F5F5F5F5F5F5F5Fll, 0ll, 33, 0x000000002FAFAFAFll}, + { "_allshr", &TST_allshr, 0x5F5F5F5F5F5F5F5Fll, 0ll, 1, 0x2FAFAFAFAFAFAFAFll }, + { "_allshr", &TST_allshr, 0x5F5F5F5F5F5F5F5Fll, 0ll, 32, 0x000000005F5F5F5Fll }, + { "_allshr", &TST_allshr, 0x5F5F5F5F5F5F5F5Fll, 0ll, 33, 0x000000002FAFAFAFll }, /* UNDEFINED {"_aullshl", &TST_aullshl, 0xFFFFFFFFFFFFFFFFll, 0ll, 65, 0x0000000000000000ll}, */ - {"_aullshl", &TST_aullshl, 0xFFFFFFFFFFFFFFFFll, 0ll, 1, 0xFFFFFFFFFFFFFFFEll}, - {"_aullshl", &TST_aullshl, 0xFFFFFFFFFFFFFFFFll, 0ll, 32, 0xFFFFFFFF00000000ll}, - {"_aullshl", &TST_aullshl, 0xFFFFFFFFFFFFFFFFll, 0ll, 33, 0xFFFFFFFE00000000ll}, - {"_aullshl", &TST_aullshl, 0xFFFFFFFFFFFFFFFFll, 0ll, 0, 0xFFFFFFFFFFFFFFFFll}, + { "_aullshl", &TST_aullshl, 0xFFFFFFFFFFFFFFFFll, 0ll, 1, 0xFFFFFFFFFFFFFFFEll }, + { "_aullshl", &TST_aullshl, 0xFFFFFFFFFFFFFFFFll, 0ll, 32, 0xFFFFFFFF00000000ll }, + { "_aullshl", &TST_aullshl, 0xFFFFFFFFFFFFFFFFll, 0ll, 33, 0xFFFFFFFE00000000ll }, + { "_aullshl", &TST_aullshl, 0xFFFFFFFFFFFFFFFFll, 0ll, 0, 0xFFFFFFFFFFFFFFFFll }, /* UNDEFINED {"_aullshr", &TST_aullshr, 0xFFFFFFFFFFFFFFFFll, 0ll, 65, 0x0000000000000000ll}, */ - {"_aullshr", &TST_aullshr, 0xFFFFFFFFFFFFFFFFll, 0ll, 1, 0x7FFFFFFFFFFFFFFFll}, - {"_aullshr", &TST_aullshr, 0xFFFFFFFFFFFFFFFFll, 0ll, 32, 0x00000000FFFFFFFFll}, - {"_aullshr", &TST_aullshr, 0xFFFFFFFFFFFFFFFFll, 0ll, 33, 0x000000007FFFFFFFll}, - {"_aullshr", &TST_aullshr, 0xFFFFFFFFFFFFFFFFll, 0ll, 0, 0xFFFFFFFFFFFFFFFFll}, + { "_aullshr", &TST_aullshr, 0xFFFFFFFFFFFFFFFFll, 0ll, 1, 0x7FFFFFFFFFFFFFFFll }, + { "_aullshr", &TST_aullshr, 0xFFFFFFFFFFFFFFFFll, 0ll, 32, 0x00000000FFFFFFFFll }, + { "_aullshr", &TST_aullshr, 0xFFFFFFFFFFFFFFFFll, 0ll, 33, 0x000000007FFFFFFFll }, + { "_aullshr", &TST_aullshr, 0xFFFFFFFFFFFFFFFFll, 0ll, 0, 0xFFFFFFFFFFFFFFFFll }, - {"_allmul", &TST_allmul, 0xFFFFFFFFFFFFFFFFll, 0x0000000000000000ll, 0, 0x0000000000000000ll}, - {"_allmul", &TST_allmul, 0x0000000000000000ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll}, - {"_allmul", &TST_allmul, 0x000000000FFFFFFFll, 0x0000000000000001ll, 0, 0x000000000FFFFFFFll}, - {"_allmul", &TST_allmul, 0x0000000000000001ll, 0x000000000FFFFFFFll, 0, 0x000000000FFFFFFFll}, - {"_allmul", &TST_allmul, 0x000000000FFFFFFFll, 0x0000000000000010ll, 0, 0x00000000FFFFFFF0ll}, - {"_allmul", &TST_allmul, 0x0000000000000010ll, 0x000000000FFFFFFFll, 0, 0x00000000FFFFFFF0ll}, - {"_allmul", &TST_allmul, 0x000000000FFFFFFFll, 0x0000000000000100ll, 0, 0x0000000FFFFFFF00ll}, - {"_allmul", &TST_allmul, 0x0000000000000100ll, 0x000000000FFFFFFFll, 0, 0x0000000FFFFFFF00ll}, - {"_allmul", &TST_allmul, 0x000000000FFFFFFFll, 0x0000000010000000ll, 0, 0x00FFFFFFF0000000ll}, - {"_allmul", &TST_allmul, 0x0000000010000000ll, 0x000000000FFFFFFFll, 0, 0x00FFFFFFF0000000ll}, - {"_allmul", &TST_allmul, 0x000000000FFFFFFFll, 0x0000000080000000ll, 0, 0x07FFFFFF80000000ll}, - {"_allmul", &TST_allmul, 0x0000000080000000ll, 0x000000000FFFFFFFll, 0, 0x07FFFFFF80000000ll}, - {"_allmul", &TST_allmul, 0xFFFFFFFFFFFFFFFEll, 0x0000000080000000ll, 0, 0xFFFFFFFF00000000ll}, - {"_allmul", &TST_allmul, 0x0000000080000000ll, 0xFFFFFFFFFFFFFFFEll, 0, 0xFFFFFFFF00000000ll}, - {"_allmul", &TST_allmul, 0xFFFFFFFFFFFFFFFEll, 0x0000000080000008ll, 0, 0xFFFFFFFEFFFFFFF0ll}, - {"_allmul", &TST_allmul, 0x0000000080000008ll, 0xFFFFFFFFFFFFFFFEll, 0, 0xFFFFFFFEFFFFFFF0ll}, - {"_allmul", &TST_allmul, 0x00000000FFFFFFFFll, 0x00000000FFFFFFFFll, 0, 0xFFFFFFFE00000001ll}, + { "_allmul", &TST_allmul, 0xFFFFFFFFFFFFFFFFll, 0x0000000000000000ll, 0, 0x0000000000000000ll }, + { "_allmul", &TST_allmul, 0x0000000000000000ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll }, + { "_allmul", &TST_allmul, 0x000000000FFFFFFFll, 0x0000000000000001ll, 0, 0x000000000FFFFFFFll }, + { "_allmul", &TST_allmul, 0x0000000000000001ll, 0x000000000FFFFFFFll, 0, 0x000000000FFFFFFFll }, + { "_allmul", &TST_allmul, 0x000000000FFFFFFFll, 0x0000000000000010ll, 0, 0x00000000FFFFFFF0ll }, + { "_allmul", &TST_allmul, 0x0000000000000010ll, 0x000000000FFFFFFFll, 0, 0x00000000FFFFFFF0ll }, + { "_allmul", &TST_allmul, 0x000000000FFFFFFFll, 0x0000000000000100ll, 0, 0x0000000FFFFFFF00ll }, + { "_allmul", &TST_allmul, 0x0000000000000100ll, 0x000000000FFFFFFFll, 0, 0x0000000FFFFFFF00ll }, + { "_allmul", &TST_allmul, 0x000000000FFFFFFFll, 0x0000000010000000ll, 0, 0x00FFFFFFF0000000ll }, + { "_allmul", &TST_allmul, 0x0000000010000000ll, 0x000000000FFFFFFFll, 0, 0x00FFFFFFF0000000ll }, + { "_allmul", &TST_allmul, 0x000000000FFFFFFFll, 0x0000000080000000ll, 0, 0x07FFFFFF80000000ll }, + { "_allmul", &TST_allmul, 0x0000000080000000ll, 0x000000000FFFFFFFll, 0, 0x07FFFFFF80000000ll }, + { "_allmul", &TST_allmul, 0xFFFFFFFFFFFFFFFEll, 0x0000000080000000ll, 0, 0xFFFFFFFF00000000ll }, + { "_allmul", &TST_allmul, 0x0000000080000000ll, 0xFFFFFFFFFFFFFFFEll, 0, 0xFFFFFFFF00000000ll }, + { "_allmul", &TST_allmul, 0xFFFFFFFFFFFFFFFEll, 0x0000000080000008ll, 0, 0xFFFFFFFEFFFFFFF0ll }, + { "_allmul", &TST_allmul, 0x0000000080000008ll, 0xFFFFFFFFFFFFFFFEll, 0, 0xFFFFFFFEFFFFFFF0ll }, + { "_allmul", &TST_allmul, 0x00000000FFFFFFFFll, 0x00000000FFFFFFFFll, 0, 0xFFFFFFFE00000001ll }, - {"_alldiv", &TST_alldiv, 0x0000000000000000ll, 0x0000000000000001ll, 0, 0x0000000000000000ll}, - {"_alldiv", &TST_alldiv, 0x0000000000000000ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll}, - {"_alldiv", &TST_alldiv, 0x0000000000000001ll, 0xFFFFFFFFFFFFFFFFll, 0, 0xFFFFFFFFFFFFFFFFll}, - {"_alldiv", &TST_alldiv, 0xFFFFFFFFFFFFFFFFll, 0x0000000000000001ll, 0, 0xFFFFFFFFFFFFFFFFll}, - {"_alldiv", &TST_alldiv, 0x0000000000000001ll, 0xFFFFFFFFFFFFFFFFll, 0, 0xFFFFFFFFFFFFFFFFll}, - {"_alldiv", &TST_alldiv, 0x0000000000000001ll, 0x0000000000000001ll, 0, 0x0000000000000001ll}, - {"_alldiv", &TST_alldiv, 0xFFFFFFFFFFFFFFFFll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000001ll}, - {"_alldiv", &TST_alldiv, 0x000000000FFFFFFFll, 0x0000000000000001ll, 0, 0x000000000FFFFFFFll}, - {"_alldiv", &TST_alldiv, 0x0000000FFFFFFFFFll, 0x0000000000000010ll, 0, 0x00000000FFFFFFFFll}, - {"_alldiv", &TST_alldiv, 0x0000000000000100ll, 0x000000000FFFFFFFll, 0, 0x0000000000000000ll}, - {"_alldiv", &TST_alldiv, 0x00FFFFFFF0000000ll, 0x0000000010000000ll, 0, 0x000000000FFFFFFFll}, - {"_alldiv", &TST_alldiv, 0x07FFFFFF80000000ll, 0x0000000080000000ll, 0, 0x000000000FFFFFFFll}, - {"_alldiv", &TST_alldiv, 0xFFFFFFFFFFFFFFFEll, 0x0000000080000000ll, 0, 0x0000000000000000ll}, - {"_alldiv", &TST_alldiv, 0xFFFFFFFEFFFFFFF0ll, 0xFFFFFFFFFFFFFFFEll, 0, 0x0000000080000008ll}, - {"_alldiv", &TST_alldiv, 0x7FFFFFFEFFFFFFF0ll, 0xFFFFFFFFFFFFFFFEll, 0, 0xC000000080000008ll}, - {"_alldiv", &TST_alldiv, 0x7FFFFFFEFFFFFFF0ll, 0x0000FFFFFFFFFFFEll, 0, 0x0000000000007FFFll}, - {"_alldiv", &TST_alldiv, 0x7FFFFFFEFFFFFFF0ll, 0x7FFFFFFEFFFFFFF0ll, 0, 0x0000000000000001ll}, + { "_alldiv", &TST_alldiv, 0x0000000000000000ll, 0x0000000000000001ll, 0, 0x0000000000000000ll }, + { "_alldiv", &TST_alldiv, 0x0000000000000000ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll }, + { "_alldiv", &TST_alldiv, 0x0000000000000001ll, 0xFFFFFFFFFFFFFFFFll, 0, 0xFFFFFFFFFFFFFFFFll }, + { "_alldiv", &TST_alldiv, 0xFFFFFFFFFFFFFFFFll, 0x0000000000000001ll, 0, 0xFFFFFFFFFFFFFFFFll }, + { "_alldiv", &TST_alldiv, 0x0000000000000001ll, 0xFFFFFFFFFFFFFFFFll, 0, 0xFFFFFFFFFFFFFFFFll }, + { "_alldiv", &TST_alldiv, 0x0000000000000001ll, 0x0000000000000001ll, 0, 0x0000000000000001ll }, + { "_alldiv", &TST_alldiv, 0xFFFFFFFFFFFFFFFFll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000001ll }, + { "_alldiv", &TST_alldiv, 0x000000000FFFFFFFll, 0x0000000000000001ll, 0, 0x000000000FFFFFFFll }, + { "_alldiv", &TST_alldiv, 0x0000000FFFFFFFFFll, 0x0000000000000010ll, 0, 0x00000000FFFFFFFFll }, + { "_alldiv", &TST_alldiv, 0x0000000000000100ll, 0x000000000FFFFFFFll, 0, 0x0000000000000000ll }, + { "_alldiv", &TST_alldiv, 0x00FFFFFFF0000000ll, 0x0000000010000000ll, 0, 0x000000000FFFFFFFll }, + { "_alldiv", &TST_alldiv, 0x07FFFFFF80000000ll, 0x0000000080000000ll, 0, 0x000000000FFFFFFFll }, + { "_alldiv", &TST_alldiv, 0xFFFFFFFFFFFFFFFEll, 0x0000000080000000ll, 0, 0x0000000000000000ll }, + { "_alldiv", &TST_alldiv, 0xFFFFFFFEFFFFFFF0ll, 0xFFFFFFFFFFFFFFFEll, 0, 0x0000000080000008ll }, + { "_alldiv", &TST_alldiv, 0x7FFFFFFEFFFFFFF0ll, 0xFFFFFFFFFFFFFFFEll, 0, 0xC000000080000008ll }, + { "_alldiv", &TST_alldiv, 0x7FFFFFFEFFFFFFF0ll, 0x0000FFFFFFFFFFFEll, 0, 0x0000000000007FFFll }, + { "_alldiv", &TST_alldiv, 0x7FFFFFFEFFFFFFF0ll, 0x7FFFFFFEFFFFFFF0ll, 0, 0x0000000000000001ll }, - {"_allrem", &TST_allrem, 0x0000000000000000ll, 0x0000000000000001ll, 0, 0x0000000000000000ll}, - {"_allrem", &TST_allrem, 0x0000000000000000ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll}, - {"_allrem", &TST_allrem, 0x0000000000000001ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll}, - {"_allrem", &TST_allrem, 0xFFFFFFFFFFFFFFFFll, 0x0000000000000001ll, 0, 0x0000000000000000ll}, - {"_allrem", &TST_allrem, 0x0000000000000001ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll}, - {"_allrem", &TST_allrem, 0x0000000000000001ll, 0x0000000000000001ll, 0, 0x0000000000000000ll}, - {"_allrem", &TST_allrem, 0xFFFFFFFFFFFFFFFFll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll}, - {"_allrem", &TST_allrem, 0x000000000FFFFFFFll, 0x0000000000000001ll, 0, 0x0000000000000000ll}, - {"_allrem", &TST_allrem, 0x0000000FFFFFFFFFll, 0x0000000000000010ll, 0, 0x000000000000000Fll}, - {"_allrem", &TST_allrem, 0x0000000000000100ll, 0x000000000FFFFFFFll, 0, 0x0000000000000100ll}, - {"_allrem", &TST_allrem, 0x00FFFFFFF0000000ll, 0x0000000010000000ll, 0, 0x0000000000000000ll}, - {"_allrem", &TST_allrem, 0x07FFFFFF80000000ll, 0x0000000080000000ll, 0, 0x0000000000000000ll}, - {"_allrem", &TST_allrem, 0xFFFFFFFFFFFFFFFEll, 0x0000000080000000ll, 0, 0xFFFFFFFFFFFFFFFEll}, - {"_allrem", &TST_allrem, 0xFFFFFFFEFFFFFFF0ll, 0xFFFFFFFFFFFFFFFEll, 0, 0x0000000000000000ll}, - {"_allrem", &TST_allrem, 0x7FFFFFFEFFFFFFF0ll, 0xFFFFFFFFFFFFFFFEll, 0, 0x0000000000000000ll}, - {"_allrem", &TST_allrem, 0x7FFFFFFEFFFFFFF0ll, 0x0000FFFFFFFFFFFEll, 0, 0x0000FFFF0000FFEEll}, - {"_allrem", &TST_allrem, 0x7FFFFFFEFFFFFFF0ll, 0x7FFFFFFEFFFFFFF0ll, 0, 0x0000000000000000ll}, + { "_allrem", &TST_allrem, 0x0000000000000000ll, 0x0000000000000001ll, 0, 0x0000000000000000ll }, + { "_allrem", &TST_allrem, 0x0000000000000000ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll }, + { "_allrem", &TST_allrem, 0x0000000000000001ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll }, + { "_allrem", &TST_allrem, 0xFFFFFFFFFFFFFFFFll, 0x0000000000000001ll, 0, 0x0000000000000000ll }, + { "_allrem", &TST_allrem, 0x0000000000000001ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll }, + { "_allrem", &TST_allrem, 0x0000000000000001ll, 0x0000000000000001ll, 0, 0x0000000000000000ll }, + { "_allrem", &TST_allrem, 0xFFFFFFFFFFFFFFFFll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll }, + { "_allrem", &TST_allrem, 0x000000000FFFFFFFll, 0x0000000000000001ll, 0, 0x0000000000000000ll }, + { "_allrem", &TST_allrem, 0x0000000FFFFFFFFFll, 0x0000000000000010ll, 0, 0x000000000000000Fll }, + { "_allrem", &TST_allrem, 0x0000000000000100ll, 0x000000000FFFFFFFll, 0, 0x0000000000000100ll }, + { "_allrem", &TST_allrem, 0x00FFFFFFF0000000ll, 0x0000000010000000ll, 0, 0x0000000000000000ll }, + { "_allrem", &TST_allrem, 0x07FFFFFF80000000ll, 0x0000000080000000ll, 0, 0x0000000000000000ll }, + { "_allrem", &TST_allrem, 0xFFFFFFFFFFFFFFFEll, 0x0000000080000000ll, 0, 0xFFFFFFFFFFFFFFFEll }, + { "_allrem", &TST_allrem, 0xFFFFFFFEFFFFFFF0ll, 0xFFFFFFFFFFFFFFFEll, 0, 0x0000000000000000ll }, + { "_allrem", &TST_allrem, 0x7FFFFFFEFFFFFFF0ll, 0xFFFFFFFFFFFFFFFEll, 0, 0x0000000000000000ll }, + { "_allrem", &TST_allrem, 0x7FFFFFFEFFFFFFF0ll, 0x0000FFFFFFFFFFFEll, 0, 0x0000FFFF0000FFEEll }, + { "_allrem", &TST_allrem, 0x7FFFFFFEFFFFFFF0ll, 0x7FFFFFFEFFFFFFF0ll, 0, 0x0000000000000000ll }, + { "_ualldiv", &TST_ualldiv, 0x0000000000000000ll, 0x0000000000000001ll, 0, 0x0000000000000000ll }, + { "_ualldiv", &TST_ualldiv, 0x0000000000000000ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll }, + { "_ualldiv", &TST_ualldiv, 0x0000000000000001ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll }, + { "_ualldiv", &TST_ualldiv, 0xFFFFFFFFFFFFFFFFll, 0x0000000000000001ll, 0, 0xFFFFFFFFFFFFFFFFll }, + { "_ualldiv", &TST_ualldiv, 0x0000000000000001ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll }, + { "_ualldiv", &TST_ualldiv, 0x0000000000000001ll, 0x0000000000000001ll, 0, 0x0000000000000001ll }, + { "_ualldiv", &TST_ualldiv, 0xFFFFFFFFFFFFFFFFll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000001ll }, + { "_ualldiv", &TST_ualldiv, 0x000000000FFFFFFFll, 0x0000000000000001ll, 0, 0x000000000FFFFFFFll }, + { "_ualldiv", &TST_ualldiv, 0x0000000FFFFFFFFFll, 0x0000000000000010ll, 0, 0x00000000FFFFFFFFll }, + { "_ualldiv", &TST_ualldiv, 0x0000000000000100ll, 0x000000000FFFFFFFll, 0, 0x0000000000000000ll }, + { "_ualldiv", &TST_ualldiv, 0x00FFFFFFF0000000ll, 0x0000000010000000ll, 0, 0x000000000FFFFFFFll }, + { "_ualldiv", &TST_ualldiv, 0x07FFFFFF80000000ll, 0x0000000080000000ll, 0, 0x000000000FFFFFFFll }, + { "_ualldiv", &TST_ualldiv, 0xFFFFFFFFFFFFFFFEll, 0x0000000080000000ll, 0, 0x00000001FFFFFFFFll }, + { "_ualldiv", &TST_ualldiv, 0xFFFFFFFEFFFFFFF0ll, 0xFFFFFFFFFFFFFFFEll, 0, 0x0000000000000000ll }, + { "_ualldiv", &TST_ualldiv, 0x7FFFFFFEFFFFFFF0ll, 0xFFFFFFFFFFFFFFFEll, 0, 0x0000000000000000ll }, + { "_ualldiv", &TST_ualldiv, 0x7FFFFFFEFFFFFFF0ll, 0x0000FFFFFFFFFFFEll, 0, 0x0000000000007FFFll }, + { "_ualldiv", &TST_ualldiv, 0x7FFFFFFEFFFFFFF0ll, 0x7FFFFFFEFFFFFFF0ll, 0, 0x0000000000000001ll }, - {"_ualldiv", &TST_ualldiv, 0x0000000000000000ll, 0x0000000000000001ll, 0, 0x0000000000000000ll}, - {"_ualldiv", &TST_ualldiv, 0x0000000000000000ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll}, - {"_ualldiv", &TST_ualldiv, 0x0000000000000001ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll}, - {"_ualldiv", &TST_ualldiv, 0xFFFFFFFFFFFFFFFFll, 0x0000000000000001ll, 0, 0xFFFFFFFFFFFFFFFFll}, - {"_ualldiv", &TST_ualldiv, 0x0000000000000001ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll}, - {"_ualldiv", &TST_ualldiv, 0x0000000000000001ll, 0x0000000000000001ll, 0, 0x0000000000000001ll}, - {"_ualldiv", &TST_ualldiv, 0xFFFFFFFFFFFFFFFFll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000001ll}, - {"_ualldiv", &TST_ualldiv, 0x000000000FFFFFFFll, 0x0000000000000001ll, 0, 0x000000000FFFFFFFll}, - {"_ualldiv", &TST_ualldiv, 0x0000000FFFFFFFFFll, 0x0000000000000010ll, 0, 0x00000000FFFFFFFFll}, - {"_ualldiv", &TST_ualldiv, 0x0000000000000100ll, 0x000000000FFFFFFFll, 0, 0x0000000000000000ll}, - {"_ualldiv", &TST_ualldiv, 0x00FFFFFFF0000000ll, 0x0000000010000000ll, 0, 0x000000000FFFFFFFll}, - {"_ualldiv", &TST_ualldiv, 0x07FFFFFF80000000ll, 0x0000000080000000ll, 0, 0x000000000FFFFFFFll}, - {"_ualldiv", &TST_ualldiv, 0xFFFFFFFFFFFFFFFEll, 0x0000000080000000ll, 0, 0x00000001FFFFFFFFll}, - {"_ualldiv", &TST_ualldiv, 0xFFFFFFFEFFFFFFF0ll, 0xFFFFFFFFFFFFFFFEll, 0, 0x0000000000000000ll}, - {"_ualldiv", &TST_ualldiv, 0x7FFFFFFEFFFFFFF0ll, 0xFFFFFFFFFFFFFFFEll, 0, 0x0000000000000000ll}, - {"_ualldiv", &TST_ualldiv, 0x7FFFFFFEFFFFFFF0ll, 0x0000FFFFFFFFFFFEll, 0, 0x0000000000007FFFll}, - {"_ualldiv", &TST_ualldiv, 0x7FFFFFFEFFFFFFF0ll, 0x7FFFFFFEFFFFFFF0ll, 0, 0x0000000000000001ll}, + { "_uallrem", &TST_uallrem, 0x0000000000000000ll, 0x0000000000000001ll, 0, 0x0000000000000000ll }, + { "_uallrem", &TST_uallrem, 0x0000000000000000ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll }, + { "_uallrem", &TST_uallrem, 0x0000000000000001ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000001ll }, + { "_uallrem", &TST_uallrem, 0xFFFFFFFFFFFFFFFFll, 0x0000000000000001ll, 0, 0x0000000000000000ll }, + { "_uallrem", &TST_uallrem, 0x0000000000000001ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000001ll }, + { "_uallrem", &TST_uallrem, 0x0000000000000001ll, 0x0000000000000001ll, 0, 0x0000000000000000ll }, + { "_uallrem", &TST_uallrem, 0xFFFFFFFFFFFFFFFFll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll }, + { "_uallrem", &TST_uallrem, 0x000000000FFFFFFFll, 0x0000000000000001ll, 0, 0x0000000000000000ll }, + { "_uallrem", &TST_uallrem, 0x0000000FFFFFFFFFll, 0x0000000000000010ll, 0, 0x000000000000000Fll }, + { "_uallrem", &TST_uallrem, 0x0000000000000100ll, 0x000000000FFFFFFFll, 0, 0x0000000000000100ll }, + { "_uallrem", &TST_uallrem, 0x00FFFFFFF0000000ll, 0x0000000010000000ll, 0, 0x0000000000000000ll }, + { "_uallrem", &TST_uallrem, 0x07FFFFFF80000000ll, 0x0000000080000000ll, 0, 0x0000000000000000ll }, + { "_uallrem", &TST_uallrem, 0xFFFFFFFFFFFFFFFEll, 0x0000000080000000ll, 0, 0x000000007FFFFFFEll }, + { "_uallrem", &TST_uallrem, 0xFFFFFFFEFFFFFFF0ll, 0xFFFFFFFFFFFFFFFEll, 0, 0xFFFFFFFEFFFFFFF0ll }, + { "_uallrem", &TST_uallrem, 0x7FFFFFFEFFFFFFF0ll, 0xFFFFFFFFFFFFFFFEll, 0, 0x7FFFFFFEFFFFFFF0ll }, + { "_uallrem", &TST_uallrem, 0x7FFFFFFEFFFFFFF0ll, 0x0000FFFFFFFFFFFEll, 0, 0x0000FFFF0000FFEEll }, + { "_uallrem", &TST_uallrem, 0x7FFFFFFEFFFFFFF0ll, 0x7FFFFFFEFFFFFFF0ll, 0, 0x0000000000000000ll }, - {"_uallrem", &TST_uallrem, 0x0000000000000000ll, 0x0000000000000001ll, 0, 0x0000000000000000ll}, - {"_uallrem", &TST_uallrem, 0x0000000000000000ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll}, - {"_uallrem", &TST_uallrem, 0x0000000000000001ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000001ll}, - {"_uallrem", &TST_uallrem, 0xFFFFFFFFFFFFFFFFll, 0x0000000000000001ll, 0, 0x0000000000000000ll}, - {"_uallrem", &TST_uallrem, 0x0000000000000001ll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000001ll}, - {"_uallrem", &TST_uallrem, 0x0000000000000001ll, 0x0000000000000001ll, 0, 0x0000000000000000ll}, - {"_uallrem", &TST_uallrem, 0xFFFFFFFFFFFFFFFFll, 0xFFFFFFFFFFFFFFFFll, 0, 0x0000000000000000ll}, - {"_uallrem", &TST_uallrem, 0x000000000FFFFFFFll, 0x0000000000000001ll, 0, 0x0000000000000000ll}, - {"_uallrem", &TST_uallrem, 0x0000000FFFFFFFFFll, 0x0000000000000010ll, 0, 0x000000000000000Fll}, - {"_uallrem", &TST_uallrem, 0x0000000000000100ll, 0x000000000FFFFFFFll, 0, 0x0000000000000100ll}, - {"_uallrem", &TST_uallrem, 0x00FFFFFFF0000000ll, 0x0000000010000000ll, 0, 0x0000000000000000ll}, - {"_uallrem", &TST_uallrem, 0x07FFFFFF80000000ll, 0x0000000080000000ll, 0, 0x0000000000000000ll}, - {"_uallrem", &TST_uallrem, 0xFFFFFFFFFFFFFFFEll, 0x0000000080000000ll, 0, 0x000000007FFFFFFEll}, - {"_uallrem", &TST_uallrem, 0xFFFFFFFEFFFFFFF0ll, 0xFFFFFFFFFFFFFFFEll, 0, 0xFFFFFFFEFFFFFFF0ll}, - {"_uallrem", &TST_uallrem, 0x7FFFFFFEFFFFFFF0ll, 0xFFFFFFFFFFFFFFFEll, 0, 0x7FFFFFFEFFFFFFF0ll}, - {"_uallrem", &TST_uallrem, 0x7FFFFFFEFFFFFFF0ll, 0x0000FFFFFFFFFFFEll, 0, 0x0000FFFF0000FFEEll}, - {"_uallrem", &TST_uallrem, 0x7FFFFFFEFFFFFFF0ll, 0x7FFFFFFEFFFFFFF0ll, 0, 0x0000000000000000ll}, - - {NULL} + { NULL } }; -int -Test64Bit (SDL_bool verbose) +int Test64Bit(SDL_bool verbose) { LL_Test *t; int failed = 0; @@ -390,35 +387,33 @@ Test64Bit (SDL_bool verbose) return failed ? 1 : 0; } -int -TestCPUInfo(SDL_bool verbose) +int TestCPUInfo(SDL_bool verbose) { if (verbose) { SDL_Log("CPU count: %d\n", SDL_GetCPUCount()); SDL_Log("CPU cache line size: %d\n", SDL_GetCPUCacheLineSize()); - SDL_Log("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected"); - SDL_Log("AltiVec %s\n", SDL_HasAltiVec()? "detected" : "not detected"); - SDL_Log("MMX %s\n", SDL_HasMMX()? "detected" : "not detected"); - SDL_Log("3DNow! %s\n", SDL_Has3DNow()? "detected" : "not detected"); - SDL_Log("SSE %s\n", SDL_HasSSE()? "detected" : "not detected"); - SDL_Log("SSE2 %s\n", SDL_HasSSE2()? "detected" : "not detected"); - SDL_Log("SSE3 %s\n", SDL_HasSSE3()? "detected" : "not detected"); - SDL_Log("SSE4.1 %s\n", SDL_HasSSE41()? "detected" : "not detected"); - SDL_Log("SSE4.2 %s\n", SDL_HasSSE42()? "detected" : "not detected"); - SDL_Log("AVX %s\n", SDL_HasAVX()? "detected" : "not detected"); - SDL_Log("AVX2 %s\n", SDL_HasAVX2()? "detected" : "not detected"); - SDL_Log("AVX-512F %s\n", SDL_HasAVX512F()? "detected" : "not detected"); - SDL_Log("ARM SIMD %s\n", SDL_HasARMSIMD()? "detected" : "not detected"); - SDL_Log("NEON %s\n", SDL_HasNEON()? "detected" : "not detected"); - SDL_Log("LSX %s\n", SDL_HasLSX()? "detected" : "not detected"); - SDL_Log("LASX %s\n", SDL_HasLASX()? "detected" : "not detected"); + SDL_Log("RDTSC %s\n", SDL_HasRDTSC() ? "detected" : "not detected"); + SDL_Log("AltiVec %s\n", SDL_HasAltiVec() ? "detected" : "not detected"); + SDL_Log("MMX %s\n", SDL_HasMMX() ? "detected" : "not detected"); + SDL_Log("3DNow! %s\n", SDL_Has3DNow() ? "detected" : "not detected"); + SDL_Log("SSE %s\n", SDL_HasSSE() ? "detected" : "not detected"); + SDL_Log("SSE2 %s\n", SDL_HasSSE2() ? "detected" : "not detected"); + SDL_Log("SSE3 %s\n", SDL_HasSSE3() ? "detected" : "not detected"); + SDL_Log("SSE4.1 %s\n", SDL_HasSSE41() ? "detected" : "not detected"); + SDL_Log("SSE4.2 %s\n", SDL_HasSSE42() ? "detected" : "not detected"); + SDL_Log("AVX %s\n", SDL_HasAVX() ? "detected" : "not detected"); + SDL_Log("AVX2 %s\n", SDL_HasAVX2() ? "detected" : "not detected"); + SDL_Log("AVX-512F %s\n", SDL_HasAVX512F() ? "detected" : "not detected"); + SDL_Log("ARM SIMD %s\n", SDL_HasARMSIMD() ? "detected" : "not detected"); + SDL_Log("NEON %s\n", SDL_HasNEON() ? "detected" : "not detected"); + SDL_Log("LSX %s\n", SDL_HasLSX() ? "detected" : "not detected"); + SDL_Log("LASX %s\n", SDL_HasLASX() ? "detected" : "not detected"); SDL_Log("System RAM %d MB\n", SDL_GetSystemRAM()); } return 0; } -int -TestAssertions(SDL_bool verbose) +int TestAssertions(SDL_bool verbose) { SDL_assert(1); SDL_assert_release(1); @@ -427,7 +422,7 @@ TestAssertions(SDL_bool verbose) SDL_assert_release(0 || 1); SDL_assert_paranoid(0 || 1); -#if 0 /* enable this to test assertion failures. */ +#if 0 /* enable this to test assertion failures. */ SDL_assert_release(1 == 2); SDL_assert_release(5 < 4); SDL_assert_release(0 && "This is a test"); @@ -437,17 +432,16 @@ TestAssertions(SDL_bool verbose) const SDL_AssertData *item = SDL_GetAssertionReport(); while (item) { SDL_Log("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n", - item->condition, item->function, item->filename, - item->linenum, item->trigger_count, - item->always_ignore ? "yes" : "no"); + item->condition, item->function, item->filename, + item->linenum, item->trigger_count, + item->always_ignore ? "yes" : "no"); item = item->next; } } return 0; } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { SDL_bool verbose = SDL_TRUE; int status = 0; diff --git a/test/testpower.c b/test/testpower.c index 27b05ee21..96a89334c 100644 --- a/test/testpower.c +++ b/test/testpower.c @@ -54,14 +54,12 @@ report_power(void) if (seconds == -1) { SDL_Log("Time left: unknown\n"); } else { - SDL_Log("Time left: %d minutes, %d seconds\n", (int) (seconds / 60), - (int) (seconds % 60)); + SDL_Log("Time left: %d minutes, %d seconds\n", (int)(seconds / 60), + (int)(seconds % 60)); } } - -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { /* Enable standard application logging */ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); diff --git a/test/testqsort.c b/test/testqsort.c index 0bee0f4a3..0f89829e2 100644 --- a/test/testqsort.c +++ b/test/testqsort.c @@ -15,8 +15,8 @@ static int SDLCALL num_compare(const void *_a, const void *_b) { - const int a = *((const int *) _a); - const int b = *((const int *) _b); + const int a = *((const int *)_a); + const int b = *((const int *)_b); return (a < b) ? -1 : ((a > b) ? 1 : 0); } @@ -28,7 +28,7 @@ test_sort(const char *desc, int *nums, const int arraylen) SDL_Log("test: %s arraylen=%d", desc, arraylen); - SDL_qsort(nums, arraylen, sizeof (nums[0]), num_compare); + SDL_qsort(nums, arraylen, sizeof(nums[0]), num_compare); prev = nums[0]; for (i = 1; i < arraylen; i++) { @@ -41,8 +41,7 @@ test_sort(const char *desc, int *nums, const int arraylen) } } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { static int nums[1024 * 100]; static const int itervals[] = { SDL_arraysize(nums), 12 }; @@ -53,9 +52,9 @@ main(int argc, char *argv[]) int success; Uint64 seed = 0; if (argv[1][0] == '0' && argv[1][1] == 'x') - success = SDL_sscanf(argv[1] + 2, "%"SDL_PRIx64, &seed); + success = SDL_sscanf(argv[1] + 2, "%" SDL_PRIx64, &seed); else - success = SDL_sscanf(argv[1], "%"SDL_PRIu64, &seed); + success = SDL_sscanf(argv[1], "%" SDL_PRIu64, &seed); if (!success) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Invalid seed. Use a decimal or hexadecimal number.\n"); return 1; @@ -82,11 +81,11 @@ main(int argc, char *argv[]) for (i = 0; i < arraylen; i++) { nums[i] = i; } - nums[arraylen-1] = -1; + nums[arraylen - 1] = -1; test_sort("already sorted except last element", nums, arraylen); for (i = 0; i < arraylen; i++) { - nums[i] = (arraylen-1) - i; + nums[i] = (arraylen - 1) - i; } test_sort("reverse sorted", nums, arraylen); diff --git a/test/testrelative.c b/test/testrelative.c index c058b8228..29313cc55 100644 --- a/test/testrelative.c +++ b/test/testrelative.c @@ -28,24 +28,24 @@ SDL_Rect rect; SDL_Event event; static void -DrawRects(SDL_Renderer * renderer) +DrawRects(SDL_Renderer *renderer) { SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); SDL_RenderFillRect(renderer, &rect); } static void -loop() { +loop() +{ /* Check for events */ while (SDL_PollEvent(&event)) { SDLTest_CommonEvent(state, &event, &done); - switch(event.type) { + switch (event.type) { case SDL_MOUSEMOTION: - { - rect.x += event.motion.xrel; - rect.y += event.motion.yrel; - } - break; + { + rect.x += event.motion.xrel; + rect.y += event.motion.yrel; + } break; } } for (i = 0; i < state->num_windows; ++i) { @@ -83,8 +83,7 @@ loop() { #endif } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { /* Enable standard application logging */ @@ -126,7 +125,7 @@ main(int argc, char *argv[]) #else while (!done) { loop(); - } + } #endif SDLTest_CommonQuit(state); return 0; diff --git a/test/testrendercopyex.c b/test/testrendercopyex.c index 8d7ed3a2c..767c5e8ae 100644 --- a/test/testrendercopyex.c +++ b/test/testrendercopyex.c @@ -24,7 +24,8 @@ static SDLTest_CommonState *state; -typedef struct { +typedef struct +{ SDL_Window *window; SDL_Renderer *renderer; SDL_Texture *background; @@ -44,13 +45,12 @@ quit(int rc) exit(rc); } -void -Draw(DrawState *s) +void Draw(DrawState *s) { SDL_Rect viewport; SDL_Texture *target; - SDL_Point *center=NULL; - SDL_Point origin = {0,0}; + SDL_Point *center = NULL; + SDL_Point origin = { 0, 0 }; SDL_RenderGetViewport(s->renderer, &viewport); @@ -110,8 +110,7 @@ void loop() #endif } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i; int frames; @@ -158,12 +157,12 @@ main(int argc, char *argv[]) while (!done) { ++frames; loop(); - } + } #endif /* Print out some timing information */ now = SDL_GetTicks(); if (now > then) { - double fps = ((double) frames * 1000) / (now - then); + double fps = ((double)frames * 1000) / (now - then); SDL_Log("%2.2f frames per second\n", fps); } diff --git a/test/testrendertarget.c b/test/testrendertarget.c index 7143336d9..d75dbd1a5 100644 --- a/test/testrendertarget.c +++ b/test/testrendertarget.c @@ -24,7 +24,8 @@ static SDLTest_CommonState *state; -typedef struct { +typedef struct +{ SDL_Window *window; SDL_Renderer *renderer; SDL_Texture *background; @@ -172,8 +173,7 @@ Draw(DrawState *s) return SDL_TRUE; } -void -loop() +void loop() { int i; SDL_Event event; @@ -203,8 +203,7 @@ loop() #endif } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i; int frames; @@ -277,7 +276,7 @@ main(int argc, char *argv[]) /* Print out some timing information */ now = SDL_GetTicks(); if (now > then) { - double fps = ((double) frames * 1000) / (now - then); + double fps = ((double)frames * 1000) / (now - then); SDL_Log("%2.2f frames per second\n", fps); } diff --git a/test/testresample.c b/test/testresample.c index 6f03aabd4..1bcbebac6 100644 --- a/test/testresample.c +++ b/test/testresample.c @@ -12,8 +12,7 @@ #include "SDL.h" -int -main(int argc, char **argv) +int main(int argc, char **argv) { SDL_AudioSpec spec; SDL_AudioCVT cvt; @@ -57,7 +56,7 @@ main(int argc, char **argv) } cvt.len = len; - cvt.buf = (Uint8 *) SDL_malloc(len * cvt.len_mult); + cvt.buf = (Uint8 *)SDL_malloc(len * cvt.len_mult); if (cvt.buf == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory.\n"); SDL_FreeWAV(data); @@ -88,19 +87,19 @@ main(int argc, char **argv) blockalign = (bitsize / 8) * cvtchans; avgbytes = cvtfreq * blockalign; - SDL_WriteLE32(io, 0x46464952); /* RIFF */ + SDL_WriteLE32(io, 0x46464952); /* RIFF */ SDL_WriteLE32(io, cvt.len_cvt + 36); - SDL_WriteLE32(io, 0x45564157); /* WAVE */ - SDL_WriteLE32(io, 0x20746D66); /* fmt */ - SDL_WriteLE32(io, 16); /* chunk size */ - SDL_WriteLE16(io, SDL_AUDIO_ISFLOAT(spec.format) ? 3 : 1); /* uncompressed */ - SDL_WriteLE16(io, cvtchans); /* channels */ - SDL_WriteLE32(io, cvtfreq); /* sample rate */ - SDL_WriteLE32(io, avgbytes); /* average bytes per second */ - SDL_WriteLE16(io, blockalign); /* block align */ - SDL_WriteLE16(io, bitsize); /* significant bits per sample */ - SDL_WriteLE32(io, 0x61746164); /* data */ - SDL_WriteLE32(io, cvt.len_cvt); /* size */ + SDL_WriteLE32(io, 0x45564157); /* WAVE */ + SDL_WriteLE32(io, 0x20746D66); /* fmt */ + SDL_WriteLE32(io, 16); /* chunk size */ + SDL_WriteLE16(io, SDL_AUDIO_ISFLOAT(spec.format) ? 3 : 1); /* uncompressed */ + SDL_WriteLE16(io, cvtchans); /* channels */ + SDL_WriteLE32(io, cvtfreq); /* sample rate */ + SDL_WriteLE32(io, avgbytes); /* average bytes per second */ + SDL_WriteLE16(io, blockalign); /* block align */ + SDL_WriteLE16(io, bitsize); /* significant bits per sample */ + SDL_WriteLE32(io, 0x61746164); /* data */ + SDL_WriteLE32(io, cvt.len_cvt); /* size */ SDL_RWwrite(io, cvt.buf, cvt.len_cvt, 1); if (SDL_RWclose(io) == -1) { @@ -109,12 +108,12 @@ main(int argc, char **argv) SDL_FreeWAV(data); SDL_Quit(); return 8; - } /* if */ + } /* if */ SDL_free(cvt.buf); SDL_FreeWAV(data); SDL_Quit(); return 0; -} /* main */ +} /* main */ /* end of testresample.c ... */ diff --git a/test/testrumble.c b/test/testrumble.c index 694e940c8..7a5087a20 100644 --- a/test/testrumble.c +++ b/test/testrumble.c @@ -31,14 +31,12 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND static SDL_Haptic *haptic; - /** * @brief The entry point of this force feedback demo. * @param[in] argc Number of arguments. * @param[in] argv Array of argc arguments. */ -int -main(int argc, char **argv) +int main(int argc, char **argv) { int i; char *name; @@ -54,9 +52,9 @@ main(int argc, char **argv) name = argv[1]; if ((SDL_strcmp(name, "--help") == 0) || (SDL_strcmp(name, "-h") == 0)) { SDL_Log("USAGE: %s [device]\n" - "If device is a two-digit number it'll use it as an index, otherwise\n" - "it'll use it as if it were part of the device's name.\n", - argv[0]); + "If device is a two-digit number it'll use it as an index, otherwise\n" + "it'll use it as if it were part of the device's name.\n", + argv[0]); return 0; } @@ -86,7 +84,7 @@ main(int argc, char **argv) if (i >= SDL_NumHaptics()) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.\n", - name); + name); return 1; } } @@ -94,7 +92,7 @@ main(int argc, char **argv) haptic = SDL_HapticOpen(i); if (haptic == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n", - SDL_GetError()); + SDL_GetError()); return 1; } SDL_Log("Device: %s\n", SDL_HapticName(i)); @@ -116,8 +114,8 @@ main(int argc, char **argv) } SDL_Log("Playing 2 second rumble at 0.5 magnitude.\n"); if (SDL_HapticRumblePlay(haptic, 0.5, 5000) != 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError() ); - return 1; + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError()); + return 1; } SDL_Delay(2000); SDL_Log("Stopping rumble.\n"); @@ -125,8 +123,8 @@ main(int argc, char **argv) SDL_Delay(2000); SDL_Log("Playing 2 second rumble at 0.3 magnitude.\n"); if (SDL_HapticRumblePlay(haptic, 0.3f, 5000) != 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError() ); - return 1; + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError()); + return 1; } SDL_Delay(2000); diff --git a/test/testscale.c b/test/testscale.c index b9a442463..34f9f14d8 100644 --- a/test/testscale.c +++ b/test/testscale.c @@ -22,12 +22,13 @@ #include "SDL_test_common.h" #include "testutils.h" -#define WINDOW_WIDTH 640 -#define WINDOW_HEIGHT 480 +#define WINDOW_WIDTH 640 +#define WINDOW_HEIGHT 480 static SDLTest_CommonState *state; -typedef struct { +typedef struct +{ SDL_Window *window; SDL_Renderer *renderer; SDL_Texture *background; @@ -47,8 +48,7 @@ quit(int rc) exit(rc); } -void -Draw(DrawState *s) +void Draw(DrawState *s) { SDL_Rect viewport; @@ -78,8 +78,7 @@ Draw(DrawState *s) SDL_RenderPresent(s->renderer); } -void -loop() +void loop() { int i; SDL_Event event; @@ -101,8 +100,7 @@ loop() #endif } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i; int frames; @@ -155,7 +153,7 @@ main(int argc, char *argv[]) /* Print out some timing information */ now = SDL_GetTicks(); if (now > then) { - double fps = ((double) frames * 1000) / (now - then); + double fps = ((double)frames * 1000) / (now - then); SDL_Log("%2.2f frames per second\n", fps); } diff --git a/test/testsem.c b/test/testsem.c index 23d2f514e..efbe78f76 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -21,14 +21,15 @@ #define NUM_THREADS 10 /* This value should be smaller than the maximum count of the */ /* semaphore implementation: */ -#define NUM_OVERHEAD_OPS 10000 +#define NUM_OVERHEAD_OPS 10000 #define NUM_OVERHEAD_OPS_MULT 10 static SDL_sem *sem; int alive; -typedef struct Thread_State { - SDL_Thread * thread; +typedef struct Thread_State +{ + SDL_Thread *thread; int number; SDL_bool flag; int loop_count; @@ -44,7 +45,7 @@ killed(int sig) static int SDLCALL ThreadFuncRealWorld(void *data) { - Thread_State *state = (Thread_State *) data; + Thread_State *state = (Thread_State *)data; while (alive) { SDL_SemWait(sem); SDL_Log("Thread number %d has got the semaphore (value = %" SDL_PRIu32 ")!\n", @@ -54,29 +55,30 @@ ThreadFuncRealWorld(void *data) SDL_Log("Thread number %d has released the semaphore (value = %" SDL_PRIu32 ")!\n", state->number, SDL_SemValue(sem)); ++state->loop_count; - SDL_Delay(1); /* For the scheduler */ + SDL_Delay(1); /* For the scheduler */ } SDL_Log("Thread number %d exiting.\n", state->number); return 0; } static void -TestRealWorld(int init_sem) { - Thread_State thread_states[NUM_THREADS] = { {0} }; +TestRealWorld(int init_sem) +{ + Thread_State thread_states[NUM_THREADS] = { { 0 } }; int i; int loop_count; sem = SDL_CreateSemaphore(init_sem); SDL_Log("Running %d threads, semaphore value = %d\n", NUM_THREADS, - init_sem); + init_sem); alive = 1; /* Create all the threads */ for (i = 0; i < NUM_THREADS; ++i) { char name[64]; - SDL_snprintf(name, sizeof (name), "Thread%u", (unsigned int) i); + SDL_snprintf(name, sizeof(name), "Thread%u", (unsigned int)i); thread_states[i].number = i; - thread_states[i].thread = SDL_CreateThread(ThreadFuncRealWorld, name, (void *) &thread_states[i]); + thread_states[i].thread = SDL_CreateThread(ThreadFuncRealWorld, name, (void *)&thread_states[i]); } /* Wait 10 seconds */ @@ -155,7 +157,7 @@ TestOverheadUncontended(void) static int SDLCALL ThreadFuncOverheadContended(void *data) { - Thread_State *state = (Thread_State *) data; + Thread_State *state = (Thread_State *)data; if (state->flag) { while (alive) { @@ -182,7 +184,7 @@ TestOverheadContended(SDL_bool try_wait) Uint32 start_ticks; Uint32 end_ticks; Uint32 duration; - Thread_State thread_states[NUM_THREADS] = { {0} }; + Thread_State thread_states[NUM_THREADS] = { { 0 } }; char textBuffer[1024]; int loop_count; int content_count; @@ -196,9 +198,9 @@ TestOverheadContended(SDL_bool try_wait) /* Create multiple threads to starve the semaphore and cause contention */ for (i = 0; i < NUM_THREADS; ++i) { char name[64]; - SDL_snprintf(name, sizeof (name), "Thread%u", (unsigned int) i); + SDL_snprintf(name, sizeof(name), "Thread%u", (unsigned int)i); thread_states[i].flag = try_wait; - thread_states[i].thread = SDL_CreateThread(ThreadFuncOverheadContended, name, (void *) &thread_states[i]); + thread_states[i].thread = SDL_CreateThread(ThreadFuncOverheadContended, name, (void *)&thread_states[i]); } start_ticks = SDL_GetTicks(); @@ -207,7 +209,8 @@ TestOverheadContended(SDL_bool try_wait) SDL_SemPost(sem); } /* Make sure threads consumed everything */ - while (SDL_SemValue(sem)) { } + while (SDL_SemValue(sem)) { + } } end_ticks = SDL_GetTicks(); @@ -224,7 +227,7 @@ TestOverheadContended(SDL_bool try_wait) duration = end_ticks - start_ticks; SDL_Log("Took %" SDL_PRIu32 " milliseconds, threads %s %d out of %d times in total (%.2f%%)\n", duration, try_wait ? "where contended" : "timed out", content_count, - loop_count, ((float) content_count * 100) / loop_count); + loop_count, ((float)content_count * 100) / loop_count); /* Print how many semaphores where consumed per thread */ SDL_snprintf(textBuffer, sizeof(textBuffer), "{ "); for (i = 0; i < NUM_THREADS; ++i) { @@ -242,8 +245,7 @@ TestOverheadContended(SDL_bool try_wait) SDL_DestroySemaphore(sem); } -int -main(int argc, char **argv) +int main(int argc, char **argv) { int init_sem; diff --git a/test/testsensor.c b/test/testsensor.c index 441460302..1e207e13f 100644 --- a/test/testsensor.c +++ b/test/testsensor.c @@ -18,8 +18,7 @@ static const char *GetSensorTypeString(SDL_SensorType type) { static char unknown_type[64]; - switch (type) - { + switch (type) { case SDL_SENSOR_INVALID: return "SDL_SENSOR_INVALID"; case SDL_SENSOR_UNKNOWN: @@ -55,8 +54,7 @@ static void HandleSensorEvent(SDL_SensorEvent *event) } } -int -main(int argc, char **argv) +int main(int argc, char **argv) { int i; int num_sensors, num_opened; diff --git a/test/testshader.c b/test/testshader.c index 3b757e2a7..7a1a4e0a6 100644 --- a/test/testshader.c +++ b/test/testshader.c @@ -17,18 +17,19 @@ #include "SDL_opengl.h" - static SDL_bool shaders_supported; -static int current_shader = 0; +static int current_shader = 0; -enum { +enum +{ SHADER_COLOR, SHADER_TEXTURE, SHADER_TEXCOORDS, NUM_SHADERS }; -typedef struct { +typedef struct +{ GLhandleARB program; GLhandleARB vert_shader; GLhandleARB frag_shader; @@ -40,75 +41,72 @@ static ShaderData shaders[NUM_SHADERS] = { /* SHADER_COLOR */ { 0, 0, 0, - /* vertex shader */ -"varying vec4 v_color;\n" -"\n" -"void main()\n" -"{\n" -" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" -" v_color = gl_Color;\n" -"}", - /* fragment shader */ -"varying vec4 v_color;\n" -"\n" -"void main()\n" -"{\n" -" gl_FragColor = v_color;\n" -"}" - }, + /* vertex shader */ + "varying vec4 v_color;\n" + "\n" + "void main()\n" + "{\n" + " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" + " v_color = gl_Color;\n" + "}", + /* fragment shader */ + "varying vec4 v_color;\n" + "\n" + "void main()\n" + "{\n" + " gl_FragColor = v_color;\n" + "}" }, /* SHADER_TEXTURE */ { 0, 0, 0, - /* vertex shader */ -"varying vec4 v_color;\n" -"varying vec2 v_texCoord;\n" -"\n" -"void main()\n" -"{\n" -" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" -" v_color = gl_Color;\n" -" v_texCoord = vec2(gl_MultiTexCoord0);\n" -"}", - /* fragment shader */ -"varying vec4 v_color;\n" -"varying vec2 v_texCoord;\n" -"uniform sampler2D tex0;\n" -"\n" -"void main()\n" -"{\n" -" gl_FragColor = texture2D(tex0, v_texCoord) * v_color;\n" -"}" - }, + /* vertex shader */ + "varying vec4 v_color;\n" + "varying vec2 v_texCoord;\n" + "\n" + "void main()\n" + "{\n" + " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" + " v_color = gl_Color;\n" + " v_texCoord = vec2(gl_MultiTexCoord0);\n" + "}", + /* fragment shader */ + "varying vec4 v_color;\n" + "varying vec2 v_texCoord;\n" + "uniform sampler2D tex0;\n" + "\n" + "void main()\n" + "{\n" + " gl_FragColor = texture2D(tex0, v_texCoord) * v_color;\n" + "}" }, /* SHADER_TEXCOORDS */ { 0, 0, 0, - /* vertex shader */ -"varying vec2 v_texCoord;\n" -"\n" -"void main()\n" -"{\n" -" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" -" v_texCoord = vec2(gl_MultiTexCoord0);\n" -"}", - /* fragment shader */ -"varying vec2 v_texCoord;\n" -"\n" -"void main()\n" -"{\n" -" vec4 color;\n" -" vec2 delta;\n" -" float dist;\n" -"\n" -" delta = vec2(0.5, 0.5) - v_texCoord;\n" -" dist = dot(delta, delta);\n" -"\n" -" color.r = v_texCoord.x;\n" -" color.g = v_texCoord.x * v_texCoord.y;\n" -" color.b = v_texCoord.y;\n" -" color.a = 1.0 - (dist * 4.0);\n" -" gl_FragColor = color;\n" -"}" - }, + /* vertex shader */ + "varying vec2 v_texCoord;\n" + "\n" + "void main()\n" + "{\n" + " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" + " v_texCoord = vec2(gl_MultiTexCoord0);\n" + "}", + /* fragment shader */ + "varying vec2 v_texCoord;\n" + "\n" + "void main()\n" + "{\n" + " vec4 color;\n" + " vec2 delta;\n" + " float dist;\n" + "\n" + " delta = vec2(0.5, 0.5) - v_texCoord;\n" + " dist = dot(delta, delta);\n" + "\n" + " color.r = v_texCoord.x;\n" + " color.g = v_texCoord.x * v_texCoord.y;\n" + " color.b = v_texCoord.y;\n" + " color.a = 1.0 - (dist * 4.0);\n" + " gl_FragColor = color;\n" + "}" }, }; static PFNGLATTACHOBJECTARBPROC glAttachObjectARB; @@ -136,7 +134,7 @@ static SDL_bool CompileShader(GLhandleARB shader, const char *source) char *info; glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); - info = (char *) SDL_malloc(length + 1); + info = (char *)SDL_malloc(length + 1); if (info == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!"); } else { @@ -164,7 +162,7 @@ static SDL_bool LinkProgram(ShaderData *data) char *info; glGetObjectParameterivARB(data->program, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); - info = (char *) SDL_malloc(length + 1); + info = (char *)SDL_malloc(length + 1); if (info == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!"); } else { @@ -240,18 +238,18 @@ static SDL_bool InitShaders() SDL_GL_ExtensionSupported("GL_ARB_shading_language_100") && SDL_GL_ExtensionSupported("GL_ARB_vertex_shader") && SDL_GL_ExtensionSupported("GL_ARB_fragment_shader")) { - glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) SDL_GL_GetProcAddress("glAttachObjectARB"); - glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) SDL_GL_GetProcAddress("glCompileShaderARB"); - glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glCreateProgramObjectARB"); - glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) SDL_GL_GetProcAddress("glCreateShaderObjectARB"); - glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) SDL_GL_GetProcAddress("glDeleteObjectARB"); - glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) SDL_GL_GetProcAddress("glGetInfoLogARB"); - glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) SDL_GL_GetProcAddress("glGetObjectParameterivARB"); - glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) SDL_GL_GetProcAddress("glGetUniformLocationARB"); - glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) SDL_GL_GetProcAddress("glLinkProgramARB"); - glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) SDL_GL_GetProcAddress("glShaderSourceARB"); - glUniform1iARB = (PFNGLUNIFORM1IARBPROC) SDL_GL_GetProcAddress("glUniform1iARB"); - glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glUseProgramObjectARB"); + glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)SDL_GL_GetProcAddress("glAttachObjectARB"); + glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)SDL_GL_GetProcAddress("glCompileShaderARB"); + glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glCreateProgramObjectARB"); + glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)SDL_GL_GetProcAddress("glCreateShaderObjectARB"); + glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)SDL_GL_GetProcAddress("glDeleteObjectARB"); + glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)SDL_GL_GetProcAddress("glGetInfoLogARB"); + glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)SDL_GL_GetProcAddress("glGetObjectParameterivARB"); + glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)SDL_GL_GetProcAddress("glGetUniformLocationARB"); + glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)SDL_GL_GetProcAddress("glLinkProgramARB"); + glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)SDL_GL_GetProcAddress("glShaderSourceARB"); + glUniform1iARB = (PFNGLUNIFORM1IARBPROC)SDL_GL_GetProcAddress("glUniform1iARB"); + glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glUseProgramObjectARB"); if (glAttachObjectARB && glCompileShaderARB && glCreateProgramObjectARB && @@ -306,7 +304,7 @@ power_of_two(int input) } GLuint -SDL_GL_LoadTexture(SDL_Surface * surface, GLfloat * texcoord) +SDL_GL_LoadTexture(SDL_Surface *surface, GLfloat *texcoord) { GLuint texture; int w, h; @@ -317,10 +315,10 @@ SDL_GL_LoadTexture(SDL_Surface * surface, GLfloat * texcoord) /* Use the surface width and height expanded to powers of 2 */ w = power_of_two(surface->w); h = power_of_two(surface->h); - texcoord[0] = 0.0f; /* Min X */ - texcoord[1] = 0.0f; /* Min Y */ - texcoord[2] = (GLfloat) surface->w / w; /* Max X */ - texcoord[3] = (GLfloat) surface->h / h; /* Max Y */ + texcoord[0] = 0.0f; /* Min X */ + texcoord[1] = 0.0f; /* Min Y */ + texcoord[2] = (GLfloat)surface->w / w; /* Max X */ + texcoord[3] = (GLfloat)surface->h / h; /* Max Y */ image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, #if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */ @@ -330,7 +328,7 @@ SDL_GL_LoadTexture(SDL_Surface * surface, GLfloat * texcoord) 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF #endif - ); + ); if (image == NULL) { return 0; } @@ -357,25 +355,25 @@ SDL_GL_LoadTexture(SDL_Surface * surface, GLfloat * texcoord) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels); - SDL_FreeSurface(image); /* No longer needed */ + SDL_FreeSurface(image); /* No longer needed */ return texture; } /* A general OpenGL initialization function. Sets all of the initial parameters. */ -void InitGL(int Width, int Height) /* We call this right after our OpenGL window is created. */ +void InitGL(int Width, int Height) /* We call this right after our OpenGL window is created. */ { GLdouble aspect; glViewport(0, 0, Width, Height); - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); /* This Will Clear The Background Color To Black */ - glClearDepth(1.0); /* Enables Clearing Of The Depth Buffer */ - glDepthFunc(GL_LESS); /* The Type Of Depth Test To Do */ - glEnable(GL_DEPTH_TEST); /* Enables Depth Testing */ - glShadeModel(GL_SMOOTH); /* Enables Smooth Color Shading */ + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); /* This Will Clear The Background Color To Black */ + glClearDepth(1.0); /* Enables Clearing Of The Depth Buffer */ + glDepthFunc(GL_LESS); /* The Type Of Depth Test To Do */ + glEnable(GL_DEPTH_TEST); /* Enables Depth Testing */ + glShadeModel(GL_SMOOTH); /* Enables Smooth Color Shading */ glMatrixMode(GL_PROJECTION); - glLoadIdentity(); /* Reset The Projection Matrix */ + glLoadIdentity(); /* Reset The Projection Matrix */ aspect = (GLdouble)Width / Height; glOrtho(-3.0, 3.0, -3.0 / aspect, 3.0 / aspect, 0.0, 1.0); @@ -384,32 +382,33 @@ void InitGL(int Width, int Height) /* We call this right afte } /* The main drawing function. */ -void DrawGLScene(SDL_Window *window, GLuint texture, GLfloat * texcoord) +void DrawGLScene(SDL_Window *window, GLuint texture, GLfloat *texcoord) { /* Texture coordinate lookup, to make it simple */ - enum { + enum + { MINX, MINY, MAXX, MAXY }; - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* Clear The Screen And The Depth Buffer */ - glLoadIdentity(); /* Reset The View */ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* Clear The Screen And The Depth Buffer */ + glLoadIdentity(); /* Reset The View */ - glTranslatef(-1.5f,0.0f,0.0f); /* Move Left 1.5 Units */ + glTranslatef(-1.5f, 0.0f, 0.0f); /* Move Left 1.5 Units */ /* draw a triangle (in smooth coloring mode) */ - glBegin(GL_POLYGON); /* start drawing a polygon */ - glColor3f(1.0f,0.0f,0.0f); /* Set The Color To Red */ - glVertex3f( 0.0f, 1.0f, 0.0f); /* Top */ - glColor3f(0.0f,1.0f,0.0f); /* Set The Color To Green */ - glVertex3f( 1.0f,-1.0f, 0.0f); /* Bottom Right */ - glColor3f(0.0f,0.0f,1.0f); /* Set The Color To Blue */ - glVertex3f(-1.0f,-1.0f, 0.0f); /* Bottom Left */ - glEnd(); /* we're done with the polygon (smooth color interpolation) */ + glBegin(GL_POLYGON); /* start drawing a polygon */ + glColor3f(1.0f, 0.0f, 0.0f); /* Set The Color To Red */ + glVertex3f(0.0f, 1.0f, 0.0f); /* Top */ + glColor3f(0.0f, 1.0f, 0.0f); /* Set The Color To Green */ + glVertex3f(1.0f, -1.0f, 0.0f); /* Bottom Right */ + glColor3f(0.0f, 0.0f, 1.0f); /* Set The Color To Blue */ + glVertex3f(-1.0f, -1.0f, 0.0f); /* Bottom Left */ + glEnd(); /* we're done with the polygon (smooth color interpolation) */ - glTranslatef(3.0f,0.0f,0.0f); /* Move Right 3 Units */ + glTranslatef(3.0f, 0.0f, 0.0f); /* Move Right 3 Units */ /* Enable blending */ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); @@ -419,21 +418,21 @@ void DrawGLScene(SDL_Window *window, GLuint texture, GLfloat * texcoord) /* draw a textured square (quadrilateral) */ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture); - glColor3f(1.0f,1.0f,1.0f); + glColor3f(1.0f, 1.0f, 1.0f); if (shaders_supported) { glUseProgramObjectARB(shaders[current_shader].program); } - glBegin(GL_QUADS); /* start drawing a polygon (4 sided) */ + glBegin(GL_QUADS); /* start drawing a polygon (4 sided) */ glTexCoord2f(texcoord[MINX], texcoord[MINY]); - glVertex3f(-1.0f, 1.0f, 0.0f); /* Top Left */ + glVertex3f(-1.0f, 1.0f, 0.0f); /* Top Left */ glTexCoord2f(texcoord[MAXX], texcoord[MINY]); - glVertex3f( 1.0f, 1.0f, 0.0f); /* Top Right */ + glVertex3f(1.0f, 1.0f, 0.0f); /* Top Right */ glTexCoord2f(texcoord[MAXX], texcoord[MAXY]); - glVertex3f( 1.0f,-1.0f, 0.0f); /* Bottom Right */ + glVertex3f(1.0f, -1.0f, 0.0f); /* Bottom Right */ glTexCoord2f(texcoord[MINX], texcoord[MAXY]); - glVertex3f(-1.0f,-1.0f, 0.0f); /* Bottom Left */ - glEnd(); /* done with the polygon */ + glVertex3f(-1.0f, -1.0f, 0.0f); /* Bottom Left */ + glEnd(); /* done with the polygon */ if (shaders_supported) { glUseProgramObjectARB(0); @@ -456,20 +455,20 @@ int main(int argc, char **argv) SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); /* Initialize SDL for video output */ - if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { + if (SDL_Init(SDL_INIT_VIDEO) < 0) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to initialize SDL: %s\n", SDL_GetError()); exit(1); } /* Create a 640x480 OpenGL screen */ - window = SDL_CreateWindow( "Shader Demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL ); + window = SDL_CreateWindow("Shader Demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL); if (window == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s\n", SDL_GetError()); SDL_Quit(); exit(2); } - if ( !SDL_GL_CreateContext(window)) { + if (!SDL_GL_CreateContext(window)) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL context: %s\n", SDL_GetError()); SDL_Quit(); exit(2); @@ -492,20 +491,21 @@ int main(int argc, char **argv) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Shaders not supported!\n"); } done = 0; - while ( ! done ) { + while (!done) { DrawGLScene(window, texture, texcoords); /* This could go in a separate function */ - { SDL_Event event; - while ( SDL_PollEvent(&event) ) { - if ( event.type == SDL_QUIT ) { + { + SDL_Event event; + while (SDL_PollEvent(&event)) { + if (event.type == SDL_QUIT) { done = 1; } - if ( event.type == SDL_KEYDOWN ) { - if ( event.key.keysym.sym == SDLK_SPACE ) { + if (event.type == SDL_KEYDOWN) { + if (event.key.keysym.sym == SDLK_SPACE) { current_shader = (current_shader + 1) % NUM_SHADERS; } - if ( event.key.keysym.sym == SDLK_ESCAPE ) { + if (event.key.keysym.sym == SDLK_ESCAPE) { done = 1; } } @@ -519,8 +519,7 @@ int main(int argc, char **argv) #else /* HAVE_OPENGL */ -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n"); return 1; diff --git a/test/testshape.c b/test/testshape.c index 67fa6f74f..fa8de5e0a 100644 --- a/test/testshape.c +++ b/test/testshape.c @@ -15,38 +15,39 @@ #include "SDL.h" #include "SDL_shape.h" -#define SHAPED_WINDOW_X 150 -#define SHAPED_WINDOW_Y 150 +#define SHAPED_WINDOW_X 150 +#define SHAPED_WINDOW_Y 150 #define SHAPED_WINDOW_DIMENSION 640 -typedef struct LoadedPicture { +typedef struct LoadedPicture +{ SDL_Surface *surface; SDL_Texture *texture; SDL_WindowShapeMode mode; - const char* name; + const char *name; } LoadedPicture; -void render(SDL_Renderer *renderer,SDL_Texture *texture,SDL_Rect texture_dimensions) +void render(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Rect texture_dimensions) { /* Clear render-target to blue. */ - SDL_SetRenderDrawColor(renderer,0x00,0x00,0xff,0xff); + SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0xff, 0xff); SDL_RenderClear(renderer); /* Render the texture. */ - SDL_RenderCopy(renderer,texture,&texture_dimensions,&texture_dimensions); + SDL_RenderCopy(renderer, texture, &texture_dimensions, &texture_dimensions); SDL_RenderPresent(renderer); } -int main(int argc,char** argv) +int main(int argc, char **argv) { Uint8 num_pictures; - LoadedPicture* pictures; + LoadedPicture *pictures; int i, j; - SDL_PixelFormat* format = NULL; + SDL_PixelFormat *format = NULL; SDL_Window *window; SDL_Renderer *renderer; - SDL_Color black = {0,0,0,0xff}; + SDL_Color black = { 0, 0, 0, 0xff }; SDL_Event event; int should_exit = 0; unsigned int current_picture; @@ -69,7 +70,7 @@ int main(int argc,char** argv) } num_pictures = argc - 1; - pictures = (LoadedPicture *)SDL_malloc(sizeof(LoadedPicture)*num_pictures); + pictures = (LoadedPicture *)SDL_malloc(sizeof(LoadedPicture) * num_pictures); if (pictures == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not allocate memory."); exit(1); @@ -77,16 +78,16 @@ int main(int argc,char** argv) for (i = 0; i < num_pictures; i++) { pictures[i].surface = NULL; } - for (i=0;i 0) { @@ -221,7 +219,6 @@ MoveSprites(SDL_Renderer * renderer, SDL_Texture * sprite) velocity->y = -velocity->y; position->y += velocity->y; } - } /* Countdown sprite-move iterations and disable color changes at iteration end - used for visual tests. */ @@ -251,7 +248,7 @@ MoveSprites(SDL_Renderer * renderer, SDL_Texture * sprite) * * Draw sprite2 as triangles that can be recombined as rect by software renderer */ - SDL_Vertex *verts = (SDL_Vertex *) SDL_malloc(num_sprites * sizeof (SDL_Vertex) * 6); + SDL_Vertex *verts = (SDL_Vertex *)SDL_malloc(num_sprites * sizeof(SDL_Vertex) * 6); SDL_Vertex *verts2 = verts; if (verts) { SDL_Color color; @@ -319,9 +316,9 @@ MoveSprites(SDL_Renderer * renderer, SDL_Texture * sprite) * Draw sprite2 as triangles that can *not* be recombined as rect by software renderer * Use an 'indices' array */ - SDL_Vertex *verts = (SDL_Vertex *) SDL_malloc(num_sprites * sizeof (SDL_Vertex) * 5); + SDL_Vertex *verts = (SDL_Vertex *)SDL_malloc(num_sprites * sizeof(SDL_Vertex) * 5); SDL_Vertex *verts2 = verts; - int *indices = (int *) SDL_malloc(num_sprites * sizeof (int) * 4 * 3); + int *indices = (int *)SDL_malloc(num_sprites * sizeof(int) * 4 * 3); int *indices2 = indices; if (verts && indices) { int pos = 0; @@ -395,8 +392,7 @@ MoveSprites(SDL_Renderer * renderer, SDL_Texture * sprite) SDL_RenderPresent(renderer); } -void -loop() +void loop() { Uint32 now; int i; @@ -423,16 +419,14 @@ loop() if (SDL_TICKS_PASSED(now, next_fps_check)) { /* Print out some timing information */ const Uint32 then = next_fps_check - fps_check_delay; - const double fps = ((double) frames * 1000) / (now - then); + const double fps = ((double)frames * 1000) / (now - then); SDL_Log("%2.2f frames per second\n", fps); next_fps_check = now + fps_check_delay; frames = 0; } - } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i; Uint64 seed; @@ -517,7 +511,8 @@ main(int argc, char *argv[]) "[--use-rendergeometry mode1|mode2]", "[num_sprites]", "[icon.bmp]", - NULL }; + NULL + }; SDLTest_CommonLogUsage(state, argv[0], options); quit(1); } @@ -529,7 +524,7 @@ main(int argc, char *argv[]) /* Create the windows, initialize the renderers, and load the textures */ sprites = - (SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites)); + (SDL_Texture **)SDL_malloc(state->num_windows * sizeof(*sprites)); if (sprites == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); @@ -544,8 +539,8 @@ main(int argc, char *argv[]) } /* Allocate memory for the sprite info */ - positions = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect)); - velocities = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect)); + positions = (SDL_Rect *)SDL_malloc(num_sprites * sizeof(SDL_Rect)); + velocities = (SDL_Rect *)SDL_malloc(num_sprites * sizeof(SDL_Rect)); if (positions == NULL || velocities == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); diff --git a/test/testspriteminimal.c b/test/testspriteminimal.c index 6be99fd4a..504dc4a3b 100644 --- a/test/testspriteminimal.c +++ b/test/testspriteminimal.c @@ -22,10 +22,10 @@ #include "SDL.h" #include "testutils.h" -#define WINDOW_WIDTH 640 -#define WINDOW_HEIGHT 480 -#define NUM_SPRITES 100 -#define MAX_SPEED 1 +#define WINDOW_WIDTH 640 +#define WINDOW_HEIGHT 480 +#define NUM_SPRITES 100 +#define MAX_SPEED 1 static SDL_Texture *sprite; static SDL_Rect positions[NUM_SPRITES]; @@ -43,8 +43,7 @@ quit(int rc) exit(rc); } -void -MoveSprites() +void MoveSprites() { int i; int window_w = WINDOW_WIDTH; @@ -96,13 +95,11 @@ void loop() #endif } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { SDL_Window *window; int i; - /* Enable standard application logging */ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); diff --git a/test/teststreaming.c b/test/teststreaming.c index e2ad9c180..980046a15 100644 --- a/test/teststreaming.c +++ b/test/teststreaming.c @@ -28,9 +28,10 @@ #define MOOSEPIC_W 64 #define MOOSEPIC_H 88 -#define MOOSEFRAME_SIZE (MOOSEPIC_W * MOOSEPIC_H) +#define MOOSEFRAME_SIZE (MOOSEPIC_W * MOOSEPIC_H) #define MOOSEFRAMES_COUNT 10 +/* *INDENT-OFF* */ /* clang-format off */ SDL_Color MooseColors[84] = { {49, 49, 49, 255}, {66, 24, 0, 255}, {66, 33, 0, 255}, {66, 66, 66, 255}, {66, 115, 49, 255}, {74, 33, 0, 255}, {74, 41, 16, 255}, {82, 33, 8, 255}, @@ -54,6 +55,7 @@ SDL_Color MooseColors[84] = { {214, 173, 140, 255}, {222, 181, 148, 255}, {222, 189, 132, 255}, {222, 189, 156, 255}, {222, 222, 222, 255}, {231, 198, 165, 255}, {231, 231, 231, 255}, {239, 206, 173, 255} }; +/* *INDENT-ON* */ /* clang-format on */ Uint8 MooseFrames[MOOSEFRAMES_COUNT][MOOSEFRAME_SIZE]; @@ -83,17 +85,16 @@ void UpdateTexture(SDL_Texture *texture) } src = MooseFrames[frame]; for (row = 0; row < MOOSEPIC_H; ++row) { - dst = (Uint32*)((Uint8*)pixels + row * pitch); + dst = (Uint32 *)((Uint8 *)pixels + row * pitch); for (col = 0; col < MOOSEPIC_W; ++col) { color = &MooseColors[*src++]; - *dst++ = (0xFF000000|(color->r<<16)|(color->g<<8)|color->b); + *dst++ = (0xFF000000 | (color->r << 16) | (color->g << 8) | color->b); } } SDL_UnlockTexture(texture); } -void -loop() +void loop() { SDL_Event event; @@ -124,8 +125,7 @@ loop() #endif } -int -main(int argc, char **argv) +int main(int argc, char **argv) { SDL_Window *window; SDL_RWops *handle; @@ -154,12 +154,11 @@ main(int argc, char **argv) SDL_RWread(handle, MooseFrames, MOOSEFRAME_SIZE, MOOSEFRAMES_COUNT); SDL_RWclose(handle); - /* Create the window and renderer */ window = SDL_CreateWindow("Happy Moose", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - MOOSEPIC_W*4, MOOSEPIC_H*4, + MOOSEPIC_W * 4, MOOSEPIC_H * 4, SDL_WINDOW_RESIZABLE); if (window == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError()); @@ -186,7 +185,7 @@ main(int argc, char **argv) #else while (!done) { loop(); - } + } #endif SDL_DestroyRenderer(renderer); diff --git a/test/testsurround.c b/test/testsurround.c index 1537b35fe..6c5fe46ce 100644 --- a/test/testsurround.c +++ b/test/testsurround.c @@ -18,16 +18,16 @@ static int total_channels; static int active_channel; -#define SAMPLE_RATE_HZ 48000 -#define QUICK_TEST_TIME_MSEC 100 +#define SAMPLE_RATE_HZ 48000 +#define QUICK_TEST_TIME_MSEC 100 #define CHANNEL_TEST_TIME_SEC 5 -#define MAX_AMPLITUDE SDL_MAX_SINT16 +#define MAX_AMPLITUDE SDL_MAX_SINT16 -#define SINE_FREQ_HZ 500 +#define SINE_FREQ_HZ 500 #define LFE_SINE_FREQ_HZ 50 /* The channel layout is defined in SDL_audio.h */ -const char* +const char * get_channel_name(int channel_index, int channel_count) { switch (channel_index) { @@ -92,9 +92,9 @@ is_lfe_channel(int channel_index, int channel_count) } void SDLCALL -fill_buffer(void* unused, Uint8* stream, int len) +fill_buffer(void *unused, Uint8 *stream, int len) { - Sint16* buffer = (Sint16*)stream; + Sint16 *buffer = (Sint16 *)stream; int samples = len / sizeof(Sint16); static int total_samples = 0; int i; @@ -132,8 +132,7 @@ fill_buffer(void* unused, Uint8* stream, int len) } } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i; diff --git a/test/testthread.c b/test/testthread.c index 894f994c4..faa022e8c 100644 --- a/test/testthread.c +++ b/test/testthread.c @@ -33,12 +33,15 @@ quit(int rc) static const char * getprioritystr(SDL_ThreadPriority priority) { - switch(priority) - { - case SDL_THREAD_PRIORITY_LOW: return "SDL_THREAD_PRIORITY_LOW"; - case SDL_THREAD_PRIORITY_NORMAL: return "SDL_THREAD_PRIORITY_NORMAL"; - case SDL_THREAD_PRIORITY_HIGH: return "SDL_THREAD_PRIORITY_HIGH"; - case SDL_THREAD_PRIORITY_TIME_CRITICAL: return "SDL_THREAD_PRIORITY_TIME_CRITICAL"; + switch (priority) { + case SDL_THREAD_PRIORITY_LOW: + return "SDL_THREAD_PRIORITY_LOW"; + case SDL_THREAD_PRIORITY_NORMAL: + return "SDL_THREAD_PRIORITY_NORMAL"; + case SDL_THREAD_PRIORITY_HIGH: + return "SDL_THREAD_PRIORITY_HIGH"; + case SDL_THREAD_PRIORITY_TIME_CRITICAL: + return "SDL_THREAD_PRIORITY_TIME_CRITICAL"; } return "???"; @@ -51,9 +54,9 @@ ThreadFunc(void *data) SDL_TLSSet(tls, "baby thread", NULL); SDL_Log("Started thread %s: My thread id is %lu, thread data = %s\n", - (char *) data, SDL_ThreadID(), (const char *)SDL_TLSGet(tls)); + (char *)data, SDL_ThreadID(), (const char *)SDL_TLSGet(tls)); while (alive) { - SDL_Log("Thread '%s' is alive!\n", (char *) data); + SDL_Log("Thread '%s' is alive!\n", (char *)data); if (testprio) { SDL_Log("SDL_SetThreadPriority(%s):%d\n", getprioritystr(prio), SDL_SetThreadPriority(prio)); @@ -64,7 +67,7 @@ ThreadFunc(void *data) SDL_Delay(1 * 1000); } - SDL_Log("Thread '%s' exiting!\n", (char *) data); + SDL_Log("Thread '%s' exiting!\n", (char *)data); return 0; } @@ -77,8 +80,7 @@ killed(int sig) quit(0); } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int arg = 1; SDL_Thread *thread; @@ -132,6 +134,6 @@ main(int argc, char *argv[]) } raise(SIGTERM); - SDL_Quit(); /* Never reached */ - return 0; /* Never reached */ + SDL_Quit(); /* Never reached */ + return 0; /* Never reached */ } diff --git a/test/testtimer.c b/test/testtimer.c index 5dd17abf2..18284da5b 100644 --- a/test/testtimer.c +++ b/test/testtimer.c @@ -19,7 +19,7 @@ #include "SDL.h" -#define DEFAULT_RESOLUTION 1 +#define DEFAULT_RESOLUTION 1 static int ticks = 0; @@ -33,12 +33,11 @@ ticktock(Uint32 interval, void *param) static Uint32 SDLCALL callback(Uint32 interval, void *param) { - SDL_Log("Timer %" SDL_PRIu32 " : param = %d\n", interval, (int) (uintptr_t) param); + SDL_Log("Timer %" SDL_PRIu32 " : param = %d\n", interval, (int)(uintptr_t)param); return interval; } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i, desired; SDL_TimerID t1, t2, t3; @@ -95,20 +94,20 @@ main(int argc, char *argv[]) /* Print the results */ if (ticks) { SDL_Log("Timer resolution: desired = %d ms, actual = %f ms\n", - desired, (double) (10 * 1000) / ticks); + desired, (double)(10 * 1000) / ticks); } /* Test multiple timers */ SDL_Log("Testing multiple timers...\n"); - t1 = SDL_AddTimer(100, callback, (void *) 1); + t1 = SDL_AddTimer(100, callback, (void *)1); if (!t1) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create timer 1: %s\n", SDL_GetError()); } - t2 = SDL_AddTimer(50, callback, (void *) 2); + t2 = SDL_AddTimer(50, callback, (void *)2); if (!t2) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create timer 2: %s\n", SDL_GetError()); } - t3 = SDL_AddTimer(233, callback, (void *) 3); + t3 = SDL_AddTimer(233, callback, (void *)3); if (!t3) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create timer 3: %s\n", SDL_GetError()); } @@ -130,9 +129,9 @@ main(int argc, char *argv[]) ticktock(0, NULL); } now = SDL_GetPerformanceCounter(); - SDL_Log("1 million iterations of ticktock took %f ms\n", (double)((now - start)*1000) / SDL_GetPerformanceFrequency()); + SDL_Log("1 million iterations of ticktock took %f ms\n", (double)((now - start) * 1000) / SDL_GetPerformanceFrequency()); - SDL_Log("Performance counter frequency: %"SDL_PRIu64"\n", SDL_GetPerformanceFrequency()); + SDL_Log("Performance counter frequency: %" SDL_PRIu64 "\n", SDL_GetPerformanceFrequency()); start64 = SDL_GetTicks64(); start32 = SDL_GetTicks(); start = SDL_GetPerformanceCounter(); @@ -140,7 +139,7 @@ main(int argc, char *argv[]) now = SDL_GetPerformanceCounter(); now64 = SDL_GetTicks64(); now32 = SDL_GetTicks(); - SDL_Log("Delay 1 second = %d ms in ticks, %d ms in ticks64, %f ms according to performance counter\n", (int) (now32-start32), (int) (now64-start64), (double)((now - start)*1000) / SDL_GetPerformanceFrequency()); + SDL_Log("Delay 1 second = %d ms in ticks, %d ms in ticks64, %f ms according to performance counter\n", (int)(now32 - start32), (int)(now64 - start64), (double)((now - start) * 1000) / SDL_GetPerformanceFrequency()); SDL_Quit(); return 0; diff --git a/test/testutils.c b/test/testutils.c index 765340b5f..024003052 100644 --- a/test/testutils.c +++ b/test/testutils.c @@ -114,17 +114,17 @@ LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent, switch (temp->format->BitsPerPixel) { case 15: SDL_SetColorKey(temp, SDL_TRUE, - (*(Uint16 *) temp->pixels) & 0x00007FFF); + (*(Uint16 *)temp->pixels) & 0x00007FFF); break; case 16: - SDL_SetColorKey(temp, SDL_TRUE, *(Uint16 *) temp->pixels); + SDL_SetColorKey(temp, SDL_TRUE, *(Uint16 *)temp->pixels); break; case 24: SDL_SetColorKey(temp, SDL_TRUE, - (*(Uint32 *) temp->pixels) & 0x00FFFFFF); + (*(Uint32 *)temp->pixels) & 0x00FFFFFF); break; case 32: - SDL_SetColorKey(temp, SDL_TRUE, *(Uint32 *) temp->pixels); + SDL_SetColorKey(temp, SDL_TRUE, *(Uint32 *)temp->pixels); break; } } diff --git a/test/testver.c b/test/testver.c index f452b9c2b..863de57a9 100644 --- a/test/testver.c +++ b/test/testver.c @@ -20,8 +20,7 @@ #include "SDL.h" #include "SDL_revision.h" -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { SDL_version compiled; SDL_version linked; @@ -36,12 +35,12 @@ main(int argc, char *argv[]) #endif SDL_VERSION(&compiled); SDL_Log("Compiled version: %d.%d.%d (%s)\n", - compiled.major, compiled.minor, compiled.patch, - SDL_REVISION); + compiled.major, compiled.minor, compiled.patch, + SDL_REVISION); SDL_GetVersion(&linked); SDL_Log("Linked version: %d.%d.%d (%s)\n", - linked.major, linked.minor, linked.patch, - SDL_GetRevision()); + linked.major, linked.minor, linked.patch, + SDL_GetRevision()); SDL_Quit(); return 0; } diff --git a/test/testviewport.c b/test/testviewport.c index ecdb4307f..df1bedf17 100644 --- a/test/testviewport.c +++ b/test/testviewport.c @@ -42,43 +42,42 @@ quit(int rc) exit(rc); } -void -DrawOnViewport(SDL_Renderer * renderer) -{ +void DrawOnViewport(SDL_Renderer *renderer) +{ SDL_Rect rect; /* Set the viewport */ SDL_RenderSetViewport(renderer, &viewport); - + /* Draw a gray background */ SDL_SetRenderDrawColor(renderer, 0x80, 0x80, 0x80, 0xFF); SDL_RenderClear(renderer); /* Test inside points */ SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0x00, 0xFF); - SDL_RenderDrawPoint(renderer, viewport.h/2 + 20, viewport.w/2); - SDL_RenderDrawPoint(renderer, viewport.h/2 - 20, viewport.w/2); - SDL_RenderDrawPoint(renderer, viewport.h/2 , viewport.w/2 - 20); - SDL_RenderDrawPoint(renderer, viewport.h/2 , viewport.w/2 + 20); + SDL_RenderDrawPoint(renderer, viewport.h / 2 + 20, viewport.w / 2); + SDL_RenderDrawPoint(renderer, viewport.h / 2 - 20, viewport.w / 2); + SDL_RenderDrawPoint(renderer, viewport.h / 2, viewport.w / 2 - 20); + SDL_RenderDrawPoint(renderer, viewport.h / 2, viewport.w / 2 + 20); /* Test horizontal and vertical lines */ SDL_SetRenderDrawColor(renderer, 0x00, 0xFF, 0x00, 0xFF); - SDL_RenderDrawLine(renderer, 1, 0, viewport.w-2, 0); - SDL_RenderDrawLine(renderer, 1, viewport.h-1, viewport.w-2, viewport.h-1); - SDL_RenderDrawLine(renderer, 0, 1, 0, viewport.h-2); - SDL_RenderDrawLine(renderer, viewport.w-1, 1, viewport.w-1, viewport.h-2); + SDL_RenderDrawLine(renderer, 1, 0, viewport.w - 2, 0); + SDL_RenderDrawLine(renderer, 1, viewport.h - 1, viewport.w - 2, viewport.h - 1); + SDL_RenderDrawLine(renderer, 0, 1, 0, viewport.h - 2); + SDL_RenderDrawLine(renderer, viewport.w - 1, 1, viewport.w - 1, viewport.h - 2); /* Test diagonal lines */ SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0xFF, 0xFF); - SDL_RenderDrawLine(renderer, 0, 0, viewport.w-1, viewport.h-1); - SDL_RenderDrawLine(renderer, viewport.w-1, 0, 0, viewport.h-1); + SDL_RenderDrawLine(renderer, 0, 0, viewport.w - 1, viewport.h - 1); + SDL_RenderDrawLine(renderer, viewport.w - 1, 0, 0, viewport.h - 1); /* Test outside points */ SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0x00, 0xFF); - SDL_RenderDrawPoint(renderer, viewport.h/2 + viewport.h, viewport.w/2); - SDL_RenderDrawPoint(renderer, viewport.h/2 - viewport.h, viewport.w/2); - SDL_RenderDrawPoint(renderer, viewport.h/2, viewport.w/2 - viewport.w); - SDL_RenderDrawPoint(renderer, viewport.h/2, viewport.w/2 + viewport.w); + SDL_RenderDrawPoint(renderer, viewport.h / 2 + viewport.h, viewport.w / 2); + SDL_RenderDrawPoint(renderer, viewport.h / 2 - viewport.h, viewport.w / 2); + SDL_RenderDrawPoint(renderer, viewport.h / 2, viewport.w / 2 - viewport.w); + SDL_RenderDrawPoint(renderer, viewport.h / 2, viewport.w / 2 + viewport.w); /* Add a box at the top */ rect.w = 8; @@ -96,8 +95,7 @@ DrawOnViewport(SDL_Renderer * renderer) SDL_RenderSetClipRect(renderer, NULL); } -void -loop() +void loop() { SDL_Event event; int i; @@ -147,8 +145,7 @@ loop() #endif } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i; Uint32 then, now, frames; @@ -159,7 +156,6 @@ main(int argc, char *argv[]) return 1; } - for (i = 1; i < argc;) { int consumed; @@ -224,7 +220,7 @@ main(int argc, char *argv[]) /* Print out some timing information */ now = SDL_GetTicks(); if (now > then) { - double fps = ((double) frames * 1000) / (now - then); + double fps = ((double)frames * 1000) / (now - then); SDL_Log("%2.2f frames per second\n", fps); } quit(0); diff --git a/test/testvulkan.c b/test/testvulkan.c index 4fe2c10be..64319a408 100644 --- a/test/testvulkan.c +++ b/test/testvulkan.c @@ -84,8 +84,8 @@ int main(int argc, char *argv[]) VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfacePresentModesKHR) \ VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceSupportKHR) -#define VULKAN_DEVICE_FUNCTION(name) static PFN_##name name = NULL; -#define VULKAN_GLOBAL_FUNCTION(name) static PFN_##name name = NULL; +#define VULKAN_DEVICE_FUNCTION(name) static PFN_##name name = NULL; +#define VULKAN_GLOBAL_FUNCTION(name) static PFN_##name name = NULL; #define VULKAN_INSTANCE_FUNCTION(name) static PFN_##name name = NULL; VULKAN_FUNCTIONS() #undef VULKAN_DEVICE_FUNCTION @@ -103,16 +103,18 @@ enum }; #endif #if VK_HEADER_VERSION < 38 -enum { +enum +{ VK_ERROR_OUT_OF_POOL_MEMORY_KHR = -1000069000 }; #endif static const char *getVulkanResultString(VkResult result) { - switch((int) result) - { - #define RESULT_CASE(x) case x: return #x + switch ((int)result) { +#define RESULT_CASE(x) \ + case x: \ + return #x RESULT_CASE(VK_SUCCESS); RESULT_CASE(VK_NOT_READY); RESULT_CASE(VK_TIMEOUT); @@ -139,8 +141,9 @@ static const char *getVulkanResultString(VkResult result) RESULT_CASE(VK_ERROR_VALIDATION_FAILED_EXT); RESULT_CASE(VK_ERROR_OUT_OF_POOL_MEMORY_KHR); RESULT_CASE(VK_ERROR_INVALID_SHADER_NV); - #undef RESULT_CASE - default: break; +#undef RESULT_CASE + default: + break; } return (result < 0) ? "VK_ERROR_" : "VK_"; } @@ -176,7 +179,7 @@ typedef struct VulkanContext } VulkanContext; static SDLTest_CommonState *state; -static VulkanContext *vulkanContexts = NULL; // an array of state->num_windows items +static VulkanContext *vulkanContexts = NULL; // an array of state->num_windows items static VulkanContext *vulkanContext = NULL; // for the currently-rendering window static void shutdownVulkan(SDL_bool doDestroySwapchain); @@ -216,8 +219,8 @@ static void loadGlobalFunctions(void) static void createInstance(void) { - VkApplicationInfo appInfo = {0}; - VkInstanceCreateInfo instanceCreateInfo = {0}; + VkApplicationInfo appInfo = { 0 }; + VkInstanceCreateInfo instanceCreateInfo = { 0 }; const char **extensions = NULL; unsigned extensionCount = 0; VkResult result; @@ -232,13 +235,13 @@ static void createInstance(void) SDL_GetError()); quit(2); } - extensions = (const char **) SDL_malloc(sizeof(const char *) * extensionCount); + extensions = (const char **)SDL_malloc(sizeof(const char *) * extensionCount); if (extensions == NULL) { SDL_OutOfMemory(); quit(2); } if (!SDL_Vulkan_GetInstanceExtensions(NULL, &extensionCount, extensions)) { - SDL_free((void*)extensions); + SDL_free((void *)extensions); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Vulkan_GetInstanceExtensions(): %s\n", SDL_GetError()); @@ -247,7 +250,7 @@ static void createInstance(void) instanceCreateInfo.enabledExtensionCount = extensionCount; instanceCreateInfo.ppEnabledExtensionNames = extensions; result = vkCreateInstance(&instanceCreateInfo, NULL, &vulkanContext->instance); - SDL_free((void*)extensions); + SDL_free((void *)extensions); if (result != VK_SUCCESS) { vulkanContext->instance = VK_NULL_HANDLE; SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, @@ -277,8 +280,8 @@ static void loadInstanceFunctions(void) static void createSurface(void) { if (!SDL_Vulkan_CreateSurface(vulkanContext->window, - vulkanContext->instance, - &vulkanContext->surface)) { + vulkanContext->instance, + &vulkanContext->surface)) { vulkanContext->surface = VK_NULL_HANDLE; SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Vulkan_CreateSurface(): %s\n", SDL_GetError()); quit(2); @@ -308,7 +311,7 @@ static void findPhysicalDevice(void) "vkEnumeratePhysicalDevices(): no physical devices\n"); quit(2); } - physicalDevices = (VkPhysicalDevice *) SDL_malloc(sizeof(VkPhysicalDevice) * physicalDeviceCount); + physicalDevices = (VkPhysicalDevice *)SDL_malloc(sizeof(VkPhysicalDevice) * physicalDeviceCount); if (physicalDevices == NULL) { SDL_OutOfMemory(); quit(2); @@ -342,7 +345,7 @@ static void findPhysicalDevice(void) if (queueFamiliesPropertiesAllocatedSize < queueFamiliesCount) { SDL_free(queueFamiliesProperties); queueFamiliesPropertiesAllocatedSize = queueFamiliesCount; - queueFamiliesProperties = (VkQueueFamilyProperties *) SDL_malloc(sizeof(VkQueueFamilyProperties) * queueFamiliesPropertiesAllocatedSize); + queueFamiliesProperties = (VkQueueFamilyProperties *)SDL_malloc(sizeof(VkQueueFamilyProperties) * queueFamiliesPropertiesAllocatedSize); if (queueFamiliesProperties == NULL) { SDL_free(physicalDevices); SDL_free(deviceExtensions); @@ -382,10 +385,10 @@ static void findPhysicalDevice(void) } } - if (vulkanContext->graphicsQueueFamilyIndex == queueFamiliesCount) { // no good queues found + if (vulkanContext->graphicsQueueFamilyIndex == queueFamiliesCount) { // no good queues found continue; } - if (vulkanContext->presentQueueFamilyIndex == queueFamiliesCount) { // no good queues found + if (vulkanContext->presentQueueFamilyIndex == queueFamiliesCount) { // no good queues found continue; } result = vkEnumerateDeviceExtensionProperties(physicalDevice, NULL, &deviceExtensionCount, NULL); @@ -445,9 +448,9 @@ static void findPhysicalDevice(void) static void createDevice(void) { - VkDeviceQueueCreateInfo deviceQueueCreateInfo[1] = { {0} }; - static const float queuePriority[] = {1.0f}; - VkDeviceCreateInfo deviceCreateInfo = {0}; + VkDeviceQueueCreateInfo deviceQueueCreateInfo[1] = { { 0 } }; + static const float queuePriority[] = { 1.0f }; + VkDeviceCreateInfo deviceCreateInfo = { 0 }; static const char *const deviceExtensionNames[] = { VK_KHR_SWAPCHAIN_EXTENSION_NAME, }; @@ -511,7 +514,7 @@ static void createSemaphore(VkSemaphore *semaphore) { VkResult result; - VkSemaphoreCreateInfo createInfo = {0}; + VkSemaphoreCreateInfo createInfo = { 0 }; createInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; result = vkCreateSemaphore(vulkanContext->device, &createInfo, NULL, semaphore); if (result != VK_SUCCESS) { @@ -563,7 +566,7 @@ static void getSurfaceFormats(void) if (vulkanContext->surfaceFormatsCount > vulkanContext->surfaceFormatsAllocatedCount) { vulkanContext->surfaceFormatsAllocatedCount = vulkanContext->surfaceFormatsCount; SDL_free(vulkanContext->surfaceFormats); - vulkanContext->surfaceFormats = (VkSurfaceFormatKHR *) SDL_malloc(sizeof(VkSurfaceFormatKHR) * vulkanContext->surfaceFormatsAllocatedCount); + vulkanContext->surfaceFormats = (VkSurfaceFormatKHR *)SDL_malloc(sizeof(VkSurfaceFormatKHR) * vulkanContext->surfaceFormatsAllocatedCount); if (!vulkanContext->surfaceFormats) { vulkanContext->surfaceFormatsCount = 0; SDL_OutOfMemory(); @@ -621,19 +624,19 @@ static SDL_bool createSwapchain(void) { uint32_t i; int w, h; - VkSwapchainCreateInfoKHR createInfo = {0}; + VkSwapchainCreateInfoKHR createInfo = { 0 }; VkResult result; // pick an image count vulkanContext->swapchainDesiredImageCount = vulkanContext->surfaceCapabilities.minImageCount + 1; - if ( (vulkanContext->swapchainDesiredImageCount > vulkanContext->surfaceCapabilities.maxImageCount) && - (vulkanContext->surfaceCapabilities.maxImageCount > 0) ) { + if ((vulkanContext->swapchainDesiredImageCount > vulkanContext->surfaceCapabilities.maxImageCount) && + (vulkanContext->surfaceCapabilities.maxImageCount > 0)) { vulkanContext->swapchainDesiredImageCount = vulkanContext->surfaceCapabilities.maxImageCount; } // pick a format - if ( (vulkanContext->surfaceFormatsCount == 1) && - (vulkanContext->surfaceFormats[0].format == VK_FORMAT_UNDEFINED) ) { + if ((vulkanContext->surfaceFormatsCount == 1) && + (vulkanContext->surfaceFormats[0].format == VK_FORMAT_UNDEFINED)) { // aren't any preferred formats, so we pick vulkanContext->surfaceFormat.colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; vulkanContext->surfaceFormat.format = VK_FORMAT_R8G8B8A8_UNORM; @@ -652,13 +655,13 @@ static SDL_bool createSwapchain(void) // Clamp the size to the allowable image extent. // SDL_Vulkan_GetDrawableSize()'s result it not always in this range (bug #3287) - vulkanContext->swapchainSize.width = SDL_clamp((uint32_t) w, - vulkanContext->surfaceCapabilities.minImageExtent.width, - vulkanContext->surfaceCapabilities.maxImageExtent.width); + vulkanContext->swapchainSize.width = SDL_clamp((uint32_t)w, + vulkanContext->surfaceCapabilities.minImageExtent.width, + vulkanContext->surfaceCapabilities.maxImageExtent.width); - vulkanContext->swapchainSize.height = SDL_clamp((uint32_t) h, - vulkanContext->surfaceCapabilities.minImageExtent.height, - vulkanContext->surfaceCapabilities.maxImageExtent.height); + vulkanContext->swapchainSize.height = SDL_clamp((uint32_t)h, + vulkanContext->surfaceCapabilities.minImageExtent.height, + vulkanContext->surfaceCapabilities.maxImageExtent.height); if (w == 0 || h == 0) { return SDL_FALSE; @@ -731,7 +734,7 @@ static void destroyCommandPool(void) static void createCommandPool(void) { VkResult result; - VkCommandPoolCreateInfo createInfo = {0}; + VkCommandPoolCreateInfo createInfo = { 0 }; createInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; createInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT | VK_COMMAND_POOL_CREATE_TRANSIENT_BIT; createInfo.queueFamilyIndex = vulkanContext->graphicsQueueFamilyIndex; @@ -748,12 +751,12 @@ static void createCommandPool(void) static void createCommandBuffers(void) { VkResult result; - VkCommandBufferAllocateInfo allocateInfo = {0}; + VkCommandBufferAllocateInfo allocateInfo = { 0 }; allocateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; allocateInfo.commandPool = vulkanContext->commandPool; allocateInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; allocateInfo.commandBufferCount = vulkanContext->swapchainImageCount; - vulkanContext->commandBuffers = (VkCommandBuffer *) SDL_malloc(sizeof(VkCommandBuffer) * vulkanContext->swapchainImageCount); + vulkanContext->commandBuffers = (VkCommandBuffer *)SDL_malloc(sizeof(VkCommandBuffer) * vulkanContext->swapchainImageCount); result = vkAllocateCommandBuffers(vulkanContext->device, &allocateInfo, vulkanContext->commandBuffers); if (result != VK_SUCCESS) { SDL_free(vulkanContext->commandBuffers); @@ -776,7 +779,7 @@ static void createFences(void) } for (i = 0; i < vulkanContext->swapchainImageCount; i++) { VkResult result; - VkFenceCreateInfo createInfo = {0}; + VkFenceCreateInfo createInfo = { 0 }; createInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; createInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; result = vkCreateFence(vulkanContext->device, &createInfo, NULL, &vulkanContext->fences[i]); @@ -816,7 +819,7 @@ static void recordPipelineImageBarrier(VkCommandBuffer commandBuffer, VkImageLayout destLayout, VkImage image) { - VkImageMemoryBarrier barrier = {0}; + VkImageMemoryBarrier barrier = { 0 }; barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; barrier.srcAccessMask = sourceAccessMask; barrier.dstAccessMask = destAccessMask; @@ -846,8 +849,8 @@ static void rerecordCommandBuffer(uint32_t frameIndex, const VkClearColorValue * { VkCommandBuffer commandBuffer = vulkanContext->commandBuffers[frameIndex]; VkImage image = vulkanContext->swapchainImages[frameIndex]; - VkCommandBufferBeginInfo beginInfo = {0}; - VkImageSubresourceRange clearRange = {0}; + VkCommandBufferBeginInfo beginInfo = { 0 }; + VkImageSubresourceRange clearRange = { 0 }; VkResult result = vkResetCommandBuffer(commandBuffer, 0); if (result != VK_SUCCESS) { @@ -923,7 +926,7 @@ static void initVulkan(void) SDL_Vulkan_LoadLibrary(NULL); - vulkanContexts = (VulkanContext *) SDL_calloc(state->num_windows, sizeof (VulkanContext)); + vulkanContexts = (VulkanContext *)SDL_calloc(state->num_windows, sizeof(VulkanContext)); if (vulkanContexts == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!"); quit(2); @@ -991,10 +994,10 @@ static SDL_bool render(void) uint32_t frameIndex; VkResult result; double currentTime; - VkClearColorValue clearColor = { {0} }; + VkClearColorValue clearColor = { { 0 } }; VkPipelineStageFlags waitDestStageMask = VK_PIPELINE_STAGE_TRANSFER_BIT; - VkSubmitInfo submitInfo = {0}; - VkPresentInfoKHR presentInfo = {0}; + VkSubmitInfo submitInfo = { 0 }; + VkPresentInfoKHR presentInfo = { 0 }; int w, h; if (!vulkanContext->swapchain) { @@ -1005,11 +1008,11 @@ static SDL_bool render(void) return retval; } result = vkAcquireNextImageKHR(vulkanContext->device, - vulkanContext->swapchain, - UINT64_MAX, - vulkanContext->imageAvailableSemaphore, - VK_NULL_HANDLE, - &frameIndex); + vulkanContext->swapchain, + UINT64_MAX, + vulkanContext->imageAvailableSemaphore, + VK_NULL_HANDLE, + &frameIndex); if (result == VK_ERROR_OUT_OF_DATE_KHR) { return createNewSwapchainAndSwapchainSpecificStuff(); } diff --git a/test/testwm2.c b/test/testwm2.c index 7fe8238f1..01c3642a5 100644 --- a/test/testwm2.c +++ b/test/testwm2.c @@ -24,18 +24,18 @@ static SDLTest_CommonState *state; int done; static const char *cursorNames[] = { - "arrow", - "ibeam", - "wait", - "crosshair", - "waitarrow", - "sizeNWSE", - "sizeNESW", - "sizeWE", - "sizeNS", - "sizeALL", - "NO", - "hand", + "arrow", + "ibeam", + "wait", + "crosshair", + "waitarrow", + "sizeNWSE", + "sizeNESW", + "sizeWE", + "sizeNS", + "sizeALL", + "NO", + "hand", }; int system_cursor = -1; SDL_Cursor *cursor = NULL; @@ -108,13 +108,13 @@ draw_modes_menu(SDL_Window *window, SDL_Renderer *renderer, SDL_Rect viewport) } SDL_snprintf(text, sizeof(text), "%d: %dx%d@%dHz", - i, mode.w, mode.h, mode.refresh_rate); + i, mode.w, mode.h, mode.refresh_rate); /* Update column width */ text_length = (int)SDL_strlen(text); column_chars = SDL_max(column_chars, text_length); - /* Check if under mouse */ + /* Check if under mouse */ cell_rect.x = x; cell_rect.y = y; cell_rect.w = text_length * FONT_CHARACTER_SIZE; @@ -143,108 +143,107 @@ draw_modes_menu(SDL_Window *window, SDL_Renderer *renderer, SDL_Rect viewport) } } -void -loop() +void loop() { int i; SDL_Event event; - /* Check for events */ - while (SDL_PollEvent(&event)) { - SDLTest_CommonEvent(state, &event, &done); + /* Check for events */ + while (SDL_PollEvent(&event)) { + SDLTest_CommonEvent(state, &event, &done); - if (event.type == SDL_WINDOWEVENT) { - if (event.window.event == SDL_WINDOWEVENT_RESIZED) { - SDL_Window *window = SDL_GetWindowFromID(event.window.windowID); - if (window) { - SDL_Log("Window %" SDL_PRIu32 " resized to %" SDL_PRIs32 "x%" SDL_PRIs32 "\n", - event.window.windowID, - event.window.data1, - event.window.data2); - } - } - if (event.window.event == SDL_WINDOWEVENT_MOVED) { - SDL_Window *window = SDL_GetWindowFromID(event.window.windowID); - if (window) { - SDL_Log("Window %" SDL_PRIu32 " moved to %" SDL_PRIs32 ",%" SDL_PRIs32 " (display %s)\n", - event.window.windowID, - event.window.data1, - event.window.data2, - SDL_GetDisplayName(SDL_GetWindowDisplayIndex(window))); - } - } - if (event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) { - relative_mode = SDL_GetRelativeMouseMode(); - if (relative_mode) { - SDL_SetRelativeMouseMode(SDL_FALSE); - } - } - if (event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED) { - if (relative_mode) { - SDL_SetRelativeMouseMode(SDL_TRUE); - } + if (event.type == SDL_WINDOWEVENT) { + if (event.window.event == SDL_WINDOWEVENT_RESIZED) { + SDL_Window *window = SDL_GetWindowFromID(event.window.windowID); + if (window) { + SDL_Log("Window %" SDL_PRIu32 " resized to %" SDL_PRIs32 "x%" SDL_PRIs32 "\n", + event.window.windowID, + event.window.data1, + event.window.data2); } } - if (event.type == SDL_KEYUP) { - SDL_bool updateCursor = SDL_FALSE; - - if (event.key.keysym.sym == SDLK_LEFT) { - --system_cursor; - if (system_cursor < 0) { - system_cursor = SDL_NUM_SYSTEM_CURSORS - 1; - } - updateCursor = SDL_TRUE; - } else if (event.key.keysym.sym == SDLK_RIGHT) { - ++system_cursor; - if (system_cursor >= SDL_NUM_SYSTEM_CURSORS) { - system_cursor = 0; - } - updateCursor = SDL_TRUE; - } - if (updateCursor) { - SDL_Log("Changing cursor to \"%s\"", cursorNames[system_cursor]); - SDL_FreeCursor(cursor); - cursor = SDL_CreateSystemCursor((SDL_SystemCursor)system_cursor); - SDL_SetCursor(cursor); + if (event.window.event == SDL_WINDOWEVENT_MOVED) { + SDL_Window *window = SDL_GetWindowFromID(event.window.windowID); + if (window) { + SDL_Log("Window %" SDL_PRIu32 " moved to %" SDL_PRIs32 ",%" SDL_PRIs32 " (display %s)\n", + event.window.windowID, + event.window.data1, + event.window.data2, + SDL_GetDisplayName(SDL_GetWindowDisplayIndex(window))); } } - if (event.type == SDL_MOUSEBUTTONUP) { - SDL_Window* window = SDL_GetMouseFocus(); - if (highlighted_mode != -1 && window != NULL) { - const int display_index = SDL_GetWindowDisplayIndex(window); - SDL_DisplayMode mode; - if (0 != SDL_GetDisplayMode(display_index, highlighted_mode, &mode)) { - SDL_Log("Couldn't get display mode"); - } else { - SDL_SetWindowDisplayMode(window, &mode); - } + if (event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) { + relative_mode = SDL_GetRelativeMouseMode(); + if (relative_mode) { + SDL_SetRelativeMouseMode(SDL_FALSE); + } + } + if (event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED) { + if (relative_mode) { + SDL_SetRelativeMouseMode(SDL_TRUE); } } } + if (event.type == SDL_KEYUP) { + SDL_bool updateCursor = SDL_FALSE; - for (i = 0; i < state->num_windows; ++i) { - SDL_Window* window = state->windows[i]; - SDL_Renderer *renderer = state->renderers[i]; - if (window != NULL && renderer != NULL) { - int y = 0; - SDL_Rect viewport, menurect; - - SDL_RenderGetViewport(renderer, &viewport); - - SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); - SDL_RenderClear(renderer); - - SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); - SDLTest_CommonDrawWindowInfo(renderer, state->windows[i], &y); - - menurect.x = 0; - menurect.y = y; - menurect.w = viewport.w; - menurect.h = viewport.h - y; - draw_modes_menu(window, renderer, menurect); - - SDL_RenderPresent(renderer); + if (event.key.keysym.sym == SDLK_LEFT) { + --system_cursor; + if (system_cursor < 0) { + system_cursor = SDL_NUM_SYSTEM_CURSORS - 1; + } + updateCursor = SDL_TRUE; + } else if (event.key.keysym.sym == SDLK_RIGHT) { + ++system_cursor; + if (system_cursor >= SDL_NUM_SYSTEM_CURSORS) { + system_cursor = 0; + } + updateCursor = SDL_TRUE; + } + if (updateCursor) { + SDL_Log("Changing cursor to \"%s\"", cursorNames[system_cursor]); + SDL_FreeCursor(cursor); + cursor = SDL_CreateSystemCursor((SDL_SystemCursor)system_cursor); + SDL_SetCursor(cursor); } } + if (event.type == SDL_MOUSEBUTTONUP) { + SDL_Window *window = SDL_GetMouseFocus(); + if (highlighted_mode != -1 && window != NULL) { + const int display_index = SDL_GetWindowDisplayIndex(window); + SDL_DisplayMode mode; + if (0 != SDL_GetDisplayMode(display_index, highlighted_mode, &mode)) { + SDL_Log("Couldn't get display mode"); + } else { + SDL_SetWindowDisplayMode(window, &mode); + } + } + } + } + + for (i = 0; i < state->num_windows; ++i) { + SDL_Window *window = state->windows[i]; + SDL_Renderer *renderer = state->renderers[i]; + if (window != NULL && renderer != NULL) { + int y = 0; + SDL_Rect viewport, menurect; + + SDL_RenderGetViewport(renderer, &viewport); + + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_RenderClear(renderer); + + SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + SDLTest_CommonDrawWindowInfo(renderer, state->windows[i], &y); + + menurect.x = 0; + menurect.y = y; + menurect.w = viewport.w; + menurect.h = viewport.h - y; + draw_modes_menu(window, renderer, menurect); + + SDL_RenderPresent(renderer); + } + } #ifdef __EMSCRIPTEN__ if (done) { emscripten_cancel_main_loop(); @@ -252,8 +251,7 @@ loop() #endif } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i; @@ -281,7 +279,7 @@ main(int argc, char *argv[]) SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); SDL_RenderClear(renderer); } - + /* Main render loop */ done = 0; #ifdef __EMSCRIPTEN__ diff --git a/test/testyuv.c b/test/testyuv.c index a09490637..788a65acb 100644 --- a/test/testyuv.c +++ b/test/testyuv.c @@ -17,10 +17,8 @@ #include "SDL_test_font.h" #include "testyuv_cvt.h" - /* 422 (YUY2, etc) formats are the largest */ -#define MAX_YUV_SURFACE_SIZE(W, H, P) (H*4*(W+P+1)/2) - +#define MAX_YUV_SURFACE_SIZE(W, H, P) (H * 4 * (W + P + 1) / 2) /* Return true if the YUV format is packed pixels */ static SDL_bool is_packed_yuv_format(Uint32 format) @@ -36,12 +34,12 @@ static SDL_Surface *generate_test_pattern(int pattern_size) if (pattern) { int i, x, y; Uint8 *p, c; - const int thickness = 2; /* Important so 2x2 blocks of color are the same, to avoid Cr/Cb interpolation over pixels */ + const int thickness = 2; /* Important so 2x2 blocks of color are the same, to avoid Cr/Cb interpolation over pixels */ /* R, G, B in alternating horizontal bands */ for (y = 0; y < pattern->h; y += thickness) { for (i = 0; i < thickness; ++i) { - p = (Uint8 *)pattern->pixels + (y + i) * pattern->pitch + ((y/thickness) % 3); + p = (Uint8 *)pattern->pixels + (y + i) * pattern->pitch + ((y / thickness) % 3); for (x = 0; x < pattern->w; ++x) { *p = 0xFF; p += 3; @@ -51,9 +49,9 @@ static SDL_Surface *generate_test_pattern(int pattern_size) /* Black and white in alternating vertical bands */ c = 0xFF; - for (x = 1*thickness; x < pattern->w; x += 2*thickness) { + for (x = 1 * thickness; x < pattern->w; x += 2 * thickness) { for (i = 0; i < thickness; ++i) { - p = (Uint8 *)pattern->pixels + (x + i)*3; + p = (Uint8 *)pattern->pixels + (x + i) * 3; for (y = 0; y < pattern->h; ++y) { SDL_memset(p, c, 3); p += pattern->pitch; @@ -127,7 +125,7 @@ static int run_automated_tests(int pattern_size, int extra_pitch) Uint8 *yuv2 = (Uint8 *)SDL_malloc(yuv_len); int yuv1_pitch, yuv2_pitch; int result = -1; - + if (pattern == NULL || yuv1 == NULL || yuv2 == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't allocate test surfaces"); goto done; @@ -204,7 +202,6 @@ static int run_automated_tests(int pattern_size, int extra_pitch) } } - result = 0; done: @@ -214,10 +211,10 @@ done: return result; } -int -main(int argc, char **argv) +int main(int argc, char **argv) { - struct { + struct + { SDL_bool enable_intrinsics; int pattern_size; int extra_pitch; @@ -313,10 +310,10 @@ main(int argc, char **argv) /* Run automated tests */ if (should_run_automated_tests) { for (i = 0; i < SDL_arraysize(automated_test_params); ++i) { - SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Running automated test, pattern size %d, extra pitch %d, intrinsics %s\n", - automated_test_params[i].pattern_size, - automated_test_params[i].extra_pitch, - automated_test_params[i].enable_intrinsics ? "enabled" : "disabled"); + SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Running automated test, pattern size %d, extra pitch %d, intrinsics %s\n", + automated_test_params[i].pattern_size, + automated_test_params[i].extra_pitch, + automated_test_params[i].enable_intrinsics ? "enabled" : "disabled"); if (run_automated_tests(automated_test_params[i].pattern_size, automated_test_params[i].extra_pitch) < 0) { return 2; } @@ -337,8 +334,8 @@ main(int argc, char **argv) raw_yuv = SDL_calloc(1, MAX_YUV_SURFACE_SIZE(original->w, original->h, 0)); ConvertRGBtoYUV(yuv_format, original->pixels, original->pitch, raw_yuv, original->w, original->h, - SDL_GetYUVConversionModeForResolution(original->w, original->h), - 0, 100); + SDL_GetYUVConversionModeForResolution(original->w, original->h), + 0, 100); pitch = CalculateYUVPitch(yuv_format, original->w); converted = SDL_CreateRGBSurfaceWithFormat(0, original->w, original->h, 0, rgb_format); @@ -348,11 +345,11 @@ main(int argc, char **argv) } then = SDL_GetTicks(); - for ( i = 0; i < iterations; ++i ) { + for (i = 0; i < iterations; ++i) { SDL_ConvertPixels(original->w, original->h, yuv_format, raw_yuv, pitch, rgb_format, converted->pixels, converted->pitch); } now = SDL_GetTicks(); - SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "%" SDL_PRIu32 " iterations in %" SDL_PRIu32 " ms, %.2fms each\n", iterations, (now - then), (float) (now - then) / iterations); + SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "%" SDL_PRIu32 " iterations in %" SDL_PRIu32 " ms, %.2fms each\n", iterations, (now - then), (float)(now - then) / iterations); window = SDL_CreateWindow("YUV test", SDL_WINDOWPOS_UNDEFINED, @@ -378,7 +375,7 @@ main(int argc, char **argv) return 5; } SDL_UpdateTexture(output[2], NULL, raw_yuv, pitch); - + yuv_name = SDL_GetPixelFormatName(yuv_format); if (SDL_strncmp(yuv_name, "SDL_PIXELFORMAT_", 16) == 0) { yuv_name += 16; @@ -399,8 +396,9 @@ main(int argc, char **argv) break; } - { int done = 0; - while ( !done ) { + { + int done = 0; + while (!done) { SDL_Event event; while (SDL_PollEvent(&event) > 0) { if (event.type == SDL_QUIT) { @@ -416,7 +414,7 @@ main(int argc, char **argv) } } if (event.type == SDL_MOUSEBUTTONDOWN) { - if (event.button.x < (original->w/2)) { + if (event.button.x < (original->w / 2)) { --current; } else { ++current; diff --git a/test/testyuv_cvt.c b/test/testyuv_cvt.c index f058f5c54..4c9ebdbe3 100644 --- a/test/testyuv_cvt.c +++ b/test/testyuv_cvt.c @@ -14,13 +14,12 @@ #include "testyuv_cvt.h" - static float clip3(float x, float y, float z) { return (z < x) ? x : ((z > y) ? y : z); } -static void RGBtoYUV(Uint8 * rgb, int *yuv, SDL_YUV_CONVERSION_MODE mode, int monochrome, int luminance) +static void RGBtoYUV(Uint8 *rgb, int *yuv, SDL_YUV_CONVERSION_MODE mode, int monochrome, int luminance) { if (mode == SDL_YUV_CONVERSION_JPEG) { /* Full range YUV */ @@ -52,9 +51,9 @@ static void RGBtoYUV(Uint8 * rgb, int *yuv, SDL_YUV_CONVERSION_MODE mode, int mo G = rgb[1]; B = rgb[2]; L = Kr * R + Kb * B + (1 - Kr - Kb) * G; - Y = (Uint8)SDL_floorf((219*(L-Z)/S + 16) + 0.5f); - U = (Uint8)clip3(0, 255, SDL_floorf((112.0f*(B-L) / ((1.0f-Kb)*S) + 128) + 0.5f)); - V = (Uint8)clip3(0, 255, SDL_floorf((112.0f*(R-L) / ((1.0f-Kr)*S) + 128) + 0.5f)); + Y = (Uint8)SDL_floorf((219 * (L - Z) / S + 16) + 0.5f); + U = (Uint8)clip3(0, 255, SDL_floorf((112.0f * (B - L) / ((1.0f - Kb) * S) + 128) + 0.5f)); + V = (Uint8)clip3(0, 255, SDL_floorf((112.0f * (R - L) / ((1.0f - Kr) * S) + 128) + 0.5f)); yuv[0] = (Uint8)Y; yuv[1] = (Uint8)U; @@ -80,7 +79,7 @@ static void ConvertRGBtoPlanar2x2(Uint32 format, Uint8 *src, int pitch, Uint8 *o int yuv[4][3]; Uint8 *Y1, *Y2, *U, *V; Uint8 *rgb1, *rgb2; - int rgb_row_advance = (pitch - w*3) + pitch; + int rgb_row_advance = (pitch - w * 3) + pitch; int UV_advance; rgb1 = src; @@ -91,12 +90,12 @@ static void ConvertRGBtoPlanar2x2(Uint32 format, Uint8 *src, int pitch, Uint8 *o switch (format) { case SDL_PIXELFORMAT_YV12: V = (Y1 + h * w); - U = V + ((h + 1)/2)*((w + 1)/2); + U = V + ((h + 1) / 2) * ((w + 1) / 2); UV_advance = 1; break; case SDL_PIXELFORMAT_IYUV: U = (Y1 + h * w); - V = U + ((h + 1)/2)*((w + 1)/2); + V = U + ((h + 1) / 2) * ((w + 1) / 2); UV_advance = 1; break; case SDL_PIXELFORMAT_NV12: @@ -132,10 +131,10 @@ static void ConvertRGBtoPlanar2x2(Uint32 format, Uint8 *src, int pitch, Uint8 *o rgb2 += 3; *Y2++ = (Uint8)yuv[3][0]; - *U = (Uint8)SDL_floorf((yuv[0][1] + yuv[1][1] + yuv[2][1] + yuv[3][1])/4.0f + 0.5f); + *U = (Uint8)SDL_floorf((yuv[0][1] + yuv[1][1] + yuv[2][1] + yuv[3][1]) / 4.0f + 0.5f); U += UV_advance; - *V = (Uint8)SDL_floorf((yuv[0][2] + yuv[1][2] + yuv[2][2] + yuv[3][2])/4.0f + 0.5f); + *V = (Uint8)SDL_floorf((yuv[0][2] + yuv[1][2] + yuv[2][2] + yuv[3][2]) / 4.0f + 0.5f); V += UV_advance; } /* Last column */ @@ -148,10 +147,10 @@ static void ConvertRGBtoPlanar2x2(Uint32 format, Uint8 *src, int pitch, Uint8 *o rgb2 += 3; *Y2++ = (Uint8)yuv[2][0]; - *U = (Uint8)SDL_floorf((yuv[0][1] + yuv[2][1])/2.0f + 0.5f); + *U = (Uint8)SDL_floorf((yuv[0][1] + yuv[2][1]) / 2.0f + 0.5f); U += UV_advance; - *V = (Uint8)SDL_floorf((yuv[0][2] + yuv[2][2])/2.0f + 0.5f); + *V = (Uint8)SDL_floorf((yuv[0][2] + yuv[2][2]) / 2.0f + 0.5f); V += UV_advance; } Y1 += w; @@ -170,10 +169,10 @@ static void ConvertRGBtoPlanar2x2(Uint32 format, Uint8 *src, int pitch, Uint8 *o rgb1 += 3; *Y1++ = (Uint8)yuv[1][0]; - *U = (Uint8)SDL_floorf((yuv[0][1] + yuv[1][1])/2.0f + 0.5f); + *U = (Uint8)SDL_floorf((yuv[0][1] + yuv[1][1]) / 2.0f + 0.5f); U += UV_advance; - *V = (Uint8)SDL_floorf((yuv[0][2] + yuv[1][2])/2.0f + 0.5f); + *V = (Uint8)SDL_floorf((yuv[0][2] + yuv[1][2]) / 2.0f + 0.5f); V += UV_advance; } /* Last column */ @@ -196,28 +195,28 @@ static void ConvertRGBtoPacked4(Uint32 format, Uint8 *src, int pitch, Uint8 *out int yuv[2][3]; Uint8 *Y1, *Y2, *U, *V; Uint8 *rgb; - int rgb_row_advance = (pitch - w*3); + int rgb_row_advance = (pitch - w * 3); rgb = src; switch (format) { case SDL_PIXELFORMAT_YUY2: Y1 = out; - U = out+1; - Y2 = out+2; - V = out+3; + U = out + 1; + Y2 = out + 2; + V = out + 3; break; case SDL_PIXELFORMAT_UYVY: U = out; - Y1 = out+1; - V = out+2; - Y2 = out+3; + Y1 = out + 1; + V = out + 2; + Y2 = out + 3; break; case SDL_PIXELFORMAT_YVYU: Y1 = out; - V = out+1; - Y2 = out+2; - U = out+3; + V = out + 1; + Y2 = out + 2; + U = out + 3; break; default: SDL_assert(!"Unsupported packed YUV format"); @@ -236,10 +235,10 @@ static void ConvertRGBtoPacked4(Uint32 format, Uint8 *src, int pitch, Uint8 *out *Y2 = (Uint8)yuv[1][0]; Y2 += 4; - *U = (Uint8)SDL_floorf((yuv[0][1] + yuv[1][1])/2.0f + 0.5f); + *U = (Uint8)SDL_floorf((yuv[0][1] + yuv[1][1]) / 2.0f + 0.5f); U += 4; - *V = (Uint8)SDL_floorf((yuv[0][2] + yuv[1][2])/2.0f + 0.5f); + *V = (Uint8)SDL_floorf((yuv[0][2] + yuv[1][2]) / 2.0f + 0.5f); V += 4; } /* Last column */ @@ -262,8 +261,7 @@ static void ConvertRGBtoPacked4(Uint32 format, Uint8 *src, int pitch, Uint8 *out SDL_bool ConvertRGBtoYUV(Uint32 format, Uint8 *src, int pitch, Uint8 *out, int w, int h, SDL_YUV_CONVERSION_MODE mode, int monochrome, int luminance) { - switch (format) - { + switch (format) { case SDL_PIXELFORMAT_YV12: case SDL_PIXELFORMAT_IYUV: case SDL_PIXELFORMAT_NV12: @@ -282,8 +280,7 @@ SDL_bool ConvertRGBtoYUV(Uint32 format, Uint8 *src, int pitch, Uint8 *out, int w int CalculateYUVPitch(Uint32 format, int width) { - switch (format) - { + switch (format) { case SDL_PIXELFORMAT_YV12: case SDL_PIXELFORMAT_IYUV: case SDL_PIXELFORMAT_NV12: diff --git a/test/torturethread.c b/test/torturethread.c index 8c67569d6..6835e020b 100644 --- a/test/torturethread.c +++ b/test/torturethread.c @@ -34,8 +34,8 @@ quit(int rc) int SDLCALL SubThreadFunc(void *data) { - while (!*(int volatile *) data) { - ; /* SDL_Delay(10); *//* do nothing */ + while (!*(int volatile *)data) { + ; /* SDL_Delay(10); */ /* do nothing */ } return 0; } @@ -46,20 +46,20 @@ ThreadFunc(void *data) SDL_Thread *sub_threads[NUMTHREADS]; int flags[NUMTHREADS]; int i; - int tid = (int) (uintptr_t) data; + int tid = (int)(uintptr_t)data; SDL_Log("Creating Thread %d\n", tid); for (i = 0; i < NUMTHREADS; i++) { char name[64]; - SDL_snprintf(name, sizeof (name), "Child%d_%d", tid, i); + SDL_snprintf(name, sizeof(name), "Child%d_%d", tid, i); flags[i] = 0; sub_threads[i] = SDL_CreateThread(SubThreadFunc, name, &flags[i]); } SDL_Log("Thread '%d' waiting for signal\n", tid); while (SDL_AtomicGet(&time_for_threads_to_die[tid]) != 1) { - ; /* do nothing */ + ; /* do nothing */ } SDL_Log("Thread '%d' sending signals to subthreads\n", tid); @@ -73,8 +73,7 @@ ThreadFunc(void *data) return 0; } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { SDL_Thread *threads[NUMTHREADS]; int i; @@ -91,9 +90,9 @@ main(int argc, char *argv[]) signal(SIGSEGV, SIG_DFL); for (i = 0; i < NUMTHREADS; i++) { char name[64]; - SDL_snprintf(name, sizeof (name), "Parent%d", i); + SDL_snprintf(name, sizeof(name), "Parent%d", i); SDL_AtomicSet(&time_for_threads_to_die[i], 0); - threads[i] = SDL_CreateThread(ThreadFunc, name, (void*) (uintptr_t) i); + threads[i] = SDL_CreateThread(ThreadFunc, name, (void *)(uintptr_t)i); if (threads[i] == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());